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:
authorRohan Rathi <rohanrathi08@gmail.com>2018-07-21 16:59:15 +0300
committerRohan Rathi <rohanrathi08@gmail.com>2018-07-21 16:59:15 +0300
commit4e6bcd10e559ab541df53a3d7b645faac1a7fe27 (patch)
treeba214c23868fe76ec5d2199b83846814bf79be25
parentb6b185691f018f6b175ffb58c65418991cda75f2 (diff)
parente361e9e99c5b6140b6284e81fa315bdcc48cee58 (diff)
Merge branch 'blender2.8' into soc-2018-bevel
-rw-r--r--CMakeLists.txt6
-rw-r--r--GNUmakefile8
-rw-r--r--build_files/buildbot/slave_compile.py8
-rw-r--r--build_files/cmake/macros.cmake6
-rw-r--r--build_files/windows/autodetect_msvc.cmd5
-rw-r--r--build_files/windows/check_libraries.cmd1
-rw-r--r--build_files/windows/detect_msvc2013.cmd3
-rw-r--r--build_files/windows/parse_arguments.cmd2
-rw-r--r--build_files/windows/show_help.cmd8
-rwxr-xr-xdoc/blender_file_format/BlendFileDnaExporter_25.py168
-rw-r--r--doc/blender_file_format/BlendFileReader.py126
-rwxr-xr-xdoc/manpage/blender.1.py1
-rw-r--r--doc/python_api/sphinx_doc_gen.py13
-rw-r--r--doc/python_api/sphinx_doc_gen_monkeypatch.py2
-rwxr-xr-xdoc/python_api/sphinx_doc_update.py15
-rw-r--r--intern/CMakeLists.txt1
-rw-r--r--intern/cycles/app/CMakeLists.txt5
-rw-r--r--intern/cycles/app/cycles_cubin_cc.cpp2
-rw-r--r--intern/cycles/app/cycles_server.cpp1
-rw-r--r--intern/cycles/app/cycles_standalone.cpp1
-rw-r--r--intern/cycles/app/cycles_xml.cpp3
-rw-r--r--intern/cycles/app/io_export_cycles_xml.py22
-rw-r--r--intern/cycles/blender/addon/__init__.py6
-rw-r--r--intern/cycles/blender/addon/engine.py15
-rw-r--r--intern/cycles/blender/addon/properties.py1608
-rw-r--r--intern/cycles/blender/addon/ui.py119
-rw-r--r--intern/cycles/blender/addon/version_update.py116
-rw-r--r--intern/cycles/blender/blender_camera.cpp7
-rw-r--r--intern/cycles/blender/blender_mesh.cpp12
-rw-r--r--intern/cycles/blender/blender_object.cpp77
-rw-r--r--intern/cycles/blender/blender_object_cull.cpp1
-rw-r--r--intern/cycles/blender/blender_particles.cpp2
-rw-r--r--intern/cycles/blender/blender_python.cpp4
-rw-r--r--intern/cycles/blender/blender_shader.cpp74
-rw-r--r--intern/cycles/blender/blender_sync.cpp51
-rw-r--r--intern/cycles/blender/blender_sync.h6
-rw-r--r--intern/cycles/bvh/bvh_binning.cpp1
-rw-r--r--intern/cycles/bvh/bvh_node.cpp5
-rw-r--r--intern/cycles/bvh/bvh_sort.cpp1
-rw-r--r--intern/cycles/device/device.h7
-rw-r--r--intern/cycles/device/device_cpu.cpp46
-rw-r--r--intern/cycles/device/device_cuda.cpp39
-rw-r--r--intern/cycles/device/device_denoising.cpp332
-rw-r--r--intern/cycles/device/device_denoising.h37
-rw-r--r--intern/cycles/device/device_intern.h1
-rw-r--r--intern/cycles/device/device_memory.cpp21
-rw-r--r--intern/cycles/device/device_memory.h22
-rw-r--r--intern/cycles/device/device_multi.cpp45
-rw-r--r--intern/cycles/device/device_network.cpp2
-rw-r--r--intern/cycles/device/device_network.h7
-rw-r--r--intern/cycles/device/device_opencl.cpp4
-rw-r--r--intern/cycles/device/device_split_kernel.cpp4
-rw-r--r--intern/cycles/device/device_split_kernel.h3
-rw-r--r--intern/cycles/device/device_task.cpp1
-rw-r--r--intern/cycles/device/device_task.h1
-rw-r--r--intern/cycles/device/opencl/memory_manager.cpp1
-rw-r--r--intern/cycles/device/opencl/memory_manager.h1
-rw-r--r--intern/cycles/device/opencl/opencl.h17
-rw-r--r--intern/cycles/device/opencl/opencl_base.cpp69
-rw-r--r--intern/cycles/device/opencl/opencl_mega.cpp4
-rw-r--r--intern/cycles/device/opencl/opencl_split.cpp4
-rw-r--r--intern/cycles/device/opencl/opencl_util.cpp38
-rw-r--r--intern/cycles/doc/license/Apache_2.0.txt1
-rw-r--r--intern/cycles/doc/license/ILM.txt3
-rw-r--r--intern/cycles/doc/license/NVidia.txt1
-rw-r--r--intern/cycles/doc/license/OSL.txt1
-rw-r--r--intern/cycles/doc/license/Sobol.txt1
-rw-r--r--intern/cycles/doc/license/readme.txt1
-rw-r--r--intern/cycles/graph/node.cpp1
-rw-r--r--intern/cycles/graph/node.h1
-rw-r--r--intern/cycles/graph/node_enum.h1
-rw-r--r--intern/cycles/graph/node_type.cpp1
-rw-r--r--intern/cycles/graph/node_type.h1
-rw-r--r--intern/cycles/graph/node_xml.cpp1
-rw-r--r--intern/cycles/graph/node_xml.h1
-rw-r--r--intern/cycles/kernel/CMakeLists.txt2
-rw-r--r--intern/cycles/kernel/closure/bsdf.h15
-rw-r--r--intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h2
-rw-r--r--intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h5
-rw-r--r--intern/cycles/kernel/closure/bsdf_diffuse.h3
-rw-r--r--intern/cycles/kernel/closure/bsdf_diffuse_ramp.h4
-rw-r--r--intern/cycles/kernel/closure/bsdf_hair.h1
-rw-r--r--intern/cycles/kernel/closure/bsdf_hair_principled.h502
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet.h11
-rw-r--r--intern/cycles/kernel/closure/bsdf_phong_ramp.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_principled_diffuse.h2
-rw-r--r--intern/cycles/kernel/closure/bsdf_principled_sheen.h2
-rw-r--r--intern/cycles/kernel/closure/bsdf_reflection.h1
-rw-r--r--intern/cycles/kernel/closure/bsdf_refraction.h1
-rw-r--r--intern/cycles/kernel/closure/bsdf_toon.h11
-rw-r--r--intern/cycles/kernel/closure/bsdf_transparent.h1
-rw-r--r--intern/cycles/kernel/closure/bsdf_util.h5
-rw-r--r--intern/cycles/kernel/closure/bssrdf.h1
-rw-r--r--intern/cycles/kernel/closure/emissive.h3
-rw-r--r--intern/cycles/kernel/closure/volume.h2
-rw-r--r--intern/cycles/kernel/filter/filter_defines.h37
-rw-r--r--intern/cycles/kernel/filter/filter_prefilter.h20
-rw-r--r--intern/cycles/kernel/geom/geom.h1
-rw-r--r--intern/cycles/kernel/geom/geom_attribute.h5
-rw-r--r--intern/cycles/kernel/geom/geom_curve.h27
-rw-r--r--intern/cycles/kernel/geom/geom_curve_intersect.h25
-rw-r--r--intern/cycles/kernel/geom/geom_motion_curve.h1
-rw-r--r--intern/cycles/kernel/geom/geom_motion_triangle.h4
-rw-r--r--intern/cycles/kernel/geom/geom_motion_triangle_shader.h1
-rw-r--r--intern/cycles/kernel/geom/geom_object.h1
-rw-r--r--intern/cycles/kernel/geom/geom_patch.h1
-rw-r--r--intern/cycles/kernel/geom/geom_primitive.h3
-rw-r--r--intern/cycles/kernel/geom/geom_subd_triangle.h1
-rw-r--r--intern/cycles/kernel/geom/geom_volume.h1
-rw-r--r--intern/cycles/kernel/kernel.h1
-rw-r--r--intern/cycles/kernel/kernel_accumulate.h2
-rw-r--r--intern/cycles/kernel/kernel_bake.h1
-rw-r--r--intern/cycles/kernel/kernel_compat_cpu.h1
-rw-r--r--intern/cycles/kernel/kernel_compat_opencl.h7
-rw-r--r--intern/cycles/kernel/kernel_differential.h1
-rw-r--r--intern/cycles/kernel/kernel_emission.h3
-rw-r--r--intern/cycles/kernel/kernel_film.h1
-rw-r--r--intern/cycles/kernel/kernel_jitter.h1
-rw-r--r--intern/cycles/kernel/kernel_montecarlo.h2
-rw-r--r--intern/cycles/kernel/kernel_passes.h5
-rw-r--r--intern/cycles/kernel/kernel_path.h1
-rw-r--r--intern/cycles/kernel/kernel_path_state.h1
-rw-r--r--intern/cycles/kernel/kernel_path_subsurface.h1
-rw-r--r--intern/cycles/kernel/kernel_path_surface.h1
-rw-r--r--intern/cycles/kernel/kernel_path_volume.h7
-rw-r--r--intern/cycles/kernel/kernel_projection.h2
-rw-r--r--intern/cycles/kernel/kernel_random.h1
-rw-r--r--intern/cycles/kernel/kernel_subsurface.h3
-rw-r--r--intern/cycles/kernel/kernel_textures.h1
-rw-r--r--intern/cycles/kernel/kernel_types.h9
-rw-r--r--intern/cycles/kernel/kernel_volume.h18
-rw-r--r--intern/cycles/kernel/kernels/cpu/filter_cpu.h4
-rw-r--r--intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h8
-rw-r--r--intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h32
-rw-r--r--intern/cycles/kernel/kernels/cpu/kernel_split.cpp1
-rw-r--r--intern/cycles/kernel/kernels/cuda/filter.cu8
-rw-r--r--intern/cycles/kernel/kernels/cuda/kernel_config.h1
-rw-r--r--intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h9
-rw-r--r--intern/cycles/kernel/kernels/opencl/filter.cl32
-rw-r--r--intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h23
-rw-r--r--intern/cycles/kernel/kernels/opencl/kernel_split_function.h1
-rw-r--r--intern/cycles/kernel/osl/background.cpp3
-rw-r--r--intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp3
-rw-r--r--intern/cycles/kernel/osl/bsdf_phong_ramp.cpp3
-rw-r--r--intern/cycles/kernel/osl/emissive.cpp3
-rw-r--r--intern/cycles/kernel/osl/osl_bssrdf.cpp3
-rw-r--r--intern/cycles/kernel/osl/osl_closures.cpp64
-rw-r--r--intern/cycles/kernel/osl/osl_closures.h4
-rw-r--r--intern/cycles/kernel/osl/osl_globals.h1
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp10
-rw-r--r--intern/cycles/kernel/osl/osl_services.h9
-rw-r--r--intern/cycles/kernel/osl/osl_shader.cpp5
-rw-r--r--intern/cycles/kernel/osl/osl_shader.h1
-rw-r--r--intern/cycles/kernel/shaders/CMakeLists.txt1
-rw-r--r--intern/cycles/kernel/shaders/node_color.h3
-rw-r--r--intern/cycles/kernel/shaders/node_fresnel.h3
-rw-r--r--intern/cycles/kernel/shaders/node_math.osl20
-rw-r--r--intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl105
-rw-r--r--intern/cycles/kernel/shaders/node_ramp_util.h2
-rw-r--r--intern/cycles/kernel/shaders/node_texture.h13
-rw-r--r--intern/cycles/kernel/shaders/node_voronoi_texture.osl122
-rw-r--r--intern/cycles/kernel/shaders/stdosl.h5
-rw-r--r--intern/cycles/kernel/split/kernel_branched.h1
-rw-r--r--intern/cycles/kernel/split/kernel_lamp_emission.h1
-rw-r--r--intern/cycles/kernel/split/kernel_shadow_blocked_ao.h1
-rw-r--r--intern/cycles/kernel/svm/svm.h1
-rw-r--r--intern/cycles/kernel/svm/svm_attribute.h1
-rw-r--r--intern/cycles/kernel/svm/svm_bevel.h1
-rw-r--r--intern/cycles/kernel/svm/svm_brick.h21
-rw-r--r--intern/cycles/kernel/svm/svm_bump.h1
-rw-r--r--intern/cycles/kernel/svm/svm_camera.h1
-rw-r--r--intern/cycles/kernel/svm/svm_checker.h5
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h127
-rw-r--r--intern/cycles/kernel/svm/svm_color_util.h9
-rw-r--r--intern/cycles/kernel/svm/svm_convert.h1
-rw-r--r--intern/cycles/kernel/svm/svm_displace.h1
-rw-r--r--intern/cycles/kernel/svm/svm_fresnel.h3
-rw-r--r--intern/cycles/kernel/svm/svm_geometry.h1
-rw-r--r--intern/cycles/kernel/svm/svm_gradient.h3
-rw-r--r--intern/cycles/kernel/svm/svm_hsv.h1
-rw-r--r--intern/cycles/kernel/svm/svm_image.h1
-rw-r--r--intern/cycles/kernel/svm/svm_invert.h1
-rw-r--r--intern/cycles/kernel/svm/svm_light_path.h1
-rw-r--r--intern/cycles/kernel/svm/svm_magic.h1
-rw-r--r--intern/cycles/kernel/svm/svm_mapping.h1
-rw-r--r--intern/cycles/kernel/svm/svm_math.h1
-rw-r--r--intern/cycles/kernel/svm/svm_math_util.h11
-rw-r--r--intern/cycles/kernel/svm/svm_mix.h1
-rw-r--r--intern/cycles/kernel/svm/svm_musgrave.h3
-rw-r--r--intern/cycles/kernel/svm/svm_noise.h62
-rw-r--r--intern/cycles/kernel/svm/svm_noisetex.h1
-rw-r--r--intern/cycles/kernel/svm/svm_normal.h1
-rw-r--r--intern/cycles/kernel/svm/svm_ramp.h1
-rw-r--r--intern/cycles/kernel/svm/svm_ramp_util.h1
-rw-r--r--intern/cycles/kernel/svm/svm_sepcomb_hsv.h9
-rw-r--r--intern/cycles/kernel/svm/svm_sepcomb_vector.h1
-rw-r--r--intern/cycles/kernel/svm/svm_sky.h19
-rw-r--r--intern/cycles/kernel/svm/svm_tex_coord.h3
-rw-r--r--intern/cycles/kernel/svm/svm_texture.h1
-rw-r--r--intern/cycles/kernel/svm/svm_types.h32
-rw-r--r--intern/cycles/kernel/svm/svm_value.h1
-rw-r--r--intern/cycles/kernel/svm/svm_vector_transform.h19
-rw-r--r--intern/cycles/kernel/svm/svm_voronoi.h198
-rw-r--r--intern/cycles/kernel/svm/svm_wave.h1
-rw-r--r--intern/cycles/kernel/svm/svm_wavelength.h11
-rw-r--r--intern/cycles/kernel/svm/svm_wireframe.h3
-rw-r--r--intern/cycles/render/attribute.cpp9
-rw-r--r--intern/cycles/render/attribute.h1
-rw-r--r--intern/cycles/render/background.cpp3
-rw-r--r--intern/cycles/render/background.h1
-rw-r--r--intern/cycles/render/bake.h1
-rw-r--r--intern/cycles/render/buffers.cpp1
-rw-r--r--intern/cycles/render/buffers.h2
-rw-r--r--intern/cycles/render/camera.cpp2
-rw-r--r--intern/cycles/render/camera.h3
-rw-r--r--intern/cycles/render/constant_fold.h1
-rw-r--r--intern/cycles/render/curves.cpp1
-rw-r--r--intern/cycles/render/curves.h1
-rw-r--r--intern/cycles/render/film.cpp9
-rw-r--r--intern/cycles/render/film.h1
-rw-r--r--intern/cycles/render/graph.cpp22
-rw-r--r--intern/cycles/render/graph.h3
-rw-r--r--intern/cycles/render/image.cpp108
-rw-r--r--intern/cycles/render/image.h1
-rw-r--r--intern/cycles/render/integrator.cpp5
-rw-r--r--intern/cycles/render/integrator.h3
-rw-r--r--intern/cycles/render/light.cpp5
-rw-r--r--intern/cycles/render/light.h1
-rw-r--r--intern/cycles/render/mesh.h1
-rw-r--r--intern/cycles/render/mesh_displace.cpp5
-rw-r--r--intern/cycles/render/mesh_subdivision.cpp1
-rw-r--r--intern/cycles/render/nodes.cpp250
-rw-r--r--intern/cycles/render/nodes.h44
-rw-r--r--intern/cycles/render/object.cpp5
-rw-r--r--intern/cycles/render/object.h1
-rw-r--r--intern/cycles/render/osl.cpp15
-rw-r--r--intern/cycles/render/osl.h1
-rw-r--r--intern/cycles/render/particles.cpp19
-rw-r--r--intern/cycles/render/particles.h1
-rw-r--r--intern/cycles/render/scene.cpp3
-rw-r--r--intern/cycles/render/scene.h1
-rw-r--r--intern/cycles/render/session.cpp9
-rw-r--r--intern/cycles/render/session.h1
-rw-r--r--intern/cycles/render/shader.cpp11
-rw-r--r--intern/cycles/render/shader.h3
-rw-r--r--intern/cycles/render/sobol.cpp23
-rw-r--r--intern/cycles/render/sobol.h1
-rw-r--r--intern/cycles/render/svm.cpp21
-rw-r--r--intern/cycles/render/svm.h1
-rw-r--r--intern/cycles/render/tables.cpp1
-rw-r--r--intern/cycles/render/tables.h1
-rw-r--r--intern/cycles/render/tile.cpp1
-rw-r--r--intern/cycles/render/tile.h1
-rw-r--r--intern/cycles/subd/subd_dice.cpp1
-rw-r--r--intern/cycles/subd/subd_dice.h3
-rw-r--r--intern/cycles/subd/subd_patch.cpp5
-rw-r--r--intern/cycles/subd/subd_patch.h1
-rw-r--r--intern/cycles/subd/subd_patch_table.cpp1
-rw-r--r--intern/cycles/subd/subd_patch_table.h1
-rw-r--r--intern/cycles/subd/subd_split.cpp3
-rw-r--r--intern/cycles/subd/subd_split.h1
-rw-r--r--intern/cycles/util/CMakeLists.txt1
-rw-r--r--intern/cycles/util/util_algorithm.h1
-rw-r--r--intern/cycles/util/util_args.h1
-rw-r--r--intern/cycles/util/util_boundbox.h11
-rw-r--r--intern/cycles/util/util_color.h1
-rw-r--r--intern/cycles/util/util_defines.h1
-rw-r--r--intern/cycles/util/util_foreach.h1
-rw-r--r--intern/cycles/util/util_function.h1
-rw-r--r--intern/cycles/util/util_half.h12
-rw-r--r--intern/cycles/util/util_hash.h1
-rw-r--r--intern/cycles/util/util_image.h62
-rw-r--r--intern/cycles/util/util_image_impl.h50
-rw-r--r--intern/cycles/util/util_list.h1
-rw-r--r--intern/cycles/util/util_map.h1
-rw-r--r--intern/cycles/util/util_math.h29
-rw-r--r--intern/cycles/util/util_math_float3.h27
-rw-r--r--intern/cycles/util/util_math_int3.h18
-rw-r--r--intern/cycles/util/util_md5.cpp5
-rw-r--r--intern/cycles/util/util_md5.h1
-rw-r--r--intern/cycles/util/util_optimization.h1
-rw-r--r--intern/cycles/util/util_param.h1
-rw-r--r--intern/cycles/util/util_path.cpp1
-rw-r--r--intern/cycles/util/util_path.h1
-rw-r--r--intern/cycles/util/util_progress.h1
-rw-r--r--intern/cycles/util/util_projection.h1
-rw-r--r--intern/cycles/util/util_queue.h1
-rw-r--r--intern/cycles/util/util_rect.h1
-rw-r--r--intern/cycles/util/util_set.h1
-rw-r--r--intern/cycles/util/util_simd.h39
-rw-r--r--intern/cycles/util/util_sky_model.cpp1
-rw-r--r--intern/cycles/util/util_sseb.h13
-rw-r--r--intern/cycles/util/util_ssef.h37
-rw-r--r--intern/cycles/util/util_ssei.h27
-rw-r--r--intern/cycles/util/util_string.cpp1
-rw-r--r--intern/cycles/util/util_string.h1
-rw-r--r--intern/cycles/util/util_system.cpp1
-rw-r--r--intern/cycles/util/util_system.h1
-rw-r--r--intern/cycles/util/util_task.cpp9
-rw-r--r--intern/cycles/util/util_task.h3
-rw-r--r--intern/cycles/util/util_texture.h2
-rw-r--r--intern/cycles/util/util_thread.h1
-rw-r--r--intern/cycles/util/util_time.cpp1
-rw-r--r--intern/cycles/util/util_time.h1
-rw-r--r--intern/cycles/util/util_transform.cpp10
-rw-r--r--intern/cycles/util/util_transform.h3
-rw-r--r--intern/cycles/util/util_types.h3
-rw-r--r--intern/cycles/util/util_types_float4_impl.h2
-rw-r--r--intern/cycles/util/util_types_ushort4.h36
-rw-r--r--intern/cycles/util/util_vector.h1
-rw-r--r--intern/cycles/util/util_view.cpp1
-rw-r--r--intern/cycles/util/util_view.h1
-rw-r--r--intern/cycles/util/util_windows.h1
-rw-r--r--intern/gawain/CMakeLists.txt50
-rw-r--r--intern/gawain/gawain/gwn_attr_binding.h19
-rw-r--r--intern/gawain/gawain/gwn_attr_binding_private.h20
-rw-r--r--intern/gawain/gawain/gwn_batch.h169
-rw-r--r--intern/gawain/gawain/gwn_batch_private.h30
-rw-r--r--intern/gawain/gawain/gwn_buffer_id.h30
-rw-r--r--intern/gawain/gawain/gwn_common.h39
-rw-r--r--intern/gawain/gawain/gwn_context.h34
-rw-r--r--intern/gawain/gawain/gwn_element.h79
-rw-r--r--intern/gawain/gawain/gwn_imm_util.h22
-rw-r--r--intern/gawain/gawain/gwn_immediate.h120
-rw-r--r--intern/gawain/gawain/gwn_primitive.h42
-rw-r--r--intern/gawain/gawain/gwn_primitive_private.h14
-rw-r--r--intern/gawain/gawain/gwn_shader_interface.h81
-rw-r--r--intern/gawain/gawain/gwn_vertex_array_id.h34
-rw-r--r--intern/gawain/gawain/gwn_vertex_buffer.h125
-rw-r--r--intern/gawain/gawain/gwn_vertex_format.h78
-rw-r--r--intern/gawain/gawain/gwn_vertex_format_private.h16
-rw-r--r--intern/gawain/src/gwn_attr_binding.c70
-rw-r--r--intern/gawain/src/gwn_batch.c632
-rw-r--r--intern/gawain/src/gwn_buffer_id.cpp70
-rw-r--r--intern/gawain/src/gwn_element.c304
-rw-r--r--intern/gawain/src/gwn_imm_util.c80
-rw-r--r--intern/gawain/src/gwn_immediate.c926
-rw-r--r--intern/gawain/src/gwn_primitive.c67
-rw-r--r--intern/gawain/src/gwn_shader_interface.c362
-rw-r--r--intern/gawain/src/gwn_vertex_array_id.cpp173
-rw-r--r--intern/gawain/src/gwn_vertex_buffer.c258
-rw-r--r--intern/gawain/src/gwn_vertex_format.c291
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.cpp35
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.h2
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.cpp135
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.h12
-rw-r--r--intern/ghost/intern/GHOST_SystemNULL.h2
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp2
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp1
-rw-r--r--intern/opencolorio/CMakeLists.txt2
-rw-r--r--intern/opencolorio/ocio_impl_glsl.cc16
-rw-r--r--intern/opensubdiv/CMakeLists.txt48
-rw-r--r--intern/opensubdiv/internal/opensubdiv.cc99
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_factory.cc440
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_factory.h37
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_internal.cc96
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_internal.h55
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_orient.cc66
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_orient.h50
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h66
-rw-r--r--intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc226
-rw-r--r--intern/opensubdiv/internal/opensubdiv_device_context_cuda.h54
-rw-r--r--intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc269
-rw-r--r--intern/opensubdiv/internal/opensubdiv_device_context_opencl.h52
-rw-r--r--intern/opensubdiv/internal/opensubdiv_evaluator.cc154
-rw-r--r--intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc746
-rw-r--r--intern/opensubdiv/internal/opensubdiv_evaluator_internal.h134
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh.cc287
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc587
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h39
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc175
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h57
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc32
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h43
-rw-r--r--intern/opensubdiv/internal/opensubdiv_internal.h38
-rw-r--r--intern/opensubdiv/internal/opensubdiv_topology_refiner.cc367
-rw-r--r--intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.cc26
-rw-r--r--intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.h47
-rw-r--r--intern/opensubdiv/internal/opensubdiv_util.cc61
-rw-r--r--intern/opensubdiv/internal/opensubdiv_util.h39
-rw-r--r--intern/opensubdiv/opensubdiv_capi.cc440
-rw-r--r--intern/opensubdiv/opensubdiv_capi.h174
-rw-r--r--intern/opensubdiv/opensubdiv_capi_type.h56
-rw-r--r--intern/opensubdiv/opensubdiv_converter.cc744
-rw-r--r--intern/opensubdiv/opensubdiv_converter_capi.h252
-rw-r--r--intern/opensubdiv/opensubdiv_device_context_cuda.cc237
-rw-r--r--intern/opensubdiv/opensubdiv_device_context_cuda.h54
-rw-r--r--intern/opensubdiv/opensubdiv_device_context_opencl.cc251
-rw-r--r--intern/opensubdiv/opensubdiv_device_context_opencl.h58
-rw-r--r--intern/opensubdiv/opensubdiv_evaluator_capi.cc495
-rw-r--r--intern/opensubdiv/opensubdiv_evaluator_capi.h117
-rw-r--r--intern/opensubdiv/opensubdiv_gl_mesh_capi.h92
-rw-r--r--intern/opensubdiv/opensubdiv_gpu_capi.cc787
-rw-r--r--intern/opensubdiv/opensubdiv_topology_refiner_capi.h151
-rw-r--r--intern/opensubdiv/opensubdiv_utils_capi.cc88
-rw-r--r--intern/opensubdiv/shader/gpu_shader_opensubdiv_fragment.glsl (renamed from intern/opensubdiv/gpu_shader_opensubdiv_fragment.glsl)0
-rw-r--r--intern/opensubdiv/shader/gpu_shader_opensubdiv_geometry.glsl (renamed from intern/opensubdiv/gpu_shader_opensubdiv_geometry.glsl)0
-rw-r--r--intern/opensubdiv/shader/gpu_shader_opensubdiv_vertex.glsl (renamed from intern/opensubdiv/gpu_shader_opensubdiv_vertex.glsl)0
-rw-r--r--release/datafiles/blender_icons.svg590
-rw-r--r--release/datafiles/blender_icons16/icon16_vis_sel_00.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_vis_sel_01.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_vis_sel_10.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_vis_sel_11.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_vis_sel_00.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_vis_sel_01.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_vis_sel_10.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_vis_sel_11.datbin0 -> 4120 bytes
-rwxr-xr-xrelease/datafiles/blender_icons_update.py4
-rw-r--r--release/datafiles/studiolights/world/sl02.jpgbin49661 -> 0 bytes
-rw-r--r--release/datafiles/userdef/userdef_default_theme.c670
-rw-r--r--release/scripts/modules/addon_utils.py95
-rw-r--r--release/scripts/modules/bl_app_override/__init__.py1
-rw-r--r--release/scripts/modules/bl_i18n_utils/bl_extract_messages.py52
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/merge_po.py19
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils.py63
-rw-r--r--release/scripts/modules/bl_previews_utils/bl_previews_render.py113
-rwxr-xr-xrelease/scripts/modules/blend_render_info.py1
-rw-r--r--release/scripts/modules/bpy/ops.py1
-rw-r--r--release/scripts/modules/bpy/path.py3
-rw-r--r--release/scripts/modules/bpy/utils/__init__.py78
-rw-r--r--release/scripts/modules/bpy_extras/__init__.py2
-rw-r--r--release/scripts/modules/bpy_extras/anim_utils.py2
-rw-r--r--release/scripts/modules/bpy_extras/image_utils.py2
-rw-r--r--release/scripts/modules/bpy_extras/io_utils.py147
-rw-r--r--release/scripts/modules/bpy_extras/keyconfig_utils.py28
-rw-r--r--release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py244
-rw-r--r--release/scripts/modules/bpy_extras/mesh_utils.py10
-rw-r--r--release/scripts/modules/bpy_extras/node_utils.py20
-rw-r--r--release/scripts/modules/bpy_extras/object_utils.py28
-rw-r--r--release/scripts/modules/bpy_types.py97
-rw-r--r--release/scripts/modules/bpyml.py1
-rw-r--r--release/scripts/modules/console/complete_import.py4
-rw-r--r--release/scripts/modules/console_python.py1
-rw-r--r--release/scripts/modules/console_shell.py3
-rw-r--r--release/scripts/modules/graphviz_export.py3
-rw-r--r--release/scripts/modules/keyingsets_utils.py3
-rw-r--r--release/scripts/modules/nodeitems_utils.py4
-rw-r--r--release/scripts/modules/rna_keymap_ui.py21
-rw-r--r--release/scripts/modules/rna_prop_ui.py26
-rw-r--r--release/scripts/presets/interface_theme/24x_blues.xml2
-rw-r--r--release/scripts/presets/interface_theme/back_to_black.xml2
-rw-r--r--release/scripts/presets/interface_theme/blender_24x.xml2
-rw-r--r--release/scripts/presets/interface_theme/blender_27x.xml2
-rw-r--r--release/scripts/presets/interface_theme/dark_blue_gradient.xml2
-rw-r--r--release/scripts/presets/interface_theme/default++.xml2
-rw-r--r--release/scripts/presets/interface_theme/elsyiun.xml2
-rw-r--r--release/scripts/presets/interface_theme/flatty_light.xml2
-rw-r--r--release/scripts/presets/interface_theme/graph.xml2
-rw-r--r--release/scripts/presets/interface_theme/hexagon.xml2
-rw-r--r--release/scripts/presets/interface_theme/modern_minimalist.xml2
-rw-r--r--release/scripts/presets/interface_theme/north.xml2
-rw-r--r--release/scripts/presets/interface_theme/rtheme.xml2
-rw-r--r--release/scripts/presets/interface_theme/sandyslate.xml2
-rw-r--r--release/scripts/presets/interface_theme/science_lab.xml2
-rw-r--r--release/scripts/presets/interface_theme/softblend.xml2
-rw-r--r--release/scripts/presets/interface_theme/true_blue_menu.xml2
-rw-r--r--release/scripts/presets/keyconfig/blender_27x.py12620
-rw-r--r--release/scripts/presets/sunsky/classic.py14
-rw-r--r--release/scripts/presets/sunsky/desert.py14
-rw-r--r--release/scripts/presets/sunsky/mountain.py14
-rw-r--r--release/scripts/startup/bl_operators/add_mesh_torus.py16
-rw-r--r--release/scripts/startup/bl_operators/anim.py40
-rw-r--r--release/scripts/startup/bl_operators/bmesh/find_adjacent.py7
-rw-r--r--release/scripts/startup/bl_operators/clip.py34
-rw-r--r--release/scripts/startup/bl_operators/console.py4
-rw-r--r--release/scripts/startup/bl_operators/file.py40
-rw-r--r--release/scripts/startup/bl_operators/freestyle.py8
-rw-r--r--release/scripts/startup/bl_operators/image.py2
-rw-r--r--release/scripts/startup/bl_operators/mesh.py4
-rw-r--r--release/scripts/startup/bl_operators/node.py12
-rw-r--r--release/scripts/startup/bl_operators/object.py29
-rw-r--r--release/scripts/startup/bl_operators/object_align.py8
-rw-r--r--release/scripts/startup/bl_operators/object_quick_effects.py32
-rw-r--r--release/scripts/startup/bl_operators/object_randomize_transform.py20
-rw-r--r--release/scripts/startup/bl_operators/presets.py33
-rw-r--r--release/scripts/startup/bl_operators/rigidbody.py12
-rw-r--r--release/scripts/startup/bl_operators/screen_play_rendered_anim.py2
-rw-r--r--release/scripts/startup/bl_operators/sequencer.py2
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_follow_active.py2
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_lightmap.py14
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_smart_project.py10
-rw-r--r--release/scripts/startup/bl_operators/vertexpaint_dirt.py10
-rw-r--r--release/scripts/startup/bl_operators/view3d.py12
-rw-r--r--release/scripts/startup/bl_operators/wm.py255
-rw-r--r--release/scripts/startup/bl_ui/__init__.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_armature.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_bone.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_camera.py31
-rw-r--r--release/scripts/startup/bl_ui/properties_data_curve.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_empty.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lamp.py363
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lattice.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_light.py295
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lightprobe.py7
-rw-r--r--release/scripts/startup/bl_ui/properties_data_mesh.py22
-rw-r--r--release/scripts/startup/bl_ui/properties_data_metaball.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_speaker.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_mask_common.py8
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py35
-rw-r--r--release/scripts/startup/bl_ui/properties_object.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_particle.py90
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_cloth.py12
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_common.py89
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py18
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_field.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody.py8
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_smoke.py16
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_softbody.py14
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py117
-rw-r--r--release/scripts/startup/bl_ui/properties_scene.py252
-rw-r--r--release/scripts/startup/bl_ui/properties_texture.py246
-rw-r--r--release/scripts/startup/bl_ui/properties_view_layer.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_world.py34
-rw-r--r--release/scripts/startup/bl_ui/space_dopesheet.py17
-rw-r--r--release/scripts/startup/bl_ui/space_graph.py11
-rw-r--r--release/scripts/startup/bl_ui/space_image.py48
-rw-r--r--release/scripts/startup/bl_ui/space_nla.py10
-rw-r--r--release/scripts/startup/bl_ui/space_node.py7
-rw-r--r--release/scripts/startup/bl_ui/space_outliner.py48
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py10
-rw-r--r--release/scripts/startup/bl_ui/space_text.py4
-rw-r--r--release/scripts/startup/bl_ui/space_time.py20
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py76
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py43
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py110
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py159
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py1109
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py21
-rw-r--r--release/scripts/startup/keyingsets_builtins.py5
-rw-r--r--release/scripts/startup/nodeitems_builtins.py65
-rw-r--r--release/scripts/templates_py/addon_add_object.py2
-rw-r--r--release/scripts/templates_py/background_job.py10
-rw-r--r--release/scripts/templates_py/custom_nodes.py13
-rw-r--r--release/scripts/templates_py/gizmo_custom_geometry.py (renamed from release/scripts/templates_py/manipulator_custom_geometry.py)26
-rw-r--r--release/scripts/templates_py/gizmo_operator.py (renamed from release/scripts/templates_py/manipulator_operator.py)36
-rw-r--r--release/scripts/templates_py/gizmo_operator_target.py (renamed from release/scripts/templates_py/manipulator_operator_target.py)14
-rw-r--r--release/scripts/templates_py/gizmo_simple.py (renamed from release/scripts/templates_py/manipulator_simple.py)20
-rw-r--r--release/scripts/templates_py/operator_file_export.py6
-rw-r--r--release/scripts/templates_py/operator_file_import.py6
-rw-r--r--release/scripts/templates_py/operator_mesh_add.py14
-rw-r--r--release/scripts/templates_py/operator_modal.py4
-rw-r--r--release/scripts/templates_py/operator_modal_view3d.py2
-rw-r--r--release/scripts/templates_py/ui_list.py6
-rw-r--r--source/blender/blenfont/intern/blf.c12
-rw-r--r--source/blender/blenfont/intern/blf_font.c48
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c12
-rw-r--r--source/blender/blenfont/intern/blf_internal_types.h8
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h7
-rw-r--r--source/blender/blenkernel/BKE_addon.h1
-rw-r--r--source/blender/blenkernel/BKE_animsys.h2
-rw-r--r--source/blender/blenkernel/BKE_armature.h2
-rw-r--r--source/blender/blenkernel/BKE_context.h4
-rw-r--r--source/blender/blenkernel/BKE_global.h4
-rw-r--r--source/blender/blenkernel/BKE_image.h2
-rw-r--r--source/blender/blenkernel/BKE_layer.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h4
-rw-r--r--source/blender/blenkernel/BKE_mesh_mapping.h18
-rw-r--r--source/blender/blenkernel/BKE_mesh_runtime.h18
-rw-r--r--source/blender/blenkernel/BKE_modifier.h8
-rw-r--r--source/blender/blenkernel/BKE_node.h23
-rw-r--r--source/blender/blenkernel/BKE_object.h5
-rw-r--r--source/blender/blenkernel/BKE_ocean.h6
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h4
-rw-r--r--source/blender/blenkernel/BKE_scene.h1
-rw-r--r--source/blender/blenkernel/BKE_screen.h30
-rw-r--r--source/blender/blenkernel/BKE_softbody.h2
-rw-r--r--source/blender/blenkernel/BKE_studiolight.h2
-rw-r--r--source/blender/blenkernel/BKE_subdiv.h230
-rw-r--r--source/blender/blenkernel/BKE_workspace.h28
-rw-r--r--source/blender/blenkernel/BKE_world.h6
-rw-r--r--source/blender/blenkernel/CMakeLists.txt11
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c6
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_intern.h4
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c140
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c123
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c39
-rw-r--r--source/blender/blenkernel/intern/addon.c11
-rw-r--r--source/blender/blenkernel/intern/anim.c12
-rw-r--r--source/blender/blenkernel/intern/armature.c32
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/blendfile.c2
-rw-r--r--source/blender/blenkernel/intern/bpath.c2
-rw-r--r--source/blender/blenkernel/intern/camera.c1
-rw-r--r--source/blender/blenkernel/intern/cloth.c4
-rw-r--r--source/blender/blenkernel/intern/collection.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c36
-rw-r--r--source/blender/blenkernel/intern/context.c22
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c35
-rw-r--r--source/blender/blenkernel/intern/idcode.c2
-rw-r--r--source/blender/blenkernel/intern/idprop.c6
-rw-r--r--source/blender/blenkernel/intern/image.c85
-rw-r--r--source/blender/blenkernel/intern/ipo.c7
-rw-r--r--source/blender/blenkernel/intern/lamp.c4
-rw-r--r--source/blender/blenkernel/intern/layer.c56
-rw-r--r--source/blender/blenkernel/intern/library.c2
-rw-r--r--source/blender/blenkernel/intern/library_query.c4
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c1
-rw-r--r--source/blender/blenkernel/intern/mesh.c69
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c56
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c369
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.c100
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c7
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c81
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c33
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c15
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c51
-rw-r--r--source/blender/blenkernel/intern/modifier.c4
-rw-r--r--source/blender/blenkernel/intern/node.c7
-rw-r--r--source/blender/blenkernel/intern/object.c70
-rw-r--r--source/blender/blenkernel/intern/ocean.c42
-rw-r--r--source/blender/blenkernel/intern/paint.c15
-rw-r--r--source/blender/blenkernel/intern/pbvh.c6
-rw-r--r--source/blender/blenkernel/intern/pointcache.c6
-rw-r--r--source/blender/blenkernel/intern/scene.c35
-rw-r--r--source/blender/blenkernel/intern/screen.c48
-rw-r--r--source/blender/blenkernel/intern/softbody.c32
-rw-r--r--source/blender/blenkernel/intern/sound.c22
-rw-r--r--source/blender/blenkernel/intern/studiolight.c92
-rw-r--r--source/blender/blenkernel/intern/subdiv.c119
-rw-r--r--source/blender/blenkernel/intern/subdiv_converter.c65
-rw-r--r--source/blender/blenkernel/intern/subdiv_converter.h57
-rw-r--r--source/blender/blenkernel/intern/subdiv_converter_mesh.c471
-rw-r--r--source/blender/blenkernel/intern/subdiv_eval.c323
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.c952
-rw-r--r--source/blender/blenkernel/intern/subdiv_stats.c80
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c21
-rw-r--r--source/blender/blenkernel/intern/texture.c2
-rw-r--r--source/blender/blenkernel/intern/workspace.c109
-rw-r--r--source/blender/blenkernel/intern/world.c13
-rw-r--r--source/blender/blenkernel/intern/writeavi.c2
-rw-r--r--source/blender/blenlib/BLI_callbacks.h4
-rw-r--r--source/blender/blenlib/BLI_hash_mm3.h40
-rw-r--r--source/blender/blenlib/BLI_math_vector.h1
-rw-r--r--source/blender/blenlib/CMakeLists.txt2
-rw-r--r--source/blender/blenlib/intern/hash_mm3.c147
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c10
-rw-r--r--source/blender/blenloader/CMakeLists.txt1
-rw-r--r--source/blender/blenloader/intern/readblenentry.c6
-rw-r--r--source/blender/blenloader/intern/readfile.c173
-rw-r--r--source/blender/blenloader/intern/readfile.h3
-rw-r--r--source/blender/blenloader/intern/versioning_260.c1
-rw-r--r--source/blender/blenloader/intern/versioning_280.c92
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c2
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c47
-rw-r--r--source/blender/blenloader/intern/writefile.c146
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_query.h6
-rw-r--r--source/blender/bmesh/intern/bmesh_query_inline.h6
-rw-r--r--source/blender/collada/DocumentImporter.cpp6
-rw-r--r--source/blender/compositor/CMakeLists.txt5
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp4
-rw-r--r--source/blender/compositor/intern/COM_compositor.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_CryptomatteNode.cpp121
-rw-r--r--source/blender/compositor/nodes/COM_CryptomatteNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.cpp12
-rw-r--r--source/blender/compositor/operations/COM_CryptomatteOperation.cpp75
-rw-r--r--source/blender/compositor/operations/COM_CryptomatteOperation.h40
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h24
-rwxr-xr-xsource/blender/datatoc/datatoc_icon_split.py84
-rwxr-xr-xsource/blender/datatoc/datatoc_icon_split_to_png.py1
-rw-r--r--source/blender/depsgraph/CMakeLists.txt1
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h8
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc5
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_map.cc15
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc15
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc46
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc13
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc37
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc13
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.h2
-rw-r--r--source/blender/draw/CMakeLists.txt7
-rw-r--r--source/blender/draw/DRW_engine.h12
-rw-r--r--source/blender/draw/engines/basic/basic_engine.c100
-rw-r--r--source/blender/draw/engines/eevee/eevee_bloom.c14
-rw-r--r--source/blender/draw/engines/eevee/eevee_data.c99
-rw-r--r--source/blender/draw/engines/eevee/eevee_depth_of_field.c6
-rw-r--r--source/blender/draw/engines/eevee/eevee_effects.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c47
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c1141
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.h59
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c1934
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c101
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c65
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c65
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_occlusion.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h197
-rw-r--r--source/blender/draw/engines/eevee/eevee_render.c34
-rw-r--r--source/blender/draw/engines/eevee/eevee_screen_raytrace.c13
-rw-r--r--source/blender/draw/engines/eevee/eevee_subsurface.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_temporal_sampling.c5
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c3
-rw-r--r--source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl17
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl49
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl14
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl35
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl1
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl11
-rw-r--r--source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl3
-rw-r--r--source/blender/draw/engines/external/external_engine.c6
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl6
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl12
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl12
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl181
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl31
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl1
-rw-r--r--source/blender/draw/engines/workbench/solid_mode.c10
-rw-r--r--source/blender/draw/engines/workbench/transparent_mode.c8
-rw-r--r--source/blender/draw/engines/workbench/workbench_data.c58
-rw-r--r--source/blender/draw/engines/workbench/workbench_deferred.c67
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_aa.c23
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_taa.c28
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.c12
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.h2
-rw-r--r--source/blender/draw/engines/workbench/workbench_forward.c57
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c9
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h45
-rw-r--r--source/blender/draw/engines/workbench/workbench_render.c172
-rw-r--r--source/blender/draw/engines/workbench/workbench_volume.c152
-rw-r--r--source/blender/draw/intern/DRW_render.h85
-rw-r--r--source/blender/draw/intern/draw_anim_viz.c32
-rw-r--r--source/blender/draw/intern/draw_armature.c40
-rw-r--r--source/blender/draw/intern/draw_cache.c1754
-rw-r--r--source/blender/draw/intern/draw_cache.h204
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h104
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c274
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c102
-rw-r--r--source/blender/draw/intern/draw_cache_impl_lattice.c88
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c1240
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c20
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c352
-rw-r--r--source/blender/draw/intern/draw_common.c89
-rw-r--r--source/blender/draw/intern/draw_common.h32
-rw-r--r--source/blender/draw/intern/draw_debug.c82
-rw-r--r--source/blender/draw/intern/draw_debug.h2
-rw-r--r--source/blender/draw/intern/draw_hair.c4
-rw-r--r--source/blender/draw/intern/draw_hair_private.h26
-rw-r--r--source/blender/draw/intern/draw_instance_data.c84
-rw-r--r--source/blender/draw/intern/draw_instance_data.h8
-rw-r--r--source/blender/draw/intern/draw_manager.c434
-rw-r--r--source/blender/draw/intern/draw_manager.h40
-rw-r--r--source/blender/draw/intern/draw_manager_data.c140
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c28
-rw-r--r--source/blender/draw/intern/draw_manager_profiling.c2
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c20
-rw-r--r--source/blender/draw/intern/draw_manager_text.c34
-rw-r--r--source/blender/draw/intern/draw_manager_text.h6
-rw-r--r--source/blender/draw/intern/draw_view.c132
-rw-r--r--source/blender/draw/intern/draw_view.h4
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c2
-rw-r--r--source/blender/draw/modes/edit_lattice_mode.c2
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c21
-rw-r--r--source/blender/draw/modes/edit_mesh_mode_text.c2
-rw-r--r--source/blender/draw/modes/edit_surface_mode.c2
-rw-r--r--source/blender/draw/modes/edit_text_mode.c2
-rw-r--r--source/blender/draw/modes/object_mode.c351
-rw-r--r--source/blender/draw/modes/overlay_mode.c2
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c10
-rw-r--r--source/blender/draw/modes/paint_vertex_mode.c2
-rw-r--r--source/blender/draw/modes/paint_weight_mode.c6
-rw-r--r--source/blender/draw/modes/particle_mode.c6
-rw-r--r--source/blender/draw/modes/pose_mode.c13
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl7
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl13
-rw-r--r--source/blender/draw/modes/shaders/object_grid_frag.glsl33
-rw-r--r--source/blender/draw/modes/shaders/object_grid_vert.glsl8
-rw-r--r--source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl13
-rw-r--r--source/blender/draw/modes/shaders/volume_velocity_vert.glsl115
-rw-r--r--source/blender/editors/CMakeLists.txt2
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c40
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c42
-rw-r--r--source/blender/editors/animation/anim_draw.c22
-rw-r--r--source/blender/editors/animation/anim_markers.c20
-rw-r--r--source/blender/editors/animation/drivers.c4
-rw-r--r--source/blender/editors/animation/keyframes_draw.c32
-rw-r--r--source/blender/editors/animation/keyframing.c7
-rw-r--r--source/blender/editors/armature/armature_intern.h1
-rw-r--r--source/blender/editors/armature/armature_ops.c16
-rw-r--r--source/blender/editors/armature/armature_select.c4
-rw-r--r--source/blender/editors/armature/armature_utils.c2
-rw-r--r--source/blender/editors/armature/pose_edit.c32
-rw-r--r--source/blender/editors/curve/curve_ops.c4
-rw-r--r--source/blender/editors/curve/editcurve_paint.c52
-rw-r--r--source/blender/editors/datafiles/CMakeLists.txt4
-rw-r--r--source/blender/editors/gizmo_library/CMakeLists.txt (renamed from source/blender/editors/manipulator_library/CMakeLists.txt)34
-rw-r--r--source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c (renamed from source/blender/editors/manipulator_library/geometry/geom_arrow_manipulator.c)6
-rw-r--r--source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c (renamed from source/blender/editors/manipulator_library/geometry/geom_cube_manipulator.c)6
-rw-r--r--source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c (renamed from source/blender/editors/manipulator_library/geometry/geom_dial_manipulator.c)6
-rw-r--r--source/blender/editors/gizmo_library/gizmo_draw_utils.c (renamed from source/blender/editors/manipulator_library/manipulator_draw_utils.c)59
-rw-r--r--source/blender/editors/gizmo_library/gizmo_geometry.h (renamed from source/blender/editors/manipulator_library/manipulator_geometry.h)30
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_intern.h (renamed from source/blender/editors/manipulator_library/manipulator_library_intern.h)66
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_presets.c (renamed from source/blender/editors/manipulator_library/manipulator_library_presets.c)62
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_utils.c (renamed from source/blender/editors/manipulator_library/manipulator_library_utils.c)90
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c (renamed from source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c)104
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c492
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c (renamed from source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c)165
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c (renamed from source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c)502
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c (renamed from source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c)318
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c (renamed from source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c)224
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c375
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c191
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c96
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c4
-rw-r--r--source/blender/editors/include/ED_gizmo_library.h222
-rw-r--r--source/blender/editors/include/ED_keyframes_draw.h2
-rw-r--r--source/blender/editors/include/ED_manipulator_library.h222
-rw-r--r--source/blender/editors/include/ED_object.h1
-rw-r--r--source/blender/editors/include/ED_scene.h5
-rw-r--r--source/blender/editors/include/ED_screen.h22
-rw-r--r--source/blender/editors/include/ED_transform.h20
-rw-r--r--source/blender/editors/include/ED_view3d.h2
-rw-r--r--source/blender/editors/include/UI_icons.h80
-rw-r--r--source/blender/editors/include/UI_interface.h142
-rw-r--r--source/blender/editors/include/UI_resources.h12
-rw-r--r--source/blender/editors/include/UI_view2d.h2
-rw-r--r--source/blender/editors/interface/CMakeLists.txt1
-rw-r--r--source/blender/editors/interface/interface.c135
-rw-r--r--source/blender/editors/interface/interface_draw.c329
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c1
-rw-r--r--source/blender/editors/interface/interface_eyedropper_color.c93
-rw-r--r--source/blender/editors/interface/interface_icons.c184
-rw-r--r--source/blender/editors/interface/interface_icons_event.c295
-rw-r--r--source/blender/editors/interface/interface_intern.h31
-rw-r--r--source/blender/editors/interface/interface_layout.c35
-rw-r--r--source/blender/editors/interface/interface_ops.c6
-rw-r--r--source/blender/editors/interface/interface_panel.c165
-rw-r--r--source/blender/editors/interface/interface_region_popover.c32
-rw-r--r--source/blender/editors/interface/interface_region_popup.c5
-rw-r--r--source/blender/editors/interface/interface_region_search.c4
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c28
-rw-r--r--source/blender/editors/interface/interface_templates.c60
-rw-r--r--source/blender/editors/interface/interface_widgets.c299
-rw-r--r--source/blender/editors/interface/resources.c46
-rw-r--r--source/blender/editors/interface/view2d.c35
-rw-r--r--source/blender/editors/lattice/lattice_ops.c6
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c498
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c375
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c191
-rw-r--r--source/blender/editors/mask/mask_draw.c58
-rw-r--r--source/blender/editors/mask/mask_edit.c4
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt2
-rw-r--r--source/blender/editors/mesh/editmesh_add_gizmo.c (renamed from source/blender/editors/mesh/editmesh_add_manipulator.c)178
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c8
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c226
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c138
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin.c256
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c8
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c40
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c22
-rw-r--r--source/blender/editors/mesh/editmesh_polybuild.c2
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c18
-rw-r--r--source/blender/editors/mesh/mesh_intern.h4
-rw-r--r--source/blender/editors/mesh/mesh_ops.c42
-rw-r--r--source/blender/editors/metaball/mball_ops.c4
-rw-r--r--source/blender/editors/object/object_add.c38
-rw-r--r--source/blender/editors/object/object_edit.c14
-rw-r--r--source/blender/editors/object/object_intern.h2
-rw-r--r--source/blender/editors/object/object_modifier.c54
-rw-r--r--source/blender/editors/object/object_ops.c14
-rw-r--r--source/blender/editors/object/object_relations.c4
-rw-r--r--source/blender/editors/object/object_select.c8
-rw-r--r--source/blender/editors/object/object_transform.c6
-rw-r--r--source/blender/editors/physics/particle_edit.c4
-rw-r--r--source/blender/editors/physics/physics_fluid.c2
-rw-r--r--source/blender/editors/physics/physics_ops.c4
-rw-r--r--source/blender/editors/render/render_intern.h3
-rw-r--r--source/blender/editors/render/render_internal.c22
-rw-r--r--source/blender/editors/render/render_opengl.c4
-rw-r--r--source/blender/editors/render/render_ops.c3
-rw-r--r--source/blender/editors/render/render_preview.c166
-rw-r--r--source/blender/editors/render/render_shading.c189
-rw-r--r--source/blender/editors/render/render_update.c5
-rw-r--r--source/blender/editors/scene/scene_edit.c57
-rw-r--r--source/blender/editors/screen/area.c82
-rw-r--r--source/blender/editors/screen/glutil.c20
-rw-r--r--source/blender/editors/screen/screen_context.c3
-rw-r--r--source/blender/editors/screen/screen_draw.c38
-rw-r--r--source/blender/editors/screen/screen_edit.c54
-rw-r--r--source/blender/editors/screen/screen_ops.c118
-rw-r--r--source/blender/editors/screen/workspace_edit.c66
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c70
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c35
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c11
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c2
-rw-r--r--source/blender/editors/space_action/action_draw.c18
-rw-r--r--source/blender/editors/space_action/action_intern.h2
-rw-r--r--source/blender/editors/space_action/action_ops.c18
-rw-r--r--source/blender/editors/space_action/action_select.c35
-rw-r--r--source/blender/editors/space_action/space_action.c11
-rw-r--r--source/blender/editors/space_api/spacetypes.c30
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c37
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c16
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c9
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c35
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c28
-rw-r--r--source/blender/editors/space_clip/clip_draw.c144
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c20
-rw-r--r--source/blender/editors/space_clip/clip_utils.c4
-rw-r--r--source/blender/editors/space_clip/space_clip.c38
-rw-r--r--source/blender/editors/space_console/console_draw.c4
-rw-r--r--source/blender/editors/space_console/space_console.c3
-rw-r--r--source/blender/editors/space_file/file_draw.c20
-rw-r--r--source/blender/editors/space_file/file_intern.h2
-rw-r--r--source/blender/editors/space_file/file_ops.c4
-rw-r--r--source/blender/editors/space_file/filelist.c2
-rw-r--r--source/blender/editors/space_file/space_file.c13
-rw-r--r--source/blender/editors/space_graph/graph_draw.c94
-rw-r--r--source/blender/editors/space_graph/graph_intern.h2
-rw-r--r--source/blender/editors/space_graph/graph_ops.c18
-rw-r--r--source/blender/editors/space_graph/graph_select.c30
-rw-r--r--source/blender/editors/space_graph/space_graph.c11
-rw-r--r--source/blender/editors/space_image/image_buttons.c19
-rw-r--r--source/blender/editors/space_image/image_draw.c26
-rw-r--r--source/blender/editors/space_image/image_ops.c117
-rw-r--r--source/blender/editors/space_image/space_image.c55
-rw-r--r--source/blender/editors/space_info/space_info.c4
-rw-r--r--source/blender/editors/space_info/textview.c12
-rw-r--r--source/blender/editors/space_nla/nla_draw.c44
-rw-r--r--source/blender/editors/space_nla/nla_intern.h2
-rw-r--r--source/blender/editors/space_nla/nla_ops.c18
-rw-r--r--source/blender/editors/space_nla/nla_select.c31
-rw-r--r--source/blender/editors/space_nla/space_nla.c9
-rw-r--r--source/blender/editors/space_node/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_node/drawnode.c186
-rw-r--r--source/blender/editors/space_node/node_draw.c60
-rw-r--r--source/blender/editors/space_node/node_edit.c94
-rw-r--r--source/blender/editors/space_node/node_gizmo.c (renamed from source/blender/editors/space_node/node_manipulators.c)268
-rw-r--r--source/blender/editors/space_node/node_intern.h10
-rw-r--r--source/blender/editors/space_node/node_ops.c9
-rw-r--r--source/blender/editors/space_node/node_templates.c7
-rw-r--r--source/blender/editors/space_node/space_node.c39
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c58
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c69
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h7
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c39
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c31
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c40
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c4
-rw-r--r--source/blender/editors/space_script/space_script.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c54
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_preview.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c2
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c9
-rw-r--r--source/blender/editors/space_statusbar/space_statusbar.c2
-rw-r--r--source/blender/editors/space_text/space_text.c3
-rw-r--r--source/blender/editors/space_text/text_draw.c22
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c4
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c4
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt16
-rw-r--r--source/blender/editors/space_view3d/drawobject.c112
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c169
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c26
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c68
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c42
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c433
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c39
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_armature.c (renamed from source/blender/editors/space_view3d/view3d_manipulator_armature.c)95
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_camera.c (renamed from source/blender/editors/space_view3d/view3d_manipulator_camera.c)236
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_empty.c (renamed from source/blender/editors/space_view3d/view3d_manipulator_empty.c)115
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_forcefield.c (renamed from source/blender/editors/space_view3d/view3d_manipulator_forcefield.c)71
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_lamp.c307
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_navigate.c (renamed from source/blender/editors/space_view3d/view3d_manipulator_navigate.c)185
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c417
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_ruler.c (renamed from source/blender/editors/space_view3d/view3d_manipulator_ruler.c)198
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c45
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h39
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_lamp.c305
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c310
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c92
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c19
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c38
-rw-r--r--source/blender/editors/transform/CMakeLists.txt4
-rw-r--r--source/blender/editors/transform/transform.c288
-rw-r--r--source/blender/editors/transform/transform.h18
-rw-r--r--source/blender/editors/transform/transform_constraints.c14
-rw-r--r--source/blender/editors/transform/transform_conversions.c6
-rw-r--r--source/blender/editors/transform/transform_generics.c20
-rw-r--r--source/blender/editors/transform/transform_gizmo_2d.c (renamed from source/blender/editors/transform/transform_manipulator_2d.c)156
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c (renamed from source/blender/editors/transform/transform_manipulator_3d.c)409
-rw-r--r--source/blender/editors/transform/transform_ops.c8
-rw-r--r--source/blender/editors/transform/transform_snap.c20
-rw-r--r--source/blender/editors/undo/ed_undo.c39
-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/numinput.c46
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c134
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c37
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c99
-rw-r--r--source/blender/gpu/CMakeLists.txt23
-rw-r--r--source/blender/gpu/GPU_attr_binding.h42
-rw-r--r--source/blender/gpu/GPU_batch.h191
-rw-r--r--source/blender/gpu/GPU_batch_presets.h52
-rw-r--r--source/blender/gpu/GPU_batch_utils.h40
-rw-r--r--source/blender/gpu/GPU_buffers.h2
-rw-r--r--source/blender/gpu/GPU_common.h (renamed from intern/opensubdiv/opensubdiv_intern.h)51
-rw-r--r--source/blender/gpu/GPU_context.h55
-rw-r--r--source/blender/gpu/GPU_draw.h2
-rw-r--r--source/blender/gpu/GPU_element.h102
-rw-r--r--source/blender/gpu/GPU_framebuffer.h5
-rw-r--r--source/blender/gpu/GPU_immediate.h112
-rw-r--r--source/blender/gpu/GPU_immediate_util.h11
-rw-r--r--source/blender/gpu/GPU_material.h14
-rw-r--r--source/blender/gpu/GPU_matrix.h92
-rw-r--r--source/blender/gpu/GPU_primitive.h65
-rw-r--r--source/blender/gpu/GPU_shader.h12
-rw-r--r--source/blender/gpu/GPU_shader_interface.h104
-rw-r--r--source/blender/gpu/GPU_state.h2
-rw-r--r--source/blender/gpu/GPU_texture.h35
-rw-r--r--source/blender/gpu/GPU_vertex_buffer.h144
-rw-r--r--source/blender/gpu/GPU_vertex_format.h103
-rw-r--r--source/blender/gpu/intern/gpu_attr_binding.c85
-rw-r--r--source/blender/gpu/intern/gpu_attr_binding_private.h45
-rw-r--r--source/blender/gpu/intern/gpu_basic_shader.c18
-rw-r--r--source/blender/gpu/intern/gpu_batch.c797
-rw-r--r--source/blender/gpu/intern/gpu_batch_presets.c141
-rw-r--r--source/blender/gpu/intern/gpu_batch_private.h (renamed from intern/opensubdiv/opensubdiv_topology_refiner.h)37
-rw-r--r--source/blender/gpu/intern/gpu_batch_utils.c243
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c206
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c209
-rw-r--r--source/blender/gpu/intern/gpu_context.cpp317
-rw-r--r--source/blender/gpu/intern/gpu_context_private.h68
-rw-r--r--source/blender/gpu/intern/gpu_draw.c184
-rw-r--r--source/blender/gpu/intern/gpu_element.c309
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c66
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c848
-rw-r--r--source/blender/gpu/intern/gpu_immediate_util.c154
-rw-r--r--source/blender/gpu/intern/gpu_init_exit.c5
-rw-r--r--source/blender/gpu/intern/gpu_material.c105
-rw-r--r--source/blender/gpu/intern/gpu_matrix.c134
-rw-r--r--source/blender/gpu/intern/gpu_primitive.c84
-rw-r--r--source/blender/gpu/intern/gpu_primitive_private.h37
-rw-r--r--source/blender/gpu/intern/gpu_private.h3
-rw-r--r--source/blender/gpu/intern/gpu_select.c2
-rw-r--r--source/blender/gpu/intern/gpu_shader.c124
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.c367
-rw-r--r--source/blender/gpu/intern/gpu_shader_private.h4
-rw-r--r--source/blender/gpu/intern/gpu_state.c9
-rw-r--r--source/blender/gpu/intern/gpu_texture.c617
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c7
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.c270
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.c312
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format_private.h39
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl300
-rw-r--r--source/blender/imbuf/IMB_imbuf.h1
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h1
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c1
-rw-r--r--source/blender/imbuf/intern/anim_movie.c34
-rw-r--r--source/blender/imbuf/intern/divers.c56
-rw-r--r--source/blender/imbuf/intern/readimage.c1
-rw-r--r--source/blender/imbuf/intern/stereoimbuf.c2
-rw-r--r--source/blender/makesdna/DNA_ID.h21
-rw-r--r--source/blender/makesdna/DNA_action_types.h6
-rw-r--r--source/blender/makesdna/DNA_image_types.h6
-rw-r--r--source/blender/makesdna/DNA_lightprobe_types.h77
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h3
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h35
-rw-r--r--source/blender/makesdna/DNA_node_types.h77
-rw-r--r--source/blender/makesdna/DNA_object_force_types.h15
-rw-r--r--source/blender/makesdna/DNA_object_types.h18
-rw-r--r--source/blender/makesdna/DNA_scene_types.h19
-rw-r--r--source/blender/makesdna/DNA_screen_types.h2
-rw-r--r--source/blender/makesdna/DNA_smoke_types.h3
-rw-r--r--source/blender/makesdna/DNA_sound_types.h12
-rw-r--r--source/blender/makesdna/DNA_space_types.h10
-rw-r--r--source/blender/makesdna/DNA_texture_types.h4
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h25
-rw-r--r--source/blender/makesdna/DNA_view2d_types.h3
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h43
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h11
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h19
-rw-r--r--source/blender/makesdna/DNA_world_types.h4
-rw-r--r--source/blender/makesrna/RNA_access.h22
-rw-r--r--source/blender/makesrna/RNA_enum_types.h2
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt4
-rw-r--r--source/blender/makesrna/intern/makesrna.c4
-rw-r--r--source/blender/makesrna/intern/rna_ID.c12
-rw-r--r--source/blender/makesrna/intern/rna_access.c2
-rw-r--r--source/blender/makesrna/intern/rna_action.c6
-rw-r--r--source/blender/makesrna/intern/rna_animation.c2
-rw-r--r--source/blender/makesrna/intern/rna_armature.c4
-rw-r--r--source/blender/makesrna/intern/rna_brush.c54
-rw-r--r--source/blender/makesrna/intern/rna_color.c7
-rw-r--r--source/blender/makesrna/intern/rna_context.c10
-rw-r--r--source/blender/makesrna/intern/rna_curve.c2
-rw-r--r--source/blender/makesrna/intern/rna_depsgraph.c26
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c4
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c2
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c12
-rw-r--r--source/blender/makesrna/intern/rna_group.c2
-rw-r--r--source/blender/makesrna/intern/rna_image.c59
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c6
-rw-r--r--source/blender/makesrna/intern/rna_internal.h16
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c237
-rw-r--r--source/blender/makesrna/intern/rna_lattice.c4
-rw-r--r--source/blender/makesrna/intern/rna_lightprobe.c17
-rw-r--r--source/blender/makesrna/intern/rna_main.c12
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c39
-rw-r--r--source/blender/makesrna/intern/rna_material.c3
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c46
-rw-r--r--source/blender/makesrna/intern/rna_meta.c2
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c57
-rw-r--r--source/blender/makesrna/intern/rna_movieclip.c2
-rw-r--r--source/blender/makesrna/intern/rna_nla.c8
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c188
-rw-r--r--source/blender/makesrna/intern/rna_object.c14
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c24
-rw-r--r--source/blender/makesrna/intern/rna_particle.c8
-rw-r--r--source/blender/makesrna/intern/rna_pose.c4
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c20
-rw-r--r--source/blender/makesrna/intern/rna_rna.c38
-rw-r--r--source/blender/makesrna/intern/rna_scene.c96
-rw-r--r--source/blender/makesrna/intern/rna_screen.c4
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c8
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c939
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c8
-rw-r--r--source/blender/makesrna/intern/rna_smoke.c2
-rw-r--r--source/blender/makesrna/intern/rna_sound.c4
-rw-r--r--source/blender/makesrna/intern/rna_space.c402
-rw-r--r--source/blender/makesrna/intern/rna_text.c2
-rw-r--r--source/blender/makesrna/intern/rna_texture.c6
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c4
-rw-r--r--source/blender/makesrna/intern/rna_ui.c33
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c15
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c155
-rw-r--r--source/blender/makesrna/intern/rna_wm.c32
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c43
-rw-r--r--source/blender/makesrna/intern/rna_wm_gizmo.c1336
-rw-r--r--source/blender/makesrna/intern/rna_wm_gizmo_api.c (renamed from source/blender/makesrna/intern/rna_wm_manipulator_api.c)130
-rw-r--r--source/blender/makesrna/intern/rna_wm_manipulator.c1328
-rw-r--r--source/blender/makesrna/intern/rna_workspace_api.c9
-rw-r--r--source/blender/makesrna/intern/rna_world.c4
-rwxr-xr-xsource/blender/makesrna/rna_cleanup/rna_cleaner.py105
-rwxr-xr-xsource/blender/makesrna/rna_cleanup/rna_cleaner_merge.py78
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c6
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c2
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c2
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c23
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c2
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c2
-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.c4
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim.c43
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c85
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.h6
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c6
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c6
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c6
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c6
-rw-r--r--source/blender/modifiers/intern/MOD_none.c2
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c176
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c2
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c4
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c2
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c2
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c2
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c82
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c6
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c6
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c6
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c2
-rw-r--r--source/blender/nodes/CMakeLists.txt2
-rw-r--r--source/blender/nodes/NOD_composite.h1
-rw-r--r--source/blender/nodes/NOD_shader.h1
-rw-r--r--source/blender/nodes/NOD_static_types.h6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_cryptomatte.c302
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_splitViewer.c1
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_viewer.c1
-rw-r--r--source/blender/nodes/intern/node_common.c3
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c115
-rw-r--r--source/blender/nodes/shader/node_shader_util.c7
-rw-r--r--source/blender/nodes/shader/node_shader_util.h2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_add_shader.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_background.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bevel.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_blackbody.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_brightness.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c132
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bump.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_camera.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_curves.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_displacement.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_eevee_specular.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_emission.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_fresnel.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_gamma.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geometry.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_hair_info.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_holdout.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_hueSatVal.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ies_light.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_invert.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_layer_weight.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_falloff.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_path.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mapping.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c47
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mixRgb.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mix_shader.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_object_info.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_lamp.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_linestyle.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_material.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_world.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_particle_info.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_rgb.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_script.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_squeeze.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_brick.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_checker.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_coord.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_gradient.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c56
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_magic.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_noise.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c22
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_wave.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_uvmap.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_value.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectMath.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectTransform.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_displacement.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_absorption.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_principled.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_scatter.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_wavelength.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_wireframe.c1
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_image.c1
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c27
-rw-r--r--source/blender/python/CMakeLists.txt2
-rw-r--r--source/blender/python/gpu/CMakeLists.txt (renamed from source/blender/python/gawain/CMakeLists.txt)11
-rw-r--r--source/blender/python/gpu/gpu_py_api.c (renamed from source/blender/python/gawain/gwn_py_api.c)32
-rw-r--r--source/blender/python/gpu/gpu_py_api.h (renamed from source/blender/python/gawain/gwn_py_api.h)12
-rw-r--r--source/blender/python/gpu/gpu_py_types.c (renamed from source/blender/python/gawain/gwn_py_types.c)358
-rw-r--r--source/blender/python/gpu/gpu_py_types.h (renamed from source/blender/python/gawain/gwn_py_types.h)52
-rw-r--r--source/blender/python/intern/CMakeLists.txt8
-rw-r--r--source/blender/python/intern/bpy.c4
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c4
-rw-r--r--source/blender/python/intern/bpy_driver.c10
-rw-r--r--source/blender/python/intern/bpy_gizmo_wrap.c (renamed from source/blender/python/intern/bpy_manipulator_wrap.c)74
-rw-r--r--source/blender/python/intern/bpy_gizmo_wrap.h (renamed from source/blender/python/intern/bpy_manipulator_wrap.h)16
-rw-r--r--source/blender/python/intern/bpy_interface.c4
-rw-r--r--source/blender/python/intern/bpy_intern_string.c4
-rw-r--r--source/blender/python/intern/bpy_intern_string.h2
-rw-r--r--source/blender/python/intern/bpy_msgbus.c2
-rw-r--r--source/blender/python/intern/bpy_rna.c49
-rw-r--r--source/blender/python/intern/bpy_rna_gizmo.c (renamed from source/blender/python/intern/bpy_rna_manipulator.c)216
-rw-r--r--source/blender/python/intern/bpy_rna_gizmo.h (renamed from source/blender/python/intern/bpy_rna_manipulator.h)10
-rw-r--r--source/blender/python/intern/gpu_py_matrix.c40
-rw-r--r--source/blender/python/intern/gpu_py_select.c2
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c3
-rw-r--r--source/blender/python/rna_dump.py5
-rw-r--r--source/blender/python/simple_enum_gen.py44
-rw-r--r--source/blender/render/CMakeLists.txt1
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h2
-rw-r--r--source/blender/render/intern/include/render_types.h2
-rw-r--r--source/blender/render/intern/source/imagetexture.c36
-rw-r--r--source/blender/render/intern/source/pipeline.c22
-rw-r--r--source/blender/windowmanager/CMakeLists.txt36
-rw-r--r--source/blender/windowmanager/WM_api.h75
-rw-r--r--source/blender/windowmanager/WM_keymap.h1
-rw-r--r--source/blender/windowmanager/WM_toolsystem.h8
-rw-r--r--source/blender/windowmanager/WM_types.h7
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_api.h343
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_types.h422
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo.c800
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c949
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c197
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h144
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c1209
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c364
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c212
-rw-r--r--source/blender/windowmanager/gizmo/wm_gizmo_fn.h88
-rw-r--r--source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h97
-rw-r--r--source/blender/windowmanager/intern/wm.c84
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c7
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c273
-rw-r--r--source/blender/windowmanager/intern/wm_files.c44
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c18
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c27
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c2
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c9
-rw-r--r--source/blender/windowmanager/intern/wm_menu_type.c115
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c567
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c588
-rw-r--r--source/blender/windowmanager/intern/wm_panel_type.c88
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c97
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c28
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c8
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c71
-rw-r--r--source/blender/windowmanager/intern/wm_uilist_type.c98
-rw-r--r--source/blender/windowmanager/intern/wm_window.c315
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_api.h343
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_types.h420
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator.c800
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c949
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c197
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h142
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c1196
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c364
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c212
-rw-r--r--source/blender/windowmanager/manipulators/wm_manipulator_fn.h88
-rw-r--r--source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h97
-rw-r--r--source/blender/windowmanager/wm.h3
-rw-r--r--source/blender/windowmanager/wm_event_system.h5
-rw-r--r--source/blender/windowmanager/wm_event_types.h4
-rw-r--r--source/blender/windowmanager/wm_window.h7
-rw-r--r--source/creator/creator.c2
-rw-r--r--tests/check_deprecated.py1
-rwxr-xr-xtests/python/alembic_tests.py1
-rw-r--r--tests/python/bl_alembic_import_test.py1
-rw-r--r--tests/python/bl_load_addons.py9
-rw-r--r--tests/python/bl_load_py_modules.py11
-rw-r--r--tests/python/bl_mesh_modifiers.py167
-rw-r--r--tests/python/bl_mesh_validate.py46
-rw-r--r--tests/python/bl_pyapi_bpy_utils_units.py39
-rw-r--r--tests/python/bl_pyapi_idprop.py1
-rw-r--r--tests/python/bl_pyapi_idprop_datablock.py29
-rw-r--r--tests/python/bl_pyapi_mathutils.py27
-rw-r--r--tests/python/bl_rna_defaults.py7
-rw-r--r--tests/python/bl_rna_manual_reference.py1
-rw-r--r--tests/python/bl_run_operators.py14
-rw-r--r--tests/python/collada/animation/test_animation_simple.py53
-rw-r--r--tests/python/collada/mesh/test_mesh_simple.py27
-rwxr-xr-xtests/python/eevee_render_tests.py2
-rwxr-xr-xtests/python/modules/render_report.py20
-rwxr-xr-xtests/python/modules/test_utils.py3
-rwxr-xr-xtests/python/opengl_draw_tests.py3
-rw-r--r--tests/python/pep8.py7
-rw-r--r--tests/python/rna_array.py76
-rw-r--r--tests/python/view_layer/test_active_collection.py26
-rw-r--r--tests/python/view_layer/test_collection_new_sync.py12
-rw-r--r--tests/python/view_layer/test_group_d.py1
-rw-r--r--tests/python/view_layer/test_layer_linking.py2
-rw-r--r--tests/python/view_layer/test_layer_syncing.py2
-rw-r--r--tests/python/view_layer/test_make_single_user.py2
-rw-r--r--tests/python/view_layer/test_move_above_below_layer_collection_f.py52
-rw-r--r--tests/python/view_layer/test_move_above_below_layer_collection_g.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_layer_collection_i.py24
-rw-r--r--tests/python/view_layer/test_move_above_below_layer_collection_l.py24
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_a.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_b.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_c.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_d.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_e.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_f.py28
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py30
-rw-r--r--tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py28
-rw-r--r--tests/python/view_layer/test_move_into_layer_collection_a.py54
-rw-r--r--tests/python/view_layer/test_move_into_layer_collection_f.py52
-rw-r--r--tests/python/view_layer/test_move_into_layer_collection_g.py22
-rw-r--r--tests/python/view_layer/test_move_into_layer_collection_h.py32
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_a.py30
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_b.py32
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_c.py28
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_e.py28
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_f.py30
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_g.py20
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_h.py32
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_i.py28
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_sync_b.py32
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_sync_c.py28
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_sync_e.py28
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_sync_f.py30
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_sync_g.py20
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_sync_h.py32
-rw-r--r--tests/python/view_layer/test_move_into_scene_collection_sync_i.py28
-rw-r--r--tests/python/view_layer/test_object_copy.py2
-rw-r--r--tests/python/view_layer/test_operator_context.py18
-rw-r--r--tests/python/view_layer/test_scene_copy_a.py6
-rw-r--r--tests/python/view_layer/test_scene_copy_b.py6
-rw-r--r--tests/python/view_layer/test_scene_copy_c.py6
-rw-r--r--tests/python/view_layer/test_scene_copy_d.py6
-rw-r--r--tests/python/view_layer/test_scene_write_read.py36
-rw-r--r--tests/python/view_layer/view_layer_common.py114
1444 files changed, 59636 insertions, 41129 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d2bcc4b0af..2961aafe908 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -624,10 +624,12 @@ endif()
if(NOT WITH_AUDASPACE)
if(WITH_OPENAL)
- message(FATAL_ERROR "WITH_OPENAL requires WITH_AUDASPACE")
+ message(WARNING "WITH_OPENAL requires WITH_AUDASPACE which is disabled")
+ set(WITH_OPENAL OFF)
endif()
if(WITH_JACK)
- message(FATAL_ERROR "WITH_JACK requires WITH_AUDASPACE")
+ message(WARNING "WITH_JACK requires WITH_AUDASPACE which is disabled")
+ set(WITH_JACK OFF)
endif()
endif()
diff --git a/GNUmakefile b/GNUmakefile
index 01806b53e61..c1be177ddc0 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -236,8 +236,12 @@ help: .FORCE
@echo " * check_descriptions - check for duplicate/invalid descriptions"
@echo ""
@echo "Utilities (not associated with building blender)"
- @echo " * icons - updates PNG icons from SVG files."
- @echo " * icons_geom - updates Geometry icons from BLEND file."
+ @echo " * icons - Updates PNG icons from SVG files."
+ @echo " Set environment variables 'BLENDER_BIN' and 'INKSCAPE_BIN'"
+ @echo " to define your own commands."
+ @echo " * icons_geom - Updates Geometry icons from BLEND file."
+ @echo " Set environment variable 'BLENDER_BIN'"
+ @echo " to define your own command."
@echo " * tgz - create a compressed archive of the source code."
@echo " * update - updates git and all submodules"
@echo ""
diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py
index 43964dda691..a77f237e978 100644
--- a/build_files/buildbot/slave_compile.py
+++ b/build_files/buildbot/slave_compile.py
@@ -77,7 +77,13 @@ if 'cmake' in builder:
# cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
elif builder.startswith('win'):
- if builder.endswith('_vc2015'):
+ if builder.endswith('_vs2017'):
+ if builder.startswith('win64'):
+ cmake_options.extend(['-G', 'Visual Studio 15 2017 Win64'])
+ elif builder.startswith('win32'):
+ bits = 32
+ cmake_options.extend(['-G', 'Visual Studio 15 2017'])
+ elif builder.endswith('_vc2015'):
if builder.startswith('win64'):
cmake_options.extend(['-G', 'Visual Studio 14 2015 Win64'])
elif builder.startswith('win32'):
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 545b0e8ce5d..0ceaee08e64 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -600,7 +600,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_editor_curve
bf_editor_gpencil
bf_editor_interface
- bf_editor_manipulator_library
+ bf_editor_gizmo_library
bf_editor_mesh
bf_editor_metaball
bf_editor_object
@@ -621,7 +621,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_python
bf_python_ext
bf_python_mathutils
- bf_python_gawain
+ bf_python_gpu
bf_python_bmesh
bf_freestyle
bf_ikplugin
@@ -635,7 +635,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_physics
bf_nodes
bf_rna
- bf_editor_manipulator_library # rna -> manipulator bad-level calls
+ bf_editor_gizmo_library # rna -> gizmo bad-level calls
bf_python
bf_imbuf
bf_blenlib
diff --git a/build_files/windows/autodetect_msvc.cmd b/build_files/windows/autodetect_msvc.cmd
index 6fce3829e7b..77dc005cd18 100644
--- a/build_files/windows/autodetect_msvc.cmd
+++ b/build_files/windows/autodetect_msvc.cmd
@@ -1,14 +1,11 @@
echo No explicit msvc version requested, autodetecting version.
-call "%~dp0\detect_msvc2013.cmd"
+call "%~dp0\detect_msvc2017.cmd"
if %ERRORLEVEL% EQU 0 goto DetectionComplete
call "%~dp0\detect_msvc2015.cmd"
if %ERRORLEVEL% EQU 0 goto DetectionComplete
-call "%~dp0\detect_msvc2017.cmd"
-if %ERRORLEVEL% EQU 0 goto DetectionComplete
-
echo Compiler Detection failed. Use verbose switch for more information.
exit /b 1
diff --git a/build_files/windows/check_libraries.cmd b/build_files/windows/check_libraries.cmd
index c8aad7c9adb..6ad1d1749c3 100644
--- a/build_files/windows/check_libraries.cmd
+++ b/build_files/windows/check_libraries.cmd
@@ -1,4 +1,3 @@
-if "%BUILD_VS_YEAR%"=="2013" set BUILD_VS_LIBDIRPOST=vc12
if "%BUILD_VS_YEAR%"=="2015" set BUILD_VS_LIBDIRPOST=vc14
if "%BUILD_VS_YEAR%"=="2017" set BUILD_VS_LIBDIRPOST=vc14
diff --git a/build_files/windows/detect_msvc2013.cmd b/build_files/windows/detect_msvc2013.cmd
deleted file mode 100644
index 5688d31c4b6..00000000000
--- a/build_files/windows/detect_msvc2013.cmd
+++ /dev/null
@@ -1,3 +0,0 @@
-set BUILD_VS_VER=12
-set BUILD_VS_YEAR=2013
-call "%~dp0\detect_msvc_classic.cmd" \ No newline at end of file
diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd
index 8a6d743978d..e8caddaf4ea 100644
--- a/build_files/windows/parse_arguments.cmd
+++ b/build_files/windows/parse_arguments.cmd
@@ -59,8 +59,6 @@ if NOT "%1" == "" (
set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools
) else if "%1" == "2015" (
set BUILD_VS_YEAR=2015
- ) else if "%1" == "2013" (
- set BUILD_VS_YEAR=2013
) else if "%1" == "packagename" (
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2"
shift /1
diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd
index 2b297120f4b..694b28c88ed 100644
--- a/build_files/windows/show_help.cmd
+++ b/build_files/windows/show_help.cmd
@@ -22,13 +22,13 @@ echo - packagename [newname] ^(override default cpack package name^)
echo - buildir [newdir] ^(override default build folder^)
echo - x86 ^(override host auto-detect and build 32 bit code^)
echo - x64 ^(override host auto-detect and build 64 bit code^)
-echo - 2013 ^(build with visual studio 2013^)
-echo.
-echo Experimental options
-echo - 2015 ^(build with visual studio 2015^)
echo - 2017 ^(build with visual studio 2017^)
echo - 2017pre ^(build with visual studio 2017 pre-release^)
echo - 2017b ^(build with visual studio 2017 Build Tools^)
+
+echo.
+echo Experimental options
+echo - 2015 ^(build with visual studio 2015^)
echo - clang ^(enable building with clang^)
echo - asan ^(enable asan when building with clang^)
echo - ninja ^(enable building with ninja instead of msbuild^)
diff --git a/doc/blender_file_format/BlendFileDnaExporter_25.py b/doc/blender_file_format/BlendFileDnaExporter_25.py
index 64c92c7cf80..a9da79f04d8 100755
--- a/doc/blender_file_format/BlendFileDnaExporter_25.py
+++ b/doc/blender_file_format/BlendFileDnaExporter_25.py
@@ -7,7 +7,7 @@
# 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,
+# 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.
@@ -22,21 +22,21 @@
#
# Name:
# dna.py
-#
+#
# Description:
# Creates a browsable DNA output to HTML.
-#
+#
# Author:
# Jeroen Bakker
-#
+#
# Version:
# v0.1 (12-05-2009) - migration of original source code to python.
# Added code to support blender 2.5 branch
# v0.2 (25-05-2009) - integrated with BlendFileReader.py
-#
+#
# Input:
# blender build executable
-#
+#
# Output:
# dna.html
# dna.css (will only be created when not existing)
@@ -76,12 +76,12 @@ class DNACatalogHTML:
DNACatalog is a catalog of all information in the DNA1 file-block
'''
- def __init__(self, catalog, bpy_module = None):
+ def __init__(self, catalog, bpy_module=None):
self.Catalog = catalog
self.bpy = bpy_module
-
+
def WriteToHTML(self, handle):
-
+
dna_html_template = """
<!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd>
<html>
@@ -105,10 +105,10 @@ class DNACatalogHTML:
${structs_content}
</body>
</html>"""
-
+
header = self.Catalog.Header
bpy = self.bpy
-
+
# ${version} and ${revision}
if bpy:
version = '.'.join(map(str, bpy.app.version))
@@ -116,7 +116,7 @@ class DNACatalogHTML:
else:
version = str(header.Version)
revision = 'Unknown'
-
+
# ${bitness}
if header.PointerSize == 8:
bitness = '64 bit'
@@ -125,10 +125,10 @@ class DNACatalogHTML:
# ${endianness}
if header.LittleEndianness:
- endianess= 'Little endianness'
+ endianess = 'Little endianness'
else:
- endianess= 'Big endianness'
-
+ endianess = 'Big endianness'
+
# ${structs_list}
log.debug("Creating structs index")
structs_list = ''
@@ -136,7 +136,7 @@ class DNACatalogHTML:
structureIndex = 0
for structure in self.Catalog.Structs:
structs_list += list_item.format(structureIndex, structure.Type.Name)
- structureIndex+=1
+ structureIndex += 1
# ${structs_content}
log.debug("Creating structs content")
@@ -144,20 +144,20 @@ class DNACatalogHTML:
for structure in self.Catalog.Structs:
log.debug(structure.Type.Name)
structs_content += self.Structure(structure)
-
+
d = dict(
- version = version,
- revision = revision,
- bitness = bitness,
- endianness = endianess,
- structs_list = structs_list,
- structs_content = structs_content
+ version=version,
+ revision=revision,
+ bitness=bitness,
+ endianness=endianess,
+ structs_list=structs_list,
+ structs_content=structs_content
)
dna_html = Template(dna_html_template).substitute(d)
dna_html = self.format(dna_html)
handle.write(dna_html)
-
+
def Structure(self, structure):
struct_table_template = """
<table><a name="${struct_name}"></a>
@@ -178,23 +178,23 @@ class DNACatalogHTML:
</table>
<label>Total size: ${size} bytes</label><br/>
<label>(<a href="#top">top</a>)</label><br/>"""
-
+
d = dict(
- struct_name = structure.Type.Name,
- fields = self.StructureFields(structure, None, 0),
- size = str(structure.Type.Size)
+ struct_name=structure.Type.Name,
+ fields=self.StructureFields(structure, None, 0),
+ size=str(structure.Type.Size)
)
-
+
struct_table = Template(struct_table_template).substitute(d)
return struct_table
-
+
def StructureFields(self, structure, parentReference, offset):
fields = ''
for field in structure.Fields:
fields += self.StructureField(field, structure, parentReference, offset)
offset += field.Size(self.Catalog.Header)
return fields
-
+
def StructureField(self, field, structure, parentReference, offset):
structure_field_template = """
<tr>
@@ -205,7 +205,7 @@ class DNACatalogHTML:
<td>${offset}</td>
<td>${size}</td>
</tr>"""
-
+
if field.Type.Structure is None or field.Name.IsPointer():
# ${reference}
@@ -216,37 +216,37 @@ class DNACatalogHTML:
struct = '<a href="#{0}">{0}</a>'.format(structure.Type.Name)
else:
struct = structure.Type.Name
-
+
# ${type}
type = field.Type.Name
-
+
# ${name}
name = field.Name.Name
-
+
# ${offset}
# offset already set
-
+
# ${size}
size = field.Size(self.Catalog.Header)
-
+
d = dict(
- reference = reference,
- struct = struct,
- type = type,
- name = name,
- offset = offset,
- size = size
+ reference=reference,
+ struct=struct,
+ type=type,
+ name=name,
+ offset=offset,
+ size=size
)
-
+
structure_field = Template(structure_field_template).substitute(d)
-
+
elif field.Type.Structure is not None:
reference = field.Name.AsReference(parentReference)
- structure_field = self.StructureFields(field.Type.Structure, reference, offset)
+ structure_field = self.StructureFields(field.Type.Structure, reference, offset)
return structure_field
- def indent(self, input, dent, startswith = ''):
+ def indent(self, input, dent, startswith=''):
output = ''
if dent < 0:
for line in input.split('\n'):
@@ -257,19 +257,19 @@ class DNACatalogHTML:
output += line.lstrip() + '\n' # remove indentation completely
elif dent > 0:
for line in input.split('\n'):
- output += ' '* dent + line + '\n'
+ output += ' ' * dent + line + '\n'
return output
-
+
def format(self, input):
diff = {
- '\n<!DOCTYPE':'<!DOCTYPE',
- '\n</ul>' :'</ul>',
- '<a name' :'\n<a name',
- '<tr>\n' :'<tr>',
- '<tr>' :' <tr>',
- '</th>\n' :'</th>',
- '</td>\n' :'</td>',
- '<tbody>\n' :'<tbody>'
+ '\n<!DOCTYPE': '<!DOCTYPE',
+ '\n</ul>': '</ul>',
+ '<a name': '\n<a name',
+ '<tr>\n': '<tr>',
+ '<tr>': ' <tr>',
+ '</th>\n': '</th>',
+ '</td>\n': '</td>',
+ '<tbody>\n': '<tbody>'
}
output = self.indent(input, 0)
for key, value in diff.items():
@@ -283,17 +283,17 @@ class DNACatalogHTML:
'''
css = """
@CHARSET "ISO-8859-1";
-
+
body {
font-family: verdana;
font-size: small;
}
-
+
div.title {
font-size: large;
text-align: center;
}
-
+
h1 {
page-break-before: always;
}
@@ -304,7 +304,7 @@ class DNACatalogHTML:
margin-right: 3%;
padding-left: 40px;
}
-
+
h1:hover{
background-color: #EBEBEB;
}
@@ -312,7 +312,7 @@ class DNACatalogHTML:
h3 {
padding-left: 40px;
}
-
+
table {
border-width: 1px;
border-style: solid;
@@ -321,21 +321,21 @@ class DNACatalogHTML:
width: 94%;
margin: 20px 3% 10px;
}
-
+
caption {
margin-bottom: 5px;
}
-
+
th {
background-color: #000000;
color:#ffffff;
padding-left:5px;
padding-right:5px;
}
-
+
tr {
}
-
+
td {
border-width: 1px;
border-style: solid;
@@ -343,12 +343,12 @@ class DNACatalogHTML:
padding-left:5px;
padding-right:5px;
}
-
+
label {
float:right;
margin-right: 3%;
}
-
+
ul.multicolumn {
list-style:none;
float:left;
@@ -361,18 +361,18 @@ class DNACatalogHTML:
width:200px;
margin-right:0px;
}
-
+
a {
color:#a000a0;
text-decoration:none;
}
-
+
a:hover {
color:#a000a0;
text-decoration:underline;
}
"""
-
+
css = self.indent(css, 0)
handle.write(css)
@@ -389,13 +389,13 @@ def usage():
print("\tdefault: % blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py")
print("\twith options: % blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py -- --dna-keep-blend --dna-debug\n")
-
+
######################################################
# Main
######################################################
def main():
-
+
import os, os.path
try:
@@ -408,37 +408,37 @@ def main():
else:
filename = 'dna'
dir = os.path.dirname(__file__)
- Path_Blend = os.path.join(dir, filename + '.blend') # temporary blend file
- Path_HTML = os.path.join(dir, filename + '.html') # output html file
- Path_CSS = os.path.join(dir, 'dna.css') # output css file
+ Path_Blend = os.path.join(dir, filename + '.blend') # temporary blend file
+ Path_HTML = os.path.join(dir, filename + '.html') # output html file
+ Path_CSS = os.path.join(dir, 'dna.css') # output css file
# create a blend file for dna parsing
if not os.path.exists(Path_Blend):
log.info("1: write temp blend file with SDNA info")
log.info(" saving to: " + Path_Blend)
try:
- bpy.ops.wm.save_as_mainfile(filepath = Path_Blend, copy = True, compress = False)
+ bpy.ops.wm.save_as_mainfile(filepath=Path_Blend, copy=True, compress=False)
except:
log.error("Filename {0} does not exist and can't be created... quitting".format(Path_Blend))
return
else:
log.info("1: found blend file with SDNA info")
log.info(" " + Path_Blend)
-
+
# read blend header from blend file
log.info("2: read file:")
-
+
if not dir in sys.path:
sys.path.append(dir)
import BlendFileReader
-
+
handle = BlendFileReader.openBlendFile(Path_Blend)
blendfile = BlendFileReader.BlendFile(handle)
catalog = DNACatalogHTML(blendfile.Catalog, bpy)
# close temp file
handle.close()
-
+
# deleting or not?
if '--dna-keep-blend' in sys.argv:
# keep the blend, useful for studying hexdumps
@@ -449,7 +449,7 @@ def main():
log.info("5: close and delete temp blend:")
log.info(" {0}".format(Path_Blend))
os.remove(Path_Blend)
-
+
# export dna to xhtml
log.info("6: export sdna to xhtml file: %r" % Path_HTML)
handleHTML = open(Path_HTML, "w")
@@ -466,12 +466,12 @@ def main():
if not bpy.app.background:
log.info("7: quit blender")
bpy.ops.wm.exit_blender()
-
+
except ImportError:
log.warning(" skipping, not running in Blender")
usage()
sys.exit(2)
-
+
if __name__ == '__main__':
main()
diff --git a/doc/blender_file_format/BlendFileReader.py b/doc/blender_file_format/BlendFileReader.py
index a4d2f494c5b..d4aed722578 100644
--- a/doc/blender_file_format/BlendFileReader.py
+++ b/doc/blender_file_format/BlendFileReader.py
@@ -7,7 +7,7 @@
# 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,
+# 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.
@@ -34,6 +34,7 @@ log = logging.getLogger("BlendFileReader")
# module global routines
######################################################
+
def ReadString(handle, length):
'''
ReadString reads a String of given length or a zero terminating String
@@ -45,7 +46,7 @@ def ReadString(handle, length):
# length == 0 means we want a zero terminating string
result = ""
s = ReadString(handle, 1)
- while s!="\0":
+ while s != "\0":
result += s
s = ReadString(handle, 1)
return result
@@ -57,7 +58,7 @@ def Read(type, handle, fileheader):
'''
def unpacked_bytes(type_char, size):
return struct.unpack(fileheader.StructPre + type_char, handle.read(size))[0]
-
+
if type == 'ushort':
return unpacked_bytes("H", 2) # unsigned short
elif type == 'short':
@@ -94,10 +95,10 @@ def openBlendFile(filename):
log.debug("decompressing started")
fs = gzip.open(filename, "rb")
handle = tempfile.TemporaryFile()
- data = fs.read(1024*1024)
- while data:
- handle.write(data)
- data = fs.read(1024*1024)
+ data = fs.read(1024 * 1024)
+ while data:
+ handle.write(data)
+ data = fs.read(1024 * 1024)
log.debug("decompressing finished")
fs.close()
log.debug("resetting decompressed file")
@@ -112,7 +113,7 @@ def Align(handle):
offset = handle.tell()
trim = offset % 4
if trim != 0:
- handle.seek(4-trim, os.SEEK_CUR)
+ handle.seek(4 - trim, os.SEEK_CUR)
######################################################
@@ -121,14 +122,14 @@ def Align(handle):
class BlendFile:
'''
- Reads a blendfile and store the header, all the fileblocks, and catalogue
+ Reads a blendfile and store the header, all the fileblocks, and catalogue
structs foound in the DNA fileblock
-
+
- BlendFile.Header (BlendFileHeader instance)
- BlendFile.Blocks (list of BlendFileBlock instances)
- BlendFile.Catalog (DNACatalog instance)
'''
-
+
def __init__(self, handle):
log.debug("initializing reading blend-file")
self.Header = BlendFileHeader(handle)
@@ -141,13 +142,13 @@ class BlendFile:
found_dna_block = True
else:
fileblock.Header.skip(handle)
-
+
self.Blocks.append(fileblock)
fileblock = BlendFileBlock(handle, self)
-
+
# appending last fileblock, "ENDB"
self.Blocks.append(fileblock)
-
+
# seems unused?
"""
def FindBlendFileBlocksWithCode(self, code):
@@ -164,27 +165,27 @@ class BlendFileHeader:
BlendFileHeader allocates the first 12 bytes of a blend file.
It contains information about the hardware architecture.
Header example: BLENDER_v254
-
+
BlendFileHeader.Magic (str)
BlendFileHeader.PointerSize (int)
BlendFileHeader.LittleEndianness (bool)
BlendFileHeader.StructPre (str) see http://docs.python.org/py3k/library/struct.html#byte-order-size-and-alignment
BlendFileHeader.Version (int)
'''
-
+
def __init__(self, handle):
log.debug("reading blend-file-header")
-
+
self.Magic = ReadString(handle, 7)
log.debug(self.Magic)
-
+
pointersize = ReadString(handle, 1)
log.debug(pointersize)
if pointersize == "-":
self.PointerSize = 8
if pointersize == "_":
self.PointerSize = 4
-
+
endianness = ReadString(handle, 1)
log.debug(endianness)
if endianness == "v":
@@ -193,11 +194,11 @@ class BlendFileHeader:
if endianness == "V":
self.LittleEndianness = False
self.StructPre = ">"
-
+
version = ReadString(handle, 3)
log.debug(version)
self.Version = int(version)
-
+
log.debug("{0} {1} {2} {3}".format(self.Magic, self.PointerSize, self.LittleEndianness, version))
@@ -206,11 +207,11 @@ class BlendFileBlock:
BlendFileBlock.File (BlendFile)
BlendFileBlock.Header (FileBlockHeader)
'''
-
+
def __init__(self, handle, blendfile):
self.File = blendfile
self.Header = FileBlockHeader(handle, blendfile.Header)
-
+
def Get(self, handle, path):
log.debug("find dna structure")
dnaIndex = self.Header.SDNAIndex
@@ -232,7 +233,7 @@ class FileBlockHeader:
Count (int)
FileOffset (= file pointer of datablock)
'''
-
+
def __init__(self, handle, fileheader):
self.Code = ReadString(handle, 4).strip()
if self.Code != "ENDB":
@@ -257,28 +258,28 @@ class FileBlockHeader:
class DNACatalog:
'''
DNACatalog is a catalog of all information in the DNA1 file-block
-
+
Header = None
Names = None
Types = None
Structs = None
'''
-
+
def __init__(self, fileheader, handle):
log.debug("building DNA catalog")
- self.Names=[]
- self.Types=[]
- self.Structs=[]
+ self.Names = []
+ self.Types = []
+ self.Structs = []
self.Header = fileheader
-
+
SDNA = ReadString(handle, 4)
-
+
# names
NAME = ReadString(handle, 4)
numberOfNames = Read('uint', handle, fileheader)
log.debug("building #{0} names".format(numberOfNames))
for i in range(numberOfNames):
- name = ReadString(handle,0)
+ name = ReadString(handle, 0)
self.Names.append(DNAName(name))
Align(handle)
@@ -287,7 +288,7 @@ class DNACatalog:
numberOfTypes = Read('uint', handle, fileheader)
log.debug("building #{0} types".format(numberOfTypes))
for i in range(numberOfTypes):
- type = ReadString(handle,0)
+ type = ReadString(handle, 0)
self.Types.append(DNAType(type))
Align(handle)
@@ -321,24 +322,24 @@ class DNACatalog:
class DNAName:
'''
DNAName is a C-type name stored in the DNA.
-
+
Name = str
'''
-
+
def __init__(self, name):
self.Name = name
-
+
def AsReference(self, parent):
if parent is None:
result = ""
else:
- result = parent+"."
-
+ result = parent + "."
+
result = result + self.ShortName()
return result
def ShortName(self):
- result = self.Name;
+ result = self.Name
result = result.replace("*", "")
result = result.replace("(", "")
result = result.replace(")", "")
@@ -346,12 +347,12 @@ class DNAName:
if Index != -1:
result = result[0:Index]
return result
-
+
def IsPointer(self):
- return self.Name.find("*")>-1
+ return self.Name.find("*") > -1
def IsMethodPointer(self):
- return self.Name.find("(*")>-1
+ return self.Name.find("(*") > -1
def ArraySize(self):
result = 1
@@ -360,10 +361,10 @@ class DNAName:
while Index != -1:
Index2 = Temp.find("]")
- result*=int(Temp[Index+1:Index2])
- Temp = Temp[Index2+1:]
+ result *= int(Temp[Index + 1:Index2])
+ Temp = Temp[Index2 + 1:]
Index = Temp.find("[")
-
+
return result
@@ -375,46 +376,46 @@ class DNAType:
Size = int
Structure = DNAStructure
'''
-
+
def __init__(self, aName):
self.Name = aName
- self.Structure=None
+ self.Structure = None
class DNAStructure:
'''
DNAType is a C-type structure stored in the DNA
-
+
Type = DNAType
Fields = [DNAField]
'''
-
+
def __init__(self, aType):
self.Type = aType
self.Type.Structure = self
- self.Fields=[]
-
+ self.Fields = []
+
def GetField(self, header, handle, path):
splitted = path.partition(".")
name = splitted[0]
rest = splitted[2]
- offset = 0;
+ offset = 0
for field in self.Fields:
if field.Name.ShortName() == name:
- log.debug("found "+name+"@"+str(offset))
+ log.debug("found " + name + "@" + str(offset))
handle.seek(offset, os.SEEK_CUR)
return field.DecodeField(header, handle, rest)
else:
offset += field.Size(header)
- log.debug("error did not find "+path)
+ log.debug("error did not find " + path)
return None
class DNAField:
'''
DNAField is a coupled DNAType and DNAName.
-
+
Type = DNAType
Name = DNAName
'''
@@ -422,25 +423,24 @@ class DNAField:
def __init__(self, aType, aName):
self.Type = aType
self.Name = aName
-
+
def Size(self, header):
if self.Name.IsPointer() or self.Name.IsMethodPointer():
- return header.PointerSize*self.Name.ArraySize()
+ return header.PointerSize * self.Name.ArraySize()
else:
- return self.Type.Size*self.Name.ArraySize()
+ return self.Type.Size * self.Name.ArraySize()
def DecodeField(self, header, handle, path):
if path == "":
if self.Name.IsPointer():
return Read('pointer', handle, header)
- if self.Type.Name=="int":
+ if self.Type.Name == "int":
return Read('int', handle, header)
- if self.Type.Name=="short":
+ if self.Type.Name == "short":
return Read('short', handle, header)
- if self.Type.Name=="float":
+ if self.Type.Name == "float":
return Read('float', handle, header)
- if self.Type.Name=="char":
+ if self.Type.Name == "char":
return ReadString(handle, self.Name.ArraySize())
else:
return self.Type.Structure.GetField(header, handle, path)
-
diff --git a/doc/manpage/blender.1.py b/doc/manpage/blender.1.py
index 52856717b4a..0890547906a 100755
--- a/doc/manpage/blender.1.py
+++ b/doc/manpage/blender.1.py
@@ -42,6 +42,7 @@ def man_format(data):
data = data.replace("\t", " ")
return data
+
if len(sys.argv) != 3:
import getopt
raise getopt.GetoptError("Usage: %s <path-to-blender> <output-filename>" % sys.argv[0])
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index b0200c0f7d8..6c631891418 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -73,6 +73,8 @@ def rna_info_BuildRNAInfo_cache():
if rna_info_BuildRNAInfo_cache.ret is None:
rna_info_BuildRNAInfo_cache.ret = rna_info.BuildRNAInfo()
return rna_info_BuildRNAInfo_cache.ret
+
+
rna_info_BuildRNAInfo_cache.ret = None
# --- end rna_info cache
@@ -332,9 +334,9 @@ except ImportError:
# to avoid having to match Blender's source tree.
EXTRA_SOURCE_FILES = (
"../../../release/scripts/templates_py/bmesh_simple.py",
- "../../../release/scripts/templates_py/manipulator_operator.py",
- "../../../release/scripts/templates_py/manipulator_operator_target.py",
- "../../../release/scripts/templates_py/manipulator_simple.py",
+ "../../../release/scripts/templates_py/gizmo_operator.py",
+ "../../../release/scripts/templates_py/gizmo_operator_target.py",
+ "../../../release/scripts/templates_py/gizmo_simple.py",
"../../../release/scripts/templates_py/operator_simple.py",
"../../../release/scripts/templates_py/ui_panel_simple.py",
"../../../release/scripts/templates_py/ui_previews_custom_icon.py",
@@ -434,7 +436,7 @@ else:
BLENDER_VERSION_DOTS = ".".join(blender_version_strings)
if BLENDER_REVISION != "Unknown":
# '2.62a SHA1' (release) or '2.62.1 SHA1' (non-release)
- BLENDER_VERSION_DOTS += " " + BLENDER_REVISION
+ BLENDER_VERSION_DOTS += " " + BLENDER_REVISION
if is_release:
# '2_62a_release'
@@ -516,6 +518,8 @@ def escape_rst(text):
""" Escape plain text which may contain characters used by RST.
"""
return text.translate(escape_rst.trans)
+
+
escape_rst.trans = str.maketrans({
"`": "\\`",
"|": "\\|",
@@ -1018,6 +1022,7 @@ def pymodule2sphinx(basepath, module_name, module, title):
file.close()
+
# Changes in Blender will force errors here
context_type_map = {
"active_base": ("ObjectBase", False),
diff --git a/doc/python_api/sphinx_doc_gen_monkeypatch.py b/doc/python_api/sphinx_doc_gen_monkeypatch.py
index 9fdbf613d96..58d09f71e9a 100644
--- a/doc/python_api/sphinx_doc_gen_monkeypatch.py
+++ b/doc/python_api/sphinx_doc_gen_monkeypatch.py
@@ -21,7 +21,7 @@
# <pep8 compliant>
bpy_types_Operator_bl_property__doc__ = (
-"""
+ """
The name of a property to use as this operators primary property.
Currently this is only used to select the default property when
expanding an operator into a menu.
diff --git a/doc/python_api/sphinx_doc_update.py b/doc/python_api/sphinx_doc_update.py
index 561e58dec66..af44137aca4 100755
--- a/doc/python_api/sphinx_doc_update.py
+++ b/doc/python_api/sphinx_doc_update.py
@@ -29,7 +29,7 @@ You'll need to specify your user login and password, obviously.
Example usage:
- ./sphinx_doc_update.py --mirror ../../../docs/remote_api_backup/ --source ../.. --blender ../../../build_cmake/bin/blender --user foobar --password barfoo
+ ./sphinx_doc_update.py --mirror ../../../docs/remote_api_backup/ --source ../.. --blender ../../../build_cmake/bin/blender --user foobar --password barfoo
"""
@@ -107,14 +107,16 @@ def main():
with tempfile.TemporaryDirectory() as tmp_dir:
# II) Generate doc source in temp dir.
- doc_gen_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
- "--python", "%s/doc/python_api/sphinx_doc_gen.py" % args.source_dir, "--",
- "--output", tmp_dir)
+ doc_gen_cmd = (
+ args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
+ "--python", "%s/doc/python_api/sphinx_doc_gen.py" % args.source_dir, "--",
+ "--output", tmp_dir
+ )
subprocess.run(doc_gen_cmd)
# III) Get Blender version info.
getver_file = os.path.join(tmp_dir, "blendver.txt")
- getver_script = (""
+ getver_script = (
"import sys, bpy\n"
"with open(sys.argv[-1], 'w') as f:\n"
" is_release = bpy.app.version_cycle in {'rc', 'release'}\n"
@@ -124,7 +126,8 @@ def main():
" f.write('%d.%d%s\\n' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n"
" if is_release else '%s\\n' % branch)\n"
" f.write('%d_%d%s_release' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n"
- " if is_release else '%d_%d_%d' % bpy.app.version)\n")
+ " if is_release else '%d_%d_%d' % bpy.app.version)\n"
+ )
get_ver_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
"--python-expr", getver_script, "--", getver_file)
subprocess.run(get_ver_cmd)
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 1a050892836..1459100d415 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -34,7 +34,6 @@ add_subdirectory(opencolorio)
add_subdirectory(mikktspace)
add_subdirectory(glew-mx)
add_subdirectory(eigen)
-add_subdirectory(gawain)
if(WITH_AUDASPACE)
add_subdirectory(audaspace)
diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt
index cfca45600a5..936da0075fe 100644
--- a/intern/cycles/app/CMakeLists.txt
+++ b/intern/cycles/app/CMakeLists.txt
@@ -60,6 +60,10 @@ link_directories(${OPENIMAGEIO_LIBPATH}
${TIFF_LIBPATH}
${OPENEXR_LIBPATH})
+if(WITH_OPENCOLORIO)
+ link_directories(${OPENCOLORIO_LIBPATH})
+endif()
+
add_definitions(${GL_DEFINITIONS})
include_directories(${INC})
@@ -81,7 +85,6 @@ macro(cycles_target_link_libraries target)
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
endif()
if(WITH_OPENCOLORIO)
- link_directories(${OPENCOLORIO_LIBPATH})
target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
endif()
target_link_libraries(
diff --git a/intern/cycles/app/cycles_cubin_cc.cpp b/intern/cycles/app/cycles_cubin_cc.cpp
index 3c83bf2dae3..01a1234531b 100644
--- a/intern/cycles/app/cycles_cubin_cc.cpp
+++ b/intern/cycles/app/cycles_cubin_cc.cpp
@@ -164,7 +164,7 @@ bool link_ptxas(CompilationSettings &settings)
ptx += " --verbose";
printf("%s\n", ptx.c_str());
}
-
+
int pxresult = system(ptx.c_str());
if(pxresult) {
fprintf(stderr, "Error: ptxas failed (%x)\n\n", pxresult);
diff --git a/intern/cycles/app/cycles_server.cpp b/intern/cycles/app/cycles_server.cpp
index e65b9d769e4..e2166473aa3 100644
--- a/intern/cycles/app/cycles_server.cpp
+++ b/intern/cycles/app/cycles_server.cpp
@@ -112,4 +112,3 @@ int main(int argc, const char **argv)
return 0;
}
-
diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp
index c682744f5fa..1ec8d18f410 100644
--- a/intern/cycles/app/cycles_standalone.cpp
+++ b/intern/cycles/app/cycles_standalone.cpp
@@ -524,4 +524,3 @@ int main(int argc, const char **argv)
return 0;
}
-
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index a46955322e3..895a83818df 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -184,7 +184,7 @@ static bool xml_equal_string(xml_node node, const char *name, const char *value)
if(attr)
return string_iequals(attr.value(), value);
-
+
return false;
}
@@ -697,4 +697,3 @@ void xml_read_file(Scene *scene, const char *filepath)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/app/io_export_cycles_xml.py b/intern/cycles/app/io_export_cycles_xml.py
index d02487aefa4..437a504d014 100644
--- a/intern/cycles/app/io_export_cycles_xml.py
+++ b/intern/cycles/app/io_export_cycles_xml.py
@@ -39,7 +39,7 @@ def write(node, fname):
f = open(fname, "w")
f.write(s)
-
+
class CyclesXMLSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
@@ -53,11 +53,11 @@ class CyclesXMLSettings(bpy.types.PropertyGroup):
maxlen=256,
default='',
subtype='FILE_PATH')
-
+
@classmethod
def unregister(cls):
del bpy.types.Scene.cycles_xml
-
+
# User Interface Drawing Code
class RenderButtonsPanel():
bl_space_type = 'PROPERTIES'
@@ -74,13 +74,13 @@ class PHYSICS_PT_fluid_export(RenderButtonsPanel, bpy.types.Panel):
def draw(self, context):
layout = self.layout
-
+
cycles = context.scene.cycles_xml
-
+
#layout.prop(cycles, "filepath")
layout.operator("export_mesh.cycles_xml")
-
+
# Export Operator
class ExportCyclesXML(bpy.types.Operator, ExportHelper):
bl_idname = "export_mesh.cycles_xml"
@@ -117,23 +117,23 @@ class ExportCyclesXML(bpy.types.Operator, ExportHelper):
P += "%f %f %f " % (v.co[0], v.co[1], v.co[2])
verts_and_uvs = zip(mesh.tessfaces, mesh.tessface_uv_textures.active.data)
-
+
for f, uvf in verts_and_uvs:
vcount = len(f.vertices)
nverts += str(vcount) + " "
for v in f.vertices:
verts += str(v) + " "
-
+
uvs += str(uvf.uv1[0]) + " " + str(uvf.uv1[1]) + " "
uvs += str(uvf.uv2[0]) + " " + str(uvf.uv2[1]) + " "
uvs += str(uvf.uv3[0]) + " " + str(uvf.uv3[1]) + " "
if vcount==4:
uvs += " " + str(uvf.uv4[0]) + " " + str(uvf.uv4[1]) + " "
-
+
node = etree.Element('mesh', attrib={'nverts': nverts.strip(), 'verts': verts.strip(), 'P': P, 'UV' : uvs.strip()})
-
+
# write to file
write(node, filepath)
@@ -147,5 +147,3 @@ def unregister():
if __name__ == "__main__":
register()
-
-
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py
index 6e64ed609b7..d222b4c8038 100644
--- a/intern/cycles/blender/addon/__init__.py
+++ b/intern/cycles/blender/addon/__init__.py
@@ -45,9 +45,9 @@ if "bpy" in locals():
import bpy
from . import (
- engine,
- version_update,
- )
+ engine,
+ version_update,
+)
class CyclesRender(bpy.types.RenderEngine):
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index b689c750be0..5c52a8bcce9 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -82,15 +82,17 @@ def _parse_command_line():
if args.cycles_resumable_current_chunk is not None:
import _cycles
_cycles.set_resumable_chunk(
- int(args.cycles_resumable_num_chunks),
- int(args.cycles_resumable_current_chunk))
+ int(args.cycles_resumable_num_chunks),
+ int(args.cycles_resumable_current_chunk),
+ )
elif args.cycles_resumable_start_chunk is not None and \
- args.cycles_resumable_end_chunk:
+ args.cycles_resumable_end_chunk:
import _cycles
_cycles.set_resumable_chunk_range(
- int(args.cycles_resumable_num_chunks),
- int(args.cycles_resumable_start_chunk),
- int(args.cycles_resumable_end_chunk))
+ int(args.cycles_resumable_num_chunks),
+ int(args.cycles_resumable_start_chunk),
+ int(args.cycles_resumable_end_chunk),
+ )
def init():
@@ -209,6 +211,7 @@ def system_info():
import _cycles
return _cycles.system_info()
+
def register_passes(engine, scene, srl):
engine.register_pass(scene, srl, "Combined", 4, "RGBA", 'COLOR')
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index df6949f2095..7f0cb7e875f 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -17,12 +17,14 @@
# <pep8 compliant>
import bpy
-from bpy.props import (BoolProperty,
- EnumProperty,
- FloatProperty,
- IntProperty,
- PointerProperty,
- StringProperty)
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ IntProperty,
+ PointerProperty,
+ StringProperty,
+)
# enums
@@ -31,7 +33,7 @@ import _cycles
enum_devices = (
('CPU', "CPU", "Use CPU for rendering"),
('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in the system tab in the user preferences"),
- )
+)
if _cycles.with_network:
enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),)
@@ -39,34 +41,34 @@ if _cycles.with_network:
enum_feature_set = (
('SUPPORTED', "Supported", "Only use finished and supported features"),
('EXPERIMENTAL', "Experimental", "Use experimental and incomplete features that might be broken or change in the future", 'ERROR', 1),
- )
+)
enum_displacement_methods = (
('BUMP', "Bump Only", "Bump mapping to simulate the appearance of displacement"),
('DISPLACEMENT', "Displacement Only", "Use true displacement of surface only, requires fine subdivision"),
('BOTH', "Displacement and Bump", "Combination of true displacement and bump mapping for finer detail"),
- )
+)
enum_bvh_layouts = (
('BVH2', "BVH2", "", 1),
('BVH4', "BVH4", "", 2),
- )
+)
enum_bvh_types = (
('DYNAMIC_BVH', "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"),
('STATIC_BVH', "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster"),
- )
+)
enum_filter_types = (
('BOX', "Box", "Box filter"),
('GAUSSIAN', "Gaussian", "Gaussian filter"),
('BLACKMAN_HARRIS', "Blackman-Harris", "Blackman-Harris filter"),
- )
+)
enum_aperture_types = (
('RADIUS', "Radius", "Directly change the size of the aperture"),
('FSTOP', "F-stop", "Change the size of the aperture by f-stop"),
- )
+)
enum_panorama_types = (
('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"),
@@ -74,23 +76,23 @@ enum_panorama_types = (
('FISHEYE_EQUISOLID', "Fisheye Equisolid",
"Similar to most fisheye modern lens, takes sensor dimensions into consideration"),
('MIRRORBALL', "Mirror Ball", "Uses the mirror ball mapping"),
- )
+)
enum_curve_primitives = (
('TRIANGLES', "Triangles", "Create triangle geometry around strands"),
('LINE_SEGMENTS', "Line Segments", "Use line segment primitives"),
('CURVE_SEGMENTS', "Curve Segments", "Use segmented cardinal curve primitives"),
- )
+)
enum_triangle_curves = (
('CAMERA_TRIANGLES', "Planes", "Create individual triangles forming planes that face camera"),
('TESSELLATED_TRIANGLES', "Tessellated", "Create mesh surrounding each strand"),
- )
+)
enum_curve_shape = (
('RIBBONS', "Ribbons", "Ignore thickness of each strand"),
('THICK', "Thick", "Use thickness of strand when rendering"),
- )
+)
enum_tile_order = (
('CENTER', "Center", "Render from center to the edges"),
@@ -99,46 +101,46 @@ enum_tile_order = (
('TOP_TO_BOTTOM', "Top to Bottom", "Render from top to bottom"),
('BOTTOM_TO_TOP', "Bottom to Top", "Render from bottom to top"),
('HILBERT_SPIRAL', "Hilbert Spiral", "Render in a Hilbert Spiral"),
- )
+)
enum_use_layer_samples = (
('USE', "Use", "Per render layer number of samples override scene samples"),
('BOUNDED', "Bounded", "Bound per render layer number of samples by global samples"),
('IGNORE', "Ignore", "Ignore per render layer number of samples"),
- )
+)
enum_sampling_pattern = (
('SOBOL', "Sobol", "Use Sobol random sampling pattern"),
('CORRELATED_MUTI_JITTER', "Correlated Multi-Jitter", "Use Correlated Multi-Jitter random sampling pattern"),
- )
+)
enum_integrator = (
('BRANCHED_PATH', "Branched Path Tracing", "Path tracing integrator that branches on the first bounce, giving more control over the number of light and material samples"),
('PATH', "Path Tracing", "Pure path tracing integrator"),
- )
+)
enum_volume_sampling = (
('DISTANCE', "Distance", "Use distance sampling, best for dense volumes with lights far away"),
('EQUIANGULAR', "Equiangular", "Use equiangular sampling, best for volumes with low density with light inside or near the volume"),
('MULTIPLE_IMPORTANCE', "Multiple Importance", "Combine distance and equi-angular sampling for volumes where neither method is ideal"),
- )
+)
enum_volume_interpolation = (
('LINEAR', "Linear", "Good smoothness and speed"),
('CUBIC', "Cubic", "Smoothed high quality interpolation, but slower")
- )
+)
enum_world_mis = (
('NONE', "None", "Don't sample the background, faster but might cause noise for non-solid backgrounds"),
('AUTOMATIC', "Auto", "Automatically try to determine the best setting"),
('MANUAL', "Manual", "Manually set the resolution of the sampling map, higher values are slower and require more memory but reduce noise")
- )
+)
enum_device_type = (
('CPU', "CPU", "CPU", 0),
('CUDA', "CUDA", "CUDA", 1),
('OPENCL', "OpenCL", "OpenCL", 2)
- )
+)
enum_texture_limit = (
('OFF', "No Limit", "No texture size limit", 0),
@@ -149,417 +151,418 @@ enum_texture_limit = (
('2048', "2048", "Limit texture size to 2048 pixels", 5),
('4096', "4096", "Limit texture size to 4096 pixels", 6),
('8192', "8192", "Limit texture size to 8192 pixels", 7),
- )
+)
+
class CyclesRenderSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Scene.cycles = PointerProperty(
- name="Cycles Render Settings",
- description="Cycles render settings",
- type=cls,
- )
+ name="Cycles Render Settings",
+ description="Cycles render settings",
+ type=cls,
+ )
cls.device = EnumProperty(
- name="Device",
- description="Device to use for rendering",
- items=enum_devices,
- default='CPU',
- )
+ name="Device",
+ description="Device to use for rendering",
+ items=enum_devices,
+ default='CPU',
+ )
cls.feature_set = EnumProperty(
- name="Feature Set",
- description="Feature set to use for rendering",
- items=enum_feature_set,
- default='SUPPORTED',
- )
+ name="Feature Set",
+ description="Feature set to use for rendering",
+ items=enum_feature_set,
+ default='SUPPORTED',
+ )
cls.shading_system = BoolProperty(
- name="Open Shading Language",
- description="Use Open Shading Language (CPU rendering only)",
- )
+ name="Open Shading Language",
+ description="Use Open Shading Language (CPU rendering only)",
+ )
cls.progressive = EnumProperty(
- name="Integrator",
- description="Method to sample lights and materials",
- items=enum_integrator,
- default='PATH',
- )
+ name="Integrator",
+ description="Method to sample lights and materials",
+ items=enum_integrator,
+ default='PATH',
+ )
cls.use_square_samples = BoolProperty(
- name="Square Samples",
- description="Square sampling values for easier artist control",
- default=False,
- )
+ name="Square Samples",
+ description="Square sampling values for easier artist control",
+ default=False,
+ )
cls.samples = IntProperty(
- name="Samples",
- description="Number of samples to render for each pixel",
- min=1, max=2147483647,
- default=128,
- )
+ name="Samples",
+ description="Number of samples to render for each pixel",
+ min=1, max=2147483647,
+ default=128,
+ )
cls.preview_samples = IntProperty(
- name="Preview Samples",
- description="Number of samples to render in the viewport, unlimited if 0",
- min=0, max=2147483647,
- default=32,
- )
+ name="Preview Samples",
+ description="Number of samples to render in the viewport, unlimited if 0",
+ min=0, max=2147483647,
+ default=32,
+ )
cls.preview_pause = BoolProperty(
- name="Pause Preview",
- description="Pause all viewport preview renders",
- default=False,
- )
+ name="Pause Preview",
+ description="Pause all viewport preview renders",
+ default=False,
+ )
cls.aa_samples = IntProperty(
- name="AA Samples",
- description="Number of antialiasing samples to render for each pixel",
- min=1, max=2097151,
- default=128,
- )
+ name="AA Samples",
+ description="Number of antialiasing samples to render for each pixel",
+ min=1, max=2097151,
+ default=128,
+ )
cls.preview_aa_samples = IntProperty(
- name="AA Samples",
- description="Number of antialiasing samples to render in the viewport, unlimited if 0",
- min=0, max=2097151,
- default=32,
- )
+ name="AA Samples",
+ description="Number of antialiasing samples to render in the viewport, unlimited if 0",
+ min=0, max=2097151,
+ default=32,
+ )
cls.diffuse_samples = IntProperty(
- name="Diffuse Samples",
- description="Number of diffuse bounce samples to render for each AA sample",
- min=1, max=1024,
- default=1,
- )
+ name="Diffuse Samples",
+ description="Number of diffuse bounce samples to render for each AA sample",
+ min=1, max=1024,
+ default=1,
+ )
cls.glossy_samples = IntProperty(
- name="Glossy Samples",
- description="Number of glossy bounce samples to render for each AA sample",
- min=1, max=1024,
- default=1,
- )
+ name="Glossy Samples",
+ description="Number of glossy bounce samples to render for each AA sample",
+ min=1, max=1024,
+ default=1,
+ )
cls.transmission_samples = IntProperty(
- name="Transmission Samples",
- description="Number of transmission bounce samples to render for each AA sample",
- min=1, max=1024,
- default=1,
- )
+ name="Transmission Samples",
+ description="Number of transmission bounce samples to render for each AA sample",
+ min=1, max=1024,
+ default=1,
+ )
cls.ao_samples = IntProperty(
- name="Ambient Occlusion Samples",
- description="Number of ambient occlusion samples to render for each AA sample",
- min=1, max=1024,
- default=1,
- )
+ name="Ambient Occlusion Samples",
+ description="Number of ambient occlusion samples to render for each AA sample",
+ min=1, max=1024,
+ default=1,
+ )
cls.mesh_light_samples = IntProperty(
- name="Mesh Light Samples",
- description="Number of mesh emission light samples to render for each AA sample",
- min=1, max=1024,
- default=1,
- )
+ name="Mesh Light Samples",
+ description="Number of mesh emission light samples to render for each AA sample",
+ min=1, max=1024,
+ default=1,
+ )
cls.subsurface_samples = IntProperty(
- name="Subsurface Samples",
- description="Number of subsurface scattering samples to render for each AA sample",
- min=1, max=1024,
- default=1,
- )
+ name="Subsurface Samples",
+ description="Number of subsurface scattering samples to render for each AA sample",
+ min=1, max=1024,
+ default=1,
+ )
cls.volume_samples = IntProperty(
- name="Volume Samples",
- description="Number of volume scattering samples to render for each AA sample",
- min=1, max=1024,
- default=1,
- )
+ name="Volume Samples",
+ description="Number of volume scattering samples to render for each AA sample",
+ min=1, max=1024,
+ default=1,
+ )
cls.sampling_pattern = EnumProperty(
- name="Sampling Pattern",
- description="Random sampling pattern used by the integrator",
- items=enum_sampling_pattern,
- default='SOBOL',
- )
+ name="Sampling Pattern",
+ description="Random sampling pattern used by the integrator",
+ items=enum_sampling_pattern,
+ default='SOBOL',
+ )
cls.use_layer_samples = EnumProperty(
- name="Layer Samples",
- description="How to use per render layer sample settings",
- items=enum_use_layer_samples,
- default='USE',
- )
+ name="Layer Samples",
+ description="How to use per render layer sample settings",
+ items=enum_use_layer_samples,
+ default='USE',
+ )
cls.sample_all_lights_direct = BoolProperty(
- name="Sample All Direct Lights",
- description="Sample all lights (for direct samples), rather than randomly picking one",
- default=True,
- )
+ name="Sample All Direct Lights",
+ description="Sample all lights (for direct samples), rather than randomly picking one",
+ default=True,
+ )
cls.sample_all_lights_indirect = BoolProperty(
- name="Sample All Indirect Lights",
- description="Sample all lights (for indirect samples), rather than randomly picking one",
- default=True,
- )
+ name="Sample All Indirect Lights",
+ description="Sample all lights (for indirect samples), rather than randomly picking one",
+ default=True,
+ )
cls.light_sampling_threshold = FloatProperty(
- name="Light Sampling Threshold",
- description="Probabilistically terminate light samples when the light contribution is below this threshold (more noise but faster rendering). "
- "Zero disables the test and never ignores lights",
- min=0.0, max=1.0,
- default=0.01,
- )
+ name="Light Sampling Threshold",
+ description="Probabilistically terminate light samples when the light contribution is below this threshold (more noise but faster rendering). "
+ "Zero disables the test and never ignores lights",
+ min=0.0, max=1.0,
+ default=0.01,
+ )
cls.caustics_reflective = BoolProperty(
- name="Reflective Caustics",
- description="Use reflective caustics, resulting in a brighter image (more noise but added realism)",
- default=True,
- )
+ name="Reflective Caustics",
+ description="Use reflective caustics, resulting in a brighter image (more noise but added realism)",
+ default=True,
+ )
cls.caustics_refractive = BoolProperty(
- name="Refractive Caustics",
- description="Use refractive caustics, resulting in a brighter image (more noise but added realism)",
- default=True,
- )
+ name="Refractive Caustics",
+ description="Use refractive caustics, resulting in a brighter image (more noise but added realism)",
+ default=True,
+ )
cls.blur_glossy = FloatProperty(
- name="Filter Glossy",
- description="Adaptively blur glossy shaders after blurry bounces, "
- "to reduce noise at the cost of accuracy",
- min=0.0, max=10.0,
- default=1.0,
- )
+ name="Filter Glossy",
+ description="Adaptively blur glossy shaders after blurry bounces, "
+ "to reduce noise at the cost of accuracy",
+ min=0.0, max=10.0,
+ default=1.0,
+ )
cls.max_bounces = IntProperty(
- name="Max Bounces",
- description="Total maximum number of bounces",
- min=0, max=1024,
- default=12,
- )
+ name="Max Bounces",
+ description="Total maximum number of bounces",
+ min=0, max=1024,
+ default=12,
+ )
cls.diffuse_bounces = IntProperty(
- name="Diffuse Bounces",
- description="Maximum number of diffuse reflection bounces, bounded by total maximum",
- min=0, max=1024,
- default=4,
- )
+ name="Diffuse Bounces",
+ description="Maximum number of diffuse reflection bounces, bounded by total maximum",
+ min=0, max=1024,
+ default=4,
+ )
cls.glossy_bounces = IntProperty(
- name="Glossy Bounces",
- description="Maximum number of glossy reflection bounces, bounded by total maximum",
- min=0, max=1024,
- default=4,
- )
+ name="Glossy Bounces",
+ description="Maximum number of glossy reflection bounces, bounded by total maximum",
+ min=0, max=1024,
+ default=4,
+ )
cls.transmission_bounces = IntProperty(
- name="Transmission Bounces",
- description="Maximum number of transmission bounces, bounded by total maximum",
- min=0, max=1024,
- default=12,
- )
+ name="Transmission Bounces",
+ description="Maximum number of transmission bounces, bounded by total maximum",
+ min=0, max=1024,
+ default=12,
+ )
cls.volume_bounces = IntProperty(
- name="Volume Bounces",
- description="Maximum number of volumetric scattering events",
- min=0, max=1024,
- default=0,
- )
+ name="Volume Bounces",
+ description="Maximum number of volumetric scattering events",
+ min=0, max=1024,
+ default=0,
+ )
cls.transparent_max_bounces = IntProperty(
- name="Transparent Max Bounces",
- description="Maximum number of transparent bounces",
- min=0, max=1024,
- default=8,
- )
+ name="Transparent Max Bounces",
+ description="Maximum number of transparent bounces",
+ min=0, max=1024,
+ default=8,
+ )
cls.volume_step_size = FloatProperty(
- name="Step Size",
- description="Distance between volume shader samples when rendering the volume "
- "(lower values give more accurate and detailed results, but also increased render time)",
- default=0.1,
- min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4
- )
+ name="Step Size",
+ description="Distance between volume shader samples when rendering the volume "
+ "(lower values give more accurate and detailed results, but also increased render time)",
+ default=0.1,
+ min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4
+ )
cls.volume_max_steps = IntProperty(
- name="Max Steps",
- description="Maximum number of steps through the volume before giving up, "
- "to avoid extremely long render times with big objects or small step sizes",
- default=1024,
- min=2, max=65536
- )
+ name="Max Steps",
+ description="Maximum number of steps through the volume before giving up, "
+ "to avoid extremely long render times with big objects or small step sizes",
+ default=1024,
+ min=2, max=65536
+ )
cls.dicing_rate = FloatProperty(
- name="Dicing Rate",
- description="Size of a micropolygon in pixels",
- min=0.1, max=1000.0, soft_min=0.5,
- default=1.0,
- subtype="PIXEL"
- )
+ name="Dicing Rate",
+ description="Size of a micropolygon in pixels",
+ min=0.1, max=1000.0, soft_min=0.5,
+ default=1.0,
+ subtype="PIXEL"
+ )
cls.preview_dicing_rate = FloatProperty(
- name="Preview Dicing Rate",
- description="Size of a micropolygon in pixels during preview render",
- min=0.1, max=1000.0, soft_min=0.5,
- default=8.0,
- subtype="PIXEL"
- )
+ name="Preview Dicing Rate",
+ description="Size of a micropolygon in pixels during preview render",
+ min=0.1, max=1000.0, soft_min=0.5,
+ default=8.0,
+ subtype="PIXEL"
+ )
cls.max_subdivisions = IntProperty(
- name="Max Subdivisions",
- description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation",
- min=0, max=16,
- default=12,
- )
+ name="Max Subdivisions",
+ description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation",
+ min=0, max=16,
+ default=12,
+ )
cls.dicing_camera = PointerProperty(
- name="Dicing Camera",
- description="Camera to use as reference point when subdividing geometry, useful to avoid crawling "
- "artifacts in animations when the scene camera is moving",
- type=bpy.types.Object,
- poll=lambda self, obj: obj.type == 'CAMERA',
- )
+ name="Dicing Camera",
+ description="Camera to use as reference point when subdividing geometry, useful to avoid crawling "
+ "artifacts in animations when the scene camera is moving",
+ type=bpy.types.Object,
+ poll=lambda self, obj: obj.type == 'CAMERA',
+ )
cls.offscreen_dicing_scale = FloatProperty(
- name="Offscreen Dicing Scale",
- description="Multiplier for dicing rate of geometry outside of the camera view. The dicing rate "
- "of objects is gradually increased the further they are outside the camera view. "
- "Lower values provide higher quality reflections and shadows for off screen objects, "
- "while higher values use less memory",
- min=1.0, soft_max=25.0,
- default=4.0,
- )
+ name="Offscreen Dicing Scale",
+ description="Multiplier for dicing rate of geometry outside of the camera view. The dicing rate "
+ "of objects is gradually increased the further they are outside the camera view. "
+ "Lower values provide higher quality reflections and shadows for off screen objects, "
+ "while higher values use less memory",
+ min=1.0, soft_max=25.0,
+ default=4.0,
+ )
cls.film_exposure = FloatProperty(
- name="Exposure",
- description="Image brightness scale",
- min=0.0, max=10.0,
- default=1.0,
- )
+ name="Exposure",
+ description="Image brightness scale",
+ min=0.0, max=10.0,
+ default=1.0,
+ )
cls.film_transparent = BoolProperty(
- name="Transparent",
- description="World background is transparent, for compositing the render over another background",
- default=False,
- )
+ name="Transparent",
+ description="World background is transparent, for compositing the render over another background",
+ default=False,
+ )
cls.film_transparent_glass = BoolProperty(
- name="Transparent Glass",
- description="Render transmissive surfaces as transparent, for compositing glass over another background",
- default=False,
- )
+ name="Transparent Glass",
+ description="Render transmissive surfaces as transparent, for compositing glass over another background",
+ default=False,
+ )
cls.film_transparent_roughness = FloatProperty(
- name="Transparent Roughness Threshold",
- description="For transparent transmission, keep surfaces with roughness above the threshold opaque",
- min=0.0, max=1.0,
- default=0.1,
- )
+ name="Transparent Roughness Threshold",
+ description="For transparent transmission, keep surfaces with roughness above the threshold opaque",
+ min=0.0, max=1.0,
+ default=0.1,
+ )
# Really annoyingly, we have to keep it around for a few releases,
# otherwise forward compatibility breaks in really bad manner: CRASH!
#
# TODO(sergey): Remove this during 2.8x series of Blender.
cls.filter_type = EnumProperty(
- name="Filter Type",
- description="Pixel filter type",
- items=enum_filter_types,
- default='BLACKMAN_HARRIS',
- )
+ name="Filter Type",
+ description="Pixel filter type",
+ items=enum_filter_types,
+ default='BLACKMAN_HARRIS',
+ )
cls.pixel_filter_type = EnumProperty(
- name="Filter Type",
- description="Pixel filter type",
- items=enum_filter_types,
- default='BLACKMAN_HARRIS',
- )
+ name="Filter Type",
+ description="Pixel filter type",
+ items=enum_filter_types,
+ default='BLACKMAN_HARRIS',
+ )
cls.filter_width = FloatProperty(
- name="Filter Width",
- description="Pixel filter width",
- min=0.01, max=10.0,
- default=1.5,
- )
+ name="Filter Width",
+ description="Pixel filter width",
+ min=0.01, max=10.0,
+ default=1.5,
+ )
cls.seed = IntProperty(
- name="Seed",
- description="Seed value for integrator to get different noise patterns",
- min=0, max=2147483647,
- default=0,
- )
+ name="Seed",
+ description="Seed value for integrator to get different noise patterns",
+ min=0, max=2147483647,
+ default=0,
+ )
cls.use_animated_seed = BoolProperty(
- name="Use Animated Seed",
- description="Use different seed values (and hence noise patterns) at different frames",
- default=False,
- )
+ name="Use Animated Seed",
+ description="Use different seed values (and hence noise patterns) at different frames",
+ default=False,
+ )
cls.sample_clamp_direct = FloatProperty(
- name="Clamp Direct",
- description="If non-zero, the maximum value for a direct sample, "
- "higher values will be scaled down to avoid too "
- "much noise and slow convergence at the cost of accuracy",
- min=0.0, max=1e8,
- default=0.0,
- )
+ name="Clamp Direct",
+ description="If non-zero, the maximum value for a direct sample, "
+ "higher values will be scaled down to avoid too "
+ "much noise and slow convergence at the cost of accuracy",
+ min=0.0, max=1e8,
+ default=0.0,
+ )
cls.sample_clamp_indirect = FloatProperty(
- name="Clamp Indirect",
- description="If non-zero, the maximum value for an indirect sample, "
- "higher values will be scaled down to avoid too "
- "much noise and slow convergence at the cost of accuracy",
- min=0.0, max=1e8,
- default=10.0,
- )
+ name="Clamp Indirect",
+ description="If non-zero, the maximum value for an indirect sample, "
+ "higher values will be scaled down to avoid too "
+ "much noise and slow convergence at the cost of accuracy",
+ min=0.0, max=1e8,
+ default=10.0,
+ )
cls.debug_tile_size = IntProperty(
- name="Tile Size",
- description="",
- min=1, max=4096,
- default=1024,
- )
+ name="Tile Size",
+ description="",
+ min=1, max=4096,
+ default=1024,
+ )
cls.preview_start_resolution = IntProperty(
- name="Start Resolution",
- description="Resolution to start rendering preview at, "
- "progressively increasing it to the full viewport size",
- min=8, max=16384,
- default=64,
- )
+ name="Start Resolution",
+ description="Resolution to start rendering preview at, "
+ "progressively increasing it to the full viewport size",
+ min=8, max=16384,
+ default=64,
+ )
cls.debug_reset_timeout = FloatProperty(
- name="Reset timeout",
- description="",
- min=0.01, max=10.0,
- default=0.1,
- )
+ name="Reset timeout",
+ description="",
+ min=0.01, max=10.0,
+ default=0.1,
+ )
cls.debug_cancel_timeout = FloatProperty(
- name="Cancel timeout",
- description="",
- min=0.01, max=10.0,
- default=0.1,
- )
+ name="Cancel timeout",
+ description="",
+ min=0.01, max=10.0,
+ default=0.1,
+ )
cls.debug_text_timeout = FloatProperty(
- name="Text timeout",
- description="",
- min=0.01, max=10.0,
- default=1.0,
- )
+ name="Text timeout",
+ description="",
+ min=0.01, max=10.0,
+ default=1.0,
+ )
cls.debug_bvh_type = EnumProperty(
- name="Viewport BVH Type",
- description="Choose between faster updates, or faster render",
- items=enum_bvh_types,
- default='DYNAMIC_BVH',
- )
+ name="Viewport BVH Type",
+ description="Choose between faster updates, or faster render",
+ items=enum_bvh_types,
+ default='DYNAMIC_BVH',
+ )
cls.debug_use_spatial_splits = BoolProperty(
- name="Use Spatial Splits",
- description="Use BVH spatial splits: longer builder time, faster render",
- default=False,
- )
+ name="Use Spatial Splits",
+ description="Use BVH spatial splits: longer builder time, faster render",
+ default=False,
+ )
cls.debug_use_hair_bvh = BoolProperty(
- name="Use Hair BVH",
- description="Use special type BVH optimized for hair (uses more ram but renders faster)",
- default=True,
- )
+ name="Use Hair BVH",
+ description="Use special type BVH optimized for hair (uses more ram but renders faster)",
+ default=True,
+ )
cls.debug_bvh_time_steps = IntProperty(
- name="BVH Time Steps",
- description="Split BVH primitives by this number of time steps to speed up render time in cost of memory",
- default=0,
- min=0, max=16,
- )
+ name="BVH Time Steps",
+ description="Split BVH primitives by this number of time steps to speed up render time in cost of memory",
+ default=0,
+ min=0, max=16,
+ )
cls.tile_order = EnumProperty(
- name="Tile Order",
- description="Tile order for rendering",
- items=enum_tile_order,
- default='HILBERT_SPIRAL',
- options=set(), # Not animatable!
- )
+ name="Tile Order",
+ description="Tile order for rendering",
+ items=enum_tile_order,
+ default='HILBERT_SPIRAL',
+ options=set(), # Not animatable!
+ )
cls.use_progressive_refine = BoolProperty(
- name="Progressive Refine",
- description="Instead of rendering each tile until it is finished, "
- "refine the whole image progressively "
- "(this renders somewhat slower, "
- "but time can be saved by manually stopping the render when the noise is low enough)",
- default=False,
- )
+ name="Progressive Refine",
+ description="Instead of rendering each tile until it is finished, "
+ "refine the whole image progressively "
+ "(this renders somewhat slower, "
+ "but time can be saved by manually stopping the render when the noise is low enough)",
+ default=False,
+ )
cls.bake_type = EnumProperty(
name="Bake Type",
@@ -578,34 +581,34 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
('GLOSSY', "Glossy", ""),
('TRANSMISSION', "Transmission", ""),
('SUBSURFACE', "Subsurface", ""),
- ),
- )
+ ),
+ )
cls.use_camera_cull = BoolProperty(
- name="Use Camera Cull",
- description="Allow objects to be culled based on the camera frustum",
- default=False,
- )
+ name="Use Camera Cull",
+ description="Allow objects to be culled based on the camera frustum",
+ default=False,
+ )
cls.camera_cull_margin = FloatProperty(
- name="Camera Cull Margin",
- description="Margin for the camera space culling",
- default=0.1,
- min=0.0, max=5.0
- )
+ name="Camera Cull Margin",
+ description="Margin for the camera space culling",
+ default=0.1,
+ min=0.0, max=5.0
+ )
cls.use_distance_cull = BoolProperty(
- name="Use Distance Cull",
- description="Allow objects to be culled based on the distance from camera",
- default=False,
- )
+ name="Use Distance Cull",
+ description="Allow objects to be culled based on the distance from camera",
+ default=False,
+ )
cls.distance_cull_margin = FloatProperty(
- name="Cull Distance",
- description="Cull objects which are further away from camera than this distance",
- default=50,
- min=0.0
- )
+ name="Cull Distance",
+ description="Cull objects which are further away from camera than this distance",
+ default=50,
+ min=0.0
+ )
cls.motion_blur_position = EnumProperty(
name="Motion Blur Position",
@@ -615,8 +618,8 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
('START', "Start on Frame", "The shutter opens at the current frame"),
('CENTER', "Center on Frame", "The shutter is open during the current frame"),
('END', "End on Frame", "The shutter closes at the current frame"),
- ),
- )
+ ),
+ )
cls.rolling_shutter_type = EnumProperty(
name="Shutter Type",
@@ -626,43 +629,43 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
('NONE', "None", "No rolling shutter effect used"),
('TOP', "Top-Bottom", "Sensor is being scanned from top to bottom")
# TODO(seergey): Are there real cameras with different scanning direction?
- ),
- )
+ ),
+ )
cls.rolling_shutter_duration = FloatProperty(
name="Rolling Shutter Duration",
description="Scanline \"exposure\" time for the rolling shutter effect",
default=0.1,
min=0.0, max=1.0,
- )
+ )
cls.texture_limit = EnumProperty(
name="Viewport Texture Limit",
default='OFF',
description="Limit texture size used by viewport rendering",
items=enum_texture_limit
- )
+ )
cls.texture_limit_render = EnumProperty(
name="Render Texture Limit",
default='OFF',
description="Limit texture size used by final rendering",
items=enum_texture_limit
- )
+ )
cls.ao_bounces = IntProperty(
name="AO Bounces",
default=0,
description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature",
min=0, max=1024,
- )
+ )
cls.ao_bounces_render = IntProperty(
name="AO Bounces Render",
default=0,
description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature",
min=0, max=1024,
- )
+ )
# Various fine-tuning debug flags
@@ -677,10 +680,10 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
cls.debug_use_cpu_sse3 = BoolProperty(name="SSE3", default=True)
cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True)
cls.debug_bvh_layout = EnumProperty(
- name="BVH Layout",
- items=enum_bvh_layouts,
- default='BVH4',
- )
+ name="BVH Layout",
+ items=enum_bvh_layouts,
+ default='BVH4',
+ )
cls.debug_use_cpu_split_kernel = BoolProperty(name="Split Kernel", default=False)
cls.debug_use_cuda_adaptive_compile = BoolProperty(name="Adaptive Compile", default=False)
@@ -693,9 +696,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
('DEFAULT', "Default", ""),
('MEGA', "Mega", ""),
('SPLIT', "Split", ""),
- ),
+ ),
update=devices_update_callback
- )
+ )
cls.debug_opencl_device_type = EnumProperty(
name="OpenCL Device Type",
@@ -707,20 +710,20 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
('CPU', "CPU", ""),
('GPU', "GPU", ""),
('ACCELERATOR', "Accelerator", ""),
- ),
+ ),
update=devices_update_callback
- )
+ )
cls.debug_opencl_kernel_single_program = BoolProperty(
name="Single Program",
default=True,
update=devices_update_callback,
- )
+ )
cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False)
cls.debug_opencl_mem_limit = IntProperty(name="Memory limit", default=0,
- description="Artificial limit on OpenCL memory usage in MB (0 to disable limit)")
+ description="Artificial limit on OpenCL memory usage in MB (0 to disable limit)")
@classmethod
def unregister(cls):
@@ -733,101 +736,101 @@ class CyclesCameraSettings(bpy.types.PropertyGroup):
import math
bpy.types.Camera.cycles = PointerProperty(
- name="Cycles Camera Settings",
- description="Cycles camera settings",
- type=cls,
- )
+ name="Cycles Camera Settings",
+ description="Cycles camera settings",
+ type=cls,
+ )
cls.aperture_type = EnumProperty(
- name="Aperture Type",
- description="Use f-stop number or aperture radius",
- items=enum_aperture_types,
- default='RADIUS',
- )
+ name="Aperture Type",
+ description="Use f-stop number or aperture radius",
+ items=enum_aperture_types,
+ default='RADIUS',
+ )
cls.aperture_fstop = FloatProperty(
- name="Aperture f-stop",
- description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)",
- min=0.0, soft_min=0.1, soft_max=64.0,
- default=5.6,
- step=10,
- precision=1,
- )
+ name="Aperture f-stop",
+ description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)",
+ min=0.0, soft_min=0.1, soft_max=64.0,
+ default=5.6,
+ step=10,
+ precision=1,
+ )
cls.aperture_size = FloatProperty(
- name="Aperture Size",
- description="Radius of the aperture for depth of field (higher values give more defocus)",
- min=0.0, soft_max=10.0,
- default=0.0,
- step=1,
- precision=4,
- subtype='DISTANCE',
- )
+ name="Aperture Size",
+ description="Radius of the aperture for depth of field (higher values give more defocus)",
+ min=0.0, soft_max=10.0,
+ default=0.0,
+ step=1,
+ precision=4,
+ subtype='DISTANCE',
+ )
cls.aperture_blades = IntProperty(
- name="Aperture Blades",
- description="Number of blades in aperture for polygonal bokeh (at least 3)",
- min=0, max=100,
- default=0,
- )
+ name="Aperture Blades",
+ description="Number of blades in aperture for polygonal bokeh (at least 3)",
+ min=0, max=100,
+ default=0,
+ )
cls.aperture_rotation = FloatProperty(
- name="Aperture Rotation",
- description="Rotation of blades in aperture",
- soft_min=-math.pi, soft_max=math.pi,
- subtype='ANGLE',
- default=0,
- )
+ name="Aperture Rotation",
+ description="Rotation of blades in aperture",
+ soft_min=-math.pi, soft_max=math.pi,
+ subtype='ANGLE',
+ default=0,
+ )
cls.aperture_ratio = FloatProperty(
- name="Aperture Ratio",
- description="Distortion to simulate anamorphic lens bokeh",
- min=0.01, soft_min=1.0, soft_max=2.0,
- default=1.0,
- precision=4,
- )
+ name="Aperture Ratio",
+ description="Distortion to simulate anamorphic lens bokeh",
+ min=0.01, soft_min=1.0, soft_max=2.0,
+ default=1.0,
+ precision=4,
+ )
cls.panorama_type = EnumProperty(
- name="Panorama Type",
- description="Distortion to use for the calculation",
- items=enum_panorama_types,
- default='FISHEYE_EQUISOLID',
- )
+ name="Panorama Type",
+ description="Distortion to use for the calculation",
+ items=enum_panorama_types,
+ default='FISHEYE_EQUISOLID',
+ )
cls.fisheye_fov = FloatProperty(
- name="Field of View",
- description="Field of view for the fisheye lens",
- min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi,
- subtype='ANGLE',
- default=math.pi,
- )
+ name="Field of View",
+ description="Field of view for the fisheye lens",
+ min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi,
+ subtype='ANGLE',
+ default=math.pi,
+ )
cls.fisheye_lens = FloatProperty(
- name="Fisheye Lens",
- description="Lens focal length (mm)",
- min=0.01, soft_max=15.0, max=100.0,
- default=10.5,
- )
+ name="Fisheye Lens",
+ description="Lens focal length (mm)",
+ min=0.01, soft_max=15.0, max=100.0,
+ default=10.5,
+ )
cls.latitude_min = FloatProperty(
- name="Min Latitude",
- description="Minimum latitude (vertical angle) for the equirectangular lens",
- min=-0.5 * math.pi, max=0.5 * math.pi,
- subtype='ANGLE',
- default=-0.5 * math.pi,
- )
+ name="Min Latitude",
+ description="Minimum latitude (vertical angle) for the equirectangular lens",
+ min=-0.5 * math.pi, max=0.5 * math.pi,
+ subtype='ANGLE',
+ default=-0.5 * math.pi,
+ )
cls.latitude_max = FloatProperty(
- name="Max Latitude",
- description="Maximum latitude (vertical angle) for the equirectangular lens",
- min=-0.5 * math.pi, max=0.5 * math.pi,
- subtype='ANGLE',
- default=0.5 * math.pi,
- )
+ name="Max Latitude",
+ description="Maximum latitude (vertical angle) for the equirectangular lens",
+ min=-0.5 * math.pi, max=0.5 * math.pi,
+ subtype='ANGLE',
+ default=0.5 * math.pi,
+ )
cls.longitude_min = FloatProperty(
- name="Min Longitude",
- description="Minimum longitude (horizontal angle) for the equirectangular lens",
- min=-math.pi, max=math.pi,
- subtype='ANGLE',
- default=-math.pi,
- )
+ name="Min Longitude",
+ description="Minimum longitude (horizontal angle) for the equirectangular lens",
+ min=-math.pi, max=math.pi,
+ subtype='ANGLE',
+ default=-math.pi,
+ )
cls.longitude_max = FloatProperty(
- name="Max Longitude",
- description="Maximum longitude (horizontal angle) for the equirectangular lens",
- min=-math.pi, max=math.pi,
- subtype='ANGLE',
- default=math.pi,
- )
+ name="Max Longitude",
+ description="Maximum longitude (horizontal angle) for the equirectangular lens",
+ min=-math.pi, max=math.pi,
+ subtype='ANGLE',
+ default=math.pi,
+ )
@classmethod
def unregister(cls):
@@ -838,150 +841,150 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Material.cycles = PointerProperty(
- name="Cycles Material Settings",
- description="Cycles material settings",
- type=cls,
- )
+ name="Cycles Material Settings",
+ description="Cycles material settings",
+ type=cls,
+ )
cls.sample_as_light = BoolProperty(
- name="Multiple Importance Sample",
- description="Use multiple importance sampling for this material, "
- "disabling may reduce overall noise for large "
- "objects that emit little light compared to other light sources",
- default=True,
- )
+ name="Multiple Importance Sample",
+ description="Use multiple importance sampling for this material, "
+ "disabling may reduce overall noise for large "
+ "objects that emit little light compared to other light sources",
+ default=True,
+ )
cls.use_transparent_shadow = BoolProperty(
- name="Transparent Shadows",
- description="Use transparent shadows for this material if it contains a Transparent BSDF, "
- "disabling will render faster but not give accurate shadows",
- default=True,
- )
+ name="Transparent Shadows",
+ description="Use transparent shadows for this material if it contains a Transparent BSDF, "
+ "disabling will render faster but not give accurate shadows",
+ default=True,
+ )
cls.homogeneous_volume = BoolProperty(
- name="Homogeneous Volume",
- description="When using volume rendering, assume volume has the same density everywhere "
- "(not using any textures), for faster rendering",
- default=False,
- )
+ name="Homogeneous Volume",
+ description="When using volume rendering, assume volume has the same density everywhere "
+ "(not using any textures), for faster rendering",
+ default=False,
+ )
cls.volume_sampling = EnumProperty(
- name="Volume Sampling",
- description="Sampling method to use for volumes",
- items=enum_volume_sampling,
- default='MULTIPLE_IMPORTANCE',
- )
+ name="Volume Sampling",
+ description="Sampling method to use for volumes",
+ items=enum_volume_sampling,
+ default='MULTIPLE_IMPORTANCE',
+ )
cls.volume_interpolation = EnumProperty(
- name="Volume Interpolation",
- description="Interpolation method to use for smoke/fire volumes",
- items=enum_volume_interpolation,
- default='LINEAR',
- )
+ name="Volume Interpolation",
+ description="Interpolation method to use for smoke/fire volumes",
+ items=enum_volume_interpolation,
+ default='LINEAR',
+ )
cls.displacement_method = EnumProperty(
- name="Displacement Method",
- description="Method to use for the displacement",
- items=enum_displacement_methods,
- default='DISPLACEMENT',
- )
+ name="Displacement Method",
+ description="Method to use for the displacement",
+ items=enum_displacement_methods,
+ default='DISPLACEMENT',
+ )
@classmethod
def unregister(cls):
del bpy.types.Material.cycles
-class CyclesLampSettings(bpy.types.PropertyGroup):
+class CyclesLightSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- bpy.types.Lamp.cycles = PointerProperty(
- name="Cycles Lamp Settings",
- description="Cycles lamp settings",
- type=cls,
- )
+ bpy.types.Light.cycles = PointerProperty(
+ name="Cycles Light Settings",
+ description="Cycles light settings",
+ type=cls,
+ )
cls.cast_shadow = BoolProperty(
- name="Cast Shadow",
- description="Lamp casts shadows",
- default=True,
- )
+ name="Cast Shadow",
+ description="Light casts shadows",
+ default=True,
+ )
cls.samples = IntProperty(
- name="Samples",
- description="Number of light samples to render for each AA sample",
- min=1, max=10000,
- default=1,
- )
+ name="Samples",
+ description="Number of light samples to render for each AA sample",
+ min=1, max=10000,
+ default=1,
+ )
cls.max_bounces = IntProperty(
- name="Max Bounces",
- description="Maximum number of bounces the light will contribute to the render",
- min=0, max=1024,
- default=1024,
- )
+ name="Max Bounces",
+ description="Maximum number of bounces the light will contribute to the render",
+ min=0, max=1024,
+ default=1024,
+ )
cls.use_multiple_importance_sampling = BoolProperty(
- name="Multiple Importance Sample",
- description="Use multiple importance sampling for the lamp, "
- "reduces noise for area lamps and sharp glossy materials",
- default=True,
- )
+ name="Multiple Importance Sample",
+ description="Use multiple importance sampling for the light, "
+ "reduces noise for area lights and sharp glossy materials",
+ default=True,
+ )
cls.is_portal = BoolProperty(
- name="Is Portal",
- description="Use this area lamp to guide sampling of the background, "
- "note that this will make the lamp invisible",
- default=False,
- )
+ name="Is Portal",
+ description="Use this area light to guide sampling of the background, "
+ "note that this will make the light invisible",
+ default=False,
+ )
@classmethod
def unregister(cls):
- del bpy.types.Lamp.cycles
+ del bpy.types.Light.cycles
class CyclesWorldSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.World.cycles = PointerProperty(
- name="Cycles World Settings",
- description="Cycles world settings",
- type=cls,
- )
+ name="Cycles World Settings",
+ description="Cycles world settings",
+ type=cls,
+ )
cls.sampling_method = EnumProperty(
- name="Sampling method",
- description="How to sample the background light",
- items=enum_world_mis,
- default='AUTOMATIC',
- )
+ name="Sampling method",
+ description="How to sample the background light",
+ items=enum_world_mis,
+ default='AUTOMATIC',
+ )
cls.sample_map_resolution = IntProperty(
- name="Map Resolution",
- description="Importance map size is resolution x resolution/2; "
- "higher values potentially produce less noise, at the cost of memory and speed",
- min=4, max=8192,
- default=1024,
- )
+ name="Map Resolution",
+ description="Importance map size is resolution x resolution/2; "
+ "higher values potentially produce less noise, at the cost of memory and speed",
+ min=4, max=8192,
+ default=1024,
+ )
cls.samples = IntProperty(
- name="Samples",
- description="Number of light samples to render for each AA sample",
- min=1, max=10000,
- default=1,
- )
+ name="Samples",
+ description="Number of light samples to render for each AA sample",
+ min=1, max=10000,
+ default=1,
+ )
cls.max_bounces = IntProperty(
- name="Max Bounces",
- description="Maximum number of bounces the background light will contribute to the render",
- min=0, max=1024,
- default=1024,
- )
+ name="Max Bounces",
+ description="Maximum number of bounces the background light will contribute to the render",
+ min=0, max=1024,
+ default=1024,
+ )
cls.homogeneous_volume = BoolProperty(
- name="Homogeneous Volume",
- description="When using volume rendering, assume volume has the same density everywhere"
- "(not using any textures), for faster rendering",
- default=False,
- )
+ name="Homogeneous Volume",
+ description="When using volume rendering, assume volume has the same density everywhere"
+ "(not using any textures), for faster rendering",
+ default=False,
+ )
cls.volume_sampling = EnumProperty(
- name="Volume Sampling",
- description="Sampling method to use for volumes",
- items=enum_volume_sampling,
- default='EQUIANGULAR',
- )
+ name="Volume Sampling",
+ description="Sampling method to use for volumes",
+ items=enum_volume_sampling,
+ default='EQUIANGULAR',
+ )
cls.volume_interpolation = EnumProperty(
- name="Volume Interpolation",
- description="Interpolation method to use for volumes",
- items=enum_volume_interpolation,
- default='LINEAR',
- )
+ name="Volume Interpolation",
+ description="Interpolation method to use for volumes",
+ items=enum_volume_interpolation,
+ default='LINEAR',
+ )
@classmethod
def unregister(cls):
@@ -992,47 +995,47 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Object.cycles_visibility = PointerProperty(
- name="Cycles Visibility Settings",
- description="Cycles visibility settings",
- type=cls,
- )
+ name="Cycles Visibility Settings",
+ description="Cycles visibility settings",
+ type=cls,
+ )
bpy.types.World.cycles_visibility = PointerProperty(
- name="Cycles Visibility Settings",
- description="Cycles visibility settings",
- type=cls,
- )
+ name="Cycles Visibility Settings",
+ description="Cycles visibility settings",
+ type=cls,
+ )
cls.camera = BoolProperty(
- name="Camera",
- description="Object visibility for camera rays",
- default=True,
- )
+ name="Camera",
+ description="Object visibility for camera rays",
+ default=True,
+ )
cls.diffuse = BoolProperty(
- name="Diffuse",
- description="Object visibility for diffuse reflection rays",
- default=True,
- )
+ name="Diffuse",
+ description="Object visibility for diffuse reflection rays",
+ default=True,
+ )
cls.glossy = BoolProperty(
- name="Glossy",
- description="Object visibility for glossy reflection rays",
- default=True,
- )
+ name="Glossy",
+ description="Object visibility for glossy reflection rays",
+ default=True,
+ )
cls.transmission = BoolProperty(
- name="Transmission",
- description="Object visibility for transmission rays",
- default=True,
- )
+ name="Transmission",
+ description="Object visibility for transmission rays",
+ default=True,
+ )
cls.shadow = BoolProperty(
- name="Shadow",
- description="Object visibility for shadow rays",
- default=True,
- )
+ name="Shadow",
+ description="Object visibility for shadow rays",
+ default=True,
+ )
cls.scatter = BoolProperty(
- name="Volume Scatter",
- description="Object visibility for volume scatter rays",
- default=True,
- )
+ name="Volume Scatter",
+ description="Object visibility for volume scatter rays",
+ default=True,
+ )
@classmethod
def unregister(cls):
@@ -1044,20 +1047,20 @@ class CyclesMeshSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Mesh.cycles = PointerProperty(
- name="Cycles Mesh Settings",
- description="Cycles mesh settings",
- type=cls,
- )
+ name="Cycles Mesh Settings",
+ description="Cycles mesh settings",
+ type=cls,
+ )
bpy.types.Curve.cycles = PointerProperty(
- name="Cycles Mesh Settings",
- description="Cycles mesh settings",
- type=cls,
- )
+ name="Cycles Mesh Settings",
+ description="Cycles mesh settings",
+ type=cls,
+ )
bpy.types.MetaBall.cycles = PointerProperty(
- name="Cycles Mesh Settings",
- description="Cycles mesh settings",
- type=cls,
- )
+ name="Cycles Mesh Settings",
+ description="Cycles mesh settings",
+ type=cls,
+ )
@classmethod
def unregister(cls):
@@ -1070,69 +1073,68 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Object.cycles = PointerProperty(
- name="Cycles Object Settings",
- description="Cycles object settings",
- type=cls,
- )
+ name="Cycles Object Settings",
+ description="Cycles object settings",
+ type=cls,
+ )
cls.use_motion_blur = BoolProperty(
- name="Use Motion Blur",
- description="Use motion blur for this object",
- default=True,
- )
+ name="Use Motion Blur",
+ description="Use motion blur for this object",
+ default=True,
+ )
cls.use_deform_motion = BoolProperty(
- name="Use Deformation Motion",
- description="Use deformation motion blur for this object",
- default=True,
- )
+ name="Use Deformation Motion",
+ description="Use deformation motion blur for this object",
+ default=True,
+ )
cls.motion_steps = IntProperty(
- name="Motion Steps",
- description="Control accuracy of motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
- min=1, soft_max=8,
- default=1,
- )
+ name="Motion Steps",
+ description="Control accuracy of motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
+ min=1, soft_max=8,
+ default=1,
+ )
cls.use_camera_cull = BoolProperty(
- name="Use Camera Cull",
- description="Allow this object and its duplicators to be culled by camera space culling",
- default=False,
- )
+ name="Use Camera Cull",
+ description="Allow this object and its duplicators to be culled by camera space culling",
+ default=False,
+ )
cls.use_distance_cull = BoolProperty(
- name="Use Distance Cull",
- description="Allow this object and its duplicators to be culled by distance from camera",
- default=False,
- )
+ name="Use Distance Cull",
+ description="Allow this object and its duplicators to be culled by distance from camera",
+ default=False,
+ )
cls.use_adaptive_subdivision = BoolProperty(
- name="Use Adaptive Subdivision",
- description="Use adaptive render time subdivision",
- default=False,
- )
+ name="Use Adaptive Subdivision",
+ description="Use adaptive render time subdivision",
+ default=False,
+ )
cls.dicing_rate = FloatProperty(
- name="Dicing Scale",
- description="Multiplier for scene dicing rate (located in the Geometry Panel)",
- min=0.1, max=1000.0, soft_min=0.5,
- default=1.0,
- )
+ name="Dicing Scale",
+ description="Multiplier for scene dicing rate (located in the Geometry Panel)",
+ min=0.1, max=1000.0, soft_min=0.5,
+ default=1.0,
+ )
cls.is_shadow_catcher = BoolProperty(
- name="Shadow Catcher",
- description="Only render shadows on this object, for compositing renders into real footage",
- default=False,
- )
+ name="Shadow Catcher",
+ description="Only render shadows on this object, for compositing renders into real footage",
+ default=False,
+ )
cls.is_holdout = BoolProperty(
- name="Holdout",
- description="Render objects as a holdout or matte, creating a "
- "hole in the image with zero alpha, to fill out in "
- "compositing with real footange or another render",
- default=False,
- )
-
+ name="Holdout",
+ description="Render objects as a holdout or matte, creating a "
+ "hole in the image with zero alpha, to fill out in "
+ "compositing with real footange or another render",
+ default=False,
+ )
@classmethod
def unregister(cls):
@@ -1143,192 +1145,194 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Scene.cycles_curves = PointerProperty(
- name="Cycles Hair Rendering Settings",
- description="Cycles hair rendering settings",
- type=cls,
- )
+ name="Cycles Hair Rendering Settings",
+ description="Cycles hair rendering settings",
+ type=cls,
+ )
cls.primitive = EnumProperty(
- name="Primitive",
- description="Type of primitive used for hair rendering",
- items=enum_curve_primitives,
- default='LINE_SEGMENTS',
- )
+ name="Primitive",
+ description="Type of primitive used for hair rendering",
+ items=enum_curve_primitives,
+ default='LINE_SEGMENTS',
+ )
cls.shape = EnumProperty(
- name="Shape",
- description="Form of hair",
- items=enum_curve_shape,
- default='THICK',
- )
+ name="Shape",
+ description="Form of hair",
+ items=enum_curve_shape,
+ default='THICK',
+ )
cls.cull_backfacing = BoolProperty(
- name="Cull Back-faces",
- description="Do not test the back-face of each strand",
- default=True,
- )
+ name="Cull Back-faces",
+ description="Do not test the back-face of each strand",
+ default=True,
+ )
cls.use_curves = BoolProperty(
- name="Use Cycles Hair Rendering",
- description="Activate Cycles hair rendering for particle system",
- default=True,
- )
+ name="Use Cycles Hair Rendering",
+ description="Activate Cycles hair rendering for particle system",
+ default=True,
+ )
cls.resolution = IntProperty(
- name="Resolution",
- description="Resolution of generated mesh",
- min=3, max=64,
- default=3,
- )
+ name="Resolution",
+ description="Resolution of generated mesh",
+ min=3, max=64,
+ default=3,
+ )
cls.minimum_width = FloatProperty(
- name="Minimal width",
- description="Minimal pixel width for strands (0 - deactivated)",
- min=0.0, max=100.0,
- default=0.0,
- )
+ name="Minimal width",
+ description="Minimal pixel width for strands (0 - deactivated)",
+ min=0.0, max=100.0,
+ default=0.0,
+ )
cls.maximum_width = FloatProperty(
- name="Maximal width",
- description="Maximum extension that strand radius can be increased by",
- min=0.0, max=100.0,
- default=0.1,
- )
+ name="Maximal width",
+ description="Maximum extension that strand radius can be increased by",
+ min=0.0, max=100.0,
+ default=0.1,
+ )
cls.subdivisions = IntProperty(
- name="Subdivisions",
- description="Number of subdivisions used in Cardinal curve intersection (power of 2)",
- min=0, max=24,
- default=4,
- )
+ name="Subdivisions",
+ description="Number of subdivisions used in Cardinal curve intersection (power of 2)",
+ min=0, max=24,
+ default=4,
+ )
@classmethod
def unregister(cls):
del bpy.types.Scene.cycles_curves
+
def update_render_passes(self, context):
scene = context.scene
rd = scene.render
view_layer = context.view_layer
view_layer.update_render_passes()
+
class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.ViewLayer.cycles = PointerProperty(
- name="Cycles ViewLayer Settings",
- description="Cycles ViewLayer Settings",
- type=cls,
- )
+ name="Cycles ViewLayer Settings",
+ description="Cycles ViewLayer Settings",
+ type=cls,
+ )
cls.pass_debug_bvh_traversed_nodes = BoolProperty(
- name="Debug BVH Traversed Nodes",
- description="Store Debug BVH Traversed Nodes pass",
- default=False,
- update=update_render_passes,
- )
+ name="Debug BVH Traversed Nodes",
+ description="Store Debug BVH Traversed Nodes pass",
+ default=False,
+ update=update_render_passes,
+ )
cls.pass_debug_bvh_traversed_instances = BoolProperty(
- name="Debug BVH Traversed Instances",
- description="Store Debug BVH Traversed Instances pass",
- default=False,
- update=update_render_passes,
- )
+ name="Debug BVH Traversed Instances",
+ description="Store Debug BVH Traversed Instances pass",
+ default=False,
+ update=update_render_passes,
+ )
cls.pass_debug_bvh_intersections = BoolProperty(
- name="Debug BVH Intersections",
- description="Store Debug BVH Intersections",
- default=False,
- update=update_render_passes,
- )
+ name="Debug BVH Intersections",
+ description="Store Debug BVH Intersections",
+ default=False,
+ update=update_render_passes,
+ )
cls.pass_debug_ray_bounces = BoolProperty(
- name="Debug Ray Bounces",
- description="Store Debug Ray Bounces pass",
- default=False,
- update=update_render_passes,
- )
+ name="Debug Ray Bounces",
+ description="Store Debug Ray Bounces pass",
+ default=False,
+ update=update_render_passes,
+ )
cls.pass_debug_render_time = BoolProperty(
- name="Debug Render Time",
- description="Render time in milliseconds per sample and pixel",
- default=False,
- update=update_render_passes,
- )
+ name="Debug Render Time",
+ description="Render time in milliseconds per sample and pixel",
+ default=False,
+ update=update_render_passes,
+ )
cls.use_pass_volume_direct = BoolProperty(
- name="Volume Direct",
- description="Deliver direct volumetric scattering pass",
- default=False,
- update=update_render_passes,
- )
+ name="Volume Direct",
+ description="Deliver direct volumetric scattering pass",
+ default=False,
+ update=update_render_passes,
+ )
cls.use_pass_volume_indirect = BoolProperty(
- name="Volume Indirect",
- description="Deliver indirect volumetric scattering pass",
- default=False,
- update=update_render_passes,
- )
+ name="Volume Indirect",
+ description="Deliver indirect volumetric scattering pass",
+ default=False,
+ update=update_render_passes,
+ )
cls.use_denoising = BoolProperty(
- name="Use Denoising",
- description="Denoise the rendered image",
- default=False,
- update=update_render_passes,
- )
+ name="Use Denoising",
+ description="Denoise the rendered image",
+ default=False,
+ update=update_render_passes,
+ )
cls.denoising_diffuse_direct = BoolProperty(
- name="Diffuse Direct",
- description="Denoise the direct diffuse lighting",
- default=True,
- )
+ name="Diffuse Direct",
+ description="Denoise the direct diffuse lighting",
+ default=True,
+ )
cls.denoising_diffuse_indirect = BoolProperty(
- name="Diffuse Indirect",
- description="Denoise the indirect diffuse lighting",
- default=True,
- )
+ name="Diffuse Indirect",
+ description="Denoise the indirect diffuse lighting",
+ default=True,
+ )
cls.denoising_glossy_direct = BoolProperty(
- name="Glossy Direct",
- description="Denoise the direct glossy lighting",
- default=True,
- )
+ name="Glossy Direct",
+ description="Denoise the direct glossy lighting",
+ default=True,
+ )
cls.denoising_glossy_indirect = BoolProperty(
- name="Glossy Indirect",
- description="Denoise the indirect glossy lighting",
- default=True,
- )
+ name="Glossy Indirect",
+ description="Denoise the indirect glossy lighting",
+ default=True,
+ )
cls.denoising_transmission_direct = BoolProperty(
- name="Transmission Direct",
- description="Denoise the direct transmission lighting",
- default=True,
- )
+ name="Transmission Direct",
+ description="Denoise the direct transmission lighting",
+ default=True,
+ )
cls.denoising_transmission_indirect = BoolProperty(
- name="Transmission Indirect",
- description="Denoise the indirect transmission lighting",
- default=True,
- )
+ name="Transmission Indirect",
+ description="Denoise the indirect transmission lighting",
+ default=True,
+ )
cls.denoising_subsurface_direct = BoolProperty(
- name="Subsurface Direct",
- description="Denoise the direct subsurface lighting",
- default=True,
- )
+ name="Subsurface Direct",
+ description="Denoise the direct subsurface lighting",
+ default=True,
+ )
cls.denoising_subsurface_indirect = BoolProperty(
- name="Subsurface Indirect",
- description="Denoise the indirect subsurface lighting",
- default=True,
- )
+ name="Subsurface Indirect",
+ description="Denoise the indirect subsurface lighting",
+ default=True,
+ )
cls.denoising_strength = FloatProperty(
- name="Denoising Strength",
- description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)",
- min=0.0, max=1.0,
- default=0.5,
- )
+ name="Denoising Strength",
+ description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)",
+ min=0.0, max=1.0,
+ default=0.5,
+ )
cls.denoising_feature_strength = FloatProperty(
- name="Denoising Feature Strength",
- description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)",
- min=0.0, max=1.0,
- default=0.5,
- )
+ name="Denoising Feature Strength",
+ description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)",
+ min=0.0, max=1.0,
+ default=0.5,
+ )
cls.denoising_radius = IntProperty(
- name="Denoising Radius",
- description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)",
- min=1, max=25,
- default=8,
+ name="Denoising Radius",
+ description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)",
+ min=1, max=25,
+ default=8,
)
cls.denoising_relative_pca = BoolProperty(
- name="Relative filter",
- description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)",
- default=False,
+ name="Relative filter",
+ description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)",
+ default=False,
)
cls.denoising_store_passes = BoolProperty(
- name="Store denoising passes",
- description="Store the denoising feature passes and the noisy image",
- default=False,
- update=update_render_passes,
+ name="Store denoising passes",
+ description="Store the denoising feature passes and the noisy image",
+ default=False,
+ update=update_render_passes,
)
@classmethod
@@ -1358,13 +1362,13 @@ class CyclesPreferences(bpy.types.AddonPreferences):
list.append(('OPENCL', "OpenCL", "Use OpenCL for GPU acceleration", 2))
return list
- compute_device_type = EnumProperty(
- name="Compute Device Type",
- description="Device to use for computation (rendering with Cycles)",
- items=get_device_types,
- )
+ compute_device_type: EnumProperty(
+ name="Compute Device Type",
+ description="Device to use for computation (rendering with Cycles)",
+ items=get_device_types,
+ )
- devices = bpy.props.CollectionProperty(type=CyclesDeviceSettings)
+ devices: bpy.props.CollectionProperty(type=CyclesDeviceSettings)
def find_existing_device_entry(self, device):
for device_entry in self.devices:
@@ -1372,7 +1376,6 @@ class CyclesPreferences(bpy.types.AddonPreferences):
return device_entry
return None
-
def update_device_entries(self, device_list):
for device in device_list:
if not device[1] in {'CUDA', 'OPENCL', 'CPU'}:
@@ -1382,15 +1385,14 @@ class CyclesPreferences(bpy.types.AddonPreferences):
if not entry:
# Create new entry if no existing one was found
entry = self.devices.add()
- entry.id = device[2]
+ entry.id = device[2]
entry.name = device[0]
entry.type = device[1]
- entry.use = entry.type != 'CPU'
+ entry.use = entry.type != 'CPU'
elif entry.name != device[0]:
# Update name in case it changed
entry.name = device[0]
-
def get_devices(self):
import _cycles
# Layout of the device tuples: (Name, Type, Persistent ID)
@@ -1416,7 +1418,6 @@ class CyclesPreferences(bpy.types.AddonPreferences):
opencl_devices.extend(cpu_devices)
return cuda_devices, opencl_devices
-
def get_num_gpu_devices(self):
import _cycles
device_list = _cycles.available_devices()
@@ -1429,11 +1430,9 @@ class CyclesPreferences(bpy.types.AddonPreferences):
num += 1
return num
-
def has_active_device(self):
return self.get_num_gpu_devices() > 0
-
def draw_impl(self, layout, context):
layout.label(text="Cycles Compute Device:")
layout.row().prop(self, "compute_device_type", expand=True)
@@ -1451,7 +1450,6 @@ class CyclesPreferences(bpy.types.AddonPreferences):
for device in opencl_devices:
box.prop(device, "use", text=device.name)
-
def draw(self, context):
self.draw_impl(self.layout, context)
@@ -1460,7 +1458,7 @@ def register():
bpy.utils.register_class(CyclesRenderSettings)
bpy.utils.register_class(CyclesCameraSettings)
bpy.utils.register_class(CyclesMaterialSettings)
- bpy.utils.register_class(CyclesLampSettings)
+ bpy.utils.register_class(CyclesLightSettings)
bpy.utils.register_class(CyclesWorldSettings)
bpy.utils.register_class(CyclesVisibilitySettings)
bpy.utils.register_class(CyclesMeshSettings)
@@ -1475,7 +1473,7 @@ def unregister():
bpy.utils.unregister_class(CyclesRenderSettings)
bpy.utils.unregister_class(CyclesCameraSettings)
bpy.utils.unregister_class(CyclesMaterialSettings)
- bpy.utils.unregister_class(CyclesLampSettings)
+ bpy.utils.unregister_class(CyclesLightSettings)
bpy.utils.unregister_class(CyclesWorldSettings)
bpy.utils.unregister_class(CyclesMeshSettings)
bpy.utils.unregister_class(CyclesObjectSettings)
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index f8bc9ca8512..3d5ed6b9b44 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -17,7 +17,7 @@
# <pep8 compliant>
import bpy
-from bpy_extras.node_utils import find_node_input, find_output_node
+from bpy_extras.node_utils import find_node_input
from bl_operators.presets import PresetMenu
from bpy.types import (
@@ -1008,7 +1008,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
def poll(cls, context):
ob = context.object
return (CyclesButtonsPanel.poll(context) and
- ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'}) or
+ ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT'}) or
(ob.dupli_type == 'COLLECTION' and ob.dupli_group)))
def draw(self, context):
@@ -1029,7 +1029,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
flow.prop(visibility, "transmission")
flow.prop(visibility, "scatter")
- if ob.type != 'LAMP':
+ if ob.type != 'LIGHT':
flow.prop(visibility, "shadow")
row = layout.row()
@@ -1049,34 +1049,34 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
class CYCLES_OT_use_shading_nodes(Operator):
- """Enable nodes on a material, world or lamp"""
+ """Enable nodes on a material, world or light"""
bl_idname = "cycles.use_shading_nodes"
bl_label = "Use Nodes"
@classmethod
def poll(cls, context):
return (getattr(context, "material", False) or getattr(context, "world", False) or
- getattr(context, "lamp", False))
+ getattr(context, "light", False))
def execute(self, context):
if context.material:
context.material.use_nodes = True
elif context.world:
context.world.use_nodes = True
- elif context.lamp:
- context.lamp.use_nodes = True
+ elif context.light:
+ context.light.use_nodes = True
return {'FINISHED'}
-def panel_node_draw(layout, id_data, output_types, input_name):
+def panel_node_draw(layout, id_data, output_type, input_name):
if not id_data.use_nodes:
layout.operator("cycles.use_shading_nodes", icon='NODETREE')
return False
ntree = id_data.node_tree
- node = find_output_node(ntree, output_types)
+ node = ntree.get_output_node('CYCLES')
if node:
input = find_node_input(node, input_name)
if input:
@@ -1089,7 +1089,7 @@ def panel_node_draw(layout, id_data, output_types, input_name):
return True
-class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel):
+class CYCLES_LIGHT_PT_preview(CyclesButtonsPanel, Panel):
bl_label = "Preview"
bl_context = "data"
bl_options = {'DEFAULT_CLOSED'}
@@ -1097,52 +1097,52 @@ class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
return (
- context.lamp and
+ context.light and
not (
- context.lamp.type == 'AREA' and
- context.lamp.cycles.is_portal
+ context.light.type == 'AREA' and
+ context.light.cycles.is_portal
) and
CyclesButtonsPanel.poll(context)
)
def draw(self, context):
- self.layout.template_preview(context.lamp)
+ self.layout.template_preview(context.light)
-class CYCLES_LAMP_PT_lamp(CyclesButtonsPanel, Panel):
- bl_label = "Lamp"
+class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel):
+ bl_label = "Light"
bl_context = "data"
@classmethod
def poll(cls, context):
- return context.lamp and CyclesButtonsPanel.poll(context)
+ return context.light and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
- lamp = context.lamp
- clamp = lamp.cycles
+ light = context.light
+ clamp = light.cycles
# cscene = context.scene.cycles
- layout.prop(lamp, "type", expand=True)
+ layout.prop(light, "type", expand=True)
layout.use_property_split = True
col = layout.column()
- if lamp.type in {'POINT', 'SUN', 'SPOT'}:
- col.prop(lamp, "shadow_soft_size", text="Size")
- elif lamp.type == 'AREA':
- col.prop(lamp, "shape", text="Shape")
+ if light.type in {'POINT', 'SUN', 'SPOT'}:
+ col.prop(light, "shadow_soft_size", text="Size")
+ elif light.type == 'AREA':
+ col.prop(light, "shape", text="Shape")
sub = col.column(align=True)
- if lamp.shape in {'SQUARE', 'DISK'}:
- sub.prop(lamp, "size")
- elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
- sub.prop(lamp, "size", text="Size X")
- sub.prop(lamp, "size_y", text="Y")
+ if light.shape in {'SQUARE', 'DISK'}:
+ sub.prop(light, "size")
+ elif light.shape in {'RECTANGLE', 'ELLIPSE'}:
+ sub.prop(light, "size", text="Size X")
+ sub.prop(light, "size_y", text="Y")
- if not (lamp.type == 'AREA' and clamp.is_portal):
+ if not (light.type == 'AREA' and clamp.is_portal):
sub = col.column()
if use_branched_path(context):
subsub = sub.row(align=True)
@@ -1151,53 +1151,53 @@ class CYCLES_LAMP_PT_lamp(CyclesButtonsPanel, Panel):
sub.prop(clamp, "max_bounces")
sub = col.column(align=True)
- sub.active = not (lamp.type == 'AREA' and clamp.is_portal)
+ sub.active = not (light.type == 'AREA' and clamp.is_portal)
sub.prop(clamp, "cast_shadow")
sub.prop(clamp, "use_multiple_importance_sampling", text="Multiple Importance")
- if lamp.type == 'AREA':
+ if light.type == 'AREA':
col.prop(clamp, "is_portal", text="Portal")
- if lamp.type == 'HEMI':
- layout.label(text="Not supported, interpreted as sun lamp")
+ if light.type == 'HEMI':
+ layout.label(text="Not supported, interpreted as sun light")
-class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel):
+class CYCLES_LIGHT_PT_nodes(CyclesButtonsPanel, Panel):
bl_label = "Nodes"
bl_context = "data"
@classmethod
def poll(cls, context):
- return context.lamp and not (context.lamp.type == 'AREA' and
- context.lamp.cycles.is_portal) and \
+ return context.light and not (context.light.type == 'AREA' and
+ context.light.cycles.is_portal) and \
CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
- lamp = context.lamp
- if not panel_node_draw(layout, lamp, ('OUTPUT_LAMP',), 'Surface'):
- layout.prop(lamp, "color")
+ light = context.light
+ if not panel_node_draw(layout, light, 'OUTPUT_LIGHT', 'Surface'):
+ layout.prop(light, "color")
-class CYCLES_LAMP_PT_spot(CyclesButtonsPanel, Panel):
+class CYCLES_LIGHT_PT_spot(CyclesButtonsPanel, Panel):
bl_label = "Spot Shape"
bl_context = "data"
@classmethod
def poll(cls, context):
- lamp = context.lamp
- return (lamp and lamp.type == 'SPOT') and CyclesButtonsPanel.poll(context)
+ light = context.light
+ return (light and light.type == 'SPOT') and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
- lamp = context.lamp
+ light = context.light
layout.use_property_split = True
col = layout.column()
- col.prop(lamp, "spot_size", text="Size")
- col.prop(lamp, "spot_blend", text="Blend", slider=True)
- col.prop(lamp, "show_cone")
+ col.prop(light, "spot_size", text="Size")
+ col.prop(light, "spot_blend", text="Blend", slider=True)
+ col.prop(light, "show_cone")
class CYCLES_WORLD_PT_preview(CyclesButtonsPanel, Panel):
@@ -1226,8 +1226,8 @@ class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel):
world = context.world
- if not panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Surface'):
- layout.prop(world, "horizon_color", text="Color")
+ if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
+ layout.prop(world, "color")
class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel):
@@ -1244,7 +1244,7 @@ class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel):
layout = self.layout
world = context.world
- panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Volume')
+ panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
class CYCLES_WORLD_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
@@ -1344,6 +1344,7 @@ class CYCLES_WORLD_PT_settings(CyclesButtonsPanel, Panel):
col = layout.column()
+
class CYCLES_WORLD_PT_settings_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface"
bl_parent_id = "CYCLES_WORLD_PT_settings"
@@ -1425,7 +1426,7 @@ class CYCLES_MATERIAL_PT_surface(CyclesButtonsPanel, Panel):
layout = self.layout
mat = context.material
- if not panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Surface'):
+ if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
layout.prop(mat, "diffuse_color")
@@ -1445,7 +1446,7 @@ class CYCLES_MATERIAL_PT_volume(CyclesButtonsPanel, Panel):
mat = context.material
# cmat = mat.cycles
- panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Volume')
+ panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel):
@@ -1461,7 +1462,7 @@ class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel):
layout = self.layout
mat = context.material
- panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Displacement')
+ panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel):
@@ -1528,8 +1529,6 @@ class CYCLES_MATERIAL_PT_settings_volume(CyclesButtonsPanel, Panel):
col.prop(cmat, "homogeneous_volume", text="Homogeneous")
-
-
class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
bl_label = "Bake"
bl_context = "render"
@@ -1789,7 +1788,7 @@ def get_panels():
'DATA_PT_area',
'DATA_PT_camera_dof',
'DATA_PT_falloff_curve',
- 'DATA_PT_lamp',
+ 'DATA_PT_light',
'DATA_PT_preview',
'DATA_PT_spot',
'MATERIAL_PT_context_material',
@@ -1843,10 +1842,10 @@ classes = (
CYCLES_OBJECT_PT_motion_blur,
CYCLES_OBJECT_PT_cycles_settings,
CYCLES_OT_use_shading_nodes,
- CYCLES_LAMP_PT_preview,
- CYCLES_LAMP_PT_lamp,
- CYCLES_LAMP_PT_nodes,
- CYCLES_LAMP_PT_spot,
+ CYCLES_LIGHT_PT_preview,
+ CYCLES_LIGHT_PT_light,
+ CYCLES_LIGHT_PT_nodes,
+ CYCLES_LIGHT_PT_spot,
CYCLES_WORLD_PT_preview,
CYCLES_WORLD_PT_surface,
CYCLES_WORLD_PT_volume,
diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py
index 3334ccd65fd..0564f2a7456 100644
--- a/intern/cycles/blender/addon/version_update.py
+++ b/intern/cycles/blender/addon/version_update.py
@@ -22,45 +22,6 @@ import math
from bpy.app.handlers import persistent
-def check_is_new_shading_ntree(node_tree):
- for node in node_tree.nodes:
- # If material has any node with ONLY new shading system
- # compatibility then it's considered a Cycles material
- # and versioning code would need to perform on it.
- #
- # We can not check for whether NEW_SHADING in compatibility
- # because some nodes could have compatibility with both old
- # and new shading system and they can't be used for any
- # decision here.
- if node.shading_compatibility == {'NEW_SHADING'}:
- return True
-
- # If node is only compatible with old shading system
- # then material can not be Cycles material and we
- # can stopiterating nodes now.
- if node.shading_compatibility == {'OLD_SHADING'}:
- return False
- return False
-
-
-def check_is_new_shading_material(material):
- if not material.node_tree:
- return False
- return check_is_new_shading_ntree(material.node_tree)
-
-
-def check_is_new_shading_world(world):
- if not world.node_tree:
- return False
- return check_is_new_shading_ntree(world.node_tree)
-
-
-def check_is_new_shading_lamp(lamp):
- if not lamp.node_tree:
- return False
- return check_is_new_shading_ntree(lamp.node_tree)
-
-
def foreach_notree_node(nodetree, callback, traversed):
if nodetree in traversed:
return
@@ -74,20 +35,26 @@ def foreach_notree_node(nodetree, callback, traversed):
def foreach_cycles_node(callback):
traversed = set()
for material in bpy.data.materials:
- if check_is_new_shading_material(material):
- foreach_notree_node(material.node_tree,
- callback,
- traversed)
+ if material.node_tree:
+ foreach_notree_node(
+ material.node_tree,
+ callback,
+ traversed,
+ )
for world in bpy.data.worlds:
- if check_is_new_shading_world(world):
- foreach_notree_node(world.node_tree,
- callback,
- traversed)
- for lamp in bpy.data.lamps:
- if check_is_new_shading_world(lamp):
- foreach_notree_node(lamp.node_tree,
- callback,
- traversed)
+ if world.node_tree:
+ foreach_notree_node(
+ world.node_tree,
+ callback,
+ traversed,
+ )
+ for light in bpy.data.lights:
+ if light.node_tree:
+ foreach_notree_node(
+ light.node_tree,
+ callback,
+ traversed,
+ )
def displacement_node_insert(material, nodetree, traversed):
@@ -102,10 +69,12 @@ def displacement_node_insert(material, nodetree, traversed):
# Gather links to replace
displacement_links = []
for link in nodetree.links:
- if link.to_node.bl_idname == 'ShaderNodeOutputMaterial' and \
- link.from_node.bl_idname != 'ShaderNodeDisplacement' and \
- link.to_socket.identifier == 'Displacement':
- displacement_links.append(link)
+ if (
+ link.to_node.bl_idname == 'ShaderNodeOutputMaterial' and
+ link.from_node.bl_idname != 'ShaderNodeDisplacement' and
+ link.to_socket.identifier == 'Displacement'
+ ):
+ displacement_links.append(link)
# Replace links with displacement node
for link in displacement_links:
@@ -117,20 +86,22 @@ def displacement_node_insert(material, nodetree, traversed):
nodetree.links.remove(link)
node = nodetree.nodes.new(type='ShaderNodeDisplacement')
- node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0]);
- node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1]);
+ node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0])
+ node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1])
node.inputs['Scale'].default_value = 0.1
node.inputs['Midlevel'].default_value = 0.0
nodetree.links.new(from_socket, node.inputs['Height'])
nodetree.links.new(node.outputs['Displacement'], to_socket)
+
def displacement_nodes_insert():
traversed = set()
for material in bpy.data.materials:
- if check_is_new_shading_material(material):
+ if material.node_tree:
displacement_node_insert(material, material.node_tree, traversed)
+
def displacement_principled_nodes(node):
if node.bl_idname == 'ShaderNodeDisplacement':
if node.space != 'WORLD':
@@ -139,6 +110,7 @@ def displacement_principled_nodes(node):
if node.subsurface_method != 'RANDOM_WALK':
node.subsurface_method = 'BURLEY'
+
def square_roughness_node_insert(material, nodetree, traversed):
if nodetree in traversed:
return
@@ -163,7 +135,7 @@ def square_roughness_node_insert(material, nodetree, traversed):
for link in nodetree.links:
if link.to_node.bl_idname in roughness_node_types and \
link.to_socket.identifier == 'Roughness':
- roughness_links.append(link)
+ roughness_links.append(link)
# Replace links with sqrt node
for link in roughness_links:
@@ -176,17 +148,18 @@ def square_roughness_node_insert(material, nodetree, traversed):
node = nodetree.nodes.new(type='ShaderNodeMath')
node.operation = 'POWER'
- node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0]);
- node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1]);
+ node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0])
+ node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1])
nodetree.links.new(from_socket, node.inputs[0])
node.inputs[1].default_value = 0.5
nodetree.links.new(node.outputs['Value'], to_socket)
+
def square_roughness_nodes_insert():
traversed = set()
for material in bpy.data.materials:
- if check_is_new_shading_material(material):
+ if material.node_tree:
square_roughness_node_insert(material, material.node_tree, traversed)
@@ -288,7 +261,7 @@ def ambient_occlusion_node_relink(material, nodetree, traversed):
ao_links = []
for link in nodetree.links:
if link.from_node.bl_idname == 'ShaderNodeAmbientOcclusion':
- ao_links.append(link)
+ ao_links.append(link)
# Replace links
for link in ao_links:
@@ -298,10 +271,11 @@ def ambient_occlusion_node_relink(material, nodetree, traversed):
nodetree.links.remove(link)
nodetree.links.new(from_node.outputs['Color'], to_socket)
+
def ambient_occlusion_nodes_relink():
traversed = set()
for material in bpy.data.materials:
- if check_is_new_shading_material(material):
+ if material.node_tree:
ambient_occlusion_node_relink(material, material.node_tree, traversed)
@@ -337,7 +311,7 @@ def do_versions(self):
sample_clamp = cscene.get("sample_clamp", False)
if (sample_clamp and
not cscene.is_property_set("sample_clamp_direct") and
- not cscene.is_property_set("sample_clamp_indirect")):
+ not cscene.is_property_set("sample_clamp_indirect")):
cscene.sample_clamp_direct = sample_clamp
cscene.sample_clamp_indirect = sample_clamp
@@ -355,7 +329,7 @@ def do_versions(self):
cscene = scene.cycles
if (cscene.get("no_caustics", False) and
not cscene.is_property_set("caustics_reflective") and
- not cscene.is_property_set("caustics_refractive")):
+ not cscene.is_property_set("caustics_refractive")):
cscene.caustics_reflective = False
cscene.caustics_refractive = False
@@ -393,12 +367,12 @@ def do_versions(self):
if not cscene.is_property_set("tile_order"):
cscene.tile_order = 'CENTER'
- for lamp in bpy.data.lamps:
- clamp = lamp.cycles
+ for light in bpy.data.lights:
+ clight = light.cycles
# MIS
- if not clamp.is_property_set("use_multiple_importance_sampling"):
- clamp.use_multiple_importance_sampling = False
+ if not clight.is_property_set("use_multiple_importance_sampling"):
+ clight.use_multiple_importance_sampling = False
for mat in bpy.data.materials:
cmat = mat.cycles
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index c5df5842bad..fc86094949f 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -124,7 +124,7 @@ static float blender_camera_focal_distance(BL::RenderEngine& b_engine,
if(!b_dof_object)
return b_camera.dof_distance();
-
+
/* for dof object, return distance along camera Z direction */
BL::Array<float, 16> b_ob_matrix;
b_engine.camera_model_matrix(b_ob, bcam->use_spherical_stereo, b_ob_matrix);
@@ -232,7 +232,7 @@ static void blender_camera_from_object(BlenderCamera *bcam,
bcam->motion_steps = object_motion_steps(b_ob, b_ob);
}
else {
- /* from lamp not implemented yet */
+ /* from light not implemented yet */
}
}
@@ -726,7 +726,7 @@ static void blender_camera_view_subset(BL::RenderEngine& b_engine,
blender_camera_viewplane(&cam_bcam, cam_bcam.full_width, cam_bcam.full_height,
&cam, &cam_aspect, &sensor_size);
-
+
/* return */
*view_box = view * (1.0f/view_aspect);
*cam_box = cam * (1.0f/cam_aspect);
@@ -895,4 +895,3 @@ BufferParams BlenderSync::get_buffer_params(BL::RenderSettings& b_render,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index b7d6c1bb36d..08206dd5521 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1077,14 +1077,6 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
bool object_updated,
bool hide_tris)
{
- /* When viewport display is not needed during render we can force some
- * caches to be releases from blender side in order to reduce peak memory
- * footprint during synchronization process.
- */
- const bool is_interface_locked = b_engine.render() &&
- b_engine.render().use_lock_interface();
- const bool can_free_caches = BlenderSession::headless || is_interface_locked;
-
/* test if we can instance or if the object is modified */
BL::ID b_ob_data = b_ob.data();
BL::ID key = (BKE_object_is_modified(b_ob))? b_ob_instance: b_ob_data;
@@ -1209,10 +1201,6 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
if(view_layer.use_hair && mesh->subdivision_type == Mesh::SUBDIVISION_NONE)
sync_curves(mesh, b_mesh, b_ob, false);
- if(can_free_caches) {
- b_ob.cache_release();
- }
-
/* free derived mesh */
b_data.meshes.remove(b_mesh, false, true, false);
}
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 6d6b367209d..ed01d728931 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -89,7 +89,7 @@ bool BlenderSync::object_is_light(BL::Object& b_ob)
{
BL::ID b_ob_data = b_ob.data();
- return (b_ob_data && b_ob_data.is_a(&RNA_Lamp));
+ return (b_ob_data && b_ob_data.is_a(&RNA_Light));
}
static uint object_ray_visibility(BL::Object& b_ob)
@@ -126,57 +126,57 @@ void BlenderSync::sync_light(BL::Object& b_parent,
*use_portal = true;
return;
}
-
- BL::Lamp b_lamp(b_ob.data());
+
+ BL::Light b_light(b_ob.data());
/* type */
- switch(b_lamp.type()) {
- case BL::Lamp::type_POINT: {
- BL::PointLamp b_point_lamp(b_lamp);
- light->size = b_point_lamp.shadow_soft_size();
+ switch(b_light.type()) {
+ case BL::Light::type_POINT: {
+ BL::PointLight b_point_light(b_light);
+ light->size = b_point_light.shadow_soft_size();
light->type = LIGHT_POINT;
break;
}
- case BL::Lamp::type_SPOT: {
- BL::SpotLamp b_spot_lamp(b_lamp);
- light->size = b_spot_lamp.shadow_soft_size();
+ case BL::Light::type_SPOT: {
+ BL::SpotLight b_spot_light(b_light);
+ light->size = b_spot_light.shadow_soft_size();
light->type = LIGHT_SPOT;
- light->spot_angle = b_spot_lamp.spot_size();
- light->spot_smooth = b_spot_lamp.spot_blend();
+ light->spot_angle = b_spot_light.spot_size();
+ light->spot_smooth = b_spot_light.spot_blend();
break;
}
- case BL::Lamp::type_HEMI: {
+ case BL::Light::type_HEMI: {
light->type = LIGHT_DISTANT;
light->size = 0.0f;
break;
}
- case BL::Lamp::type_SUN: {
- BL::SunLamp b_sun_lamp(b_lamp);
- light->size = b_sun_lamp.shadow_soft_size();
+ case BL::Light::type_SUN: {
+ BL::SunLight b_sun_light(b_light);
+ light->size = b_sun_light.shadow_soft_size();
light->type = LIGHT_DISTANT;
break;
}
- case BL::Lamp::type_AREA: {
- BL::AreaLamp b_area_lamp(b_lamp);
+ case BL::Light::type_AREA: {
+ BL::AreaLight b_area_light(b_light);
light->size = 1.0f;
light->axisu = transform_get_column(&tfm, 0);
light->axisv = transform_get_column(&tfm, 1);
- light->sizeu = b_area_lamp.size();
- switch(b_area_lamp.shape()) {
- case BL::AreaLamp::shape_SQUARE:
+ light->sizeu = b_area_light.size();
+ switch(b_area_light.shape()) {
+ case BL::AreaLight::shape_SQUARE:
light->sizev = light->sizeu;
light->round = false;
break;
- case BL::AreaLamp::shape_RECTANGLE:
- light->sizev = b_area_lamp.size_y();
+ case BL::AreaLight::shape_RECTANGLE:
+ light->sizev = b_area_light.size_y();
light->round = false;
break;
- case BL::AreaLamp::shape_DISK:
+ case BL::AreaLight::shape_DISK:
light->sizev = light->sizeu;
light->round = true;
break;
- case BL::AreaLamp::shape_ELLIPSE:
- light->sizev = b_area_lamp.size_y();
+ case BL::AreaLight::shape_ELLIPSE:
+ light->sizev = b_area_light.size_y();
light->round = true;
break;
}
@@ -192,22 +192,22 @@ void BlenderSync::sync_light(BL::Object& b_parent,
/* shader */
vector<Shader*> used_shaders;
- find_shader(b_lamp, used_shaders, scene->default_light);
+ find_shader(b_light, used_shaders, scene->default_light);
light->shader = used_shaders[0];
/* shadow */
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
- PointerRNA clamp = RNA_pointer_get(&b_lamp.ptr, "cycles");
- light->cast_shadow = get_boolean(clamp, "cast_shadow");
- light->use_mis = get_boolean(clamp, "use_multiple_importance_sampling");
-
- int samples = get_int(clamp, "samples");
+ PointerRNA clight = RNA_pointer_get(&b_light.ptr, "cycles");
+ light->cast_shadow = get_boolean(clight, "cast_shadow");
+ light->use_mis = get_boolean(clight, "use_multiple_importance_sampling");
+
+ int samples = get_int(clight, "samples");
if(get_boolean(cscene, "use_square_samples"))
light->samples = samples * samples;
else
light->samples = samples;
- light->max_bounces = get_int(clamp, "max_bounces");
+ light->max_bounces = get_int(clight, "max_bounces");
if(b_ob != b_ob_instance) {
light->random_id = random_id;
@@ -217,7 +217,7 @@ void BlenderSync::sync_light(BL::Object& b_parent,
}
if(light->type == LIGHT_AREA)
- light->is_portal = get_boolean(clamp, "is_portal");
+ light->is_portal = get_boolean(clight, "is_portal");
else
light->is_portal = false;
@@ -315,7 +315,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph,
/* light is handled separately */
if(object_is_light(b_ob)) {
- /* don't use lamps for excluded layers used as mask layer */
+ /* don't use lights for excluded layers used as mask layer */
if(!motion && !((layer_flag & view_layer.holdout_layer) &&
(layer_flag & view_layer.exclude_layer)))
{
@@ -394,7 +394,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph,
if(object_map.sync(&object, b_ob, b_parent, key))
object_updated = true;
-
+
/* mesh sync */
object->mesh = sync_mesh(b_depsgraph, b_ob, b_ob_instance, object_updated, hide_tris);
@@ -543,7 +543,7 @@ static bool object_render_hide(BL::Object& b_ob,
}
parent = parent.parent();
}
-
+
hide_triangles = hide_emitter;
if(show_emitter) {
@@ -563,7 +563,7 @@ void BlenderSync::sync_objects(BL::Depsgraph& b_depsgraph, float motion_time)
{
/* layer data */
bool motion = motion_time != 0.0f;
-
+
if(!motion) {
/* prepare for sync */
light_map.pre_sync();
@@ -729,4 +729,3 @@ void BlenderSync::sync_motion(BL::RenderSettings& b_render,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/blender/blender_object_cull.cpp b/intern/cycles/blender/blender_object_cull.cpp
index bdf7dc469b2..680d9d7b1ff 100644
--- a/intern/cycles/blender/blender_object_cull.cpp
+++ b/intern/cycles/blender/blender_object_cull.cpp
@@ -146,4 +146,3 @@ bool BlenderObjectCulling::test_distance(Scene *scene, float3 bb[8])
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/blender/blender_particles.cpp b/intern/cycles/blender/blender_particles.cpp
index bb8e2e1398e..a733a499826 100644
--- a/intern/cycles/blender/blender_particles.cpp
+++ b/intern/cycles/blender/blender_particles.cpp
@@ -68,7 +68,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object& b_ob,
/* add particle */
BL::Particle b_pa = b_psys.particles[persistent_id[0]];
Particle pa;
-
+
pa.index = persistent_id[0];
pa.age = b_scene.frame_current() - b_pa.birth_time();
pa.lifetime = b_pa.lifetime();
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 84b90cb53de..4c199f4838f 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -326,7 +326,7 @@ static PyObject *draw_func(PyObject * /*self*/, PyObject *args)
if(!PyArg_ParseTuple(args, "OOOO", &pysession, &pygraph, &pyv3d, &pyrv3d))
return NULL;
-
+
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
if(PyLong_AsVoidPtr(pyrv3d)) {
@@ -594,7 +594,7 @@ static PyObject *osl_compile_func(PyObject * /*self*/, PyObject *args)
if(!PyArg_ParseTuple(args, "ss", &inputfile, &outputfile))
return NULL;
-
+
/* return */
if(!OSLShaderManager::osl_compile(inputfile, outputfile))
Py_RETURN_FALSE;
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 66034919145..62c160ca503 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -154,7 +154,7 @@ static SocketType::Type convert_socket_type(BL::NodeSocket& b_socket)
return SocketType::STRING;
case BL::NodeSocket::type_SHADER:
return SocketType::CLOSURE;
-
+
default:
return SocketType::UNDEFINED;
}
@@ -436,7 +436,7 @@ static ShaderNode *add_node(Scene *scene,
else if(b_node.is_a(&RNA_ShaderNodeBsdfGlossy)) {
BL::ShaderNodeBsdfGlossy b_glossy_node(b_node);
GlossyBsdfNode *glossy = new GlossyBsdfNode();
-
+
switch(b_glossy_node.distribution()) {
case BL::ShaderNodeBsdfGlossy::distribution_SHARP:
glossy->distribution = CLOSURE_BSDF_REFLECTION_ID;
@@ -517,6 +517,12 @@ static ShaderNode *add_node(Scene *scene,
}
node = hair;
}
+ else if(b_node.is_a(&RNA_ShaderNodeBsdfHairPrincipled)) {
+ BL::ShaderNodeBsdfHairPrincipled b_principled_hair_node(b_node);
+ PrincipledHairBsdfNode *principled_hair = new PrincipledHairBsdfNode();
+ principled_hair->parametrization = (NodePrincipledHairParametrization) get_enum(b_principled_hair_node.ptr, "parametrization", NODE_PRINCIPLED_HAIR_NUM, NODE_PRINCIPLED_HAIR_REFLECTANCE);
+ node = principled_hair;
+ }
else if(b_node.is_a(&RNA_ShaderNodeBsdfPrincipled)) {
BL::ShaderNodeBsdfPrincipled b_principled_node(b_node);
PrincipledBsdfNode *principled = new PrincipledBsdfNode();
@@ -747,6 +753,8 @@ static ShaderNode *add_node(Scene *scene,
BL::ShaderNodeTexVoronoi b_voronoi_node(b_node);
VoronoiTextureNode *voronoi = new VoronoiTextureNode();
voronoi->coloring = (NodeVoronoiColoring)b_voronoi_node.coloring();
+ voronoi->metric = (NodeVoronoiDistanceMetric)b_voronoi_node.distance();
+ voronoi->feature = (NodeVoronoiFeature)b_voronoi_node.feature();
BL::TexMapping b_texture_mapping(b_voronoi_node.texture_mapping());
get_tex_mapping(&voronoi->tex_mapping, b_texture_mapping);
node = voronoi;
@@ -940,7 +948,7 @@ static ShaderInput *node_find_input_by_name(ShaderNode *node,
BL::NodeSocket& b_socket)
{
string name = b_socket.name();
-
+
if(node_use_modified_socket_name(node)) {
BL::Node::inputs_iterator b_input;
bool found = false;
@@ -1001,31 +1009,6 @@ static ShaderOutput *node_find_output_by_name(ShaderNode *node,
return node->output(name.c_str());
}
-static BL::ShaderNode find_output_node(BL::ShaderNodeTree& b_ntree)
-{
- BL::ShaderNodeTree::nodes_iterator b_node;
- BL::ShaderNode output_node(PointerRNA_NULL);
-
- for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
- BL::ShaderNodeOutputMaterial b_output_node(*b_node);
-
- if (b_output_node.is_a(&RNA_ShaderNodeOutputMaterial) ||
- b_output_node.is_a(&RNA_ShaderNodeOutputWorld) ||
- b_output_node.is_a(&RNA_ShaderNodeOutputLamp)) {
- /* regular Cycles output node */
- if(b_output_node.is_active_output()) {
- output_node = b_output_node;
- break;
- }
- else if(!output_node.ptr.data) {
- output_node = b_output_node;
- }
- }
- }
-
- return output_node;
-}
-
static void add_nodes(Scene *scene,
BL::RenderEngine& b_engine,
BL::BlendData& b_data,
@@ -1045,7 +1028,7 @@ static void add_nodes(Scene *scene,
BL::Node::outputs_iterator b_output;
/* find the node to use for output if there are multiple */
- BL::ShaderNode output_node = find_output_node(b_ntree);
+ BL::ShaderNode output_node = b_ntree.get_output_node(BL::ShaderNodeOutputMaterial::target_CYCLES);
/* add nodes */
for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
@@ -1068,7 +1051,7 @@ static void add_nodes(Scene *scene,
}
}
else if(b_node->is_a(&RNA_ShaderNodeGroup) || b_node->is_a(&RNA_NodeCustomGroup)) {
-
+
BL::ShaderNodeTree b_group_ntree(PointerRNA_NULL);
if(b_node->is_a(&RNA_ShaderNodeGroup))
b_group_ntree = BL::ShaderNodeTree(((BL::NodeGroup)(*b_node)).node_tree());
@@ -1110,7 +1093,7 @@ static void add_nodes(Scene *scene,
output_map[b_output->ptr.data] = proxy->outputs[0];
}
-
+
if(b_group_ntree) {
add_nodes(scene,
b_engine,
@@ -1353,7 +1336,7 @@ void BlenderSync::sync_world(BL::Depsgraph& b_depsgraph, bool update_all)
}
else if(b_world) {
BackgroundNode *background = new BackgroundNode();
- background->color = get_float3(b_world.horizon_color());
+ background->color = get_float3(b_world.color());
graph->add(background);
ShaderNode *out = graph->output();
@@ -1418,45 +1401,45 @@ void BlenderSync::sync_world(BL::Depsgraph& b_depsgraph, bool update_all)
background->tag_update(scene);
}
-/* Sync Lamps */
+/* Sync Lights */
-void BlenderSync::sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all)
+void BlenderSync::sync_lights(BL::Depsgraph& b_depsgraph, bool update_all)
{
shader_map.set_default(scene->default_light);
BL::Depsgraph::ids_iterator b_id;
for(b_depsgraph.ids.begin(b_id); b_id != b_depsgraph.ids.end(); ++b_id) {
- if (!b_id->is_a(&RNA_Lamp)) {
+ if (!b_id->is_a(&RNA_Light)) {
continue;
}
- BL::Lamp b_lamp(*b_id);
+ BL::Light b_light(*b_id);
Shader *shader;
/* test if we need to sync */
- if(shader_map.sync(&shader, b_lamp) || update_all) {
+ if(shader_map.sync(&shader, b_light) || update_all) {
ShaderGraph *graph = new ShaderGraph();
/* create nodes */
- if(b_lamp.use_nodes() && b_lamp.node_tree()) {
- shader->name = b_lamp.name().c_str();
+ if(b_light.use_nodes() && b_light.node_tree()) {
+ shader->name = b_light.name().c_str();
- BL::ShaderNodeTree b_ntree(b_lamp.node_tree());
+ BL::ShaderNodeTree b_ntree(b_light.node_tree());
add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, graph, b_ntree);
}
else {
float strength = 1.0f;
- if(b_lamp.type() == BL::Lamp::type_POINT ||
- b_lamp.type() == BL::Lamp::type_SPOT ||
- b_lamp.type() == BL::Lamp::type_AREA)
+ if(b_light.type() == BL::Light::type_POINT ||
+ b_light.type() == BL::Light::type_SPOT ||
+ b_light.type() == BL::Light::type_AREA)
{
strength = 100.0f;
}
EmissionNode *emission = new EmissionNode();
- emission->color = get_float3(b_lamp.color());
+ emission->color = get_float3(b_light.color());
emission->strength = strength;
graph->add(emission);
@@ -1484,7 +1467,7 @@ void BlenderSync::sync_shaders(BL::Depsgraph& b_depsgraph)
shader_map.pre_sync();
sync_world(b_depsgraph, auto_refresh_update);
- sync_lamps(b_depsgraph, auto_refresh_update);
+ sync_lights(b_depsgraph, auto_refresh_update);
sync_materials(b_depsgraph, auto_refresh_update);
/* false = don't delete unused shaders, not supported */
@@ -1492,4 +1475,3 @@ void BlenderSync::sync_shaders(BL::Depsgraph& b_depsgraph)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 80aa68d9756..3204e0cd3f2 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -113,17 +113,17 @@ void BlenderSync::sync_recalc(BL::Depsgraph& b_depsgraph)
BL::Material b_mat(b_id);
shader_map.set_recalc(b_mat);
}
- /* Lamp */
- else if (b_id.is_a(&RNA_Lamp)) {
- BL::Lamp b_lamp(b_id);
- shader_map.set_recalc(b_lamp);
+ /* Light */
+ else if (b_id.is_a(&RNA_Light)) {
+ BL::Light b_light(b_id);
+ shader_map.set_recalc(b_light);
}
/* Object */
else if (b_id.is_a(&RNA_Object)) {
BL::Object b_ob(b_id);
- const bool updated_geometry = b_update->updated_geometry();
+ const bool updated_geometry = !b_update->is_dirty_geometry();
- if (b_update->updated_transform()) {
+ if (!b_update->is_dirty_transform()) {
object_map.set_recalc(b_ob);
light_map.set_recalc(b_ob);
}
@@ -207,6 +207,8 @@ void BlenderSync::sync_data(BL::RenderSettings& b_render,
python_thread_state);
mesh_synced.clear();
+
+ free_data_after_sync(b_depsgraph);
}
/* Integrator */
@@ -292,7 +294,7 @@ void BlenderSync::sync_integrator()
integrator->mesh_light_samples = mesh_light_samples * mesh_light_samples;
integrator->subsurface_samples = subsurface_samples * subsurface_samples;
integrator->volume_samples = volume_samples * volume_samples;
- }
+ }
else {
integrator->diffuse_samples = diffuse_samples;
integrator->glossy_samples = glossy_samples;
@@ -327,7 +329,7 @@ void BlenderSync::sync_film()
Film *film = scene->film;
Film prevfilm = *film;
-
+
film->exposure = get_float(cscene, "film_exposure");
film->filter_type = (FilterType)get_enum(cscene,
"pixel_filter_type",
@@ -566,6 +568,30 @@ array<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay,
return passes;
}
+void BlenderSync::free_data_after_sync(BL::Depsgraph& b_depsgraph)
+{
+ /* When viewport display is not needed during render we can force some
+ * caches to be releases from blender side in order to reduce peak memory
+ * footprint during synchronization process.
+ */
+ const bool is_interface_locked = b_engine.render() &&
+ b_engine.render().use_lock_interface();
+ const bool can_free_caches = BlenderSession::headless || is_interface_locked;
+ if (!can_free_caches) {
+ return;
+ }
+ /* TODO(sergey): We can actually remove the whole dependency graph,
+ * but that will need some API support first.
+ */
+ BL::Depsgraph::objects_iterator b_ob;
+ for(b_depsgraph.objects.begin(b_ob);
+ b_ob != b_depsgraph.objects.end();
+ ++b_ob)
+ {
+ b_ob->cache_release();
+ }
+}
+
/* Scene Parameters */
SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
@@ -580,7 +606,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
params.shadingsystem = SHADINGSYSTEM_SVM;
else if(shadingsystem == 1)
params.shadingsystem = SHADINGSYSTEM_OSL;
-
+
if(background || DebugFlags().viewport_static_bvh)
params.bvh_type = SceneParams::BVH_STATIC;
else
@@ -645,7 +671,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
/* device type */
vector<DeviceInfo>& devices = Device::available_devices();
-
+
/* device default CPU */
foreach(DeviceInfo& device, devices) {
if(device.type == DEVICE_CPU) {
@@ -720,7 +746,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
int aa_samples = get_int(cscene, "aa_samples");
int preview_samples = get_int(cscene, "preview_samples");
int preview_aa_samples = get_int(cscene, "preview_aa_samples");
-
+
if(get_boolean(cscene, "use_square_samples")) {
aa_samples = aa_samples * aa_samples;
preview_aa_samples = preview_aa_samples * preview_aa_samples;
@@ -817,7 +843,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
params.shadingsystem = SHADINGSYSTEM_SVM;
else if(shadingsystem == 1)
params.shadingsystem = SHADINGSYSTEM_OSL;
-
+
/* color managagement */
params.display_buffer_linear = GLEW_ARB_half_float_pixel &&
b_engine.support_display_space_shader(b_scene);
@@ -833,4 +859,3 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index 77ee590335c..0465f703c51 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -100,7 +100,7 @@ public:
private:
/* sync */
- void sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all);
+ void sync_lights(BL::Depsgraph& b_depsgraph, bool update_all);
void sync_materials(BL::Depsgraph& b_depsgraph, bool update_all);
void sync_objects(BL::Depsgraph& b_depsgraph, float motion_time = 0.0f);
void sync_motion(BL::RenderSettings& b_render,
@@ -157,6 +157,9 @@ private:
/* Images. */
void sync_images();
+ /* Early data free. */
+ void free_data_after_sync(BL::Depsgraph& b_depsgraph);
+
/* util */
void find_shader(BL::ID& id, vector<Shader*>& used_shaders, Shader *default_shader);
bool BKE_object_is_modified(BL::Object& b_ob);
@@ -218,4 +221,3 @@ private:
CCL_NAMESPACE_END
#endif /* __BLENDER_SYNC_H__ */
-
diff --git a/intern/cycles/bvh/bvh_binning.cpp b/intern/cycles/bvh/bvh_binning.cpp
index 63a7fc11668..f574f31b358 100644
--- a/intern/cycles/bvh/bvh_binning.cpp
+++ b/intern/cycles/bvh/bvh_binning.cpp
@@ -251,4 +251,3 @@ void BVHObjectBinning::split(BVHReference* prims,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/bvh/bvh_node.cpp b/intern/cycles/bvh/bvh_node.cpp
index 24af919ff46..879d07b9625 100644
--- a/intern/cycles/bvh/bvh_node.cpp
+++ b/intern/cycles/bvh/bvh_node.cpp
@@ -206,7 +206,7 @@ void InnerNode::print(int depth) const
{
for(int i = 0; i < depth; i++)
printf(" ");
-
+
printf("inner node %p\n", (void*)this);
if(children[0])
@@ -219,9 +219,8 @@ void LeafNode::print(int depth) const
{
for(int i = 0; i < depth; i++)
printf(" ");
-
+
printf("leaf node %d to %d\n", lo, hi);
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/bvh/bvh_sort.cpp b/intern/cycles/bvh/bvh_sort.cpp
index b40bf5bb21b..f4f73ab2f2f 100644
--- a/intern/cycles/bvh/bvh_sort.cpp
+++ b/intern/cycles/bvh/bvh_sort.cpp
@@ -201,4 +201,3 @@ void bvh_reference_sort(int start,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 31deba2d796..585d9802279 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -123,7 +123,7 @@ public:
/* Use OpenSubdiv patch evaluation */
bool use_patch_evaluation;
-
+
/* Use Transparent shadows */
bool use_transparent;
@@ -307,7 +307,7 @@ public:
/* open shading language, only for CPU device */
virtual void *osl_memory() { return NULL; }
- /* load/compile kernels, must be called before adding tasks */
+ /* load/compile kernels, must be called before adding tasks */
virtual bool load_kernels(
const DeviceRequestedFeatures& /*requested_features*/)
{ return true; }
@@ -317,7 +317,7 @@ public:
virtual void task_add(DeviceTask& task) = 0;
virtual void task_wait() = 0;
virtual void task_cancel() = 0;
-
+
/* opengl drawing */
virtual void draw_pixels(device_memory& mem, int y,
int w, int h, int width, int height,
@@ -376,4 +376,3 @@ private:
CCL_NAMESPACE_END
#endif /* __DEVICE_H__ */
-
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 6be60f8bbb6..be0dcc20755 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -179,8 +179,8 @@ public:
KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_byte_kernel;
KernelFunctions<void(*)(KernelGlobals *, uint4 *, float4 *, int, int, int, int, int)> shader_kernel;
- KernelFunctions<void(*)(int, TilesInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int)> filter_divide_shadow_kernel;
- KernelFunctions<void(*)(int, TilesInfo*, int, int, int, int, float*, float*, int*, int, int)> filter_get_feature_kernel;
+ KernelFunctions<void(*)(int, TileInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int)> filter_divide_shadow_kernel;
+ KernelFunctions<void(*)(int, TileInfo*, int, int, int, int, float*, float*, int*, int, int)> filter_get_feature_kernel;
KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_detect_outliers_kernel;
KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_combine_halves_kernel;
@@ -459,18 +459,6 @@ public:
}
};
- bool denoising_set_tiles(device_ptr *buffers, DenoisingTask *task)
- {
- TilesInfo *tiles = (TilesInfo*) task->tiles_mem.host_pointer;
- for(int i = 0; i < 9; i++) {
- tiles->buffers[i] = buffers[i];
- }
-
- task->tiles_mem.copy_to_device();
-
- return true;
- }
-
bool denoising_non_local_means(device_ptr image_ptr, device_ptr guide_ptr, device_ptr variance_ptr, device_ptr out_ptr,
DenoisingTask *task)
{
@@ -626,7 +614,7 @@ public:
for(int y = task->rect.y; y < task->rect.w; y++) {
for(int x = task->rect.x; x < task->rect.z; x++) {
filter_divide_shadow_kernel()(task->render_buffer.samples,
- task->tiles,
+ task->tile_info,
x, y,
(float*) a_ptr,
(float*) b_ptr,
@@ -635,7 +623,7 @@ public:
(float*) buffer_variance_ptr,
&task->rect.x,
task->render_buffer.pass_stride,
- task->render_buffer.denoising_data_offset);
+ task->render_buffer.offset);
}
}
return true;
@@ -650,7 +638,7 @@ public:
for(int y = task->rect.y; y < task->rect.w; y++) {
for(int x = task->rect.x; x < task->rect.z; x++) {
filter_get_feature_kernel()(task->render_buffer.samples,
- task->tiles,
+ task->tile_info,
mean_offset,
variance_offset,
x, y,
@@ -658,7 +646,7 @@ public:
(float*) variance_ptr,
&task->rect.x,
task->render_buffer.pass_stride,
- task->render_buffer.denoising_data_offset);
+ task->render_buffer.offset);
}
}
return true;
@@ -711,7 +699,7 @@ public:
}
}
- void denoise(DeviceTask &task, DenoisingTask& denoising, RenderTile &tile)
+ void denoise(DenoisingTask& denoising, RenderTile &tile)
{
tile.sample = tile.start_sample + tile.num_samples;
@@ -722,23 +710,11 @@ public:
denoising.functions.combine_halves = function_bind(&CPUDevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising);
denoising.functions.get_feature = function_bind(&CPUDevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising);
denoising.functions.detect_outliers = function_bind(&CPUDevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising);
- denoising.functions.set_tiles = function_bind(&CPUDevice::denoising_set_tiles, this, _1, &denoising);
denoising.filter_area = make_int4(tile.x, tile.y, tile.w, tile.h);
denoising.render_buffer.samples = tile.sample;
- RenderTile rtiles[9];
- rtiles[4] = tile;
- task.map_neighbor_tiles(rtiles, this);
- denoising.tiles_from_rendertiles(rtiles);
-
- denoising.init_from_devicetask(task);
-
- denoising.run_denoising();
-
- task.unmap_neighbor_tiles(rtiles, this);
-
- task.update_progress(&tile, tile.w*tile.h);
+ denoising.run_denoising(&tile);
}
void thread_render(DeviceTask& task)
@@ -766,7 +742,7 @@ public:
}
RenderTile tile;
- DenoisingTask denoising(this);
+ DenoisingTask denoising(this, task);
while(task.acquire_tile(this, tile)) {
if(tile.task == RenderTile::PATH_TRACE) {
@@ -779,7 +755,9 @@ public:
}
}
else if(tile.task == RenderTile::DENOISE) {
- denoise(task, denoising, tile);
+ denoise(denoising, tile);
+
+ task.update_progress(&tile, tile.w*tile.h);
}
task.release_tile(tile);
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 656ad07d657..c9ec1cc1219 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -1072,6 +1072,7 @@ public:
CUarray_format_enum format;
switch(mem.data_type) {
case TYPE_UCHAR: format = CU_AD_FORMAT_UNSIGNED_INT8; break;
+ case TYPE_UINT16: format = CU_AD_FORMAT_UNSIGNED_INT16; break;
case TYPE_UINT: format = CU_AD_FORMAT_UNSIGNED_INT32; break;
case TYPE_INT: format = CU_AD_FORMAT_SIGNED_INT32; break;
case TYPE_FLOAT: format = CU_AD_FORMAT_FLOAT; break;
@@ -1251,18 +1252,6 @@ public:
}
}
- bool denoising_set_tiles(device_ptr *buffers, DenoisingTask *task)
- {
- TilesInfo *tiles = (TilesInfo*) task->tiles_mem.host_pointer;
- for(int i = 0; i < 9; i++) {
- tiles->buffers[i] = buffers[i];
- }
-
- task->tiles_mem.copy_to_device();
-
- return !have_error();
- }
-
#define CUDA_GET_BLOCKSIZE(func, w, h) \
int threads_per_block; \
cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, func)); \
@@ -1534,7 +1523,7 @@ public:
task->rect.w-task->rect.y);
void *args[] = {&task->render_buffer.samples,
- &task->tiles_mem.device_pointer,
+ &task->tile_info_mem.device_pointer,
&a_ptr,
&b_ptr,
&sample_variance_ptr,
@@ -1542,7 +1531,7 @@ public:
&buffer_variance_ptr,
&task->rect,
&task->render_buffer.pass_stride,
- &task->render_buffer.denoising_data_offset};
+ &task->render_buffer.offset};
CUDA_LAUNCH_KERNEL(cuFilterDivideShadow, args);
cuda_assert(cuCtxSynchronize());
@@ -1568,14 +1557,14 @@ public:
task->rect.w-task->rect.y);
void *args[] = {&task->render_buffer.samples,
- &task->tiles_mem.device_pointer,
+ &task->tile_info_mem.device_pointer,
&mean_offset,
&variance_offset,
&mean_ptr,
&variance_ptr,
&task->rect,
&task->render_buffer.pass_stride,
- &task->render_buffer.denoising_data_offset};
+ &task->render_buffer.offset};
CUDA_LAUNCH_KERNEL(cuFilterGetFeature, args);
cuda_assert(cuCtxSynchronize());
@@ -1613,7 +1602,7 @@ public:
return !have_error();
}
- void denoise(RenderTile &rtile, DenoisingTask& denoising, const DeviceTask &task)
+ void denoise(RenderTile &rtile, DenoisingTask& denoising)
{
denoising.functions.construct_transform = function_bind(&CUDADevice::denoising_construct_transform, this, &denoising);
denoising.functions.reconstruct = function_bind(&CUDADevice::denoising_reconstruct, this, _1, _2, _3, &denoising);
@@ -1622,21 +1611,11 @@ public:
denoising.functions.combine_halves = function_bind(&CUDADevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising);
denoising.functions.get_feature = function_bind(&CUDADevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising);
denoising.functions.detect_outliers = function_bind(&CUDADevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising);
- denoising.functions.set_tiles = function_bind(&CUDADevice::denoising_set_tiles, this, _1, &denoising);
denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h);
denoising.render_buffer.samples = rtile.sample;
- RenderTile rtiles[9];
- rtiles[4] = rtile;
- task.map_neighbor_tiles(rtiles, this);
- denoising.tiles_from_rendertiles(rtiles);
-
- denoising.init_from_devicetask(task);
-
- denoising.run_denoising();
-
- task.unmap_neighbor_tiles(rtiles, this);
+ denoising.run_denoising(&rtile);
}
void path_trace(DeviceTask& task, RenderTile& rtile, device_vector<WorkTile>& work_tiles)
@@ -2092,7 +2071,7 @@ public:
/* keep rendering tiles until done */
RenderTile tile;
- DenoisingTask denoising(this);
+ DenoisingTask denoising(this, *task);
while(task->acquire_tile(this, tile)) {
if(tile.task == RenderTile::PATH_TRACE) {
@@ -2107,7 +2086,7 @@ public:
else if(tile.task == RenderTile::DENOISE) {
tile.sample = tile.start_sample + tile.num_samples;
- denoise(tile, denoising, *task);
+ denoise(tile, denoising);
task->update_progress(&tile, tile.w*tile.h);
}
diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp
index 644cf6cd10e..c0d4634262d 100644
--- a/intern/cycles/device/device_denoising.cpp
+++ b/intern/cycles/device/device_denoising.cpp
@@ -20,12 +20,29 @@
CCL_NAMESPACE_BEGIN
-DenoisingTask::DenoisingTask(Device *device)
-: tiles_mem(device, "denoising tiles_mem", MEM_READ_WRITE),
+DenoisingTask::DenoisingTask(Device *device, const DeviceTask &task)
+: tile_info_mem(device, "denoising tile info mem", MEM_READ_WRITE),
storage(device),
buffer(device),
device(device)
{
+ radius = task.denoising_radius;
+ nlm_k_2 = powf(2.0f, lerp(-5.0f, 3.0f, task.denoising_strength));
+ if(task.denoising_relative_pca) {
+ pca_threshold = -powf(10.0f, lerp(-8.0f, 0.0f, task.denoising_feature_strength));
+ }
+ else {
+ pca_threshold = powf(10.0f, lerp(-5.0f, 3.0f, task.denoising_feature_strength));
+ }
+
+ render_buffer.pass_stride = task.pass_stride;
+ render_buffer.offset = task.pass_denoising_data;
+
+ target_buffer.pass_stride = task.pass_stride;
+ target_buffer.denoising_clean_offset = task.pass_denoising_clean;
+
+ functions.map_neighbor_tiles = function_bind(task.map_neighbor_tiles, _1, device);
+ functions.unmap_neighbor_tiles = function_bind(task.unmap_neighbor_tiles, _1, device);
}
DenoisingTask::~DenoisingTask()
@@ -38,170 +55,170 @@ DenoisingTask::~DenoisingTask()
storage.temporary_2.free();
storage.temporary_color.free();
buffer.mem.free();
- tiles_mem.free();
-}
-
-void DenoisingTask::init_from_devicetask(const DeviceTask &task)
-{
- radius = task.denoising_radius;
- nlm_k_2 = powf(2.0f, lerp(-5.0f, 3.0f, task.denoising_strength));
- if(task.denoising_relative_pca) {
- pca_threshold = -powf(10.0f, lerp(-8.0f, 0.0f, task.denoising_feature_strength));
- }
- else {
- pca_threshold = powf(10.0f, lerp(-5.0f, 3.0f, task.denoising_feature_strength));
- }
-
- render_buffer.pass_stride = task.pass_stride;
- render_buffer.denoising_data_offset = task.pass_denoising_data;
- render_buffer.denoising_clean_offset = task.pass_denoising_clean;
-
- /* Expand filter_area by radius pixels and clamp the result to the extent of the neighboring tiles */
- rect = rect_from_shape(filter_area.x, filter_area.y, filter_area.z, filter_area.w);
- rect = rect_expand(rect, radius);
- rect = rect_clip(rect, make_int4(tiles->x[0], tiles->y[0], tiles->x[3], tiles->y[3]));
+ tile_info_mem.free();
}
-void DenoisingTask::tiles_from_rendertiles(RenderTile *rtiles)
+void DenoisingTask::set_render_buffer(RenderTile *rtiles)
{
- tiles = (TilesInfo*) tiles_mem.alloc(sizeof(TilesInfo)/sizeof(int));
+ tile_info = (TileInfo*) tile_info_mem.alloc(sizeof(TileInfo)/sizeof(int));
- device_ptr buffers[9];
for(int i = 0; i < 9; i++) {
- buffers[i] = rtiles[i].buffer;
- tiles->offsets[i] = rtiles[i].offset;
- tiles->strides[i] = rtiles[i].stride;
+ tile_info->offsets[i] = rtiles[i].offset;
+ tile_info->strides[i] = rtiles[i].stride;
+ tile_info->buffers[i] = rtiles[i].buffer;
}
- tiles->x[0] = rtiles[3].x;
- tiles->x[1] = rtiles[4].x;
- tiles->x[2] = rtiles[5].x;
- tiles->x[3] = rtiles[5].x + rtiles[5].w;
- tiles->y[0] = rtiles[1].y;
- tiles->y[1] = rtiles[4].y;
- tiles->y[2] = rtiles[7].y;
- tiles->y[3] = rtiles[7].y + rtiles[7].h;
-
- render_buffer.offset = rtiles[4].offset;
- render_buffer.stride = rtiles[4].stride;
- render_buffer.ptr = rtiles[4].buffer;
-
- functions.set_tiles(buffers);
+ tile_info->x[0] = rtiles[3].x;
+ tile_info->x[1] = rtiles[4].x;
+ tile_info->x[2] = rtiles[5].x;
+ tile_info->x[3] = rtiles[5].x + rtiles[5].w;
+ tile_info->y[0] = rtiles[1].y;
+ tile_info->y[1] = rtiles[4].y;
+ tile_info->y[2] = rtiles[7].y;
+ tile_info->y[3] = rtiles[7].y + rtiles[7].h;
+
+ target_buffer.offset = rtiles[9].offset;
+ target_buffer.stride = rtiles[9].stride;
+ target_buffer.ptr = rtiles[9].buffer;
+
+ tile_info_mem.copy_to_device();
}
-bool DenoisingTask::run_denoising()
+void DenoisingTask::setup_denoising_buffer()
{
- /* Allocate denoising buffer. */
+ /* Expand filter_area by radius pixels and clamp the result to the extent of the neighboring tiles */
+ rect = rect_from_shape(filter_area.x, filter_area.y, filter_area.z, filter_area.w);
+ rect = rect_expand(rect, radius);
+ rect = rect_clip(rect, make_int4(tile_info->x[0], tile_info->y[0], tile_info->x[3], tile_info->y[3]));
+
buffer.passes = 14;
buffer.width = rect.z - rect.x;
buffer.stride = align_up(buffer.width, 4);
buffer.h = rect.w - rect.y;
- buffer.pass_stride = align_up(buffer.stride * buffer.h, divide_up(device->mem_sub_ptr_alignment(), sizeof(float)));
- buffer.mem.alloc_to_device(buffer.pass_stride * buffer.passes, false);
+ int alignment_floats = divide_up(device->mem_sub_ptr_alignment(), sizeof(float));
+ buffer.pass_stride = align_up(buffer.stride * buffer.h, alignment_floats);
+ /* Pad the total size by four floats since the SIMD kernels might go a bit over the end. */
+ int mem_size = align_up(buffer.pass_stride * buffer.passes + 4, alignment_floats);
+ buffer.mem.alloc_to_device(mem_size, false);
+}
+void DenoisingTask::prefilter_shadowing()
+{
device_ptr null_ptr = (device_ptr) 0;
- /* Prefilter shadow feature. */
- {
- device_sub_ptr unfiltered_a (buffer.mem, 0, buffer.pass_stride);
- device_sub_ptr unfiltered_b (buffer.mem, 1*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr sample_var (buffer.mem, 2*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr sample_var_var (buffer.mem, 3*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr buffer_var (buffer.mem, 5*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr filtered_var (buffer.mem, 6*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr nlm_temporary_1(buffer.mem, 7*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr nlm_temporary_2(buffer.mem, 8*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr nlm_temporary_3(buffer.mem, 9*buffer.pass_stride, buffer.pass_stride);
-
- nlm_state.temporary_1_ptr = *nlm_temporary_1;
- nlm_state.temporary_2_ptr = *nlm_temporary_2;
- nlm_state.temporary_3_ptr = *nlm_temporary_3;
-
- /* Get the A/B unfiltered passes, the combined sample variance, the estimated variance of the sample variance and the buffer variance. */
- functions.divide_shadow(*unfiltered_a, *unfiltered_b, *sample_var, *sample_var_var, *buffer_var);
-
- /* Smooth the (generally pretty noisy) buffer variance using the spatial information from the sample variance. */
- nlm_state.set_parameters(6, 3, 4.0f, 1.0f);
- functions.non_local_means(*buffer_var, *sample_var, *sample_var_var, *filtered_var);
-
- /* Reuse memory, the previous data isn't needed anymore. */
- device_ptr filtered_a = *buffer_var,
- filtered_b = *sample_var;
- /* Use the smoothed variance to filter the two shadow half images using each other for weight calculation. */
- nlm_state.set_parameters(5, 3, 1.0f, 0.25f);
- functions.non_local_means(*unfiltered_a, *unfiltered_b, *filtered_var, filtered_a);
- functions.non_local_means(*unfiltered_b, *unfiltered_a, *filtered_var, filtered_b);
-
- device_ptr residual_var = *sample_var_var;
- /* Estimate the residual variance between the two filtered halves. */
- functions.combine_halves(filtered_a, filtered_b, null_ptr, residual_var, 2, rect);
-
- device_ptr final_a = *unfiltered_a,
- final_b = *unfiltered_b;
- /* Use the residual variance for a second filter pass. */
- nlm_state.set_parameters(4, 2, 1.0f, 0.5f);
- functions.non_local_means(filtered_a, filtered_b, residual_var, final_a);
- functions.non_local_means(filtered_b, filtered_a, residual_var, final_b);
-
- /* Combine the two double-filtered halves to a final shadow feature. */
- device_sub_ptr shadow_pass(buffer.mem, 4*buffer.pass_stride, buffer.pass_stride);
- functions.combine_halves(final_a, final_b, *shadow_pass, null_ptr, 0, rect);
- }
+ device_sub_ptr unfiltered_a (buffer.mem, 0, buffer.pass_stride);
+ device_sub_ptr unfiltered_b (buffer.mem, 1*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr sample_var (buffer.mem, 2*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr sample_var_var (buffer.mem, 3*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr buffer_var (buffer.mem, 5*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr filtered_var (buffer.mem, 6*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr nlm_temporary_1(buffer.mem, 7*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr nlm_temporary_2(buffer.mem, 8*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr nlm_temporary_3(buffer.mem, 9*buffer.pass_stride, buffer.pass_stride);
+
+ nlm_state.temporary_1_ptr = *nlm_temporary_1;
+ nlm_state.temporary_2_ptr = *nlm_temporary_2;
+ nlm_state.temporary_3_ptr = *nlm_temporary_3;
+
+ /* Get the A/B unfiltered passes, the combined sample variance, the estimated variance of the sample variance and the buffer variance. */
+ functions.divide_shadow(*unfiltered_a, *unfiltered_b, *sample_var, *sample_var_var, *buffer_var);
+
+ /* Smooth the (generally pretty noisy) buffer variance using the spatial information from the sample variance. */
+ nlm_state.set_parameters(6, 3, 4.0f, 1.0f);
+ functions.non_local_means(*buffer_var, *sample_var, *sample_var_var, *filtered_var);
+
+ /* Reuse memory, the previous data isn't needed anymore. */
+ device_ptr filtered_a = *buffer_var,
+ filtered_b = *sample_var;
+ /* Use the smoothed variance to filter the two shadow half images using each other for weight calculation. */
+ nlm_state.set_parameters(5, 3, 1.0f, 0.25f);
+ functions.non_local_means(*unfiltered_a, *unfiltered_b, *filtered_var, filtered_a);
+ functions.non_local_means(*unfiltered_b, *unfiltered_a, *filtered_var, filtered_b);
+
+ device_ptr residual_var = *sample_var_var;
+ /* Estimate the residual variance between the two filtered halves. */
+ functions.combine_halves(filtered_a, filtered_b, null_ptr, residual_var, 2, rect);
+
+ device_ptr final_a = *unfiltered_a,
+ final_b = *unfiltered_b;
+ /* Use the residual variance for a second filter pass. */
+ nlm_state.set_parameters(4, 2, 1.0f, 0.5f);
+ functions.non_local_means(filtered_a, filtered_b, residual_var, final_a);
+ functions.non_local_means(filtered_b, filtered_a, residual_var, final_b);
+
+ /* Combine the two double-filtered halves to a final shadow feature. */
+ device_sub_ptr shadow_pass(buffer.mem, 4*buffer.pass_stride, buffer.pass_stride);
+ functions.combine_halves(final_a, final_b, *shadow_pass, null_ptr, 0, rect);
+}
- /* Prefilter general features. */
- {
- device_sub_ptr unfiltered (buffer.mem, 8*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr variance (buffer.mem, 9*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr nlm_temporary_1(buffer.mem, 10*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr nlm_temporary_2(buffer.mem, 11*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr nlm_temporary_3(buffer.mem, 12*buffer.pass_stride, buffer.pass_stride);
-
- nlm_state.temporary_1_ptr = *nlm_temporary_1;
- nlm_state.temporary_2_ptr = *nlm_temporary_2;
- nlm_state.temporary_3_ptr = *nlm_temporary_3;
-
- int mean_from[] = { 0, 1, 2, 12, 6, 7, 8 };
- int variance_from[] = { 3, 4, 5, 13, 9, 10, 11};
- int pass_to[] = { 1, 2, 3, 0, 5, 6, 7};
- for(int pass = 0; pass < 7; pass++) {
- device_sub_ptr feature_pass(buffer.mem, pass_to[pass]*buffer.pass_stride, buffer.pass_stride);
- /* Get the unfiltered pass and its variance from the RenderBuffers. */
- functions.get_feature(mean_from[pass], variance_from[pass], *unfiltered, *variance);
- /* Smooth the pass and store the result in the denoising buffers. */
- nlm_state.set_parameters(2, 2, 1.0f, 0.25f);
- functions.non_local_means(*unfiltered, *unfiltered, *variance, *feature_pass);
- }
+void DenoisingTask::prefilter_features()
+{
+ device_sub_ptr unfiltered (buffer.mem, 8*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr variance (buffer.mem, 9*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr nlm_temporary_1(buffer.mem, 10*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr nlm_temporary_2(buffer.mem, 11*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr nlm_temporary_3(buffer.mem, 12*buffer.pass_stride, buffer.pass_stride);
+
+ nlm_state.temporary_1_ptr = *nlm_temporary_1;
+ nlm_state.temporary_2_ptr = *nlm_temporary_2;
+ nlm_state.temporary_3_ptr = *nlm_temporary_3;
+
+ int mean_from[] = { 0, 1, 2, 12, 6, 7, 8 };
+ int variance_from[] = { 3, 4, 5, 13, 9, 10, 11};
+ int pass_to[] = { 1, 2, 3, 0, 5, 6, 7};
+ for(int pass = 0; pass < 7; pass++) {
+ device_sub_ptr feature_pass(buffer.mem, pass_to[pass]*buffer.pass_stride, buffer.pass_stride);
+ /* Get the unfiltered pass and its variance from the RenderBuffers. */
+ functions.get_feature(mean_from[pass], variance_from[pass], *unfiltered, *variance);
+ /* Smooth the pass and store the result in the denoising buffers. */
+ nlm_state.set_parameters(2, 2, 1.0f, 0.25f);
+ functions.non_local_means(*unfiltered, *unfiltered, *variance, *feature_pass);
}
+}
- /* Copy color passes. */
- {
- int mean_from[] = {20, 21, 22};
- int variance_from[] = {23, 24, 25};
- int mean_to[] = { 8, 9, 10};
- int variance_to[] = {11, 12, 13};
- int num_color_passes = 3;
-
- storage.temporary_color.alloc_to_device(3*buffer.pass_stride, false);
-
- for(int pass = 0; pass < num_color_passes; pass++) {
- device_sub_ptr color_pass(storage.temporary_color, pass*buffer.pass_stride, buffer.pass_stride);
- device_sub_ptr color_var_pass(buffer.mem, variance_to[pass]*buffer.pass_stride, buffer.pass_stride);
- functions.get_feature(mean_from[pass], variance_from[pass], *color_pass, *color_var_pass);
- }
-
- {
- device_sub_ptr depth_pass (buffer.mem, 0, buffer.pass_stride);
- device_sub_ptr color_var_pass(buffer.mem, variance_to[0]*buffer.pass_stride, 3*buffer.pass_stride);
- device_sub_ptr output_pass (buffer.mem, mean_to[0]*buffer.pass_stride, 3*buffer.pass_stride);
- functions.detect_outliers(storage.temporary_color.device_pointer, *color_var_pass, *depth_pass, *output_pass);
- }
+void DenoisingTask::prefilter_color()
+{
+ int mean_from[] = {20, 21, 22};
+ int variance_from[] = {23, 24, 25};
+ int mean_to[] = { 8, 9, 10};
+ int variance_to[] = {11, 12, 13};
+ int num_color_passes = 3;
+
+ storage.temporary_color.alloc_to_device(3*buffer.pass_stride, false);
+ device_sub_ptr nlm_temporary_1(storage.temporary_color, 0*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr nlm_temporary_2(storage.temporary_color, 1*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr nlm_temporary_3(storage.temporary_color, 2*buffer.pass_stride, buffer.pass_stride);
+
+ nlm_state.temporary_1_ptr = *nlm_temporary_1;
+ nlm_state.temporary_2_ptr = *nlm_temporary_2;
+ nlm_state.temporary_3_ptr = *nlm_temporary_3;
+
+ for(int pass = 0; pass < num_color_passes; pass++) {
+ device_sub_ptr color_pass(storage.temporary_color, pass*buffer.pass_stride, buffer.pass_stride);
+ device_sub_ptr color_var_pass(buffer.mem, variance_to[pass]*buffer.pass_stride, buffer.pass_stride);
+ functions.get_feature(mean_from[pass], variance_from[pass], *color_pass, *color_var_pass);
}
+ device_sub_ptr depth_pass (buffer.mem, 0, buffer.pass_stride);
+ device_sub_ptr color_var_pass(buffer.mem, variance_to[0]*buffer.pass_stride, 3*buffer.pass_stride);
+ device_sub_ptr output_pass (buffer.mem, mean_to[0]*buffer.pass_stride, 3*buffer.pass_stride);
+ functions.detect_outliers(storage.temporary_color.device_pointer, *color_var_pass, *depth_pass, *output_pass);
+
+ storage.temporary_color.free();
+}
+
+void DenoisingTask::construct_transform()
+{
storage.w = filter_area.z;
storage.h = filter_area.w;
+
storage.transform.alloc_to_device(storage.w*storage.h*TRANSFORM_SIZE, false);
storage.rank.alloc_to_device(storage.w*storage.h, false);
functions.construct_transform();
+}
+
+void DenoisingTask::reconstruct()
+{
device_only_memory<float> temporary_1(device, "Denoising NLM temporary 1");
device_only_memory<float> temporary_2(device, "Denoising NLM temporary 2");
@@ -214,21 +231,36 @@ bool DenoisingTask::run_denoising()
storage.XtWY.alloc_to_device(storage.w*storage.h*XTWY_SIZE, false);
reconstruction_state.filter_window = rect_from_shape(filter_area.x-rect.x, filter_area.y-rect.y, storage.w, storage.h);
- int tile_coordinate_offset = filter_area.y*render_buffer.stride + filter_area.x;
- reconstruction_state.buffer_params = make_int4(render_buffer.offset + tile_coordinate_offset,
- render_buffer.stride,
- render_buffer.pass_stride,
- render_buffer.denoising_clean_offset);
+ int tile_coordinate_offset = filter_area.y*target_buffer.stride + filter_area.x;
+ reconstruction_state.buffer_params = make_int4(target_buffer.offset + tile_coordinate_offset,
+ target_buffer.stride,
+ target_buffer.pass_stride,
+ target_buffer.denoising_clean_offset);
reconstruction_state.source_w = rect.z-rect.x;
reconstruction_state.source_h = rect.w-rect.y;
- {
- device_sub_ptr color_ptr (buffer.mem, 8*buffer.pass_stride, 3*buffer.pass_stride);
- device_sub_ptr color_var_ptr(buffer.mem, 11*buffer.pass_stride, 3*buffer.pass_stride);
- functions.reconstruct(*color_ptr, *color_var_ptr, render_buffer.ptr);
- }
+ device_sub_ptr color_ptr (buffer.mem, 8*buffer.pass_stride, 3*buffer.pass_stride);
+ device_sub_ptr color_var_ptr(buffer.mem, 11*buffer.pass_stride, 3*buffer.pass_stride);
+ functions.reconstruct(*color_ptr, *color_var_ptr, target_buffer.ptr);
+}
+
+void DenoisingTask::run_denoising(RenderTile *tile)
+{
+ RenderTile rtiles[10];
+ rtiles[4] = *tile;
+ functions.map_neighbor_tiles(rtiles);
+ set_render_buffer(rtiles);
+
+ setup_denoising_buffer();
+
+ prefilter_shadowing();
+ prefilter_features();
+ prefilter_color();
+
+ construct_transform();
+ reconstruct();
- return true;
+ functions.unmap_neighbor_tiles(rtiles);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/device/device_denoising.h b/intern/cycles/device/device_denoising.h
index 77a82d0ad04..e0da52867f1 100644
--- a/intern/cycles/device/device_denoising.h
+++ b/intern/cycles/device/device_denoising.h
@@ -32,20 +32,24 @@ public:
float nlm_k_2;
float pca_threshold;
- /* Pointer and parameters of the RenderBuffers. */
+ /* Parameters of the RenderBuffers. */
struct RenderBuffers {
- int denoising_data_offset;
- int denoising_clean_offset;
+ int offset;
int pass_stride;
+ int samples;
+ } render_buffer;
+
+ /* Pointer and parameters of the target buffer. */
+ struct TargetBuffer {
int offset;
int stride;
+ int pass_stride;
+ int denoising_clean_offset;
device_ptr ptr;
- int samples;
- } render_buffer;
+ } target_buffer;
- TilesInfo *tiles;
- device_vector<int> tiles_mem;
- void tiles_from_rendertiles(RenderTile *rtiles);
+ TileInfo *tile_info;
+ device_vector<int> tile_info_mem;
int4 rect;
int4 filter_area;
@@ -85,7 +89,8 @@ public:
device_ptr depth_ptr,
device_ptr output_ptr
)> detect_outliers;
- function<bool(device_ptr*)> set_tiles;
+ function<void(RenderTile *rtiles)> map_neighbor_tiles;
+ function<void(RenderTile *rtiles)> unmap_neighbor_tiles;
} functions;
/* Stores state of the current Reconstruction operation,
@@ -138,12 +143,10 @@ public:
{}
} storage;
- DenoisingTask(Device *device);
+ DenoisingTask(Device *device, const DeviceTask &task);
~DenoisingTask();
- void init_from_devicetask(const DeviceTask &task);
-
- bool run_denoising();
+ void run_denoising(RenderTile *tile);
struct DenoiseBuffers {
int pass_stride;
@@ -160,6 +163,14 @@ public:
protected:
Device *device;
+
+ void set_render_buffer(RenderTile *rtiles);
+ void setup_denoising_buffer();
+ void prefilter_shadowing();
+ void prefilter_features();
+ void prefilter_color();
+ void construct_transform();
+ void reconstruct();
};
CCL_NAMESPACE_END
diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h
index de487649045..941be448101 100644
--- a/intern/cycles/device/device_intern.h
+++ b/intern/cycles/device/device_intern.h
@@ -41,4 +41,3 @@ string device_cuda_capabilities(void);
CCL_NAMESPACE_END
#endif /* __DEVICE_INTERN_H__ */
-
diff --git a/intern/cycles/device/device_memory.cpp b/intern/cycles/device/device_memory.cpp
index c6248fcf88b..a8d29896553 100644
--- a/intern/cycles/device/device_memory.cpp
+++ b/intern/cycles/device/device_memory.cpp
@@ -104,6 +104,26 @@ void device_memory::device_zero()
}
}
+void device_memory::swap_device(Device *new_device,
+ size_t new_device_size,
+ device_ptr new_device_ptr)
+{
+ original_device = device;
+ original_device_size = device_size;
+ original_device_ptr = device_pointer;
+
+ device = new_device;
+ device_size = new_device_size;
+ device_pointer = new_device_ptr;
+}
+
+void device_memory::restore_device()
+{
+ device = original_device;
+ device_size = original_device_size;
+ device_pointer = original_device_ptr;
+}
+
/* Device Sub Ptr */
device_sub_ptr::device_sub_ptr(device_memory& mem, int offset, int size)
@@ -118,4 +138,3 @@ device_sub_ptr::~device_sub_ptr()
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h
index d8fe41e78bb..2b4835c9c65 100644
--- a/intern/cycles/device/device_memory.h
+++ b/intern/cycles/device/device_memory.h
@@ -43,6 +43,7 @@ enum MemoryType {
enum DataType {
TYPE_UNKNOWN,
TYPE_UCHAR,
+ TYPE_UINT16,
TYPE_UINT,
TYPE_INT,
TYPE_FLOAT,
@@ -50,13 +51,14 @@ enum DataType {
TYPE_UINT64,
};
-static inline size_t datatype_size(DataType datatype)
+static inline size_t datatype_size(DataType datatype)
{
switch(datatype) {
case TYPE_UNKNOWN: return 1;
case TYPE_UCHAR: return sizeof(uchar);
case TYPE_FLOAT: return sizeof(float);
case TYPE_UINT: return sizeof(uint);
+ case TYPE_UINT16: return sizeof(uint16_t);
case TYPE_INT: return sizeof(int);
case TYPE_HALF: return sizeof(half);
case TYPE_UINT64: return sizeof(uint64_t);
@@ -156,6 +158,16 @@ template<> struct device_type_traits<half> {
static const int num_elements = 1;
};
+template<> struct device_type_traits<ushort4> {
+ static const DataType data_type = TYPE_UINT16;
+ static const int num_elements = 4;
+};
+
+template<> struct device_type_traits<uint16_t> {
+ static const DataType data_type = TYPE_UINT16;
+ static const int num_elements = 1;
+};
+
template<> struct device_type_traits<half4> {
static const DataType data_type = TYPE_HALF;
static const int num_elements = 4;
@@ -200,6 +212,9 @@ public:
virtual ~device_memory();
+ void swap_device(Device *new_device, size_t new_device_size, device_ptr new_device_ptr);
+ void restore_device();
+
protected:
friend class CUDADevice;
@@ -222,6 +237,10 @@ protected:
void device_copy_to();
void device_copy_from(int y, int w, int h, int elem);
void device_zero();
+
+ device_ptr original_device_ptr;
+ size_t original_device_size;
+ Device *original_device;
};
/* Device Only Memory
@@ -478,4 +497,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __DEVICE_MEMORY_H__ */
-
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 91507e6be0c..587840e551f 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -285,26 +285,27 @@ public:
mem.copy_from_device(0, mem.data_size, 1);
}
- Device *original_device = mem.device;
- device_ptr original_ptr = mem.device_pointer;
- size_t original_size = mem.device_size;
-
- mem.device = sub_device;
- mem.device_pointer = 0;
- mem.device_size = 0;
+ mem.swap_device(sub_device, 0, 0);
mem.copy_to_device();
tiles[i].buffer = mem.device_pointer;
+ tiles[i].device_size = mem.device_size;
- mem.device = original_device;
- mem.device_pointer = original_ptr;
- mem.device_size = original_size;
+ mem.restore_device();
}
}
}
void unmap_neighbor_tiles(Device * sub_device, RenderTile * tiles)
{
+ /* Copy denoised result back to the host. */
+ device_vector<float> &mem = tiles[9].buffers->buffer;
+ mem.swap_device(sub_device, tiles[9].device_size, tiles[9].buffer);
+ mem.copy_from_device(0, mem.data_size, 1);
+ mem.restore_device();
+ /* Copy denoised result to the original device. */
+ mem.copy_to_device();
+
for(int i = 0; i < 9; i++) {
if(!tiles[i].buffers) {
continue;
@@ -312,28 +313,9 @@ public:
device_vector<float> &mem = tiles[i].buffers->buffer;
if(mem.device != sub_device) {
- Device *original_device = mem.device;
- device_ptr original_ptr = mem.device_pointer;
- size_t original_size = mem.device_size;
-
- mem.device = sub_device;
- mem.device_pointer = tiles[i].buffer;
-
- /* Copy denoised tile to the host. */
- if(i == 4) {
- mem.copy_from_device(0, mem.data_size, 1);
- }
-
+ mem.swap_device(sub_device, tiles[i].device_size, tiles[i].buffer);
sub_device->mem_free(mem);
-
- mem.device = original_device;
- mem.device_pointer = original_ptr;
- mem.device_size = original_size;
-
- /* Copy denoised tile to the original device. */
- if(i == 4) {
- mem.copy_to_device();
- }
+ mem.restore_device();
}
}
}
@@ -397,4 +379,3 @@ Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp
index 5ad4405366e..204e405421d 100644
--- a/intern/cycles/device/device_network.cpp
+++ b/intern/cycles/device/device_network.cpp
@@ -797,5 +797,3 @@ void Device::server_run()
CCL_NAMESPACE_END
#endif
-
-
diff --git a/intern/cycles/device/device_network.h b/intern/cycles/device/device_network.h
index b734ba2bda9..96e0de742db 100644
--- a/intern/cycles/device/device_network.h
+++ b/intern/cycles/device/device_network.h
@@ -179,7 +179,7 @@ public:
boost::asio::write(socket,
boost::asio::buffer(archive_str),
boost::asio::transfer_all(), error);
-
+
if(error.value())
error_func->network_error(error.message());
@@ -193,7 +193,7 @@ public:
boost::asio::write(socket,
boost::asio::buffer(buffer, size),
boost::asio::transfer_all(), error);
-
+
if(error.value())
error_func->network_error(error.message());
}
@@ -467,7 +467,7 @@ private:
/* buffer and endpoint for receiving messages */
char receive_buffer[256];
boost::asio::ip::udp::endpoint receive_endpoint;
-
+
// os, version, devices, status, host name, group name, ip as far as fields go
struct ServerInfo {
string cycles_version;
@@ -489,4 +489,3 @@ CCL_NAMESPACE_END
#endif
#endif /* __DEVICE_NETWORK_H__ */
-
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 9d61bbdae5d..95eef8263d4 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -137,6 +137,10 @@ void device_opencl_info(vector<DeviceInfo>& devices)
info.has_volume_decoupled = false;
info.bvh_layout_mask = BVH_LAYOUT_BVH2;
info.id = id;
+
+ /* Check OpenCL extensions */
+ info.has_half_images = platform_device.device_extensions.find("cl_khr_fp16") != string::npos;
+
devices.push_back(info);
num_devices++;
}
diff --git a/intern/cycles/device/device_split_kernel.cpp b/intern/cycles/device/device_split_kernel.cpp
index 74135a1f3c8..efaae8c84f4 100644
--- a/intern/cycles/device/device_split_kernel.cpp
+++ b/intern/cycles/device/device_split_kernel.cpp
@@ -261,7 +261,7 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
ENQUEUE_SPLIT_KERNEL(buffer_update, global_size, local_size);
if(task->get_cancel() && cancel_time == DBL_MAX) {
- /* Wait up to twice as many seconds for current samples to finish
+ /* Wait up to twice as many seconds for current samples to finish
* to avoid artifacts in render result from ending too soon.
*/
cancel_time = time_dt() + 2.0 * time_multiplier;
@@ -322,5 +322,3 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
}
CCL_NAMESPACE_END
-
-
diff --git a/intern/cycles/device/device_split_kernel.h b/intern/cycles/device/device_split_kernel.h
index 2ec0261e847..26ddce5bb22 100644
--- a/intern/cycles/device/device_split_kernel.h
+++ b/intern/cycles/device/device_split_kernel.h
@@ -131,6 +131,3 @@ public:
CCL_NAMESPACE_END
#endif /* __DEVICE_SPLIT_KERNEL_H__ */
-
-
-
diff --git a/intern/cycles/device/device_task.cpp b/intern/cycles/device/device_task.cpp
index 3c7d24fb5b7..8310863886c 100644
--- a/intern/cycles/device/device_task.cpp
+++ b/intern/cycles/device/device_task.cpp
@@ -126,4 +126,3 @@ void DeviceTask::update_progress(RenderTile *rtile, int pixel_samples)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h
index b9658eb978f..ec87aa8c560 100644
--- a/intern/cycles/device/device_task.h
+++ b/intern/cycles/device/device_task.h
@@ -86,4 +86,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __DEVICE_TASK_H__ */
-
diff --git a/intern/cycles/device/opencl/memory_manager.cpp b/intern/cycles/device/opencl/memory_manager.cpp
index 75c9de65035..485a656cb83 100644
--- a/intern/cycles/device/opencl/memory_manager.cpp
+++ b/intern/cycles/device/opencl/memory_manager.cpp
@@ -254,4 +254,3 @@ void MemoryManager::set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg)
CCL_NAMESPACE_END
#endif /* WITH_OPENCL */
-
diff --git a/intern/cycles/device/opencl/memory_manager.h b/intern/cycles/device/opencl/memory_manager.h
index b3d861275f0..b49bd32dab6 100644
--- a/intern/cycles/device/opencl/memory_manager.h
+++ b/intern/cycles/device/opencl/memory_manager.h
@@ -104,4 +104,3 @@ public:
};
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h
index 85ef14ee29a..d0571fc3c14 100644
--- a/intern/cycles/device/opencl/opencl.h
+++ b/intern/cycles/device/opencl/opencl.h
@@ -59,19 +59,22 @@ struct OpenCLPlatformDevice {
cl_device_id device_id,
cl_device_type device_type,
const string& device_name,
- const string& hardware_id)
+ const string& hardware_id,
+ const string& device_extensions)
: platform_id(platform_id),
platform_name(platform_name),
device_id(device_id),
device_type(device_type),
device_name(device_name),
- hardware_id(hardware_id) {}
+ hardware_id(hardware_id),
+ device_extensions(device_extensions) {}
cl_platform_id platform_id;
string platform_name;
cl_device_id device_id;
cl_device_type device_type;
string device_name;
string hardware_id;
+ string device_extensions;
};
/* Contains all static OpenCL helper functions. */
@@ -130,6 +133,12 @@ public:
static string get_device_name(cl_device_id device_id);
+ static bool get_device_extensions(cl_device_id device_id,
+ string *device_extensions,
+ cl_int* error = NULL);
+
+ static string get_device_extensions(cl_device_id device_id);
+
static bool get_device_type(cl_device_id device_id,
cl_device_type *device_type,
cl_int* error = NULL);
@@ -362,7 +371,7 @@ public:
void film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half);
void shader(DeviceTask& task);
- void denoise(RenderTile& tile, DenoisingTask& denoising, const DeviceTask& task);
+ void denoise(RenderTile& tile, DenoisingTask& denoising);
class OpenCLDeviceTask : public DeviceTask {
public:
@@ -436,8 +445,6 @@ protected:
device_ptr depth_ptr,
device_ptr output_ptr,
DenoisingTask *task);
- bool denoising_set_tiles(device_ptr *buffers,
- DenoisingTask *task);
device_ptr mem_alloc_sub_ptr(device_memory& mem, int offset, int size);
void mem_free_sub_ptr(device_ptr ptr);
diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp
index bfa2702ad62..9a50d217321 100644
--- a/intern/cycles/device/opencl/opencl_base.cpp
+++ b/intern/cycles/device/opencl/opencl_base.cpp
@@ -246,7 +246,6 @@ bool OpenCLDeviceBase::load_kernels(const DeviceRequestedFeatures& requested_fea
denoising_program.add_kernel(ustring("filter_nlm_normalize"));
denoising_program.add_kernel(ustring("filter_nlm_construct_gramian"));
denoising_program.add_kernel(ustring("filter_finalize"));
- denoising_program.add_kernel(ustring("filter_set_tiles"));
vector<OpenCLProgram*> programs;
programs.push_back(&base_program);
@@ -977,13 +976,20 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr,
cl_mem sv_variance_mem = CL_MEM_PTR(sv_variance_ptr);
cl_mem buffer_variance_mem = CL_MEM_PTR(buffer_variance_ptr);
- cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer);
+ cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer);
cl_kernel ckFilterDivideShadow = denoising_program(ustring("filter_divide_shadow"));
- kernel_set_args(ckFilterDivideShadow, 0,
- task->render_buffer.samples,
- tiles_mem,
+ int arg_ofs = kernel_set_args(ckFilterDivideShadow, 0,
+ task->render_buffer.samples,
+ tile_info_mem);
+ cl_mem buffers[9];
+ for(int i = 0; i < 9; i++) {
+ buffers[i] = CL_MEM_PTR(task->tile_info->buffers[i]);
+ arg_ofs += kernel_set_args(ckFilterDivideShadow, arg_ofs,
+ buffers[i]);
+ }
+ kernel_set_args(ckFilterDivideShadow, arg_ofs,
a_mem,
b_mem,
sample_variance_mem,
@@ -991,7 +997,7 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr,
buffer_variance_mem,
task->rect,
task->render_buffer.pass_stride,
- task->render_buffer.denoising_data_offset);
+ task->render_buffer.offset);
enqueue_kernel(ckFilterDivideShadow,
task->rect.z-task->rect.x,
task->rect.w-task->rect.y);
@@ -1008,20 +1014,27 @@ bool OpenCLDeviceBase::denoising_get_feature(int mean_offset,
cl_mem mean_mem = CL_MEM_PTR(mean_ptr);
cl_mem variance_mem = CL_MEM_PTR(variance_ptr);
- cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer);
+ cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer);
cl_kernel ckFilterGetFeature = denoising_program(ustring("filter_get_feature"));
- kernel_set_args(ckFilterGetFeature, 0,
- task->render_buffer.samples,
- tiles_mem,
+ int arg_ofs = kernel_set_args(ckFilterGetFeature, 0,
+ task->render_buffer.samples,
+ tile_info_mem);
+ cl_mem buffers[9];
+ for(int i = 0; i < 9; i++) {
+ buffers[i] = CL_MEM_PTR(task->tile_info->buffers[i]);
+ arg_ofs += kernel_set_args(ckFilterGetFeature, arg_ofs,
+ buffers[i]);
+ }
+ kernel_set_args(ckFilterGetFeature, arg_ofs,
mean_offset,
variance_offset,
mean_mem,
variance_mem,
task->rect,
task->render_buffer.pass_stride,
- task->render_buffer.denoising_data_offset);
+ task->render_buffer.offset);
enqueue_kernel(ckFilterGetFeature,
task->rect.z-task->rect.x,
task->rect.w-task->rect.y);
@@ -1056,29 +1069,8 @@ bool OpenCLDeviceBase::denoising_detect_outliers(device_ptr image_ptr,
return true;
}
-bool OpenCLDeviceBase::denoising_set_tiles(device_ptr *buffers,
- DenoisingTask *task)
-{
- task->tiles_mem.copy_to_device();
-
- cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer);
-
- cl_kernel ckFilterSetTiles = denoising_program(ustring("filter_set_tiles"));
-
- kernel_set_args(ckFilterSetTiles, 0, tiles_mem);
- for(int i = 0; i < 9; i++) {
- cl_mem buffer_mem = CL_MEM_PTR(buffers[i]);
- kernel_set_args(ckFilterSetTiles, i+1, buffer_mem);
- }
-
- enqueue_kernel(ckFilterSetTiles, 1, 1);
-
- return true;
-}
-
-void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising, const DeviceTask &task)
+void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising)
{
- denoising.functions.set_tiles = function_bind(&OpenCLDeviceBase::denoising_set_tiles, this, _1, &denoising);
denoising.functions.construct_transform = function_bind(&OpenCLDeviceBase::denoising_construct_transform, this, &denoising);
denoising.functions.reconstruct = function_bind(&OpenCLDeviceBase::denoising_reconstruct, this, _1, _2, _3, &denoising);
denoising.functions.divide_shadow = function_bind(&OpenCLDeviceBase::denoising_divide_shadow, this, _1, _2, _3, _4, _5, &denoising);
@@ -1090,16 +1082,7 @@ void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising, cons
denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h);
denoising.render_buffer.samples = rtile.sample;
- RenderTile rtiles[9];
- rtiles[4] = rtile;
- task.map_neighbor_tiles(rtiles, this);
- denoising.tiles_from_rendertiles(rtiles);
-
- denoising.init_from_devicetask(task);
-
- denoising.run_denoising();
-
- task.unmap_neighbor_tiles(rtiles, this);
+ denoising.run_denoising(&rtile);
}
void OpenCLDeviceBase::shader(DeviceTask& task)
diff --git a/intern/cycles/device/opencl/opencl_mega.cpp b/intern/cycles/device/opencl/opencl_mega.cpp
index ef39cfb5f7d..e004c0b44f4 100644
--- a/intern/cycles/device/opencl/opencl_mega.cpp
+++ b/intern/cycles/device/opencl/opencl_mega.cpp
@@ -107,7 +107,7 @@ public:
}
else if(task->type == DeviceTask::RENDER) {
RenderTile tile;
- DenoisingTask denoising(this);
+ DenoisingTask denoising(this, *task);
/* Keep rendering tiles until done. */
while(task->acquire_tile(this, tile)) {
@@ -141,7 +141,7 @@ public:
}
else if(tile.task == RenderTile::DENOISE) {
tile.sample = tile.start_sample + tile.num_samples;
- denoise(tile, denoising, *task);
+ denoise(tile, denoising);
task->update_progress(&tile, tile.w*tile.h);
}
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp
index 51d3c7bb10f..66a4aa7e891 100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@ -129,7 +129,7 @@ public:
}
else if(task->type == DeviceTask::RENDER) {
RenderTile tile;
- DenoisingTask denoising(this);
+ DenoisingTask denoising(this, *task);
/* Allocate buffer for kernel globals */
device_only_memory<KernelGlobalsDummy> kgbuffer(this, "kernel_globals");
@@ -159,7 +159,7 @@ public:
}
else if(tile.task == RenderTile::DENOISE) {
tile.sample = tile.start_sample + tile.num_samples;
- denoise(tile, denoising, *task);
+ denoise(tile, denoising);
task->update_progress(&tile, tile.w*tile.h);
}
diff --git a/intern/cycles/device/opencl/opencl_util.cpp b/intern/cycles/device/opencl/opencl_util.cpp
index 78ed401bff5..9104f64bedd 100644
--- a/intern/cycles/device/opencl/opencl_util.cpp
+++ b/intern/cycles/device/opencl/opencl_util.cpp
@@ -831,13 +831,15 @@ void OpenCLInfo::get_usable_devices(vector<OpenCLPlatformDevice> *usable_devices
FIRST_VLOG(2) << "Adding new device "
<< readable_device_name << ".";
string hardware_id = get_hardware_id(platform_name, device_id);
+ string device_extensions = get_device_extensions(device_id);
usable_devices->push_back(OpenCLPlatformDevice(
platform_id,
platform_name,
device_id,
device_type,
readable_device_name,
- hardware_id));
+ hardware_id,
+ device_extensions));
}
else {
FIRST_VLOG(2) << "Ignoring device " << device_name
@@ -1047,6 +1049,40 @@ string OpenCLInfo::get_device_name(cl_device_id device_id)
return device_name;
}
+bool OpenCLInfo::get_device_extensions(cl_device_id device_id,
+ string *device_extensions,
+ cl_int* error)
+{
+ char buffer[1024];
+ cl_int err;
+ if((err = clGetDeviceInfo(device_id,
+ CL_DEVICE_EXTENSIONS,
+ sizeof(buffer),
+ &buffer,
+ NULL)) != CL_SUCCESS)
+ {
+ if(error != NULL) {
+ *error = err;
+ }
+ *device_extensions = "";
+ return false;
+ }
+ if(error != NULL) {
+ *error = CL_SUCCESS;
+ }
+ *device_extensions = buffer;
+ return true;
+}
+
+string OpenCLInfo::get_device_extensions(cl_device_id device_id)
+{
+ string device_extensions;
+ if(!get_device_extensions(device_id, &device_extensions)) {
+ return "";
+ }
+ return device_extensions;
+}
+
bool OpenCLInfo::get_device_type(cl_device_id device_id,
cl_device_type *device_type,
cl_int* error)
diff --git a/intern/cycles/doc/license/Apache_2.0.txt b/intern/cycles/doc/license/Apache_2.0.txt
index 6b0b1270ff0..d6456956733 100644
--- a/intern/cycles/doc/license/Apache_2.0.txt
+++ b/intern/cycles/doc/license/Apache_2.0.txt
@@ -200,4 +200,3 @@
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.
-
diff --git a/intern/cycles/doc/license/ILM.txt b/intern/cycles/doc/license/ILM.txt
index 0e24aa56203..8b68abc954d 100644
--- a/intern/cycles/doc/license/ILM.txt
+++ b/intern/cycles/doc/license/ILM.txt
@@ -13,7 +13,7 @@ met:
distribution.
* Neither the name of Industrial Light & Magic nor the names of its
contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -26,4 +26,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/intern/cycles/doc/license/NVidia.txt b/intern/cycles/doc/license/NVidia.txt
index 4fa55d3d2bc..42c165e11d2 100644
--- a/intern/cycles/doc/license/NVidia.txt
+++ b/intern/cycles/doc/license/NVidia.txt
@@ -33,4 +33,3 @@ 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.
-
diff --git a/intern/cycles/doc/license/OSL.txt b/intern/cycles/doc/license/OSL.txt
index 1ffeb58291e..e716b5c5e10 100644
--- a/intern/cycles/doc/license/OSL.txt
+++ b/intern/cycles/doc/license/OSL.txt
@@ -25,4 +25,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/intern/cycles/doc/license/Sobol.txt b/intern/cycles/doc/license/Sobol.txt
index 4ad42d22fb1..0bce8349fe5 100644
--- a/intern/cycles/doc/license/Sobol.txt
+++ b/intern/cycles/doc/license/Sobol.txt
@@ -26,4 +26,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/intern/cycles/doc/license/readme.txt b/intern/cycles/doc/license/readme.txt
index 4c56c90a0f1..cc5476e3511 100644
--- a/intern/cycles/doc/license/readme.txt
+++ b/intern/cycles/doc/license/readme.txt
@@ -13,4 +13,3 @@ MIT license
Boost License
* Boost and OpenCL dynamic loading
-
diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp
index b16c6af5d0e..45ffc8d7d6b 100644
--- a/intern/cycles/graph/node.cpp
+++ b/intern/cycles/graph/node.cpp
@@ -496,4 +496,3 @@ void Node::hash(MD5Hash& md5)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/graph/node.h b/intern/cycles/graph/node.h
index d198c38be32..a738bfe197e 100644
--- a/intern/cycles/graph/node.h
+++ b/intern/cycles/graph/node.h
@@ -97,4 +97,3 @@ struct Node
};
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/graph/node_enum.h b/intern/cycles/graph/node_enum.h
index 4e40c294f4f..9de776ddb55 100644
--- a/intern/cycles/graph/node_enum.h
+++ b/intern/cycles/graph/node_enum.h
@@ -45,4 +45,3 @@ private:
};
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/graph/node_type.cpp b/intern/cycles/graph/node_type.cpp
index 37aae211e93..671ae2d815a 100644
--- a/intern/cycles/graph/node_type.cpp
+++ b/intern/cycles/graph/node_type.cpp
@@ -217,4 +217,3 @@ const NodeType *NodeType::find(ustring name)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h
index 15d34a79bb8..d4e2dbceff6 100644
--- a/intern/cycles/graph/node_type.h
+++ b/intern/cycles/graph/node_type.h
@@ -263,4 +263,3 @@ const NodeType *structname::register_type()
{ type->register_output(ustring(#name), ustring(ui_name), SocketType::ENUM); }
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/graph/node_xml.cpp b/intern/cycles/graph/node_xml.cpp
index f4599e22d40..b7a28b427e5 100644
--- a/intern/cycles/graph/node_xml.cpp
+++ b/intern/cycles/graph/node_xml.cpp
@@ -458,4 +458,3 @@ xml_node xml_write_node(Node *node, xml_node xml_root)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/graph/node_xml.h b/intern/cycles/graph/node_xml.h
index b648c9666c1..5fecf40f96c 100644
--- a/intern/cycles/graph/node_xml.h
+++ b/intern/cycles/graph/node_xml.h
@@ -32,4 +32,3 @@ void xml_read_node(XMLReader& reader, Node *node, xml_node xml_node);
xml_node xml_write_node(Node *node, xml_node xml_root);
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 95cdefdd94b..c4cad17429d 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -156,6 +156,7 @@ set(SRC_CLOSURE_HEADERS
closure/volume.h
closure/bsdf_principled_diffuse.h
closure/bsdf_principled_sheen.h
+ closure/bsdf_hair_principled.h
)
set(SRC_SVM_HEADERS
@@ -287,6 +288,7 @@ set(SRC_UTIL_HEADERS
../util/util_types_uint3_impl.h
../util/util_types_uint4.h
../util/util_types_uint4_impl.h
+ ../util/util_types_ushort4.h
../util/util_types_vector3.h
../util/util_types_vector3_impl.h
)
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h
index c1b02cd4be1..3a9629ea9d7 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -27,6 +27,7 @@
#include "kernel/closure/bsdf_ashikhmin_shirley.h"
#include "kernel/closure/bsdf_toon.h"
#include "kernel/closure/bsdf_hair.h"
+#include "kernel/closure/bsdf_hair_principled.h"
#include "kernel/closure/bsdf_principled_diffuse.h"
#include "kernel/closure/bsdf_principled_sheen.h"
#include "kernel/closure/bssrdf.h"
@@ -171,6 +172,10 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
label = bsdf_hair_transmission_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
break;
+ case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
+ label = bsdf_principled_hair_sample(kg, sc, sd, randu, randv,
+ eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
+ break;
#ifdef __PRINCIPLED__
case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID:
@@ -284,6 +289,9 @@ float3 bsdf_eval(KernelGlobals *kg,
case CLOSURE_BSDF_GLOSSY_TOON_ID:
eval = bsdf_glossy_toon_eval_reflect(sc, sd->I, omega_in, pdf);
break;
+ case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
+ eval = bsdf_principled_hair_eval(kg, sd, sc, omega_in, pdf);
+ break;
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
eval = bsdf_hair_reflection_eval_reflect(sc, sd->I, omega_in, pdf);
break;
@@ -366,6 +374,9 @@ float3 bsdf_eval(KernelGlobals *kg,
case CLOSURE_BSDF_GLOSSY_TOON_ID:
eval = bsdf_glossy_toon_eval_transmit(sc, sd->I, omega_in, pdf);
break;
+ case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
+ eval = bsdf_principled_hair_eval(kg, sd, sc, omega_in, pdf);
+ break;
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
eval = bsdf_hair_reflection_eval_transmit(sc, sd->I, omega_in, pdf);
break;
@@ -424,6 +435,9 @@ ccl_device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness)
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
bsdf_ashikhmin_shirley_blur(sc, roughness);
break;
+ case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
+ bsdf_principled_hair_blur(sc, roughness);
+ break;
default:
break;
}
@@ -486,4 +500,3 @@ ccl_device bool bsdf_merge(ShaderClosure *a, ShaderClosure *b)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
index b6c896c754b..ff238b7a834 100644
--- a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
+++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
@@ -117,7 +117,7 @@ ccl_device_forceinline float3 bsdf_ashikhmin_shirley_eval_reflect(
lobe = 1.0f;
}
float norm = sqrtf((n_x + 1.0f)*(n_y + 1.0f)) / (8.0f * M_PI_F);
-
+
out = NdotO * norm * lobe * pump;
*pdf = norm * lobe / HdotI;
}
diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
index a5ba2cb2972..b0bdea723b9 100644
--- a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
+++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -46,7 +46,7 @@ ccl_device int bsdf_ashikhmin_velvet_setup(VelvetBsdf *bsdf)
{
float sigma = fmaxf(bsdf->sigma, 0.01f);
bsdf->invsigma2 = 1.0f/(sigma * sigma);
-
+
bsdf->type = CLOSURE_BSDF_ASHIKHMIN_VELVET_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL;
@@ -159,4 +159,3 @@ ccl_device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc, float3 Ng,
CCL_NAMESPACE_END
#endif /* __BSDF_ASHIKHMIN_VELVET_H__ */
-
diff --git a/intern/cycles/kernel/closure/bsdf_diffuse.h b/intern/cycles/kernel/closure/bsdf_diffuse.h
index ec6f1f20996..ee6d4cdf2df 100644
--- a/intern/cycles/kernel/closure/bsdf_diffuse.h
+++ b/intern/cycles/kernel/closure/bsdf_diffuse.h
@@ -88,7 +88,7 @@ ccl_device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I,
}
else
*pdf = 0.0f;
-
+
return LABEL_REFLECT|LABEL_DIFFUSE;
}
@@ -140,4 +140,3 @@ ccl_device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float
CCL_NAMESPACE_END
#endif /* __BSDF_DIFFUSE_H__ */
-
diff --git a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
index 24f40af46a3..35bb2fdf0e8 100644
--- a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
+++ b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
@@ -46,7 +46,7 @@ typedef ccl_addr_space struct DiffuseRampBsdf {
ccl_device float3 bsdf_diffuse_ramp_get_color(const float3 colors[8], float pos)
{
int MAXCOLORS = 8;
-
+
float npos = pos * (float)(MAXCOLORS - 1);
int ipos = float_to_int(npos);
if(ipos < 0)
@@ -99,7 +99,7 @@ ccl_device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc, float3 Ng, floa
}
else
*pdf = 0.0f;
-
+
return LABEL_REFLECT|LABEL_DIFFUSE;
}
diff --git a/intern/cycles/kernel/closure/bsdf_hair.h b/intern/cycles/kernel/closure/bsdf_hair.h
index daaa26dc6ad..7b44a23f05b 100644
--- a/intern/cycles/kernel/closure/bsdf_hair.h
+++ b/intern/cycles/kernel/closure/bsdf_hair.h
@@ -278,4 +278,3 @@ ccl_device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng,
CCL_NAMESPACE_END
#endif /* __BSDF_HAIR_H__ */
-
diff --git a/intern/cycles/kernel/closure/bsdf_hair_principled.h b/intern/cycles/kernel/closure/bsdf_hair_principled.h
new file mode 100644
index 00000000000..4ee58089384
--- /dev/null
+++ b/intern/cycles/kernel/closure/bsdf_hair_principled.h
@@ -0,0 +1,502 @@
+/*
+ * Copyright 2018 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.
+ */
+
+#ifdef __KERNEL_CPU__
+#include <fenv.h>
+#endif
+
+#include "kernel/kernel_color.h"
+
+#ifndef __BSDF_HAIR_PRINCIPLED_H__
+#define __BSDF_HAIR_PRINCIPLED_H__
+
+CCL_NAMESPACE_BEGIN
+
+typedef ccl_addr_space struct PrincipledHairExtra {
+ /* Geometry data. */
+ float4 geom;
+} PrincipledHairExtra;
+
+typedef ccl_addr_space struct PrincipledHairBSDF {
+ SHADER_CLOSURE_BASE;
+
+ /* Absorption coefficient. */
+ float3 sigma;
+ /* Variance of the underlying logistic distribution. */
+ float v;
+ /* Scale factor of the underlying logistic distribution. */
+ float s;
+ /* Cuticle tilt angle. */
+ float alpha;
+ /* IOR. */
+ float eta;
+ /* Effective variance for the diffuse bounce only. */
+ float m0_roughness;
+
+ /* Extra closure. */
+ PrincipledHairExtra *extra;
+} PrincipledHairBSDF;
+
+static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledHairBSDF), "PrincipledHairBSDF is too large!");
+static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledHairExtra), "PrincipledHairExtra is too large!");
+
+ccl_device_inline float cos_from_sin(const float s)
+{
+ return safe_sqrtf(1.0f - s*s);
+}
+
+/* Gives the change in direction in the normal plane for the given angles and p-th-order scattering. */
+ccl_device_inline float delta_phi(int p, float gamma_o, float gamma_t)
+{
+ return 2.0f * p * gamma_t - 2.0f * gamma_o + p * M_PI_F;
+}
+
+/* Remaps the given angle to [-pi, pi]. */
+ccl_device_inline float wrap_angle(float a)
+{
+ while(a > M_PI_F) {
+ a -= M_2PI_F;
+ }
+ while(a < -M_PI_F) {
+ a += M_2PI_F;
+ }
+ return a;
+}
+
+/* Logistic distribution function. */
+ccl_device_inline float logistic(float x, float s)
+{
+ float v = expf(-fabsf(x)/s);
+ return v / (s * sqr(1.0f + v));
+}
+
+/* Logistic cumulative density function. */
+ccl_device_inline float logistic_cdf(float x, float s)
+{
+ float arg = -x/s;
+ /* expf() overflows if arg >= 89.0. */
+ if(arg > 88.0f) {
+ return 0.0f;
+ }
+ else {
+ return 1.0f / (1.0f + expf(arg));
+ }
+}
+
+/* Numerical approximation to the Bessel function of the first kind. */
+ccl_device_inline float bessel_I0(float x)
+{
+ x = sqr(x);
+ float val = 1.0f + 0.25f*x;
+ float pow_x_2i = sqr(x);
+ uint64_t i_fac_2 = 1;
+ int pow_4_i = 16;
+ for(int i = 2; i < 10; i++) {
+ i_fac_2 *= i*i;
+ float newval = val + pow_x_2i / (pow_4_i * i_fac_2);
+ if(val == newval) {
+ return val;
+ }
+ val = newval;
+ pow_x_2i *= x;
+ pow_4_i *= 4;
+ }
+ return val;
+}
+
+/* Logarithm of the Bessel function of the first kind. */
+ccl_device_inline float log_bessel_I0(float x)
+{
+ if (x > 12.0f) {
+ /* log(1/x) == -log(x) iff x > 0.
+ * This is only used with positive cosines */
+ return x + 0.5f * (1.f / (8.0f * x) - M_LN_2PI_F - logf(x));
+ }
+ else {
+ return logf(bessel_I0(x));
+ }
+}
+
+/* Logistic distribution limited to the interval [-pi, pi]. */
+ccl_device_inline float trimmed_logistic(float x, float s)
+{
+ /* The logistic distribution is symmetric and centered around zero,
+ * so logistic_cdf(x, s) = 1 - logistic_cdf(-x, s).
+ * Therefore, logistic_cdf(x, s)-logistic_cdf(-x, s) = 1 - 2*logistic_cdf(-x, s) */
+ float scaling_fac = 1.0f - 2.0f*logistic_cdf(-M_PI_F, s);
+ float val = logistic(x, s);
+ return safe_divide(val, scaling_fac);
+}
+
+/* Sampling function for the trimmed logistic function. */
+ccl_device_inline float sample_trimmed_logistic(float u, float s)
+{
+ float cdf_minuspi = logistic_cdf(-M_PI_F, s);
+ float x = -s*logf(1.0f / (u*(1.0f - 2.0f*cdf_minuspi) + cdf_minuspi) - 1.0f);
+ return clamp(x, -M_PI_F, M_PI_F);
+}
+
+/* Azimuthal scattering function Np. */
+ccl_device_inline float azimuthal_scattering(float phi,
+ int p,
+ float s,
+ float gamma_o,
+ float gamma_t)
+{
+ float phi_o = wrap_angle(phi - delta_phi(p, gamma_o, gamma_t));
+ float val = trimmed_logistic(phi_o, s);
+ return val;
+}
+
+/* Longitudinal scattering function Mp. */
+ccl_device_inline float longitudinal_scattering(float sin_theta_i,
+ float cos_theta_i,
+ float sin_theta_o,
+ float cos_theta_o,
+ float v)
+{
+ float inv_v = 1.0f/v;
+ float cos_arg = cos_theta_i * cos_theta_o * inv_v;
+ float sin_arg = sin_theta_i * sin_theta_o * inv_v;
+ if(v <= 0.1f) {
+ float i0 = log_bessel_I0(cos_arg);
+ float val = expf(i0 - sin_arg - inv_v + 0.6931f + logf(0.5f*inv_v));
+ return val;
+ }
+ else {
+ float i0 = bessel_I0(cos_arg);
+ float val = (expf(-sin_arg) * i0) / (sinhf(inv_v) * 2.0f * v);
+ return val;
+ }
+}
+
+/* Combine the three values using their luminances. */
+ccl_device_inline float4 combine_with_energy(KernelGlobals *kg, float3 c)
+{
+ return make_float4(c.x, c.y, c.z, linear_rgb_to_gray(kg, c));
+}
+
+#ifdef __HAIR__
+/* Set up the hair closure. */
+ccl_device int bsdf_principled_hair_setup(ShaderData *sd, PrincipledHairBSDF *bsdf)
+{
+ bsdf->type = CLOSURE_BSDF_HAIR_PRINCIPLED_ID;
+ bsdf->v = clamp(bsdf->v, 0.001f, 1.0f);
+ bsdf->s = clamp(bsdf->s, 0.001f, 1.0f);
+ /* Apply Primary Reflection Roughness modifier. */
+ bsdf->m0_roughness = clamp(bsdf->m0_roughness*bsdf->v, 0.001f, 1.0f);
+
+ /* Map from roughness_u and roughness_v to variance and scale factor. */
+ bsdf->v = sqr(0.726f*bsdf->v + 0.812f*sqr(bsdf->v) + 3.700f*pow20(bsdf->v));
+ bsdf->s = (0.265f*bsdf->s + 1.194f*sqr(bsdf->s) + 5.372f*pow22(bsdf->s))*M_SQRT_PI_8_F;
+ bsdf->m0_roughness = sqr(0.726f*bsdf->m0_roughness + 0.812f*sqr(bsdf->m0_roughness) + 3.700f*pow20(bsdf->m0_roughness));
+
+ /* Compute local frame, aligned to curve tangent and ray direction. */
+ float3 X = safe_normalize(sd->dPdu);
+ float3 Y = safe_normalize(cross(X, sd->I));
+ float3 Z = safe_normalize(cross(X, Y));
+ /* TODO: the solution below works where sd->Ng is the normal
+ * pointing from the center of the curve to the shading point.
+ * It doesn't work for triangles, see https://developer.blender.org/T43625 */
+
+ /* h -1..0..1 means the rays goes from grazing the hair, to hitting it at
+ * the center, to grazing the other edge. This is the sine of the angle
+ * between sd->Ng and Z, as seen from the tangent X. */
+
+ /* TODO: we convert this value to a cosine later and discard the sign, so
+ * we could probably save some operations. */
+ float h = dot(cross(sd->Ng, X), Z);
+
+ kernel_assert(fabsf(h) < 1.0f + 1e-4f);
+ kernel_assert(isfinite3_safe(Y));
+ kernel_assert(isfinite_safe(h));
+
+ bsdf->extra->geom = make_float4(Y.x, Y.y, Y.z, h);
+
+ return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_NEEDS_LCG;
+}
+
+#endif /* __HAIR__ */
+
+/* Given the Fresnel term and transmittance, generate the attenuation terms for each bounce. */
+ccl_device_inline void hair_attenuation(KernelGlobals *kg,
+ float f,
+ float3 T,
+ float4 *Ap)
+{
+ /* Primary specular (R). */
+ Ap[0] = make_float4(f, f, f, f);
+
+ /* Transmission (TT). */
+ float3 col = sqr(1.0f - f) * T;
+ Ap[1] = combine_with_energy(kg, col);
+
+ /* Secondary specular (TRT). */
+ col *= T*f;
+ Ap[2] = combine_with_energy(kg, col);
+
+ /* Residual component (TRRT+). */
+ col *= safe_divide_color(T*f, make_float3(1.0f, 1.0f, 1.0f) - T*f);
+ Ap[3] = combine_with_energy(kg, col);
+
+ /* Normalize sampling weights. */
+ float totweight = Ap[0].w + Ap[1].w + Ap[2].w + Ap[3].w;
+ float fac = safe_divide(1.0f, totweight);
+
+ Ap[0].w *= fac;
+ Ap[1].w *= fac;
+ Ap[2].w *= fac;
+ Ap[3].w *= fac;
+}
+
+/* Given the tilt angle, generate the rotated theta_i for the different bounces. */
+ccl_device_inline void hair_alpha_angles(float sin_theta_i,
+ float cos_theta_i,
+ float alpha,
+ float *angles)
+{
+ float sin_1alpha = sinf(alpha);
+ float cos_1alpha = cos_from_sin(sin_1alpha);
+ float sin_2alpha = 2.0f*sin_1alpha*cos_1alpha;
+ float cos_2alpha = sqr(cos_1alpha) - sqr(sin_1alpha);
+ float sin_4alpha = 2.0f*sin_2alpha*cos_2alpha;
+ float cos_4alpha = sqr(cos_2alpha) - sqr(sin_2alpha);
+
+ angles[0] = sin_theta_i*cos_2alpha + cos_theta_i*sin_2alpha;
+ angles[1] = fabsf(cos_theta_i*cos_2alpha - sin_theta_i*sin_2alpha);
+ angles[2] = sin_theta_i*cos_1alpha - cos_theta_i*sin_1alpha;
+ angles[3] = fabsf(cos_theta_i*cos_1alpha + sin_theta_i*sin_1alpha);
+ angles[4] = sin_theta_i*cos_4alpha - cos_theta_i*sin_4alpha;
+ angles[5] = fabsf(cos_theta_i*cos_4alpha + sin_theta_i*sin_4alpha);
+}
+
+/* Evaluation function for our shader. */
+ccl_device float3 bsdf_principled_hair_eval(KernelGlobals *kg,
+ const ShaderData *sd,
+ const ShaderClosure *sc,
+ const float3 omega_in,
+ float *pdf)
+{
+ kernel_assert(isfinite3_safe(sd->P) && isfinite_safe(sd->ray_length));
+
+ const PrincipledHairBSDF *bsdf = (const PrincipledHairBSDF*) sc;
+ float3 Y = float4_to_float3(bsdf->extra->geom);
+
+ float3 X = safe_normalize(sd->dPdu);
+ kernel_assert(fabsf(dot(X, Y)) < 1e-4f);
+ float3 Z = safe_normalize(cross(X, Y));
+
+ float3 wo = make_float3(dot(sd->I, X), dot(sd->I, Y), dot(sd->I, Z));
+ float3 wi = make_float3(dot(omega_in, X), dot(omega_in, Y), dot(omega_in, Z));
+
+ float sin_theta_o = wo.x;
+ float cos_theta_o = cos_from_sin(sin_theta_o);
+ float phi_o = atan2f(wo.z, wo.y);
+
+ float sin_theta_t = sin_theta_o / bsdf->eta;
+ float cos_theta_t = cos_from_sin(sin_theta_t);
+
+ float sin_gamma_o = bsdf->extra->geom.w;
+ float cos_gamma_o = cos_from_sin(sin_gamma_o);
+ float gamma_o = safe_asinf(sin_gamma_o);
+
+ float sin_gamma_t = sin_gamma_o * cos_theta_o / sqrtf(sqr(bsdf->eta) - sqr(sin_theta_o));
+ float cos_gamma_t = cos_from_sin(sin_gamma_t);
+ float gamma_t = safe_asinf(sin_gamma_t);
+
+ float3 T = exp3(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t));
+ float4 Ap[4];
+ hair_attenuation(kg, fresnel_dielectric_cos(cos_theta_o * cos_gamma_o, bsdf->eta), T, Ap);
+
+ float sin_theta_i = wi.x;
+ float cos_theta_i = cos_from_sin(sin_theta_i);
+ float phi_i = atan2f(wi.z, wi.y);
+
+ float phi = phi_i - phi_o;
+
+ float angles[6];
+ hair_alpha_angles(sin_theta_i, cos_theta_i, bsdf->alpha, angles);
+
+ float4 F;
+ float Mp, Np;
+
+ /* Primary specular (R). */
+ Mp = longitudinal_scattering(angles[0], angles[1], sin_theta_o, cos_theta_o, bsdf->m0_roughness);
+ Np = azimuthal_scattering(phi, 0, bsdf->s, gamma_o, gamma_t);
+ F = Ap[0] * Mp * Np;
+ kernel_assert(isfinite3_safe(float4_to_float3(F)));
+
+ /* Transmission (TT). */
+ Mp = longitudinal_scattering(angles[2], angles[3], sin_theta_o, cos_theta_o, 0.25f*bsdf->v);
+ Np = azimuthal_scattering(phi, 1, bsdf->s, gamma_o, gamma_t);
+ F += Ap[1] * Mp * Np;
+ kernel_assert(isfinite3_safe(float4_to_float3(F)));
+
+ /* Secondary specular (TRT). */
+ Mp = longitudinal_scattering(angles[4], angles[5], sin_theta_o, cos_theta_o, 4.0f*bsdf->v);
+ Np = azimuthal_scattering(phi, 2, bsdf->s, gamma_o, gamma_t);
+ F += Ap[2] * Mp * Np;
+ kernel_assert(isfinite3_safe(float4_to_float3(F)));
+
+ /* Residual component (TRRT+). */
+ Mp = longitudinal_scattering(sin_theta_i, cos_theta_i, sin_theta_o, cos_theta_o, 4.0f*bsdf->v);
+ Np = M_1_2PI_F;
+ F += Ap[3] * Mp * Np;
+ kernel_assert(isfinite3_safe(float4_to_float3(F)));
+
+ *pdf = F.w;
+ return float4_to_float3(F);
+}
+
+/* Sampling function for the hair shader. */
+ccl_device int bsdf_principled_hair_sample(KernelGlobals *kg,
+ const ShaderClosure *sc,
+ ShaderData *sd,
+ float randu,
+ float randv,
+ float3 *eval,
+ float3 *omega_in,
+ float3 *domega_in_dx,
+ float3 *domega_in_dy,
+ float *pdf)
+{
+ PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*) sc;
+
+ float3 Y = float4_to_float3(bsdf->extra->geom);
+
+ float3 X = safe_normalize(sd->dPdu);
+ kernel_assert(fabsf(dot(X, Y)) < 1e-4f);
+ float3 Z = safe_normalize(cross(X, Y));
+
+ float3 wo = make_float3(dot(sd->I, X), dot(sd->I, Y), dot(sd->I, Z));
+
+ float2 u[2];
+ u[0] = make_float2(randu, randv);
+ u[1].x = lcg_step_float_addrspace(&sd->lcg_state);
+ u[1].y = lcg_step_float_addrspace(&sd->lcg_state);
+
+ float sin_theta_o = wo.x;
+ float cos_theta_o = cos_from_sin(sin_theta_o);
+ float phi_o = atan2f(wo.z, wo.y);
+
+ float sin_theta_t = sin_theta_o / bsdf->eta;
+ float cos_theta_t = cos_from_sin(sin_theta_t);
+
+ float sin_gamma_o = bsdf->extra->geom.w;
+ float cos_gamma_o = cos_from_sin(sin_gamma_o);
+ float gamma_o = safe_asinf(sin_gamma_o);
+
+ float sin_gamma_t = sin_gamma_o * cos_theta_o / sqrtf(sqr(bsdf->eta) - sqr(sin_theta_o));
+ float cos_gamma_t = cos_from_sin(sin_gamma_t);
+ float gamma_t = safe_asinf(sin_gamma_t);
+
+ float3 T = exp3(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t));
+ float4 Ap[4];
+ hair_attenuation(kg, fresnel_dielectric_cos(cos_theta_o * cos_gamma_o, bsdf->eta), T, Ap);
+
+ int p = 0;
+ for(; p < 3; p++) {
+ if(u[0].x < Ap[p].w) {
+ break;
+ }
+ u[0].x -= Ap[p].w;
+ }
+
+ float v = bsdf->v;
+ if(p == 1) {
+ v *= 0.25f;
+ }
+ if(p >= 2) {
+ v *= 4.0f;
+ }
+
+ u[1].x = max(u[1].x, 1e-5f);
+ float fac = 1.0f + v*logf(u[1].x + (1.0f - u[1].x)*expf(-2.0f/v));
+ float sin_theta_i = -fac * sin_theta_o + cos_from_sin(fac) * cosf(M_2PI_F * u[1].y) * cos_theta_o;
+ float cos_theta_i = cos_from_sin(sin_theta_i);
+
+ float angles[6];
+ if(p < 3) {
+ hair_alpha_angles(sin_theta_i, cos_theta_i, -bsdf->alpha, angles);
+ sin_theta_i = angles[2*p];
+ cos_theta_i = angles[2*p+1];
+ }
+
+ float phi;
+ if(p < 3) {
+ phi = delta_phi(p, gamma_o, gamma_t) + sample_trimmed_logistic(u[0].y, bsdf->s);
+ }
+ else {
+ phi = M_2PI_F*u[0].y;
+ }
+ float phi_i = phi_o + phi;
+
+ hair_alpha_angles(sin_theta_i, cos_theta_i, bsdf->alpha, angles);
+
+ float4 F;
+ float Mp, Np;
+
+ /* Primary specular (R). */
+ Mp = longitudinal_scattering(angles[0], angles[1], sin_theta_o, cos_theta_o, bsdf->m0_roughness);
+ Np = azimuthal_scattering(phi, 0, bsdf->s, gamma_o, gamma_t);
+ F = Ap[0] * Mp * Np;
+ kernel_assert(isfinite3_safe(float4_to_float3(F)));
+
+ /* Transmission (TT). */
+ Mp = longitudinal_scattering(angles[2], angles[3], sin_theta_o, cos_theta_o, 0.25f*bsdf->v);
+ Np = azimuthal_scattering(phi, 1, bsdf->s, gamma_o, gamma_t);
+ F += Ap[1] * Mp * Np;
+ kernel_assert(isfinite3_safe(float4_to_float3(F)));
+
+ /* Secondary specular (TRT). */
+ Mp = longitudinal_scattering(angles[4], angles[5], sin_theta_o, cos_theta_o, 4.0f*bsdf->v);
+ Np = azimuthal_scattering(phi, 2, bsdf->s, gamma_o, gamma_t);
+ F += Ap[2] * Mp * Np;
+ kernel_assert(isfinite3_safe(float4_to_float3(F)));
+
+ /* Residual component (TRRT+). */
+ Mp = longitudinal_scattering(sin_theta_i, cos_theta_i, sin_theta_o, cos_theta_o, 4.0f*bsdf->v);
+ Np = M_1_2PI_F;
+ F += Ap[3] * Mp * Np;
+ kernel_assert(isfinite3_safe(float4_to_float3(F)));
+
+ *eval = float4_to_float3(F);
+ *pdf = F.w;
+
+ *omega_in = X*sin_theta_i + Y*cos_theta_i*cosf(phi_i) + Z*cos_theta_i*sinf(phi_i);
+
+#ifdef __RAY_DIFFERENTIALS__
+ float3 N = safe_normalize(sd->I + *omega_in);
+ *domega_in_dx = (2 * dot(N, sd->dI.dx)) * N - sd->dI.dx;
+ *domega_in_dy = (2 * dot(N, sd->dI.dy)) * N - sd->dI.dy;
+#endif
+
+ return LABEL_GLOSSY|((p == 0)? LABEL_REFLECT : LABEL_TRANSMIT);
+}
+
+/* Implements Filter Glossy by capping the effective roughness. */
+ccl_device void bsdf_principled_hair_blur(ShaderClosure *sc, float roughness)
+{
+ PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)sc;
+
+ bsdf->v = fmaxf(roughness, bsdf->v);
+ bsdf->s = fmaxf(roughness, bsdf->s);
+ bsdf->m0_roughness = fmaxf(roughness, bsdf->m0_roughness);
+}
+
+CCL_NAMESPACE_END
+
+#endif /* __BSDF_HAIR_PRINCIPLED_H__ */
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index 2dd59354058..e74d5ebaa42 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -231,7 +231,7 @@ ccl_device_forceinline float3 microfacet_sample_stretched(
/* 5. compute normal */
return normalize(make_float3(-slope_x, -slope_y, 1.0f));
-}
+}
/* Calculate the reflection color
*
@@ -434,7 +434,7 @@ ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, cons
/* eq. 34: now calculate G1(i,m) and G1(o,m) */
G1o = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNO * cosNO) / (cosNO * cosNO)));
- G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
+ G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
}
else {
/* anisotropic */
@@ -535,7 +535,7 @@ ccl_device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, con
/* eq. 34: now calculate G1(i,m) and G1(o,m) */
G1o = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNO * cosNO) / (cosNO * cosNO)));
- G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
+ G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
float G = G1o * G1i;
@@ -706,7 +706,7 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure
dIdx, dIdy, &dRdx, &dRdy, &dTdx, &dTdy,
#endif
&inside);
-
+
if(!inside && fresnel != 1.0f) {
*omega_in = T;
@@ -733,7 +733,7 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure
float cosNI = dot(N, *omega_in);
/* eq. 34: now calculate G1(i,m) */
- float G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
+ float G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
/* eq. 21 */
float cosHI = dot(m, *omega_in);
@@ -1125,4 +1125,3 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg, const ShaderCl
CCL_NAMESPACE_END
#endif /* __BSDF_MICROFACET_H__ */
-
diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
index 420f94755ee..91c7803346d 100644
--- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h
+++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
@@ -47,7 +47,7 @@ typedef ccl_addr_space struct PhongRampBsdf {
ccl_device float3 bsdf_phong_ramp_get_color(const float3 colors[8], float pos)
{
int MAXCOLORS = 8;
-
+
float npos = pos * (float)(MAXCOLORS - 1);
int ipos = float_to_int(npos);
if(ipos < 0)
@@ -71,7 +71,7 @@ ccl_device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const fl
float m_exponent = bsdf->exponent;
float cosNI = dot(bsdf->N, omega_in);
float cosNO = dot(bsdf->N, I);
-
+
if(cosNI > 0 && cosNO > 0) {
// reflect the view vector
float3 R = (2 * cosNO) * bsdf->N - I;
@@ -84,7 +84,7 @@ ccl_device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const fl
return bsdf_phong_ramp_get_color(bsdf->colors, cosp) * out;
}
}
-
+
return make_float3(0.0f, 0.0f, 0.0f);
}
@@ -98,7 +98,7 @@ ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, float3 Ng, float3
const PhongRampBsdf *bsdf = (const PhongRampBsdf*)sc;
float cosNO = dot(bsdf->N, I);
float m_exponent = bsdf->exponent;
-
+
if(cosNO > 0) {
// reflect the view vector
float3 R = (2 * cosNO) * bsdf->N - I;
@@ -107,7 +107,7 @@ ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, float3 Ng, float3
*domega_in_dx = (2 * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
*domega_in_dy = (2 * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
#endif
-
+
float3 T, B;
make_orthonormals (R, &T, &B);
float phi = M_2PI_F * randu;
diff --git a/intern/cycles/kernel/closure/bsdf_principled_diffuse.h b/intern/cycles/kernel/closure/bsdf_principled_diffuse.h
index f8ca64293b0..83be2b35a00 100644
--- a/intern/cycles/kernel/closure/bsdf_principled_diffuse.h
+++ b/intern/cycles/kernel/closure/bsdf_principled_diffuse.h
@@ -123,5 +123,3 @@ ccl_device int bsdf_principled_diffuse_sample(const ShaderClosure *sc,
CCL_NAMESPACE_END
#endif /* __BSDF_PRINCIPLED_DIFFUSE_H__ */
-
-
diff --git a/intern/cycles/kernel/closure/bsdf_principled_sheen.h b/intern/cycles/kernel/closure/bsdf_principled_sheen.h
index f4476bfecd0..8b7c4399516 100644
--- a/intern/cycles/kernel/closure/bsdf_principled_sheen.h
+++ b/intern/cycles/kernel/closure/bsdf_principled_sheen.h
@@ -109,5 +109,3 @@ ccl_device int bsdf_principled_sheen_sample(const ShaderClosure *sc,
CCL_NAMESPACE_END
#endif /* __BSDF_PRINCIPLED_SHEEN_H__ */
-
-
diff --git a/intern/cycles/kernel/closure/bsdf_reflection.h b/intern/cycles/kernel/closure/bsdf_reflection.h
index 1d21614ecee..b33b6e3597b 100644
--- a/intern/cycles/kernel/closure/bsdf_reflection.h
+++ b/intern/cycles/kernel/closure/bsdf_reflection.h
@@ -78,4 +78,3 @@ ccl_device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3
CCL_NAMESPACE_END
#endif /* __BSDF_REFLECTION_H__ */
-
diff --git a/intern/cycles/kernel/closure/bsdf_refraction.h b/intern/cycles/kernel/closure/bsdf_refraction.h
index 050a4e76fa9..b181650e928 100644
--- a/intern/cycles/kernel/closure/bsdf_refraction.h
+++ b/intern/cycles/kernel/closure/bsdf_refraction.h
@@ -87,4 +87,3 @@ ccl_device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3
CCL_NAMESPACE_END
#endif /* __BSDF_REFRACTION_H__ */
-
diff --git a/intern/cycles/kernel/closure/bsdf_toon.h b/intern/cycles/kernel/closure/bsdf_toon.h
index d8b6d8ddead..6d8074b7130 100644
--- a/intern/cycles/kernel/closure/bsdf_toon.h
+++ b/intern/cycles/kernel/closure/bsdf_toon.h
@@ -73,7 +73,7 @@ ccl_device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float a
is = (1.0f - (angle - max_angle)/smooth);
else
is = 0.0f;
-
+
return make_float3(is, is, is);
}
@@ -90,7 +90,7 @@ ccl_device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const
float angle = safe_acosf(fmaxf(dot(bsdf->N, omega_in), 0.0f));
float3 eval = bsdf_toon_get_intensity(max_angle, smooth, angle);
-
+
if(eval.x > 0.0f) {
float sample_angle = bsdf_toon_get_sample_angle(max_angle, smooth);
@@ -152,7 +152,7 @@ ccl_device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const f
float smooth = bsdf->smooth*M_PI_2_F;
float cosNI = dot(bsdf->N, omega_in);
float cosNO = dot(bsdf->N, I);
-
+
if(cosNI > 0 && cosNO > 0) {
/* reflect the view vector */
float3 R = (2 * cosNO) * bsdf->N - I;
@@ -166,7 +166,7 @@ ccl_device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const f
*pdf = 0.5f * M_1_PI_F / (1.0f - cosf(sample_angle));
return *pdf * eval;
}
-
+
return make_float3(0.0f, 0.0f, 0.0f);
}
@@ -181,7 +181,7 @@ ccl_device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float
float max_angle = bsdf->size*M_PI_2_F;
float smooth = bsdf->smooth*M_PI_2_F;
float cosNO = dot(bsdf->N, I);
-
+
if(cosNO > 0) {
/* reflect the view vector */
float3 R = (2 * cosNO) * bsdf->N - I;
@@ -216,4 +216,3 @@ ccl_device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float
CCL_NAMESPACE_END
#endif /* __BSDF_TOON_H__ */
-
diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h
index 8fc7ef4dd4f..f788dbcd0ff 100644
--- a/intern/cycles/kernel/closure/bsdf_transparent.h
+++ b/intern/cycles/kernel/closure/bsdf_transparent.h
@@ -107,4 +107,3 @@ ccl_device int bsdf_transparent_sample(const ShaderClosure *sc, float3 Ng, float
CCL_NAMESPACE_END
#endif /* __BSDF_TRANSPARENT_H__ */
-
diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h
index 3dc15d5791c..b080e025d16 100644
--- a/intern/cycles/kernel/closure/bsdf_util.h
+++ b/intern/cycles/kernel/closure/bsdf_util.h
@@ -62,14 +62,14 @@ ccl_device float fresnel_dielectric(
Nn = -N;
*is_inside = true;
}
-
+
// compute reflection
*R = (2 * cos)* Nn - I;
#ifdef __RAY_DIFFERENTIALS__
*dRdx = (2 * dot(Nn, dIdx)) * Nn - dIdx;
*dRdy = (2 * dot(Nn, dIdy)) * Nn - dIdy;
#endif
-
+
float arg = 1 -(neta * neta *(1 -(cos * cos)));
if(arg < 0) {
*T = make_float3(0.0f, 0.0f, 0.0f);
@@ -159,4 +159,3 @@ ccl_device_forceinline float3 interpolate_fresnel_color(float3 L, float3 H, floa
CCL_NAMESPACE_END
#endif /* __BSDF_UTIL_H__ */
-
diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h
index 8578767b07e..ba0c6ae8c61 100644
--- a/intern/cycles/kernel/closure/bssrdf.h
+++ b/intern/cycles/kernel/closure/bssrdf.h
@@ -500,4 +500,3 @@ ccl_device_forceinline float bssrdf_pdf(const ShaderClosure *sc, float r)
CCL_NAMESPACE_END
#endif /* __KERNEL_BSSRDF_H__ */
-
diff --git a/intern/cycles/kernel/closure/emissive.h b/intern/cycles/kernel/closure/emissive.h
index e709ca9a372..a7f4a2a7327 100644
--- a/intern/cycles/kernel/closure/emissive.h
+++ b/intern/cycles/kernel/closure/emissive.h
@@ -76,9 +76,8 @@ ccl_device void emissive_sample(const float3 Ng, float randu, float randv,
ccl_device float3 emissive_simple_eval(const float3 Ng, const float3 I)
{
float res = emissive_pdf(Ng, I);
-
+
return make_float3(res, res, res);
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/closure/volume.h b/intern/cycles/kernel/closure/volume.h
index da791e9aa73..872d06c936a 100644
--- a/intern/cycles/kernel/closure/volume.h
+++ b/intern/cycles/kernel/closure/volume.h
@@ -51,7 +51,7 @@ ccl_device float single_peaked_henyey_greenstein(float cos_theta, float g)
ccl_device int volume_henyey_greenstein_setup(HenyeyGreensteinVolume *volume)
{
volume->type = CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID;
-
+
/* clamp anisotropy to avoid delta function */
volume->g = signf(volume->g) * min(fabsf(volume->g), 1.0f - 1e-3f);
diff --git a/intern/cycles/kernel/filter/filter_defines.h b/intern/cycles/kernel/filter/filter_defines.h
index ce96f733aff..1a2f22a6987 100644
--- a/intern/cycles/kernel/filter/filter_defines.h
+++ b/intern/cycles/kernel/filter/filter_defines.h
@@ -22,7 +22,7 @@
#define XTWX_SIZE (((DENOISE_FEATURES+1)*(DENOISE_FEATURES+2))/2)
#define XTWY_SIZE (DENOISE_FEATURES+1)
-typedef struct TilesInfo {
+typedef struct TileInfo {
int offsets[9];
int strides[9];
int x[4];
@@ -33,6 +33,39 @@ typedef struct TilesInfo {
#else
long long int buffers[9];
#endif
-} TilesInfo;
+} TileInfo;
+
+#ifdef __KERNEL_OPENCL__
+# define CCL_FILTER_TILE_INFO ccl_global TileInfo* tile_info, \
+ ccl_global float *tile_buffer_1, \
+ ccl_global float *tile_buffer_2, \
+ ccl_global float *tile_buffer_3, \
+ ccl_global float *tile_buffer_4, \
+ ccl_global float *tile_buffer_5, \
+ ccl_global float *tile_buffer_6, \
+ ccl_global float *tile_buffer_7, \
+ ccl_global float *tile_buffer_8, \
+ ccl_global float *tile_buffer_9
+# define CCL_FILTER_TILE_INFO_ARG tile_info, \
+ tile_buffer_1, tile_buffer_2, tile_buffer_3, \
+ tile_buffer_4, tile_buffer_5, tile_buffer_6, \
+ tile_buffer_7, tile_buffer_8, tile_buffer_9
+# define ccl_get_tile_buffer(id) (id == 0 ? tile_buffer_1 \
+ : id == 1 ? tile_buffer_2 \
+ : id == 2 ? tile_buffer_3 \
+ : id == 3 ? tile_buffer_4 \
+ : id == 4 ? tile_buffer_5 \
+ : id == 5 ? tile_buffer_6 \
+ : id == 6 ? tile_buffer_7 \
+ : id == 7 ? tile_buffer_8 \
+ : tile_buffer_9)
+#else
+# ifdef __KERNEL_CUDA__
+# define CCL_FILTER_TILE_INFO ccl_global TileInfo* tile_info
+# else
+# define CCL_FILTER_TILE_INFO TileInfo* tile_info
+# endif
+# define ccl_get_tile_buffer(id) (tile_info->buffers[id])
+#endif
#endif /* __FILTER_DEFINES_H__*/
diff --git a/intern/cycles/kernel/filter/filter_prefilter.h b/intern/cycles/kernel/filter/filter_prefilter.h
index 4af209341f6..3507f80df46 100644
--- a/intern/cycles/kernel/filter/filter_prefilter.h
+++ b/intern/cycles/kernel/filter/filter_prefilter.h
@@ -26,7 +26,7 @@ CCL_NAMESPACE_BEGIN
* bufferVariance: The buffer-based variance of the shadow feature. Unbiased, but quite noisy.
*/
ccl_device void kernel_filter_divide_shadow(int sample,
- ccl_global TilesInfo *tiles,
+ CCL_FILTER_TILE_INFO,
int x, int y,
ccl_global float *unfilteredA,
ccl_global float *unfilteredB,
@@ -37,13 +37,13 @@ ccl_device void kernel_filter_divide_shadow(int sample,
int buffer_pass_stride,
int buffer_denoising_offset)
{
- int xtile = (x < tiles->x[1])? 0: ((x < tiles->x[2])? 1: 2);
- int ytile = (y < tiles->y[1])? 0: ((y < tiles->y[2])? 1: 2);
+ int xtile = (x < tile_info->x[1])? 0: ((x < tile_info->x[2])? 1: 2);
+ int ytile = (y < tile_info->y[1])? 0: ((y < tile_info->y[2])? 1: 2);
int tile = ytile*3+xtile;
- int offset = tiles->offsets[tile];
- int stride = tiles->strides[tile];
- const ccl_global float *ccl_restrict center_buffer = (ccl_global float*) tiles->buffers[tile];
+ int offset = tile_info->offsets[tile];
+ int stride = tile_info->strides[tile];
+ const ccl_global float *ccl_restrict center_buffer = (ccl_global float*) ccl_get_tile_buffer(tile);
center_buffer += (y*stride + x + offset)*buffer_pass_stride;
center_buffer += buffer_denoising_offset + 14;
@@ -79,7 +79,7 @@ ccl_device void kernel_filter_divide_shadow(int sample,
* - rect: The prefilter area (lower pixels inclusive, upper pixels exclusive).
*/
ccl_device void kernel_filter_get_feature(int sample,
- ccl_global TilesInfo *tiles,
+ CCL_FILTER_TILE_INFO,
int m_offset, int v_offset,
int x, int y,
ccl_global float *mean,
@@ -87,10 +87,10 @@ ccl_device void kernel_filter_get_feature(int sample,
int4 rect, int buffer_pass_stride,
int buffer_denoising_offset)
{
- int xtile = (x < tiles->x[1])? 0: ((x < tiles->x[2])? 1: 2);
- int ytile = (y < tiles->y[1])? 0: ((y < tiles->y[2])? 1: 2);
+ int xtile = (x < tile_info->x[1])? 0: ((x < tile_info->x[2])? 1: 2);
+ int ytile = (y < tile_info->y[1])? 0: ((y < tile_info->y[2])? 1: 2);
int tile = ytile*3+xtile;
- ccl_global float *center_buffer = ((ccl_global float*) tiles->buffers[tile]) + (tiles->offsets[tile] + y*tiles->strides[tile] + x)*buffer_pass_stride + buffer_denoising_offset;
+ ccl_global float *center_buffer = ((ccl_global float*) ccl_get_tile_buffer(tile)) + (tile_info->offsets[tile] + y*tile_info->strides[tile] + x)*buffer_pass_stride + buffer_denoising_offset;
int buffer_w = align_up(rect.z - rect.x, 4);
int idx = (y-rect.y)*buffer_w + (x - rect.x);
diff --git a/intern/cycles/kernel/geom/geom.h b/intern/cycles/kernel/geom/geom.h
index f34b77ebc07..e81c1b781c8 100644
--- a/intern/cycles/kernel/geom/geom.h
+++ b/intern/cycles/kernel/geom/geom.h
@@ -30,4 +30,3 @@
#include "kernel/geom/geom_curve_intersect.h"
#include "kernel/geom/geom_volume.h"
#include "kernel/geom/geom_primitive.h"
-
diff --git a/intern/cycles/kernel/geom/geom_attribute.h b/intern/cycles/kernel/geom/geom_attribute.h
index 42c053704d5..e991f3d685a 100644
--- a/intern/cycles/kernel/geom/geom_attribute.h
+++ b/intern/cycles/kernel/geom/geom_attribute.h
@@ -66,7 +66,7 @@ ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const Sh
uint attr_offset = object_attribute_map_offset(kg, sd->object);
attr_offset += attribute_primitive_type(kg, sd);
uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
-
+
while(attr_map.x != id) {
if(UNLIKELY(attr_map.x == ATTR_STD_NONE)) {
return attribute_not_found();
@@ -77,7 +77,7 @@ ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const Sh
AttributeDescriptor desc;
desc.element = (AttributeElement)attr_map.y;
-
+
if(sd->prim == PRIM_NONE &&
desc.element != ATTR_ELEMENT_MESH &&
desc.element != ATTR_ELEMENT_VOXEL &&
@@ -108,4 +108,3 @@ ccl_device Transform primitive_attribute_matrix(KernelGlobals *kg, const ShaderD
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/geom/geom_curve.h b/intern/cycles/kernel/geom/geom_curve.h
index e35267f02bf..dea0c742ed7 100644
--- a/intern/cycles/kernel/geom/geom_curve.h
+++ b/intern/cycles/kernel/geom/geom_curve.h
@@ -23,6 +23,33 @@ CCL_NAMESPACE_BEGIN
#ifdef __HAIR__
+/* Interpolation of curve geometry */
+
+ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3)
+{
+ float fc = 0.71f;
+ float data[4];
+ float t2 = t * t;
+ data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc;
+ data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t;
+ data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc;
+ data[3] = 3.0f * fc * t2 - 2.0f * fc * t;
+ return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
+}
+
+ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3)
+{
+ float data[4];
+ float fc = 0.71f;
+ float t2 = t * t;
+ float t3 = t2 * t;
+ data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t;
+ data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f;
+ data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t;
+ data[3] = fc * t3 - fc * t2;
+ return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
+}
+
/* Reading attributes on various curve elements */
ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy)
diff --git a/intern/cycles/kernel/geom/geom_curve_intersect.h b/intern/cycles/kernel/geom/geom_curve_intersect.h
index 46c3f408f0b..4cfbe21685c 100644
--- a/intern/cycles/kernel/geom/geom_curve_intersect.h
+++ b/intern/cycles/kernel/geom/geom_curve_intersect.h
@@ -752,31 +752,6 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
#endif
}
-ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3)
-{
- float fc = 0.71f;
- float data[4];
- float t2 = t * t;
- data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc;
- data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t;
- data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc;
- data[3] = 3.0f * fc * t2 - 2.0f * fc * t;
- return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
-}
-
-ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3)
-{
- float data[4];
- float fc = 0.71f;
- float t2 = t * t;
- float t3 = t2 * t;
- data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t;
- data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f;
- data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t;
- data[3] = fc * t3 - fc * t2;
- return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
-}
-
ccl_device_inline float3 curve_refine(KernelGlobals *kg,
ShaderData *sd,
const Intersection *isect,
diff --git a/intern/cycles/kernel/geom/geom_motion_curve.h b/intern/cycles/kernel/geom/geom_motion_curve.h
index fad29e431ec..5cc22ae2155 100644
--- a/intern/cycles/kernel/geom/geom_motion_curve.h
+++ b/intern/cycles/kernel/geom/geom_motion_curve.h
@@ -214,4 +214,3 @@ ccl_device_inline void motion_cardinal_curve_keys_avx(KernelGlobals *kg,
#endif
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/geom/geom_motion_triangle.h b/intern/cycles/kernel/geom/geom_motion_triangle.h
index 7ac6807e749..64f6d027b99 100644
--- a/intern/cycles/kernel/geom/geom_motion_triangle.h
+++ b/intern/cycles/kernel/geom/geom_motion_triangle.h
@@ -34,14 +34,14 @@ ccl_device_inline int find_attribute_motion(KernelGlobals *kg, int object, uint
/* todo: find a better (faster) solution for this, maybe store offset per object */
uint attr_offset = object_attribute_map_offset(kg, object);
uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
-
+
while(attr_map.x != id) {
attr_offset += ATTR_PRIM_TYPES;
attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
}
*elem = (AttributeElement)attr_map.y;
-
+
/* return result */
return (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : (int)attr_map.z;
}
diff --git a/intern/cycles/kernel/geom/geom_motion_triangle_shader.h b/intern/cycles/kernel/geom/geom_motion_triangle_shader.h
index 4789137d5b0..e91a4be96ba 100644
--- a/intern/cycles/kernel/geom/geom_motion_triangle_shader.h
+++ b/intern/cycles/kernel/geom/geom_motion_triangle_shader.h
@@ -120,4 +120,3 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals *kg,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h
index 800649abf38..cfe17e63627 100644
--- a/intern/cycles/kernel/geom/geom_object.h
+++ b/intern/cycles/kernel/geom/geom_object.h
@@ -613,4 +613,3 @@ ccl_device_inline void object_normal_transform_addrspace(KernelGlobals *kg,
#endif
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/geom/geom_patch.h b/intern/cycles/kernel/geom/geom_patch.h
index 5663b598508..343649ad934 100644
--- a/intern/cycles/kernel/geom/geom_patch.h
+++ b/intern/cycles/kernel/geom/geom_patch.h
@@ -340,4 +340,3 @@ ccl_device float3 patch_eval_uchar4(KernelGlobals *kg, const ShaderData *sd, int
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/geom/geom_primitive.h b/intern/cycles/kernel/geom/geom_primitive.h
index c159be92885..6db8475d196 100644
--- a/intern/cycles/kernel/geom/geom_primitive.h
+++ b/intern/cycles/kernel/geom/geom_primitive.h
@@ -192,7 +192,7 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *
/* object motion. note that depending on the mesh having motion vectors, this
* transformation was set match the world/object space of motion_pre/post */
Transform tfm;
-
+
tfm = object_fetch_motion_pass_transform(kg, sd->object, OBJECT_PASS_MOTION_PRE);
motion_pre = transform_point(&tfm, motion_pre);
@@ -240,4 +240,3 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/geom/geom_subd_triangle.h b/intern/cycles/kernel/geom/geom_subd_triangle.h
index 044e82f03d4..00ce89ae567 100644
--- a/intern/cycles/kernel/geom/geom_subd_triangle.h
+++ b/intern/cycles/kernel/geom/geom_subd_triangle.h
@@ -352,4 +352,3 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h
index 346f228e961..688413b74a1 100644
--- a/intern/cycles/kernel/geom/geom_volume.h
+++ b/intern/cycles/kernel/geom/geom_volume.h
@@ -80,4 +80,3 @@ ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *s
#endif
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h
index cfb35dd33f5..373324afb01 100644
--- a/intern/cycles/kernel/kernel.h
+++ b/intern/cycles/kernel/kernel.h
@@ -64,4 +64,3 @@ void kernel_tex_copy(KernelGlobals *kg,
CCL_NAMESPACE_END
#endif /* __KERNEL_H__ */
-
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h
index c0f281cae97..6b3cec9fda6 100644
--- a/intern/cycles/kernel/kernel_accumulate.h
+++ b/intern/cycles/kernel/kernel_accumulate.h
@@ -270,7 +270,7 @@ ccl_device_inline void path_radiance_bsdf_bounce(
L_state->transmission +
L_state->subsurface +
L_state->scatter;
-
+
L_state->direct = *throughput;
}
else {
diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h
index 79e6d1b4862..afb63152830 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -563,4 +563,3 @@ ccl_device void kernel_background_evaluate(KernelGlobals *kg,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index d26b668cb11..2f955741797 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -153,4 +153,3 @@ ccl_device_inline void print_sse3i(const char *label, sse3i& a)
CCL_NAMESPACE_END
#endif /* __KERNEL_COMPAT_CPU_H__ */
-
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h
index 671c47e2225..3f7e264fbee 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -123,6 +123,7 @@
#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))
+#define sinhf(x) sinh(((float)(x)))
#ifndef __CL_USE_NATIVE__
# define sinf(x) native_sin(((float)(x)))
@@ -150,8 +151,12 @@
/* define NULL */
#define NULL 0
+/* enable extensions */
+#ifdef __KERNEL_CL_KHR_FP16__
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+#endif
+
#include "util/util_half.h"
#include "util/util_types.h"
#endif /* __KERNEL_COMPAT_OPENCL_H__ */
-
diff --git a/intern/cycles/kernel/kernel_differential.h b/intern/cycles/kernel/kernel_differential.h
index ae1e70f0167..924d96c72e5 100644
--- a/intern/cycles/kernel/kernel_differential.h
+++ b/intern/cycles/kernel/kernel_differential.h
@@ -103,4 +103,3 @@ ccl_device differential3 differential3_zero()
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index 524e2467ebc..302bb047647 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -76,7 +76,7 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
/* Evaluate emissive closure. */
eval = shader_emissive_eval(kg, emission_sd);
}
-
+
eval *= ls->eval_fac;
return eval;
@@ -338,4 +338,3 @@ ccl_device_noinline float3 indirect_background(KernelGlobals *kg,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h
index 94815601179..b5f151d8663 100644
--- a/intern/cycles/kernel/kernel_film.h
+++ b/intern/cycles/kernel/kernel_film.h
@@ -87,4 +87,3 @@ ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_jitter.h b/intern/cycles/kernel/kernel_jitter.h
index f5855757d3f..3bde96b078c 100644
--- a/intern/cycles/kernel/kernel_jitter.h
+++ b/intern/cycles/kernel/kernel_jitter.h
@@ -226,4 +226,3 @@ ccl_device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy)
#endif
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h
index 9995490505f..49dc1f08cc1 100644
--- a/intern/cycles/kernel/kernel_montecarlo.h
+++ b/intern/cycles/kernel/kernel_montecarlo.h
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index a42a8e9812f..458aa6c2a97 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -203,7 +203,7 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
if(!((flag | light_flag) & PASS_ANY))
return;
-
+
if(!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) {
if(!(sd->flag & SD_TRANSPARENT) ||
kernel_data.film.pass_alpha_threshold == 0.0f ||
@@ -285,7 +285,7 @@ ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global f
if(!kernel_data.film.use_light_pass)
return;
-
+
if(light_flag & PASSMASK(DIFFUSE_INDIRECT))
kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, L->indirect_diffuse);
if(light_flag & PASSMASK(GLOSSY_INDIRECT))
@@ -392,4 +392,3 @@ ccl_device_inline void kernel_write_result(KernelGlobals *kg,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index d79b556c2ce..5745762e183 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -762,4 +762,3 @@ ccl_device void kernel_path_trace(KernelGlobals *kg,
#endif /* __SPLIT_KERNEL__ */
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h
index 8a358e51f94..b13fabde268 100644
--- a/intern/cycles/kernel/kernel_path_state.h
+++ b/intern/cycles/kernel/kernel_path_state.h
@@ -269,4 +269,3 @@ ccl_device_inline void path_state_branch(ccl_addr_space PathState *state,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_path_subsurface.h b/intern/cycles/kernel/kernel_path_subsurface.h
index 71aea9e3b27..ff4a8a9d580 100644
--- a/intern/cycles/kernel/kernel_path_subsurface.h
+++ b/intern/cycles/kernel/kernel_path_subsurface.h
@@ -152,4 +152,3 @@ ccl_device void kernel_path_subsurface_setup_indirect(
#endif /* __SUBSURFACE__ */
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
index 27be90d5059..c9202ccb16d 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -356,4 +356,3 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_path_volume.h b/intern/cycles/kernel/kernel_path_volume.h
index 6275d0d6562..feaea15d3c4 100644
--- a/intern/cycles/kernel/kernel_path_volume.h
+++ b/intern/cycles/kernel/kernel_path_volume.h
@@ -85,7 +85,7 @@ bool kernel_path_volume_bounce(
if(phase_pdf == 0.0f || bsdf_eval_is_zero(&phase_eval))
return false;
-
+
/* modify throughput */
path_radiance_bsdf_bounce(kg, L_state, throughput, &phase_eval, phase_pdf, state->bounce, label);
@@ -223,7 +223,7 @@ ccl_device void kernel_branched_path_volume_connect_light(
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
-
+
/* todo: split up light_sample so we don't have to call it again with new position */
if(result == VOLUME_PATH_SCATTERED &&
light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
@@ -260,7 +260,7 @@ ccl_device void kernel_branched_path_volume_connect_light(
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
-
+
/* todo: split up light_sample so we don't have to call it again with new position */
if(result == VOLUME_PATH_SCATTERED &&
light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
@@ -284,4 +284,3 @@ ccl_device void kernel_branched_path_volume_connect_light(
#endif /* __VOLUME_SCATTER__ */
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h
index 4540d733af4..7bad89c831c 100644
--- a/intern/cycles/kernel/kernel_projection.h
+++ b/intern/cycles/kernel/kernel_projection.h
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h
index 93152e9ff1c..b33e4eba8a4 100644
--- a/intern/cycles/kernel/kernel_random.h
+++ b/intern/cycles/kernel/kernel_random.h
@@ -296,4 +296,3 @@ ccl_device float lcg_step_float_addrspace(ccl_addr_space uint *rng)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h
index e8553d84547..a06fbe72ffa 100644
--- a/intern/cycles/kernel/kernel_subsurface.h
+++ b/intern/cycles/kernel/kernel_subsurface.h
@@ -50,7 +50,7 @@ ccl_device_inline float3 subsurface_scatter_eval(ShaderData *sd,
for(int i = 0; i < sd->num_closure; i++) {
sc = &sd->closure[i];
-
+
if(CLOSURE_IS_DISK_BSSRDF(sc->type)) {
/* in case of branched path integrate we sample all bssrdf's once,
* for path trace we pick one, so adjust pdf for that */
@@ -533,4 +533,3 @@ ccl_device_inline int subsurface_scatter_multi_intersect(
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h
index a7b8c492ee9..e83727ec64e 100644
--- a/intern/cycles/kernel/kernel_textures.h
+++ b/intern/cycles/kernel/kernel_textures.h
@@ -85,4 +85,3 @@ KERNEL_TEX(TextureInfo, __texture_info)
KERNEL_TEX(float, __ies)
#undef KERNEL_TEX
-
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index c2a65dc9999..85548484873 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -54,7 +54,7 @@ CCL_NAMESPACE_BEGIN
#define PRIM_NONE (~0)
#define LAMP_NONE (~0)
-#define VOLUME_STACK_SIZE 16
+#define VOLUME_STACK_SIZE 32
/* Split kernel constants */
#define WORK_POOL_SIZE_GPU 64
@@ -1238,19 +1238,19 @@ typedef struct KernelFilm {
int pass_glossy_color;
int pass_transmission_color;
int pass_subsurface_color;
-
+
int pass_diffuse_indirect;
int pass_glossy_indirect;
int pass_transmission_indirect;
int pass_subsurface_indirect;
int pass_volume_indirect;
-
+
int pass_diffuse_direct;
int pass_glossy_direct;
int pass_transmission_direct;
int pass_subsurface_direct;
int pass_volume_direct;
-
+
int pass_emission;
int pass_background;
int pass_ao;
@@ -1671,4 +1671,3 @@ typedef struct WorkTile {
CCL_NAMESPACE_END
#endif /* __KERNEL_TYPES_H__ */
-
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index 58032545338..d71761a97bc 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -68,7 +68,7 @@ ccl_device_inline bool volume_shader_sample(KernelGlobals *kg,
if(!(sd->flag & (SD_EXTINCTION|SD_SCATTER|SD_EMISSION)))
return false;
-
+
coeff->sigma_s = make_float3(0.0f, 0.0f, 0.0f);
coeff->sigma_t = (sd->flag & SD_EXTINCTION)? sd->closure_transparent_extinction:
make_float3(0.0f, 0.0f, 0.0f);
@@ -91,7 +91,7 @@ ccl_device_inline bool volume_shader_sample(KernelGlobals *kg,
ccl_device float3 volume_color_transmittance(float3 sigma, float t)
{
- return make_float3(expf(-sigma.x * t), expf(-sigma.y * t), expf(-sigma.z * t));
+ return exp3(-sigma * t);
}
ccl_device float kernel_volume_channel_get(float3 value, int channel)
@@ -234,7 +234,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg,
sum += (-sigma_t * (new_t - t));
if((i & 0x07) == 0) { /* ToDo: Other interval? */
- tp = *throughput * make_float3(expf(sum.x), expf(sum.y), expf(sum.z));
+ tp = *throughput * exp3(sum);
/* stop if nearly all light is blocked */
if(tp.x < tp_eps && tp.y < tp_eps && tp.z < tp_eps)
@@ -246,7 +246,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg,
t = new_t;
if(t == ray->t) {
/* Update throughput in case we haven't done it above */
- tp = *throughput * make_float3(expf(sum.x), expf(sum.y), expf(sum.z));
+ tp = *throughput * exp3(sum);
break;
}
}
@@ -368,7 +368,7 @@ ccl_device float3 kernel_volume_emission_integrate(VolumeShaderCoefficients *coe
}
else
emission *= t;
-
+
return emission;
}
@@ -475,7 +475,7 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_homogeneous(
new_tp = *throughput * transmittance / pdf;
}
}
- else
+ else
#endif
if(closure_flag & SD_EXTINCTION) {
/* absorption only, no sampling needed */
@@ -596,7 +596,7 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_heterogeneous_distance(
xi = 1.0f - (1.0f - xi)/sample_transmittance;
}
}
- else
+ else
#endif
if(closure_flag & SD_EXTINCTION) {
/* absorption only, no sampling needed */
@@ -751,7 +751,7 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg, PathState *sta
step_offset = 0.0f;
segment->steps = &segment->stack_step;
}
-
+
/* init accumulation variables */
float3 accum_emission = make_float3(0.0f, 0.0f, 0.0f);
float3 accum_transmittance = make_float3(1.0f, 1.0f, 1.0f);
@@ -1263,7 +1263,7 @@ ccl_device void kernel_volume_stack_enter_exit(KernelGlobals *kg, ShaderData *sd
if(!(sd->flag & SD_HAS_VOLUME))
return;
-
+
if(sd->flag & SD_BACKFACING) {
/* exit volume object: remove from stack */
for(int i = 0; stack[i].shader != SHADER_NONE; i++) {
diff --git a/intern/cycles/kernel/kernels/cpu/filter_cpu.h b/intern/cycles/kernel/kernels/cpu/filter_cpu.h
index 4231aba88d7..b62aa9663ec 100644
--- a/intern/cycles/kernel/kernels/cpu/filter_cpu.h
+++ b/intern/cycles/kernel/kernels/cpu/filter_cpu.h
@@ -17,7 +17,7 @@
/* Templated common declaration part of all CPU kernels. */
void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
- TilesInfo *tiles,
+ TileInfo *tile_info,
int x,
int y,
float *unfilteredA,
@@ -30,7 +30,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
int buffer_denoising_offset);
void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample,
- TilesInfo *tiles,
+ TileInfo *tile_info,
int m_offset,
int v_offset,
int x,
diff --git a/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h b/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h
index 504622ecfd9..26777fdabb2 100644
--- a/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h
+++ b/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h
@@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN
/* Denoise filter */
void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
- TilesInfo *tiles,
+ TileInfo *tile_info,
int x,
int y,
float *unfilteredA,
@@ -49,7 +49,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
#ifdef KERNEL_STUB
STUB_ASSERT(KERNEL_ARCH, filter_divide_shadow);
#else
- kernel_filter_divide_shadow(sample, tiles,
+ kernel_filter_divide_shadow(sample, tile_info,
x, y,
unfilteredA,
unfilteredB,
@@ -63,7 +63,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
}
void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample,
- TilesInfo *tiles,
+ TileInfo *tile_info,
int m_offset,
int v_offset,
int x,
@@ -76,7 +76,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample,
#ifdef KERNEL_STUB
STUB_ASSERT(KERNEL_ARCH, filter_get_feature);
#else
- kernel_filter_get_feature(sample, tiles,
+ kernel_filter_get_feature(sample, tile_info,
m_offset, v_offset,
x, y,
mean, variance,
diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
index 7bf833eadbc..b77b7350d86 100644
--- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
+++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
@@ -35,13 +35,13 @@ template<typename T> struct TextureInterpolator {
static ccl_always_inline float4 read(uchar4 r)
{
- float f = 1.0f/255.0f;
+ float f = 1.0f / 255.0f;
return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
}
static ccl_always_inline float4 read(uchar r)
{
- float f = r*(1.0f/255.0f);
+ float f = r * (1.0f / 255.0f);
return make_float4(f, f, f, 1.0f);
}
@@ -63,6 +63,18 @@ template<typename T> struct TextureInterpolator {
return make_float4(f, f, f, 1.0f);
}
+ static ccl_always_inline float4 read(uint16_t r)
+ {
+ float f = r*(1.0f/65535.0f);
+ return make_float4(f, f, f, 1.0f);
+ }
+
+ static ccl_always_inline float4 read(ushort4 r)
+ {
+ float f = 1.0f/65535.0f;
+ return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
+ }
+
static ccl_always_inline float4 read(const T *data,
int x, int y,
int width, int height)
@@ -481,15 +493,21 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
return TextureInterpolator<half>::interp(info, x, y);
case IMAGE_DATA_TYPE_BYTE:
return TextureInterpolator<uchar>::interp(info, x, y);
+ case IMAGE_DATA_TYPE_USHORT:
+ return TextureInterpolator<uint16_t>::interp(info, x, y);
case IMAGE_DATA_TYPE_FLOAT:
return TextureInterpolator<float>::interp(info, x, y);
case IMAGE_DATA_TYPE_HALF4:
return TextureInterpolator<half4>::interp(info, x, y);
case IMAGE_DATA_TYPE_BYTE4:
return TextureInterpolator<uchar4>::interp(info, x, y);
+ case IMAGE_DATA_TYPE_USHORT4:
+ return TextureInterpolator<ushort4>::interp(info, x, y);
case IMAGE_DATA_TYPE_FLOAT4:
- default:
return TextureInterpolator<float4>::interp(info, x, y);
+ default:
+ assert(0);
+ return make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A);
}
}
@@ -502,15 +520,21 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x,
return TextureInterpolator<half>::interp_3d(info, x, y, z, interp);
case IMAGE_DATA_TYPE_BYTE:
return TextureInterpolator<uchar>::interp_3d(info, x, y, z, interp);
+ case IMAGE_DATA_TYPE_USHORT:
+ return TextureInterpolator<uint16_t>::interp_3d(info, x, y, z, interp);
case IMAGE_DATA_TYPE_FLOAT:
return TextureInterpolator<float>::interp_3d(info, x, y, z, interp);
case IMAGE_DATA_TYPE_HALF4:
return TextureInterpolator<half4>::interp_3d(info, x, y, z, interp);
case IMAGE_DATA_TYPE_BYTE4:
return TextureInterpolator<uchar4>::interp_3d(info, x, y, z, interp);
+ case IMAGE_DATA_TYPE_USHORT4:
+ return TextureInterpolator<ushort4>::interp_3d(info, x, y, z, interp);
case IMAGE_DATA_TYPE_FLOAT4:
- default:
return TextureInterpolator<float4>::interp_3d(info, x, y, z, interp);
+ default:
+ assert(0);
+ return make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A);
}
}
diff --git a/intern/cycles/kernel/kernels/cpu/kernel_split.cpp b/intern/cycles/kernel/kernels/cpu/kernel_split.cpp
index ca750e5a00d..c5e199b0a69 100644
--- a/intern/cycles/kernel/kernels/cpu/kernel_split.cpp
+++ b/intern/cycles/kernel/kernels/cpu/kernel_split.cpp
@@ -60,4 +60,3 @@
#include "kernel/kernel.h"
#define KERNEL_ARCH cpu
#include "kernel/kernels/cpu/kernel_cpu_impl.h"
-
diff --git a/intern/cycles/kernel/kernels/cuda/filter.cu b/intern/cycles/kernel/kernels/cuda/filter.cu
index 035f0484488..0561c40e6b1 100644
--- a/intern/cycles/kernel/kernels/cuda/filter.cu
+++ b/intern/cycles/kernel/kernels/cuda/filter.cu
@@ -29,7 +29,7 @@
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
kernel_cuda_filter_divide_shadow(int sample,
- TilesInfo *tiles,
+ TileInfo *tile_info,
float *unfilteredA,
float *unfilteredB,
float *sampleVariance,
@@ -43,7 +43,7 @@ kernel_cuda_filter_divide_shadow(int sample,
int y = prefilter_rect.y + blockDim.y*blockIdx.y + threadIdx.y;
if(x < prefilter_rect.z && y < prefilter_rect.w) {
kernel_filter_divide_shadow(sample,
- tiles,
+ tile_info,
x, y,
unfilteredA,
unfilteredB,
@@ -59,7 +59,7 @@ kernel_cuda_filter_divide_shadow(int sample,
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
kernel_cuda_filter_get_feature(int sample,
- TilesInfo *tiles,
+ TileInfo *tile_info,
int m_offset,
int v_offset,
float *mean,
@@ -72,7 +72,7 @@ kernel_cuda_filter_get_feature(int sample,
int y = prefilter_rect.y + blockDim.y*blockIdx.y + threadIdx.y;
if(x < prefilter_rect.z && y < prefilter_rect.w) {
kernel_filter_get_feature(sample,
- tiles,
+ tile_info,
m_offset, v_offset,
x, y,
mean, variance,
diff --git a/intern/cycles/kernel/kernels/cuda/kernel_config.h b/intern/cycles/kernel/kernels/cuda/kernel_config.h
index f3d0d721c5c..3808898c5ca 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel_config.h
+++ b/intern/cycles/kernel/kernels/cuda/kernel_config.h
@@ -106,4 +106,3 @@
#if CUDA_KERNEL_BRANCHED_MAX_REGISTERS > CUDA_THREAD_MAX_REGISTERS
# error "Maximum number of registers per thread exceeded"
#endif
-
diff --git a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
index 91ad289a858..37cfbbcb235 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
+++ b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
@@ -127,11 +127,12 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
const TextureInfo& info = kernel_tex_fetch(__texture_info, id);
CUtexObject tex = (CUtexObject)info.data;
- /* float4, byte4 and half4 */
+ /* float4, byte4, ushort4 and half4 */
const int texture_type = kernel_tex_type(id);
if(texture_type == IMAGE_DATA_TYPE_FLOAT4 ||
texture_type == IMAGE_DATA_TYPE_BYTE4 ||
- texture_type == IMAGE_DATA_TYPE_HALF4)
+ texture_type == IMAGE_DATA_TYPE_HALF4 ||
+ texture_type == IMAGE_DATA_TYPE_USHORT4)
{
if(info.interpolation == INTERPOLATION_CUBIC) {
return kernel_tex_image_interp_bicubic<float4>(info, tex, x, y);
@@ -164,7 +165,8 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x,
const int texture_type = kernel_tex_type(id);
if(texture_type == IMAGE_DATA_TYPE_FLOAT4 ||
texture_type == IMAGE_DATA_TYPE_BYTE4 ||
- texture_type == IMAGE_DATA_TYPE_HALF4)
+ texture_type == IMAGE_DATA_TYPE_HALF4 ||
+ texture_type == IMAGE_DATA_TYPE_USHORT4)
{
if(interpolation == INTERPOLATION_CUBIC) {
return kernel_tex_image_interp_bicubic_3d<float4>(info, tex, x, y, z);
@@ -186,4 +188,3 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x,
return make_float4(f, f, f, 1.0f);
}
}
-
diff --git a/intern/cycles/kernel/kernels/opencl/filter.cl b/intern/cycles/kernel/kernels/opencl/filter.cl
index 2b77807c38b..3c75754fb39 100644
--- a/intern/cycles/kernel/kernels/opencl/filter.cl
+++ b/intern/cycles/kernel/kernels/opencl/filter.cl
@@ -23,7 +23,7 @@
/* kernels */
__kernel void kernel_ocl_filter_divide_shadow(int sample,
- ccl_global TilesInfo *tiles,
+ CCL_FILTER_TILE_INFO,
ccl_global float *unfilteredA,
ccl_global float *unfilteredB,
ccl_global float *sampleVariance,
@@ -37,7 +37,7 @@ __kernel void kernel_ocl_filter_divide_shadow(int sample,
int y = prefilter_rect.y + get_global_id(1);
if(x < prefilter_rect.z && y < prefilter_rect.w) {
kernel_filter_divide_shadow(sample,
- tiles,
+ CCL_FILTER_TILE_INFO_ARG,
x, y,
unfilteredA,
unfilteredB,
@@ -51,7 +51,7 @@ __kernel void kernel_ocl_filter_divide_shadow(int sample,
}
__kernel void kernel_ocl_filter_get_feature(int sample,
- ccl_global TilesInfo *tiles,
+ CCL_FILTER_TILE_INFO,
int m_offset,
int v_offset,
ccl_global float *mean,
@@ -64,7 +64,7 @@ __kernel void kernel_ocl_filter_get_feature(int sample,
int y = prefilter_rect.y + get_global_id(1);
if(x < prefilter_rect.z && y < prefilter_rect.w) {
kernel_filter_get_feature(sample,
- tiles,
+ CCL_FILTER_TILE_INFO_ARG,
m_offset, v_offset,
x, y,
mean, variance,
@@ -276,27 +276,3 @@ __kernel void kernel_ocl_filter_finalize(ccl_global float *buffer,
buffer_params, sample);
}
}
-
-__kernel void kernel_ocl_filter_set_tiles(ccl_global TilesInfo* tiles,
- ccl_global float *buffer_1,
- ccl_global float *buffer_2,
- ccl_global float *buffer_3,
- ccl_global float *buffer_4,
- ccl_global float *buffer_5,
- ccl_global float *buffer_6,
- ccl_global float *buffer_7,
- ccl_global float *buffer_8,
- ccl_global float *buffer_9)
-{
- if((get_global_id(0) == 0) && (get_global_id(1) == 0)) {
- tiles->buffers[0] = buffer_1;
- tiles->buffers[1] = buffer_2;
- tiles->buffers[2] = buffer_3;
- tiles->buffers[3] = buffer_4;
- tiles->buffers[4] = buffer_5;
- tiles->buffers[5] = buffer_6;
- tiles->buffers[6] = buffer_7;
- tiles->buffers[7] = buffer_8;
- tiles->buffers[8] = buffer_9;
- }
-}
diff --git a/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h b/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h
index faa9dd66d0e..dd9d683e030 100644
--- a/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h
+++ b/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h
@@ -54,12 +54,35 @@ ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, const ccl_glo
float f = 1.0f/255.0f;
return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
}
+ /* Ushort4 */
+ else if(texture_type == IMAGE_DATA_TYPE_USHORT4) {
+ ushort4 r = tex_fetch(ushort4, info, offset);
+ float f = 1.0f/65535.f;
+ return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
+ }
/* Float */
else if(texture_type == IMAGE_DATA_TYPE_FLOAT) {
float f = tex_fetch(float, info, offset);
return make_float4(f, f, f, 1.0f);
}
+ /* UShort */
+ else if(texture_type == IMAGE_DATA_TYPE_USHORT) {
+ ushort r = tex_fetch(ushort, info, offset);
+ float f = r * (1.0f / 65535.0f);
+ return make_float4(f, f, f, 1.0f);
+ }
/* Byte */
+#ifdef cl_khr_fp16
+ /* half and half4 are optional in OpenCL */
+ else if(texture_type == IMAGE_DATA_TYPE_HALF) {
+ float f = tex_fetch(half, info, offset);
+ return make_float4(f, f, f, 1.0f);
+ }
+ else if(texture_type == IMAGE_DATA_TYPE_HALF4) {
+ half4 r = tex_fetch(half4, info, offset);
+ return make_float4(r.x, r.y, r.z, r.w);
+ }
+#endif
else {
uchar r = tex_fetch(uchar, info, offset);
float f = r * (1.0f/255.0f);
diff --git a/intern/cycles/kernel/kernels/opencl/kernel_split_function.h b/intern/cycles/kernel/kernels/opencl/kernel_split_function.h
index 6aa7681cbed..05e1ddf6da2 100644
--- a/intern/cycles/kernel/kernels/opencl/kernel_split_function.h
+++ b/intern/cycles/kernel/kernels/opencl/kernel_split_function.h
@@ -62,4 +62,3 @@ __kernel void KERNEL_NAME_EVAL(kernel_ocl_path_trace, KERNEL_NAME)(
#undef KERNEL_NAME_JOIN
#undef KERNEL_NAME_EVAL
-
diff --git a/intern/cycles/kernel/osl/background.cpp b/intern/cycles/kernel/osl/background.cpp
index 30a9e84c399..6924a4144c5 100644
--- a/intern/cycles/kernel/osl/background.cpp
+++ b/intern/cycles/kernel/osl/background.cpp
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -96,4 +96,3 @@ ClosureParam *closure_holdout_params()
CCLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure)
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp b/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
index ea18f2c8c86..ed5d5235a34 100644
--- a/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
+++ b/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -82,4 +82,3 @@ ClosureParam *closure_bsdf_diffuse_ramp_params()
CCLOSURE_PREPARE(closure_bsdf_diffuse_ramp_prepare, DiffuseRampClosure)
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
index a26671eb09e..a8acdb8e342 100644
--- a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
+++ b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -82,4 +82,3 @@ ClosureParam *closure_bsdf_phong_ramp_params()
CCLOSURE_PREPARE(closure_bsdf_phong_ramp_prepare, PhongRampClosure)
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/osl/emissive.cpp b/intern/cycles/kernel/osl/emissive.cpp
index 6162786b527..c2a848231f2 100644
--- a/intern/cycles/kernel/osl/emissive.cpp
+++ b/intern/cycles/kernel/osl/emissive.cpp
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -72,4 +72,3 @@ ClosureParam *closure_emission_params()
CCLOSURE_PREPARE(closure_emission_prepare, GenericEmissiveClosure)
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/osl/osl_bssrdf.cpp b/intern/cycles/kernel/osl/osl_bssrdf.cpp
index da7368bbc61..2ebfd5f0c2f 100644
--- a/intern/cycles/kernel/osl/osl_bssrdf.cpp
+++ b/intern/cycles/kernel/osl/osl_bssrdf.cpp
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -132,4 +132,3 @@ ClosureParam *closure_bssrdf_params()
CCLOSURE_PREPARE(closure_bssrdf_prepare, CBSSRDFClosure)
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp
index 6a1e52d7d16..8c7ae30725c 100644
--- a/intern/cycles/kernel/osl/osl_closures.cpp
+++ b/intern/cycles/kernel/osl/osl_closures.cpp
@@ -4,8 +4,8 @@
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
* All Rights Reserved.
*
- * Modifications Copyright 2011, Blender Foundation.
- *
+ * Modifications Copyright 2011-2018, Blender Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -59,6 +59,7 @@
#include "kernel/closure/bsdf_ashikhmin_shirley.h"
#include "kernel/closure/bsdf_toon.h"
#include "kernel/closure/bsdf_hair.h"
+#include "kernel/closure/bsdf_hair_principled.h"
#include "kernel/closure/bsdf_principled_diffuse.h"
#include "kernel/closure/bsdf_principled_sheen.h"
#include "kernel/closure/volume.h"
@@ -176,6 +177,61 @@ BSDF_CLOSURE_CLASS_BEGIN(PrincipledSheen, principled_sheen, PrincipledSheenBsdf,
CLOSURE_FLOAT3_PARAM(PrincipledSheenClosure, params.N),
BSDF_CLOSURE_CLASS_END(PrincipledSheen, principled_sheen)
+/* PRINCIPLED HAIR BSDF */
+class PrincipledHairClosure : public CBSDFClosure {
+public:
+ PrincipledHairBSDF params;
+
+ PrincipledHairBSDF *alloc(ShaderData *sd, int path_flag, float3 weight)
+ {
+ PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)bsdf_alloc_osl(sd, sizeof(PrincipledHairBSDF), weight, &params);
+ if(!bsdf) {
+ return NULL;
+ }
+
+ PrincipledHairExtra *extra = (PrincipledHairExtra*)closure_alloc_extra(sd, sizeof(PrincipledHairExtra));
+ if(!extra) {
+ return NULL;
+ }
+
+ bsdf->extra = extra;
+ return bsdf;
+ }
+
+ void setup(ShaderData *sd, int path_flag, float3 weight)
+ {
+ if(!skip(sd, path_flag, LABEL_GLOSSY))
+ {
+ PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)alloc(sd, path_flag, weight);
+ if (!bsdf)
+ {
+ return;
+ }
+
+ sd->flag |= (bsdf) ? bsdf_principled_hair_setup(sd, bsdf) : 0;
+ }
+ }
+};
+
+static ClosureParam *closure_bsdf_principled_hair_params()
+{
+ static ClosureParam params[] = {
+ CLOSURE_FLOAT3_PARAM(PrincipledHairClosure, params.N),
+ CLOSURE_FLOAT3_PARAM(PrincipledHairClosure, params.sigma),
+ CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.v),
+ CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.s),
+ CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.m0_roughness),
+ CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.alpha),
+ CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.eta),
+ CLOSURE_STRING_KEYPARAM(PrincipledHairClosure, label, "label"),
+ CLOSURE_FINISH_PARAM(PrincipledHairClosure)
+ };
+
+ return params;
+}
+
+CCLOSURE_PREPARE(closure_bsdf_principled_hair_prepare, PrincipledHairClosure)
+
/* DISNEY PRINCIPLED CLEARCOAT */
class PrincipledClearcoatClosure : public CBSDFClosure {
public:
@@ -322,6 +378,9 @@ void OSLShader::register_closures(OSLShadingSystem *ss_)
register_closure(ss, "hair_transmission", id++,
bsdf_hair_transmission_params(), bsdf_hair_transmission_prepare);
+ register_closure(ss, "principled_hair", id++,
+ closure_bsdf_principled_hair_params(), closure_bsdf_principled_hair_prepare);
+
register_closure(ss, "henyey_greenstein", id++,
closure_henyey_greenstein_params(), closure_henyey_greenstein_prepare);
register_closure(ss, "absorption", id++,
@@ -770,4 +829,3 @@ CCLOSURE_PREPARE(closure_henyey_greenstein_prepare, VolumeHenyeyGreensteinClosur
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/osl/osl_closures.h b/intern/cycles/kernel/osl/osl_closures.h
index 68dfa9a4650..d9aeb9ab9fb 100644
--- a/intern/cycles/kernel/osl/osl_closures.h
+++ b/intern/cycles/kernel/osl/osl_closures.h
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -79,6 +79,7 @@ void closure_bsdf_microfacet_multi_ggx_fresnel_prepare(OSL::RendererServices *,
void closure_bsdf_microfacet_multi_ggx_glass_fresnel_prepare(OSL::RendererServices *, int id, void *data);
void closure_bsdf_microfacet_multi_ggx_aniso_fresnel_prepare(OSL::RendererServices *, int id, void *data);
void closure_bsdf_principled_clearcoat_prepare(OSL::RendererServices *, int id, void *data);
+void closure_bsdf_principled_hair_prepare(OSL::RendererServices *, int id, void *data);
#define CCLOSURE_PREPARE(name, classname) \
void name(RendererServices *, int id, void *data) \
@@ -146,4 +147,3 @@ CCLOSURE_PREPARE_STATIC(bsdf_##lower##_prepare, Upper##Closure)
CCL_NAMESPACE_END
#endif /* __OSL_CLOSURES_H__ */
-
diff --git a/intern/cycles/kernel/osl/osl_globals.h b/intern/cycles/kernel/osl/osl_globals.h
index 9585d9f4825..30b29793e2d 100644
--- a/intern/cycles/kernel/osl/osl_globals.h
+++ b/intern/cycles/kernel/osl/osl_globals.h
@@ -95,4 +95,3 @@ CCL_NAMESPACE_END
#endif
#endif /* __OSL_GLOBALS_H__ */
-
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index 4b7a4cb34b7..7902381440b 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -364,7 +364,7 @@ bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result
bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring to)
{
KernelGlobals *kg = kernel_globals;
-
+
if(to == u_ndc) {
copy_matrix(result, kernel_data.cam.worldtondc);
return true;
@@ -381,11 +381,11 @@ bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44
copy_matrix(result, kernel_data.cam.worldtocamera);
return true;
}
-
+
return false;
}
-bool OSLRenderServices::get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives,
+bool OSLRenderServices::get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives,
ustring object, TypeDesc type, ustring name,
int index, void *val)
{
@@ -684,7 +684,7 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD
float3 f = particle_angular_velocity(kg, particle_id);
return set_attribute_float3(f, type, derivatives, val);
}
-
+
/* Geometry Attributes */
else if(name == u_geom_numpolyvertices) {
return set_attribute_int(3, type, derivatives, val);
@@ -873,7 +873,7 @@ bool OSLRenderServices::get_attribute(ShaderData *sd, bool derivatives, ustring
return false;
}
-bool OSLRenderServices::get_userdata(bool derivatives, ustring name, TypeDesc type,
+bool OSLRenderServices::get_userdata(bool derivatives, ustring name, TypeDesc type,
OSL::ShaderGlobals *sg, void *val)
{
return false; /* disabled by lockgeom */
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h
index 1a40e2ece2b..50044746fd1 100644
--- a/intern/cycles/kernel/osl/osl_services.h
+++ b/intern/cycles/kernel/osl/osl_services.h
@@ -45,18 +45,18 @@ class OSLRenderServices : public OSL::RendererServices
public:
OSLRenderServices();
~OSLRenderServices();
-
+
void thread_init(KernelGlobals *kernel_globals, OSL::TextureSystem *ts);
bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
-
+
bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from, float time);
bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring to, float time);
-
+
bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform);
bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform);
-
+
bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from);
bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from);
@@ -195,4 +195,3 @@ private:
CCL_NAMESPACE_END
#endif /* __OSL_SERVICES_H__ */
-
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp
index b7d1c629291..6a690e880ad 100644
--- a/intern/cycles/kernel/osl/osl_shader.cpp
+++ b/intern/cycles/kernel/osl/osl_shader.cpp
@@ -115,7 +115,7 @@ static void shaderdata_to_shaderglobals(KernelGlobals *kg, ShaderData *sd, PathS
globals->backfacing = (sd->flag & SD_BACKFACING);
/* shader data to be used in services callbacks */
- globals->renderstate = sd;
+ globals->renderstate = sd;
/* hacky, we leave it to services to fetch actual object matrix */
globals->shader2common = sd;
@@ -340,7 +340,7 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state,
if(kg->osl->volume_state[shader]) {
ss->execute(octx, *(kg->osl->volume_state[shader]), *globals);
}
-
+
/* flatten closure tree */
if(globals->Ci)
flatten_volume_closure_tree(sd, globals->Ci);
@@ -405,4 +405,3 @@ int OSLShader::find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/osl/osl_shader.h b/intern/cycles/kernel/osl/osl_shader.h
index 6b392b25cf7..571a3f502be 100644
--- a/intern/cycles/kernel/osl/osl_shader.h
+++ b/intern/cycles/kernel/osl/osl_shader.h
@@ -67,4 +67,3 @@ CCL_NAMESPACE_END
#endif
#endif /* __OSL_SHADER_H__ */
-
diff --git a/intern/cycles/kernel/shaders/CMakeLists.txt b/intern/cycles/kernel/shaders/CMakeLists.txt
index 9ee78d160a4..4740db27d4e 100644
--- a/intern/cycles/kernel/shaders/CMakeLists.txt
+++ b/intern/cycles/kernel/shaders/CMakeLists.txt
@@ -85,6 +85,7 @@ set(SRC_OSL
node_wave_texture.osl
node_wireframe.osl
node_hair_bsdf.osl
+ node_principled_hair_bsdf.osl
node_uv_map.osl
node_principled_bsdf.osl
node_rgb_to_bw.osl
diff --git a/intern/cycles/kernel/shaders/node_color.h b/intern/cycles/kernel/shaders/node_color.h
index 2c3a810cb18..fc758bef1fa 100644
--- a/intern/cycles/kernel/shaders/node_color.h
+++ b/intern/cycles/kernel/shaders/node_color.h
@@ -131,7 +131,7 @@ color hsv_to_rgb(color hsv)
else {
if (h == 1.0)
h = 0.0;
-
+
h *= 6.0;
i = floor(h);
f = h - i;
@@ -150,4 +150,3 @@ color hsv_to_rgb(color hsv)
return rgb;
}
-
diff --git a/intern/cycles/kernel/shaders/node_fresnel.h b/intern/cycles/kernel/shaders/node_fresnel.h
index de2d40a849c..fcb0efa8445 100644
--- a/intern/cycles/kernel/shaders/node_fresnel.h
+++ b/intern/cycles/kernel/shaders/node_fresnel.h
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
float fresnel_dielectric_cos(float cosi, float eta)
{
/* compute fresnel reflectance without explicitly computing
@@ -46,4 +46,3 @@ color fresnel_conductor(float cosi, color eta, color k)
(tmp_f + (2.0 * eta * cosi) + cosi2);
return (Rparl2 + Rperp2) * 0.5;
}
-
diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl
index c5fcbc311d3..aa9f6e671c3 100644
--- a/intern/cycles/kernel/shaders/node_math.osl
+++ b/intern/cycles/kernel/shaders/node_math.osl
@@ -40,6 +40,18 @@ float safe_modulo(float a, float b)
return result;
}
+float safe_sqrt(float a)
+{
+ float result;
+
+ if (a > 0.0)
+ result = sqrt(a);
+ else
+ result = 0.0;
+
+ return result;
+}
+
float safe_log(float a, float b)
{
if (a < 0.0 || b < 0.0)
@@ -97,6 +109,14 @@ shader node_math(
Value = fabs(Value1);
else if (type == "arctan2")
Value = atan2(Value1, Value2);
+ else if (type == "floor")
+ Value = floor(Value1);
+ else if (type == "ceil")
+ Value = ceil(Value1);
+ else if (type == "fract")
+ Value = Value1 - floor(Value1);
+ else if (type == "sqrt")
+ Value = safe_sqrt(Value1);
if (use_clamp)
Value = clamp(Value, 0.0, 1.0);
diff --git a/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl b/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
new file mode 100644
index 00000000000..757a88f8ece
--- /dev/null
+++ b/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2018 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 "stdosl.h"
+
+color log3(color a)
+{
+ return color(log(a[0]), log(a[1]), log(a[2]));
+}
+
+color sigma_from_concentration(float eumelanin, float pheomelanin)
+{
+ return eumelanin*color(0.506, 0.841, 1.653) + pheomelanin*color(0.343, 0.733, 1.924);
+}
+
+color sigma_from_reflectance(color c, float azimuthal_roughness)
+{
+ float x = azimuthal_roughness;
+ float roughness_fac = (((((0.245*x) + 5.574)*x - 10.73)*x + 2.532)*x - 0.215)*x + 5.969;
+ color sigma = log3(c) / roughness_fac;
+ return sigma * sigma;
+}
+
+shader node_principled_hair_bsdf(
+ color Color = color(0.017513, 0.005763, 0.002059),
+ float Melanin = 0.8,
+ float MelaninRedness = 1.0,
+ float RandomColor = 0.0,
+ color Tint = 1.0,
+ color AbsorptionCoefficient = color(0.245531, 0.52, 1.365),
+ normal Normal = Ng,
+ string parametrization = "Absorption coefficient",
+ float Offset = radians(2),
+ float Roughness = 0.3,
+ float RadialRoughness = 0.3,
+ float RandomRoughness = 0.0,
+ float Coat = 0.0,
+ float IOR = 1.55,
+ string AttrRandom = "geom:curve_random",
+ float Random = 0.0,
+
+ output closure color BSDF = 0)
+{
+ /* Get random value from curve in none is specified. */
+ float random_value = 0.0;
+
+ if (isconnected(Random)) {
+ random_value = Random;
+ }
+ else {
+ getattribute(AttrRandom, random_value);
+ }
+
+ /* Compute roughness. */
+ float factor_random_roughness = 1.0 + 2.0*(random_value - 0.5)*RandomRoughness;
+ float m0_roughness = 1.0 - clamp(Coat, 0.0, 1.0);
+ float roughness = Roughness*factor_random_roughness;
+ float radial_roughness = RadialRoughness*factor_random_roughness;
+
+ /* Compute absorption. */
+ color sigma;
+
+ if (parametrization == "Absorption coefficient") {
+ sigma = AbsorptionCoefficient;
+ }
+ else if (parametrization == "Melanin concentration") {
+ /* Randomize melanin. */
+ float factor_random_color = 1.0 + 2.0*(random_value - 0.5) * RandomColor;
+ float melanin = Melanin * factor_random_color;
+
+ /* Map melanin 0..inf from more perceptually linear 0..1. */
+ melanin = -log(max(1.0 - melanin, 0.0001));
+
+ /* Benedikt Bitterli's melanin ratio remapping. */
+ float eumelanin = melanin * (1.0 - MelaninRedness);
+ float pheomelanin = melanin * MelaninRedness;
+ color melanin_sigma = sigma_from_concentration(eumelanin, pheomelanin);
+
+ /* Optional tint. */
+ color tint_sigma = sigma_from_reflectance(Tint, radial_roughness);
+ sigma = melanin_sigma + tint_sigma;
+ }
+ else if (parametrization == "Direct coloring"){
+ sigma = sigma_from_reflectance(Color, radial_roughness);
+ }
+ else {
+ /* Fallback to brownish hair, same as defaults for melanin. */
+ sigma = sigma_from_concentration(0.0, 0.8054375);
+ }
+
+ BSDF = principled_hair(Normal, sigma, roughness, radial_roughness, m0_roughness, Offset, IOR);
+}
diff --git a/intern/cycles/kernel/shaders/node_ramp_util.h b/intern/cycles/kernel/shaders/node_ramp_util.h
index 917fb65c6df..d07d5a98316 100644
--- a/intern/cycles/kernel/shaders/node_ramp_util.h
+++ b/intern/cycles/kernel/shaders/node_ramp_util.h
@@ -84,6 +84,6 @@ float rgb_ramp_lookup(float ramp[], float at, int interpolate, int extrapolate)
if (interpolate && t > 0.0)
result = (1.0 - t) * result + t * ramp[i + 1];
-
+
return result;
}
diff --git a/intern/cycles/kernel/shaders/node_texture.h b/intern/cycles/kernel/shaders/node_texture.h
index fc2cfdcd55c..88305fb320f 100644
--- a/intern/cycles/kernel/shaders/node_texture.h
+++ b/intern/cycles/kernel/shaders/node_texture.h
@@ -90,11 +90,11 @@ void voronoi(point p, float e, float da[4], point pa[4])
float safe_noise(point p, string type)
{
float f = 0.0;
-
+
/* Perlin noise in range -1..1 */
if (type == "signed")
f = noise("perlin", p);
-
+
/* Perlin noise in range 0..1 */
else
f = noise(p);
@@ -102,7 +102,7 @@ float safe_noise(point p, string type)
/* can happen for big coordinates, things even out to 0.5 then anyway */
if (!isfinite(f))
return 0.5;
-
+
return f;
}
@@ -114,7 +114,7 @@ float noise_turbulence(point p, float details, int hard)
float amp = 1.0;
float sum = 0.0;
int i, n;
-
+
float octaves = clamp(details, 0.0, 16.0);
n = (int)octaves;
@@ -128,7 +128,7 @@ float noise_turbulence(point p, float details, int hard)
amp *= 0.5;
fscale *= 2.0;
}
-
+
float rmd = octaves - floor(octaves);
if (rmd != 0.0) {
@@ -160,7 +160,6 @@ float nonzero(float f, float eps)
r = sign(f) * eps;
else
r = f;
-
+
return r;
}
-
diff --git a/intern/cycles/kernel/shaders/node_voronoi_texture.osl b/intern/cycles/kernel/shaders/node_voronoi_texture.osl
index 0c3b95ae4d0..2e47d74a414 100644
--- a/intern/cycles/kernel/shaders/node_voronoi_texture.osl
+++ b/intern/cycles/kernel/shaders/node_voronoi_texture.osl
@@ -17,12 +17,93 @@
#include "stdosl.h"
#include "node_texture.h"
+void voronoi_m(point p, string metric, float e, float da[4], point pa[4])
+{
+ /* Compute the distance to and the position of the four closest neighbors to p.
+ *
+ * The neighbors are randomly placed, 1 each in a 3x3x3 grid (Worley pattern).
+ * The distances and points are returned in ascending order, i.e. da[0] and pa[0] will
+ * contain the distance to the closest point and its coordinates respectively.
+ */
+ int xx, yy, zz, xi, yi, zi;
+
+ xi = (int)floor(p[0]);
+ yi = (int)floor(p[1]);
+ zi = (int)floor(p[2]);
+
+ da[0] = 1e10;
+ da[1] = 1e10;
+ da[2] = 1e10;
+ da[3] = 1e10;
+
+ for (xx = xi - 1; xx <= xi + 1; xx++) {
+ for (yy = yi - 1; yy <= yi + 1; yy++) {
+ for (zz = zi - 1; zz <= zi + 1; zz++) {
+ point ip = point(xx, yy, zz);
+ point vp = (point)cellnoise_color(ip);
+ point pd = p - (vp + ip);
+
+ float d = 0.0;
+ if (metric == "distance") {
+ d = dot(pd, pd);
+ }
+ else if (metric == "manhattan") {
+ d = fabs(pd[0]) + fabs(pd[1]) + fabs(pd[2]);
+ }
+ else if (metric == "chebychev") {
+ d = max(fabs(pd[0]), max(fabs(pd[1]), fabs(pd[2])));
+ }
+ else if (metric == "minkowski") {
+ d = pow(pow(fabs(pd[0]), e) + pow(fabs(pd[1]), e) + pow(fabs(pd[2]), e), 1.0/e);
+ }
+
+ vp += point(xx, yy, zz);
+
+ if (d < da[0]) {
+ da[3] = da[2];
+ da[2] = da[1];
+ da[1] = da[0];
+ da[0] = d;
+
+ pa[3] = pa[2];
+ pa[2] = pa[1];
+ pa[1] = pa[0];
+ pa[0] = vp;
+ }
+ else if (d < da[1]) {
+ da[3] = da[2];
+ da[2] = da[1];
+ da[1] = d;
+
+ pa[3] = pa[2];
+ pa[2] = pa[1];
+ pa[1] = vp;
+ }
+ else if (d < da[2]) {
+ da[3] = da[2];
+ da[2] = d;
+
+ pa[3] = pa[2];
+ pa[2] = vp;
+ }
+ else if (d < da[3]) {
+ da[3] = d;
+ pa[3] = vp;
+ }
+ }
+ }
+ }
+}
+
/* Voronoi */
shader node_voronoi_texture(
int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
string coloring = "intensity",
+ string metric = "distance",
+ string feature = "F1",
+ float Exponent = 1.0,
float Scale = 5.0,
point Vector = P,
output float Fac = 0.0,
@@ -37,17 +118,48 @@ shader node_voronoi_texture(
float da[4];
point pa[4];
- voronoi(p * Scale, 1.0, da, pa);
+ /* compute distance and point coordinate of 4 nearest neighbours */
+ voronoi_m(p * Scale, metric, Exponent, da, pa);
- /* Colored output */
if (coloring == "intensity") {
- Fac = fabs(da[0]);
+ /* Intensity output */
+ if (feature == "F1") {
+ Fac = fabs(da[0]);
+ }
+ else if (feature == "F2") {
+ Fac = fabs(da[1]);
+ }
+ else if (feature == "F3") {
+ Fac = fabs(da[2]);
+ }
+ else if (feature == "F4") {
+ Fac = fabs(da[3]);
+ }
+ else if (feature == "F2F1") {
+ Fac = fabs(da[1] - da[0]);
+ }
Color = color(Fac);
}
else {
- Color = cellnoise_color(pa[0]);
- Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
+ /* Color output */
+ if (feature == "F1") {
+ Color = pa[0];
+ }
+ else if (feature == "F2") {
+ Color = pa[1];
+ }
+ else if (feature == "F3") {
+ Color = pa[2];
+ }
+ else if (feature == "F4") {
+ Color = pa[3];
+ }
+ else if (feature == "F2F1") {
+ Color = fabs(pa[1] - pa[0]);
+ }
+ Color = cellnoise_color(Color);
+ Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
}
}
diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h
index 091ade4a60d..df9c2010872 100644
--- a/intern/cycles/kernel/shaders/stdosl.h
+++ b/intern/cycles/kernel/shaders/stdosl.h
@@ -213,7 +213,7 @@ void fresnel (vector I, normal N, float eta,
F *= sqr (beta / (g+c));
Kr = F;
Kt = (1.0 - Kr) * eta*eta;
- // OPT: the following recomputes some of the above values, but it
+ // OPT: the following recomputes some of the above values, but it
// gives us the same result as if the shader-writer called refract()
T = refract(I, N, eta);
} else {
@@ -415,7 +415,7 @@ color transformc (string from, string to, color x)
return transformc (to, r);
}
-
+
// Matrix functions
@@ -554,6 +554,7 @@ closure color bssrdf(string method, normal N, vector radius, color albedo) BUILT
// Hair
closure color hair_reflection(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
closure color hair_transmission(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
+closure color principled_hair(normal N, color sigma, float roughnessu, float roughnessv, float coat, float alpha, float eta) BUILTIN;
// Volume
closure color henyey_greenstein(float g) BUILTIN;
diff --git a/intern/cycles/kernel/split/kernel_branched.h b/intern/cycles/kernel/split/kernel_branched.h
index 368a4395760..ed0a82067f1 100644
--- a/intern/cycles/kernel/split/kernel_branched.h
+++ b/intern/cycles/kernel/split/kernel_branched.h
@@ -231,4 +231,3 @@ ccl_device_noinline bool kernel_split_branched_path_surface_indirect_light_iter(
#endif /* __BRANCHED_PATH__ */
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/split/kernel_lamp_emission.h b/intern/cycles/kernel/split/kernel_lamp_emission.h
index c14f66f664f..5b2c554b922 100644
--- a/intern/cycles/kernel/split/kernel_lamp_emission.h
+++ b/intern/cycles/kernel/split/kernel_lamp_emission.h
@@ -65,4 +65,3 @@ ccl_device void kernel_lamp_emission(KernelGlobals *kg)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h b/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h
index a4cffd77eff..fb08112503a 100644
--- a/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h
+++ b/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h
@@ -52,4 +52,3 @@ ccl_device void kernel_shadow_blocked_ao(KernelGlobals *kg)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index 2bee4bc7b69..ab69afa051e 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -498,4 +498,3 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a
CCL_NAMESPACE_END
#endif /* __SVM_H__ */
-
diff --git a/intern/cycles/kernel/svm/svm_attribute.h b/intern/cycles/kernel/svm/svm_attribute.h
index 229a3f20421..d98f538d089 100644
--- a/intern/cycles/kernel/svm/svm_attribute.h
+++ b/intern/cycles/kernel/svm/svm_attribute.h
@@ -154,4 +154,3 @@ void svm_node_attr_bump_dy(KernelGlobals *kg,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_bevel.h b/intern/cycles/kernel/svm/svm_bevel.h
index 89f4a98e846..19cdb71c20f 100644
--- a/intern/cycles/kernel/svm/svm_bevel.h
+++ b/intern/cycles/kernel/svm/svm_bevel.h
@@ -223,4 +223,3 @@ ccl_device void svm_node_bevel(
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_brick.h b/intern/cycles/kernel/svm/svm_brick.h
index 90fa2a99b67..744d9ff16c5 100644
--- a/intern/cycles/kernel/svm/svm_brick.h
+++ b/intern/cycles/kernel/svm/svm_brick.h
@@ -36,7 +36,7 @@ ccl_device_noinline float2 svm_brick(float3 p, float mortar_size, float mortar_s
float x, y;
rownum = floor_to_int(p.y / row_height);
-
+
if(offset_frequency && squash_frequency) {
brick_width *= (rownum % squash_frequency) ? 1.0f : squash_amount; /* squash */
offset = (rownum % offset_frequency) ? 0.0f : (brick_width*offset_amount); /* offset */
@@ -66,31 +66,31 @@ ccl_device_noinline float2 svm_brick(float3 p, float mortar_size, float mortar_s
}
ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
-{
+{
uint4 node2 = read_node(kg, offset);
uint4 node3 = read_node(kg, offset);
uint4 node4 = read_node(kg, offset);
-
+
/* Input and Output Sockets */
uint co_offset, color1_offset, color2_offset, mortar_offset, scale_offset;
uint mortar_size_offset, bias_offset, brick_width_offset, row_height_offset;
uint color_offset, fac_offset, mortar_smooth_offset;
-
+
/* RNA properties */
uint offset_frequency, squash_frequency;
-
+
decode_node_uchar4(node.y, &co_offset, &color1_offset, &color2_offset, &mortar_offset);
decode_node_uchar4(node.z, &scale_offset, &mortar_size_offset, &bias_offset, &brick_width_offset);
decode_node_uchar4(node.w, &row_height_offset, &color_offset, &fac_offset, &mortar_smooth_offset);
-
+
decode_node_uchar4(node2.x, &offset_frequency, &squash_frequency, NULL, NULL);
float3 co = stack_load_float3(stack, co_offset);
-
+
float3 color1 = stack_load_float3(stack, color1_offset);
float3 color2 = stack_load_float3(stack, color2_offset);
float3 mortar = stack_load_float3(stack, mortar_offset);
-
+
float scale = stack_load_float_default(stack, scale_offset, node2.y);
float mortar_size = stack_load_float_default(stack, mortar_size_offset, node2.z);
float mortar_smooth = stack_load_float_default(stack, mortar_smooth_offset, node4.x);
@@ -99,13 +99,13 @@ ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *sta
float row_height = stack_load_float_default(stack, row_height_offset, node3.y);
float offset_amount = __int_as_float(node3.z);
float squash_amount = __int_as_float(node3.w);
-
+
float2 f2 = svm_brick(co*scale, mortar_size, mortar_smooth, bias, brick_width, row_height,
offset_amount, offset_frequency, squash_amount, squash_frequency);
float tint = f2.x;
float f = f2.y;
-
+
if(f != 1.0f) {
float facm = 1.0f - tint;
color1 = facm * color1 + tint * color2;
@@ -118,4 +118,3 @@ ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *sta
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_bump.h b/intern/cycles/kernel/svm/svm_bump.h
index 610d9af9e1f..1c1fe155538 100644
--- a/intern/cycles/kernel/svm/svm_bump.h
+++ b/intern/cycles/kernel/svm/svm_bump.h
@@ -51,4 +51,3 @@ ccl_device void svm_node_leave_bump_eval(KernelGlobals *kg, ShaderData *sd, floa
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_camera.h b/intern/cycles/kernel/svm/svm_camera.h
index 90249dfd978..cf90229b53b 100644
--- a/intern/cycles/kernel/svm/svm_camera.h
+++ b/intern/cycles/kernel/svm/svm_camera.h
@@ -38,4 +38,3 @@ ccl_device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_checker.h b/intern/cycles/kernel/svm/svm_checker.h
index cea245991de..45e6c181e9e 100644
--- a/intern/cycles/kernel/svm/svm_checker.h
+++ b/intern/cycles/kernel/svm/svm_checker.h
@@ -33,7 +33,7 @@ ccl_device_noinline float svm_checker(float3 p)
}
ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
-{
+{
uint co_offset, color1_offset, color2_offset, scale_offset;
uint color_offset, fac_offset;
@@ -44,7 +44,7 @@ ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *s
float3 color1 = stack_load_float3(stack, color1_offset);
float3 color2 = stack_load_float3(stack, color2_offset);
float scale = stack_load_float_default(stack, scale_offset, node.w);
-
+
float f = svm_checker(co*scale);
if(stack_valid(color_offset))
@@ -54,4 +54,3 @@ ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *s
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index f5b316c67da..aa253223c93 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -16,6 +16,21 @@
CCL_NAMESPACE_BEGIN
+/* Hair Melanin */
+
+ccl_device_inline float3 sigma_from_concentration(float eumelanin, float pheomelanin)
+{
+ return eumelanin*make_float3(0.506f, 0.841f, 1.653f) + pheomelanin*make_float3(0.343f, 0.733f, 1.924f);
+}
+
+ccl_device_inline float3 sigma_from_reflectance(float3 color, float azimuthal_roughness)
+{
+ float x = azimuthal_roughness;
+ float roughness_fac = (((((0.245f*x) + 5.574f)*x - 10.73f)*x + 2.532f)*x - 0.215f)*x + 5.969f;
+ float3 sigma = log3(color) / roughness_fac;
+ return sigma * sigma;
+}
+
/* Closure Nodes */
ccl_device void svm_node_glass_setup(ShaderData *sd, MicrofacetBsdf *bsdf, int type, float eta, float roughness, bool refract)
@@ -130,7 +145,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
// calculate weights of the diffuse and specular part
float diffuse_weight = (1.0f - saturate(metallic)) * (1.0f - saturate(transmission));
-
+
float final_transmission = saturate(transmission) * (1.0f - saturate(metallic));
float specular_weight = (1.0f - final_transmission);
@@ -243,7 +258,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
float3 spec_weight = weight * specular_weight;
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), spec_weight);
- if(!bsdf){
+ if(!bsdf) {
break;
}
@@ -713,7 +728,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
bsdf->N = N;
bsdf->size = param1;
bsdf->smooth = param2;
-
+
if(type == CLOSURE_BSDF_DIFFUSE_TOON_ID)
sd->flag |= bsdf_diffuse_toon_setup(bsdf);
else
@@ -722,10 +737,111 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
break;
}
#ifdef __HAIR__
+ case CLOSURE_BSDF_HAIR_PRINCIPLED_ID: {
+ uint4 data_node2 = read_node(kg, offset);
+ uint4 data_node3 = read_node(kg, offset);
+ uint4 data_node4 = read_node(kg, offset);
+
+ float3 weight = sd->svm_closure_weight * mix_weight;
+
+ uint offset_ofs, ior_ofs, color_ofs, parametrization;
+ decode_node_uchar4(data_node.y, &offset_ofs, &ior_ofs, &color_ofs, &parametrization);
+ float alpha = stack_load_float_default(stack, offset_ofs, data_node.z);
+ float ior = stack_load_float_default(stack, ior_ofs, data_node.w);
+
+ uint coat_ofs, melanin_ofs, melanin_redness_ofs, absorption_coefficient_ofs;
+ decode_node_uchar4(data_node2.x, &coat_ofs, &melanin_ofs, &melanin_redness_ofs, &absorption_coefficient_ofs);
+
+ uint tint_ofs, random_ofs, random_color_ofs, random_roughness_ofs;
+ decode_node_uchar4(data_node3.x, &tint_ofs, &random_ofs, &random_color_ofs, &random_roughness_ofs);
+
+ const AttributeDescriptor attr_descr_random = find_attribute(kg, sd, data_node4.y);
+ float random = 0.0f;
+ if (attr_descr_random.offset != ATTR_STD_NOT_FOUND) {
+ random = primitive_attribute_float(kg, sd, attr_descr_random, NULL, NULL);
+ }
+ else {
+ random = stack_load_float_default(stack, random_ofs, data_node3.y);
+ }
+
+
+ PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)bsdf_alloc(sd, sizeof(PrincipledHairBSDF), weight);
+ if(bsdf) {
+ PrincipledHairExtra *extra = (PrincipledHairExtra*)closure_alloc_extra(sd, sizeof(PrincipledHairExtra));
+
+ if (!extra)
+ break;
+
+ /* Random factors range: [-randomization/2, +randomization/2]. */
+ float random_roughness = stack_load_float_default(stack, random_roughness_ofs, data_node3.w);
+ float factor_random_roughness = 1.0f + 2.0f*(random - 0.5f)*random_roughness;
+ float roughness = param1 * factor_random_roughness;
+ float radial_roughness = param2 * factor_random_roughness;
+
+ /* Remap Coat value to [0, 100]% of Roughness. */
+ float coat = stack_load_float_default(stack, coat_ofs, data_node2.y);
+ float m0_roughness = 1.0f - clamp(coat, 0.0f, 1.0f);
+
+ bsdf->N = N;
+ bsdf->v = roughness;
+ bsdf->s = radial_roughness;
+ bsdf->m0_roughness = m0_roughness;
+ bsdf->alpha = alpha;
+ bsdf->eta = ior;
+ bsdf->extra = extra;
+
+ switch(parametrization) {
+ case NODE_PRINCIPLED_HAIR_DIRECT_ABSORPTION: {
+ float3 absorption_coefficient = stack_load_float3(stack, absorption_coefficient_ofs);
+ bsdf->sigma = absorption_coefficient;
+ break;
+ }
+ case NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION: {
+ float melanin = stack_load_float_default(stack, melanin_ofs, data_node2.z);
+ float melanin_redness = stack_load_float_default(stack, melanin_redness_ofs, data_node2.w);
+
+ /* Randomize melanin. */
+ float random_color = stack_load_float_default(stack, random_color_ofs, data_node3.z);
+ random_color = clamp(random_color, 0.0f, 1.0f);
+ float factor_random_color = 1.0f + 2.0f * (random - 0.5f) * random_color;
+ melanin *= factor_random_color;
+
+ /* Map melanin 0..inf from more perceptually linear 0..1. */
+ melanin = -logf(fmaxf(1.0f - melanin, 0.0001f));
+
+ /* Benedikt Bitterli's melanin ratio remapping. */
+ float eumelanin = melanin * (1.0f - melanin_redness);
+ float pheomelanin = melanin * melanin_redness;
+ float3 melanin_sigma = sigma_from_concentration(eumelanin, pheomelanin);
+
+ /* Optional tint. */
+ float3 tint = stack_load_float3(stack, tint_ofs);
+ float3 tint_sigma = sigma_from_reflectance(tint, radial_roughness);
+
+ bsdf->sigma = melanin_sigma + tint_sigma;
+ break;
+ }
+ case NODE_PRINCIPLED_HAIR_REFLECTANCE: {
+ float3 color = stack_load_float3(stack, color_ofs);
+ bsdf->sigma = sigma_from_reflectance(color, radial_roughness);
+ break;
+ }
+ default: {
+ /* Fallback to brownish hair, same as defaults for melanin. */
+ kernel_assert(!"Invalid Principled Hair parametrization!");
+ bsdf->sigma = sigma_from_concentration(0.0f, 0.8054375f);
+ break;
+ }
+ }
+
+ sd->flag |= bsdf_principled_hair_setup(sd, bsdf);
+ }
+ break;
+ }
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
case CLOSURE_BSDF_HAIR_TRANSMISSION_ID: {
float3 weight = sd->svm_closure_weight * mix_weight;
-
+
if(sd->flag & SD_BACKFACING && sd->type & PRIMITIVE_ALL_CURVE) {
/* todo: giving a fixed weight here will cause issues when
* mixing multiple BSDFS. energy will not be conserved and
@@ -764,7 +880,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
break;
}
-#endif
+#endif /* __HAIR__ */
#ifdef __SUBSURFACE__
case CLOSURE_BSSRDF_CUBIC_ID:
@@ -1055,4 +1171,3 @@ ccl_device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *st
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_color_util.h b/intern/cycles/kernel/svm/svm_color_util.h
index 258cdeb630e..d5945f915c6 100644
--- a/intern/cycles/kernel/svm/svm_color_util.h
+++ b/intern/cycles/kernel/svm/svm_color_util.h
@@ -60,7 +60,7 @@ ccl_device float3 svm_mix_overlay(float t, float3 col1, float3 col2)
outcol.z *= tm + 2.0f*t*col2.z;
else
outcol.z = 1.0f - (tm + 2.0f*t*(1.0f - col2.z))*(1.0f - outcol.z);
-
+
return outcol;
}
@@ -167,7 +167,7 @@ ccl_device float3 svm_mix_burn(float t, float3 col1, float3 col2)
outcol.z = 1.0f;
else
outcol.z = tmp;
-
+
return outcol;
}
@@ -180,7 +180,7 @@ ccl_device float3 svm_mix_hue(float t, float3 col1, float3 col2)
if(hsv2.y != 0.0f) {
float3 hsv = rgb_to_hsv(outcol);
hsv.x = hsv2.x;
- float3 tmp = hsv_to_rgb(hsv);
+ float3 tmp = hsv_to_rgb(hsv);
outcol = interp(outcol, tmp, t);
}
@@ -227,7 +227,7 @@ ccl_device float3 svm_mix_color(float t, float3 col1, float3 col2)
float3 hsv = rgb_to_hsv(outcol);
hsv.x = hsv2.x;
hsv.y = hsv2.y;
- float3 tmp = hsv_to_rgb(hsv);
+ float3 tmp = hsv_to_rgb(hsv);
outcol = interp(outcol, tmp, t);
}
@@ -303,4 +303,3 @@ ccl_device_inline float3 svm_brightness_contrast(float3 color, float brightness,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_convert.h b/intern/cycles/kernel/svm/svm_convert.h
index c88ac57e20d..63b1dc6865e 100644
--- a/intern/cycles/kernel/svm/svm_convert.h
+++ b/intern/cycles/kernel/svm/svm_convert.h
@@ -69,4 +69,3 @@ ccl_device void svm_node_convert(KernelGlobals *kg, ShaderData *sd, float *stack
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h
index 533b7f065e6..b85eb9c0458 100644
--- a/intern/cycles/kernel/svm/svm_displace.h
+++ b/intern/cycles/kernel/svm/svm_displace.h
@@ -160,4 +160,3 @@ ccl_device void svm_node_vector_displacement(KernelGlobals *kg, ShaderData *sd,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h
index 3703ec55015..99dda5fb170 100644
--- a/intern/cycles/kernel/svm/svm_fresnel.h
+++ b/intern/cycles/kernel/svm/svm_fresnel.h
@@ -24,7 +24,7 @@ ccl_device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset,
decode_node_uchar4(node, &normal_offset, &out_offset, NULL, NULL);
float eta = (stack_valid(ior_offset))? stack_load_float(stack, ior_offset): __uint_as_float(ior_value);
float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
-
+
eta = fmaxf(eta, 1e-5f);
eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
@@ -71,4 +71,3 @@ ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h
index 81308d6f12b..05443772505 100644
--- a/intern/cycles/kernel/svm/svm_geometry.h
+++ b/intern/cycles/kernel/svm/svm_geometry.h
@@ -208,4 +208,3 @@ ccl_device void svm_node_hair_info(KernelGlobals *kg,
#endif
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_gradient.h b/intern/cycles/kernel/svm/svm_gradient.h
index 74e36e70427..177e0506dee 100644
--- a/intern/cycles/kernel/svm/svm_gradient.h
+++ b/intern/cycles/kernel/svm/svm_gradient.h
@@ -36,7 +36,7 @@ ccl_device float svm_gradient(float3 p, NodeGradientType type)
else if(type == NODE_BLEND_EASING) {
float r = fminf(fmaxf(x, 0.0f), 1.0f);
float t = r*r;
-
+
return (3.0f*t - 2.0f*t*r);
}
else if(type == NODE_BLEND_DIAGONAL) {
@@ -78,4 +78,3 @@ ccl_device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_hsv.h b/intern/cycles/kernel/svm/svm_hsv.h
index 3a1840c12e2..27127b85323 100644
--- a/intern/cycles/kernel/svm/svm_hsv.h
+++ b/intern/cycles/kernel/svm/svm_hsv.h
@@ -60,4 +60,3 @@ ccl_device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, ui
CCL_NAMESPACE_END
#endif /* __SVM_HSV_H__ */
-
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 28565308867..81ee79c984e 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -203,4 +203,3 @@ ccl_device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, floa
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_invert.h b/intern/cycles/kernel/svm/svm_invert.h
index 5ce858e2e5d..57cc4281101 100644
--- a/intern/cycles/kernel/svm/svm_invert.h
+++ b/intern/cycles/kernel/svm/svm_invert.h
@@ -35,4 +35,3 @@ ccl_device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h
index 1492e358608..dd4390057cf 100644
--- a/intern/cycles/kernel/svm/svm_light_path.h
+++ b/intern/cycles/kernel/svm/svm_light_path.h
@@ -74,4 +74,3 @@ ccl_device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_magic.h b/intern/cycles/kernel/svm/svm_magic.h
index ac87c77d719..6afaff37acd 100644
--- a/intern/cycles/kernel/svm/svm_magic.h
+++ b/intern/cycles/kernel/svm/svm_magic.h
@@ -109,4 +109,3 @@ ccl_device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *sta
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_mapping.h b/intern/cycles/kernel/svm/svm_mapping.h
index 42a7ae9946f..86181283821 100644
--- a/intern/cycles/kernel/svm/svm_mapping.h
+++ b/intern/cycles/kernel/svm/svm_mapping.h
@@ -43,4 +43,3 @@ ccl_device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h
index d633e54ed8d..c9a838361cd 100644
--- a/intern/cycles/kernel/svm/svm_math.h
+++ b/intern/cycles/kernel/svm/svm_math.h
@@ -47,4 +47,3 @@ ccl_device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *s
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h
index caf0addbf35..d3490ab284f 100644
--- a/intern/cycles/kernel/svm/svm_math_util.h
+++ b/intern/cycles/kernel/svm/svm_math_util.h
@@ -94,11 +94,19 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
Fac = fabsf(Fac1);
else if(type == NODE_MATH_ARCTAN2)
Fac = atan2f(Fac1, Fac2);
+ else if (type == NODE_MATH_FLOOR)
+ Fac = floorf(Fac1);
+ else if (type == NODE_MATH_CEIL)
+ Fac = ceilf(Fac1);
+ else if (type == NODE_MATH_FRACT)
+ Fac = Fac1 - floorf(Fac1);
+ else if (type == NODE_MATH_SQRT)
+ Fac = safe_sqrtf(Fac1);
else if(type == NODE_MATH_CLAMP)
Fac = saturate(Fac1);
else
Fac = 0.0f;
-
+
return Fac;
}
@@ -180,4 +188,3 @@ ccl_device_inline float3 svm_math_gamma_color(float3 color, float gamma)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_mix.h b/intern/cycles/kernel/svm/svm_mix.h
index 022a68d1928..903a4dacebf 100644
--- a/intern/cycles/kernel/svm/svm_mix.h
+++ b/intern/cycles/kernel/svm/svm_mix.h
@@ -32,4 +32,3 @@ ccl_device void svm_node_mix(KernelGlobals *kg, ShaderData *sd, float *stack, ui
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_musgrave.h b/intern/cycles/kernel/svm/svm_musgrave.h
index 09eba31945e..5d9e12628ca 100644
--- a/intern/cycles/kernel/svm/svm_musgrave.h
+++ b/intern/cycles/kernel/svm/svm_musgrave.h
@@ -193,7 +193,7 @@ ccl_device float svm_musgrave(NodeMusgraveType type, float dimension, float lacu
return intensity*noise_musgrave_ridged_multi_fractal(p, dimension, lacunarity, octaves, offset, gain);
else if(type == NODE_MUSGRAVE_HETERO_TERRAIN)
return intensity*noise_musgrave_hetero_terrain(p, dimension, lacunarity, octaves, offset);
-
+
return 0.0f;
}
@@ -232,4 +232,3 @@ ccl_device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float *
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_noise.h b/intern/cycles/kernel/svm/svm_noise.h
index 3f75ae5c04e..8c425ecf326 100644
--- a/intern/cycles/kernel/svm/svm_noise.h
+++ b/intern/cycles/kernel/svm/svm_noise.h
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2011, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -32,12 +32,7 @@
CCL_NAMESPACE_BEGIN
-#ifndef __KERNEL_SSE2__
-ccl_device int quick_floor(float x)
-{
- return float_to_int(x) - ((x < 0) ? 1 : 0);
-}
-#else
+#ifdef __KERNEL_SSE2__
ccl_device_inline ssei quick_floor_sse(const ssef& x)
{
ssei b = truncatei(x);
@@ -46,18 +41,6 @@ ccl_device_inline ssei quick_floor_sse(const ssef& x)
}
#endif
-#ifndef __KERNEL_SSE2__
-ccl_device float bits_to_01(uint bits)
-{
- return bits * (1.0f/(float)0xFFFFFFFF);
-}
-#else
-ccl_device_inline ssef bits_to_01_sse(const ssei& bits)
-{
- return uint32_to_float(bits) * ssef(1.0f/(float)0xFFFFFFFF);
-}
-#endif
-
ccl_device uint hash(uint kx, uint ky, uint kz)
{
// define some handy macros
@@ -120,7 +103,7 @@ ccl_device int imod(int a, int b)
return a < 0 ? a + b : a;
}
-ccl_device uint phash(int kx, int ky, int kz, int3 p)
+ccl_device uint phash(int kx, int ky, int kz, int3 p)
{
return hash(imod(kx, p.x), imod(ky, p.y), imod(kz, p.z));
}
@@ -129,7 +112,7 @@ ccl_device uint phash(int kx, int ky, int kz, int3 p)
#ifndef __KERNEL_SSE2__
ccl_device float floorfrac(float x, int* i)
{
- *i = quick_floor(x);
+ *i = quick_floor_to_int(x);
return x - *i;
}
#else
@@ -304,34 +287,27 @@ ccl_device float snoise(float3 p)
}
/* cell noise */
-#ifndef __KERNEL_SSE2__
-ccl_device_noinline float cellnoise(float3 p)
+ccl_device float cellnoise(float3 p)
{
- uint ix = quick_floor(p.x);
- uint iy = quick_floor(p.y);
- uint iz = quick_floor(p.z);
-
- return bits_to_01(hash(ix, iy, iz));
+ int3 ip = quick_floor_to_int3(p);
+ return bits_to_01(hash(ip.x, ip.y, ip.z));
}
-ccl_device float3 cellnoise_color(float3 p)
+ccl_device float3 cellnoise3(float3 p)
{
- float r = cellnoise(p);
- float g = cellnoise(make_float3(p.y, p.x, p.z));
- float b = cellnoise(make_float3(p.y, p.z, p.x));
-
+ int3 ip = quick_floor_to_int3(p);
+#ifndef __KERNEL_SSE__
+ float r = bits_to_01(hash(ip.x, ip.y, ip.z));
+ float g = bits_to_01(hash(ip.y, ip.x, ip.z));
+ float b = bits_to_01(hash(ip.y, ip.z, ip.x));
return make_float3(r, g, b);
-}
#else
-ccl_device ssef cellnoise_color(const ssef& p)
-{
- ssei ip = quick_floor_sse(p);
- ssei ip_yxz = shuffle<1, 0, 2, 3>(ip);
- ssei ip_xyy = shuffle<0, 1, 1, 3>(ip);
- ssei ip_zzx = shuffle<2, 2, 0, 3>(ip);
- return bits_to_01_sse(hash_sse(ip_xyy, ip_yxz, ip_zzx));
-}
+ ssei ip_yxz = shuffle<1, 0, 2, 3>(ssei(ip.m128));
+ ssei ip_xyy = shuffle<0, 1, 1, 3>(ssei(ip.m128));
+ ssei ip_zzx = shuffle<2, 2, 0, 3>(ssei(ip.m128));
+ ssei bits = hash_sse(ip_xyy, ip_yxz, ip_zzx);
+ return float3(uint32_to_float(bits) * ssef(1.0f/(float)0xFFFFFFFF));
#endif
+}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_noisetex.h b/intern/cycles/kernel/svm/svm_noisetex.h
index 0347ab7b193..c02940f96d6 100644
--- a/intern/cycles/kernel/svm/svm_noisetex.h
+++ b/intern/cycles/kernel/svm/svm_noisetex.h
@@ -57,4 +57,3 @@ ccl_device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *sta
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_normal.h b/intern/cycles/kernel/svm/svm_normal.h
index 53abef71012..fe46d79fe15 100644
--- a/intern/cycles/kernel/svm/svm_normal.h
+++ b/intern/cycles/kernel/svm/svm_normal.h
@@ -36,4 +36,3 @@ ccl_device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_ramp.h b/intern/cycles/kernel/svm/svm_ramp.h
index 368740f64c7..a3e4b6e87cd 100644
--- a/intern/cycles/kernel/svm/svm_ramp.h
+++ b/intern/cycles/kernel/svm/svm_ramp.h
@@ -109,4 +109,3 @@ ccl_device void svm_node_curves(KernelGlobals *kg, ShaderData *sd, float *stack,
CCL_NAMESPACE_END
#endif /* __SVM_RAMP_H__ */
-
diff --git a/intern/cycles/kernel/svm/svm_ramp_util.h b/intern/cycles/kernel/svm/svm_ramp_util.h
index b0adadae9b7..a67689ff9d1 100644
--- a/intern/cycles/kernel/svm/svm_ramp_util.h
+++ b/intern/cycles/kernel/svm/svm_ramp_util.h
@@ -96,4 +96,3 @@ ccl_device float float_ramp_lookup(const float *ramp,
CCL_NAMESPACE_END
#endif /* __SVM_RAMP_UTIL_H__ */
-
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
index 6f51b163756..1096aed2d97 100644
--- a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
+++ b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
@@ -20,11 +20,11 @@ ccl_device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *s
{
uint4 node1 = read_node(kg, offset);
uint color_out = node1.y;
-
+
float hue = stack_load_float(stack, hue_in);
float saturation = stack_load_float(stack, saturation_in);
float value = stack_load_float(stack, value_in);
-
+
/* Combine, and convert back to RGB */
float3 color = hsv_to_rgb(make_float3(hue, saturation, value));
@@ -36,9 +36,9 @@ ccl_device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *
{
uint4 node1 = read_node(kg, offset);
uint value_out = node1.y;
-
+
float3 color = stack_load_float3(stack, color_in);
-
+
/* Convert to HSV */
color = rgb_to_hsv(color);
@@ -51,4 +51,3 @@ ccl_device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_vector.h b/intern/cycles/kernel/svm/svm_sepcomb_vector.h
index 63570dd6942..0d85c0d6f1d 100644
--- a/intern/cycles/kernel/svm/svm_sepcomb_vector.h
+++ b/intern/cycles/kernel/svm/svm_sepcomb_vector.h
@@ -41,4 +41,3 @@ ccl_device void svm_node_separate_vector(ShaderData *sd, float *stack, uint ivec
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h
index b83a7168541..092f6e045d6 100644
--- a/intern/cycles/kernel/svm/svm_sky.h
+++ b/intern/cycles/kernel/svm/svm_sky.h
@@ -110,7 +110,7 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack
/* Define variables */
float sunphi, suntheta, radiance_x, radiance_y, radiance_z;
float config_x[9], config_y[9], config_z[9];
-
+
/* Load data */
uint dir_offset = node.y;
uint out_offset = node.z;
@@ -121,49 +121,49 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack
suntheta = data.y;
radiance_x = data.z;
radiance_y = data.w;
-
+
data = read_node_float(kg, offset);
radiance_z = data.x;
config_x[0] = data.y;
config_x[1] = data.z;
config_x[2] = data.w;
-
+
data = read_node_float(kg, offset);
config_x[3] = data.x;
config_x[4] = data.y;
config_x[5] = data.z;
config_x[6] = data.w;
-
+
data = read_node_float(kg, offset);
config_x[7] = data.x;
config_x[8] = data.y;
config_y[0] = data.z;
config_y[1] = data.w;
-
+
data = read_node_float(kg, offset);
config_y[2] = data.x;
config_y[3] = data.y;
config_y[4] = data.z;
config_y[5] = data.w;
-
+
data = read_node_float(kg, offset);
config_y[6] = data.x;
config_y[7] = data.y;
config_y[8] = data.z;
config_z[0] = data.w;
-
+
data = read_node_float(kg, offset);
config_z[1] = data.x;
config_z[2] = data.y;
config_z[3] = data.z;
config_z[4] = data.w;
-
+
data = read_node_float(kg, offset);
config_z[5] = data.x;
config_z[6] = data.y;
config_z[7] = data.z;
config_z[8] = data.w;
-
+
float3 dir = stack_load_float3(stack, dir_offset);
float3 f;
@@ -183,4 +183,3 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index 6ff39e5f587..7c207083929 100644
--- a/intern/cycles/kernel/svm/svm_tex_coord.h
+++ b/intern/cycles/kernel/svm/svm_tex_coord.h
@@ -323,7 +323,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
color.y = -color.y;
color.z = -color.z;
}
-
+
/* object, world space */
N = color;
@@ -392,4 +392,3 @@ ccl_device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_texture.h b/intern/cycles/kernel/svm/svm_texture.h
index dcb00f7dd55..57729817bdc 100644
--- a/intern/cycles/kernel/svm/svm_texture.h
+++ b/intern/cycles/kernel/svm/svm_texture.h
@@ -61,4 +61,3 @@ ccl_device_noinline float noise_turbulence(float3 p, float octaves, int hard)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 54db18cd7bb..910537a2539 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -24,7 +24,7 @@ CCL_NAMESPACE_BEGIN
/* SVM stack has a fixed size */
#define SVM_STACK_SIZE 255
/* SVM stack offsets with this value indicate that it's not on the stack */
-#define SVM_STACK_INVALID 255
+#define SVM_STACK_INVALID 255
#define SVM_BUMP_EVAL_STATE_SIZE 9
@@ -261,6 +261,10 @@ typedef enum NodeMath {
NODE_MATH_MODULO,
NODE_MATH_ABSOLUTE,
NODE_MATH_ARCTAN2,
+ NODE_MATH_FLOOR,
+ NODE_MATH_CEIL,
+ NODE_MATH_FRACT,
+ NODE_MATH_SQRT,
NODE_MATH_CLAMP /* used for the clamp UI option */
} NodeMath;
@@ -334,6 +338,21 @@ typedef enum NodeVoronoiColoring {
NODE_VORONOI_CELLS
} NodeVoronoiColoring;
+typedef enum NodeVoronoiDistanceMetric {
+ NODE_VORONOI_DISTANCE,
+ NODE_VORONOI_MANHATTAN,
+ NODE_VORONOI_CHEBYCHEV,
+ NODE_VORONOI_MINKOWSKI
+} NodeVoronoiDistanceMetric;
+
+typedef enum NodeVoronoiFeature {
+ NODE_VORONOI_F1,
+ NODE_VORONOI_F2,
+ NODE_VORONOI_F3,
+ NODE_VORONOI_F4,
+ NODE_VORONOI_F2F1
+} NodeVoronoiFeature;
+
typedef enum NodeBlendWeightType {
NODE_LAYER_WEIGHT_FRESNEL,
NODE_LAYER_WEIGHT_FACING
@@ -399,6 +418,13 @@ typedef enum ShaderType {
SHADER_TYPE_BUMP,
} ShaderType;
+typedef enum NodePrincipledHairParametrization {
+ NODE_PRINCIPLED_HAIR_REFLECTANCE = 0,
+ NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION = 1,
+ NODE_PRINCIPLED_HAIR_DIRECT_ABSORPTION = 2,
+ NODE_PRINCIPLED_HAIR_NUM,
+} NodePrincipledHairParametrization;
+
/* Closure */
typedef enum ClosureType {
@@ -445,6 +471,7 @@ typedef enum ClosureType {
CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID,
CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID,
CLOSURE_BSDF_SHARP_GLASS_ID,
+ CLOSURE_BSDF_HAIR_PRINCIPLED_ID,
CLOSURE_BSDF_HAIR_TRANSMISSION_ID,
/* Special cases */
@@ -476,7 +503,7 @@ typedef enum ClosureType {
/* watch this, being lazy with memory usage */
#define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
#define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_DIFFUSE_TOON_ID)
-#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_HAIR_REFLECTION_ID)
+#define CLOSURE_IS_BSDF_GLOSSY(type) ((type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_HAIR_REFLECTION_ID )|| (type == CLOSURE_BSDF_HAIR_PRINCIPLED_ID))
#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_HAIR_TRANSMISSION_ID)
#define CLOSURE_IS_BSDF_BSSRDF(type) (type == CLOSURE_BSDF_BSSRDF_ID || type == CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID)
#define CLOSURE_IS_BSDF_SINGULAR(type) (type == CLOSURE_BSDF_REFLECTION_ID || \
@@ -505,4 +532,3 @@ typedef enum ClosureType {
CCL_NAMESPACE_END
#endif /* __SVM_TYPES_H__ */
-
diff --git a/intern/cycles/kernel/svm/svm_value.h b/intern/cycles/kernel/svm/svm_value.h
index c1c2b539df3..062aee2956e 100644
--- a/intern/cycles/kernel/svm/svm_value.h
+++ b/intern/cycles/kernel/svm/svm_value.h
@@ -33,4 +33,3 @@ ccl_device void svm_node_value_v(KernelGlobals *kg, ShaderData *sd, float *stack
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_vector_transform.h b/intern/cycles/kernel/svm/svm_vector_transform.h
index 4e92f27acdb..f6ec36ba41f 100644
--- a/intern/cycles/kernel/svm/svm_vector_transform.h
+++ b/intern/cycles/kernel/svm/svm_vector_transform.h
@@ -22,20 +22,20 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo
{
uint itype, ifrom, ito;
uint vector_in, vector_out;
-
+
decode_node_uchar4(node.y, &itype, &ifrom, &ito, NULL);
decode_node_uchar4(node.z, &vector_in, &vector_out, NULL, NULL);
-
+
float3 in = stack_load_float3(stack, vector_in);
-
+
NodeVectorTransformType type = (NodeVectorTransformType)itype;
NodeVectorTransformConvertSpace from = (NodeVectorTransformConvertSpace)ifrom;
NodeVectorTransformConvertSpace to = (NodeVectorTransformConvertSpace)ito;
-
+
Transform tfm;
bool is_object = (sd->object != OBJECT_NONE);
bool is_direction = (type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR || type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL);
-
+
/* From world */
if(from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD) {
if(to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) {
@@ -52,7 +52,7 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo
object_inverse_position_transform(kg, sd, &in);
}
}
-
+
/* From camera */
else if(from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) {
if(to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) {
@@ -69,7 +69,7 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo
object_inverse_position_transform(kg, sd, &in);
}
}
-
+
/* From object */
else if(from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) {
if((to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) && is_object) {
@@ -86,11 +86,11 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo
in = transform_point(&tfm, in);
}
}
-
+
/* Normalize Normal */
if(type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL)
in = normalize(in);
-
+
/* Output */
if(stack_valid(vector_out)) {
stack_store_float3(stack, vector_out, in);
@@ -98,4 +98,3 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h
index d612d7e973f..e5e350bf76a 100644
--- a/intern/cycles/kernel/svm/svm_voronoi.h
+++ b/intern/cycles/kernel/svm/svm_voronoi.h
@@ -18,123 +18,137 @@ CCL_NAMESPACE_BEGIN
/* Voronoi */
-ccl_device float voronoi_F1_distance(float3 p)
+ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance, float e, float da[4], float3 pa[4])
{
- /* returns squared distance in da */
- float da = 1e10f;
+ /* Compute the distance to and the position of the closest neighbors to p.
+ *
+ * The neighbors are randomly placed, 1 each in a 3x3x3 grid (Worley pattern).
+ * The distances and points are returned in ascending order, i.e. da[0] and pa[0] will
+ * contain the distance to the closest point and its coordinates respectively.
+ */
-#ifndef __KERNEL_SSE2__
- int ix = floor_to_int(p.x), iy = floor_to_int(p.y), iz = floor_to_int(p.z);
+ da[0] = 1e10f;
+ da[1] = 1e10f;
+ da[2] = 1e10f;
+ da[3] = 1e10f;
- for(int xx = -1; xx <= 1; xx++) {
- for(int yy = -1; yy <= 1; yy++) {
- for(int zz = -1; zz <= 1; zz++) {
- float3 ip = make_float3(ix + xx, iy + yy, iz + zz);
- float3 vp = ip + cellnoise_color(ip);
- float d = len_squared(p - vp);
- da = min(d, da);
- }
- }
- }
-#else
- ssef vec_p = load4f(p);
- ssei xyzi = quick_floor_sse(vec_p);
+ int3 xyzi = quick_floor_to_int3(p);
for(int xx = -1; xx <= 1; xx++) {
for(int yy = -1; yy <= 1; yy++) {
for(int zz = -1; zz <= 1; zz++) {
- ssef ip = ssef(xyzi + ssei(xx, yy, zz, 0));
- ssef vp = ip + cellnoise_color(ip);
- float d = len_squared<1, 1, 1, 0>(vec_p - vp);
- da = min(d, da);
+ int3 ip = xyzi + make_int3(xx, yy, zz);
+ float3 fp = make_float3(ip.x, ip.y, ip.z);
+ float3 vp = fp + cellnoise3(fp);
+
+ float d;
+ switch(distance) {
+ case NODE_VORONOI_DISTANCE:
+ d = len_squared(p - vp);
+ break;
+ case NODE_VORONOI_MANHATTAN:
+ d = reduce_add(fabs(vp - p));
+ break;
+ case NODE_VORONOI_CHEBYCHEV:
+ d = max3(fabs(vp - p));
+ break;
+ case NODE_VORONOI_MINKOWSKI:
+ float3 n = fabs(vp - p);
+ if(e == 0.5f) {
+ d = sqr(reduce_add(sqrt(n)));
+ }
+ else {
+ d = powf(reduce_add(pow3(n, e)), 1.0f/e);
+ }
+ break;
+ }
+
+ /* To keep the shortest four distances and associated points we have to keep them in sorted order. */
+ if (d < da[0]) {
+ da[3] = da[2];
+ da[2] = da[1];
+ da[1] = da[0];
+ da[0] = d;
+
+ pa[3] = pa[2];
+ pa[2] = pa[1];
+ pa[1] = pa[0];
+ pa[0] = vp;
+ }
+ else if (d < da[1]) {
+ da[3] = da[2];
+ da[2] = da[1];
+ da[1] = d;
+
+ pa[3] = pa[2];
+ pa[2] = pa[1];
+ pa[1] = vp;
+ }
+ else if (d < da[2]) {
+ da[3] = da[2];
+ da[2] = d;
+
+ pa[3] = pa[2];
+ pa[2] = vp;
+ }
+ else if (d < da[3]) {
+ da[3] = d;
+ pa[3] = vp;
+ }
}
}
}
-#endif
-
- return da;
}
-ccl_device float3 voronoi_F1_color(float3 p)
+ccl_device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
- /* returns color of the nearest point */
- float da = 1e10f;
+ uint4 node2 = read_node(kg, offset);
-#ifndef __KERNEL_SSE2__
- float3 pa;
- int ix = floor_to_int(p.x), iy = floor_to_int(p.y), iz = floor_to_int(p.z);
+ uint co_offset, coloring, distance, feature;
+ uint scale_offset, e_offset, fac_offset, color_offset;
- for(int xx = -1; xx <= 1; xx++) {
- for(int yy = -1; yy <= 1; yy++) {
- for(int zz = -1; zz <= 1; zz++) {
- float3 ip = make_float3(ix + xx, iy + yy, iz + zz);
- float3 vp = ip + cellnoise_color(ip);
- float d = len_squared(p - vp);
-
- if(d < da) {
- da = d;
- pa = vp;
- }
- }
- }
- }
+ decode_node_uchar4(node.y, &co_offset, &coloring, &distance, &feature);
+ decode_node_uchar4(node.z, &scale_offset, &e_offset, &fac_offset, &color_offset);
- return cellnoise_color(pa);
-#else
- ssef pa, vec_p = load4f(p);
- ssei xyzi = quick_floor_sse(vec_p);
+ float3 co = stack_load_float3(stack, co_offset);
+ float scale = stack_load_float_default(stack, scale_offset, node2.x);
+ float exponent = stack_load_float_default(stack, e_offset, node2.y);
- for(int xx = -1; xx <= 1; xx++) {
- for(int yy = -1; yy <= 1; yy++) {
- for(int zz = -1; zz <= 1; zz++) {
- ssef ip = ssef(xyzi + ssei(xx, yy, zz, 0));
- ssef vp = ip + cellnoise_color(ip);
- float d = len_squared<1, 1, 1, 0>(vec_p - vp);
+ float dist[4];
+ float3 neighbor[4];
+ voronoi_neighbors(co*scale, (NodeVoronoiDistanceMetric)distance, exponent, dist, neighbor);
- if(d < da) {
- da = d;
- pa = vp;
- }
- }
+ float3 color;
+ float fac;
+ if(coloring == NODE_VORONOI_INTENSITY) {
+ switch(feature) {
+ case NODE_VORONOI_F1: fac = dist[0]; break;
+ case NODE_VORONOI_F2: fac = dist[1]; break;
+ case NODE_VORONOI_F3: fac = dist[2]; break;
+ case NODE_VORONOI_F4: fac = dist[3]; break;
+ case NODE_VORONOI_F2F1: fac = dist[1] - dist[0]; break;
}
- }
-
- ssef color = cellnoise_color(pa);
- return (float3 &)color;
-#endif
-}
-ccl_device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float3 p)
-{
- if(coloring == NODE_VORONOI_INTENSITY) {
- /* compute squared distance to the nearest neighbour */
- float fac = voronoi_F1_distance(p);
- return make_float4(fac, fac, fac, fac);
+ color = make_float3(fac, fac, fac);
}
else {
- /* compute color of the nearest neighbour */
- float3 color = voronoi_F1_color(p);
- return make_float4(color.x, color.y, color.z, average(color));
- }
-}
-
-ccl_device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
-{
- uint coloring = node.y;
- uint scale_offset, co_offset, fac_offset, color_offset;
-
- decode_node_uchar4(node.z, &scale_offset, &co_offset, &fac_offset, &color_offset);
-
- float3 co = stack_load_float3(stack, co_offset);
- float scale = stack_load_float_default(stack, scale_offset, node.w);
+ /* NODE_VORONOI_CELLS */
+ switch(feature) {
+ case NODE_VORONOI_F1: color = neighbor[0]; break;
+ case NODE_VORONOI_F2: color = neighbor[1]; break;
+ case NODE_VORONOI_F3: color = neighbor[2]; break;
+ case NODE_VORONOI_F4: color = neighbor[3]; break;
+ /* Usefulness of this vector is questionable. Note F2 >= F1 but the
+ * individual vector components might not be. */
+ case NODE_VORONOI_F2F1: color = fabs(neighbor[1] - neighbor[0]); break;
+ }
- float4 result = svm_voronoi((NodeVoronoiColoring)coloring, co*scale);
- float3 color = make_float3(result.x, result.y, result.z);
- float f = result.w;
+ color = cellnoise3(color);
+ fac = average(color);
+ }
- if(stack_valid(fac_offset)) stack_store_float(stack, fac_offset, f);
+ if(stack_valid(fac_offset)) stack_store_float(stack, fac_offset, fac);
if(stack_valid(color_offset)) stack_store_float3(stack, color_offset, color);
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_wave.h b/intern/cycles/kernel/svm/svm_wave.h
index 6ce69458a03..7b60ab6e6ae 100644
--- a/intern/cycles/kernel/svm/svm_wave.h
+++ b/intern/cycles/kernel/svm/svm_wave.h
@@ -63,4 +63,3 @@ ccl_device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stac
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_wavelength.h b/intern/cycles/kernel/svm/svm_wavelength.h
index 62e026278ac..e935fd20690 100644
--- a/intern/cycles/kernel/svm/svm_wavelength.h
+++ b/intern/cycles/kernel/svm/svm_wavelength.h
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2013, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -71,12 +71,12 @@ ccl_static_constant float cie_colour_match[81][3] = {
};
ccl_device void svm_node_wavelength(KernelGlobals *kg, ShaderData *sd, float *stack, uint wavelength, uint color_out)
-{
+{
float lambda_nm = stack_load_float(stack, wavelength);
float ii = (lambda_nm-380.0f) * (1.0f/5.0f); // scaled 0..80
int i = float_to_int(ii);
float3 color;
-
+
if(i < 0 || i >= 80) {
color = make_float3(0.0f, 0.0f, 0.0f);
}
@@ -85,10 +85,10 @@ ccl_device void svm_node_wavelength(KernelGlobals *kg, ShaderData *sd, float *st
ccl_constant float *c = cie_colour_match[i];
color = interp(make_float3(c[0], c[1], c[2]), make_float3(c[3], c[4], c[5]), ii);
}
-
+
color = xyz_to_rgb(kg, color);
color *= 1.0f/2.52f; // Empirical scale from lg to make all comps <= 1
-
+
/* Clamp to zero if values are smaller */
color = max(color, make_float3(0.0f, 0.0f, 0.0f));
@@ -96,4 +96,3 @@ ccl_device void svm_node_wavelength(KernelGlobals *kg, ShaderData *sd, float *st
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/svm/svm_wireframe.h b/intern/cycles/kernel/svm/svm_wireframe.h
index 3c6353c8001..35df9e8a0e7 100644
--- a/intern/cycles/kernel/svm/svm_wireframe.h
+++ b/intern/cycles/kernel/svm/svm_wireframe.h
@@ -5,7 +5,7 @@
* All Rights Reserved.
*
* Modifications Copyright 2013, Blender Foundation.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -134,4 +134,3 @@ ccl_device void svm_node_wireframe(KernelGlobals *kg,
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index 8c77687d9cc..a7450849195 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -202,7 +202,7 @@ bool Attribute::same_storage(TypeDesc a, TypeDesc b)
{
if(a == b)
return true;
-
+
if(a == TypeDesc::TypeColor || a == TypeDesc::TypePoint ||
a == TypeDesc::TypeVector || a == TypeDesc::TypeNormal)
{
@@ -292,7 +292,7 @@ const char *Attribute::standard_name(AttributeStandard std)
case ATTR_STD_NUM:
return "";
}
-
+
return "";
}
@@ -476,7 +476,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
}
attr->std = std;
-
+
return attr;
}
@@ -682,7 +682,7 @@ bool AttributeRequestSet::find(ustring name)
foreach(AttributeRequest& req, requests)
if(req.name == name)
return true;
-
+
return false;
}
@@ -706,4 +706,3 @@ void AttributeRequestSet::clear()
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/attribute.h b/intern/cycles/render/attribute.h
index 5cb6c75aab2..40e5be2e1b2 100644
--- a/intern/cycles/render/attribute.h
+++ b/intern/cycles/render/attribute.h
@@ -173,4 +173,3 @@ public:
CCL_NAMESPACE_END
#endif /* __ATTRIBUTE_H__ */
-
diff --git a/intern/cycles/render/background.cpp b/intern/cycles/render/background.cpp
index df3b65be110..d8a49bf6a5e 100644
--- a/intern/cycles/render/background.cpp
+++ b/intern/cycles/render/background.cpp
@@ -62,7 +62,7 @@ void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene
{
if(!need_update)
return;
-
+
device_free(device, dscene);
Shader *bg_shader = shader;
@@ -135,4 +135,3 @@ void Background::tag_update(Scene *scene)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/background.h b/intern/cycles/render/background.h
index 145c05f1c18..3f56dedb2c8 100644
--- a/intern/cycles/render/background.h
+++ b/intern/cycles/render/background.h
@@ -60,4 +60,3 @@ public:
CCL_NAMESPACE_END
#endif /* __BACKGROUND_H__ */
-
diff --git a/intern/cycles/render/bake.h b/intern/cycles/render/bake.h
index fbb8686b8f6..a811eac3327 100644
--- a/intern/cycles/render/bake.h
+++ b/intern/cycles/render/bake.h
@@ -84,4 +84,3 @@ private:
CCL_NAMESPACE_END
#endif /* __BAKE_H__ */
-
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 91b739741bb..a258b465fa2 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -452,4 +452,3 @@ bool DisplayBuffer::draw_ready()
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h
index dfc98fe2061..1b06ffe33a6 100644
--- a/intern/cycles/render/buffers.h
+++ b/intern/cycles/render/buffers.h
@@ -137,6 +137,7 @@ public:
int tile_index;
device_ptr buffer;
+ int device_size;
RenderBuffers *buffers;
@@ -146,4 +147,3 @@ public:
CCL_NAMESPACE_END
#endif /* __BUFFERS_H__ */
-
diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp
index 734cdffd5c5..cc3dd1c923b 100644
--- a/intern/cycles/render/camera.cpp
+++ b/intern/cycles/render/camera.cpp
@@ -246,7 +246,7 @@ void Camera::update(Scene *scene)
cameratoscreen = projection_orthographic(nearclip, farclip);
else
cameratoscreen = projection_identity();
-
+
ProjectionTransform screentocamera = projection_inverse(cameratoscreen);
rastertocamera = screentocamera * rastertoscreen;
diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h
index 37d05c01bd9..323f2c61ca4 100644
--- a/intern/cycles/render/camera.h
+++ b/intern/cycles/render/camera.h
@@ -181,7 +181,7 @@ public:
/* functions */
Camera();
~Camera();
-
+
void compute_auto_viewplane();
void update(Scene *scene);
@@ -213,4 +213,3 @@ private:
CCL_NAMESPACE_END
#endif /* __CAMERA_H__ */
-
diff --git a/intern/cycles/render/constant_fold.h b/intern/cycles/render/constant_fold.h
index cc24d614206..26fa4e8b1c8 100644
--- a/intern/cycles/render/constant_fold.h
+++ b/intern/cycles/render/constant_fold.h
@@ -71,4 +71,3 @@ public:
CCL_NAMESPACE_END
#endif /* __CONSTANT_FOLD_H__ */
-
diff --git a/intern/cycles/render/curves.cpp b/intern/cycles/render/curves.cpp
index 4c085b928fb..58b71d3e122 100644
--- a/intern/cycles/render/curves.cpp
+++ b/intern/cycles/render/curves.cpp
@@ -188,4 +188,3 @@ void CurveSystemManager::tag_update_mesh()
need_mesh_update = true;
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/curves.h b/intern/cycles/render/curves.h
index 8834764bd63..62066d8a809 100644
--- a/intern/cycles/render/curves.h
+++ b/intern/cycles/render/curves.h
@@ -120,4 +120,3 @@ public:
CCL_NAMESPACE_END
#endif /* __CURVES_H__ */
-
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 69828cc78da..8f3596ade58 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -175,11 +175,11 @@ bool Pass::equals(const array<Pass>& A, const array<Pass>& B)
{
if(A.size() != B.size())
return false;
-
+
for(int i = 0; i < A.size(); i++)
if(A[i].type != B[i].type)
return false;
-
+
return true;
}
@@ -188,7 +188,7 @@ bool Pass::contains(const array<Pass>& passes, PassType type)
for(size_t i = 0; i < passes.size(); i++)
if(passes[i].type == type)
return true;
-
+
return false;
}
@@ -302,7 +302,7 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
{
if(!need_update)
return;
-
+
device_free(device, dscene, scene);
KernelFilm *kfilm = &dscene->data.film;
@@ -510,4 +510,3 @@ void Film::tag_update(Scene * /*scene*/)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h
index 29b1e7e9157..6ab2eea79b8 100644
--- a/intern/cycles/render/film.h
+++ b/intern/cycles/render/film.h
@@ -93,4 +93,3 @@ public:
CCL_NAMESPACE_END
#endif /* __FILM_H__ */
-
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 8b179f742c4..3a9e2981418 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -745,7 +745,7 @@ void ShaderGraph::clean(Scene *scene)
vector<bool> visited(num_node_ids, false);
vector<bool> on_stack(num_node_ids, false);
-
+
/* break cycles */
break_cycles(output(), visited, on_stack);
@@ -860,7 +860,7 @@ void ShaderGraph::refine_bump_nodes()
copy_nodes(nodes_bump, nodes_dx);
copy_nodes(nodes_bump, nodes_dy);
-
+
/* mark nodes to indicate they are use for bump computation, so
that any texture coordinates are shifted by dx/dy when sampling */
foreach(ShaderNode *node, nodes_bump)
@@ -876,13 +876,13 @@ void ShaderGraph::refine_bump_nodes()
connect(out_dx, node->input("SampleX"));
connect(out_dy, node->input("SampleY"));
-
+
/* add generated nodes */
foreach(NodePair& pair, nodes_dx)
add(pair.second);
foreach(NodePair& pair, nodes_dy)
add(pair.second);
-
+
/* connect what is connected is bump to samplecenter input*/
connect(out , node->input("SampleCenter"));
@@ -941,7 +941,7 @@ void ShaderGraph::bump_from_displacement(bool use_object_space)
* this for bump from displacement, this will be the only bump allowed to
* overwrite the shader normal */
ShaderNode *set_normal = add(new SetNormalNode());
-
+
/* add bump node and connect copied graphs to it */
BumpNode *bump = (BumpNode*)add(new BumpNode());
bump->use_object_space = use_object_space;
@@ -973,7 +973,7 @@ void ShaderGraph::bump_from_displacement(bool use_object_space)
connect(dot_center->output("Value"), bump->input("SampleCenter"));
connect(dot_dx->output("Value"), bump->input("SampleX"));
connect(dot_dy->output("Value"), bump->input("SampleY"));
-
+
/* connect the bump out to the set normal in: */
connect(bump->output("Normal"), set_normal->input("Direction"));
@@ -996,7 +996,7 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight
* the graph into nodes that feed weights into closure nodes. this is too
* avoid building a closure tree and then flattening it, and instead write it
* directly to an array */
-
+
if(node->special_type == SHADER_SPECIAL_TYPE_COMBINE_CLOSURE) {
ShaderInput *fin = node->input("Fac");
ShaderInput *cl1in = node->input("Closure1");
@@ -1007,8 +1007,8 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight
/* mix closure: add node to mix closure weights */
MixClosureWeightNode *mix_node = new MixClosureWeightNode();
add(mix_node);
- ShaderInput *fac_in = mix_node->input("Fac");
- ShaderInput *weight_in = mix_node->input("Weight");
+ ShaderInput *fac_in = mix_node->input("Fac");
+ ShaderInput *weight_in = mix_node->input("Weight");
if(fin->link)
connect(fin->link, fac_in);
@@ -1091,6 +1091,9 @@ int ShaderGraph::get_num_closures()
else if(CLOSURE_IS_VOLUME(closure_type)) {
num_closures += VOLUME_STACK_SIZE;
}
+ else if(closure_type == CLOSURE_BSDF_HAIR_PRINCIPLED_ID) {
+ num_closures += 4;
+ }
else {
++num_closures;
}
@@ -1171,4 +1174,3 @@ void ShaderGraph::dump_graph(const char *filename)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 5d986ae4827..426522066b3 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -165,7 +165,7 @@ public:
int id; /* index in graph node array */
ShaderBump bump; /* for bump mapping utility */
-
+
ShaderNodeSpecialType special_type; /* special node type */
/* ** Selective nodes compilation ** */
@@ -294,4 +294,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __GRAPH_H__ */
-
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 023ca4b47c2..28ef026135a 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -33,11 +33,15 @@ CCL_NAMESPACE_BEGIN
/* Some helpers to silence warning in templated function. */
static bool isfinite(uchar /*value*/)
{
- return false;
+ return true;
}
static bool isfinite(half /*value*/)
{
- return false;
+ return true;
+}
+static bool isfinite(uint16_t /*value*/)
+{
+ return true;
}
ImageManager::ImageManager(const DeviceInfo& info)
@@ -164,23 +168,27 @@ bool ImageManager::get_image_metadata(const string& filename,
metadata.height = spec.height;
metadata.depth = spec.depth;
- /* check the main format, and channel formats;
- * if any take up more than one byte, we'll need a float texture slot */
- if(spec.format.basesize() > 1) {
+
+ /* Check the main format, and channel formats. */
+ size_t channel_size = spec.format.basesize();
+
+ if(spec.format.is_floating_point()) {
metadata.is_float = true;
metadata.is_linear = true;
}
for(size_t channel = 0; channel < spec.channelformats.size(); channel++) {
- if(spec.channelformats[channel].basesize() > 1) {
+ channel_size = max(channel_size, spec.channelformats[channel].basesize());
+ if(spec.channelformats[channel].is_floating_point()) {
metadata.is_float = true;
metadata.is_linear = true;
}
}
/* check if it's half float */
- if(spec.format == TypeDesc::HALF)
+ if(spec.format == TypeDesc::HALF) {
metadata.is_half = true;
+ }
/* basic color space detection, not great but better than nothing
* before we do OpenColorIO integration */
@@ -208,6 +216,9 @@ bool ImageManager::get_image_metadata(const string& filename,
else if(metadata.is_float) {
metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_FLOAT4 : IMAGE_DATA_TYPE_FLOAT;
}
+ else if(spec.format == TypeDesc::USHORT) {
+ metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_USHORT4 : IMAGE_DATA_TYPE_USHORT;
+ }
else {
metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_BYTE4 : IMAGE_DATA_TYPE_BYTE;
}
@@ -254,6 +265,10 @@ string ImageManager::name_from_type(int type)
return "half4";
else if(type == IMAGE_DATA_TYPE_HALF)
return "half";
+ else if(type == IMAGE_DATA_TYPE_USHORT)
+ return "ushort";
+ else if(type == IMAGE_DATA_TYPE_USHORT4)
+ return "ushort4";
else
return "byte4";
}
@@ -493,7 +508,6 @@ bool ImageManager::file_load_image(Image *img,
int texture_limit,
device_vector<DeviceType>& tex_img)
{
- const StorageType alpha_one = (FileFormat == TypeDesc::UINT8)? 255 : 1;
ImageInput *in = NULL;
if(!file_load_image_generic(img, &in)) {
return false;
@@ -583,15 +597,22 @@ bool ImageManager::file_load_image(Image *img,
*/
bool is_rgba = (type == IMAGE_DATA_TYPE_FLOAT4 ||
type == IMAGE_DATA_TYPE_HALF4 ||
- type == IMAGE_DATA_TYPE_BYTE4);
+ type == IMAGE_DATA_TYPE_BYTE4 ||
+ type == IMAGE_DATA_TYPE_USHORT4);
if(is_rgba) {
+ const StorageType one = util_image_cast_from_float<StorageType>(1.0f);
+
if(cmyk) {
/* CMYK */
for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) {
- pixels[i*4+2] = (pixels[i*4+2]*pixels[i*4+3])/255;
- pixels[i*4+1] = (pixels[i*4+1]*pixels[i*4+3])/255;
- pixels[i*4+0] = (pixels[i*4+0]*pixels[i*4+3])/255;
- pixels[i*4+3] = alpha_one;
+ float c = util_image_cast_to_float(pixels[i*4+0]);
+ float m = util_image_cast_to_float(pixels[i*4+1]);
+ float y = util_image_cast_to_float(pixels[i*4+2]);
+ float k = util_image_cast_to_float(pixels[i*4+3]);
+ pixels[i*4+0] = util_image_cast_from_float<StorageType>((1.0f - c) * (1.0f - k));
+ pixels[i*4+1] = util_image_cast_from_float<StorageType>((1.0f - m) * (1.0f - k));
+ pixels[i*4+2] = util_image_cast_from_float<StorageType>((1.0f - y) * (1.0f - k));
+ pixels[i*4+3] = one;
}
}
else if(components == 2) {
@@ -606,7 +627,7 @@ bool ImageManager::file_load_image(Image *img,
else if(components == 3) {
/* RGB */
for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) {
- pixels[i*4+3] = alpha_one;
+ pixels[i*4+3] = one;
pixels[i*4+2] = pixels[i*3+2];
pixels[i*4+1] = pixels[i*3+1];
pixels[i*4+0] = pixels[i*3+0];
@@ -615,7 +636,7 @@ bool ImageManager::file_load_image(Image *img,
else if(components == 1) {
/* grayscale */
for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) {
- pixels[i*4+3] = alpha_one;
+ pixels[i*4+3] = one;
pixels[i*4+2] = pixels[i];
pixels[i*4+1] = pixels[i];
pixels[i*4+0] = pixels[i];
@@ -623,7 +644,7 @@ bool ImageManager::file_load_image(Image *img,
}
if(img->use_alpha == false) {
for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) {
- pixels[i*4+3] = alpha_one;
+ pixels[i*4+3] = one;
}
}
}
@@ -843,14 +864,61 @@ void ImageManager::device_load_image(Device *device,
thread_scoped_lock device_lock(device_mutex);
tex_img->copy_to_device();
}
+ else if(type == IMAGE_DATA_TYPE_USHORT) {
+ device_vector<uint16_t> *tex_img
+ = new device_vector<uint16_t>(device, img->mem_name.c_str(), MEM_TEXTURE);
+
+ if(!file_load_image<TypeDesc::USHORT, uint16_t>(img,
+ type,
+ texture_limit,
+ *tex_img)) {
+ /* on failure to load, we set a 1x1 pixels pink image */
+ thread_scoped_lock device_lock(device_mutex);
+ uint16_t *pixels = (uint16_t*)tex_img->alloc(1, 1);
+
+ pixels[0] = (TEX_IMAGE_MISSING_R * 65535);
+ }
+
+ img->mem = tex_img;
+ img->mem->interpolation = img->interpolation;
+ img->mem->extension = img->extension;
+
+ thread_scoped_lock device_lock(device_mutex);
+ tex_img->copy_to_device();
+ }
+ else if(type == IMAGE_DATA_TYPE_USHORT4) {
+ device_vector<ushort4> *tex_img
+ = new device_vector<ushort4>(device, img->mem_name.c_str(), MEM_TEXTURE);
+
+ if(!file_load_image<TypeDesc::USHORT, uint16_t>(img,
+ type,
+ texture_limit,
+ *tex_img)) {
+ /* on failure to load, we set a 1x1 pixels pink image */
+ thread_scoped_lock device_lock(device_mutex);
+ uint16_t *pixels = (uint16_t*)tex_img->alloc(1, 1);
+
+ pixels[0] = (TEX_IMAGE_MISSING_R * 65535);
+ pixels[1] = (TEX_IMAGE_MISSING_G * 65535);
+ pixels[2] = (TEX_IMAGE_MISSING_B * 65535);
+ pixels[3] = (TEX_IMAGE_MISSING_A * 65535);
+ }
+
+ img->mem = tex_img;
+ img->mem->interpolation = img->interpolation;
+ img->mem->extension = img->extension;
+
+ thread_scoped_lock device_lock(device_mutex);
+ tex_img->copy_to_device();
+ }
else if(type == IMAGE_DATA_TYPE_HALF) {
device_vector<half> *tex_img
= new device_vector<half>(device, img->mem_name.c_str(), MEM_TEXTURE);
if(!file_load_image<TypeDesc::HALF, half>(img,
- type,
- texture_limit,
- *tex_img)) {
+ type,
+ texture_limit,
+ *tex_img)) {
/* on failure to load, we set a 1x1 pixels pink image */
thread_scoped_lock device_lock(device_mutex);
half *pixels = (half*)tex_img->alloc(1, 1);
@@ -865,7 +933,6 @@ void ImageManager::device_load_image(Device *device,
thread_scoped_lock device_lock(device_mutex);
tex_img->copy_to_device();
}
-
img->need_load = false;
}
@@ -1005,4 +1072,3 @@ void ImageManager::device_free(Device *device)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 59b9f9ea28d..c9667fb77a9 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -171,4 +171,3 @@ private:
CCL_NAMESPACE_END
#endif /* __IMAGE_H__ */
-
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index 9c276bcab31..d86eb8fc5d3 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -118,7 +118,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
}
/* Transparent Shadows
- * We only need to enable transparent shadows, if we actually have
+ * We only need to enable transparent shadows, if we actually have
* transparent shaders in the scene. Otherwise we can disable it
* to improve performance a bit. */
kintegrator->transparent_shadows = false;
@@ -141,7 +141,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
kintegrator->use_ambient_occlusion =
((Pass::contains(scene->film->passes, PASS_AO)) || dscene->data.background.ao_factor != 0.0f);
-
+
kintegrator->sample_clamp_direct = (sample_clamp_direct == 0.0f)? FLT_MAX: sample_clamp_direct*3.0f;
kintegrator->sample_clamp_indirect = (sample_clamp_indirect == 0.0f)? FLT_MAX: sample_clamp_indirect*3.0f;
@@ -236,4 +236,3 @@ void Integrator::tag_update(Scene *scene)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h
index 3cb430d72b4..f68400ac416 100644
--- a/intern/cycles/render/integrator.h
+++ b/intern/cycles/render/integrator.h
@@ -75,7 +75,7 @@ public:
NUM_METHODS,
};
-
+
Method method;
SamplingPattern sampling_pattern;
@@ -95,4 +95,3 @@ public:
CCL_NAMESPACE_END
#endif /* __INTEGRATOR_H__ */
-
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 94072d7da09..49cfae4888b 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -763,7 +763,7 @@ void LightManager::device_update_points(Device *,
}
float invarea = (area != 0.0f)? 1.0f/area: 1.0f;
float3 dir = light->dir;
-
+
dir = safe_normalize(dir);
if(light->use_mis && area != 0.0f)
@@ -792,7 +792,7 @@ void LightManager::device_update_points(Device *,
float spot_angle = cosf(light->spot_angle*0.5f);
float spot_smooth = (1.0f - spot_angle)*light->spot_smooth;
float3 dir = light->dir;
-
+
dir = safe_normalize(dir);
if(light->use_mis && radius > 0.0f)
@@ -1034,4 +1034,3 @@ void LightManager::device_update_ies(DeviceScene *dscene)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h
index acbbdd15ddf..ec957c7cc68 100644
--- a/intern/cycles/render/light.h
+++ b/intern/cycles/render/light.h
@@ -141,4 +141,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __LIGHT_H__ */
-
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index e370f8a2021..e7dc1c8e5cf 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -388,4 +388,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __MESH_H__ */
-
diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp
index ad2a5713bcb..53b9bfa3451 100644
--- a/intern/cycles/render/mesh_displace.cpp
+++ b/intern/cycles/render/mesh_displace.cpp
@@ -89,7 +89,7 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
int object = object_index;
int prim = mesh->tri_offset + i;
float u, v;
-
+
switch(j) {
case 0:
u = 1.0f;
@@ -113,7 +113,7 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
if(d_input_size == 0)
return false;
-
+
/* run device task */
device_vector<float4> d_output(device, "displace_output", MEM_READ_WRITE);
d_output.alloc(d_input_size);
@@ -319,4 +319,3 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/mesh_subdivision.cpp b/intern/cycles/render/mesh_subdivision.cpp
index 9dd81eb6700..13fda99e9cc 100644
--- a/intern/cycles/render/mesh_subdivision.cpp
+++ b/intern/cycles/render/mesh_subdivision.cpp
@@ -613,4 +613,3 @@ void Mesh::tessellate(DiagSplit *split)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index e7f13f3123f..cce851612db 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -82,7 +82,7 @@ Transform TextureMapping::compute_transform()
mmat[1][y_mapping-1] = 1.0f;
if(z_mapping != NONE)
mmat[2][z_mapping-1] = 1.0f;
-
+
float3 scale_clamped = scale;
if(type == TEXTURE || type == NORMAL) {
@@ -94,7 +94,7 @@ Transform TextureMapping::compute_transform()
if(fabsf(scale.z) < 1e-5f)
scale_clamped.z = signf(scale.z)*1e-5f;
}
-
+
Transform smat = transform_scale(scale_clamped);
Transform rmat = transform_euler(rotation);
Transform tmat = transform_translate(translation);
@@ -137,12 +137,12 @@ bool TextureMapping::skip()
return false;
if(scale != make_float3(1.0f, 1.0f, 1.0f))
return false;
-
+
if(x_mapping != X || y_mapping != Y || z_mapping != Z)
return false;
if(use_minmax)
return false;
-
+
return true;
}
@@ -520,7 +520,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
compiler.stack_assign_if_linked(alpha_out),
srgb),
projection);
-
+
tex_mapping.compile_end(compiler, vector_in, vector_offset);
}
else {
@@ -612,7 +612,7 @@ static void sky_texture_precompute_old(SunSky *sunsky, float3 dir, float turbidi
* zenith_Y/x/y is now radiance_x/y/z
* perez_Y/x/y is now config_x/y/z
*/
-
+
float2 spherical = sky_spherical_coordinates(dir);
float theta = spherical.x;
float phi = spherical.y;
@@ -676,12 +676,12 @@ static void sky_texture_precompute_new(SunSky *sunsky, float3 dir, float turbidi
float2 spherical = sky_spherical_coordinates(dir);
float theta = spherical.x;
float phi = spherical.y;
-
+
/* Clamp Turbidity */
- turbidity = clamp(turbidity, 0.0f, 10.0f);
-
+ turbidity = clamp(turbidity, 0.0f, 10.0f);
+
/* Clamp to Horizon */
- theta = clamp(theta, 0.0f, M_PI_2_F);
+ theta = clamp(theta, 0.0f, M_PI_2_F);
sunsky->theta = theta;
sunsky->phi = phi;
@@ -773,7 +773,7 @@ void SkyTextureNode::compile(OSLCompiler& compiler)
sky_texture_precompute_new(&sunsky, sun_direction, turbidity, ground_albedo);
else
assert(false);
-
+
compiler.parameter(this, "type");
compiler.parameter("theta", sunsky.theta);
compiler.parameter("phi", sunsky.phi);
@@ -913,7 +913,23 @@ NODE_DEFINE(VoronoiTextureNode)
coloring_enum.insert("cells", NODE_VORONOI_CELLS);
SOCKET_ENUM(coloring, "Coloring", coloring_enum, NODE_VORONOI_INTENSITY);
+ static NodeEnum metric;
+ metric.insert("distance", NODE_VORONOI_DISTANCE);
+ metric.insert("manhattan", NODE_VORONOI_MANHATTAN);
+ metric.insert("chebychev", NODE_VORONOI_CHEBYCHEV);
+ metric.insert("minkowski", NODE_VORONOI_MINKOWSKI);
+ SOCKET_ENUM(metric, "Distance Metric", metric, NODE_VORONOI_INTENSITY);
+
+ static NodeEnum feature_enum;
+ feature_enum.insert("F1", NODE_VORONOI_F1);
+ feature_enum.insert("F2", NODE_VORONOI_F2);
+ feature_enum.insert("F3", NODE_VORONOI_F3);
+ feature_enum.insert("F4", NODE_VORONOI_F4);
+ feature_enum.insert("F2F1", NODE_VORONOI_F2F1);
+ SOCKET_ENUM(feature, "Feature", feature_enum, NODE_VORONOI_INTENSITY);
+
SOCKET_IN_FLOAT(scale, "Scale", 1.0f);
+ SOCKET_IN_FLOAT(exponent, "Exponent", 0.5f);
SOCKET_IN_POINT(vector, "Vector", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED);
SOCKET_OUT_COLOR(color, "Color");
@@ -931,19 +947,32 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *scale_in = input("Scale");
ShaderInput *vector_in = input("Vector");
+ ShaderInput *exponent_in = input("Exponent");
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
+ if (vector_in->link) compiler.stack_assign(vector_in);
+ if (scale_in->link) compiler.stack_assign(scale_in);
+ if (exponent_in->link) compiler.stack_assign(exponent_in);
+
int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
compiler.add_node(NODE_TEX_VORONOI,
- coloring,
compiler.encode_uchar4(
- compiler.stack_assign_if_linked(scale_in),
vector_offset,
+ coloring,
+ metric,
+ feature
+ ),
+ compiler.encode_uchar4(
+ compiler.stack_assign_if_linked(scale_in),
+ compiler.stack_assign_if_linked(exponent_in),
compiler.stack_assign(fac_out),
- compiler.stack_assign(color_out)),
- __float_as_int(scale));
+ compiler.stack_assign(color_out)
+ ));
+ compiler.add_node(
+ __float_as_int(scale),
+ __float_as_int(exponent));
tex_mapping.compile_end(compiler, vector_in, vector_offset);
}
@@ -953,6 +982,8 @@ void VoronoiTextureNode::compile(OSLCompiler& compiler)
tex_mapping.compile(compiler);
compiler.parameter(this, "coloring");
+ compiler.parameter(this, "metric");
+ compiler.parameter(this, "feature");
compiler.add(this, "node_voronoi_texture");
}
@@ -1296,7 +1327,7 @@ void CheckerTextureNode::compile(SVMCompiler& compiler)
ShaderInput *color1_in = input("Color1");
ShaderInput *color2_in = input("Color2");
ShaderInput *scale_in = input("Scale");
-
+
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
@@ -1371,7 +1402,7 @@ void BrickTextureNode::compile(SVMCompiler& compiler)
ShaderInput *bias_in = input("Bias");
ShaderInput *brick_width_in = input("Brick Width");
ShaderInput *row_height_in = input("Row Height");
-
+
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
@@ -1393,7 +1424,7 @@ void BrickTextureNode::compile(SVMCompiler& compiler)
compiler.stack_assign_if_linked(color_out),
compiler.stack_assign_if_linked(fac_out),
compiler.stack_assign_if_linked(mortar_smooth_in)));
-
+
compiler.add_node(compiler.encode_uchar4(offset_frequency, squash_frequency),
__float_as_int(scale),
__float_as_int(mortar_size),
@@ -2307,7 +2338,7 @@ ToonBsdfNode::ToonBsdfNode()
void ToonBsdfNode::compile(SVMCompiler& compiler)
{
closure = component;
-
+
BsdfNode::compile(compiler, input("Size"), input("Smooth"));
}
@@ -2861,7 +2892,7 @@ void VolumeNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput
compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(color_in));
else
compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color);
-
+
compiler.add_node(NODE_CLOSURE_VOLUME,
compiler.encode_uchar4(closure,
(param1)? compiler.stack_assign(param1): SVM_STACK_INVALID,
@@ -3058,6 +3089,139 @@ void PrincipledVolumeNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_principled_volume");
}
+/* Principled Hair BSDF Closure */
+
+NODE_DEFINE(PrincipledHairBsdfNode)
+{
+ NodeType* type = NodeType::add("principled_hair_bsdf", create, NodeType::SHADER);
+
+ /* Color parametrization specified as enum. */
+ static NodeEnum parametrization_enum;
+ parametrization_enum.insert("Direct coloring", NODE_PRINCIPLED_HAIR_REFLECTANCE);
+ parametrization_enum.insert("Melanin concentration", NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION);
+ parametrization_enum.insert("Absorption coefficient", NODE_PRINCIPLED_HAIR_DIRECT_ABSORPTION);
+ SOCKET_ENUM(parametrization, "Parametrization", parametrization_enum, NODE_PRINCIPLED_HAIR_REFLECTANCE);
+
+ /* Initialize sockets to their default values. */
+ SOCKET_IN_COLOR(color, "Color", make_float3(0.017513f, 0.005763f, 0.002059f));
+ SOCKET_IN_FLOAT(melanin, "Melanin", 0.8f);
+ SOCKET_IN_FLOAT(melanin_redness, "Melanin Redness", 1.0f);
+ SOCKET_IN_COLOR(tint, "Tint", make_float3(1.f, 1.f, 1.f));
+ SOCKET_IN_VECTOR(absorption_coefficient, "Absorption Coefficient", make_float3(0.245531f, 0.52f, 1.365f), SocketType::VECTOR);
+
+ SOCKET_IN_FLOAT(offset, "Offset", 2.f*M_PI_F/180.f);
+ SOCKET_IN_FLOAT(roughness, "Roughness", 0.3f);
+ SOCKET_IN_FLOAT(radial_roughness, "Radial Roughness", 0.3f);
+ SOCKET_IN_FLOAT(coat, "Coat", 0.0f);
+ SOCKET_IN_FLOAT(ior, "IOR", 1.55f);
+
+ SOCKET_IN_FLOAT(random_roughness, "Random Roughness", 0.0f);
+ SOCKET_IN_FLOAT(random_color, "Random Color", 0.0f);
+ SOCKET_IN_FLOAT(random, "Random", 0.0f);
+
+ SOCKET_IN_NORMAL(normal, "Normal", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL);
+ SOCKET_IN_FLOAT(surface_mix_weight, "SurfaceMixWeight", 0.0f, SocketType::SVM_INTERNAL);
+
+ SOCKET_OUT_CLOSURE(BSDF, "BSDF");
+
+ return type;
+}
+
+PrincipledHairBsdfNode::PrincipledHairBsdfNode()
+: BsdfBaseNode(node_type)
+{
+ closure = CLOSURE_BSDF_HAIR_PRINCIPLED_ID;
+}
+
+/* Enable retrieving Hair Info -> Random if Random isn't linked. */
+void PrincipledHairBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes)
+{
+ if(!input("Random")->link) {
+ attributes->add(ATTR_STD_CURVE_RANDOM);
+ }
+ ShaderNode::attributes(shader, attributes);
+}
+
+/* Prepares the input data for the SVM shader. */
+void PrincipledHairBsdfNode::compile(SVMCompiler& compiler)
+{
+ compiler.add_node(NODE_CLOSURE_SET_WEIGHT, make_float3(1.0f, 1.0f, 1.0f));
+
+ ShaderInput *roughness_in = input("Roughness");
+ ShaderInput *radial_roughness_in = input("Radial Roughness");
+ ShaderInput *random_roughness_in = input("Random Roughness");
+ ShaderInput *offset_in = input("Offset");
+ ShaderInput *coat_in = input("Coat");
+ ShaderInput *ior_in = input("IOR");
+ ShaderInput *melanin_in = input("Melanin");
+ ShaderInput *melanin_redness_in = input("Melanin Redness");
+ ShaderInput *random_color_in = input("Random Color");
+
+ int color_ofs = compiler.stack_assign(input("Color"));
+ int tint_ofs = compiler.stack_assign(input("Tint"));
+ int absorption_coefficient_ofs = compiler.stack_assign(input("Absorption Coefficient"));
+
+ ShaderInput *random_in = input("Random");
+ int attr_random = random_in->link ? SVM_STACK_INVALID : compiler.attribute(ATTR_STD_CURVE_RANDOM);
+
+ /* Encode all parameters into data nodes. */
+ compiler.add_node(NODE_CLOSURE_BSDF,
+ /* Socket IDs can be packed 4 at a time into a single data packet */
+ compiler.encode_uchar4(closure,
+ compiler.stack_assign_if_linked(roughness_in),
+ compiler.stack_assign_if_linked(radial_roughness_in),
+ compiler.closure_mix_weight_offset()),
+ /* The rest are stored as unsigned integers */
+ __float_as_uint(roughness),
+ __float_as_uint(radial_roughness));
+
+ compiler.add_node(compiler.stack_assign_if_linked(input("Normal")),
+ compiler.encode_uchar4(
+ compiler.stack_assign_if_linked(offset_in),
+ compiler.stack_assign_if_linked(ior_in),
+ color_ofs,
+ parametrization),
+ __float_as_uint(offset),
+ __float_as_uint(ior));
+
+ compiler.add_node(
+ compiler.encode_uchar4(
+ compiler.stack_assign_if_linked(coat_in),
+ compiler.stack_assign_if_linked(melanin_in),
+ compiler.stack_assign_if_linked(melanin_redness_in),
+ absorption_coefficient_ofs),
+ __float_as_uint(coat),
+ __float_as_uint(melanin),
+ __float_as_uint(melanin_redness));
+
+ compiler.add_node(
+ compiler.encode_uchar4(
+ tint_ofs,
+ compiler.stack_assign_if_linked(random_in),
+ compiler.stack_assign_if_linked(random_color_in),
+ compiler.stack_assign_if_linked(random_roughness_in)),
+ __float_as_uint(random),
+ __float_as_uint(random_color),
+ __float_as_uint(random_roughness));
+
+ compiler.add_node(
+ compiler.encode_uchar4(
+ SVM_STACK_INVALID,
+ SVM_STACK_INVALID,
+ SVM_STACK_INVALID,
+ SVM_STACK_INVALID),
+ attr_random,
+ SVM_STACK_INVALID,
+ SVM_STACK_INVALID);
+}
+
+/* Prepares the input data for the OSL shader. */
+void PrincipledHairBsdfNode::compile(OSLCompiler& compiler)
+{
+ compiler.parameter(this, "parametrization");
+ compiler.add(this, "node_principled_hair_bsdf");
+}
+
/* Hair BSDF Closure */
NODE_DEFINE(HairBsdfNode)
@@ -3155,7 +3319,7 @@ void GeometryNode::compile(SVMCompiler& compiler)
geom_node = NODE_GEOMETRY_BUMP_DY;
attr_node = NODE_ATTR_BUMP_DY;
}
-
+
out = output("Position");
if(!out->links.empty()) {
compiler.add_node(geom_node, NODE_GEOM_P, compiler.stack_assign(out));
@@ -3284,7 +3448,7 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler)
attr_node = NODE_ATTR_BUMP_DY;
geom_node = NODE_GEOMETRY_BUMP_DY;
}
-
+
out = output("Generated");
if(!out->links.empty()) {
if(compiler.background) {
@@ -3360,7 +3524,7 @@ void TextureCoordinateNode::compile(OSLCompiler& compiler)
compiler.parameter("bump_offset", "dy");
else
compiler.parameter("bump_offset", "center");
-
+
if(compiler.background)
compiler.parameter("is_background", true);
if(compiler.output_type() == SHADER_TYPE_VOLUME)
@@ -3522,7 +3686,7 @@ void LightPathNode::compile(SVMCompiler& compiler)
if(!out->links.empty()) {
compiler.add_node(NODE_LIGHT_PATH, NODE_LP_transmission, compiler.stack_assign(out));
}
-
+
out = output("Is Volume Scatter Ray");
if(!out->links.empty()) {
compiler.add_node(NODE_LIGHT_PATH, NODE_LP_volume_scatter, compiler.stack_assign(out));
@@ -3532,7 +3696,7 @@ void LightPathNode::compile(SVMCompiler& compiler)
if(!out->links.empty()) {
compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_length, compiler.stack_assign(out));
}
-
+
out = output("Ray Depth");
if(!out->links.empty()) {
compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_depth, compiler.stack_assign(out));
@@ -3725,7 +3889,7 @@ void ParticleInfoNode::attributes(Shader *shader, AttributeRequestSet *attribute
void ParticleInfoNode::compile(SVMCompiler& compiler)
{
ShaderOutput *out;
-
+
out = output("Index");
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_INDEX, compiler.stack_assign(out));
@@ -3735,22 +3899,22 @@ void ParticleInfoNode::compile(SVMCompiler& compiler)
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_RANDOM, compiler.stack_assign(out));
}
-
+
out = output("Age");
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_AGE, compiler.stack_assign(out));
}
-
+
out = output("Lifetime");
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_LIFETIME, compiler.stack_assign(out));
}
-
+
out = output("Location");
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_LOCATION, compiler.stack_assign(out));
}
-
+
/* quaternion data is not yet supported by Cycles */
#if 0
out = output("Rotation");
@@ -3758,17 +3922,17 @@ void ParticleInfoNode::compile(SVMCompiler& compiler)
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_ROTATION, compiler.stack_assign(out));
}
#endif
-
+
out = output("Size");
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_SIZE, compiler.stack_assign(out));
}
-
+
out = output("Velocity");
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_VELOCITY, compiler.stack_assign(out));
}
-
+
out = output("Angular Velocity");
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_ANGULAR_VELOCITY, compiler.stack_assign(out));
@@ -3821,7 +3985,7 @@ void HairInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes)
void HairInfoNode::compile(SVMCompiler& compiler)
{
ShaderOutput *out;
-
+
out = output("Is Strand");
if(!out->links.empty()) {
compiler.add_node(NODE_HAIR_INFO, NODE_INFO_CURVE_IS_STRAND, compiler.stack_assign(out));
@@ -4744,7 +4908,7 @@ void AttributeNode::compile(OSLCompiler& compiler)
compiler.parameter("bump_offset", "dy");
else
compiler.parameter("bump_offset", "center");
-
+
if(Attribute::name_standard(attribute.c_str()) != ATTR_STD_NONE)
compiler.parameter("name", (string("geom:") + attribute.c_str()).c_str());
else
@@ -5068,6 +5232,10 @@ NODE_DEFINE(MathNode)
type_enum.insert("modulo", NODE_MATH_MODULO);
type_enum.insert("absolute", NODE_MATH_ABSOLUTE);
type_enum.insert("arctan2", NODE_MATH_ARCTAN2);
+ type_enum.insert("floor", NODE_MATH_FLOOR);
+ type_enum.insert("ceil", NODE_MATH_CEIL);
+ type_enum.insert("fract", NODE_MATH_FRACT);
+ type_enum.insert("sqrt", NODE_MATH_SQRT);
SOCKET_ENUM(type, "Type", type_enum, NODE_MATH_ADD);
SOCKET_BOOLEAN(use_clamp, "Use Clamp", false);
@@ -5550,7 +5718,7 @@ void RGBRampNode::compile(OSLCompiler& compiler)
compiler.parameter_color_array("ramp_color", ramp);
compiler.parameter_array("ramp_alpha", ramp_alpha.data(), ramp_alpha.size());
compiler.parameter(this, "interpolate");
-
+
compiler.add(this, "node_rgb_ramp");
}
@@ -5583,7 +5751,7 @@ void SetNormalNode::compile(SVMCompiler& compiler)
void SetNormalNode::compile(OSLCompiler& compiler)
{
- compiler.add(this, "node_set_normal");
+ compiler.add(this, "node_set_normal");
}
/* OSLNode */
@@ -5704,7 +5872,7 @@ void NormalMapNode::attributes(Shader *shader, AttributeRequestSet *attributes)
attributes->add(ATTR_STD_VERTEX_NORMAL);
}
-
+
ShaderNode::attributes(shader, attributes);
}
@@ -5749,7 +5917,7 @@ void NormalMapNode::compile(OSLCompiler& compiler)
}
compiler.parameter(this, "space");
- compiler.add(this, "node_normal_map");
+ compiler.add(this, "node_normal_map");
}
/* Tangent */
@@ -5794,7 +5962,7 @@ void TangentNode::attributes(Shader *shader, AttributeRequestSet *attributes)
else
attributes->add(ATTR_STD_GENERATED);
}
-
+
ShaderNode::attributes(shader, attributes);
}
@@ -5830,7 +5998,7 @@ void TangentNode::compile(OSLCompiler& compiler)
compiler.parameter(this, "direction_type");
compiler.parameter(this, "axis");
- compiler.add(this, "node_tangent");
+ compiler.add(this, "node_tangent");
}
/* Bevel */
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 996c582d206..c2cf13ad020 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -189,7 +189,9 @@ public:
virtual int get_group() { return NODE_GROUP_LEVEL_2; }
NodeVoronoiColoring coloring;
- float scale;
+ NodeVoronoiDistanceMetric metric;
+ NodeVoronoiFeature feature;
+ float scale, exponent;
float3 vector;
};
@@ -608,6 +610,45 @@ public:
float temperature;
};
+/* Interface between the I/O sockets and the SVM/OSL backend. */
+class PrincipledHairBsdfNode : public BsdfBaseNode {
+public:
+ SHADER_NODE_CLASS(PrincipledHairBsdfNode)
+ void attributes(Shader *shader, AttributeRequestSet *attributes);
+
+ /* Longitudinal roughness. */
+ float roughness;
+ /* Azimuthal roughness. */
+ float radial_roughness;
+ /* Randomization factor for roughnesses. */
+ float random_roughness;
+ /* Longitudinal roughness factor for only the diffuse bounce (shiny undercoat). */
+ float coat;
+ /* Index of reflection. */
+ float ior;
+ /* Cuticle tilt angle. */
+ float offset;
+ /* Direct coloring's color. */
+ float3 color;
+ /* Melanin concentration. */
+ float melanin;
+ /* Melanin redness ratio. */
+ float melanin_redness;
+ /* Dye color. */
+ float3 tint;
+ /* Randomization factor for melanin quantities. */
+ float random_color;
+ /* Absorption coefficient (unfiltered). */
+ float3 absorption_coefficient;
+
+ float3 normal;
+ float surface_mix_weight;
+ /* If linked, here will be the given random number. */
+ float random;
+ /* Selected coloring parametrization. */
+ NodePrincipledHairParametrization parametrization;
+};
+
class HairBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(HairBsdfNode)
@@ -1123,4 +1164,3 @@ public:
CCL_NAMESPACE_END
#endif /* __NODES_H__ */
-
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index 4d64d841206..e3f35c366d6 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -183,7 +183,7 @@ void Object::apply_transform(bool apply_to_motion)
{
if(!mesh || tfm == transform_identity())
return;
-
+
/* triangles */
if(mesh->verts.size()) {
/* store matrix to transform later. when accessing these as attributes we
@@ -194,7 +194,7 @@ void Object::apply_transform(bool apply_to_motion)
/* 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);
@@ -840,4 +840,3 @@ void ObjectManager::tag_update(Scene *scene)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h
index c7212ae25f9..b80c4aef70b 100644
--- a/intern/cycles/render/object.h
+++ b/intern/cycles/render/object.h
@@ -129,4 +129,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __OBJECT_H__ */
-
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index dde622bff8a..fdd872f62b9 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -122,7 +122,7 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
shader->need_update = false;
need_update = false;
-
+
/* set texture system */
scene->image_manager->set_osl_texture_system((void*)ts);
@@ -578,7 +578,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderInput *input)
/* strip whitespace */
while((i = sname.find(" ")) != string::npos)
sname.replace(i, 1, "");
-
+
/* if output exists with the same name, add "In" suffix */
foreach(ShaderOutput *output, node->outputs) {
if(input->name() == output->name()) {
@@ -586,7 +586,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderInput *input)
break;
}
}
-
+
return sname;
}
@@ -598,7 +598,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderOutput *output)
/* strip whitespace */
while((i = sname.find(" ")) != string::npos)
sname.replace(i, 1, "");
-
+
/* if input exists with the same name, add "Out" suffix */
foreach(ShaderInput *input, node->inputs) {
if(input->name() == output->name()) {
@@ -606,7 +606,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderOutput *output)
break;
}
}
-
+
return sname;
}
@@ -614,7 +614,7 @@ bool OSLCompiler::node_skip_input(ShaderNode *node, ShaderInput *input)
{
/* exception for output node, only one input is actually used
* depending on the current shader type */
-
+
if(input->flags() & SocketType::SVM_INTERNAL)
return true;
@@ -704,7 +704,7 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
ss->Shader("displacement", name, id(node).c_str());
else
assert(0);
-
+
/* link inputs to other nodes */
foreach(ShaderInput *input, node->inputs) {
if(input->link) {
@@ -1250,4 +1250,3 @@ void OSLCompiler::parameter_color_array(const char * /*name*/, const array<float
#endif /* WITH_OSL */
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/osl.h b/intern/cycles/render/osl.h
index 7a3208c402a..09d1a54d0b9 100644
--- a/intern/cycles/render/osl.h
+++ b/intern/cycles/render/osl.h
@@ -171,4 +171,3 @@ private:
CCL_NAMESPACE_END
#endif /* __OSL_H__ */
-
diff --git a/intern/cycles/render/particles.cpp b/intern/cycles/render/particles.cpp
index e4be3306d7e..0583556c8a9 100644
--- a/intern/cycles/render/particles.cpp
+++ b/intern/cycles/render/particles.cpp
@@ -61,12 +61,12 @@ void ParticleSystemManager::device_update_particles(Device *, DeviceScene *dscen
int num_particles = 1;
for(size_t j = 0; j < scene->particle_systems.size(); j++)
num_particles += scene->particle_systems[j]->particles.size();
-
+
KernelParticle *kparticles = dscene->particles.alloc(num_particles);
-
+
/* dummy particle */
memset(kparticles, 0, sizeof(KernelParticle));
-
+
int i = 1;
for(size_t j = 0; j < scene->particle_systems.size(); j++) {
ParticleSystem *psys = scene->particle_systems[j];
@@ -74,7 +74,7 @@ void ParticleSystemManager::device_update_particles(Device *, DeviceScene *dscen
for(size_t k = 0; k < psys->particles.size(); k++) {
/* pack in texture */
Particle& pa = psys->particles[k];
-
+
kparticles[i].index = pa.index;
kparticles[i].age = pa.age;
kparticles[i].lifetime = pa.lifetime;
@@ -83,13 +83,13 @@ void ParticleSystemManager::device_update_particles(Device *, DeviceScene *dscen
kparticles[i].location = float3_to_float4(pa.location);
kparticles[i].velocity = float3_to_float4(pa.velocity);
kparticles[i].angular_velocity = float3_to_float4(pa.angular_velocity);
-
+
i++;
-
+
if(progress.get_cancel()) return;
}
}
-
+
dscene->particles.copy_to_device();
}
@@ -105,9 +105,9 @@ void ParticleSystemManager::device_update(Device *device, DeviceScene *dscene, S
progress.set_status("Updating Particle Systems", "Copying Particles to device");
device_update_particles(device, dscene, scene, progress);
-
+
if(progress.get_cancel()) return;
-
+
need_update = false;
}
@@ -122,4 +122,3 @@ void ParticleSystemManager::tag_update(Scene * /*scene*/)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/particles.h b/intern/cycles/render/particles.h
index 66d46114b3e..7e7afd5d054 100644
--- a/intern/cycles/render/particles.h
+++ b/intern/cycles/render/particles.h
@@ -69,4 +69,3 @@ public:
CCL_NAMESPACE_END
#endif /* __PARTICLES_H__ */
-
diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp
index c0f1ae0445e..1d65ef65980 100644
--- a/intern/cycles/render/scene.cpp
+++ b/intern/cycles/render/scene.cpp
@@ -319,7 +319,7 @@ bool Scene::need_global_attribute(AttributeStandard std)
return need_motion() != MOTION_NONE;
else if(std == ATTR_STD_MOTION_VERTEX_NORMAL)
return need_motion() == MOTION_BLUR;
-
+
return false;
}
@@ -380,4 +380,3 @@ void Scene::device_free()
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h
index 6c67433c9fc..713eba623b1 100644
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@ -267,4 +267,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __SCENE_H__ */
-
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index bb636dd962a..d0aa985b035 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -364,7 +364,7 @@ bool Session::acquire_tile(Device *tile_device, RenderTile& rtile)
if(!tile_manager.next_tile(tile, device_num))
return false;
-
+
/* fill render tile */
rtile.x = tile_manager.state.buffer.full_x + tile->x;
rtile.y = tile_manager.state.buffer.full_y + tile->y;
@@ -502,6 +502,9 @@ void Session::map_neighbor_tiles(RenderTile *tiles, Device *tile_device)
assert(tiles[4].buffers);
device->map_neighbor_tiles(tile_device, tiles);
+
+ /* The denoised result is written back to the original tile. */
+ tiles[9] = tiles[4];
}
void Session::unmap_neighbor_tiles(RenderTile *tiles, Device *tile_device)
@@ -913,7 +916,7 @@ void Session::update_status_time(bool show_pause, bool show_done)
substatus = string_printf("Path Tracing Sample %d/%d",
progressive_sample+1,
num_samples);
-
+
if(show_pause) {
status = "Paused";
}
@@ -938,7 +941,7 @@ void Session::render()
/* Add path trace task. */
DeviceTask task(DeviceTask::RENDER);
-
+
task.acquire_tile = function_bind(&Session::acquire_tile, this, _1, _2);
task.release_tile = function_bind(&Session::release_tile, this, _1);
task.map_neighbor_tiles = function_bind(&Session::map_neighbor_tiles, this, _1, _2);
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index e63cad0d977..61f62f8e712 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -237,4 +237,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __SESSION_H__ */
-
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 69f84a62a9f..e428e174712 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -314,7 +314,7 @@ void Shader::tag_update(Scene *scene)
if(has_displacement && displacement_method == DISPLACE_BOTH) {
attributes.add(ATTR_STD_POSITION_UNDISPLACED);
}
-
+
/* compare if the attributes changed, mesh manager will check
* need_update_mesh, update the relevant meshes and clear it. */
if(attributes.modified(prev_attributes)) {
@@ -399,7 +399,7 @@ ShaderManager *ShaderManager::create(Scene *scene, int shadingsystem)
{
manager = new SVMShaderManager();
}
-
+
add_default(scene);
return manager;
@@ -414,7 +414,7 @@ uint ShaderManager::get_attribute_id(ustring name)
if(it != unique_attribute_id.end())
return it->second;
-
+
uint id = (uint)ATTR_STD_NUM + unique_attribute_id.size();
unique_attribute_id[name] = id;
return id;
@@ -433,10 +433,10 @@ int ShaderManager::get_shader_id(Shader *shader, bool smooth)
/* smooth flag */
if(smooth)
id |= SHADER_SMOOTH_NORMAL;
-
+
/* default flags */
id |= SHADER_CAST_SHADOW|SHADER_AREA_LIGHT;
-
+
return id;
}
@@ -697,4 +697,3 @@ float ShaderManager::linear_rgb_to_gray(float3 c)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h
index d787c3b266b..e898d984f5a 100644
--- a/intern/cycles/render/shader.h
+++ b/intern/cycles/render/shader.h
@@ -156,7 +156,7 @@ public:
};
/* Shader Manager virtual base class
- *
+ *
* From this the SVM and OSL shader managers are derived, that do the actual
* shader compiling and device updating. */
@@ -224,4 +224,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __SHADER_H__ */
-
diff --git a/intern/cycles/render/sobol.cpp b/intern/cycles/render/sobol.cpp
index 6906667ac19..01dfafa2ed9 100644
--- a/intern/cycles/render/sobol.cpp
+++ b/intern/cycles/render/sobol.cpp
@@ -7,7 +7,7 @@
* http://web.maths.unsw.edu.au/~fkuo/sobol/
*
* From these papers:
- *
+ *
* S. Joe and F. Y. Kuo, Remark on Algorithm 659: Implementing Sobol's quasirandom
* sequence generator, ACM Trans. Math. Softw. 29, 49-57 (2003)
*
@@ -18,22 +18,22 @@
/* Copyright (c) 2008, Frances Y. Kuo and Stephen Joe
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the names of the copyright holders nor the names of the
* University of New South Wales and the University of Waikato
* and its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -21284,21 +21284,20 @@ void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions
if(L <= s) {
for(uint i = 0; i < L; i++)
- v[i] = m[i] << (31-i);
+ v[i] = m[i] << (31-i);
}
else {
for(uint i = 0; i < s; i++)
- v[i] = m[i] << (31-i);
+ v[i] = m[i] << (31-i);
for(uint i = s; i < L; i++) {
- v[i] = v[i-s] ^ (v[i-s] >> s);
+ v[i] = v[i-s] ^ (v[i-s] >> s);
- for(uint k = 1; k < s; k++)
- v[i] ^= (((a >> (s-1-k)) & 1) * v[i-k]);
+ for(uint k = 1; k < s; k++)
+ v[i] ^= (((a >> (s-1-k)) & 1) * v[i-k]);
}
}
}
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/sobol.h b/intern/cycles/render/sobol.h
index 9fbce4e14a5..d38857d2b35 100644
--- a/intern/cycles/render/sobol.h
+++ b/intern/cycles/render/sobol.h
@@ -29,4 +29,3 @@ void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions
CCL_NAMESPACE_END
#endif /* __SOBOL_H__ */
-
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index 626f160786f..44b7eeec6db 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -71,12 +71,12 @@ void SVMShaderManager::device_update_shader(Scene *scene,
scene->light_manager->need_update = true;
}
- /* The copy needs to be done inside the lock, if another thread resizes the array
- * while memcpy is running, it'll be copying into possibly invalid/freed ram.
+ /* The copy needs to be done inside the lock, if another thread resizes the array
+ * while memcpy is running, it'll be copying into possibly invalid/freed ram.
*/
size_t global_nodes_size = global_svm_nodes->size();
global_svm_nodes->resize(global_nodes_size + svm_nodes.size());
-
+
/* Offset local SVM nodes to a global address space. */
int4& jump_node = (*global_svm_nodes)[shader->id];
jump_node.y = svm_nodes[0].y + global_nodes_size - 1;
@@ -173,7 +173,7 @@ SVMCompiler::SVMCompiler(ShaderManager *shader_manager_,
int SVMCompiler::stack_size(SocketType::Type type)
{
int size = 0;
-
+
switch(type) {
case SocketType::FLOAT:
case SocketType::INT:
@@ -192,14 +192,14 @@ int SVMCompiler::stack_size(SocketType::Type type)
assert(0);
break;
}
-
+
return size;
}
int SVMCompiler::stack_find_offset(int size)
{
int offset = -1;
-
+
/* find free space in stack & mark as used */
for(int i = 0, num_unused = 0; i < SVM_STACK_SIZE; i++) {
if(active_stack.users[i]) num_unused = 0;
@@ -413,7 +413,7 @@ bool SVMCompiler::node_skip_input(ShaderNode * /*node*/, ShaderInput *input)
/* nasty exception .. */
if(current_type == SHADER_TYPE_DISPLACEMENT && input->link && input->link->parent->special_type == SHADER_SPECIAL_TYPE_BUMP)
return true;
-
+
return false;
}
@@ -715,7 +715,7 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
/* get input in output node */
ShaderNode *node = graph->output();
ShaderInput *clin = NULL;
-
+
switch(type) {
case SHADER_TYPE_SURFACE:
clin = node->input("Surface");
@@ -756,9 +756,9 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
if(shader->used) {
if(clin->link) {
bool generate = false;
-
+
switch(type) {
- case SHADER_TYPE_SURFACE: /* generate surface shader */
+ case SHADER_TYPE_SURFACE: /* generate surface shader */
generate = true;
shader->has_surface = true;
break;
@@ -936,4 +936,3 @@ SVMCompiler::CompilerState::CompilerState(ShaderGraph *graph)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/svm.h b/intern/cycles/render/svm.h
index 7cf1e4ad791..1d0613bbfdc 100644
--- a/intern/cycles/render/svm.h
+++ b/intern/cycles/render/svm.h
@@ -224,4 +224,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __SVM_H__ */
-
diff --git a/intern/cycles/render/tables.cpp b/intern/cycles/render/tables.cpp
index 536fdd0775e..ddbb138f059 100644
--- a/intern/cycles/render/tables.cpp
+++ b/intern/cycles/render/tables.cpp
@@ -115,4 +115,3 @@ void LookupTables::remove_table(size_t *offset)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/tables.h b/intern/cycles/render/tables.h
index bc261c2a74d..09d961a9c3c 100644
--- a/intern/cycles/render/tables.h
+++ b/intern/cycles/render/tables.h
@@ -51,4 +51,3 @@ public:
CCL_NAMESPACE_END
#endif /* __TABLES_H__ */
-
diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp
index a388f5dfc8b..dc863b067b0 100644
--- a/intern/cycles/render/tile.cpp
+++ b/intern/cycles/render/tile.cpp
@@ -535,4 +535,3 @@ int TileManager::get_num_effective_samples()
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/render/tile.h b/intern/cycles/render/tile.h
index 2692c7cf9f0..f72f653f4c2 100644
--- a/intern/cycles/render/tile.h
+++ b/intern/cycles/render/tile.h
@@ -155,4 +155,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __TILE_H__ */
-
diff --git a/intern/cycles/subd/subd_dice.cpp b/intern/cycles/subd/subd_dice.cpp
index 8c426da4acf..c5ac54cfcc8 100644
--- a/intern/cycles/subd/subd_dice.cpp
+++ b/intern/cycles/subd/subd_dice.cpp
@@ -348,4 +348,3 @@ void QuadDice::dice(SubPatch& sub, EdgeFactors& ef)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/subd/subd_dice.h b/intern/cycles/subd/subd_dice.h
index c0e32be18c4..4617c782b3a 100644
--- a/intern/cycles/subd/subd_dice.h
+++ b/intern/cycles/subd/subd_dice.h
@@ -81,7 +81,7 @@ public:
* Edge tessellation factors and subpatch coordinates are as follows:
*
* tu1
- * P01 --------- P11
+ * P01 --------- P11
* | |
* tv0 | | tv1
* | |
@@ -135,4 +135,3 @@ public:
CCL_NAMESPACE_END
#endif /* __SUBD_DICE_H__ */
-
diff --git a/intern/cycles/subd/subd_patch.cpp b/intern/cycles/subd/subd_patch.cpp
index fa2fe2bf113..f8f5aa25d19 100644
--- a/intern/cycles/subd/subd_patch.cpp
+++ b/intern/cycles/subd/subd_patch.cpp
@@ -80,7 +80,7 @@ BoundBox LinearQuadPatch::bound()
for(int i = 0; i < 4; i++)
bbox.grow(hull[i]);
-
+
return bbox;
}
@@ -110,9 +110,8 @@ BoundBox BicubicPatch::bound()
for(int i = 0; i < 16; i++)
bbox.grow(hull[i]);
-
+
return bbox;
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/subd/subd_patch.h b/intern/cycles/subd/subd_patch.h
index 1bb81588835..64ec8f70951 100644
--- a/intern/cycles/subd/subd_patch.h
+++ b/intern/cycles/subd/subd_patch.h
@@ -57,4 +57,3 @@ public:
CCL_NAMESPACE_END
#endif /* __SUBD_PATCH_H__ */
-
diff --git a/intern/cycles/subd/subd_patch_table.cpp b/intern/cycles/subd/subd_patch_table.cpp
index 63bf673a90b..13a6f284542 100644
--- a/intern/cycles/subd/subd_patch_table.cpp
+++ b/intern/cycles/subd/subd_patch_table.cpp
@@ -294,4 +294,3 @@ void PackedPatchTable::copy_adjusting_offsets(uint* dest, int doffset)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/subd/subd_patch_table.h b/intern/cycles/subd/subd_patch_table.h
index 907f2dd6c28..45be7051992 100644
--- a/intern/cycles/subd/subd_patch_table.h
+++ b/intern/cycles/subd/subd_patch_table.h
@@ -60,4 +60,3 @@ struct PackedPatchTable {
CCL_NAMESPACE_END
#endif /* __SUBD_PATCH_TABLE_H__ */
-
diff --git a/intern/cycles/subd/subd_split.cpp b/intern/cycles/subd/subd_split.cpp
index d3bed6a5c53..76261243359 100644
--- a/intern/cycles/subd/subd_split.cpp
+++ b/intern/cycles/subd/subd_split.cpp
@@ -86,7 +86,7 @@ int DiagSplit::T(Patch *patch, float2 Pstart, float2 Pend)
if(tmax - tmin > params.split_threshold)
return DSPLIT_NON_UNIFORM;
-
+
return tmax;
}
@@ -258,4 +258,3 @@ void DiagSplit::split_quad(Patch *patch, QuadDice::SubPatch *subpatch)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/subd/subd_split.h b/intern/cycles/subd/subd_split.h
index f869cc6a48e..7a276b35382 100644
--- a/intern/cycles/subd/subd_split.h
+++ b/intern/cycles/subd/subd_split.h
@@ -57,4 +57,3 @@ public:
CCL_NAMESPACE_END
#endif /* __SUBD_SPLIT_H__ */
-
diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt
index 3b690860d53..508f44e7c4d 100644
--- a/intern/cycles/util/CMakeLists.txt
+++ b/intern/cycles/util/CMakeLists.txt
@@ -116,6 +116,7 @@ set(SRC_HEADERS
util_types_uint3_impl.h
util_types_uint4.h
util_types_uint4_impl.h
+ util_types_ushort4.h
util_types_vector3.h
util_types_vector3_impl.h
util_vector.h
diff --git a/intern/cycles/util/util_algorithm.h b/intern/cycles/util/util_algorithm.h
index 5c79c00cc98..eb874713d43 100644
--- a/intern/cycles/util/util_algorithm.h
+++ b/intern/cycles/util/util_algorithm.h
@@ -30,4 +30,3 @@ using std::remove;
CCL_NAMESPACE_END
#endif /* __UTIL_ALGORITHM_H__ */
-
diff --git a/intern/cycles/util/util_args.h b/intern/cycles/util/util_args.h
index a53fc061758..be6f2c2b9f1 100644
--- a/intern/cycles/util/util_args.h
+++ b/intern/cycles/util/util_args.h
@@ -29,4 +29,3 @@ OIIO_NAMESPACE_USING
CCL_NAMESPACE_END
#endif /* __UTIL_ARGS_H__ */
-
diff --git a/intern/cycles/util/util_boundbox.h b/intern/cycles/util/util_boundbox.h
index ed94ca20211..b1bd5be0df3 100644
--- a/intern/cycles/util/util_boundbox.h
+++ b/intern/cycles/util/util_boundbox.h
@@ -55,7 +55,7 @@ public:
{
}
- __forceinline void grow(const float3& pt)
+ __forceinline void grow(const float3& pt)
{
/* the order of arguments to min is such that if pt is nan, it will not
* influence the resulting bounding box */
@@ -63,7 +63,7 @@ public:
max = ccl::max(pt, max);
}
- __forceinline void grow(const float3& pt, float border)
+ __forceinline void grow(const float3& pt, float border)
{
float3 shift = make_float3(border, border, border);
min = ccl::min(pt - shift, min);
@@ -76,7 +76,7 @@ public:
grow(bbox.max);
}
- __forceinline void grow_safe(const float3& pt)
+ __forceinline void grow_safe(const float3& pt)
{
/* the order of arguments to min is such that if pt is nan, it will not
* influence the resulting bounding box */
@@ -86,7 +86,7 @@ public:
}
}
- __forceinline void grow_safe(const float3& pt, float border)
+ __forceinline void grow_safe(const float3& pt, float border)
{
if(isfinite(pt.x) && isfinite(pt.y) && isfinite(pt.z) && isfinite(border)) {
float3 shift = make_float3(border, border, border);
@@ -101,7 +101,7 @@ public:
grow_safe(bbox.max);
}
- __forceinline void intersect(const BoundBox& bbox)
+ __forceinline void intersect(const BoundBox& bbox)
{
min = ccl::max(min, bbox.min);
max = ccl::min(max, bbox.max);
@@ -283,4 +283,3 @@ public:
CCL_NAMESPACE_END
#endif /* __UTIL_BOUNDBOX_H__ */
-
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index 62a9bf8e47d..826db469d25 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -241,4 +241,3 @@ ccl_device float4 color_srgb_to_linear_v4(float4 c)
CCL_NAMESPACE_END
#endif /* __UTIL_COLOR_H__ */
-
diff --git a/intern/cycles/util/util_defines.h b/intern/cycles/util/util_defines.h
index 98944a19022..d994d4e08f4 100644
--- a/intern/cycles/util/util_defines.h
+++ b/intern/cycles/util/util_defines.h
@@ -133,4 +133,3 @@ template<typename T> static inline T decltype_helper(T x) { return x; }
#endif
#endif /* __UTIL_DEFINES_H__ */
-
diff --git a/intern/cycles/util/util_foreach.h b/intern/cycles/util/util_foreach.h
index 4f7337107b3..03fcefc67b9 100644
--- a/intern/cycles/util/util_foreach.h
+++ b/intern/cycles/util/util_foreach.h
@@ -27,4 +27,3 @@
#endif
#endif /* __UTIL_FOREACH_H__ */
-
diff --git a/intern/cycles/util/util_function.h b/intern/cycles/util/util_function.h
index 6d0f0b444a9..958f8b4008c 100644
--- a/intern/cycles/util/util_function.h
+++ b/intern/cycles/util/util_function.h
@@ -47,4 +47,3 @@ using boost::function;
CCL_NAMESPACE_END
#endif /* __UTIL_FUNCTION_H__ */
-
diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h
index 612228dd1c1..53b7f2472bd 100644
--- a/intern/cycles/util/util_half.h
+++ b/intern/cycles/util/util_half.h
@@ -36,7 +36,16 @@ CCL_NAMESPACE_BEGIN
/* CUDA has its own half data type, no need to define then */
#ifndef __KERNEL_CUDA__
-typedef unsigned short half;
+/* Implementing this as a class rather than a typedef so that the compiler can tell it apart from unsigned shorts. */
+class half {
+public:
+ half() : v(0) {}
+ half(const unsigned short& i) : v(i) {}
+ operator unsigned short() { return v; }
+ half& operator =(const unsigned short& i) { v = i; return *this; }
+private:
+ unsigned short v;
+};
#endif
struct half4 { half x, y, z, w; };
@@ -140,4 +149,3 @@ ccl_device_inline half float_to_half(float f)
CCL_NAMESPACE_END
#endif /* __UTIL_HALF_H__ */
-
diff --git a/intern/cycles/util/util_hash.h b/intern/cycles/util/util_hash.h
index 2307ca158f0..a8a5076fbb3 100644
--- a/intern/cycles/util/util_hash.h
+++ b/intern/cycles/util/util_hash.h
@@ -69,4 +69,3 @@ ccl_device_inline float hash_int_01(uint k)
CCL_NAMESPACE_END
#endif /* __UTIL_HASH_H__ */
-
diff --git a/intern/cycles/util/util_image.h b/intern/cycles/util/util_image.h
index 18876841b5b..85bdb0d8050 100644
--- a/intern/cycles/util/util_image.h
+++ b/intern/cycles/util/util_image.h
@@ -38,6 +38,68 @@ void util_image_resize_pixels(const vector<T>& input_pixels,
size_t *output_height,
size_t *output_depth);
+/* Cast input pixel from unknown storage to float. */
+template<typename T>
+inline float util_image_cast_to_float(T value);
+
+template<>
+inline float util_image_cast_to_float(float value)
+{
+ return value;
+}
+template<>
+inline float util_image_cast_to_float(uchar value)
+{
+ return (float)value / 255.0f;
+}
+template<>
+inline float util_image_cast_to_float(uint16_t value)
+{
+ return (float)value / 65535.0f;
+}
+template<>
+inline float util_image_cast_to_float(half value)
+{
+ return half_to_float(value);
+}
+
+/* Cast float value to output pixel type. */
+template<typename T>
+inline T util_image_cast_from_float(float value);
+
+template<>
+inline float util_image_cast_from_float(float value)
+{
+ return value;
+}
+template<>
+inline uchar util_image_cast_from_float(float value)
+{
+ if(value < 0.0f) {
+ return 0;
+ }
+ else if(value > (1.0f - 0.5f / 255.0f)) {
+ return 255;
+ }
+ return (uchar)((255.0f * value) + 0.5f);
+}
+template<>
+inline uint16_t util_image_cast_from_float(float value)
+{
+ if(value < 0.0f) {
+ return 0;
+ }
+ else if(value > (1.0f - 0.5f / 65535.0f)) {
+ return 65535;
+ }
+ return (uint16_t)((65535.0f * value) + 0.5f);
+}
+template<>
+inline half util_image_cast_from_float(float value)
+{
+ return float_to_half(value);
+}
+
CCL_NAMESPACE_END
#endif /* __UTIL_IMAGE_H__ */
diff --git a/intern/cycles/util/util_image_impl.h b/intern/cycles/util/util_image_impl.h
index 751f52aaa86..5bc1c727595 100644
--- a/intern/cycles/util/util_image_impl.h
+++ b/intern/cycles/util/util_image_impl.h
@@ -38,52 +38,6 @@ const T *util_image_read(const vector<T>& pixels,
return &pixels[index];
}
-/* Cast input pixel from unknown storage to float. */
-template<typename T>
-inline float cast_to_float(T value);
-
-template<>
-inline float cast_to_float(float value)
-{
- return value;
-}
-template<>
-inline float cast_to_float(uchar value)
-{
- return (float)value / 255.0f;
-}
-template<>
-inline float cast_to_float(half value)
-{
- return half_to_float(value);
-}
-
-/* Cast float value to output pixel type. */
-template<typename T>
-inline T cast_from_float(float value);
-
-template<>
-inline float cast_from_float(float value)
-{
- return value;
-}
-template<>
-inline uchar cast_from_float(float value)
-{
- if(value < 0.0f) {
- return 0;
- }
- else if(value > (1.0f - 0.5f / 255.0f)) {
- return 255;
- }
- return (uchar)((255.0f * value) + 0.5f);
-}
-template<>
-inline half cast_from_float(float value)
-{
- return float_to_half(value);
-}
-
template<typename T>
void util_image_downscale_sample(const vector<T>& pixels,
const size_t width,
@@ -117,7 +71,7 @@ void util_image_downscale_sample(const vector<T>& pixels,
components,
nx, ny, nz);
for(size_t k = 0; k < components; ++k) {
- accum[k] += cast_to_float(pixel[k]);
+ accum[k] += util_image_cast_to_float(pixel[k]);
}
++count;
}
@@ -126,7 +80,7 @@ void util_image_downscale_sample(const vector<T>& pixels,
if(count != 0) {
const float inv_count = 1.0f / (float)count;
for(size_t k = 0; k < components; ++k) {
- result[k] = cast_from_float<T>(accum[k] * inv_count);
+ result[k] = util_image_cast_from_float<T>(accum[k] * inv_count);
}
}
else {
diff --git a/intern/cycles/util/util_list.h b/intern/cycles/util/util_list.h
index 6cb27e6defe..f555b001186 100644
--- a/intern/cycles/util/util_list.h
+++ b/intern/cycles/util/util_list.h
@@ -26,4 +26,3 @@ using std::list;
CCL_NAMESPACE_END
#endif /* __UTIL_LIST_H__ */
-
diff --git a/intern/cycles/util/util_map.h b/intern/cycles/util/util_map.h
index 46c2885f8b0..b3d887f093c 100644
--- a/intern/cycles/util/util_map.h
+++ b/intern/cycles/util/util_map.h
@@ -54,4 +54,3 @@ using std::unordered_map;
CCL_NAMESPACE_END
#endif /* __UTIL_MAP_H__ */
-
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index fd3199f209f..52aeb8d8599 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -55,6 +55,15 @@ CCL_NAMESPACE_BEGIN
#ifndef M_2_PI_F
# define M_2_PI_F (0.6366197723675813f) /* 2/pi */
#endif
+#ifndef M_1_2PI_F
+# define M_1_2PI_F (0.1591549430918953f) /* 1/(2*pi) */
+#endif
+#ifndef M_SQRT_PI_8_F
+# define M_SQRT_PI_8_F (0.6266570686577501f) /* sqrt(pi/8) */
+#endif
+#ifndef M_LN_2PI_F
+# define M_LN_2PI_F (1.8378770664093454f) /* ln(2*pi) */
+#endif
/* Multiplication */
#ifndef M_2PI_F
@@ -266,6 +275,11 @@ ccl_device_inline int floor_to_int(float f)
return float_to_int(floorf(f));
}
+ccl_device_inline int quick_floor_to_int(float x)
+{
+ return float_to_int(x) - ((x < 0) ? 1 : 0);
+}
+
ccl_device_inline int ceil_to_int(float f)
{
return float_to_int(ceilf(f));
@@ -536,6 +550,16 @@ ccl_device_inline float sqr(float a)
return a * a;
}
+ccl_device_inline float pow20(float a)
+{
+ return sqr(sqr(sqr(sqr(a))*a));
+}
+
+ccl_device_inline float pow22(float a)
+{
+ return sqr(a*sqr(sqr(sqr(a))*a));
+}
+
ccl_device_inline float beta(float x, float y)
{
#ifndef __KERNEL_OPENCL__
@@ -550,6 +574,11 @@ ccl_device_inline float xor_signmask(float x, int y)
return __int_as_float(__float_as_int(x) ^ y);
}
+ccl_device float bits_to_01(uint bits)
+{
+ return bits * (1.0f/(float)0xFFFFFFFF);
+}
+
/* projections */
ccl_device_inline float2 map_to_tube(const float3 co)
{
diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h
index f5149fe13ed..ba1c117cdea 100644
--- a/intern/cycles/util/util_math_float3.h
+++ b/intern/cycles/util/util_math_float3.h
@@ -280,6 +280,11 @@ ccl_device_inline float3 sqrt(const float3& a)
#endif
}
+ccl_device_inline float3 pow3(const float3& a, float e)
+{
+ return make_float3(powf(a.x, e), powf(a.y, e), powf(a.z, e));
+}
+
ccl_device_inline float3 mix(const float3& a, const float3& b, float t)
{
return a + t*(b - a);
@@ -377,6 +382,28 @@ ccl_device_inline bool isequal_float3(const float3 a, const float3 b)
#endif
}
+ccl_device_inline float3 exp3(float3 v)
+{
+ return make_float3(expf(v.x), expf(v.y), expf(v.z));
+}
+
+ccl_device_inline float3 log3(float3 v)
+{
+ return make_float3(logf(v.x), logf(v.y), logf(v.z));
+}
+
+ccl_device_inline int3 quick_floor_to_int3(const float3 a)
+{
+#ifdef __KERNEL_SSE__
+ int3 b = int3(_mm_cvttps_epi32(a.m128));
+ int3 isneg = int3(_mm_castps_si128(_mm_cmplt_ps(a.m128, _mm_set_ps1(0.0f))));
+ /* Unsaturated add 0xffffffff is the same as subtract -1. */
+ return b + isneg;
+#else
+ return make_int3(quick_floor_to_int(a.x), quick_floor_to_int(a.y), quick_floor_to_int(a.z));
+#endif
+}
+
ccl_device_inline bool isfinite3_safe(float3 v)
{
return isfinite_safe(v.x) && isfinite_safe(v.y) && isfinite_safe(v.z);
diff --git a/intern/cycles/util/util_math_int3.h b/intern/cycles/util/util_math_int3.h
index 6eef8517665..81b10f31f4a 100644
--- a/intern/cycles/util/util_math_int3.h
+++ b/intern/cycles/util/util_math_int3.h
@@ -91,6 +91,24 @@ ccl_device_inline bool operator<(const int3 &a, const int3 &b)
{
return a.x < b.x && a.y < b.y && a.z < b.z;
}
+
+ccl_device_inline int3 operator+(const int3 &a, const int3 &b)
+{
+#ifdef __KERNEL_SSE__
+ return int3(_mm_add_epi32(a.m128, b.m128));
+#else
+ return make_int3(a.x + b.x, a.y + b.y, a.z + b.z);
+#endif
+}
+
+ccl_device_inline int3 operator-(const int3 &a, const int3 &b)
+{
+#ifdef __KERNEL_SSE__
+ return int3(_mm_sub_epi32(a.m128, b.m128));
+#else
+ return make_int3(a.x - b.x, a.y - b.y, a.z - b.z);
+#endif
+}
#endif /* !__KERNEL_OPENCL__ */
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_md5.cpp b/intern/cycles/util/util_md5.cpp
index 749760d84f0..7cdd28a4793 100644
--- a/intern/cycles/util/util_md5.cpp
+++ b/intern/cycles/util/util_md5.cpp
@@ -338,7 +338,7 @@ bool MD5Hash::append_file(const string& filepath)
bool success = (ferror(f) == 0);
fclose(f);
-
+
return success;
}
@@ -376,7 +376,7 @@ string MD5Hash::get_hex()
for(int i = 0; i < 16; i++)
sprintf(buf + i*2, "%02X", (unsigned int)digest[i]);
buf[sizeof(buf)-1] = '\0';
-
+
return string(buf);
}
@@ -388,4 +388,3 @@ string util_md5_string(const string& str)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_md5.h b/intern/cycles/util/util_md5.h
index b043b591e67..9023ccee4c2 100644
--- a/intern/cycles/util/util_md5.h
+++ b/intern/cycles/util/util_md5.h
@@ -59,4 +59,3 @@ string util_md5_string(const string& str);
CCL_NAMESPACE_END
#endif /* __UTIL_MD5_H__ */
-
diff --git a/intern/cycles/util/util_optimization.h b/intern/cycles/util/util_optimization.h
index 3c5785c4807..3b3627242d5 100644
--- a/intern/cycles/util/util_optimization.h
+++ b/intern/cycles/util/util_optimization.h
@@ -69,4 +69,3 @@
#endif
#endif /* __UTIL_OPTIMIZATION_H__ */
-
diff --git a/intern/cycles/util/util_param.h b/intern/cycles/util/util_param.h
index 69bcbf80a78..246b5cb7d63 100644
--- a/intern/cycles/util/util_param.h
+++ b/intern/cycles/util/util_param.h
@@ -31,4 +31,3 @@ OIIO_NAMESPACE_USING
CCL_NAMESPACE_END
#endif /* __UTIL_PARAM_H__ */
-
diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp
index 0e0371928ab..51b7944705e 100644
--- a/intern/cycles/util/util_path.cpp
+++ b/intern/cycles/util/util_path.cpp
@@ -987,4 +987,3 @@ void path_cache_clear_except(const string& name, const set<string>& except)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_path.h b/intern/cycles/util/util_path.h
index 0e5e2d2c837..738dba94647 100644
--- a/intern/cycles/util/util_path.h
+++ b/intern/cycles/util/util_path.h
@@ -76,4 +76,3 @@ void path_cache_clear_except(const string& name, const set<string>& except);
CCL_NAMESPACE_END
#endif
-
diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h
index 134383e88db..3ef15c5c09a 100644
--- a/intern/cycles/util/util_progress.h
+++ b/intern/cycles/util/util_progress.h
@@ -366,4 +366,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __UTIL_PROGRESS_H__ */
-
diff --git a/intern/cycles/util/util_projection.h b/intern/cycles/util/util_projection.h
index dbcb9877a48..26b4843928c 100644
--- a/intern/cycles/util/util_projection.h
+++ b/intern/cycles/util/util_projection.h
@@ -174,4 +174,3 @@ ccl_device_inline ProjectionTransform projection_orthographic(float znear, float
CCL_NAMESPACE_END
#endif /* __UTIL_PROJECTION_H__ */
-
diff --git a/intern/cycles/util/util_queue.h b/intern/cycles/util/util_queue.h
index f4c802785f9..622f4fe3e47 100644
--- a/intern/cycles/util/util_queue.h
+++ b/intern/cycles/util/util_queue.h
@@ -26,4 +26,3 @@ using std::queue;
CCL_NAMESPACE_END
#endif /* __UTIL_LIST_H__ */
-
diff --git a/intern/cycles/util/util_rect.h b/intern/cycles/util/util_rect.h
index 17a55a14d0b..d13baefe85e 100644
--- a/intern/cycles/util/util_rect.h
+++ b/intern/cycles/util/util_rect.h
@@ -70,4 +70,3 @@ ccl_device_inline int rect_size(int4 rect)
CCL_NAMESPACE_END
#endif /* __UTIL_RECT_H__ */
-
diff --git a/intern/cycles/util/util_set.h b/intern/cycles/util/util_set.h
index c19fa071b37..1d010e19996 100644
--- a/intern/cycles/util/util_set.h
+++ b/intern/cycles/util/util_set.h
@@ -60,4 +60,3 @@ using std::unordered_set;
CCL_NAMESPACE_END
#endif /* __UTIL_SET_H__ */
-
diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h
index 04341451afb..cc7f436c8fe 100644
--- a/intern/cycles/util/util_simd.h
+++ b/intern/cycles/util/util_simd.h
@@ -111,7 +111,7 @@ __forceinline size_t __popcnt(size_t in) {
#endif
__forceinline int __bsf(int v) {
-#if defined(__KERNEL_AVX2__)
+#if defined(__KERNEL_AVX2__)
return _tzcnt_u32(v);
#else
unsigned long r = 0; _BitScanForward(&r,v); return r;
@@ -119,7 +119,7 @@ __forceinline int __bsf(int v) {
}
__forceinline unsigned int __bsf(unsigned int v) {
-#if defined(__KERNEL_AVX2__)
+#if defined(__KERNEL_AVX2__)
return _tzcnt_u32(v);
#else
unsigned long r = 0; _BitScanForward(&r,v); return r;
@@ -143,7 +143,7 @@ __forceinline int __btr(int v, int i) {
}
__forceinline int bitscan(int v) {
-#if defined(__KERNEL_AVX2__)
+#if defined(__KERNEL_AVX2__)
return _tzcnt_u32(v);
#else
return __bsf(v);
@@ -156,18 +156,18 @@ __forceinline int clz(const int x)
return _lzcnt_u32(x);
#else
if(UNLIKELY(x == 0)) return 32;
- return 31 - __bsr(x);
+ return 31 - __bsr(x);
#endif
}
-__forceinline int __bscf(int& v)
+__forceinline int __bscf(int& v)
{
int i = __bsf(v);
v &= v-1;
return i;
}
-__forceinline unsigned int __bscf(unsigned int& v)
+__forceinline unsigned int __bscf(unsigned int& v)
{
unsigned int i = __bsf(v);
v &= v-1;
@@ -177,7 +177,7 @@ __forceinline unsigned int __bscf(unsigned int& v)
#if defined(__KERNEL_64_BIT__)
__forceinline size_t __bsf(size_t v) {
-#if defined(__KERNEL_AVX2__)
+#if defined(__KERNEL_AVX2__)
return _tzcnt_u64(v);
#else
unsigned long r = 0; _BitScanForward64(&r,v); return r;
@@ -212,7 +212,7 @@ __forceinline size_t bitscan(size_t v) {
#endif
}
-__forceinline size_t __bscf(size_t& v)
+__forceinline size_t __bscf(size_t& v)
{
size_t i = __bsf(v);
v &= v-1;
@@ -274,7 +274,7 @@ __forceinline size_t __btr(size_t v, size_t i) {
}
__forceinline int bitscan(int v) {
-#if defined(__KERNEL_AVX2__)
+#if defined(__KERNEL_AVX2__)
return _tzcnt_u32(v);
#else
return __bsf(v);
@@ -282,7 +282,7 @@ __forceinline int bitscan(int v) {
}
__forceinline unsigned int bitscan(unsigned int v) {
-#if defined(__KERNEL_AVX2__)
+#if defined(__KERNEL_AVX2__)
return _tzcnt_u32(v);
#else
return __bsf(v);
@@ -309,11 +309,11 @@ __forceinline int clz(const int x)
return _lzcnt_u32(x);
#else
if(UNLIKELY(x == 0)) return 32;
- return 31 - __bsr(x);
+ return 31 - __bsr(x);
#endif
}
-__forceinline int __bscf(int& v)
+__forceinline int __bscf(int& v)
{
int i = bitscan(v);
#if defined(__KERNEL_AVX2__)
@@ -324,7 +324,7 @@ __forceinline int __bscf(int& v)
return i;
}
-__forceinline unsigned int __bscf(unsigned int& v)
+__forceinline unsigned int __bscf(unsigned int& v)
{
unsigned int i = bitscan(v);
v &= v-1;
@@ -332,7 +332,7 @@ __forceinline unsigned int __bscf(unsigned int& v)
}
#if (defined(__KERNEL_64_BIT__) || defined(__APPLE__)) && !(defined(__ILP32__) && defined(__x86_64__))
-__forceinline size_t __bscf(size_t& v)
+__forceinline size_t __bscf(size_t& v)
{
size_t i = bitscan(v);
#if defined(__KERNEL_AVX2__)
@@ -375,28 +375,28 @@ __forceinline __m128 _mm_blendv_ps_emu( __m128 value, __m128 input, __m128 mask)
#define _mm_blend_ps _mm_blend_ps_emu
__forceinline __m128 _mm_blend_ps_emu( __m128 value, __m128 input, const int mask)
{
- assert(mask < 0x10); return _mm_blendv_ps(value, input, _mm_lookupmask_ps[mask]);
+ assert(mask < 0x10); return _mm_blendv_ps(value, input, _mm_lookupmask_ps[mask]);
}
#undef _mm_blendv_epi8
#define _mm_blendv_epi8 _mm_blendv_epi8_emu
__forceinline __m128i _mm_blendv_epi8_emu( __m128i value, __m128i input, __m128i mask)
{
- return _mm_or_si128(_mm_and_si128(mask, input), _mm_andnot_si128(mask, value));
+ return _mm_or_si128(_mm_and_si128(mask, input), _mm_andnot_si128(mask, value));
}
#undef _mm_min_epi32
#define _mm_min_epi32 _mm_min_epi32_emu
__forceinline __m128i _mm_min_epi32_emu( __m128i value, __m128i input)
{
- return _mm_blendv_epi8(input, value, _mm_cmplt_epi32(value, input));
+ return _mm_blendv_epi8(input, value, _mm_cmplt_epi32(value, input));
}
#undef _mm_max_epi32
#define _mm_max_epi32 _mm_max_epi32_emu
__forceinline __m128i _mm_max_epi32_emu( __m128i value, __m128i input)
{
- return _mm_blendv_epi8(value, input, _mm_cmplt_epi32(value, input));
+ return _mm_blendv_epi8(value, input, _mm_cmplt_epi32(value, input));
}
#undef _mm_extract_epi32
@@ -416,7 +416,7 @@ __forceinline int _mm_extract_epi32_emu( __m128i input, const int index)
#define _mm_insert_epi32 _mm_insert_epi32_emu
__forceinline __m128i _mm_insert_epi32_emu( __m128i value, int input, const int index)
{
- assert(index >= 0 && index < 4); ((int*)&value)[index] = input; return value;
+ assert(index >= 0 && index < 4); ((int*)&value)[index] = input; return value;
}
#undef _mm_insert_ps
@@ -487,4 +487,3 @@ CCL_NAMESPACE_END
#endif /* __KERNEL_GPU__ */
#endif /* __UTIL_SIMD_TYPES_H__ */
-
diff --git a/intern/cycles/util/util_sky_model.cpp b/intern/cycles/util/util_sky_model.cpp
index 6dda8469907..526bce4ff88 100644
--- a/intern/cycles/util/util_sky_model.cpp
+++ b/intern/cycles/util/util_sky_model.cpp
@@ -367,4 +367,3 @@ ArHosekSkyModelState * arhosek_xyz_skymodelstate_alloc_init(
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_sseb.h b/intern/cycles/util/util_sseb.h
index 977976c3fc0..115b133c662 100644
--- a/intern/cycles/util/util_sseb.h
+++ b/intern/cycles/util/util_sseb.h
@@ -38,7 +38,7 @@ struct sseb
////////////////////////////////////////////////////////////////////////////////
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
-
+
__forceinline sseb ( ) {}
__forceinline sseb ( const sseb& other ) { m128 = other.m128; }
__forceinline sseb& operator=( const sseb& other ) { m128 = other.m128; return *this; }
@@ -47,10 +47,10 @@ struct sseb
__forceinline operator const __m128&( void ) const { return m128; }
__forceinline operator const __m128i( void ) const { return _mm_castps_si128(m128); }
__forceinline operator const __m128d( void ) const { return _mm_castps_pd(m128); }
-
+
__forceinline sseb ( bool a )
: m128(_mm_lookupmask_ps[(size_t(a) << 3) | (size_t(a) << 2) | (size_t(a) << 1) | size_t(a)]) {}
- __forceinline sseb ( bool a, bool b)
+ __forceinline sseb ( bool a, bool b)
: m128(_mm_lookupmask_ps[(size_t(b) << 3) | (size_t(a) << 2) | (size_t(b) << 1) | size_t(a)]) {}
__forceinline sseb ( bool a, bool b, bool c, bool d)
: m128(_mm_lookupmask_ps[(size_t(d) << 3) | (size_t(c) << 2) | (size_t(b) << 1) | size_t(a)]) {}
@@ -103,11 +103,11 @@ __forceinline const sseb operator ^=( sseb& a, const sseb& b ) { return a = a ^
__forceinline const sseb operator !=( const sseb& a, const sseb& b ) { return _mm_xor_ps(a, b); }
__forceinline const sseb operator ==( const sseb& a, const sseb& b ) { return _mm_castsi128_ps(_mm_cmpeq_epi32(a, b)); }
-__forceinline const sseb select( const sseb& m, const sseb& t, const sseb& f ) {
+__forceinline const sseb select( const sseb& m, const sseb& t, const sseb& f ) {
#if defined(__KERNEL_SSE41__)
- return _mm_blendv_ps(f, t, m);
+ return _mm_blendv_ps(f, t, m);
#else
- return _mm_or_ps(_mm_and_ps(m, t), _mm_andnot_ps(m, f));
+ return _mm_or_ps(_mm_and_ps(m, t), _mm_andnot_ps(m, f));
#endif
}
@@ -186,4 +186,3 @@ ccl_device_inline void print_sseb(const char *label, const sseb &a)
CCL_NAMESPACE_END
#endif
-
diff --git a/intern/cycles/util/util_ssef.h b/intern/cycles/util/util_ssef.h
index e9a617bb2cc..b5623860e33 100644
--- a/intern/cycles/util/util_ssef.h
+++ b/intern/cycles/util/util_ssef.h
@@ -31,14 +31,14 @@ struct ssef
typedef sseb Mask; // mask type
typedef ssei Int; // int type
typedef ssef Float; // float type
-
+
enum { size = 4 }; // number of SIMD elements
union { __m128 m128; float f[4]; int i[4]; }; // data
////////////////////////////////////////////////////////////////////////////////
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
-
+
__forceinline ssef () {}
__forceinline ssef (const ssef& other) { m128 = other.m128; }
__forceinline ssef& operator=(const ssef& other) { m128 = other.m128; return *this; }
@@ -143,7 +143,7 @@ __forceinline ssef mini(const ssef& a, const ssef& b) {
return _mm_castsi128_ps(ci);
}
#endif
-
+
#if defined(__KERNEL_SSE41__)
__forceinline ssef maxi(const ssef& a, const ssef& b) {
const ssei ai = _mm_castps_si128(a);
@@ -229,7 +229,7 @@ __forceinline const ssef select(const ssef& m, const ssef& t, const ssef& f) {
#endif
}
-__forceinline const ssef select(const int mask, const ssef& t, const ssef& f) {
+__forceinline const ssef select(const int mask, const ssef& t, const ssef& f) {
#if defined(__KERNEL_SSE41__) && ((!defined(__clang__) && !defined(_MSC_VER)) || defined(__INTEL_COMPILER))
return _mm_blend_ps(f, t, mask);
#else
@@ -298,8 +298,8 @@ template<> __forceinline const ssef shuffle<2, 3, 2, 3>(const ssef& a, const sse
}
#if defined(__KERNEL_SSSE3__)
-__forceinline const ssef shuffle8(const ssef& a, const ssei& shuf) {
- return _mm_castsi128_ps(_mm_shuffle_epi8(_mm_castps_si128(a), shuf));
+__forceinline const ssef shuffle8(const ssef& a, const ssei& shuf) {
+ return _mm_castsi128_ps(_mm_shuffle_epi8(_mm_castps_si128(a), shuf));
}
#endif
@@ -333,7 +333,7 @@ template<size_t dst> __forceinline const ssef insert(const ssef& a,
/// Transpose
////////////////////////////////////////////////////////////////////////////////
-__forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, const ssef& r3, ssef& c0, ssef& c1, ssef& c2, ssef& c3)
+__forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, const ssef& r3, ssef& c0, ssef& c1, ssef& c2, ssef& c3)
{
ssef l02 = unpacklo(r0,r2);
ssef h02 = unpackhi(r0,r2);
@@ -345,7 +345,7 @@ __forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, con
c3 = unpackhi(h02,h13);
}
-__forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, const ssef& r3, ssef& c0, ssef& c1, ssef& c2)
+__forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, const ssef& r3, ssef& c0, ssef& c1, ssef& c2)
{
ssef l02 = unpacklo(r0,r2);
ssef h02 = unpackhi(r0,r2);
@@ -382,22 +382,22 @@ __forceinline size_t movemask( const ssef& a ) { return _mm_movemask_ps(a); }
__forceinline ssef load4f(const float4& a) {
#ifdef __KERNEL_WITH_SSE_ALIGN__
- return _mm_load_ps(&a.x);
+ return _mm_load_ps(&a.x);
#else
- return _mm_loadu_ps(&a.x);
+ return _mm_loadu_ps(&a.x);
#endif
}
__forceinline ssef load4f(const float3& a) {
#ifdef __KERNEL_WITH_SSE_ALIGN__
- return _mm_load_ps(&a.x);
+ return _mm_load_ps(&a.x);
#else
- return _mm_loadu_ps(&a.x);
+ return _mm_loadu_ps(&a.x);
#endif
}
__forceinline ssef load4f(const void* const a) {
- return _mm_load_ps((float*)a);
+ return _mm_load_ps((float*)a);
}
__forceinline ssef load1f_first(const float a) {
@@ -409,14 +409,14 @@ __forceinline void store4f(void* ptr, const ssef& v) {
}
__forceinline ssef loadu4f(const void* const a) {
- return _mm_loadu_ps((float*)a);
+ return _mm_loadu_ps((float*)a);
}
__forceinline void storeu4f(void* ptr, const ssef& v) {
_mm_storeu_ps((float*)ptr,v);
}
-__forceinline void store4f(const sseb& mask, void* ptr, const ssef& f) {
+__forceinline void store4f(const sseb& mask, void* ptr, const ssef& f) {
#if defined(__KERNEL_AVX__)
_mm_maskstore_ps((float*)ptr,(__m128i)mask,f);
#else
@@ -428,7 +428,7 @@ __forceinline ssef load4f_nt(void* ptr) {
#if defined(__KERNEL_SSE41__)
return _mm_castsi128_ps(_mm_stream_load_si128((__m128i*)ptr));
#else
- return _mm_load_ps((float*)ptr);
+ return _mm_load_ps((float*)ptr);
#endif
}
@@ -449,7 +449,7 @@ __forceinline float dot(const ssef& a, const ssef& b) {
}
/* calculate shuffled cross product, useful when order of components does not matter */
-__forceinline ssef cross_zxy(const ssef& a, const ssef& b)
+__forceinline ssef cross_zxy(const ssef& a, const ssef& b)
{
const ssef a0 = a;
const ssef b0 = shuffle<1,2,0,3>(b);
@@ -458,7 +458,7 @@ __forceinline ssef cross_zxy(const ssef& a, const ssef& b)
return msub(a0,b0,a1*b1);
}
-__forceinline ssef cross(const ssef& a, const ssef& b)
+__forceinline ssef cross(const ssef& a, const ssef& b)
{
return shuffle<1,2,0,3>(cross_zxy(a, b));
}
@@ -628,4 +628,3 @@ ccl_device_inline void print_ssef(const char *label, const ssef &a)
CCL_NAMESPACE_END
#endif
-
diff --git a/intern/cycles/util/util_ssei.h b/intern/cycles/util/util_ssei.h
index ef2a9e68b7d..ba0389cd114 100644
--- a/intern/cycles/util/util_ssei.h
+++ b/intern/cycles/util/util_ssei.h
@@ -38,7 +38,7 @@ struct ssei
////////////////////////////////////////////////////////////////////////////////
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
-
+
__forceinline ssei ( ) {}
__forceinline ssei ( const ssei& a ) { m128 = a.m128; }
__forceinline ssei& operator=( const ssei& a ) { m128 = a.m128; return *this; }
@@ -173,15 +173,15 @@ __forceinline const sseb operator <=( const ssei& a, const ssei& b ) { return !(
__forceinline const sseb operator <=( const ssei& a, const int32_t& b ) { return a <= ssei(b); }
__forceinline const sseb operator <=( const int32_t& a, const ssei& b ) { return ssei(a) <= b; }
-__forceinline const ssei select( const sseb& m, const ssei& t, const ssei& f ) {
+__forceinline const ssei select( const sseb& m, const ssei& t, const ssei& f ) {
#ifdef __KERNEL_SSE41__
- return _mm_castps_si128(_mm_blendv_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), m));
+ return _mm_castps_si128(_mm_blendv_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), m));
#else
- return _mm_or_si128(_mm_and_si128(m, t), _mm_andnot_si128(m, f));
+ return _mm_or_si128(_mm_and_si128(m, t), _mm_andnot_si128(m, f));
#endif
}
-__forceinline const ssei select( const int mask, const ssei& t, const ssei& f ) {
+__forceinline const ssei select( const int mask, const ssei& t, const ssei& f ) {
#if defined(__KERNEL_SSE41__) && ((!defined(__clang__) && !defined(_MSC_VER)) || defined(__INTEL_COMPILER))
return _mm_castps_si128(_mm_blend_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), mask));
#else
@@ -249,8 +249,8 @@ __forceinline int reduce_add(const ssei& v) { return v[0]+v[1]+v[2]+v[3]; }
/// Memory load and store operations
////////////////////////////////////////////////////////////////////////////////
-__forceinline ssei load4i( const void* const a ) {
- return _mm_load_si128((__m128i*)a);
+__forceinline ssei load4i( const void* const a ) {
+ return _mm_load_si128((__m128i*)a);
}
__forceinline void store4i(void* ptr, const ssei& v) {
@@ -261,7 +261,7 @@ __forceinline void storeu4i(void* ptr, const ssei& v) {
_mm_storeu_si128((__m128i*)ptr,v);
}
-__forceinline void store4i( const sseb& mask, void* ptr, const ssei& i ) {
+__forceinline void store4i( const sseb& mask, void* ptr, const ssei& i ) {
#if defined (__KERNEL_AVX__)
_mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i));
#else
@@ -269,17 +269,17 @@ __forceinline void store4i( const sseb& mask, void* ptr, const ssei& i ) {
#endif
}
-__forceinline ssei load4i_nt (void* ptr) {
+__forceinline ssei load4i_nt (void* ptr) {
#if defined(__KERNEL_SSE41__)
- return _mm_stream_load_si128((__m128i*)ptr);
+ return _mm_stream_load_si128((__m128i*)ptr);
#else
- return _mm_load_si128((__m128i*)ptr);
+ return _mm_load_si128((__m128i*)ptr);
#endif
}
-__forceinline void store4i_nt(void* ptr, const ssei& v) {
+__forceinline void store4i_nt(void* ptr, const ssei& v) {
#if defined(__KERNEL_SSE41__)
- _mm_stream_ps((float*)ptr,_mm_castsi128_ps(v));
+ _mm_stream_ps((float*)ptr,_mm_castsi128_ps(v));
#else
_mm_store_si128((__m128i*)ptr,v);
#endif
@@ -300,4 +300,3 @@ ccl_device_inline void print_ssei(const char *label, const ssei &a)
CCL_NAMESPACE_END
#endif
-
diff --git a/intern/cycles/util/util_string.cpp b/intern/cycles/util/util_string.cpp
index 94ad512982c..995f5d3df27 100644
--- a/intern/cycles/util/util_string.cpp
+++ b/intern/cycles/util/util_string.cpp
@@ -293,4 +293,3 @@ string string_human_readable_number(size_t num)
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_string.h b/intern/cycles/util/util_string.h
index e2c105db9c1..7dfa97335a9 100644
--- a/intern/cycles/util/util_string.h
+++ b/intern/cycles/util/util_string.h
@@ -73,4 +73,3 @@ string string_human_readable_number(size_t num);
CCL_NAMESPACE_END
#endif /* __UTIL_STRING_H__ */
-
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 5f5211228c5..8ae5b63b2f9 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -312,4 +312,3 @@ size_t system_physical_ram()
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_system.h b/intern/cycles/util/util_system.h
index e55dd6dd136..42ad72356b9 100644
--- a/intern/cycles/util/util_system.h
+++ b/intern/cycles/util/util_system.h
@@ -47,4 +47,3 @@ size_t system_physical_ram();
CCL_NAMESPACE_END
#endif /* __UTIL_SYSTEM_H__ */
-
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
index 9df1096de8a..2d21d6b5a18 100644
--- a/intern/cycles/util/util_task.cpp
+++ b/intern/cycles/util/util_task.cpp
@@ -122,7 +122,7 @@ void TaskPool::cancel()
do_cancel = true;
TaskScheduler::clear(this);
-
+
{
thread_scoped_lock num_lock(num_mutex);
@@ -210,7 +210,7 @@ void TaskScheduler::init(int num_threads)
int current_group_threads = 0;
if(num_groups > 1) {
process_groups.resize(num_groups);
- num_process_groups = system_cpu_process_groups(num_groups,
+ num_process_groups = system_cpu_process_groups(num_groups,
&process_groups[0]);
if(num_process_groups == 1) {
current_group_threads = system_cpu_group_thread_count(process_groups[0]);
@@ -251,7 +251,7 @@ void TaskScheduler::init(int num_threads)
}
}
}
-
+
users++;
}
@@ -295,7 +295,7 @@ bool TaskScheduler::thread_wait_pop(Entry& entry)
assert(do_exit);
return false;
}
-
+
entry = queue.front();
queue.pop_front();
@@ -518,4 +518,3 @@ string TaskPool::Summary::full_report() const
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h
index 3ebfb007e40..15f0d341be7 100644
--- a/intern/cycles/util/util_task.h
+++ b/intern/cycles/util/util_task.h
@@ -118,7 +118,7 @@ protected:
};
/* Task Scheduler
- *
+ *
* Central scheduler that holds running threads ready to execute tasks. A singe
* queue holds the task from all pools. */
@@ -207,4 +207,3 @@ protected:
CCL_NAMESPACE_END
#endif
-
diff --git a/intern/cycles/util/util_texture.h b/intern/cycles/util/util_texture.h
index 4b5f630427d..f752e81128d 100644
--- a/intern/cycles/util/util_texture.h
+++ b/intern/cycles/util/util_texture.h
@@ -53,6 +53,8 @@ typedef enum ImageDataType {
IMAGE_DATA_TYPE_FLOAT = 3,
IMAGE_DATA_TYPE_BYTE = 4,
IMAGE_DATA_TYPE_HALF = 5,
+ IMAGE_DATA_TYPE_USHORT4 = 6,
+ IMAGE_DATA_TYPE_USHORT = 7,
IMAGE_DATA_NUM_TYPES
} ImageDataType;
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index 4d8f464359c..77b51d37ea0 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -155,4 +155,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __UTIL_THREAD_H__ */
-
diff --git a/intern/cycles/util/util_time.cpp b/intern/cycles/util/util_time.cpp
index 7c39aa294bf..bc6ac4e2099 100644
--- a/intern/cycles/util/util_time.cpp
+++ b/intern/cycles/util/util_time.cpp
@@ -77,4 +77,3 @@ void time_sleep(double t)
CCL_NAMESPACE_END
#endif
-
diff --git a/intern/cycles/util/util_time.h b/intern/cycles/util/util_time.h
index f03aa590e9b..13281bf188b 100644
--- a/intern/cycles/util/util_time.h
+++ b/intern/cycles/util/util_time.h
@@ -59,4 +59,3 @@ protected:
CCL_NAMESPACE_END
#endif
-
diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp
index 206c3da23eb..c72e729a2e5 100644
--- a/intern/cycles/util/util_transform.cpp
+++ b/intern/cycles/util/util_transform.cpp
@@ -16,10 +16,10 @@
/*
* Adapted from code with license:
- *
+ *
* Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
* Digital Ltd. LLC. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -31,8 +31,8 @@
* distribution.
* * Neither the name of Industrial Light & Magic nor the names of its
* contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
+ * from this software without specific prior written permission.
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -236,7 +236,7 @@ static void transform_decompose(DecomposedTransform *decomp, const Transform *tf
for(int i = 0; i < 3; i++)
for(int j = 0; j < 4; j++)
Rnext[i][j] = 0.5f * (R[i][j] + Rit[i][j]);
-
+
norm = 0.0f;
for(int i = 0; i < 3; i++) {
norm = max(norm,
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index 987f4dac777..e781f85dded 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -258,7 +258,7 @@ ccl_device_inline bool transform_uniform_scale(const Transform& tfm, float& scal
/* the epsilon here is quite arbitrary, but this function is only used for
* surface area and bump, where we expect it to not be so sensitive */
float eps = 1e-6f;
-
+
float sx = len_squared(float4_to_float3(tfm.x));
float sy = len_squared(float4_to_float3(tfm.y));
float sz = len_squared(float4_to_float3(tfm.z));
@@ -471,4 +471,3 @@ OPENCL_TRANSFORM_ADDRSPACE_DECLARE(transform_direction_transposed)
CCL_NAMESPACE_END
#endif /* __UTIL_TRANSFORM_H__ */
-
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index 84206a7ba5a..dfe755a8789 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -116,6 +116,8 @@ CCL_NAMESPACE_END
#include "util/util_types_uint3.h"
#include "util/util_types_uint4.h"
+#include "util/util_types_ushort4.h"
+
#include "util/util_types_float2.h"
#include "util/util_types_float3.h"
#include "util/util_types_float4.h"
@@ -150,4 +152,3 @@ CCL_NAMESPACE_END
#endif
#endif /* __UTIL_TYPES_H__ */
-
diff --git a/intern/cycles/util/util_types_float4_impl.h b/intern/cycles/util/util_types_float4_impl.h
index 09f45f47d38..a49fac65b10 100644
--- a/intern/cycles/util/util_types_float4_impl.h
+++ b/intern/cycles/util/util_types_float4_impl.h
@@ -102,7 +102,7 @@ ccl_device_inline float4 make_float4(const int4& i)
ccl_device_inline void print_float4(const char *label, const float4& a)
{
printf("%s: %.8f %.8f %.8f %.8f\n",
- label,
+ label,
(double)a.x, (double)a.y, (double)a.z, (double)a.w);
}
#endif /* __KERNEL_GPU__ */
diff --git a/intern/cycles/util/util_types_ushort4.h b/intern/cycles/util/util_types_ushort4.h
new file mode 100644
index 00000000000..fc234b8abe8
--- /dev/null
+++ b/intern/cycles/util/util_types_ushort4.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011-2017 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 __UTIL_TYPES_USHORT4_H__
+#define __UTIL_TYPES_USHORT4_H__
+
+#ifndef __UTIL_TYPES_H__
+# error "Do not include this file directly, include util_types.h instead."
+#endif
+
+CCL_NAMESPACE_BEGIN
+
+#ifndef __KERNEL_GPU__
+
+struct ushort4 {
+ uint16_t x, y, z, w;
+};
+
+#endif
+
+CCL_NAMESPACE_END
+
+#endif /* __UTIL_TYPES_USHORT4_H__ */
diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h
index 8d91d3936a4..569f503b66e 100644
--- a/intern/cycles/util/util_vector.h
+++ b/intern/cycles/util/util_vector.h
@@ -341,4 +341,3 @@ protected:
CCL_NAMESPACE_END
#endif /* __UTIL_VECTOR_H__ */
-
diff --git a/intern/cycles/util/util_view.cpp b/intern/cycles/util/util_view.cpp
index 7b453d123b8..05094c7b327 100644
--- a/intern/cycles/util/util_view.cpp
+++ b/intern/cycles/util/util_view.cpp
@@ -272,4 +272,3 @@ void view_redraw()
}
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_view.h b/intern/cycles/util/util_view.h
index 5def0564175..e603e605776 100644
--- a/intern/cycles/util/util_view.h
+++ b/intern/cycles/util/util_view.h
@@ -41,4 +41,3 @@ void view_redraw();
CCL_NAMESPACE_END
#endif /*__UTIL_VIEW_H__*/
-
diff --git a/intern/cycles/util/util_windows.h b/intern/cycles/util/util_windows.h
index 7ea3e65c2c5..3b23ce8a3cb 100644
--- a/intern/cycles/util/util_windows.h
+++ b/intern/cycles/util/util_windows.h
@@ -57,4 +57,3 @@ CCL_NAMESPACE_END
#endif /* WIN32 */
#endif /* __UTIL_WINDOWS_H__ */
-
diff --git a/intern/gawain/CMakeLists.txt b/intern/gawain/CMakeLists.txt
deleted file mode 100644
index 7ebd3ee7622..00000000000
--- a/intern/gawain/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-# WITH_OPENGL limits the visibility of the opengl headers to just gawain and bg_gpu,
-# to more easily highlight codepadths in other libraries that need to be refactored,
-# bf_intern_gawain is allowed to have opengl regardless of this option.
-
-if(NOT WITH_OPENGL)
- add_definitions(-DWITH_OPENGL)
-endif()
-
-set(INC
- gawain
-)
-
-set(INC_SYS
- ${GLEW_INCLUDE_PATH}
-)
-
-set(SRC
- src/gwn_attr_binding.c
- src/gwn_batch.c
- src/gwn_element.c
- src/gwn_buffer_id.cpp
- src/gwn_immediate.c
- src/gwn_imm_util.c
- src/gwn_primitive.c
- src/gwn_shader_interface.c
- src/gwn_vertex_array_id.cpp
- src/gwn_vertex_buffer.c
- src/gwn_vertex_format.c
-
- gawain/gwn_attr_binding.h
- gawain/gwn_attr_binding_private.h
- gawain/gwn_batch.h
- gawain/gwn_batch_private.h
- gawain/gwn_buffer_id.h
- gawain/gwn_common.h
- gawain/gwn_element.h
- gawain/gwn_imm_util.h
- gawain/gwn_immediate.h
- gawain/gwn_primitive.h
- gawain/gwn_primitive_private.h
- gawain/gwn_shader_interface.h
- gawain/gwn_vertex_array_id.h
- gawain/gwn_vertex_buffer.h
- gawain/gwn_vertex_format.h
- gawain/gwn_vertex_format_private.h
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-blender_add_lib(bf_intern_gawain "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/gawain/gawain/gwn_attr_binding.h b/intern/gawain/gawain/gwn_attr_binding.h
deleted file mode 100644
index a209e1c4f0f..00000000000
--- a/intern/gawain/gawain/gwn_attr_binding.h
+++ /dev/null
@@ -1,19 +0,0 @@
-
-// Gawain vertex attribute binding
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_common.h"
-
-typedef struct Gwn_AttrBinding {
- uint64_t loc_bits; // store 4 bits for each of the 16 attribs
- uint16_t enabled_bits; // 1 bit for each attrib
-} Gwn_AttrBinding;
diff --git a/intern/gawain/gawain/gwn_attr_binding_private.h b/intern/gawain/gawain/gwn_attr_binding_private.h
deleted file mode 100644
index 300945d464b..00000000000
--- a/intern/gawain/gawain/gwn_attr_binding_private.h
+++ /dev/null
@@ -1,20 +0,0 @@
-
-// Gawain vertex attribute binding
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_vertex_format.h"
-#include "gwn_shader_interface.h"
-
-void AttribBinding_clear(Gwn_AttrBinding*);
-
-void get_attrib_locations(const Gwn_VertFormat*, Gwn_AttrBinding*, const Gwn_ShaderInterface*);
-unsigned read_attrib_location(const Gwn_AttrBinding*, unsigned a_idx);
diff --git a/intern/gawain/gawain/gwn_batch.h b/intern/gawain/gawain/gwn_batch.h
deleted file mode 100644
index e0cf66637f6..00000000000
--- a/intern/gawain/gawain/gwn_batch.h
+++ /dev/null
@@ -1,169 +0,0 @@
-
-// Gawain geometry batch
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_vertex_buffer.h"
-#include "gwn_element.h"
-#include "gwn_shader_interface.h"
-
-typedef enum {
- GWN_BATCH_READY_TO_FORMAT,
- GWN_BATCH_READY_TO_BUILD,
- GWN_BATCH_BUILDING,
- GWN_BATCH_READY_TO_DRAW
-} Gwn_BatchPhase;
-
-#define GWN_BATCH_VBO_MAX_LEN 3
-#define GWN_BATCH_VAO_STATIC_LEN 3
-#define GWN_BATCH_VAO_DYN_ALLOC_COUNT 16
-
-typedef struct Gwn_Batch {
- // geometry
- Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; // verts[0] is required, others can be NULL
- Gwn_VertBuf* inst; // instance attribs
- Gwn_IndexBuf* elem; // NULL if element list not needed
- uint32_t gl_prim_type;
-
- // cached values (avoid dereferencing later)
- uint32_t vao_id;
- uint32_t program;
- const struct Gwn_ShaderInterface* interface;
-
- // book-keeping
- unsigned owns_flag;
- struct Gwn_Context *context; // used to free all vaos. this implies all vaos were created under the same context.
- Gwn_BatchPhase phase;
- bool program_in_use;
-
- // Vao management: remembers all geometry state (vertex attrib bindings & element buffer)
- // for each shader interface. Start with a static number of vaos and fallback to dynamic count
- // if necessary. Once a batch goes dynamic it does not go back.
- bool is_dynamic_vao_count;
- union {
- // Static handle count
- struct {
- const struct Gwn_ShaderInterface* interfaces[GWN_BATCH_VAO_STATIC_LEN];
- uint32_t vao_ids[GWN_BATCH_VAO_STATIC_LEN];
- } static_vaos;
- // Dynamic handle count
- struct {
- unsigned count;
- const struct Gwn_ShaderInterface** interfaces;
- uint32_t* vao_ids;
- } dynamic_vaos;
- };
-
- // XXX This is the only solution if we want to have some data structure using
- // batches as key to identify nodes. We must destroy these nodes with this callback.
- void (*free_callback)(struct Gwn_Batch*, void*);
- void* callback_data;
-} Gwn_Batch;
-
-enum {
- GWN_BATCH_OWNS_VBO = (1 << 0),
- /* each vbo index gets bit-shifted */
- GWN_BATCH_OWNS_INSTANCES = (1 << 30),
- GWN_BATCH_OWNS_INDEX = (1 << 31),
-};
-
-Gwn_Batch* GWN_batch_create_ex(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, unsigned owns_flag);
-void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, unsigned owns_flag);
-Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src);
-
-#define GWN_batch_create(prim, verts, elem) \
- GWN_batch_create_ex(prim, verts, elem, 0)
-#define GWN_batch_init(batch, prim, verts, elem) \
- GWN_batch_init_ex(batch, prim, verts, elem, 0)
-
-void GWN_batch_discard(Gwn_Batch*); // verts & elem are not discarded
-
-void GWN_batch_callback_free_set(Gwn_Batch*, void (*callback)(Gwn_Batch*, void*), void*);
-
-void GWN_batch_instbuf_set(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); // Instancing
-
-int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo);
-
-#define GWN_batch_vertbuf_add(batch, verts) \
- GWN_batch_vertbuf_add_ex(batch, verts, false)
-
-void GWN_batch_program_set_no_use(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*);
-void GWN_batch_program_set(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*);
-// Entire batch draws with one shader program, but can be redrawn later with another program.
-// Vertex shader's inputs must be compatible with the batch's vertex format.
-
-void GWN_batch_program_use_begin(Gwn_Batch*); // call before Batch_Uniform (temp hack?)
-void GWN_batch_program_use_end(Gwn_Batch*);
-
-void GWN_batch_uniform_1ui(Gwn_Batch*, const char* name, int value);
-void GWN_batch_uniform_1i(Gwn_Batch*, const char* name, int value);
-void GWN_batch_uniform_1b(Gwn_Batch*, const char* name, bool value);
-void GWN_batch_uniform_1f(Gwn_Batch*, const char* name, float value);
-void GWN_batch_uniform_2f(Gwn_Batch*, const char* name, float x, float y);
-void GWN_batch_uniform_3f(Gwn_Batch*, const char* name, float x, float y, float z);
-void GWN_batch_uniform_4f(Gwn_Batch*, const char* name, float x, float y, float z, float w);
-void GWN_batch_uniform_2fv(Gwn_Batch*, const char* name, const float data[2]);
-void GWN_batch_uniform_3fv(Gwn_Batch*, const char* name, const float data[3]);
-void GWN_batch_uniform_4fv(Gwn_Batch*, const char* name, const float data[4]);
-void GWN_batch_uniform_2fv_array(Gwn_Batch*, const char* name, int len, const float *data);
-void GWN_batch_uniform_4fv_array(Gwn_Batch*, const char* name, int len, const float *data);
-void GWN_batch_uniform_mat4(Gwn_Batch*, const char* name, const float data[4][4]);
-
-void GWN_batch_draw(Gwn_Batch*);
-
-// This does not bind/unbind shader and does not call gpuBindMatrices()
-void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance);
-
-// Does not even need batch
-void GWN_draw_primitive(Gwn_PrimType, int v_count);
-
-#if 0 // future plans
-
-// Can multiple batches share a Gwn_VertBuf? Use ref count?
-
-
-// We often need a batch with its own data, to be created and discarded together.
-// WithOwn variants reduce number of system allocations.
-
-typedef struct BatchWithOwnVertexBuffer {
- Gwn_Batch batch;
- Gwn_VertBuf verts; // link batch.verts to this
-} BatchWithOwnVertexBuffer;
-
-typedef struct BatchWithOwnElementList {
- Gwn_Batch batch;
- Gwn_IndexBuf elem; // link batch.elem to this
-} BatchWithOwnElementList;
-
-typedef struct BatchWithOwnVertexBufferAndElementList {
- Gwn_Batch batch;
- Gwn_IndexBuf elem; // link batch.elem to this
- Gwn_VertBuf verts; // link batch.verts to this
-} BatchWithOwnVertexBufferAndElementList;
-
-Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, unsigned v_ct, Gwn_IndexBuf*);
-Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, unsigned prim_ct);
-Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, unsigned v_ct, unsigned prim_ct);
-// verts: shared, own
-// elem: none, shared, own
-Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff);
-
-#endif // future plans
-
-
-/* Macros */
-
-#define GWN_BATCH_DISCARD_SAFE(batch) do { \
- if (batch != NULL) { \
- GWN_batch_discard(batch); \
- batch = NULL; \
- } \
-} while (0)
diff --git a/intern/gawain/gawain/gwn_batch_private.h b/intern/gawain/gawain/gwn_batch_private.h
deleted file mode 100644
index 6503429c237..00000000000
--- a/intern/gawain/gawain/gwn_batch_private.h
+++ /dev/null
@@ -1,30 +0,0 @@
-
-// Gawain context
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2018 Mike Erwin, Clément Foucault
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "gwn_batch.h"
-#include "gwn_context.h"
-#include "gwn_shader_interface.h"
-
-void gwn_batch_remove_interface_ref(Gwn_Batch*, const Gwn_ShaderInterface*);
-void gwn_batch_vao_cache_clear(Gwn_Batch*);
-
-void gwn_context_add_batch(Gwn_Context*, Gwn_Batch*);
-void gwn_context_remove_batch(Gwn_Context*, Gwn_Batch*);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/intern/gawain/gawain/gwn_buffer_id.h b/intern/gawain/gawain/gwn_buffer_id.h
deleted file mode 100644
index 6f51ca6905d..00000000000
--- a/intern/gawain/gawain/gwn_buffer_id.h
+++ /dev/null
@@ -1,30 +0,0 @@
-
-// Gawain buffer IDs
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-// Manage GL buffer IDs in a thread-safe way
-// Use these instead of glGenBuffers & its friends
-// - alloc must be called from main thread
-// - free can be called from any thread
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "gwn_common.h"
-
-GLuint GWN_buf_id_alloc(void);
-void GWN_buf_id_free(GLuint buffer_id);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/intern/gawain/gawain/gwn_common.h b/intern/gawain/gawain/gwn_common.h
deleted file mode 100644
index 6a56543da40..00000000000
--- a/intern/gawain/gawain/gwn_common.h
+++ /dev/null
@@ -1,39 +0,0 @@
-
-// Gawain common #defines and #includes
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#define PROGRAM_NO_OPTI 0
-
-#if defined(NDEBUG)
- #define TRUST_NO_ONE 0
-#else
- // strict error checking, enabled for debug builds during early development
- #define TRUST_NO_ONE 1
-#endif
-
-#if defined(WITH_OPENGL)
- #include <GL/glew.h>
-#endif
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#if TRUST_NO_ONE
- #include <assert.h>
-#endif
-
-/* GWN_INLINE */
-#if defined(_MSC_VER)
-# define GWN_INLINE static __forceinline
-#else
-# define GWN_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
-#endif
diff --git a/intern/gawain/gawain/gwn_context.h b/intern/gawain/gawain/gwn_context.h
deleted file mode 100644
index 3addce762b3..00000000000
--- a/intern/gawain/gawain/gwn_context.h
+++ /dev/null
@@ -1,34 +0,0 @@
-
-// Gawain context
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2018 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-// This interface allow Gawain to manage VAOs for mutiple context and threads.
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "gwn_common.h"
-#include "gwn_batch.h"
-#include "gwn_shader_interface.h"
-
-typedef struct Gwn_Context Gwn_Context;
-
-Gwn_Context* GWN_context_create(void);
-void GWN_context_discard(Gwn_Context*);
-
-void GWN_context_active_set(Gwn_Context*);
-Gwn_Context* GWN_context_active_get(void);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/intern/gawain/gawain/gwn_element.h b/intern/gawain/gawain/gwn_element.h
deleted file mode 100644
index 4bd0c34675a..00000000000
--- a/intern/gawain/gawain/gwn_element.h
+++ /dev/null
@@ -1,79 +0,0 @@
-
-// Gawain element list (AKA index buffer)
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_primitive.h"
-
-#define GWN_TRACK_INDEX_RANGE 1
-
-#define GWN_PRIM_RESTART 0xFFFFFFFF
-
-typedef enum {
- GWN_INDEX_U8, // GL has this, Vulkan does not
- GWN_INDEX_U16,
- GWN_INDEX_U32
-} Gwn_IndexBufType;
-
-typedef struct Gwn_IndexBuf {
- unsigned index_ct;
-#if GWN_TRACK_INDEX_RANGE
- Gwn_IndexBufType index_type;
- uint32_t gl_index_type;
- unsigned min_index;
- unsigned max_index;
- unsigned base_index;
-#endif
- uint32_t vbo_id; // 0 indicates not yet sent to VRAM
- bool use_prim_restart;
-} Gwn_IndexBuf;
-
-void GWN_indexbuf_use(Gwn_IndexBuf*);
-unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf*);
-
-typedef struct Gwn_IndexBufBuilder {
- unsigned max_allowed_index;
- unsigned max_index_ct;
- unsigned index_ct;
- Gwn_PrimType prim_type;
- unsigned* data;
- bool use_prim_restart;
-} Gwn_IndexBufBuilder;
-
-
-// supports all primitive types.
-void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned index_ct, unsigned vertex_ct, bool use_prim_restart);
-
-// supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS.
-void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned prim_ct, unsigned vertex_ct);
-
-void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, unsigned v);
-void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*);
-
-void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, unsigned v);
-void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2);
-void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2, unsigned v3);
-void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2, unsigned v3, unsigned v4);
-
-Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*);
-void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*);
-
-void GWN_indexbuf_discard(Gwn_IndexBuf*);
-
-
-/* Macros */
-
-#define GWN_INDEXBUF_DISCARD_SAFE(elem) do { \
- if (elem != NULL) { \
- GWN_indexbuf_discard(elem); \
- elem = NULL; \
- } \
-} while (0)
diff --git a/intern/gawain/gawain/gwn_imm_util.h b/intern/gawain/gawain/gwn_imm_util.h
deleted file mode 100644
index 5d17ec50669..00000000000
--- a/intern/gawain/gawain/gwn_imm_util.h
+++ /dev/null
@@ -1,22 +0,0 @@
-
-// Gawain immediate mode drawing utilities
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-
-// Draw 2D rectangles (replaces glRect functions)
-// caller is reponsible for vertex format & shader
-void immRectf(unsigned pos, float x1, float y1, float x2, float y2);
-void immRecti(unsigned pos, int x1, int y1, int x2, int y2);
-
-// Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS.
-void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, float x2, float y2, const float color[4]);
-void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2, int y2, const float color[4]);
diff --git a/intern/gawain/gawain/gwn_immediate.h b/intern/gawain/gawain/gwn_immediate.h
deleted file mode 100644
index 35f9c9d9e2c..00000000000
--- a/intern/gawain/gawain/gwn_immediate.h
+++ /dev/null
@@ -1,120 +0,0 @@
-
-// Gawain immediate mode work-alike
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_vertex_format.h"
-#include "gwn_primitive.h"
-#include "gwn_shader_interface.h"
-
-#define IMM_BATCH_COMBO 1
-
-
-Gwn_VertFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib
-
-void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first
-void immUnbindProgram(void); // call after your last immEnd, or before binding another program
-
-void immBegin(Gwn_PrimType, unsigned vertex_ct); // must supply exactly vertex_ct vertices
-void immBeginAtMost(Gwn_PrimType, unsigned max_vertex_ct); // can supply fewer vertices
-void immEnd(void); // finishes and draws
-
-#if IMM_BATCH_COMBO
-#include "gwn_batch.h"
-// immBegin a batch, then use standard immFunctions as usual.
-// immEnd will finalize the batch instead of drawing.
-// Then you can draw it as many times as you like! Partially replaces the need for display lists.
-Gwn_Batch* immBeginBatch(Gwn_PrimType, unsigned vertex_ct);
-Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, unsigned vertex_ct);
-#endif
-
-
-// provide attribute values that can change per vertex
-// first vertex after immBegin must have all its attributes specified
-// skipped attributes will continue using the previous value for that attrib_id
-void immAttrib1f(unsigned attrib_id, float x);
-void immAttrib2f(unsigned attrib_id, float x, float y);
-void immAttrib3f(unsigned attrib_id, float x, float y, float z);
-void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w);
-
-void immAttrib2i(unsigned attrib_id, int x, int y);
-
-void immAttrib1u(unsigned attrib_id, unsigned x);
-
-void immAttrib2s(unsigned attrib_id, short x, short y);
-
-void immAttrib2fv(unsigned attrib_id, const float data[2]);
-void immAttrib3fv(unsigned attrib_id, const float data[3]);
-void immAttrib4fv(unsigned attrib_id, const float data[4]);
-
-void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b);
-void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
-
-void immAttrib3ubv(unsigned attrib_id, const unsigned char data[4]);
-void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]);
-
-// explicitly skip an attribute
-// this advanced option kills automatic value copying for this attrib_id
-void immSkipAttrib(unsigned attrib_id);
-
-
-// provide one last attribute value & end the current vertex
-// this is most often used for 2D or 3D position (similar to glVertex)
-void immVertex2f(unsigned attrib_id, float x, float y);
-void immVertex3f(unsigned attrib_id, float x, float y, float z);
-void immVertex4f(unsigned attrib_id, float x, float y, float z, float w);
-
-void immVertex2i(unsigned attrib_id, int x, int y);
-
-void immVertex2s(unsigned attrib_id, short x, short y);
-
-void immVertex2fv(unsigned attrib_id, const float data[2]);
-void immVertex3fv(unsigned attrib_id, const float data[3]);
-
-void immVertex2iv(unsigned attrib_id, const int data[2]);
-
-
-// provide uniform values that don't change for the entire draw call
-void immUniform1i(const char* name, int x);
-void immUniform4iv(const char* name, const int data[4]);
-void immUniform1f(const char* name, float x);
-void immUniform2f(const char* name, float x, float y);
-void immUniform2fv(const char* name, const float data[2]);
-void immUniform3f(const char* name, float x, float y, float z);
-void immUniform3fv(const char* name, const float data[3]);
-void immUniformArray3fv(const char* name, const float *data, int count);
-void immUniform4f(const char* name, float x, float y, float z, float w);
-void immUniform4fv(const char* name, const float data[4]);
-void immUniformArray4fv(const char* bare_name, const float *data, int count);
-void immUniformMatrix4fv(const char* name, const float data[4][4]);
-
-
-// convenience functions for setting "uniform vec4 color"
-// the rgb functions have implicit alpha = 1.0
-void immUniformColor4f(float r, float g, float b, float a);
-void immUniformColor4fv(const float rgba[4]);
-void immUniformColor3f(float r, float g, float b);
-void immUniformColor3fv(const float rgb[3]);
-void immUniformColor3fvAlpha(const float rgb[3], float a);
-
-void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b);
-void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
-void immUniformColor3ubv(const unsigned char rgb[3]);
-void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a);
-void immUniformColor4ubv(const unsigned char rgba[4]);
-
-
-// these are called by the system -- not part of drawing API
-
-void immInit(void);
-void immActivate(void);
-void immDeactivate(void);
-void immDestroy(void);
diff --git a/intern/gawain/gawain/gwn_primitive.h b/intern/gawain/gawain/gwn_primitive.h
deleted file mode 100644
index 3359b3582bb..00000000000
--- a/intern/gawain/gawain/gwn_primitive.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-// Gawain geometric primitives
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_common.h"
-
-typedef enum {
- GWN_PRIM_POINTS,
- GWN_PRIM_LINES,
- GWN_PRIM_TRIS,
- GWN_PRIM_LINE_STRIP,
- GWN_PRIM_LINE_LOOP, // GL has this, Vulkan does not
- GWN_PRIM_TRI_STRIP,
- GWN_PRIM_TRI_FAN,
-
- GWN_PRIM_LINES_ADJ,
- GWN_PRIM_TRIS_ADJ,
- GWN_PRIM_LINE_STRIP_ADJ,
-
- GWN_PRIM_NONE
-} Gwn_PrimType;
-
-// what types of primitives does each shader expect?
-typedef enum {
- GWN_PRIM_CLASS_NONE = 0,
- GWN_PRIM_CLASS_POINT = (1 << 0),
- GWN_PRIM_CLASS_LINE = (1 << 1),
- GWN_PRIM_CLASS_SURFACE = (1 << 2),
- GWN_PRIM_CLASS_ANY = GWN_PRIM_CLASS_POINT | GWN_PRIM_CLASS_LINE | GWN_PRIM_CLASS_SURFACE
-} Gwn_PrimClass;
-
-Gwn_PrimClass GWN_primtype_class(Gwn_PrimType);
-bool GWN_primtype_belongs_to_class(Gwn_PrimType, Gwn_PrimClass);
diff --git a/intern/gawain/gawain/gwn_primitive_private.h b/intern/gawain/gawain/gwn_primitive_private.h
deleted file mode 100644
index d959cd89852..00000000000
--- a/intern/gawain/gawain/gwn_primitive_private.h
+++ /dev/null
@@ -1,14 +0,0 @@
-
-// Gawain geometric primitives (private interface for use inside Gawain)
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-GLenum convert_prim_type_to_gl(Gwn_PrimType);
diff --git a/intern/gawain/gawain/gwn_shader_interface.h b/intern/gawain/gawain/gwn_shader_interface.h
deleted file mode 100644
index ee3d51fb3cc..00000000000
--- a/intern/gawain/gawain/gwn_shader_interface.h
+++ /dev/null
@@ -1,81 +0,0 @@
-
-// Gawain shader interface (C --> GLSL)
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_common.h"
-
-typedef enum {
- GWN_UNIFORM_NONE = 0, // uninitialized/unknown
-
- GWN_UNIFORM_MODEL, // mat4 ModelMatrix
- GWN_UNIFORM_VIEW, // mat4 ViewMatrix
- GWN_UNIFORM_MODELVIEW, // mat4 ModelViewMatrix
- GWN_UNIFORM_PROJECTION, // mat4 ProjectionMatrix
- GWN_UNIFORM_VIEWPROJECTION, // mat4 ViewProjectionMatrix
- GWN_UNIFORM_MVP, // mat4 ModelViewProjectionMatrix
-
- GWN_UNIFORM_MODEL_INV, // mat4 ModelMatrixInverse
- GWN_UNIFORM_VIEW_INV, // mat4 ViewMatrixInverse
- GWN_UNIFORM_MODELVIEW_INV, // mat4 ModelViewMatrixInverse
- GWN_UNIFORM_PROJECTION_INV, // mat4 ProjectionMatrixInverse
- GWN_UNIFORM_VIEWPROJECTION_INV, // mat4 ViewProjectionMatrixInverse
-
- GWN_UNIFORM_NORMAL, // mat3 NormalMatrix
- GWN_UNIFORM_WORLDNORMAL, // mat3 WorldNormalMatrix
- GWN_UNIFORM_CAMERATEXCO, // vec4 CameraTexCoFactors
- GWN_UNIFORM_ORCO, // vec3 OrcoTexCoFactors[]
-
- GWN_UNIFORM_COLOR, // vec4 color
- GWN_UNIFORM_EYE, // vec3 eye
- GWN_UNIFORM_CALLID, // int callId
-
- GWN_UNIFORM_CUSTOM, // custom uniform, not one of the above built-ins
-
- GWN_NUM_UNIFORMS, // Special value, denotes number of builtin uniforms.
-} Gwn_UniformBuiltin;
-
-typedef struct Gwn_ShaderInput {
- struct Gwn_ShaderInput* next;
- uint32_t name_offset;
- unsigned name_hash;
- Gwn_UniformBuiltin builtin_type; // only for uniform inputs
- uint32_t gl_type; // only for attrib inputs
- int32_t size; // only for attrib inputs
- int32_t location;
-} Gwn_ShaderInput;
-
-#define GWN_NUM_SHADERINTERFACE_BUCKETS 257
-#define GWN_SHADERINTERFACE_REF_ALLOC_COUNT 16
-
-typedef struct Gwn_ShaderInterface {
- int32_t program;
- uint32_t name_buffer_offset;
- Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
- Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
- Gwn_ShaderInput* ubo_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
- Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS];
- char* name_buffer;
- struct Gwn_Batch** batches; // references to batches using this interface
- unsigned batches_ct;
-} Gwn_ShaderInterface;
-
-Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id);
-void GWN_shaderinterface_discard(Gwn_ShaderInterface*);
-
-const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name);
-const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin);
-const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface*, const char* name);
-const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name);
-
-// keep track of batches using this interface
-void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*);
-void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*);
diff --git a/intern/gawain/gawain/gwn_vertex_array_id.h b/intern/gawain/gawain/gwn_vertex_array_id.h
deleted file mode 100644
index 1c093d428ce..00000000000
--- a/intern/gawain/gawain/gwn_vertex_array_id.h
+++ /dev/null
@@ -1,34 +0,0 @@
-
-// Gawain buffer IDs
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2018 Mike Erwin, Clément Foucault
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-// Manage GL vertex array IDs in a thread-safe way
-// Use these instead of glGenBuffers & its friends
-// - alloc must be called from a thread that is bound
-// to the context that will be used for drawing with
-// this vao.
-// - free can be called from any thread
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "gwn_common.h"
-#include "gwn_context.h"
-
-GLuint GWN_vao_default(void);
-GLuint GWN_vao_alloc(void);
-void GWN_vao_free(GLuint vao_id, Gwn_Context*);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/intern/gawain/gawain/gwn_vertex_buffer.h b/intern/gawain/gawain/gwn_vertex_buffer.h
deleted file mode 100644
index b92e4a87698..00000000000
--- a/intern/gawain/gawain/gwn_vertex_buffer.h
+++ /dev/null
@@ -1,125 +0,0 @@
-
-// Gawain vertex buffer
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_vertex_format.h"
-
-#define VRAM_USAGE 1
-// How to create a Gwn_VertBuf:
-// 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts)
-// 2) GWN_vertformat_attr_add(verts->format, ...)
-// 3) GWN_vertbuf_data_alloc(verts, vertex_ct) <-- finalizes/packs vertex format
-// 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer)
-
-// Is Gwn_VertBuf always used as part of a Gwn_Batch?
-
-typedef enum {
- // can be extended to support more types
- GWN_USAGE_STREAM,
- GWN_USAGE_STATIC, // do not keep data in memory
- GWN_USAGE_DYNAMIC
-} Gwn_UsageType;
-
-typedef struct Gwn_VertBuf {
- Gwn_VertFormat format;
- unsigned vertex_ct; // number of verts we want to draw
- unsigned vertex_alloc; // number of verts data
- bool dirty;
- unsigned char* data; // NULL indicates data in VRAM (unmapped)
- uint32_t vbo_id; // 0 indicates not yet allocated
- Gwn_UsageType usage; // usage hint for GL optimisation
-} Gwn_VertBuf;
-
-Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType);
-Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat*, Gwn_UsageType);
-
-#define GWN_vertbuf_create_with_format(format) \
- GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_STATIC)
-
-void GWN_vertbuf_discard(Gwn_VertBuf*);
-
-void GWN_vertbuf_init(Gwn_VertBuf*, Gwn_UsageType);
-void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf*, const Gwn_VertFormat*, Gwn_UsageType);
-
-#define GWN_vertbuf_init_with_format(verts, format) \
- GWN_vertbuf_init_with_format_ex(verts, format, GWN_USAGE_STATIC)
-
-unsigned GWN_vertbuf_size_get(const Gwn_VertBuf*);
-void GWN_vertbuf_data_alloc(Gwn_VertBuf*, unsigned v_ct);
-void GWN_vertbuf_data_resize(Gwn_VertBuf*, unsigned v_ct);
-void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, unsigned v_ct);
-
-// The most important set_attrib variant is the untyped one. Get it right first.
-// It takes a void* so the app developer is responsible for matching their app data types
-// to the vertex attribute's type and component count. They're in control of both, so this
-// should not be a problem.
-
-void GWN_vertbuf_attr_set(Gwn_VertBuf*, unsigned a_idx, unsigned v_idx, const void* data);
-void GWN_vertbuf_attr_fill(Gwn_VertBuf*, unsigned a_idx, const void* data); // tightly packed, non interleaved input data
-void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, unsigned a_idx, unsigned stride, const void* data);
-
-// For low level access only
-typedef struct Gwn_VertBufRaw {
- unsigned size;
- unsigned stride;
- unsigned char* data;
- unsigned char* data_init;
-#if TRUST_NO_ONE
- // Only for overflow check
- unsigned char* _data_end;
-#endif
-} Gwn_VertBufRaw;
-
-GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a)
- {
- unsigned char* data = a->data;
- a->data += a->stride;
-#if TRUST_NO_ONE
- assert(data < a->_data_end);
-#endif
- return (void *)data;
- }
-
-GWN_INLINE unsigned GWN_vertbuf_raw_used(Gwn_VertBufRaw *a)
- {
- return ((a->data - a->data_init) / a->stride);
- }
-
-void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, unsigned a_idx, Gwn_VertBufRaw *access);
-
-// TODO: decide whether to keep the functions below
-// doesn't immediate mode satisfy these needs?
-
-// void setAttrib1f(unsigned a_idx, unsigned v_idx, float x);
-// void setAttrib2f(unsigned a_idx, unsigned v_idx, float x, float y);
-// void setAttrib3f(unsigned a_idx, unsigned v_idx, float x, float y, float z);
-// void setAttrib4f(unsigned a_idx, unsigned v_idx, float x, float y, float z, float w);
-//
-// void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b);
-// void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
-
-void GWN_vertbuf_use(Gwn_VertBuf*);
-
-
-// Metrics
-
-unsigned GWN_vertbuf_get_memory_usage(void);
-
-
-// Macros
-
-#define GWN_VERTBUF_DISCARD_SAFE(verts) do { \
- if (verts != NULL) { \
- GWN_vertbuf_discard(verts); \
- verts = NULL; \
- } \
-} while (0)
diff --git a/intern/gawain/gawain/gwn_vertex_format.h b/intern/gawain/gawain/gwn_vertex_format.h
deleted file mode 100644
index 503c2d03c42..00000000000
--- a/intern/gawain/gawain/gwn_vertex_format.h
+++ /dev/null
@@ -1,78 +0,0 @@
-
-// Gawain vertex format
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "gwn_common.h"
-
-#define GWN_VERT_ATTR_MAX_LEN 16
-#define GWN_VERT_ATTR_MAX_NAMES 3
-#define GWN_VERT_ATTR_NAME_AVERAGE_LEN 11
-#define GWN_VERT_ATTR_NAMES_BUF_LEN ((GWN_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GWN_VERT_ATTR_MAX_LEN)
-
-typedef enum {
- GWN_COMP_I8,
- GWN_COMP_U8,
- GWN_COMP_I16,
- GWN_COMP_U16,
- GWN_COMP_I32,
- GWN_COMP_U32,
-
- GWN_COMP_F32,
-
- GWN_COMP_I10
-} Gwn_VertCompType;
-
-typedef enum {
- GWN_FETCH_FLOAT,
- GWN_FETCH_INT,
- GWN_FETCH_INT_TO_FLOAT_UNIT, // 127 (ubyte) -> 0.5 (and so on for other int types)
- GWN_FETCH_INT_TO_FLOAT // 127 (any int type) -> 127.0
-} Gwn_VertFetchMode;
-
-typedef struct Gwn_VertAttr {
- Gwn_VertFetchMode fetch_mode;
- Gwn_VertCompType comp_type;
- unsigned gl_comp_type;
- unsigned comp_ct; // 1 to 4 or 8 or 12 or 16
- unsigned sz; // size in bytes, 1 to 64
- unsigned offset; // from beginning of vertex, in bytes
- unsigned name_ct; // up to GWN_VERT_ATTR_MAX_NAMES
- const char* name[GWN_VERT_ATTR_MAX_NAMES];
-} Gwn_VertAttr;
-
-typedef struct Gwn_VertFormat {
- unsigned attrib_ct; // 0 to 16 (GWN_VERT_ATTR_MAX_LEN)
- unsigned name_ct; // total count of active vertex attrib
- unsigned stride; // stride in bytes, 1 to 256
- unsigned name_offset;
- bool packed;
- char names[GWN_VERT_ATTR_NAMES_BUF_LEN];
- Gwn_VertAttr attribs[GWN_VERT_ATTR_MAX_LEN]; // TODO: variable-size attribs array
-} Gwn_VertFormat;
-
-void GWN_vertformat_clear(Gwn_VertFormat*);
-void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src);
-
-unsigned GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, unsigned comp_ct, Gwn_VertFetchMode);
-void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias);
-
-// format conversion
-
-typedef struct Gwn_PackedNormal {
- int x : 10;
- int y : 10;
- int z : 10;
- int w : 2; // 0 by default, can manually set to { -2, -1, 0, 1 }
-} Gwn_PackedNormal;
-
-Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]);
-Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]);
diff --git a/intern/gawain/gawain/gwn_vertex_format_private.h b/intern/gawain/gawain/gwn_vertex_format_private.h
deleted file mode 100644
index c1a0f734eda..00000000000
--- a/intern/gawain/gawain/gwn_vertex_format_private.h
+++ /dev/null
@@ -1,16 +0,0 @@
-
-// Gawain vertex format (private interface for use inside Gawain)
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016-2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-void VertexFormat_pack(Gwn_VertFormat*);
-unsigned padding(unsigned offset, unsigned alignment);
-unsigned vertex_buffer_size(const Gwn_VertFormat*, unsigned vertex_ct);
diff --git a/intern/gawain/src/gwn_attr_binding.c b/intern/gawain/src/gwn_attr_binding.c
deleted file mode 100644
index 7647a927b1e..00000000000
--- a/intern/gawain/src/gwn_attr_binding.c
+++ /dev/null
@@ -1,70 +0,0 @@
-
-// Gawain vertex attribute binding
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_attr_binding.h"
-#include "gwn_attr_binding_private.h"
-#include <stddef.h>
-
-#if GWN_VERT_ATTR_MAX_LEN != 16
- #error "attrib binding code assumes GWN_VERT_ATTR_MAX_LEN = 16"
-#endif
-
-void AttribBinding_clear(Gwn_AttrBinding* binding)
- {
- binding->loc_bits = 0;
- binding->enabled_bits = 0;
- }
-
-unsigned read_attrib_location(const Gwn_AttrBinding* binding, unsigned a_idx)
- {
-#if TRUST_NO_ONE
- assert(a_idx < GWN_VERT_ATTR_MAX_LEN);
- assert(binding->enabled_bits & (1 << a_idx));
-#endif
-
- return (binding->loc_bits >> (4 * a_idx)) & 0xF;
- }
-
-static void write_attrib_location(Gwn_AttrBinding* binding, unsigned a_idx, unsigned location)
- {
-#if TRUST_NO_ONE
- assert(a_idx < GWN_VERT_ATTR_MAX_LEN);
- assert(location < GWN_VERT_ATTR_MAX_LEN);
-#endif
-
- const unsigned shift = 4 * a_idx;
- const uint64_t mask = ((uint64_t)0xF) << shift;
- // overwrite this attrib's previous location
- binding->loc_bits = (binding->loc_bits & ~mask) | (location << shift);
- // mark this attrib as enabled
- binding->enabled_bits |= 1 << a_idx;
- }
-
-void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding, const Gwn_ShaderInterface* shaderface)
- {
- AttribBinding_clear(binding);
-
- for (unsigned a_idx = 0; a_idx < format->attrib_ct; ++a_idx)
- {
- const Gwn_VertAttr* a = format->attribs + a_idx;
- for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx)
- {
- const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]);
-
-#if TRUST_NO_ONE
- assert(input != NULL);
- // TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program
-#endif
-
- write_attrib_location(binding, a_idx, input->location);
- }
- }
- }
diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c
deleted file mode 100644
index adc72e171c0..00000000000
--- a/intern/gawain/src/gwn_batch.c
+++ /dev/null
@@ -1,632 +0,0 @@
-
-// Gawain geometry batch
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_batch.h"
-#include "gwn_batch_private.h"
-#include "gwn_buffer_id.h"
-#include "gwn_vertex_array_id.h"
-#include "gwn_primitive_private.h"
-#include <stdlib.h>
-#include <string.h>
-
-// necessary functions from matrix API
-extern void gpuBindMatrices(const Gwn_ShaderInterface* shaderface);
-
-static void batch_update_program_bindings(Gwn_Batch* batch, unsigned int v_first);
-
-void gwn_batch_vao_cache_clear(Gwn_Batch* batch)
- {
- if (batch->context == NULL)
- return;
-
- if (batch->is_dynamic_vao_count)
- {
- for (int i = 0; i < batch->dynamic_vaos.count; ++i)
- {
- if (batch->dynamic_vaos.vao_ids[i])
- GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context);
- if (batch->dynamic_vaos.interfaces[i])
- GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->dynamic_vaos.interfaces[i], batch);
- }
- free(batch->dynamic_vaos.interfaces);
- free(batch->dynamic_vaos.vao_ids);
- }
- else
- {
- for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i)
- {
- if (batch->static_vaos.vao_ids[i])
- GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context);
- if (batch->static_vaos.interfaces[i])
- GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->static_vaos.interfaces[i], batch);
- }
- }
-
- batch->is_dynamic_vao_count = false;
- for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i)
- {
- batch->static_vaos.vao_ids[i] = 0;
- batch->static_vaos.interfaces[i] = NULL;
- }
-
- gwn_context_remove_batch(batch->context, batch);
- batch->context = NULL;
- }
-
-Gwn_Batch* GWN_batch_create_ex(
- Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem,
- unsigned owns_flag)
- {
- Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch));
-
- GWN_batch_init_ex(batch, prim_type, verts, elem, owns_flag);
-
- return batch;
- }
-
-void GWN_batch_init_ex(
- Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem,
- unsigned owns_flag)
- {
-#if TRUST_NO_ONE
- assert(verts != NULL);
-#endif
-
- batch->verts[0] = verts;
- for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v)
- batch->verts[v] = NULL;
- batch->inst = NULL;
- batch->elem = elem;
- batch->gl_prim_type = convert_prim_type_to_gl(prim_type);
- batch->phase = GWN_BATCH_READY_TO_DRAW;
- batch->is_dynamic_vao_count = false;
- batch->owns_flag = owns_flag;
- batch->free_callback = NULL;
- }
-
-// This will share the VBOs with the new batch
-Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src)
- {
- Gwn_Batch* batch = GWN_batch_create_ex(GWN_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0);
-
- batch->gl_prim_type = batch_src->gl_prim_type;
- for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v)
- batch->verts[v] = batch_src->verts[v];
-
- return batch;
- }
-
-void GWN_batch_discard(Gwn_Batch* batch)
- {
- if (batch->owns_flag & GWN_BATCH_OWNS_INDEX)
- GWN_indexbuf_discard(batch->elem);
-
- if (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES)
- GWN_vertbuf_discard(batch->inst);
-
- if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0)
- {
- for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
- {
- if (batch->verts[v] == NULL)
- break;
- if (batch->owns_flag & (1 << v))
- GWN_vertbuf_discard(batch->verts[v]);
- }
- }
-
- gwn_batch_vao_cache_clear(batch);
-
- if (batch->free_callback)
- batch->free_callback(batch, batch->callback_data);
-
- free(batch);
- }
-
-void GWN_batch_callback_free_set(Gwn_Batch* batch, void (*callback)(Gwn_Batch*, void*), void* user_data)
- {
- batch->free_callback = callback;
- batch->callback_data = user_data;
- }
-
-void GWN_batch_instbuf_set(Gwn_Batch* batch, Gwn_VertBuf* inst, bool own_vbo)
- {
-#if TRUST_NO_ONE
- assert(inst != NULL);
-#endif
- // redo the bindings
- gwn_batch_vao_cache_clear(batch);
-
- if (batch->inst != NULL && (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES))
- GWN_vertbuf_discard(batch->inst);
-
- batch->inst = inst;
-
- if (own_vbo)
- batch->owns_flag |= GWN_BATCH_OWNS_INSTANCES;
- else
- batch->owns_flag &= ~GWN_BATCH_OWNS_INSTANCES;
- }
-
-int GWN_batch_vertbuf_add_ex(
- Gwn_Batch* batch, Gwn_VertBuf* verts,
- bool own_vbo)
- {
- // redo the bindings
- gwn_batch_vao_cache_clear(batch);
-
- for (unsigned v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
- {
- if (batch->verts[v] == NULL)
- {
-#if TRUST_NO_ONE
- // for now all VertexBuffers must have same vertex_ct
- assert(verts->vertex_ct == batch->verts[0]->vertex_ct);
- // in the near future we will enable instanced attribs which have their own vertex_ct
-#endif
- batch->verts[v] = verts;
- // TODO: mark dirty so we can keep attrib bindings up-to-date
- if (own_vbo)
- batch->owns_flag |= (1 << v);
- return v;
- }
- }
-
- // we only make it this far if there is no room for another Gwn_VertBuf
-#if TRUST_NO_ONE
- assert(false);
-#endif
- return -1;
- }
-
-static GLuint batch_vao_get(Gwn_Batch *batch)
- {
- // Search through cache
- if (batch->is_dynamic_vao_count)
- {
- for (int i = 0; i < batch->dynamic_vaos.count; ++i)
- if (batch->dynamic_vaos.interfaces[i] == batch->interface)
- return batch->dynamic_vaos.vao_ids[i];
- }
- else
- {
- for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i)
- if (batch->static_vaos.interfaces[i] == batch->interface)
- return batch->static_vaos.vao_ids[i];
- }
-
- // Set context of this batch.
- // It will be bound to it until gwn_batch_vao_cache_clear is called.
- // Until then it can only be drawn with this context.
- if (batch->context == NULL)
- {
- batch->context = GWN_context_active_get();
- gwn_context_add_batch(batch->context, batch);
- }
-#if TRUST_NO_ONE
- else // Make sure you are not trying to draw this batch in another context.
- assert(batch->context == GWN_context_active_get());
-#endif
-
- // Cache miss, time to add a new entry!
- GLuint new_vao = 0;
- if (!batch->is_dynamic_vao_count)
- {
- int i; // find first unused slot
- for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i)
- if (batch->static_vaos.vao_ids[i] == 0)
- break;
-
- if (i < GWN_BATCH_VAO_STATIC_LEN)
- {
- batch->static_vaos.interfaces[i] = batch->interface;
- batch->static_vaos.vao_ids[i] = new_vao = GWN_vao_alloc();
- }
- else
- {
- // Not enough place switch to dynamic.
- batch->is_dynamic_vao_count = true;
- // Erase previous entries, they will be added back if drawn again.
- for (int j = 0; j < GWN_BATCH_VAO_STATIC_LEN; ++j)
- {
- GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface*)batch->static_vaos.interfaces[j], batch);
- GWN_vao_free(batch->static_vaos.vao_ids[j], batch->context);
- }
- // Init dynamic arrays and let the branch below set the values.
- batch->dynamic_vaos.count = GWN_BATCH_VAO_DYN_ALLOC_COUNT;
- batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(Gwn_ShaderInterface*));
- batch->dynamic_vaos.vao_ids = calloc(batch->dynamic_vaos.count, sizeof(GLuint));
- }
- }
-
- if (batch->is_dynamic_vao_count)
- {
- int i; // find first unused slot
- for (i = 0; i < batch->dynamic_vaos.count; ++i)
- if (batch->dynamic_vaos.vao_ids[i] == 0)
- break;
-
- if (i == batch->dynamic_vaos.count)
- {
- // Not enough place, realloc the array.
- i = batch->dynamic_vaos.count;
- batch->dynamic_vaos.count += GWN_BATCH_VAO_DYN_ALLOC_COUNT;
- batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(Gwn_ShaderInterface*) * batch->dynamic_vaos.count);
- batch->dynamic_vaos.vao_ids = realloc(batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count);
- memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(Gwn_ShaderInterface*) * GWN_BATCH_VAO_DYN_ALLOC_COUNT);
- memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GWN_BATCH_VAO_DYN_ALLOC_COUNT);
- }
-
- batch->dynamic_vaos.interfaces[i] = batch->interface;
- batch->dynamic_vaos.vao_ids[i] = new_vao = GWN_vao_alloc();
- }
-
- GWN_shaderinterface_add_batch_ref((Gwn_ShaderInterface*)batch->interface, batch);
-
-#if TRUST_NO_ONE
- assert(new_vao != 0);
-#endif
-
- // We just got a fresh VAO we need to initialize it.
- glBindVertexArray(new_vao);
- batch_update_program_bindings(batch, 0);
- glBindVertexArray(0);
-
- return new_vao;
- }
-
-void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface)
- {
-#if TRUST_NO_ONE
- assert(glIsProgram(shaderface->program));
- assert(batch->program_in_use == 0);
-#endif
-
- batch->interface = shaderface;
- batch->program = program;
- batch->vao_id = batch_vao_get(batch);
- }
-
-void GWN_batch_program_set(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface)
- {
- GWN_batch_program_set_no_use(batch, program, shaderface);
- GWN_batch_program_use_begin(batch); // hack! to make Batch_Uniform* simpler
- }
-
-void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* interface)
- {
- if (batch->is_dynamic_vao_count)
- {
- for (int i = 0; i < batch->dynamic_vaos.count; ++i)
- {
- if (batch->dynamic_vaos.interfaces[i] == interface)
- {
- GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context);
- batch->dynamic_vaos.vao_ids[i] = 0;
- batch->dynamic_vaos.interfaces[i] = NULL;
- break; // cannot have duplicates
- }
- }
- }
- else
- {
- int i;
- for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i)
- {
- if (batch->static_vaos.interfaces[i] == interface)
- {
- GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context);
- batch->static_vaos.vao_ids[i] = 0;
- batch->static_vaos.interfaces[i] = NULL;
- break; // cannot have duplicates
- }
- }
- }
- }
-
-static void create_bindings(Gwn_VertBuf* verts, const Gwn_ShaderInterface* interface, unsigned int v_first, const bool use_instancing)
- {
- const Gwn_VertFormat* format = &verts->format;
-
- const unsigned attrib_ct = format->attrib_ct;
- const unsigned stride = format->stride;
-
- GWN_vertbuf_use(verts);
-
- for (unsigned a_idx = 0; a_idx < attrib_ct; ++a_idx)
- {
- const Gwn_VertAttr* a = format->attribs + a_idx;
-
- const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride;
-
- for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx)
- {
- const Gwn_ShaderInput* input = GWN_shaderinterface_attr(interface, a->name[n_idx]);
-
- if (input == NULL) continue;
-
- if (a->comp_ct == 16 || a->comp_ct == 12 || a->comp_ct == 8)
- {
-#if TRUST_NO_ONE
- assert(a->fetch_mode == GWN_FETCH_FLOAT);
- assert(a->gl_comp_type == GL_FLOAT);
-#endif
- for (int i = 0; i < a->comp_ct / 4; ++i)
- {
- glEnableVertexAttribArray(input->location + i);
- glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0);
- glVertexAttribPointer(input->location + i, 4, a->gl_comp_type, GL_FALSE, stride,
- (const GLubyte*)pointer + i * 16);
- }
- }
- else
- {
- glEnableVertexAttribArray(input->location);
- glVertexAttribDivisor(input->location, (use_instancing) ? 1 : 0);
-
- switch (a->fetch_mode)
- {
- case GWN_FETCH_FLOAT:
- case GWN_FETCH_INT_TO_FLOAT:
- glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer);
- break;
- case GWN_FETCH_INT_TO_FLOAT_UNIT:
- glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer);
- break;
- case GWN_FETCH_INT:
- glVertexAttribIPointer(input->location, a->comp_ct, a->gl_comp_type, stride, pointer);
- }
- }
- }
- }
- }
-
-static void batch_update_program_bindings(Gwn_Batch* batch, unsigned int v_first)
- {
- for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v)
- create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false);
-
- if (batch->inst)
- create_bindings(batch->inst, batch->interface, v_first, true);
-
- if (batch->elem)
- GWN_indexbuf_use(batch->elem);
- }
-
-void GWN_batch_program_use_begin(Gwn_Batch* batch)
- {
- // NOTE: use_program & done_using_program are fragile, depend on staying in sync with
- // the GL context's active program. use_program doesn't mark other programs as "not used".
- // TODO: make not fragile (somehow)
-
- if (!batch->program_in_use)
- {
- glUseProgram(batch->program);
- batch->program_in_use = true;
- }
- }
-
-void GWN_batch_program_use_end(Gwn_Batch* batch)
- {
- if (batch->program_in_use)
- {
-#if PROGRAM_NO_OPTI
- glUseProgram(0);
-#endif
- batch->program_in_use = false;
- }
- }
-
-#if TRUST_NO_ONE
- #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); assert(uniform);
-#else
- #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name);
-#endif
-
-void GWN_batch_uniform_1ui(Gwn_Batch* batch, const char* name, int value)
- {
- GET_UNIFORM
- glUniform1ui(uniform->location, value);
- }
-
-void GWN_batch_uniform_1i(Gwn_Batch* batch, const char* name, int value)
- {
- GET_UNIFORM
- glUniform1i(uniform->location, value);
- }
-
-void GWN_batch_uniform_1b(Gwn_Batch* batch, const char* name, bool value)
- {
- GET_UNIFORM
- glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE);
- }
-
-void GWN_batch_uniform_2f(Gwn_Batch* batch, const char* name, float x, float y)
- {
- GET_UNIFORM
- glUniform2f(uniform->location, x, y);
- }
-
-void GWN_batch_uniform_3f(Gwn_Batch* batch, const char* name, float x, float y, float z)
- {
- GET_UNIFORM
- glUniform3f(uniform->location, x, y, z);
- }
-
-void GWN_batch_uniform_4f(Gwn_Batch* batch, const char* name, float x, float y, float z, float w)
- {
- GET_UNIFORM
- glUniform4f(uniform->location, x, y, z, w);
- }
-
-void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x)
- {
- GET_UNIFORM
- glUniform1f(uniform->location, x);
- }
-
-void GWN_batch_uniform_2fv(Gwn_Batch* batch, const char* name, const float data[2])
- {
- GET_UNIFORM
- glUniform2fv(uniform->location, 1, data);
- }
-
-void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3])
- {
- GET_UNIFORM
- glUniform3fv(uniform->location, 1, data);
- }
-
-void GWN_batch_uniform_4fv(Gwn_Batch* batch, const char* name, const float data[4])
- {
- GET_UNIFORM
- glUniform4fv(uniform->location, 1, data);
- }
-
-void GWN_batch_uniform_2fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data)
- {
- GET_UNIFORM
- glUniform2fv(uniform->location, len, data);
- }
-
-void GWN_batch_uniform_4fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data)
- {
- GET_UNIFORM
- glUniform4fv(uniform->location, len, data);
- }
-
-void GWN_batch_uniform_mat4(Gwn_Batch* batch, const char* name, const float data[4][4])
- {
- GET_UNIFORM
- glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (const float *)data);
- }
-
-static void primitive_restart_enable(const Gwn_IndexBuf *el)
-{
- // TODO(fclem) Replace by GL_PRIMITIVE_RESTART_FIXED_INDEX when we have ogl 4.3
- glEnable(GL_PRIMITIVE_RESTART);
- GLuint restart_index = (GLuint)0xFFFFFFFF;
-
-#if GWN_TRACK_INDEX_RANGE
- if (el->index_type == GWN_INDEX_U8)
- restart_index = (GLuint)0xFF;
- else if (el->index_type == GWN_INDEX_U16)
- restart_index = (GLuint)0xFFFF;
-#endif
-
- glPrimitiveRestartIndex(restart_index);
-}
-
-static void primitive_restart_disable(void)
-{
- glDisable(GL_PRIMITIVE_RESTART);
-}
-
-void GWN_batch_draw(Gwn_Batch* batch)
- {
-#if TRUST_NO_ONE
- assert(batch->phase == GWN_BATCH_READY_TO_DRAW);
- assert(batch->verts[0]->vbo_id != 0);
-#endif
- GWN_batch_program_use_begin(batch);
- gpuBindMatrices(batch->interface); // external call.
-
- GWN_batch_draw_range_ex(batch, 0, 0, false);
-
- GWN_batch_program_use_end(batch);
- }
-
-void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool force_instance)
- {
-#if TRUST_NO_ONE
- assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance
-#endif
- const bool do_instance = (force_instance || batch->inst);
-
- // If using offset drawing, use the default VAO and redo bindings.
- if (v_first != 0 && (do_instance || batch->elem))
- {
- glBindVertexArray(GWN_vao_default());
- batch_update_program_bindings(batch, v_first);
- }
- else
- glBindVertexArray(batch->vao_id);
-
- if (do_instance)
- {
- // Infer length if vertex count is not given
- if (v_count == 0)
- v_count = batch->inst->vertex_ct;
-
- if (batch->elem)
- {
- const Gwn_IndexBuf* el = batch->elem;
-
- if (el->use_prim_restart)
- primitive_restart_enable(el);
-
-#if GWN_TRACK_INDEX_RANGE
- glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_ct, el->gl_index_type, 0, v_count, el->base_index);
-#else
- glDrawElementsInstanced(batch->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0, v_count);
-#endif
- if (el->use_prim_restart)
- primitive_restart_disable();
- }
- else
- glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct, v_count);
- }
- else
- {
- // Infer length if vertex count is not given
- if (v_count == 0)
- v_count = (batch->elem) ? batch->elem->index_ct : batch->verts[0]->vertex_ct;
-
- if (batch->elem)
- {
- const Gwn_IndexBuf* el = batch->elem;
-
- if (el->use_prim_restart)
- primitive_restart_enable(el);
-
-#if GWN_TRACK_INDEX_RANGE
- if (el->base_index)
- glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, el->max_index, v_count, el->gl_index_type, 0, el->base_index);
- else
- glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, v_count, el->gl_index_type, 0);
-#else
- glDrawElements(batch->gl_prim_type, v_count, GL_UNSIGNED_INT, 0);
-#endif
- if (el->use_prim_restart)
- primitive_restart_disable();
- }
- else
- glDrawArrays(batch->gl_prim_type, v_first, v_count);
- }
-
- // Performance hog if you are drawing with the same vao multiple time.
- // Only activate for debugging.
- // glBindVertexArray(0);
- }
-
-// just draw some vertices and let shader place them where we want.
-void GWN_draw_primitive(Gwn_PrimType prim_type, int v_count)
- {
- // we cannot draw without vao ... annoying ...
- glBindVertexArray(GWN_vao_default());
-
- GLenum type = convert_prim_type_to_gl(prim_type);
- glDrawArrays(type, 0, v_count);
-
- // Performance hog if you are drawing with the same vao multiple time.
- // Only activate for debugging.
- // glBindVertexArray(0);
- }
diff --git a/intern/gawain/src/gwn_buffer_id.cpp b/intern/gawain/src/gwn_buffer_id.cpp
deleted file mode 100644
index 64bad855ca7..00000000000
--- a/intern/gawain/src/gwn_buffer_id.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-
-// Gawain buffer IDs
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.#include "buffer_id.h"
-
-#include "gwn_buffer_id.h"
-#include <mutex>
-#include <vector>
-
-#define ORPHAN_DEBUG 0
-
-#if ORPHAN_DEBUG
- #include <cstdio>
-#endif
-
-static std::vector<GLuint> orphaned_buffer_ids;
-
-static std::mutex orphan_mutex;
-
-extern "C" {
-extern int BLI_thread_is_main(void); // Blender-specific function
-}
-
-static bool thread_is_main()
- {
- // "main" here means the GL context's thread
- return BLI_thread_is_main();
- }
-
-GLuint GWN_buf_id_alloc()
- {
- // delete orphaned IDs
- orphan_mutex.lock();
- if (!orphaned_buffer_ids.empty())
- {
- const auto orphaned_buffer_ct = (unsigned)orphaned_buffer_ids.size();
-#if ORPHAN_DEBUG
- printf("deleting %u orphaned VBO%s\n", orphaned_buffer_ct, orphaned_buffer_ct == 1 ? "" : "s");
-#endif
- glDeleteBuffers(orphaned_buffer_ct, orphaned_buffer_ids.data());
- orphaned_buffer_ids.clear();
- }
- orphan_mutex.unlock();
-
- GLuint new_buffer_id = 0;
- glGenBuffers(1, &new_buffer_id);
- return new_buffer_id;
- }
-
-void GWN_buf_id_free(GLuint buffer_id)
- {
- if (thread_is_main())
- glDeleteBuffers(1, &buffer_id);
- else
- {
- // add this ID to the orphaned list
- orphan_mutex.lock();
-#if ORPHAN_DEBUG
- printf("orphaning VBO %u\n", buffer_id);
-#endif
- orphaned_buffer_ids.emplace_back(buffer_id);
- orphan_mutex.unlock();
- }
- }
diff --git a/intern/gawain/src/gwn_element.c b/intern/gawain/src/gwn_element.c
deleted file mode 100644
index e2fbb657c78..00000000000
--- a/intern/gawain/src/gwn_element.c
+++ /dev/null
@@ -1,304 +0,0 @@
-
-// Gawain element list (AKA index buffer)
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_element.h"
-#include "gwn_buffer_id.h"
-#include <stdlib.h>
-
-#define KEEP_SINGLE_COPY 1
-
-static GLenum convert_index_type_to_gl(Gwn_IndexBufType type)
- {
- static const GLenum table[] = {
- [GWN_INDEX_U8] = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not
- [GWN_INDEX_U16] = GL_UNSIGNED_SHORT,
- [GWN_INDEX_U32] = GL_UNSIGNED_INT
- };
- return table[type];
- }
-
-unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf* elem)
- {
-#if GWN_TRACK_INDEX_RANGE
- static const unsigned table[] = {
- [GWN_INDEX_U8] = sizeof(GLubyte), // GL has this, Vulkan does not
- [GWN_INDEX_U16] = sizeof(GLushort),
- [GWN_INDEX_U32] = sizeof(GLuint)
- };
- return elem->index_ct * table[elem->index_type];
-#else
- return elem->index_ct * sizeof(GLuint);
-#endif
- }
-
-void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned index_ct, unsigned vertex_ct, bool use_prim_restart)
- {
- builder->use_prim_restart = use_prim_restart;
- builder->max_allowed_index = vertex_ct - 1;
- builder->max_index_ct = index_ct;
- builder->index_ct = 0; // start empty
- builder->prim_type = prim_type;
- builder->data = calloc(builder->max_index_ct, sizeof(unsigned));
- }
-
-void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned prim_ct, unsigned vertex_ct)
- {
- unsigned verts_per_prim = 0;
- switch (prim_type)
- {
- case GWN_PRIM_POINTS:
- verts_per_prim = 1;
- break;
- case GWN_PRIM_LINES:
- verts_per_prim = 2;
- break;
- case GWN_PRIM_TRIS:
- verts_per_prim = 3;
- break;
- case GWN_PRIM_LINES_ADJ:
- verts_per_prim = 4;
- break;
- default:
-#if TRUST_NO_ONE
- assert(false);
-#endif
- return;
- }
-
- GWN_indexbuf_init_ex(builder, prim_type, prim_ct * verts_per_prim, vertex_ct, false);
- }
-
-void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, unsigned v)
- {
-#if TRUST_NO_ONE
- assert(builder->data != NULL);
- assert(builder->index_ct < builder->max_index_ct);
- assert(v <= builder->max_allowed_index);
-#endif
-
- builder->data[builder->index_ct++] = v;
- }
-
-void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder* builder)
- {
-#if TRUST_NO_ONE
- assert(builder->data != NULL);
- assert(builder->index_ct < builder->max_index_ct);
- assert(builder->use_prim_restart);
-#endif
-
- builder->data[builder->index_ct++] = GWN_PRIM_RESTART;
- }
-
-void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, unsigned v)
- {
-#if TRUST_NO_ONE
- assert(builder->prim_type == GWN_PRIM_POINTS);
-#endif
-
- GWN_indexbuf_add_generic_vert(builder, v);
- }
-
-void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2)
- {
-#if TRUST_NO_ONE
- assert(builder->prim_type == GWN_PRIM_LINES);
- assert(v1 != v2);
-#endif
-
- GWN_indexbuf_add_generic_vert(builder, v1);
- GWN_indexbuf_add_generic_vert(builder, v2);
- }
-
-void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2, unsigned v3)
- {
-#if TRUST_NO_ONE
- assert(builder->prim_type == GWN_PRIM_TRIS);
- assert(v1 != v2 && v2 != v3 && v3 != v1);
-#endif
-
- GWN_indexbuf_add_generic_vert(builder, v1);
- GWN_indexbuf_add_generic_vert(builder, v2);
- GWN_indexbuf_add_generic_vert(builder, v3);
- }
-
-void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2, unsigned v3, unsigned v4)
- {
-#if TRUST_NO_ONE
- assert(builder->prim_type == GWN_PRIM_LINES_ADJ);
- assert(v2 != v3); /* only the line need diff indices */
-#endif
-
- GWN_indexbuf_add_generic_vert(builder, v1);
- GWN_indexbuf_add_generic_vert(builder, v2);
- GWN_indexbuf_add_generic_vert(builder, v3);
- GWN_indexbuf_add_generic_vert(builder, v4);
- }
-
-#if GWN_TRACK_INDEX_RANGE
-// Everything remains 32 bit while building to keep things simple.
-// Find min/max after, then convert to smallest index type possible.
-
-static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned* min_out, unsigned* max_out)
- {
- if (value_ct == 0)
- {
- *min_out = 0;
- *max_out = 0;
- return 0;
- }
- unsigned min_value = values[0];
- unsigned max_value = values[0];
- for (unsigned i = 1; i < value_ct; ++i)
- {
- const unsigned value = values[i];
- if (value == GWN_PRIM_RESTART)
- continue;
- else if (value < min_value)
- min_value = value;
- else if (value > max_value)
- max_value = value;
- }
- *min_out = min_value;
- *max_out = max_value;
- return max_value - min_value;
- }
-
-static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem)
- {
- const unsigned *values = builder->data;
- const unsigned index_ct = elem->index_ct;
-
- // data will never be *larger* than builder->data...
- // converting in place to avoid extra allocation
- GLubyte *data = (GLubyte *)builder->data;
-
- if (elem->max_index > 0xFF)
- {
- const unsigned base = elem->min_index;
-
- elem->base_index = base;
- elem->min_index = 0;
- elem->max_index -= base;
-
- for (unsigned i = 0; i < index_ct; ++i)
- data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base);
- }
- else
- {
- elem->base_index = 0;
-
- for (unsigned i = 0; i < index_ct; ++i)
- data[i] = (GLubyte)(values[i]);
- }
- }
-
-static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem)
- {
- const unsigned *values = builder->data;
- const unsigned index_ct = elem->index_ct;
-
- // data will never be *larger* than builder->data...
- // converting in place to avoid extra allocation
- GLushort *data = (GLushort *)builder->data;
-
- if (elem->max_index > 0xFFFF)
- {
- const unsigned base = elem->min_index;
-
- elem->base_index = base;
- elem->min_index = 0;
- elem->max_index -= base;
-
- for (unsigned i = 0; i < index_ct; ++i)
- data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base);
- }
- else
- {
- elem->base_index = 0;
-
- for (unsigned i = 0; i < index_ct; ++i)
- data[i] = (GLushort)(values[i]);
- }
- }
-
-#endif // GWN_TRACK_INDEX_RANGE
-
-Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder* builder)
- {
- Gwn_IndexBuf* elem = calloc(1, sizeof(Gwn_IndexBuf));
- GWN_indexbuf_build_in_place(builder, elem);
- return elem;
- }
-
-void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* elem)
- {
-#if TRUST_NO_ONE
- assert(builder->data != NULL);
-#endif
-
- elem->index_ct = builder->index_ct;
- elem->use_prim_restart = builder->use_prim_restart;
-
-#if GWN_TRACK_INDEX_RANGE
- unsigned range = index_range(builder->data, builder->index_ct, &elem->min_index, &elem->max_index);
-
- // count the primitive restart index.
- if (elem->use_prim_restart)
- range += 1;
-
- if (range <= 0xFF)
- {
- elem->index_type = GWN_INDEX_U8;
- squeeze_indices_byte(builder, elem);
- }
- else if (range <= 0xFFFF)
- {
- elem->index_type = GWN_INDEX_U16;
- squeeze_indices_short(builder, elem);
- }
- else
- {
- elem->index_type = GWN_INDEX_U32;
- elem->base_index = 0;
- }
-
- elem->gl_index_type = convert_index_type_to_gl(elem->index_type);
-#endif
-
- if (elem->vbo_id == 0)
- elem->vbo_id = GWN_buf_id_alloc();
-
- // send data to GPU
- // GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound,
- // so we use the GL_ARRAY_BUFFER here to create a buffer without
- // interfering in the VAO state.
- glBindBuffer(GL_ARRAY_BUFFER, elem->vbo_id);
- glBufferData(GL_ARRAY_BUFFER, GWN_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW);
-
- // discard builder (one-time use)
- free(builder->data);
- builder->data = NULL;
- // other fields are safe to leave
- }
-
-void GWN_indexbuf_use(Gwn_IndexBuf* elem)
- {
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id);
- }
-
-void GWN_indexbuf_discard(Gwn_IndexBuf* elem)
- {
- if (elem->vbo_id)
- GWN_buf_id_free(elem->vbo_id);
-
- free(elem);
- }
diff --git a/intern/gawain/src/gwn_imm_util.c b/intern/gawain/src/gwn_imm_util.c
deleted file mode 100644
index a8d2b05c8a3..00000000000
--- a/intern/gawain/src/gwn_imm_util.c
+++ /dev/null
@@ -1,80 +0,0 @@
-
-// Gawain immediate mode drawing utilities
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_imm_util.h"
-#include "gwn_immediate.h"
-
-
-void immRectf(unsigned pos, float x1, float y1, float x2, float y2)
- {
- immBegin(GWN_PRIM_TRI_FAN, 4);
- immVertex2f(pos, x1, y1);
- immVertex2f(pos, x2, y1);
- immVertex2f(pos, x2, y2);
- immVertex2f(pos, x1, y2);
- immEnd();
- }
-
-void immRecti(unsigned pos, int x1, int y1, int x2, int y2)
- {
- immBegin(GWN_PRIM_TRI_FAN, 4);
- immVertex2i(pos, x1, y1);
- immVertex2i(pos, x2, y1);
- immVertex2i(pos, x2, y2);
- immVertex2i(pos, x1, y2);
- immEnd();
- }
-
-void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, float x2, float y2, const float color[4])
- {
- immAttrib4fv(col, color);
- immVertex2f(pos, x1, y1);
- immAttrib4fv(col, color);
- immVertex2f(pos, x2, y1);
- immAttrib4fv(col, color);
- immVertex2f(pos, x2, y2);
-
- immAttrib4fv(col, color);
- immVertex2f(pos, x1, y1);
- immAttrib4fv(col, color);
- immVertex2f(pos, x2, y2);
- immAttrib4fv(col, color);
- immVertex2f(pos, x1, y2);
- }
-
-void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2, int y2, const float color[4])
- {
- immAttrib4fv(col, color);
- immVertex2i(pos, x1, y1);
- immAttrib4fv(col, color);
- immVertex2i(pos, x2, y1);
- immAttrib4fv(col, color);
- immVertex2i(pos, x2, y2);
-
- immAttrib4fv(col, color);
- immVertex2i(pos, x1, y1);
- immAttrib4fv(col, color);
- immVertex2i(pos, x2, y2);
- immAttrib4fv(col, color);
- immVertex2i(pos, x1, y2);
- }
-
-#if 0 // more complete version in case we want that
-void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
- {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned pos = add_attrib(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor4fv(color);
- immRecti(pos, x1, y1, x2, y2);
- immUnbindProgram();
- }
-#endif
diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c
deleted file mode 100644
index b0b587d1b8c..00000000000
--- a/intern/gawain/src/gwn_immediate.c
+++ /dev/null
@@ -1,926 +0,0 @@
-
-// Gawain immediate mode work-alike
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_immediate.h"
-#include "gwn_buffer_id.h"
-#include "gwn_attr_binding.h"
-#include "gwn_attr_binding_private.h"
-#include "gwn_vertex_format_private.h"
-#include "gwn_vertex_array_id.h"
-#include "gwn_primitive_private.h"
-#include <string.h>
-
-// necessary functions from matrix API
-extern void gpuBindMatrices(const Gwn_ShaderInterface*);
-extern bool gpuMatricesDirty(void);
-
-typedef struct {
- // TODO: organize this struct by frequency of change (run-time)
-
-#if IMM_BATCH_COMBO
- Gwn_Batch* batch;
-#endif
- Gwn_Context* context;
-
- // current draw call
- GLubyte* buffer_data;
- unsigned buffer_offset;
- unsigned buffer_bytes_mapped;
- unsigned vertex_ct;
- bool strict_vertex_ct;
- Gwn_PrimType prim_type;
-
- Gwn_VertFormat vertex_format;
-
- // current vertex
- unsigned vertex_idx;
- GLubyte* vertex_data;
- uint16_t unassigned_attrib_bits; // which attributes of current vertex have not been given values?
-
- GLuint vbo_id;
- GLuint vao_id;
-
- GLuint bound_program;
- const Gwn_ShaderInterface* shader_interface;
- Gwn_AttrBinding attrib_binding;
- uint16_t prev_enabled_attrib_bits; // <-- only affects this VAO, so we're ok
-} Immediate;
-
-// size of internal buffer -- make this adjustable?
-#define IMM_BUFFER_SIZE (4 * 1024 * 1024)
-
-static bool initialized = false;
-static Immediate imm;
-
-void immInit(void)
- {
-#if TRUST_NO_ONE
- assert(!initialized);
-#endif
-
- memset(&imm, 0, sizeof(Immediate));
-
- imm.vbo_id = GWN_buf_id_alloc();
- glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id);
- glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
-
- imm.prim_type = GWN_PRIM_NONE;
- imm.strict_vertex_ct = true;
-
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- initialized = true;
-
- immActivate();
- }
-
-void immActivate(void)
- {
-#if TRUST_NO_ONE
- assert(initialized);
- assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair
- assert(imm.vao_id == 0);
-#endif
- imm.vao_id = GWN_vao_alloc();
- imm.context = GWN_context_active_get();
- }
-
-void immDeactivate(void)
- {
-#if TRUST_NO_ONE
- assert(initialized);
- assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair
- assert(imm.vao_id != 0);
-#endif
- GWN_vao_free(imm.vao_id, imm.context);
- imm.vao_id = 0;
- imm.prev_enabled_attrib_bits = 0;
- }
-
-void immDestroy(void)
- {
- immDeactivate();
- GWN_buf_id_free(imm.vbo_id);
- initialized = false;
- }
-
-Gwn_VertFormat* immVertexFormat(void)
- {
- GWN_vertformat_clear(&imm.vertex_format);
- return &imm.vertex_format;
- }
-
-void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface)
- {
-#if TRUST_NO_ONE
- assert(imm.bound_program == 0);
- assert(glIsProgram(program));
-#endif
-
- imm.bound_program = program;
- imm.shader_interface = shaderface;
-
- if (!imm.vertex_format.packed)
- VertexFormat_pack(&imm.vertex_format);
-
- glUseProgram(program);
- get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface);
- gpuBindMatrices(shaderface);
- }
-
-void immUnbindProgram(void)
- {
-#if TRUST_NO_ONE
- assert(imm.bound_program != 0);
-#endif
-#if PROGRAM_NO_OPTI
- glUseProgram(0);
-#endif
- imm.bound_program = 0;
- }
-
-#if TRUST_NO_ONE
-static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, Gwn_PrimType prim_type)
- {
- // does vertex_ct make sense for this primitive type?
- if (vertex_ct == 0)
- return false;
-
- switch (prim_type)
- {
- case GWN_PRIM_POINTS:
- return true;
- case GWN_PRIM_LINES:
- return vertex_ct % 2 == 0;
- case GWN_PRIM_LINE_STRIP:
- case GWN_PRIM_LINE_LOOP:
- return vertex_ct >= 2;
- case GWN_PRIM_LINE_STRIP_ADJ:
- return vertex_ct >= 4;
- case GWN_PRIM_TRIS:
- return vertex_ct % 3 == 0;
- case GWN_PRIM_TRI_STRIP:
- case GWN_PRIM_TRI_FAN:
- return vertex_ct >= 3;
- default:
- return false;
- }
- }
-#endif
-
-void immBegin(Gwn_PrimType prim_type, unsigned vertex_ct)
- {
-#if TRUST_NO_ONE
- assert(initialized);
- assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun
- assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type));
-#endif
-
- imm.prim_type = prim_type;
- imm.vertex_ct = vertex_ct;
- imm.vertex_idx = 0;
- imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
-
- // how many bytes do we need for this draw call?
- const unsigned bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_ct);
-
-#if TRUST_NO_ONE
- assert(bytes_needed <= IMM_BUFFER_SIZE);
-#endif
-
- glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id);
-
- // does the current buffer have enough room?
- const unsigned available_bytes = IMM_BUFFER_SIZE - imm.buffer_offset;
- // ensure vertex data is aligned
- const unsigned pre_padding = padding(imm.buffer_offset, imm.vertex_format.stride); // might waste a little space, but it's safe
- if ((bytes_needed + pre_padding) <= available_bytes)
- imm.buffer_offset += pre_padding;
- else
- {
- // orphan this buffer & start with a fresh one
-#if 1
- // this method works on all platforms, old & new
- glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
-#else
- // TODO: use other (more recent) methods after thorough testing
- if (GLEW_VERSION_4_3 || GLEW_ARB_invalidate_subdata)
- glInvalidateBufferData(imm.vbo_id);
- else
- {
- // glitches!
-// glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, GL_MAP_INVALIDATE_BUFFER_BIT);
-
- // works
-// glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE,
-// GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
-// glUnmapBuffer(GL_ARRAY_BUFFER);
-
- // also works
- glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
- }
-#endif
-
- imm.buffer_offset = 0;
- }
-
-// printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1);
-
- imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, bytes_needed,
- GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_ct ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT));
-
-#if TRUST_NO_ONE
- assert(imm.buffer_data != NULL);
-#endif
-
- imm.buffer_bytes_mapped = bytes_needed;
- imm.vertex_data = imm.buffer_data;
- }
-
-void immBeginAtMost(Gwn_PrimType prim_type, unsigned vertex_ct)
- {
-#if TRUST_NO_ONE
- assert(vertex_ct > 0);
-#endif
-
- imm.strict_vertex_ct = false;
- immBegin(prim_type, vertex_ct);
- }
-
-#if IMM_BATCH_COMBO
-
-Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_ct)
- {
-#if TRUST_NO_ONE
- assert(initialized);
- assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun
- assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type));
-#endif
-
- imm.prim_type = prim_type;
- imm.vertex_ct = vertex_ct;
- imm.vertex_idx = 0;
- imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
-
- Gwn_VertBuf* verts = GWN_vertbuf_create_with_format(&imm.vertex_format);
- GWN_vertbuf_data_alloc(verts, vertex_ct);
-
- imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts);
- imm.vertex_data = verts->data;
-
- imm.batch = GWN_batch_create_ex(prim_type, verts, NULL, GWN_BATCH_OWNS_VBO);
- imm.batch->phase = GWN_BATCH_BUILDING;
-
- return imm.batch;
- }
-
-Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, unsigned vertex_ct)
- {
- imm.strict_vertex_ct = false;
- return immBeginBatch(prim_type, vertex_ct);
- }
-
-#endif // IMM_BATCH_COMBO
-
-static void immDrawSetup(void)
- {
- // set up VAO -- can be done during Begin or End really
- glBindVertexArray(imm.vao_id);
-
- // enable/disable vertex attribs as needed
- if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits)
- {
- for (unsigned loc = 0; loc < GWN_VERT_ATTR_MAX_LEN; ++loc)
- {
- bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc);
- bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc);
-
- if (is_enabled && !was_enabled)
- {
-// printf("enabling attrib %u\n", loc);
- glEnableVertexAttribArray(loc);
- }
- else if (was_enabled && !is_enabled)
- {
-// printf("disabling attrib %u\n", loc);
- glDisableVertexAttribArray(loc);
- }
- }
-
- imm.prev_enabled_attrib_bits = imm.attrib_binding.enabled_bits;
- }
-
- const unsigned stride = imm.vertex_format.stride;
-
- for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx)
- {
- const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx;
-
- const unsigned offset = imm.buffer_offset + a->offset;
- const GLvoid* pointer = (const GLubyte*)0 + offset;
-
- const unsigned loc = read_attrib_location(&imm.attrib_binding, a_idx);
-
-// printf("specifying attrib %u '%s' with offset %u, stride %u\n", loc, a->name, offset, stride);
-
- switch (a->fetch_mode)
- {
- case GWN_FETCH_FLOAT:
- case GWN_FETCH_INT_TO_FLOAT:
- glVertexAttribPointer(loc, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer);
- break;
- case GWN_FETCH_INT_TO_FLOAT_UNIT:
- glVertexAttribPointer(loc, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer);
- break;
- case GWN_FETCH_INT:
- glVertexAttribIPointer(loc, a->comp_ct, a->gl_comp_type, stride, pointer);
- }
- }
-
- if (gpuMatricesDirty())
- gpuBindMatrices(imm.shader_interface);
- }
-
-void immEnd(void)
- {
-#if TRUST_NO_ONE
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- unsigned buffer_bytes_used;
- if (imm.strict_vertex_ct)
- {
-#if TRUST_NO_ONE
- assert(imm.vertex_idx == imm.vertex_ct); // with all vertices defined
-#endif
- buffer_bytes_used = imm.buffer_bytes_mapped;
- }
- else
- {
-#if TRUST_NO_ONE
- assert(imm.vertex_idx <= imm.vertex_ct);
-#endif
- // printf("used %u of %u verts,", imm.vertex_idx, imm.vertex_ct);
- if (imm.vertex_idx == imm.vertex_ct)
- {
- buffer_bytes_used = imm.buffer_bytes_mapped;
- }
- else
- {
-#if TRUST_NO_ONE
- assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type));
-#endif
- imm.vertex_ct = imm.vertex_idx;
- buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_ct);
- // unused buffer bytes are available to the next immBegin
- // printf(" %u of %u bytes\n", buffer_bytes_used, imm.buffer_bytes_mapped);
- }
-
- // tell OpenGL what range was modified so it doesn't copy the whole mapped range
- // printf("flushing %u to %u\n", imm.buffer_offset, imm.buffer_offset + buffer_bytes_used - 1);
- glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, buffer_bytes_used);
- }
-
-#if IMM_BATCH_COMBO
- if (imm.batch)
- {
- if (buffer_bytes_used != imm.buffer_bytes_mapped)
- {
- GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_ct);
- // TODO: resize only if vertex count is much smaller
- }
-
- GWN_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface);
- imm.batch->phase = GWN_BATCH_READY_TO_DRAW;
- imm.batch = NULL; // don't free, batch belongs to caller
- }
- else
-#endif
- {
- glUnmapBuffer(GL_ARRAY_BUFFER);
-
- if (imm.vertex_ct > 0)
- {
- immDrawSetup();
- glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_ct);
- }
-
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindVertexArray(0);
-
- // prep for next immBegin
- imm.buffer_offset += buffer_bytes_used;
- }
-
- // prep for next immBegin
- imm.prim_type = GWN_PRIM_NONE;
- imm.strict_vertex_ct = true;
- }
-
-static void setAttribValueBit(unsigned attrib_id)
- {
- uint16_t mask = 1 << attrib_id;
-
-#if TRUST_NO_ONE
- assert(imm.unassigned_attrib_bits & mask); // not already set
-#endif
-
- imm.unassigned_attrib_bits &= ~mask;
- }
-
-
-// --- generic attribute functions ---
-
-void immAttrib1f(unsigned attrib_id, float x)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_F32);
- assert(attrib->comp_ct == 1);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- float* data = (float*)(imm.vertex_data + attrib->offset);
-// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
-
- data[0] = x;
- }
-
-void immAttrib2f(unsigned attrib_id, float x, float y)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_F32);
- assert(attrib->comp_ct == 2);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- float* data = (float*)(imm.vertex_data + attrib->offset);
-// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
-
- data[0] = x;
- data[1] = y;
- }
-
-void immAttrib3f(unsigned attrib_id, float x, float y, float z)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_F32);
- assert(attrib->comp_ct == 3);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- float* data = (float*)(imm.vertex_data + attrib->offset);
-// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
-
- data[0] = x;
- data[1] = y;
- data[2] = z;
- }
-
-void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_F32);
- assert(attrib->comp_ct == 4);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- float* data = (float*)(imm.vertex_data + attrib->offset);
-// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
-
- data[0] = x;
- data[1] = y;
- data[2] = z;
- data[3] = w;
- }
-
-void immAttrib1u(unsigned attrib_id, unsigned x)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_U32);
- assert(attrib->comp_ct == 1);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- unsigned* data = (unsigned*)(imm.vertex_data + attrib->offset);
-
- data[0] = x;
- }
-
-void immAttrib2i(unsigned attrib_id, int x, int y)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_I32);
- assert(attrib->comp_ct == 2);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- int* data = (int*)(imm.vertex_data + attrib->offset);
-
- data[0] = x;
- data[1] = y;
- }
-
-void immAttrib2s(unsigned attrib_id, short x, short y)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_I16);
- assert(attrib->comp_ct == 2);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- short* data = (short*)(imm.vertex_data + attrib->offset);
-
- data[0] = x;
- data[1] = y;
- }
-
-void immAttrib2fv(unsigned attrib_id, const float data[2])
- {
- immAttrib2f(attrib_id, data[0], data[1]);
- }
-
-void immAttrib3fv(unsigned attrib_id, const float data[3])
- {
- immAttrib3f(attrib_id, data[0], data[1], data[2]);
- }
-
-void immAttrib4fv(unsigned attrib_id, const float data[4])
- {
- immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]);
- }
-
-void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_U8);
- assert(attrib->comp_ct == 3);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- GLubyte* data = imm.vertex_data + attrib->offset;
-// printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data);
-
- data[0] = r;
- data[1] = g;
- data[2] = b;
- }
-
-void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
- {
- Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
-
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(attrib->comp_type == GWN_COMP_U8);
- assert(attrib->comp_ct == 4);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
-
- GLubyte* data = imm.vertex_data + attrib->offset;
-// printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data);
-
- data[0] = r;
- data[1] = g;
- data[2] = b;
- data[3] = a;
- }
-
-void immAttrib3ubv(unsigned attrib_id, const unsigned char data[3])
- {
- immAttrib3ub(attrib_id, data[0], data[1], data[2]);
- }
-
-void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4])
- {
- immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]);
- }
-
-void immSkipAttrib(unsigned attrib_id)
- {
-#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attrib_ct);
- assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
-#endif
-
- setAttribValueBit(attrib_id);
- }
-
-static void immEndVertex(void) // and move on to the next vertex
- {
-#if TRUST_NO_ONE
- assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
- assert(imm.vertex_idx < imm.vertex_ct);
-#endif
-
- // have all attribs been assigned values?
- // if not, copy value from previous vertex
- if (imm.unassigned_attrib_bits)
- {
-#if TRUST_NO_ONE
- assert(imm.vertex_idx > 0); // first vertex must have all attribs specified
-#endif
-
- for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx)
- {
- if ((imm.unassigned_attrib_bits >> a_idx) & 1)
- {
- const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx;
-
-// printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx);
-
- GLubyte* data = imm.vertex_data + a->offset;
- memcpy(data, data - imm.vertex_format.stride, a->sz);
- // TODO: consolidate copy of adjacent attributes
- }
- }
- }
-
- imm.vertex_idx++;
- imm.vertex_data += imm.vertex_format.stride;
- imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
- }
-
-void immVertex2f(unsigned attrib_id, float x, float y)
- {
- immAttrib2f(attrib_id, x, y);
- immEndVertex();
- }
-
-void immVertex3f(unsigned attrib_id, float x, float y, float z)
- {
- immAttrib3f(attrib_id, x, y, z);
- immEndVertex();
- }
-
-void immVertex4f(unsigned attrib_id, float x, float y, float z, float w)
- {
- immAttrib4f(attrib_id, x, y, z, w);
- immEndVertex();
- }
-
-void immVertex2i(unsigned attrib_id, int x, int y)
- {
- immAttrib2i(attrib_id, x, y);
- immEndVertex();
- }
-
-void immVertex2s(unsigned attrib_id, short x, short y)
- {
- immAttrib2s(attrib_id, x, y);
- immEndVertex();
- }
-
-void immVertex2fv(unsigned attrib_id, const float data[2])
- {
- immAttrib2f(attrib_id, data[0], data[1]);
- immEndVertex();
- }
-
-void immVertex3fv(unsigned attrib_id, const float data[3])
- {
- immAttrib3f(attrib_id, data[0], data[1], data[2]);
- immEndVertex();
- }
-
-void immVertex2iv(unsigned attrib_id, const int data[2])
- {
- immAttrib2i(attrib_id, data[0], data[1]);
- immEndVertex();
- }
-
-
-// --- generic uniform functions ---
-
-#if 0
- #if TRUST_NO_ONE
- #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); assert(uniform);
- #else
- #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name);
- #endif
-#else
- // NOTE: It is possible to have uniform fully optimized out from the shader.
- // In this case we can't assert failure or allow NULL-pointer dereference.
- // TODO(sergey): How can we detect existing-but-optimized-out uniform but still
- // catch typos in uniform names passed to immUniform*() functions?
- #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
-#endif
-
-void immUniform1f(const char* name, float x)
- {
- GET_UNIFORM
- glUniform1f(uniform->location, x);
- }
-
-void immUniform2f(const char* name, float x, float y)
- {
- GET_UNIFORM
- glUniform2f(uniform->location, x, y);
- }
-
-void immUniform2fv(const char* name, const float data[2])
- {
- GET_UNIFORM
- glUniform2fv(uniform->location, 1, data);
- }
-
-void immUniform3f(const char* name, float x, float y, float z)
- {
- GET_UNIFORM
- glUniform3f(uniform->location, x, y, z);
- }
-
-void immUniform3fv(const char* name, const float data[3])
- {
- GET_UNIFORM
- glUniform3fv(uniform->location, 1, data);
- }
-
-// can increase this limit or move to another file
-#define MAX_UNIFORM_NAME_LEN 60
-
-void immUniformArray3fv(const char* bare_name, const float *data, int count)
- {
- // look up "name[0]" when given "name"
- const size_t len = strlen(bare_name);
-#if TRUST_NO_ONE
- assert(len <= MAX_UNIFORM_NAME_LEN);
-#endif
- char name[MAX_UNIFORM_NAME_LEN];
- strcpy(name, bare_name);
- name[len + 0] = '[';
- name[len + 1] = '0';
- name[len + 2] = ']';
- name[len + 3] = '\0';
-
- GET_UNIFORM
- glUniform3fv(uniform->location, count, data);
- }
-
-void immUniform4f(const char* name, float x, float y, float z, float w)
- {
- GET_UNIFORM
- glUniform4f(uniform->location, x, y, z, w);
- }
-
-void immUniform4fv(const char* name, const float data[4])
- {
- GET_UNIFORM
- glUniform4fv(uniform->location, 1, data);
- }
-
-void immUniformArray4fv(const char* bare_name, const float *data, int count)
- {
- // look up "name[0]" when given "name"
- const size_t len = strlen(bare_name);
-#if TRUST_NO_ONE
- assert(len <= MAX_UNIFORM_NAME_LEN);
-#endif
- char name[MAX_UNIFORM_NAME_LEN];
- strcpy(name, bare_name);
- name[len + 0] = '[';
- name[len + 1] = '0';
- name[len + 2] = ']';
- name[len + 3] = '\0';
-
- GET_UNIFORM
- glUniform4fv(uniform->location, count, data);
- }
-
-void immUniformMatrix4fv(const char* name, const float data[4][4])
- {
- GET_UNIFORM
- glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (float *)data);
- }
-
-void immUniform1i(const char* name, int x)
- {
- GET_UNIFORM
- glUniform1i(uniform->location, x);
- }
-
-void immUniform4iv(const char* name, const int data[4])
- {
- GET_UNIFORM
- glUniform4iv(uniform->location, 1, data);
- }
-
-// --- convenience functions for setting "uniform vec4 color" ---
-
-void immUniformColor4f(float r, float g, float b, float a)
- {
- const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform_builtin(imm.shader_interface, GWN_UNIFORM_COLOR);
-
-#if TRUST_NO_ONE
- assert(uniform != NULL);
-#endif
-
- glUniform4f(uniform->location, r, g, b, a);
- }
-
-void immUniformColor4fv(const float rgba[4])
- {
- immUniformColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
- }
-
-void immUniformColor3f(float r, float g, float b)
- {
- immUniformColor4f(r, g, b, 1.0f);
- }
-
-void immUniformColor3fv(const float rgb[3])
- {
- immUniformColor4f(rgb[0], rgb[1], rgb[2], 1.0f);
- }
-
-void immUniformColor3fvAlpha(const float rgb[3], float a)
- {
- immUniformColor4f(rgb[0], rgb[1], rgb[2], a);
- }
-
-// TODO: v-- treat as sRGB? --v
-
-void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b)
- {
- const float scale = 1.0f / 255.0f;
- immUniformColor4f(scale * r, scale * g, scale * b, 1.0f);
- }
-
-void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
- {
- const float scale = 1.0f / 255.0f;
- immUniformColor4f(scale * r, scale * g, scale * b, scale * a);
- }
-
-void immUniformColor3ubv(const unsigned char rgb[3])
- {
- immUniformColor3ub(rgb[0], rgb[1], rgb[2]);
- }
-
-void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char alpha)
- {
- immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha);
- }
-
-void immUniformColor4ubv(const unsigned char rgba[4])
- {
- immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]);
- }
diff --git a/intern/gawain/src/gwn_primitive.c b/intern/gawain/src/gwn_primitive.c
deleted file mode 100644
index c2638bcc8c8..00000000000
--- a/intern/gawain/src/gwn_primitive.c
+++ /dev/null
@@ -1,67 +0,0 @@
-
-// Gawain geometric primitives
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_primitive.h"
-#include "gwn_primitive_private.h"
-
-Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type)
- {
- static const Gwn_PrimClass classes[] =
- {
- [GWN_PRIM_POINTS] = GWN_PRIM_CLASS_POINT,
- [GWN_PRIM_LINES] = GWN_PRIM_CLASS_LINE,
- [GWN_PRIM_LINE_STRIP] = GWN_PRIM_CLASS_LINE,
- [GWN_PRIM_LINE_LOOP] = GWN_PRIM_CLASS_LINE,
- [GWN_PRIM_TRIS] = GWN_PRIM_CLASS_SURFACE,
- [GWN_PRIM_TRI_STRIP] = GWN_PRIM_CLASS_SURFACE,
- [GWN_PRIM_TRI_FAN] = GWN_PRIM_CLASS_SURFACE,
-
- [GWN_PRIM_LINES_ADJ] = GWN_PRIM_CLASS_LINE,
- [GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE,
- [GWN_PRIM_TRIS_ADJ] = GWN_PRIM_CLASS_SURFACE,
-
- [GWN_PRIM_NONE] = GWN_PRIM_CLASS_NONE
- };
-
- return classes[prim_type];
- }
-
-bool GWN_primtype_belongs_to_class(Gwn_PrimType prim_type, Gwn_PrimClass prim_class)
- {
- if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE)
- return true;
-
- return prim_class & GWN_primtype_class(prim_type);
- }
-
-GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type)
- {
-#if TRUST_NO_ONE
- assert(prim_type != GWN_PRIM_NONE);
-#endif
-
- static const GLenum table[] =
- {
- [GWN_PRIM_POINTS] = GL_POINTS,
- [GWN_PRIM_LINES] = GL_LINES,
- [GWN_PRIM_LINE_STRIP] = GL_LINE_STRIP,
- [GWN_PRIM_LINE_LOOP] = GL_LINE_LOOP,
- [GWN_PRIM_TRIS] = GL_TRIANGLES,
- [GWN_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP,
- [GWN_PRIM_TRI_FAN] = GL_TRIANGLE_FAN,
-
- [GWN_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY,
- [GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY,
- [GWN_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY,
- };
-
- return table[prim_type];
- }
diff --git a/intern/gawain/src/gwn_shader_interface.c b/intern/gawain/src/gwn_shader_interface.c
deleted file mode 100644
index 16451573bba..00000000000
--- a/intern/gawain/src/gwn_shader_interface.c
+++ /dev/null
@@ -1,362 +0,0 @@
-
-// Gawain shader interface (C --> GLSL)
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_batch_private.h"
-#include "gwn_shader_interface.h"
-#include "gwn_vertex_array_id.h"
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-
-#define DEBUG_SHADER_INTERFACE 0
-
-#if DEBUG_SHADER_INTERFACE
- #include <stdio.h>
-#endif
-
-static const char* BuiltinUniform_name(Gwn_UniformBuiltin u)
- {
- static const char* names[] =
- {
- [GWN_UNIFORM_NONE] = NULL,
-
- [GWN_UNIFORM_MODEL] = "ModelMatrix",
- [GWN_UNIFORM_VIEW] = "ViewMatrix",
- [GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix",
- [GWN_UNIFORM_PROJECTION] = "ProjectionMatrix",
- [GWN_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix",
- [GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix",
-
- [GWN_UNIFORM_MODEL_INV] = "ModelMatrixInverse",
- [GWN_UNIFORM_VIEW_INV] = "ViewMatrixInverse",
- [GWN_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse",
- [GWN_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse",
- [GWN_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse",
-
- [GWN_UNIFORM_NORMAL] = "NormalMatrix",
- [GWN_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix",
- [GWN_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors",
- [GWN_UNIFORM_ORCO] = "OrcoTexCoFactors",
-
- [GWN_UNIFORM_COLOR] = "color",
- [GWN_UNIFORM_EYE] = "eye",
- [GWN_UNIFORM_CALLID] = "callId",
-
- [GWN_UNIFORM_CUSTOM] = NULL,
- [GWN_NUM_UNIFORMS] = NULL,
- };
-
- return names[u];
- }
-
-GWN_INLINE bool match(const char* a, const char* b)
- {
- return strcmp(a, b) == 0;
- }
-
-GWN_INLINE unsigned hash_string(const char *str)
- {
- unsigned i = 0, c;
-
- while ((c = *str++))
- {
- i = i * 37 + c;
- }
-
- return i;
- }
-
-GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* input,
- const char* name, uint32_t name_len)
- {
- input->name_offset = shaderface->name_buffer_offset;
- input->name_hash = hash_string(name);
- shaderface->name_buffer_offset += name_len + 1; // include NULL terminator
- }
-
-GWN_INLINE void shader_input_to_bucket(Gwn_ShaderInput* input,
- Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS])
- {
- const unsigned bucket_index = input->name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS;
- input->next = buckets[bucket_index];
- buckets[bucket_index] = input;
- }
-
-GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[GWN_NUM_SHADERINTERFACE_BUCKETS],
- const char *name_buffer, const char *name)
- {
- const unsigned name_hash = hash_string(name);
- const unsigned bucket_index = name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS;
- const Gwn_ShaderInput* input = buckets[bucket_index];
- if (input == NULL)
- {
- // Requested uniform is not found at all.
- return NULL;
- }
- // Optimization bit: if there is no hash collision detected when constructing shader interface
- // it means we can only request the single possible uniform. Surely, it's possible we request
- // uniform which causes hash collision, but that will be detected in debug builds.
- if (input->next == NULL)
- {
- if (name_hash == input->name_hash)
- {
-#if TRUST_NO_ONE
- assert(match(name_buffer + input->name_offset, name));
-#endif
- return input;
- }
- return NULL;
- }
- // Work through possible collisions.
- const Gwn_ShaderInput* next = input;
- while (next != NULL)
- {
- input = next;
- next = input->next;
-
- if (input->name_hash != name_hash)
- {
- continue;
- }
- if (match(name_buffer + input->name_offset, name))
- {
- return input;
- }
- }
- return NULL; // not found
- }
-
-GWN_INLINE void buckets_free(Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS])
- {
- for (unsigned bucket_index = 0; bucket_index < GWN_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index)
- {
- Gwn_ShaderInput *input = buckets[bucket_index];
- while (input != NULL)
- {
- Gwn_ShaderInput *input_next = input->next;
- free(input);
- input = input_next;
- }
- }
- }
-
-static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name)
- {
- // TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types
-
- // detect built-in uniforms (name must match)
- for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u)
- {
- const char* builtin_name = BuiltinUniform_name(u);
- if (match(name, builtin_name))
- {
- input->builtin_type = u;
- return true;
- }
- }
-
- input->builtin_type = GWN_UNIFORM_CUSTOM;
- return false;
- }
-
-static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const char* name)
- {
- Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput));
-
- input->location = glGetUniformLocation(shaderface->program, name);
-
- unsigned name_len = strlen(name);
- shaderface->name_buffer = realloc(shaderface->name_buffer, shaderface->name_buffer_offset + name_len + 1); // include NULL terminator
- char* name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset;
- strcpy(name_buffer, name);
-
- set_input_name(shaderface, input, name, name_len);
- setup_builtin_uniform(input, name);
-
- shader_input_to_bucket(input, shaderface->uniform_buckets);
- if (input->builtin_type != GWN_UNIFORM_NONE &&
- input->builtin_type != GWN_UNIFORM_CUSTOM)
- {
- shaderface->builtin_uniforms[input->builtin_type] = input;
- }
-#if DEBUG_SHADER_INTERFACE
- printf("Gwn_ShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, shaderface->program, name, input->location);
-#endif
- return input;
- }
-
-Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program)
- {
- Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface));
- shaderface->program = program;
-
-#if DEBUG_SHADER_INTERFACE
- printf("%s {\n", __func__); // enter function
- printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program);
-#endif
-
- GLint max_attrib_name_len, attrib_ct;
- glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len);
- glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attrib_ct);
-
- GLint max_ubo_name_len, ubo_ct;
- glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len);
- glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_ct);
-
- const uint32_t name_buffer_len = attrib_ct * max_attrib_name_len + ubo_ct * max_ubo_name_len;
- shaderface->name_buffer = malloc(name_buffer_len);
-
- // Attributes
- for (uint32_t i = 0; i < attrib_ct; ++i)
- {
- Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput));
- GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset;
- char* name = shaderface->name_buffer + shaderface->name_buffer_offset;
- GLsizei name_len = 0;
-
- glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name);
-
- // remove "[0]" from array name
- if (name[name_len-1] == ']')
- {
- name[name_len-3] = '\0';
- name_len -= 3;
- }
-
- // TODO: reject DOUBLE gl_types
-
- input->location = glGetAttribLocation(program, name);
-
- set_input_name(shaderface, input, name, name_len);
-
- shader_input_to_bucket(input, shaderface->attrib_buckets);
-
-#if DEBUG_SHADER_INTERFACE
- printf("attrib[%u] '%s' at location %d\n", i, name, input->location);
-#endif
- }
-
- // Uniform Blocks
- for (uint32_t i = 0; i < ubo_ct; ++i)
- {
- Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput));
- GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset;
- char* name = shaderface->name_buffer + shaderface->name_buffer_offset;
- GLsizei name_len = 0;
-
- glGetActiveUniformBlockName(program, i, remaining_buffer, &name_len, name);
-
- input->location = i;
-
- set_input_name(shaderface, input, name, name_len);
-
- shader_input_to_bucket(input, shaderface->ubo_buckets);
-
-#if DEBUG_SHADER_INTERFACE
- printf("ubo '%s' at location %d\n", name, input->location);
-#endif
- }
-
- // Builtin Uniforms
- for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u)
- {
- const char* builtin_name = BuiltinUniform_name(u);
- if (glGetUniformLocation(program, builtin_name) != -1)
- add_uniform((Gwn_ShaderInterface*)shaderface, builtin_name);
- }
-
- // Batches ref buffer
- shaderface->batches_ct = GWN_SHADERINTERFACE_REF_ALLOC_COUNT;
- shaderface->batches = calloc(shaderface->batches_ct, sizeof(Gwn_Batch*));
-
- return shaderface;
- }
-
-void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface)
- {
- // Free memory used by buckets and has entries.
- buckets_free(shaderface->uniform_buckets);
- buckets_free(shaderface->attrib_buckets);
- buckets_free(shaderface->ubo_buckets);
- // Free memory used by name_buffer.
- free(shaderface->name_buffer);
- // Remove this interface from all linked Batches vao cache.
- for (int i = 0; i < shaderface->batches_ct; ++i)
- if (shaderface->batches[i] != NULL)
- gwn_batch_remove_interface_ref(shaderface->batches[i], shaderface);
-
- free(shaderface->batches);
- // Free memory used by shader interface by its self.
- free(shaderface);
- }
-
-const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name)
- {
- // TODO: Warn if we find a matching builtin, since these can be looked up much quicker.
- const Gwn_ShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name);
-
- // If input is not found add it so it's found next time.
- if (input == NULL)
- input = add_uniform((Gwn_ShaderInterface*)shaderface, name);
-
- return (input->location != -1) ? input : NULL;
- }
-
-const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin)
- {
-#if TRUST_NO_ONE
- assert(builtin != GWN_UNIFORM_NONE);
- assert(builtin != GWN_UNIFORM_CUSTOM);
- assert(builtin != GWN_NUM_UNIFORMS);
-#endif
- return shaderface->builtin_uniforms[builtin];
- }
-
-const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface* shaderface, const char* name)
- {
- return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name);
- }
-
-const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name)
- {
- return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name);
- }
-
-void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch)
- {
- int i; // find first unused slot
- for (i = 0; i < shaderface->batches_ct; ++i)
- if (shaderface->batches[i] == NULL)
- break;
-
- if (i == shaderface->batches_ct)
- {
- // Not enough place, realloc the array.
- i = shaderface->batches_ct;
- shaderface->batches_ct += GWN_SHADERINTERFACE_REF_ALLOC_COUNT;
- shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_ct);
- memset(shaderface->batches + i, 0, sizeof(Gwn_Batch*) * GWN_SHADERINTERFACE_REF_ALLOC_COUNT);
- }
-
- shaderface->batches[i] = batch;
- }
-
-void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch)
- {
- for (int i = 0; i < shaderface->batches_ct; ++i)
- {
- if (shaderface->batches[i] == batch)
- {
- shaderface->batches[i] = NULL;
- break; // cannot have duplicates
- }
- }
- }
diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp
deleted file mode 100644
index 2ab38a8fe18..00000000000
--- a/intern/gawain/src/gwn_vertex_array_id.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-
-// Gawain vertex array IDs
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin, Clément Foucault
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.#include "buffer_id.h"
-
-#include "gwn_batch_private.h"
-#include "gwn_vertex_array_id.h"
-#include "gwn_context.h"
-#include <vector>
-#include <string.h>
-#include <pthread.h>
-#include <mutex>
-#include <unordered_set>
-
-#if 0
-extern "C" {
-extern int BLI_thread_is_main(void); // Blender-specific function
-}
-
-static bool thread_is_main()
- {
- // "main" here means the GL context's thread
- return BLI_thread_is_main();
- }
-#endif
-
-struct Gwn_Context {
- GLuint default_vao;
- std::unordered_set<Gwn_Batch*> batches; // Batches that have VAOs from this context
- std::vector<GLuint> orphaned_vertarray_ids;
- std::mutex orphans_mutex; // todo: try spinlock instead
-#if TRUST_NO_ONE
- pthread_t thread; // Thread on which this context is active.
- bool thread_is_used;
-
- Gwn_Context()
- {
- thread_is_used = false;
- }
-#endif
-};
-
-#if defined(_MSC_VER) && (_MSC_VER == 1800)
-#define thread_local __declspec(thread)
-thread_local Gwn_Context* active_ctx = NULL;
-#else
-static thread_local Gwn_Context* active_ctx = NULL;
-#endif
-
-static void clear_orphans(Gwn_Context* ctx)
- {
- ctx->orphans_mutex.lock();
- if (!ctx->orphaned_vertarray_ids.empty())
- {
- unsigned orphan_ct = (unsigned)ctx->orphaned_vertarray_ids.size();
- glDeleteVertexArrays(orphan_ct, ctx->orphaned_vertarray_ids.data());
- ctx->orphaned_vertarray_ids.clear();
- }
- ctx->orphans_mutex.unlock();
- }
-
-Gwn_Context* GWN_context_create(void)
- {
-#if TRUST_NO_ONE
- /* We cannot rely on this anymore. */
- // assert(thread_is_main());
-#endif
- Gwn_Context* ctx = new Gwn_Context;
- glGenVertexArrays(1, &ctx->default_vao);
- GWN_context_active_set(ctx);
- return ctx;
- }
-
-// to be called after GWN_context_active_set(ctx_to_destroy)
-void GWN_context_discard(Gwn_Context* ctx)
- {
-#if TRUST_NO_ONE
- // Make sure no other thread has locked it.
- assert(ctx == active_ctx);
- assert(pthread_equal(pthread_self(), ctx->thread));
- assert(ctx->orphaned_vertarray_ids.empty());
-#endif
- // delete remaining vaos
- while (!ctx->batches.empty())
- {
- // this removes the array entry
- gwn_batch_vao_cache_clear(*ctx->batches.begin());
- }
- glDeleteVertexArrays(1, &ctx->default_vao);
- delete ctx;
- active_ctx = NULL;
- }
-
-// ctx can be NULL
-void GWN_context_active_set(Gwn_Context* ctx)
- {
-#if TRUST_NO_ONE
- if (active_ctx)
- active_ctx->thread_is_used = false;
- // Make sure no other context is already bound to this thread.
- if (ctx)
- {
- // Make sure no other thread has locked it.
- assert(ctx->thread_is_used == false);
- ctx->thread = pthread_self();
- ctx->thread_is_used = true;
- }
-#endif
- if (ctx)
- clear_orphans(ctx);
- active_ctx = ctx;
- }
-
-Gwn_Context* GWN_context_active_get(void)
- {
- return active_ctx;
- }
-
-GLuint GWN_vao_default(void)
- {
-#if TRUST_NO_ONE
- assert(active_ctx); // need at least an active context
- assert(pthread_equal(pthread_self(), active_ctx->thread)); // context has been activated by another thread!
-#endif
- return active_ctx->default_vao;
- }
-
-GLuint GWN_vao_alloc(void)
- {
-#if TRUST_NO_ONE
- assert(active_ctx); // need at least an active context
- assert(pthread_equal(pthread_self(), active_ctx->thread)); // context has been activated by another thread!
-#endif
- clear_orphans(active_ctx);
-
- GLuint new_vao_id = 0;
- glGenVertexArrays(1, &new_vao_id);
- return new_vao_id;
- }
-
-// this can be called from multiple thread
-void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx)
- {
-#if TRUST_NO_ONE
- assert(ctx);
-#endif
- if (ctx == active_ctx)
- glDeleteVertexArrays(1, &vao_id);
- else
- {
- ctx->orphans_mutex.lock();
- ctx->orphaned_vertarray_ids.emplace_back(vao_id);
- ctx->orphans_mutex.unlock();
- }
- }
-
-void gwn_context_add_batch(Gwn_Context* ctx, Gwn_Batch* batch)
- {
- ctx->batches.emplace(batch);
- }
-
-void gwn_context_remove_batch(Gwn_Context* ctx, Gwn_Batch* batch)
- {
- ctx->orphans_mutex.lock();
- ctx->batches.erase(batch);
- ctx->orphans_mutex.unlock();
- }
diff --git a/intern/gawain/src/gwn_vertex_buffer.c b/intern/gawain/src/gwn_vertex_buffer.c
deleted file mode 100644
index f621b4c01b9..00000000000
--- a/intern/gawain/src/gwn_vertex_buffer.c
+++ /dev/null
@@ -1,258 +0,0 @@
-
-// Gawain vertex buffer
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_vertex_buffer.h"
-#include "gwn_buffer_id.h"
-#include "gwn_vertex_format_private.h"
-#include <stdlib.h>
-#include <string.h>
-
-#define KEEP_SINGLE_COPY 1
-
-static unsigned vbo_memory_usage;
-
-static GLenum convert_usage_type_to_gl(Gwn_UsageType type)
- {
- static const GLenum table[] = {
- [GWN_USAGE_STREAM] = GL_STREAM_DRAW,
- [GWN_USAGE_STATIC] = GL_STATIC_DRAW,
- [GWN_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW
- };
- return table[type];
- }
-
-Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType usage)
- {
- Gwn_VertBuf* verts = malloc(sizeof(Gwn_VertBuf));
- GWN_vertbuf_init(verts, usage);
- return verts;
- }
-
-Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat* format, Gwn_UsageType usage)
- {
- Gwn_VertBuf* verts = GWN_vertbuf_create(usage);
- GWN_vertformat_copy(&verts->format, format);
- if (!format->packed)
- VertexFormat_pack(&verts->format);
- return verts;
-
- // this function might seem redundant, but there is potential for memory savings here...
- // TODO: implement those memory savings
- }
-
-void GWN_vertbuf_init(Gwn_VertBuf* verts, Gwn_UsageType usage)
- {
- memset(verts, 0, sizeof(Gwn_VertBuf));
- verts->usage = usage;
- verts->dirty = true;
- }
-
-void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf* verts, const Gwn_VertFormat* format, Gwn_UsageType usage)
- {
- GWN_vertbuf_init(verts, usage);
- GWN_vertformat_copy(&verts->format, format);
- if (!format->packed)
- VertexFormat_pack(&verts->format);
- }
-
-void GWN_vertbuf_discard(Gwn_VertBuf* verts)
- {
- if (verts->vbo_id)
- {
- GWN_buf_id_free(verts->vbo_id);
-#if VRAM_USAGE
- vbo_memory_usage -= GWN_vertbuf_size_get(verts);
-#endif
- }
-
- if (verts->data)
- free(verts->data);
-
- free(verts);
- }
-
-unsigned GWN_vertbuf_size_get(const Gwn_VertBuf* verts)
- {
- return vertex_buffer_size(&verts->format, verts->vertex_ct);
- }
-
-// create a new allocation, discarding any existing data
-void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_ct)
- {
- Gwn_VertFormat* format = &verts->format;
- if (!format->packed)
- VertexFormat_pack(format);
-
-#if TRUST_NO_ONE
- // catch any unnecessary use
- assert(verts->vertex_alloc != v_ct || verts->data == NULL);
-#endif
-
- // only create the buffer the 1st time
- if (verts->vbo_id == 0)
- verts->vbo_id = GWN_buf_id_alloc();
-
- // discard previous data if any
- if (verts->data)
- free(verts->data);
-
-#if VRAM_USAGE
- unsigned new_size = vertex_buffer_size(&verts->format, v_ct);
- vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts);
-#endif
-
- verts->dirty = true;
- verts->vertex_ct = verts->vertex_alloc = v_ct;
- verts->data = malloc(sizeof(GLubyte) * GWN_vertbuf_size_get(verts));
- }
-
-// resize buffer keeping existing data
-void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, unsigned v_ct)
- {
-#if TRUST_NO_ONE
- assert(verts->data != NULL);
- assert(verts->vertex_alloc != v_ct);
-#endif
-
-#if VRAM_USAGE
- unsigned new_size = vertex_buffer_size(&verts->format, v_ct);
- vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts);
-#endif
-
- verts->dirty = true;
- verts->vertex_ct = verts->vertex_alloc = v_ct;
- verts->data = realloc(verts->data, sizeof(GLubyte) * GWN_vertbuf_size_get(verts));
- }
-
-// set vertex count but does not change allocation
-// only this many verts will be uploaded to the GPU and rendered
-// this is usefull for streaming data
-void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, unsigned v_ct)
- {
-#if TRUST_NO_ONE
- assert(verts->data != NULL); // only for dynamic data
- assert(v_ct <= verts->vertex_alloc);
-#endif
-
-#if VRAM_USAGE
- unsigned new_size = vertex_buffer_size(&verts->format, v_ct);
- vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts);
-#endif
-
- verts->vertex_ct = v_ct;
- }
-
-void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, unsigned a_idx, unsigned v_idx, const void* data)
- {
- const Gwn_VertFormat* format = &verts->format;
- const Gwn_VertAttr* a = format->attribs + a_idx;
-
-#if TRUST_NO_ONE
- assert(a_idx < format->attrib_ct);
- assert(v_idx < verts->vertex_alloc);
- assert(verts->data != NULL);
-#endif
-
- verts->dirty = true;
- memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz);
- }
-
-void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, unsigned a_idx, const void* data)
- {
- const Gwn_VertFormat* format = &verts->format;
- const Gwn_VertAttr* a = format->attribs + a_idx;
-
-#if TRUST_NO_ONE
- assert(a_idx < format->attrib_ct);
-#endif
-
- const unsigned stride = a->sz; // tightly packed input data
-
- GWN_vertbuf_attr_fill_stride(verts, a_idx, stride, data);
- }
-
-void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, unsigned a_idx, unsigned stride, const void* data)
- {
- const Gwn_VertFormat* format = &verts->format;
- const Gwn_VertAttr* a = format->attribs + a_idx;
-
-#if TRUST_NO_ONE
- assert(a_idx < format->attrib_ct);
- assert(verts->data != NULL);
-#endif
-
- verts->dirty = true;
- const unsigned vertex_ct = verts->vertex_ct;
-
- if (format->attrib_ct == 1 && stride == format->stride)
- {
- // we can copy it all at once
- memcpy(verts->data, data, vertex_ct * a->sz);
- }
- else
- {
- // we must copy it per vertex
- for (unsigned v = 0; v < vertex_ct; ++v)
- memcpy((GLubyte*)verts->data + a->offset + v * format->stride, (const GLubyte*)data + v * stride, a->sz);
- }
- }
-
-void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, unsigned a_idx, Gwn_VertBufRaw *access)
- {
- const Gwn_VertFormat* format = &verts->format;
- const Gwn_VertAttr* a = format->attribs + a_idx;
-
-#if TRUST_NO_ONE
- assert(a_idx < format->attrib_ct);
- assert(verts->data != NULL);
-#endif
-
- verts->dirty = true;
-
- access->size = a->sz;
- access->stride = format->stride;
- access->data = (GLubyte*)verts->data + a->offset;
- access->data_init = access->data;
-#if TRUST_NO_ONE
- access->_data_end = access->data_init + (size_t)(verts->vertex_alloc * format->stride);
-#endif
- }
-
-static void VertBuffer_upload_data(Gwn_VertBuf* verts)
- {
- unsigned buffer_sz = GWN_vertbuf_size_get(verts);
-
- // orphan the vbo to avoid sync
- glBufferData(GL_ARRAY_BUFFER, buffer_sz, NULL, convert_usage_type_to_gl(verts->usage));
- // upload data
- glBufferSubData(GL_ARRAY_BUFFER, 0, buffer_sz, verts->data);
-
- if (verts->usage == GWN_USAGE_STATIC)
- {
- free(verts->data);
- verts->data = NULL;
- }
-
- verts->dirty = false;
- }
-
-void GWN_vertbuf_use(Gwn_VertBuf* verts)
- {
- glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id);
-
- if (verts->dirty)
- VertBuffer_upload_data(verts);
- }
-
-unsigned GWN_vertbuf_get_memory_usage(void)
- {
- return vbo_memory_usage;
- }
diff --git a/intern/gawain/src/gwn_vertex_format.c b/intern/gawain/src/gwn_vertex_format.c
deleted file mode 100644
index c180c304d28..00000000000
--- a/intern/gawain/src/gwn_vertex_format.c
+++ /dev/null
@@ -1,291 +0,0 @@
-
-// Gawain vertex format
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2016 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "gwn_vertex_format.h"
-#include "gwn_vertex_format_private.h"
-#include <stddef.h>
-#include <string.h>
-
-#define PACK_DEBUG 0
-
-#if PACK_DEBUG
- #include <stdio.h>
-#endif
-
-void GWN_vertformat_clear(Gwn_VertFormat* format)
- {
-#if TRUST_NO_ONE
- memset(format, 0, sizeof(Gwn_VertFormat));
-#else
- format->attrib_ct = 0;
- format->packed = false;
- format->name_offset = 0;
- format->name_ct = 0;
-
- for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++)
- format->attribs[i].name_ct = 0;
-#endif
- }
-
-void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src)
- {
- // copy regular struct fields
- memcpy(dest, src, sizeof(Gwn_VertFormat));
-
- for (unsigned i = 0; i < dest->attrib_ct; i++)
- for (unsigned j = 0; j < dest->attribs[i].name_ct; j++)
- dest->attribs[i].name[j] = (char *)dest + (src->attribs[i].name[j] - ((char *)src));
- }
-
-static GLenum convert_comp_type_to_gl(Gwn_VertCompType type)
- {
- static const GLenum table[] = {
- [GWN_COMP_I8] = GL_BYTE,
- [GWN_COMP_U8] = GL_UNSIGNED_BYTE,
- [GWN_COMP_I16] = GL_SHORT,
- [GWN_COMP_U16] = GL_UNSIGNED_SHORT,
- [GWN_COMP_I32] = GL_INT,
- [GWN_COMP_U32] = GL_UNSIGNED_INT,
-
- [GWN_COMP_F32] = GL_FLOAT,
-
- [GWN_COMP_I10] = GL_INT_2_10_10_10_REV
- };
- return table[type];
- }
-
-static unsigned comp_sz(Gwn_VertCompType type)
- {
-#if TRUST_NO_ONE
- assert(type <= GWN_COMP_F32); // other types have irregular sizes (not bytes)
-#endif
-
- const GLubyte sizes[] = {1,1,2,2,4,4,4};
- return sizes[type];
- }
-
-static unsigned attrib_sz(const Gwn_VertAttr *a)
- {
- if (a->comp_type == GWN_COMP_I10)
- return 4; // always packed as 10_10_10_2
-
- return a->comp_ct * comp_sz(a->comp_type);
- }
-
-static unsigned attrib_align(const Gwn_VertAttr *a)
- {
- if (a->comp_type == GWN_COMP_I10)
- return 4; // always packed as 10_10_10_2
-
- unsigned c = comp_sz(a->comp_type);
- if (a->comp_ct == 3 && c <= 2)
- return 4 * c; // AMD HW can't fetch these well, so pad it out (other vendors too?)
- else
- return c; // most fetches are ok if components are naturally aligned
- }
-
-unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_ct)
- {
-#if TRUST_NO_ONE
- assert(format->packed && format->stride > 0);
-#endif
-
- return format->stride * vertex_ct;
- }
-
-static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name)
- {
- // strncpy does 110% of what we need; let's do exactly 100%
- char* name_copy = format->names + format->name_offset;
- unsigned available = GWN_VERT_ATTR_NAMES_BUF_LEN - format->name_offset;
- bool terminated = false;
-
- for (unsigned i = 0; i < available; ++i)
- {
- const char c = name[i];
- name_copy[i] = c;
- if (c == '\0')
- {
- terminated = true;
- format->name_offset += (i + 1);
- break;
- }
- }
-
-#if TRUST_NO_ONE
- assert(terminated);
- assert(format->name_offset <= GWN_VERT_ATTR_NAMES_BUF_LEN);
-#else
- (void)terminated;
-#endif
-
- return name_copy;
- }
-
-unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_ct, Gwn_VertFetchMode fetch_mode)
- {
-#if TRUST_NO_ONE
- assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more
- assert(format->attrib_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more
- assert(!format->packed); // packed means frozen/locked
- assert((comp_ct >= 1 && comp_ct <= 4) || comp_ct == 8 || comp_ct == 12 || comp_ct == 16);
- switch (comp_type)
- {
- case GWN_COMP_F32:
- // float type can only kept as float
- assert(fetch_mode == GWN_FETCH_FLOAT);
- break;
- case GWN_COMP_I10:
- // 10_10_10 format intended for normals (xyz) or colors (rgb)
- // extra component packed.w can be manually set to { -2, -1, 0, 1 }
- assert(comp_ct == 3 || comp_ct == 4);
- assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); // not strictly required, may relax later
- break;
- default:
- // integer types can be kept as int or converted/normalized to float
- assert(fetch_mode != GWN_FETCH_FLOAT);
- // only support float matrices (see Batch_update_program_bindings)
- assert(comp_ct != 8 && comp_ct != 12 && comp_ct != 16);
- }
-#endif
- format->name_ct++; // multiname support
-
- const unsigned attrib_id = format->attrib_ct++;
- Gwn_VertAttr* attrib = format->attribs + attrib_id;
-
- attrib->name[attrib->name_ct++] = copy_attrib_name(format, name);
- attrib->comp_type = comp_type;
- attrib->gl_comp_type = convert_comp_type_to_gl(comp_type);
- attrib->comp_ct = (comp_type == GWN_COMP_I10) ? 4 : comp_ct; // system needs 10_10_10_2 to be 4 or BGRA
- attrib->sz = attrib_sz(attrib);
- attrib->offset = 0; // offsets & stride are calculated later (during pack)
- attrib->fetch_mode = fetch_mode;
-
- return attrib_id;
- }
-
-void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias)
- {
- Gwn_VertAttr* attrib = format->attribs + (format->attrib_ct - 1);
-#if TRUST_NO_ONE
- assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more
- assert(attrib->name_ct < GWN_VERT_ATTR_MAX_NAMES);
-#endif
- format->name_ct++; // multiname support
- attrib->name[attrib->name_ct++] = copy_attrib_name(format, alias);
- }
-
-unsigned padding(unsigned offset, unsigned alignment)
- {
- const unsigned mod = offset % alignment;
- return (mod == 0) ? 0 : (alignment - mod);
- }
-
-#if PACK_DEBUG
-static void show_pack(unsigned a_idx, unsigned sz, unsigned pad)
- {
- const char c = 'A' + a_idx;
- for (unsigned i = 0; i < pad; ++i)
- putchar('-');
- for (unsigned i = 0; i < sz; ++i)
- putchar(c);
- }
-#endif
-
-void VertexFormat_pack(Gwn_VertFormat* format)
- {
- // for now, attributes are packed in the order they were added,
- // making sure each attrib is naturally aligned (add padding where necessary)
-
- // later we can implement more efficient packing w/ reordering
- // (keep attrib ID order, adjust their offsets to reorder in buffer)
-
- // TODO:
- // realloc just enough to hold the final combo string. And just enough to
- // hold used attribs, not all 16.
-
- Gwn_VertAttr* a0 = format->attribs + 0;
- a0->offset = 0;
- unsigned offset = a0->sz;
-
-#if PACK_DEBUG
- show_pack(0, a0->sz, 0);
-#endif
-
- for (unsigned a_idx = 1; a_idx < format->attrib_ct; ++a_idx)
- {
- Gwn_VertAttr* a = format->attribs + a_idx;
- unsigned mid_padding = padding(offset, attrib_align(a));
- offset += mid_padding;
- a->offset = offset;
- offset += a->sz;
-
-#if PACK_DEBUG
- show_pack(a_idx, a->sz, mid_padding);
-#endif
- }
-
- unsigned end_padding = padding(offset, attrib_align(a0));
-
-#if PACK_DEBUG
- show_pack(0, 0, end_padding);
- putchar('\n');
-#endif
-
- format->stride = offset + end_padding;
- format->packed = true;
- }
-
-
-// OpenGL ES packs in a different order as desktop GL but component conversion is the same.
-// Of the code here, only struct Gwn_PackedNormal needs to change.
-
-#define SIGNED_INT_10_MAX 511
-#define SIGNED_INT_10_MIN -512
-
-static int clampi(int x, int min_allowed, int max_allowed)
- {
-#if TRUST_NO_ONE
- assert(min_allowed <= max_allowed);
-#endif
-
- if (x < min_allowed)
- return min_allowed;
- else if (x > max_allowed)
- return max_allowed;
- else
- return x;
- }
-
-static int quantize(float x)
- {
- int qx = x * 511.0f;
- return clampi(qx, SIGNED_INT_10_MIN, SIGNED_INT_10_MAX);
- }
-
-static int convert_i16(short x)
- {
- // 16-bit signed --> 10-bit signed
- return x >> 6;
- // TODO: round?
- }
-
-Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3])
- {
- Gwn_PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) };
- return n;
- }
-
-Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3])
- {
- Gwn_PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) };
- return n;
- }
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp
index 1a995eb2cbc..815189b9098 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.cpp
+++ b/intern/ghost/intern/GHOST_ContextGLX.cpp
@@ -72,8 +72,7 @@ GHOST_ContextGLX::GHOST_ContextGLX(
m_contextMinorVersion(contextMinorVersion),
m_contextFlags(contextFlags),
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
- m_context(None),
- m_init(false)
+ m_context(None)
{
assert(m_display != NULL);
}
@@ -111,9 +110,6 @@ GHOST_TSuccess GHOST_ContextGLX::swapBuffers()
GHOST_TSuccess GHOST_ContextGLX::activateDrawingContext()
{
- if (m_init == false) {
- initContext();
- }
if (m_display) {
return ::glXMakeCurrent(m_display, m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
}
@@ -188,8 +184,7 @@ const bool GLXEW_ARB_create_context_robustness =
glxewInit();
#endif /* USE_GLXEW_INIT_WORKAROUND */
- /* Only init the non-offscreen context directly */
- const bool do_init = (m_window != None);
+
if (GLXEW_ARB_create_context) {
int profileBitCore = m_contextProfileMask & GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
@@ -306,30 +301,15 @@ const bool GLXEW_ARB_create_context_robustness =
fprintf(stderr, "Warning! GLX_ARB_create_context not available.\n");
}
- GHOST_TSuccess success = GHOST_kSuccess;
+ GHOST_TSuccess success;
if (m_context != NULL) {
+ const unsigned char *version;
+
if (!s_sharedContext)
s_sharedContext = m_context;
s_sharedCount++;
- }
-
- if (do_init) {
- success = initContext();
- }
-
- GHOST_X11_ERROR_HANDLERS_RESTORE(handler_store);
-
- return success;
-}
-
-GHOST_TSuccess GHOST_ContextGLX::initContext()
-{
- GHOST_TSuccess success;
-
- if (m_context != NULL) {
- const unsigned char *version;
glXMakeCurrent(m_display, m_window, m_context);
@@ -361,12 +341,13 @@ GHOST_TSuccess GHOST_ContextGLX::initContext()
success = GHOST_kFailure;
}
- /* We tag as init even if it fails. */
- m_init = true;
+
+ GHOST_X11_ERROR_HANDLERS_RESTORE(handler_store);
return success;
}
+
GHOST_TSuccess GHOST_ContextGLX::releaseNativeHandles()
{
m_window = 0;
diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h
index b4d6a841d72..ded1b293659 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.h
+++ b/intern/ghost/intern/GHOST_ContextGLX.h
@@ -116,7 +116,6 @@ public:
private:
void initContextGLXEW();
- GHOST_TSuccess initContext();
Display *m_display;
GLXFBConfig m_fbconfig;
@@ -129,7 +128,6 @@ private:
const int m_contextResetNotificationStrategy;
GLXContext m_context;
- bool m_init;
/** The first created OpenGL context (for sharing display lists) */
static GLXContext s_sharedContext;
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index 0047a88fa1d..9605f7ddff2 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -70,8 +70,7 @@ GHOST_ContextWGL::GHOST_ContextWGL(
m_contextFlags(contextFlags),
m_alphaBackground(alphaBackground),
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
- m_hGLRC(NULL),
- m_init(false)
+ m_hGLRC(NULL)
#ifndef NDEBUG
,
m_dummyVendor(NULL),
@@ -140,10 +139,6 @@ GHOST_TSuccess GHOST_ContextWGL::getSwapInterval(int &intervalOut)
GHOST_TSuccess GHOST_ContextWGL::activateDrawingContext()
{
- if (m_init == false) {
- initContext();
- }
-
if (WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) {
return GHOST_kSuccess;
}
@@ -204,10 +199,6 @@ static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd, PIXELFORMATDESCRIPTOR
weight++;
#endif
- /* want swap copy capability -- it matters a lot */
- if (pfd.dwFlags & PFD_SWAP_COPY)
- weight += 16;
-
return weight;
}
@@ -409,7 +400,6 @@ static void makeAttribList(
std::vector<int>& out,
bool stereoVisual,
int numOfAASamples,
- int swapMethod,
bool needAlpha,
bool needStencil,
bool sRGB)
@@ -429,9 +419,6 @@ static void makeAttribList(
out.push_back(WGL_ACCELERATION_ARB);
out.push_back(WGL_FULL_ACCELERATION_ARB);
- out.push_back(WGL_SWAP_METHOD_ARB);
- out.push_back(swapMethod);
-
if (stereoVisual) {
out.push_back(WGL_STEREO_ARB);
out.push_back(GL_TRUE);
@@ -473,13 +460,12 @@ static void makeAttribList(
}
-int GHOST_ContextWGL::_choose_pixel_format_arb_2(
+int GHOST_ContextWGL::_choose_pixel_format_arb_1(
bool stereoVisual,
- int *numOfAASamples,
+ int numOfAASamples,
bool needAlpha,
bool needStencil,
- bool sRGB,
- int swapMethod)
+ bool sRGB)
{
std::vector<int> iAttributes;
@@ -491,12 +477,12 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2(
int samples;
// guard against some insanely high number of samples
- if (*numOfAASamples > 64) {
+ if (numOfAASamples > 64) {
fprintf(stderr, "Warning! Clamping number of samples to 64.\n");
samples = 64;
}
else {
- samples = *numOfAASamples;
+ samples = numOfAASamples;
}
// request a format with as many samples as possible, but not more than requested
@@ -505,7 +491,6 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2(
iAttributes,
stereoVisual,
samples,
- swapMethod,
needAlpha,
needStencil,
sRGB);
@@ -554,13 +539,11 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2(
int actualSamples, alphaBits;
wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, iQuery, &actualSamples);
- if (actualSamples != *numOfAASamples) {
+ if (actualSamples != numOfAASamples) {
fprintf(stderr,
"Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
"Substituting one that uses %d samples.\n",
- *numOfAASamples, actualSamples);
-
- *numOfAASamples = actualSamples; // set context property to actual value
+ numOfAASamples, actualSamples);
}
if (needAlpha) {
iQuery[0] = WGL_ALPHA_BITS_ARB;
@@ -571,69 +554,6 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2(
}
}
}
- else {
- *numOfAASamples = 0;
- }
- return iPixelFormat;
-}
-
-
-int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual,
- int numOfAASamples,
- bool needAlpha,
- bool needStencil,
- bool sRGB,
- int *swapMethodOut)
-{
- int iPixelFormat;
- int copyPixelFormat = 0;
- int undefPixelFormat = 0;
- int exchPixelFormat = 0;
- int copyNumOfAASamples = 0;
- int undefNumOfAASamples = 0;
- int exchNumOfAASamples = 0;
-
- *swapMethodOut = WGL_SWAP_COPY_ARB;
- copyNumOfAASamples = numOfAASamples;
- copyPixelFormat = _choose_pixel_format_arb_2(
- stereoVisual, &copyNumOfAASamples, needAlpha, needStencil, sRGB, *swapMethodOut);
-
- if (copyPixelFormat == 0 || copyNumOfAASamples < numOfAASamples) {
- *swapMethodOut = WGL_SWAP_UNDEFINED_ARB;
- undefNumOfAASamples = numOfAASamples;
- undefPixelFormat = _choose_pixel_format_arb_2(
- stereoVisual, &undefNumOfAASamples, needAlpha, needStencil, sRGB, *swapMethodOut);
-
- if (undefPixelFormat == 0 || undefNumOfAASamples < numOfAASamples) {
- *swapMethodOut = WGL_SWAP_EXCHANGE_ARB;
- exchNumOfAASamples = numOfAASamples;
- exchPixelFormat = _choose_pixel_format_arb_2(
- stereoVisual, &exchNumOfAASamples, needAlpha, needStencil, sRGB, *swapMethodOut);
- if (exchPixelFormat == 0 || exchNumOfAASamples < numOfAASamples) {
- // the number of AA samples cannot be met, take the highest
- if (undefPixelFormat != 0 && undefNumOfAASamples >= exchNumOfAASamples) {
- exchNumOfAASamples = undefNumOfAASamples;
- exchPixelFormat = undefPixelFormat;
- *swapMethodOut = WGL_SWAP_UNDEFINED_ARB;
- }
- if (copyPixelFormat != 0 && copyNumOfAASamples >= exchNumOfAASamples) {
- exchNumOfAASamples = copyNumOfAASamples;
- exchPixelFormat = copyPixelFormat;
- *swapMethodOut = WGL_SWAP_COPY_ARB;
- }
- }
- iPixelFormat = exchPixelFormat;
- m_numOfAASamples = exchNumOfAASamples;
- }
- else {
- iPixelFormat = undefPixelFormat;
- m_numOfAASamples = undefNumOfAASamples;
- }
- }
- else {
- iPixelFormat = copyPixelFormat;
- m_numOfAASamples = copyNumOfAASamples;
- }
return iPixelFormat;
}
@@ -646,15 +566,13 @@ int GHOST_ContextWGL::choose_pixel_format_arb(
bool sRGB)
{
int iPixelFormat;
- int swapMethodOut;
iPixelFormat = _choose_pixel_format_arb_1(
stereoVisual,
numOfAASamples,
needAlpha,
needStencil,
- sRGB,
- &swapMethodOut);
+ sRGB);
if (iPixelFormat == 0 && stereoVisual) {
fprintf(stderr, "Warning! Unable to find a stereo pixel format.\n");
@@ -664,19 +582,11 @@ int GHOST_ContextWGL::choose_pixel_format_arb(
numOfAASamples,
needAlpha,
needStencil,
- sRGB,
- &swapMethodOut);
+ sRGB);
m_stereoVisual = false; // set context property to actual value
}
- if (swapMethodOut != WGL_SWAP_COPY_ARB) {
- fprintf(stderr,
- "Warning! Unable to find a pixel format that supports WGL_SWAP_COPY_ARB. "
- "Substituting one that uses %s.\n",
- swapMethodOut == WGL_SWAP_UNDEFINED_ARB ? "WGL_SWAP_UNDEFINED_ARB" : "WGL_SWAP_EXCHANGE_ARB");
- }
-
return iPixelFormat;
}
@@ -694,7 +604,6 @@ int GHOST_ContextWGL::choose_pixel_format(
(DWORD) (
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
- PFD_SWAP_COPY | /* support swap copy */
PFD_DOUBLEBUFFER | /* support double-buffering */
(stereoVisual ? PFD_STEREO : 0) |/* support stereo */
(
@@ -893,23 +802,8 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
goto error;
}
- initContext();
-
- initClearGL();
- ::SwapBuffers(m_hDC);
-
- return GHOST_kSuccess;
-error:
- ::wglMakeCurrent(prevHDC, prevHGLRC);
- return GHOST_kFailure;
-
-}
-
-
-GHOST_TSuccess GHOST_ContextWGL::initContext()
-{
if (!WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) {
- return GHOST_kFailure;
+ goto error;
}
initContextGLEW();
@@ -923,7 +817,8 @@ GHOST_TSuccess GHOST_ContextWGL::initContext()
glEnable(GL_POINT_SPRITE);
}
- m_init = true;
+ initClearGL();
+ ::SwapBuffers(m_hDC);
#ifndef NDEBUG
const char *vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
@@ -938,6 +833,10 @@ GHOST_TSuccess GHOST_ContextWGL::initContext()
#endif
return GHOST_kSuccess;
+error:
+ ::wglMakeCurrent(prevHDC, prevHGLRC);
+ return GHOST_kFailure;
+
}
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h
index 7711f90a9e9..07ed7f4d2ef 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -131,22 +131,12 @@ private:
int numOfAASamples,
bool needAlpha,
bool needStencil,
- bool sRGB,
- int *swapMethodOut);
-
- int _choose_pixel_format_arb_2(bool stereoVisual,
- int *numOfAASamples,
- bool needAlpha,
- bool needStencil,
- bool sRGB,
- int swapMethod);
- GHOST_TSuccess initContext();
+ bool sRGB);
void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD);
HWND m_hWnd;
HDC m_hDC;
- bool m_init;
const int m_contextProfileMask;
const int m_contextMajorVersion;
diff --git a/intern/ghost/intern/GHOST_SystemNULL.h b/intern/ghost/intern/GHOST_SystemNULL.h
index 7c8d26d7486..ac3dfd71d63 100644
--- a/intern/ghost/intern/GHOST_SystemNULL.h
+++ b/intern/ghost/intern/GHOST_SystemNULL.h
@@ -53,6 +53,8 @@ public:
void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const { /* nop */ }
void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const { /* nop */ }
bool supportsNativeDialogs(void) { return false;}
+ GHOST_IContext *createOffscreenContext() { return NULL; }
+ GHOST_TSuccess disposeContext(GHOST_IContext *context) { return GHOST_kFailure; }
GHOST_TSuccess init() {
GHOST_TSuccess success = GHOST_System::init();
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index fcda5d8b72d..5d383f68e9d 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -261,7 +261,7 @@ GHOST_SystemX11::
#endif /* WITH_X11_XINPUT */
if (m_xkb_descr) {
- XkbFreeNames(m_xkb_descr, XkbKeyNamesMask, false);
+ XkbFreeKeyboard (m_xkb_descr, XkbAllComponentsMask, true);
}
XCloseDisplay(m_display);
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index ade4799a52d..e740542961e 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -1677,6 +1677,7 @@ getDPIHint()
}
}
}
+ XrmDestroyDatabase(xrdb);
}
/* Fallback to calculating DPI using X reported DPI, set using xrandr --dpi */
diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt
index 2611477252a..10898e4239b 100644
--- a/intern/opencolorio/CMakeLists.txt
+++ b/intern/opencolorio/CMakeLists.txt
@@ -27,8 +27,8 @@ set(INC
.
../glew-mx
../guardedalloc
- ../gawain
../../source/blender/blenlib
+ ../../source/blender/gpu
)
set(INC_SYS
diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc
index 090422ff795..78c73a6e3bf 100644
--- a/intern/opencolorio/ocio_impl_glsl.cc
+++ b/intern/opencolorio/ocio_impl_glsl.cc
@@ -49,7 +49,7 @@
#endif
extern "C" {
-#include "gawain/gwn_immediate.h"
+#include "GPU_immediate.h"
}
using namespace OCIO_NAMESPACE;
@@ -98,7 +98,7 @@ typedef struct OCIO_GLSLShader {
GLuint ocio_shader;
GLuint vert_shader;
GLuint program;
- Gwn_ShaderInterface *shader_interface;
+ GPUShaderInterface *shader_interface;
} GLSLDrawState;
typedef struct OCIO_GLSLDrawState {
@@ -251,7 +251,7 @@ static void freeGLSLShader(OCIO_GLSLShader *shader)
}
if (shader->shader_interface) {
- GWN_shaderinterface_discard(shader->shader_interface);
+ GPU_shaderinterface_discard(shader->shader_interface);
}
if (shader->ocio_shader) {
@@ -424,9 +424,9 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
if (shader->program) {
if (shader->shader_interface) {
- GWN_shaderinterface_discard(shader->shader_interface);
+ GPU_shaderinterface_discard(shader->shader_interface);
}
- shader->shader_interface = GWN_shaderinterface_create(shader->program);
+ shader->shader_interface = GPU_shaderinterface_create(shader->program);
}
}
}
@@ -461,9 +461,9 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
*
* TODO(sergey): Look into some nicer solution.
*/
- Gwn_VertFormat *format = immVertexFormat();
- GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindProgram(shader->program, shader->shader_interface);
immUniform1i("image_texture", 0);
diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
index 876b5c0181f..887eb399224 100644
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -34,20 +34,40 @@ set(INC_SYS
)
set(SRC
- opensubdiv_capi.cc
- opensubdiv_converter.cc
- opensubdiv_device_context_cuda.cc
- opensubdiv_device_context_opencl.cc
- opensubdiv_evaluator_capi.cc
- opensubdiv_gpu_capi.cc
- opensubdiv_utils_capi.cc
+ internal/opensubdiv.cc
+ internal/opensubdiv_converter_factory.cc
+ internal/opensubdiv_converter_internal.cc
+ internal/opensubdiv_converter_orient.cc
+ internal/opensubdiv_device_context_cuda.cc
+ internal/opensubdiv_device_context_opencl.cc
+ internal/opensubdiv_evaluator.cc
+ internal/opensubdiv_evaluator_internal.cc
+ internal/opensubdiv_gl_mesh.cc
+ internal/opensubdiv_gl_mesh_draw.cc
+ internal/opensubdiv_gl_mesh_fvar.cc
+ internal/opensubdiv_gl_mesh_internal.cc
+ internal/opensubdiv_topology_refiner.cc
+ internal/opensubdiv_topology_refiner_internal.cc
+ internal/opensubdiv_util.cc
+
+ internal/opensubdiv_converter_internal.h
+ internal/opensubdiv_converter_orient.h
+ internal/opensubdiv_converter_orient_impl.h
+ internal/opensubdiv_device_context_cuda.h
+ internal/opensubdiv_device_context_opencl.h
+ internal/opensubdiv_evaluator_internal.h
+ internal/opensubdiv_gl_mesh_fvar.h
+ internal/opensubdiv_gl_mesh_internal.h
+ internal/opensubdiv_internal.h
+ internal/opensubdiv_topology_refiner_internal.h
+ internal/opensubdiv_util.h
opensubdiv_capi.h
+ opensubdiv_capi_type.h
opensubdiv_converter_capi.h
- opensubdiv_device_context_cuda.h
- opensubdiv_device_context_opencl.h
- opensubdiv_intern.h
- opensubdiv_topology_refiner.h
+ opensubdiv_evaluator_capi.h
+ opensubdiv_gl_mesh_capi.h
+ opensubdiv_topology_refiner_capi.h
)
macro(OPENSUBDIV_DEFINE_COMPONENT component)
@@ -64,9 +84,9 @@ OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_OPENMP)
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_COMPUTE)
-data_to_c_simple(gpu_shader_opensubdiv_vertex.glsl SRC)
-data_to_c_simple(gpu_shader_opensubdiv_geometry.glsl SRC)
-data_to_c_simple(gpu_shader_opensubdiv_fragment.glsl SRC)
+data_to_c_simple(shader/gpu_shader_opensubdiv_vertex.glsl SRC)
+data_to_c_simple(shader/gpu_shader_opensubdiv_geometry.glsl SRC)
+data_to_c_simple(shader/gpu_shader_opensubdiv_fragment.glsl SRC)
add_definitions(-DGLEW_STATIC)
diff --git a/intern/opensubdiv/internal/opensubdiv.cc b/intern/opensubdiv/internal/opensubdiv.cc
new file mode 100644
index 00000000000..c2945ed25ab
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv.cc
@@ -0,0 +1,99 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+// Contributor(s): Brecht van Lommel
+
+#include "opensubdiv_capi.h"
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <GL/glew.h>
+
+#include "opensubdiv_device_context_opencl.h"
+#include "opensubdiv_device_context_cuda.h"
+#include "opensubdiv_gl_mesh_capi.h"
+
+void openSubdiv_init(void) {
+ // Ensure all OpenGL strings are cached.
+ openSubdiv_getAvailableEvaluators();
+}
+
+void openSubdiv_cleanup(void) {
+ openSubdiv_deinitGLMeshDrawingResources();
+}
+
+int openSubdiv_getAvailableEvaluators(void) {
+ int flags = OPENSUBDIV_EVALUATOR_CPU;
+
+#ifdef OPENSUBDIV_HAS_OPENMP
+ flags |= OPENSUBDIV_EVALUATOR_OPENMP;
+#endif
+
+#ifdef OPENSUBDIV_HAS_OPENCL
+ if (CLDeviceContext::HAS_CL_VERSION_1_1()) {
+ flags |= OPENSUBDIV_EVALUATOR_OPENCL;
+ }
+#endif
+
+#ifdef OPENSUBDIV_HAS_CUDA
+ if (CudaDeviceContext::HAS_CUDA_VERSION_4_0()) {
+ flags |= OPENSUBDIV_EVALUATOR_CUDA;
+ }
+#endif
+
+#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
+ if (GLEW_VERSION_4_1) {
+ flags |= OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK;
+ }
+#endif
+
+#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
+ if (GLEW_VERSION_4_3 || GLEW_ARB_compute_shader) {
+ flags |= OPENSUBDIV_EVALUATOR_GLSL_COMPUTE;
+ }
+#endif
+
+ return flags;
+}
+
+int openSubdiv_getVersionHex(void) {
+#if defined(OPENSUBDIV_VERSION_NUMBER)
+ return OPENSUBDIV_VERSION_NUMBER;
+#elif defined(OPENSUBDIV_VERSION_MAJOR)
+ return OPENSUBDIV_VERSION_MAJOR * 10000 +
+ OPENSUBDIV_VERSION_MINOR * 100 +
+ OPENSUBDIV_VERSION_PATCH;
+#elif defined(OPENSUBDIV_VERSION)
+ const char* version = STRINGIFY(OPENSUBDIV_VERSION);
+ if (version[0] == 'v') {
+ version += 1;
+ }
+ int major = 0, minor = 0, patch = 0;
+ vector<string> tokens;
+ opensubdiv_capi::stringSplit(&tokens, version, "_", true);
+ if (tokens.size() == 3) {
+ major = atoi(tokens[0].c_str());
+ minor = atoi(tokens[1].c_str());
+ patch = atoi(tokens[2].c_str());
+ }
+ return major * 10000 + minor * 100 + patch;
+#else
+ return 0;
+#endif
+}
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc
new file mode 100644
index 00000000000..48516cc80b7
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc
@@ -0,0 +1,440 @@
+// Copyright 2015 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include "internal/opensubdiv_converter_factory.h"
+
+#include <cassert>
+#include <cstdio>
+#include <stack>
+#include <vector>
+
+#include <opensubdiv/far/topologyRefinerFactory.h>
+
+#include "internal/opensubdiv_converter_internal.h"
+#include "internal/opensubdiv_converter_orient.h"
+#include "internal/opensubdiv_internal.h"
+#include "opensubdiv_converter_capi.h"
+
+struct TopologyRefinerData {
+ const OpenSubdiv_Converter* converter;
+};
+
+namespace OpenSubdiv {
+namespace OPENSUBDIV_VERSION {
+namespace Far {
+
+template <>
+inline bool
+TopologyRefinerFactory<TopologyRefinerData>::resizeComponentTopology(
+ TopologyRefiner& refiner,
+ const TopologyRefinerData& cb_data) {
+ const OpenSubdiv_Converter* converter = cb_data.converter;
+ /// Faces and face-vertices.
+ const int num_faces = converter->getNumFaces(converter);
+ setNumBaseFaces(refiner, num_faces);
+ for (int face_index = 0; face_index < num_faces; ++face_index) {
+ const int num_face_vertices =
+ converter->getNumFaceVertices(converter, face_index);
+ setNumBaseFaceVertices(refiner, face_index, num_face_vertices);
+ }
+ // Edges and edge-faces.
+ const int num_edges = converter->getNumEdges(converter);
+ setNumBaseEdges(refiner, num_edges);
+ for (int edge_index = 0; edge_index < num_edges; ++edge_index) {
+ const int num_edge_faces =
+ converter->getNumEdgeFaces(converter, edge_index);
+ setNumBaseEdgeFaces(refiner, edge_index, num_edge_faces);
+ }
+ // Vertices and vertex-faces and vertex-edges.
+ const int num_vertices = converter->getNumVertices(converter);
+ setNumBaseVertices(refiner, num_vertices);
+ for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index) {
+ const int num_vert_edges =
+ converter->getNumVertexEdges(converter, vertex_index);
+ const int num_vert_faces =
+ converter->getNumVertexFaces(converter, vertex_index);
+ setNumBaseVertexEdges(refiner, vertex_index, num_vert_edges);
+ setNumBaseVertexFaces(refiner, vertex_index, num_vert_faces);
+ }
+ return true;
+}
+
+template <>
+inline bool
+TopologyRefinerFactory<TopologyRefinerData>::assignComponentTopology(
+ TopologyRefiner& refiner,
+ const TopologyRefinerData& cb_data) {
+ using Far::IndexArray;
+ const OpenSubdiv_Converter* converter = cb_data.converter;
+ // Face relations.
+ const int num_faces = converter->getNumFaces(converter);
+ for (int face_index = 0; face_index < num_faces; ++face_index) {
+ IndexArray dst_face_verts = getBaseFaceVertices(refiner, face_index);
+ converter->getFaceVertices(converter, face_index, &dst_face_verts[0]);
+ IndexArray dst_face_edges = getBaseFaceEdges(refiner, face_index);
+ converter->getFaceEdges(converter, face_index, &dst_face_edges[0]);
+ }
+ // Edge relations.
+ const int num_edges = converter->getNumEdges(converter);
+ for (int edge_index = 0; edge_index < num_edges; ++edge_index) {
+ // Edge-vertices.
+ IndexArray dst_edge_vertices = getBaseEdgeVertices(refiner, edge_index);
+ converter->getEdgeVertices(converter, edge_index, &dst_edge_vertices[0]);
+ // Edge-faces.
+ IndexArray dst_edge_faces = getBaseEdgeFaces(refiner, edge_index);
+ converter->getEdgeFaces(converter, edge_index, &dst_edge_faces[0]);
+ }
+// TODO(sergey): Find a way to move this to an utility function.
+#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
+ // Make face normals consistent.
+ std::vector<bool> face_used(num_faces, false);
+ std::stack<int> traverse_stack;
+ int face_start = 0, num_traversed_faces = 0;
+ // Traverse all islands.
+ while (num_traversed_faces != num_faces) {
+ // Find first face of any untraversed islands.
+ while (face_used[face_start]) {
+ ++face_start;
+ }
+ // Add first face to the stack.
+ traverse_stack.push(face_start);
+ face_used[face_start] = true;
+ // Go over whole connected component.
+ while (!traverse_stack.empty()) {
+ int face = traverse_stack.top();
+ traverse_stack.pop();
+ IndexArray face_edges = getBaseFaceEdges(refiner, face);
+ ConstIndexArray face_vertices = getBaseFaceVertices(refiner, face);
+ for (int i = 0; i < face_edges.size(); ++i) {
+ const int edge = face_edges[i];
+ ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge);
+ if (edge_faces.size() != 2) {
+ /* Can't make consistent normals for non-manifolds. */
+ continue;
+ }
+ ConstIndexArray edge_vertices = getBaseEdgeVertices(refiner, edge);
+ // Get winding of the reference face.
+ const int vert0_of_face = face_vertices.FindIndex(edge_vertices[0]);
+ const int vert1_of_face = face_vertices.FindIndex(edge_vertices[1]);
+ const int delta_face =
+ opensubdiv_capi::getLoopWinding(vert0_of_face, vert1_of_face);
+ for (int edge_face = 0; edge_face < edge_faces.size(); ++edge_face) {
+ const int other_face_index = edge_faces[edge_face];
+ // Never re-traverse faces, only move forward.
+ if (face_used[other_face_index]) {
+ continue;
+ }
+ IndexArray other_face_vertics =
+ getBaseFaceVertices(refiner, other_face_index);
+ const int vert0_of_other_face =
+ other_face_vertics.FindIndex(edge_vertices[0]);
+ const int vert1_of_other_face =
+ other_face_vertics.FindIndex(edge_vertices[1]);
+ const int delta_other_face = opensubdiv_capi::getLoopWinding(
+ vert0_of_other_face, vert1_of_other_face);
+ if (delta_face * delta_other_face > 0) {
+ IndexArray other_face_vertices =
+ getBaseFaceVertices(refiner, other_face_index);
+ IndexArray other_face_edges =
+ getBaseFaceEdges(refiner, other_face_index);
+ opensubdiv_capi::reverseFaceLoops(&other_face_vertices,
+ &other_face_edges);
+ }
+ traverse_stack.push(other_face_index);
+ face_used[other_face_index] = true;
+ }
+ }
+ ++num_traversed_faces;
+ }
+ }
+#endif // OPENSUBDIV_ORIENT_TOPOLOGY
+ // Vertex relations.
+ const int num_vertices = converter->getNumVertices(converter);
+ std::vector<int> vertex_faces, vertex_edges;
+ for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index) {
+ // Vertex-faces.
+ IndexArray dst_vertex_faces = getBaseVertexFaces(refiner, vertex_index);
+ const int num_vertex_faces =
+ converter->getNumVertexFaces(converter, vertex_index);
+ vertex_faces.resize(num_vertex_faces);
+ converter->getVertexFaces(converter, vertex_index, &vertex_faces[0]);
+ // Vertex-edges.
+ IndexArray dst_vertex_edges = getBaseVertexEdges(refiner, vertex_index);
+ const int num_vertex_edges =
+ converter->getNumVertexEdges(converter, vertex_index);
+ vertex_edges.resize(num_vertex_edges);
+ converter->getVertexEdges(converter, vertex_index, &vertex_edges[0]);
+// TODO(sergey): Find a way to move this to an utility function.
+#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
+ // Order vertex edges and faces to be in a CCW order.
+ std::fill(face_used.begin(), face_used.end(), false);
+ // Number of edges and faces added to the ordered array.
+ int edge_count_ordered = 0, face_count_ordered = 0;
+ // Add loose edges straight into the edges array.
+ bool has_fan_connections = false;
+ for (int i = 0; i < num_vertex_edges; ++i) {
+ IndexArray edge_faces = getBaseEdgeFaces(refiner, vertex_edges[i]);
+ if (edge_faces.size() == 0) {
+ dst_vertex_edges[edge_count_ordered++] = vertex_edges[i];
+ } else if (edge_faces.size() > 2) {
+ has_fan_connections = true;
+ }
+ }
+ if (has_fan_connections) {
+ // OpenSubdiv currently doesn't give us clues how to handle fan face
+ // connections. and since handling such connections complicates the loop
+ // below we simply don't do special orientation for them.
+ memcpy(&dst_vertex_edges[0], &vertex_edges[0],
+ sizeof(int) * num_vertex_edges);
+ memcpy(&dst_vertex_faces[0], &vertex_faces[0],
+ sizeof(int) * num_vertex_faces);
+ continue;
+ }
+ // Perform at max numbder of vert-edges iteration and try to avoid
+ // deadlock here for malformed mesh.
+ for (int global_iter = 0; global_iter < num_vertex_edges; ++global_iter) {
+ // Number of edges and faces which are still to be ordered.
+ const int num_vertex_edges_remained =
+ num_vertex_edges - edge_count_ordered;
+ const int num_vertex_faces_remained =
+ num_vertex_faces - face_count_ordered;
+ if (num_vertex_edges_remained == 0 && num_vertex_faces_remained == 0) {
+ // All done, nothing to do anymore.
+ break;
+ }
+ // Face, edge and face-vertex index to start traversal from.
+ int face_start = -1, edge_start = -1, face_vertex_start = -1;
+ if (num_vertex_edges_remained == num_vertex_faces_remained) {
+ // Vertex is either complete manifold or is connected to several
+ // manifold islands (hourglass-like configuration), can pick up
+ // random edge unused and start from it.
+ //
+ // TODO(sergey): Start from previous edge from which traversal began at
+ // previous iteration.
+ for (int i = 0; i < num_vertex_edges; ++i) {
+ face_start = vertex_faces[i];
+ if (!face_used[face_start]) {
+ ConstIndexArray face_vertices =
+ getBaseFaceVertices(refiner, face_start);
+ ConstIndexArray face_edges = getBaseFaceEdges(refiner, face_start);
+ face_vertex_start = face_vertices.FindIndex(vertex_index);
+ edge_start = face_edges[face_vertex_start];
+ break;
+ }
+ }
+ } else {
+ // Special handle of non-manifold vertex.
+ for (int i = 0; i < num_vertex_edges; ++i) {
+ edge_start = vertex_edges[i];
+ IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_start);
+ if (edge_faces.size() == 1) {
+ face_start = edge_faces[0];
+ if (!face_used[face_start]) {
+ ConstIndexArray face_vertices =
+ getBaseFaceVertices(refiner, face_start);
+ ConstIndexArray face_edges =
+ getBaseFaceEdges(refiner, face_start);
+ face_vertex_start = face_vertices.FindIndex(vertex_index);
+ if (edge_start == face_edges[face_vertex_start]) {
+ break;
+ }
+ }
+ }
+ // Reset indices for sanity check below.
+ face_start = edge_start = face_vertex_start = -1;
+ }
+ }
+ // Sanity check.
+ assert(face_start != -1);
+ assert(edge_start != -1);
+ assert(face_vertex_start != -1);
+ // Traverse faces starting from the current one. */
+ int edge_first = edge_start;
+ dst_vertex_faces[face_count_ordered++] = face_start;
+ dst_vertex_edges[edge_count_ordered++] = edge_start;
+ face_used[face_start] = true;
+ while (edge_count_ordered < num_vertex_edges) {
+ IndexArray face_vertices = getBaseFaceVertices(refiner, face_start);
+ IndexArray face_edges = getBaseFaceEdges(refiner, face_start);
+ int face_edge_start = face_vertex_start;
+ int face_edge_next = (face_edge_start > 0) ? (face_edge_start - 1)
+ : (face_vertices.size() - 1);
+ Index edge_next = face_edges[face_edge_next];
+ if (edge_next == edge_first) {
+ // Multiple manifolds found, stop for now and handle rest
+ // in the next iteration.
+ break;
+ }
+ dst_vertex_edges[edge_count_ordered++] = edge_next;
+ if (face_count_ordered < num_vertex_faces) {
+ IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_next);
+ assert(edge_faces.size() != 0);
+ if (edge_faces.size() == 1) {
+ assert(edge_faces[0] == face_start);
+ break;
+ } else if (edge_faces.size() != 2) {
+ break;
+ }
+ assert(edge_faces.size() == 2);
+ face_start = edge_faces[(edge_faces[0] == face_start) ? 1 : 0];
+ face_vertex_start =
+ getBaseFaceEdges(refiner, face_start).FindIndex(edge_next);
+ dst_vertex_faces[face_count_ordered++] = face_start;
+ face_used[face_start] = true;
+ }
+ edge_start = edge_next;
+ }
+ }
+ // Verify ordering doesn't ruin connectivity information.
+ assert(face_count_ordered == num_vertex_faces);
+ assert(edge_count_ordered == num_vertex_edges);
+ opensubdiv_capi::checkOrientedVertexConnectivity(
+ num_vertex_edges, num_vertex_faces, &vertex_edges[0], &vertex_faces[0],
+ &dst_vertex_edges[0], &dst_vertex_faces[0]);
+ // For the release builds we're failing mesh construction so instead of
+ // nasty bugs the unsupported mesh will simply disappear from the viewport.
+ if (face_count_ordered != num_vertex_faces ||
+ edge_count_ordered != num_vertex_edges) {
+ return false;
+ }
+#else // OPENSUBDIV_ORIENT_TOPOLOGY
+ memcpy(&dst_vertex_edges[0], &vertex_edges[0],
+ sizeof(int) * num_vertex_edges);
+ memcpy(&dst_vertex_faces[0], &vertex_faces[0],
+ sizeof(int) * num_vertex_faces);
+#endif // OPENSUBDIV_ORIENT_TOPOLOGY
+ }
+ populateBaseLocalIndices(refiner);
+ return true;
+}
+
+template <>
+inline bool TopologyRefinerFactory<TopologyRefinerData>::assignComponentTags(
+ TopologyRefiner& refiner,
+ const TopologyRefinerData& cb_data) {
+ using OpenSubdiv::Sdc::Crease;
+ const OpenSubdiv_Converter* converter = cb_data.converter;
+ const int num_edges = converter->getNumEdges(converter);
+ for (int edge_index = 0; edge_index < num_edges; ++edge_index) {
+ const float sharpness =
+ opensubdiv_capi::getCompatibleEdgeSharpness(converter, edge_index);
+ setBaseEdgeSharpness(refiner, edge_index, sharpness);
+ }
+ // OpenSubdiv expects non-manifold vertices to be sharp but at the time it
+ // handles correct cases when vertex is a corner of plane. Currently mark
+ // vertices which are adjacent to a loose edge as sharp, but this decision
+ // needs some more investigation.
+ const int num_vertices = converter->getNumVertices(converter);
+ for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index) {
+ ConstIndexArray vertex_edges = getBaseVertexEdges(refiner, vertex_index);
+ for (int i = 0; i < vertex_edges.size(); ++i) {
+ const int edge_index = vertex_edges[i];
+ ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge_index);
+ if (edge_faces.size() == 0) {
+ setBaseVertexSharpness(refiner, vertex_index,
+ Crease::SHARPNESS_INFINITE);
+ break;
+ }
+ }
+ if (vertex_edges.size() == 2) {
+ const int edge0 = vertex_edges[0], edge1 = vertex_edges[1];
+ const float sharpness0 = converter->getEdgeSharpness(converter, edge0);
+ const float sharpness1 = converter->getEdgeSharpness(converter, edge1);
+ const float sharpness = std::min(sharpness0, sharpness1);
+ setBaseVertexSharpness(refiner, vertex_index, sharpness);
+ }
+ }
+ return true;
+}
+
+template <>
+inline bool
+TopologyRefinerFactory<TopologyRefinerData>::assignFaceVaryingTopology(
+ TopologyRefiner& refiner,
+ const TopologyRefinerData& cb_data) {
+ const OpenSubdiv_Converter* converter = cb_data.converter;
+ const int num_layers = converter->getNumUVLayers(converter);
+ if (num_layers <= 0) {
+ // No UV maps, we can skip any face-varying data.
+ return true;
+ }
+ const int num_faces = getNumBaseFaces(refiner);
+ for (int layer_index = 0; layer_index < num_layers; ++layer_index) {
+ converter->precalcUVLayer(converter, layer_index);
+ const int num_uvs = converter->getNumUVCoordinates(converter);
+ // Fill in per-corner index of the UV.
+ const int channel = createBaseFVarChannel(refiner, num_uvs);
+ // TODO(sergey): Need to check whether converter changed the winding of
+ // face to match OpenSubdiv's expectations.
+ for (int face_index = 0; face_index < num_faces; ++face_index) {
+ Far::IndexArray dst_face_uvs =
+ getBaseFaceFVarValues(refiner, face_index, channel);
+ for (int corner = 0; corner < dst_face_uvs.size(); ++corner) {
+ const int uv_index =
+ converter->getFaceCornerUVIndex(converter, face_index, corner);
+ dst_face_uvs[corner] = uv_index;
+ }
+ }
+ converter->finishUVLayer(converter);
+ }
+ return true;
+}
+
+template <>
+inline void TopologyRefinerFactory<TopologyRefinerData>::reportInvalidTopology(
+ TopologyError /*errCode*/, const char* msg,
+ const TopologyRefinerData& /*mesh*/) {
+ printf("OpenSubdiv Error: %s\n", msg);
+}
+
+} /* namespace Far */
+} /* namespace OPENSUBDIV_VERSION */
+} /* namespace OpenSubdiv */
+
+namespace opensubdiv_capi {
+
+OpenSubdiv::Far::TopologyRefiner* createOSDTopologyRefinerFromConverter(
+ OpenSubdiv_Converter* converter) {
+ using OpenSubdiv::Sdc::Options;
+ using OpenSubdiv::Far::TopologyRefinerFactory;
+ const OpenSubdiv::Sdc::SchemeType scheme_type =
+ getSchemeTypeFromCAPI(converter->getSchemeType(converter));
+ const Options::FVarLinearInterpolation linear_interpolation =
+ getFVarLinearInterpolationFromCAPI(
+ converter->getFVarLinearInterpolation(converter));
+ Options options;
+ options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY);
+ options.SetCreasingMethod(Options::CREASE_UNIFORM);
+ options.SetFVarLinearInterpolation(linear_interpolation);
+
+ TopologyRefinerFactory<TopologyRefinerData>::Options topology_options(
+ scheme_type, options);
+#ifdef OPENSUBDIV_VALIDATE_TOPOLOGY
+ topology_options.validateFullTopology = true;
+#endif
+ TopologyRefinerData cb_data;
+ cb_data.converter = converter;
+ return TopologyRefinerFactory<TopologyRefinerData>::Create(
+ cb_data, topology_options);
+}
+
+} // namespace opensubdiv_capi
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.h b/intern/opensubdiv/internal/opensubdiv_converter_factory.h
new file mode 100644
index 00000000000..451418813e1
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.h
@@ -0,0 +1,37 @@
+// Copyright 2015 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_CONVERTER_FACTORY_H_
+#define OPENSUBDIV_CONVERTER_FACTORY_H_
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <opensubdiv/far/topologyRefiner.h>
+
+struct OpenSubdiv_Converter;
+
+namespace opensubdiv_capi {
+
+OpenSubdiv::Far::TopologyRefiner* createOSDTopologyRefinerFromConverter(
+ struct OpenSubdiv_Converter* converter);
+
+} // namespace opensubdiv_capi
+
+#endif // OPENSUBDIV_CONVERTER_FACTORY_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_internal.cc b/intern/opensubdiv/internal/opensubdiv_converter_internal.cc
new file mode 100644
index 00000000000..32815dc34dc
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_converter_internal.cc
@@ -0,0 +1,96 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include "internal/opensubdiv_converter_internal.h"
+
+#include <opensubdiv/sdc/crease.h>
+#include <cassert>
+
+namespace opensubdiv_capi {
+
+OpenSubdiv::Sdc::SchemeType getSchemeTypeFromCAPI(OpenSubdiv_SchemeType type) {
+ switch (type) {
+ case OSD_SCHEME_BILINEAR:
+ return OpenSubdiv::Sdc::SCHEME_BILINEAR;
+ case OSD_SCHEME_CATMARK:
+ return OpenSubdiv::Sdc::SCHEME_CATMARK;
+ case OSD_SCHEME_LOOP:
+ return OpenSubdiv::Sdc::SCHEME_LOOP;
+ }
+ assert(!"Unknown scheme type passed via C-API");
+ return OpenSubdiv::Sdc::SCHEME_CATMARK;
+}
+
+OpenSubdiv::Sdc::Options::FVarLinearInterpolation
+getFVarLinearInterpolationFromCAPI(
+ OpenSubdiv_FVarLinearInterpolation linear_interpolation) {
+ typedef OpenSubdiv::Sdc::Options Options;
+ switch (linear_interpolation) {
+ case OSD_FVAR_LINEAR_INTERPOLATION_NONE:
+ return Options::FVAR_LINEAR_NONE;
+ case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY:
+ return Options::FVAR_LINEAR_CORNERS_ONLY;
+ case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1:
+ return Options::FVAR_LINEAR_CORNERS_PLUS1;
+ case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2:
+ return Options::FVAR_LINEAR_CORNERS_PLUS2;
+ case OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES:
+ return Options::FVAR_LINEAR_BOUNDARIES;
+ case OSD_FVAR_LINEAR_INTERPOLATION_ALL:
+ return Options::FVAR_LINEAR_ALL;
+ }
+ assert(!"Unknown fvar linear interpolation passed via C-API");
+ return Options::FVAR_LINEAR_NONE;
+}
+
+OpenSubdiv_FVarLinearInterpolation
+getCAPIFVarLinearInterpolationFromOSD(
+ OpenSubdiv::Sdc::Options::FVarLinearInterpolation linear_interpolation) {
+ typedef OpenSubdiv::Sdc::Options Options;
+ switch (linear_interpolation) {
+ case Options::FVAR_LINEAR_NONE:
+ return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
+ case Options::FVAR_LINEAR_CORNERS_ONLY:
+ return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY;
+ case Options::FVAR_LINEAR_CORNERS_PLUS1:
+ return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1;
+ case Options::FVAR_LINEAR_CORNERS_PLUS2:
+ return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2;
+ case Options::FVAR_LINEAR_BOUNDARIES:
+ return OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES;
+ case Options::FVAR_LINEAR_ALL:
+ return OSD_FVAR_LINEAR_INTERPOLATION_ALL;
+ }
+ assert(!"Unknown fvar linear interpolation passed via C-API");
+ return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
+}
+
+float getCompatibleEdgeSharpness(const OpenSubdiv_Converter* converter,
+ int edge_index) {
+ if (converter->getNumEdgeFaces(converter, edge_index) == 2) {
+ return converter->getEdgeSharpness(converter, edge_index);
+ } else {
+ return OpenSubdiv::Sdc::Crease::SHARPNESS_INFINITE;
+ }
+}
+
+} // namespace opensubdiv_capi
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_internal.h b/intern/opensubdiv/internal/opensubdiv_converter_internal.h
new file mode 100644
index 00000000000..c47cdd1004d
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_converter_internal.h
@@ -0,0 +1,55 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_CONVERTER_INTERNAL_H_
+#define OPENSUBDIV_CONVERTER_INTERNAL_H_
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <opensubdiv/sdc/options.h>
+#include <opensubdiv/sdc/types.h>
+
+#include "opensubdiv_converter_capi.h"
+
+struct OpenSubdiv_Converter;
+
+namespace opensubdiv_capi {
+
+// Convert scheme type from C-API enum to an OpenSubdiv native enum.
+OpenSubdiv::Sdc::SchemeType getSchemeTypeFromCAPI(OpenSubdiv_SchemeType type);
+
+// Convert face-varying interpolation type from C-API to an OpenSubdiv
+// native enum.
+OpenSubdiv::Sdc::Options::FVarLinearInterpolation
+getFVarLinearInterpolationFromCAPI(
+ OpenSubdiv_FVarLinearInterpolation linear_interpolation);
+
+// Similar to above, just other way around.
+OpenSubdiv_FVarLinearInterpolation
+getCAPIFVarLinearInterpolationFromOSD(
+ OpenSubdiv::Sdc::Options::FVarLinearInterpolation linear_interpolation);
+
+// Get edge sharpness in a way which makes OpenSubdiv happy.
+float getCompatibleEdgeSharpness(const OpenSubdiv_Converter* converter,
+ int edge_index);
+
+} // namespace opensubdiv_capi
+
+#endif // OPENSUBDIV_CONVERTER_INTERNAL_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient.cc b/intern/opensubdiv/internal/opensubdiv_converter_orient.cc
new file mode 100644
index 00000000000..449e9028180
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_converter_orient.cc
@@ -0,0 +1,66 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#include "internal/opensubdiv_converter_orient.h"
+
+#include "internal/opensubdiv_internal.h"
+
+namespace opensubdiv_capi {
+
+void checkOrientedVertexConnectivity(const int num_vertex_edges,
+ const int num_vertex_faces,
+ const int* vertex_edges,
+ const int* vertex_faces,
+ const int* dst_vertex_edges,
+ const int* dst_vertex_faces) {
+#ifndef NDEBUG
+ for (int i = 0; i < num_vertex_faces; ++i) {
+ bool found = false;
+ for (int j = 0; j < num_vertex_faces; ++j) {
+ if (vertex_faces[i] == dst_vertex_faces[j]) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ assert(!"vert-faces connectivity ruined");
+ }
+ }
+ for (int i = 0; i < num_vertex_edges; ++i) {
+ bool found = false;
+ for (int j = 0; j < num_vertex_edges; ++j) {
+ if (vertex_edges[i] == dst_vertex_edges[j]) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ assert(!"vert-edges connectivity ruined");
+ }
+ }
+#else
+ (void) num_vertex_edges;
+ (void) num_vertex_faces;
+ (void) vertex_edges;
+ (void) vertex_faces;
+ (void) dst_vertex_edges;
+ (void) dst_vertex_faces;
+#endif
+}
+
+} // namespace opensubdiv_capi
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient.h b/intern/opensubdiv/internal/opensubdiv_converter_orient.h
new file mode 100644
index 00000000000..b783007a0cb
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_converter_orient.h
@@ -0,0 +1,50 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_CONVERTER_ORIENT_H_
+#define OPENSUBDIV_CONVERTER_ORIENT_H_
+
+#include <opensubdiv/far/types.h>
+
+// Set of utility functions which are needed to bring topology to an orientation
+// (or, winding, if you wish) which OpenSubdiv expects.
+
+namespace opensubdiv_capi {
+
+inline void reverseFaceVertices(int* face_vertices, const int num_vertices);
+
+// TODO(sergey): Document which value corresponds to which winding.
+inline int getLoopWinding(int vert0_of_face, int vert1_of_face);
+
+inline void reverseFaceLoops(
+ OpenSubdiv::Far::IndexArray* face_vertices,
+ OpenSubdiv::Far::IndexArray* face_edges);
+
+// Used for debugging, checks whether orientation happened correct.
+void checkOrientedVertexConnectivity(const int num_vertex_edges,
+ const int num_vertex_faces,
+ const int* vertex_edges,
+ const int* vertex_faces,
+ const int* dst_vertex_edges,
+ const int* dst_vertex_faces);
+
+} // namespace opensubdiv_capi
+
+#endif // OPENSUBDIV_CONVERTER_ORIENT_H_
+
+#include "internal/opensubdiv_converter_orient_impl.h"
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h b/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h
new file mode 100644
index 00000000000..3125bc600e5
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h
@@ -0,0 +1,66 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_
+#define OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_
+
+#include "internal/opensubdiv_converter_orient.h"
+
+#include <algorithm>
+#include <cmath>
+#include <utility>
+
+namespace opensubdiv_capi {
+
+inline void reverseFaceVertices(int* face_vertices, const int num_vertices) {
+ int last_vert = face_vertices[num_vertices - 1];
+ for (int i = num_vertices - 1; i > 0; --i) {
+ face_vertices[i] = face_vertices[i - 1];
+ }
+ face_vertices[0] = last_vert;
+}
+
+inline int getLoopWinding(int vert0_of_face, int vert1_of_face) {
+ int delta_face = vert1_of_face - vert0_of_face;
+ if (abs(delta_face) != 1) {
+ if (delta_face > 0) {
+ delta_face = -1;
+ } else {
+ delta_face = 1;
+ }
+ }
+ return delta_face;
+}
+
+inline void reverseFaceLoops(
+ OpenSubdiv::Far::IndexArray* face_vertices,
+ OpenSubdiv::Far::IndexArray* face_edges) {
+ const int num_face_vertices = face_vertices->size();
+ for (int i = 0; i < num_face_vertices / 2; ++i) {
+ const int j = num_face_vertices - i - 1;
+ if (i != j) {
+ std::swap((*face_vertices)[i], (*face_vertices)[j]);
+ std::swap((*face_edges)[i], (*face_edges)[j]);
+ }
+ }
+ reverseFaceVertices(&(*face_vertices)[0], num_face_vertices);
+}
+
+} // namespace opensubdiv_capi
+
+#endif // OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc
new file mode 100644
index 00000000000..875f503b9ab
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc
@@ -0,0 +1,226 @@
+// Adopted from OpenSubdiv with the following license:
+//
+// Copyright 2015 Pixar
+//
+// Licensed under the Apache License, Version 2.0 (the "Apache License")
+// with the following modification; you may not use this file except in
+// compliance with the Apache License and the following modification to it:
+// Section 6. Trademarks. is deleted and replaced with:
+//
+// 6. Trademarks. This License does not grant permission to use the trade
+// names, trademarks, service marks, or product names of the Licensor
+// and its affiliates, except as required to comply with Section 4(c) of
+// the License and to reproduce the content of the NOTICE file.
+//
+// You may obtain a copy of the Apache License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the Apache License with the above modification is
+// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the Apache License for the specific
+// language governing permissions and limitations under the Apache License.
+
+#ifdef OPENSUBDIV_HAS_CUDA
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include "opensubdiv_device_context_cuda.h"
+
+#if defined(_WIN32)
+# include <windows.h>
+#elif defined(__APPLE__)
+# include <OpenGL/OpenGL.h>
+#else
+# include <GL/glx.h>
+# include <X11/Xlib.h>
+#endif
+
+#include <cuda.h>
+#include <cuda_gl_interop.h>
+#include <cuda_runtime_api.h>
+#include <algorithm>
+#include <cstdio>
+
+#define message(fmt, ...)
+// #define message(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
+#define error(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
+
+namespace {
+
+int getCudaDeviceForCurrentGLContext() {
+ // Find and use the CUDA device for the current GL context
+ unsigned int interop_device_count = 0;
+ int interopDevices[1];
+ cudaError_t status = cudaGLGetDevices(&interop_device_count,
+ interopDevices,
+ 1,
+ cudaGLDeviceListCurrentFrame);
+ if (status == cudaErrorNoDevice || interop_device_count != 1) {
+ message("CUDA no interop devices found.\n");
+ return 0;
+ }
+ int device = interopDevices[0];
+#if defined(_WIN32)
+ return device;
+#elif defined(__APPLE__)
+ return device;
+#else // X11
+ Display* display = glXGetCurrentDisplay();
+ int screen = DefaultScreen(display);
+ if (device != screen) {
+ error("The CUDA interop device (%d) does not match "
+ "the screen used by the current GL context (%d), "
+ "which may cause slow performance on systems "
+ "with multiple GPU devices.",
+ device, screen);
+ }
+ message("CUDA init using device for current GL context: %d\n", device);
+ return device;
+#endif
+}
+
+// Beginning of GPU Architecture definitions.
+int convertSMVer2Cores_local(int major, int minor) {
+ // Defines for GPU Architecture types (using the SM version to determine
+ // the # of cores per SM
+ typedef struct {
+ int SM; // 0xMm (hexidecimal notation),
+ // M = SM Major version,
+ // and m = SM minor version
+ int Cores;
+ } sSMtoCores;
+
+ sSMtoCores nGpuArchCoresPerSM[] = {
+ {0x10, 8}, // Tesla Generation (SM 1.0) G80 class.
+ {0x11, 8}, // Tesla Generation (SM 1.1) G8x class.
+ {0x12, 8}, // Tesla Generation (SM 1.2) G9x class.
+ {0x13, 8}, // Tesla Generation (SM 1.3) GT200 class.
+ {0x20, 32}, // Fermi Generation (SM 2.0) GF100 class.
+ {0x21, 48}, // Fermi Generation (SM 2.1) GF10x class.
+ {0x30, 192}, // Fermi Generation (SM 3.0) GK10x class.
+ {-1, -1}};
+ int index = 0;
+ while (nGpuArchCoresPerSM[index].SM != -1) {
+ if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) {
+ return nGpuArchCoresPerSM[index].Cores;
+ }
+ index++;
+ }
+ printf("MapSMtoCores undefined SMversion %d.%d!\n", major, minor);
+ return -1;
+}
+
+// This function returns the best GPU (with maximum GFLOPS).
+int cutGetMaxGflopsDeviceId() {
+ int current_device = 0, sm_per_multiproc = 0;
+ int max_compute_perf = 0, max_perf_device = -1;
+ int device_count = 0, best_SM_arch = 0;
+ int compat_major, compat_minor;
+ cuDeviceGetCount(&device_count);
+ // Find the best major SM Architecture GPU device.
+ while (current_device < device_count) {
+ cuDeviceComputeCapability(&compat_major, &compat_minor, current_device);
+ if (compat_major > 0 && compat_major < 9999) {
+ best_SM_arch = std::max(best_SM_arch, compat_major);
+ }
+ current_device++;
+ }
+ // Find the best CUDA capable GPU device.
+ current_device = 0;
+ while (current_device < device_count) {
+ cuDeviceComputeCapability(&compat_major, &compat_minor, current_device);
+ if (compat_major == 9999 && compat_minor == 9999) {
+ sm_per_multiproc = 1;
+ } else {
+ sm_per_multiproc = convertSMVer2Cores_local(compat_major, compat_minor);
+ }
+ int multi_processor_count;
+ cuDeviceGetAttribute(&multi_processor_count,
+ CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT,
+ current_device);
+ int clock_rate;
+ cuDeviceGetAttribute(&clock_rate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE,
+ current_device);
+ int compute_perf = multi_processor_count * sm_per_multiproc * clock_rate;
+ if (compute_perf > max_compute_perf) {
+ /* If we find GPU with SM major > 2, search only these */
+ if (best_SM_arch > 2) {
+ /* If our device==dest_SM_arch, choose this, or else pass. */
+ if (compat_major == best_SM_arch) {
+ max_compute_perf = compute_perf;
+ max_perf_device = current_device;
+ }
+ } else {
+ max_compute_perf = compute_perf;
+ max_perf_device = current_device;
+ }
+ }
+ ++current_device;
+ }
+ return max_perf_device;
+}
+
+} // namespace
+
+bool CudaDeviceContext::HAS_CUDA_VERSION_4_0() {
+#ifdef OPENSUBDIV_HAS_CUDA
+ static bool cuda_initialized = false;
+ static bool cuda_load_success = true;
+ if (!cuda_initialized) {
+ cuda_initialized = true;
+
+#ifdef OPENSUBDIV_HAS_CUEW
+ cuda_load_success = cuewInit(CUEW_INIT_CUDA) == CUEW_SUCCESS;
+ if (!cuda_load_success) {
+ fprintf(stderr, "Loading CUDA failed.\n");
+ }
+#endif
+ // Need to initialize CUDA here so getting device
+ // with the maximum FPLOS works fine.
+ if (cuInit(0) == CUDA_SUCCESS) {
+ // This is to deal with cases like NVidia Optimus,
+ // when there might be CUDA library installed but
+ // NVidia card is not being active.
+ if (cutGetMaxGflopsDeviceId() < 0) {
+ cuda_load_success = false;
+ }
+ } else {
+ cuda_load_success = false;
+ }
+ }
+ return cuda_load_success;
+#else
+ return false;
+#endif
+}
+
+CudaDeviceContext::CudaDeviceContext()
+ : initialized_(false) {
+}
+
+CudaDeviceContext::~CudaDeviceContext() {
+ cudaDeviceReset();
+}
+
+bool CudaDeviceContext::Initialize() {
+ // See if any cuda device is available.
+ int device_count = 0;
+ cudaGetDeviceCount(&device_count);
+ message("CUDA device count: %d\n", device_count);
+ if (device_count <= 0) {
+ return false;
+ }
+ cudaGLSetGLDevice(getCudaDeviceForCurrentGLContext());
+ initialized_ = true;
+ return true;
+}
+
+bool CudaDeviceContext::IsInitialized() const {
+ return initialized_;
+}
+
+#endif // OPENSUBDIV_HAS_CUDA
diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_cuda.h b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.h
new file mode 100644
index 00000000000..ef212df10f0
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.h
@@ -0,0 +1,54 @@
+// Adopted from OpenSubdiv with the following license:
+//
+// Copyright 2013 Pixar
+//
+// Licensed under the Apache License, Version 2.0 (the "Apache License")
+// with the following modification; you may not use this file except in
+// compliance with the Apache License and the following modification to it:
+// Section 6. Trademarks. is deleted and replaced with:
+//
+// 6. Trademarks. This License does not grant permission to use the trade
+// names, trademarks, service marks, or product names of the Licensor
+// and its affiliates, except as required to comply with Section 4(c) of
+// the License and to reproduce the content of the NOTICE file.
+//
+// You may obtain a copy of the Apache License at
+//
+// http: //www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the Apache License with the above modification is
+// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the Apache License for the specific
+// language governing permissions and limitations under the Apache License.
+
+#ifndef OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_
+#define OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_
+
+#ifdef OPENSUBDIV_HAS_CUDA
+
+struct ID3D11Device;
+
+class CudaDeviceContext {
+ public:
+ CudaDeviceContext();
+ ~CudaDeviceContext();
+
+ static bool HAS_CUDA_VERSION_4_0();
+
+ // Initialze cuda device from the current GL context.
+ bool Initialize();
+
+ // Initialze cuda device from the ID3D11Device.
+ bool Initialize(ID3D11Device* device);
+
+ // Returns true if the cuda device has already been initialized.
+ bool IsInitialized() const;
+
+ private:
+ bool initialized_;
+};
+
+#endif // OPENSUBDIV_HAS_CUDA
+
+#endif // _OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc
new file mode 100644
index 00000000000..00f58af894a
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc
@@ -0,0 +1,269 @@
+// Adopted from OpenSubdiv with the following license:
+//
+// Copyright 2015 Pixar
+//
+// Licensed under the Apache License, Version 2.0 (the "Apache License")
+// with the following modification; you may not use this file except in
+// compliance with the Apache License and the following modification to it:
+// Section 6. Trademarks. is deleted and replaced with:
+//
+// 6. Trademarks. This License does not grant permission to use the trade
+// names, trademarks, service marks, or product names of the Licensor
+// and its affiliates, except as required to comply with Section 4(c) of
+// the License and to reproduce the content of the NOTICE file.
+//
+// You may obtain a copy of the Apache License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the Apache License with the above modification is
+// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the Apache License for the specific
+// language governing permissions and limitations under the Apache License.
+
+#include "opensubdiv_device_context_opencl.h"
+
+#ifdef OPENSUBDIV_HAS_OPENCL
+
+#if defined(_WIN32)
+# include <windows.h>
+#elif defined(__APPLE__)
+# include <OpenGL/OpenGL.h>
+#else
+# include <GL/glx.h>
+#endif
+
+#include <cstdio>
+#include <cstring>
+#include <string>
+#include <vector>
+
+#define message(...) // fprintf(stderr, __VA_ARGS__)
+#define error(...) fprintf(stderr, __VA_ARGS__)
+
+namespace {
+
+// Returns the first found platform.
+cl_platform_id findPlatform() {
+ cl_uint num_platforms;
+ cl_int ci_error_number = clGetPlatformIDs(0, NULL, &num_platforms);
+ if (ci_error_number != CL_SUCCESS) {
+ error("Error %d in clGetPlatformIDs call.\n", ci_error_number);
+ return NULL;
+ }
+ if (num_platforms == 0) {
+ error("No OpenCL platform found.\n");
+ return NULL;
+ }
+ std::vector<cl_platform_id> cl_platform_ids(num_platforms);
+ ci_error_number = clGetPlatformIDs(num_platforms, &cl_platform_ids[0], NULL);
+ char ch_buffer[1024];
+ for (cl_uint i = 0; i < num_platforms; ++i) {
+ ci_error_number = clGetPlatformInfo(cl_platform_ids[i],
+ CL_PLATFORM_NAME,
+ sizeof(ch_buffer),
+ ch_buffer,
+ NULL);
+ if (ci_error_number == CL_SUCCESS) {
+ cl_platform_id platform_id = cl_platform_ids[i];
+ return platform_id;
+ }
+ }
+ return NULL;
+}
+
+// Return the device in cl_devices which supports the extension.
+int findExtensionSupportedDevice(cl_device_id* cl_devices,
+ int num_devices,
+ const char* extension_name) {
+ // Find a device that supports sharing with GL/D3D11
+ // (SLI / X-fire configurations)
+ cl_int cl_error_number;
+ for (int i = 0; i < num_devices; ++i) {
+ // Get extensions string size.
+ size_t extensions_size;
+ cl_error_number = clGetDeviceInfo(cl_devices[i],
+ CL_DEVICE_EXTENSIONS,
+ 0,
+ NULL,
+ &extensions_size);
+ if (cl_error_number != CL_SUCCESS) {
+ error("Error %d in clGetDeviceInfo\n", cl_error_number);
+ return -1;
+ }
+ if (extensions_size > 0) {
+ // Get extensions string.
+ std::string extensions('\0', extensions_size);
+ cl_error_number = clGetDeviceInfo(cl_devices[i],
+ CL_DEVICE_EXTENSIONS,
+ extensions_size,
+ &extensions[0],
+ &extensions_size);
+ if (cl_error_number != CL_SUCCESS) {
+ error("Error %d in clGetDeviceInfo\n", cl_error_number);
+ continue;
+ }
+ // Parse string. This is bit deficient since the extentions
+ // is space separated.
+ //
+ // The actual string would be "cl_khr_d3d11_sharing"
+ // or "cl_nv_d3d11_sharing"
+ if (extensions.find(extension_name) != std::string::npos) {
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
+} // namespace
+
+CLDeviceContext::CLDeviceContext()
+ : cl_context_(NULL),
+ cl_command_queue_(NULL) {
+}
+
+CLDeviceContext::~CLDeviceContext() {
+ if (cl_command_queue_) {
+ clReleaseCommandQueue(cl_command_queue_);
+ }
+ if (cl_context_) {
+ clReleaseContext(cl_context_);
+ }
+}
+
+bool CLDeviceContext::HAS_CL_VERSION_1_1() {
+#ifdef OPENSUBDIV_HAS_CLEW
+ static bool clew_initialized = false;
+ static bool clew_load_success;
+ if (!clew_initialized) {
+ clew_initialized = true;
+ clew_load_success = clewInit() == CLEW_SUCCESS;
+ if (!clew_load_success) {
+ error("Loading OpenCL failed.\n");
+ }
+ }
+ return clew_load_success;
+#endif
+ return true;
+}
+
+bool CLDeviceContext::Initialize() {
+#ifdef OPENSUBDIV_HAS_CLEW
+ if (!clGetPlatformIDs) {
+ error("Error clGetPlatformIDs function not bound.\n");
+ return false;
+ }
+#endif
+ cl_int cl_error_number;
+ cl_platform_id cp_platform = findPlatform();
+
+#if defined(_WIN32)
+ cl_context_properties props[] = {
+ CL_GL_CONTEXT_KHR,
+ (cl_context_properties)wglGetCurrentContext(),
+ CL_WGL_HDC_KHR,
+ (cl_context_properties)wglGetCurrentDC(),
+ CL_CONTEXT_PLATFORM,
+ (cl_context_properties)cp_platform,
+ 0};
+#elif defined(__APPLE__)
+ CGLContextObj kCGLContext = CGLGetCurrentContext();
+ CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext);
+ cl_context_properties props[] = {CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
+ (cl_context_properties)kCGLShareGroup,
+ 0};
+#else
+ cl_context_properties props[] = {
+ CL_GL_CONTEXT_KHR,
+ (cl_context_properties)glXGetCurrentContext(),
+ CL_GLX_DISPLAY_KHR,
+ (cl_context_properties)glXGetCurrentDisplay(),
+ CL_CONTEXT_PLATFORM,
+ (cl_context_properties)cp_platform,
+ 0};
+#endif
+
+#if defined(__APPLE__)
+ _clContext = clCreateContext(props, 0, NULL, clLogMessagesToStdoutAPPLE, NULL,
+ &cl_error_number);
+ if (cl_error_number != CL_SUCCESS) {
+ error("Error %d in clCreateContext\n", cl_error_number);
+ return false;
+ }
+ size_t devices_size = 0;
+ clGetGLContextInfoAPPLE(_clContext, kCGLContext,
+ CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE,
+ 0,
+ NULL,
+ &devices_size);
+ const int num_devices = devices_size / sizeof(cl_device_id);
+ if (num_devices == 0) {
+ error("No sharable devices.\n");
+ return false;
+ }
+ std::vector<cl_device_id> cl_devices(num_devices);
+ clGetGLContextInfoAPPLE(_clContext, kCGLContext,
+ CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE,
+ num_devices * sizeof(cl_device_id),
+ &cl_devices[0],
+ NULL);
+ int cl_device_used = 0;
+#else // not __APPLE__
+ // Get the number of GPU devices available to the platform.
+ cl_uint num_devices = 0;
+ clGetDeviceIDs(cp_platform, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices);
+ if (num_devices == 0) {
+ error("No CL GPU device found.\n");
+ return false;
+ }
+ // Create the device list.
+ std::vector<cl_device_id> cl_devices(num_devices);
+ clGetDeviceIDs(cp_platform,
+ CL_DEVICE_TYPE_GPU,
+ num_devices,
+ &cl_devices[0],
+ NULL);
+ const char* extension = "cl_khr_gl_sharing";
+ int cl_device_used = findExtensionSupportedDevice(&cl_devices[0],
+ num_devices,
+ extension);
+ if (cl_device_used < 0) {
+ error("No device found that supports CL/GL context sharing\n");
+ return false;
+ }
+ cl_context_ = clCreateContext(props,
+ 1,
+ &cl_devices[cl_device_used],
+ NULL, NULL,
+ &cl_error_number);
+#endif // not __APPLE__
+ if (cl_error_number != CL_SUCCESS) {
+ error("Error %d in clCreateContext\n", cl_error_number);
+ return false;
+ }
+ cl_command_queue_ = clCreateCommandQueue(cl_context_,
+ cl_devices[cl_device_used],
+ 0,
+ &cl_error_number);
+ if (cl_error_number != CL_SUCCESS) {
+ error("Error %d in clCreateCommandQueue\n", cl_error_number);
+ return false;
+ }
+ return true;
+}
+
+bool CLDeviceContext::IsInitialized() const {
+ return (cl_context_ != NULL);
+}
+
+cl_context CLDeviceContext::GetContext() const {
+ return cl_context_;
+}
+
+cl_command_queue CLDeviceContext::GetCommandQueue() const {
+ return cl_command_queue_;
+}
+
+#endif // OPENSUBDIV_HAS_OPENCL
diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_opencl.h b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.h
new file mode 100644
index 00000000000..bc751cb6954
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.h
@@ -0,0 +1,52 @@
+// Adopted from OpenSubdiv with the following license:
+//
+// Copyright 2015 Pixar
+//
+// Licensed under the Apache License, Version 2.0 (the "Apache License")
+// with the following modification; you may not use this file except in
+// compliance with the Apache License and the following modification to it:
+// Section 6. Trademarks. is deleted and replaced with:
+//
+// 6. Trademarks. This License does not grant permission to use the trade
+// names, trademarks, service marks, or product names of the Licensor
+// and its affiliates, except as required to comply with Section 4(c) of
+// the License and to reproduce the content of the NOTICE file.
+//
+// You may obtain a copy of the Apache License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the Apache License with the above modification is
+// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the Apache License for the specific
+// language governing permissions and limitations under the Apache License.
+
+#ifndef OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_
+#define OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_
+
+#ifdef OPENSUBDIV_HAS_OPENCL
+#include <opensubdiv/osd/opencl.h>
+
+class CLDeviceContext {
+ public:
+ static bool HAS_CL_VERSION_1_1();
+
+ CLDeviceContext();
+ ~CLDeviceContext();
+
+ bool Initialize();
+
+ bool IsInitialized() const;
+
+ cl_context GetContext() const;
+ cl_command_queue GetCommandQueue() const;
+
+ protected:
+ cl_context cl_context_;
+ cl_command_queue cl_command_queue_;
+};
+
+#endif // OPENSUBDIV_HAS_OPENCL
+
+#endif // _OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator.cc b/intern/opensubdiv/internal/opensubdiv_evaluator.cc
new file mode 100644
index 00000000000..29d42a903ba
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator.cc
@@ -0,0 +1,154 @@
+// Copyright 2015 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#include "opensubdiv_evaluator_capi.h"
+
+#include <new>
+#include "MEM_guardedalloc.h"
+
+#include "internal/opensubdiv_evaluator_internal.h"
+
+namespace {
+
+void setCoarsePositions(OpenSubdiv_Evaluator* evaluator,
+ const float* positions,
+ const int start_vertex_index, const int num_vertices) {
+ evaluator->internal->eval_output->setCoarsePositions(positions,
+ start_vertex_index,
+ num_vertices);
+}
+
+void setVaryingData(OpenSubdiv_Evaluator* evaluator,
+ const float* varying_data,
+ const int start_vertex_index, const int num_vertices) {
+ evaluator->internal->eval_output->setVaryingData(varying_data,
+ start_vertex_index,
+ num_vertices);
+}
+
+void setFaceVaryingData(OpenSubdiv_Evaluator* evaluator,
+ const float* face_varying_data,
+ const int start_vertex_index, const int num_vertices) {
+ evaluator->internal->eval_output->setFaceVaryingData(face_varying_data,
+ start_vertex_index,
+ num_vertices);
+}
+
+void setCoarsePositionsFromBuffer(OpenSubdiv_Evaluator* evaluator,
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices) {
+ evaluator->internal->eval_output->setCoarsePositionsFromBuffer(
+ buffer,
+ start_offset,
+ stride,
+ start_vertex_index,
+ num_vertices);
+}
+
+void setVaryingDataFromBuffer(OpenSubdiv_Evaluator* evaluator,
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices) {
+ evaluator->internal->eval_output->setVaryingDataFromBuffer(
+ buffer,
+ start_offset,
+ stride,
+ start_vertex_index,
+ num_vertices);
+}
+
+void setFaceVaryingDataFromBuffer(OpenSubdiv_Evaluator* evaluator,
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices) {
+ evaluator->internal->eval_output->setFaceVaryingDataFromBuffer(
+ buffer,
+ start_offset,
+ stride,
+ start_vertex_index,
+ num_vertices);
+}
+
+void refine(OpenSubdiv_Evaluator* evaluator) {
+ evaluator->internal->eval_output->refine();
+}
+
+void evaluateLimit(OpenSubdiv_Evaluator* evaluator,
+ const int ptex_face_index,
+ const float face_u, const float face_v,
+ float P[3], float dPdu[3], float dPdv[3]) {
+ evaluator->internal->eval_output->evaluateLimit(ptex_face_index,
+ face_u, face_v,
+ P, dPdu, dPdv);
+}
+
+void evaluateVarying(OpenSubdiv_Evaluator* evaluator,
+ const int ptex_face_index,
+ float face_u, float face_v,
+ float varying[3]) {
+ evaluator->internal->eval_output->evaluateVarying(ptex_face_index,
+ face_u, face_v,
+ varying);
+}
+
+void evaluateFaceVarying(OpenSubdiv_Evaluator* evaluator,
+ const int ptex_face_index,
+ float face_u, float face_v,
+ float face_varying[2]) {
+ evaluator->internal->eval_output->evaluateFaceVarying(ptex_face_index,
+ face_u, face_v,
+ face_varying);
+}
+
+void assignFunctionPointers(OpenSubdiv_Evaluator* evaluator) {
+ evaluator->setCoarsePositions = setCoarsePositions;
+ evaluator->setVaryingData = setVaryingData;
+ evaluator->setFaceVaryingData = setFaceVaryingData;
+
+ evaluator->setCoarsePositionsFromBuffer = setCoarsePositionsFromBuffer;
+ evaluator->setVaryingDataFromBuffer = setVaryingDataFromBuffer;
+ evaluator->setFaceVaryingDataFromBuffer = setFaceVaryingDataFromBuffer;
+
+ evaluator->refine = refine;
+
+ evaluator->evaluateLimit = evaluateLimit;
+ evaluator->evaluateVarying = evaluateVarying;
+ evaluator->evaluateFaceVarying = evaluateFaceVarying;
+}
+
+} // namespace
+
+OpenSubdiv_Evaluator* openSubdiv_createEvaluatorFromTopologyRefiner(
+ OpenSubdiv_TopologyRefiner* topology_refiner) {
+ OpenSubdiv_Evaluator* evaluator = OBJECT_GUARDED_NEW(OpenSubdiv_Evaluator);
+ assignFunctionPointers(evaluator);
+ evaluator->internal = openSubdiv_createEvaluatorInternal(topology_refiner);
+ return evaluator;
+}
+
+void openSubdiv_deleteEvaluator(OpenSubdiv_Evaluator* evaluator) {
+ openSubdiv_deleteEvaluatorInternal(evaluator->internal);
+ OBJECT_GUARDED_DELETE(evaluator, OpenSubdiv_Evaluator);
+}
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
new file mode 100644
index 00000000000..d593518405f
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
@@ -0,0 +1,746 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#include "internal/opensubdiv_evaluator_internal.h"
+
+#include <cassert>
+#include <cstdio>
+#include <vector>
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <opensubdiv/far/patchMap.h>
+#include <opensubdiv/far/patchTable.h>
+#include <opensubdiv/far/patchTableFactory.h>
+#include <opensubdiv/osd/cpuEvaluator.h>
+#include <opensubdiv/osd/cpuPatchTable.h>
+#include <opensubdiv/osd/cpuVertexBuffer.h>
+#include <opensubdiv/osd/mesh.h>
+#include <opensubdiv/osd/types.h>
+#include <opensubdiv/version.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "internal/opensubdiv_topology_refiner_internal.h"
+#include "opensubdiv_topology_refiner_capi.h"
+
+using OpenSubdiv::Osd::BufferDescriptor;
+using OpenSubdiv::Osd::CpuEvaluator;
+using OpenSubdiv::Osd::CpuPatchTable;
+using OpenSubdiv::Osd::CpuVertexBuffer;
+using OpenSubdiv::Osd::PatchCoord;
+using OpenSubdiv::Far::PatchMap;
+using OpenSubdiv::Far::PatchTable;
+using OpenSubdiv::Far::PatchTableFactory;
+using OpenSubdiv::Far::StencilTable;
+using OpenSubdiv::Far::StencilTableFactory;
+using OpenSubdiv::Far::TopologyRefiner;
+
+// TODO(sergey): Remove after official requirement bump for OSD version.
+#if OPENSUBDIV_VERSION_NUMBER >= 30200
+# define OPENSUBDIV_HAS_FVAR_EVALUATION
+#else
+# undef OPENSUBDIV_HAS_FVAR_EVALUATION
+#endif
+
+namespace opensubdiv_capi {
+
+namespace {
+
+// Helper class to wrap numerous of patch coordinates into a buffer.
+// Used to pass coordinates to the CPU evaluator. Other evaluators are not
+// supported.
+class PatchCoordBuffer : public std::vector<PatchCoord> {
+ public:
+ static PatchCoordBuffer* Create(int size) {
+ PatchCoordBuffer* buffer = new PatchCoordBuffer();
+ buffer->resize(size);
+ return buffer;
+ }
+
+ PatchCoord* BindCpuBuffer() {
+ return reinterpret_cast<PatchCoord*>(&(*this)[0]);
+ }
+
+ int GetNumVertices() {
+ return size();
+ }
+
+ void UpdateData(const PatchCoord* patch_coords, int num_patch_coords) {
+ memcpy(&(*this)[0],
+ reinterpret_cast<const void*>(patch_coords),
+ sizeof(PatchCoord) * num_patch_coords);
+ }
+};
+
+// Helper class to wrap single of patch coord into a buffer. Used to pass
+// coordinates to the CPU evaluator. Other evaluators are not supported.
+class SinglePatchCoordBuffer {
+ public:
+ static SinglePatchCoordBuffer* Create() {
+ return new SinglePatchCoordBuffer();
+ }
+
+ SinglePatchCoordBuffer() {
+ }
+
+ explicit SinglePatchCoordBuffer(const PatchCoord &patch_coord)
+ : patch_coord_(patch_coord) {
+ }
+
+ PatchCoord* BindCpuBuffer() {
+ return &patch_coord_;
+ }
+
+ int GetNumVertices() {
+ return 1;
+ }
+
+ void UpdateData(const PatchCoord &patch_coord) {
+ patch_coord_ = patch_coord;
+ }
+
+ protected:
+ PatchCoord patch_coord_;
+};
+
+// Helper class which is aimed to be used in cases when buffer is small enough
+// and better to be allocated in stack rather than in heap.
+//
+// TODO(sergey): Check if bare arrays could be used by CPU evaluator.
+template <int element_size, int num_vertices>
+class StackAllocatedBuffer {
+ public:
+ static PatchCoordBuffer* Create(int /*size*/) {
+ // TODO(sergey): Validate that requested dize is smaller than static
+ // stack memory size.
+ return new StackAllocatedBuffer<element_size, num_vertices>();
+ }
+
+ float* BindCpuBuffer() {
+ return &data_[0];
+ }
+
+ int GetNumVertices() {
+ return num_vertices;
+ }
+
+ // TODO(sergey): Support UpdateData().
+ protected:
+ float data_[element_size * num_vertices];
+};
+
+// Volatile evaluator which can be used from threads.
+//
+// TODO(sergey): Make it possible to evaluate coordinates in chunks.
+// TODO(sergey): Make it possible to evaluate multiple face varying layers.
+// (or maybe, it's cheap to create new evaluator for existing
+// topology to evaluate all needed face varying layers?)
+template <typename SRC_VERTEX_BUFFER,
+ typename EVAL_VERTEX_BUFFER,
+ typename STENCIL_TABLE,
+ typename PATCH_TABLE,
+ typename EVALUATOR,
+ typename DEVICE_CONTEXT = void>
+class VolatileEvalOutput {
+ public:
+ typedef OpenSubdiv::Osd::EvaluatorCacheT<EVALUATOR> EvaluatorCache;
+
+ VolatileEvalOutput(const StencilTable* vertex_stencils,
+ const StencilTable* varying_stencils,
+ const StencilTable* face_varying_stencils,
+ const int face_varying_channel,
+ const int face_varying_width,
+ const PatchTable* patch_table,
+ EvaluatorCache* evaluator_cache = NULL,
+ DEVICE_CONTEXT* device_context = NULL)
+ : src_desc_(0, 3, 3),
+ src_varying_desc_(0, 3, 3),
+ src_face_varying_desc_(0, face_varying_width, face_varying_width),
+ face_varying_channel_(face_varying_channel),
+ face_varying_width_(face_varying_width),
+ evaluator_cache_(evaluator_cache),
+ device_context_(device_context) {
+ // Total number of vertices = coarse points + refined points + local points.
+ int num_total_vertices = vertex_stencils->GetNumControlVertices() +
+ vertex_stencils->GetNumStencils();
+ num_coarse_vertices_ = vertex_stencils->GetNumControlVertices();
+ using OpenSubdiv::Osd::convertToCompatibleStencilTable;
+ src_data_ =
+ SRC_VERTEX_BUFFER::Create(3, num_total_vertices, device_context_);
+ src_varying_data_ =
+ SRC_VERTEX_BUFFER::Create(3, num_total_vertices, device_context_);
+ patch_table_ = PATCH_TABLE::Create(patch_table, device_context_);
+ patch_coords_ = NULL;
+ vertex_stencils_ = convertToCompatibleStencilTable<STENCIL_TABLE>(
+ vertex_stencils, device_context_);
+ varying_stencils_ = convertToCompatibleStencilTable<STENCIL_TABLE>(
+ varying_stencils, device_context_);
+ if (face_varying_stencils != NULL) {
+ num_coarse_face_varying_vertices_ =
+ face_varying_stencils->GetNumControlVertices();
+ const int num_total_face_varying_vertices =
+ face_varying_stencils->GetNumControlVertices() +
+ face_varying_stencils->GetNumStencils();
+ src_face_varying_data_ =
+ EVAL_VERTEX_BUFFER::Create(2,
+ num_total_face_varying_vertices,
+ device_context_);
+ face_varying_stencils_ = convertToCompatibleStencilTable<STENCIL_TABLE>(
+ face_varying_stencils, device_context_);
+ } else {
+ num_coarse_face_varying_vertices_ = 0;
+ src_face_varying_data_ = NULL;
+ face_varying_stencils_ = NULL;
+ }
+ }
+
+ ~VolatileEvalOutput() {
+ delete src_data_;
+ delete src_varying_data_;
+ delete src_face_varying_data_;
+ delete patch_table_;
+ delete vertex_stencils_;
+ delete varying_stencils_;
+ delete face_varying_stencils_;
+ }
+
+ // TODO(sergey): Implement binding API.
+
+ void updateData(const float* src, int start_vertex, int num_vertices) {
+ src_data_->UpdateData(src, start_vertex, num_vertices, device_context_);
+ }
+
+ void updateVaryingData(const float* src, int start_vertex, int num_vertices) {
+ src_varying_data_->UpdateData(src,
+ start_vertex,
+ num_vertices,
+ device_context_);
+ }
+
+ void updateFaceVaryingData(const float* src,
+ int start_vertex,
+ int num_vertices) {
+ src_face_varying_data_->UpdateData(src,
+ start_vertex,
+ num_vertices,
+ device_context_);
+ }
+
+ bool hasVaryingData() const {
+ // return varying_stencils_ != NULL;
+ // TODO(sergey): Check this based on actual topology.
+ return false;
+ }
+
+ bool hasFaceVaryingData() const {
+ return face_varying_stencils_ != NULL;
+ }
+
+ void refine() {
+ // Evaluate vertex positions.
+ BufferDescriptor dst_desc = src_desc_;
+ dst_desc.offset += num_coarse_vertices_ * src_desc_.stride;
+ const EVALUATOR* eval_instance =
+ OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
+ src_desc_,
+ dst_desc,
+ device_context_);
+ EVALUATOR::EvalStencils(src_data_, src_desc_,
+ src_data_, dst_desc,
+ vertex_stencils_,
+ eval_instance,
+ device_context_);
+ // Evaluate varying data.
+ if (hasVaryingData()) {
+ BufferDescriptor dst_varying_desc = src_varying_desc_;
+ dst_varying_desc.offset +=
+ num_coarse_vertices_ * src_varying_desc_.stride;
+ eval_instance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
+ evaluator_cache_,
+ src_varying_desc_,
+ dst_varying_desc,
+ device_context_);
+ EVALUATOR::EvalStencils(src_varying_data_, src_varying_desc_,
+ src_varying_data_, dst_varying_desc,
+ varying_stencils_,
+ eval_instance, device_context_);
+ }
+ // Evaluate face-varying data.
+ if (hasFaceVaryingData()) {
+ BufferDescriptor dst_face_varying_desc = src_face_varying_desc_;
+ dst_face_varying_desc.offset += num_coarse_face_varying_vertices_ *
+ src_face_varying_desc_.stride;
+ eval_instance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
+ evaluator_cache_,
+ src_face_varying_desc_,
+ dst_face_varying_desc,
+ device_context_);
+ EVALUATOR::EvalStencils(src_face_varying_data_, src_face_varying_desc_,
+ src_face_varying_data_, dst_face_varying_desc,
+ face_varying_stencils_,
+ eval_instance,
+ device_context_);
+ }
+ }
+
+ void evalPatchCoord(const PatchCoord& patch_coord, float P[3]) {
+ StackAllocatedBuffer<6, 1> vertex_data;
+ // TODO(sergey): Varying data is interleaved in vertex array, so need to
+ // adjust stride if there is a varying data.
+ // BufferDescriptor vertex_desc(0, 3, 6);
+ BufferDescriptor vertex_desc(0, 3, 3);
+ SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
+ const EVALUATOR* eval_instance =
+ OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
+ src_desc_,
+ vertex_desc,
+ device_context_);
+ EVALUATOR::EvalPatches(src_data_,
+ src_desc_,
+ &vertex_data,
+ vertex_desc,
+ patch_coord_buffer.GetNumVertices(),
+ &patch_coord_buffer,
+ patch_table_,
+ eval_instance,
+ device_context_);
+ const float* refined_vertices = vertex_data.BindCpuBuffer();
+ memcpy(P, refined_vertices, sizeof(float) * 3);
+ }
+
+ void evalPatchesWithDerivatives(const PatchCoord& patch_coord,
+ float P[3],
+ float dPdu[3], float dPdv[3]) {
+ StackAllocatedBuffer<6, 1> vertex_data, derivatives;
+ // TODO(sergey): Varying data is interleaved in vertex array, so need to
+ // adjust stride if there is a varying data.
+ // BufferDescriptor vertex_desc(0, 3, 6);
+ BufferDescriptor vertex_desc(0, 3, 3);
+ BufferDescriptor du_desc(0, 3, 6), dv_desc(3, 3, 6);
+ SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
+ const EVALUATOR* eval_instance =
+ OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
+ src_desc_,
+ vertex_desc,
+ du_desc, dv_desc,
+ device_context_);
+ EVALUATOR::EvalPatches(src_data_, src_desc_,
+ &vertex_data, vertex_desc,
+ &derivatives, du_desc,
+ &derivatives, dv_desc,
+ patch_coord_buffer.GetNumVertices(),
+ &patch_coord_buffer,
+ patch_table_,
+ eval_instance,
+ device_context_);
+ const float* refined_vertices = vertex_data.BindCpuBuffer();
+ memcpy(P, refined_vertices, sizeof(float) * 3);
+ if (dPdu != NULL || dPdv != NULL) {
+ const float* refined_derivatives = derivatives.BindCpuBuffer();
+ if (dPdu != NULL) {
+ memcpy(dPdu, refined_derivatives, sizeof(float) * 3);
+ }
+ if (dPdv != NULL) {
+ memcpy(dPdv, refined_derivatives + 3, sizeof(float) * 3);
+ }
+ }
+ }
+
+ void evalPatchVarying(const PatchCoord& patch_coord, float varying[3]) {
+ StackAllocatedBuffer<6, 1> varying_data;
+ BufferDescriptor varying_desc(3, 3, 6);
+ SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
+ const EVALUATOR* eval_instance =
+ OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
+ src_varying_desc_,
+ varying_desc,
+ device_context_);
+ EVALUATOR::EvalPatchesVarying(src_varying_data_, src_varying_desc_,
+ &varying_data, varying_desc,
+ patch_coord_buffer.GetNumVertices(),
+ &patch_coord_buffer,
+ patch_table_,
+ eval_instance,
+ device_context_);
+ const float* refined_varying = varying_data.BindCpuBuffer();
+ memcpy(varying, refined_varying, sizeof(float) * 3);
+ }
+
+ void evalPatchFaceVarying(const PatchCoord& patch_coord,
+ float face_varying[2]) {
+ StackAllocatedBuffer<2, 1> face_varying_data;
+ BufferDescriptor face_varying_desc(0, 2, 2);
+ SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
+ const EVALUATOR* eval_instance =
+ OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
+ src_face_varying_desc_,
+ face_varying_desc,
+ device_context_);
+ EVALUATOR::EvalPatchesFaceVarying(
+ src_face_varying_data_, src_face_varying_desc_,
+ &face_varying_data, face_varying_desc,
+ patch_coord_buffer.GetNumVertices(),
+ &patch_coord_buffer,
+ patch_table_,
+ face_varying_channel_,
+ eval_instance,
+ device_context_);
+ const float* refined_face_varying = face_varying_data.BindCpuBuffer();
+ memcpy(face_varying, refined_face_varying, sizeof(float) * 2);
+ }
+
+ private:
+ SRC_VERTEX_BUFFER* src_data_;
+ SRC_VERTEX_BUFFER* src_varying_data_;
+ EVAL_VERTEX_BUFFER* src_face_varying_data_;
+ PatchCoordBuffer* patch_coords_;
+ PATCH_TABLE* patch_table_;
+ BufferDescriptor src_desc_;
+ BufferDescriptor src_varying_desc_;
+ BufferDescriptor src_face_varying_desc_;
+
+ int num_coarse_vertices_;
+ int face_varying_channel_;
+ int face_varying_width_;
+ int num_coarse_face_varying_vertices_;
+
+ const STENCIL_TABLE* vertex_stencils_;
+ const STENCIL_TABLE* varying_stencils_;
+ const STENCIL_TABLE* face_varying_stencils_;
+
+ EvaluatorCache* evaluator_cache_;
+ DEVICE_CONTEXT* device_context_;
+};
+
+} // namespace
+
+// Note: Define as a class instead of typedcef to make it possible
+// to have anonymous class in opensubdiv_evaluator_internal.h
+class CpuEvalOutput : public VolatileEvalOutput<CpuVertexBuffer,
+ CpuVertexBuffer,
+ StencilTable,
+ CpuPatchTable,
+ CpuEvaluator> {
+ public:
+ CpuEvalOutput(const StencilTable* vertex_stencils,
+ const StencilTable* varying_stencils,
+ const StencilTable* face_varying_stencils,
+ const int face_varying_channel,
+ const int face_varying_width,
+ const PatchTable* patch_table,
+ EvaluatorCache* evaluator_cache = NULL)
+ : VolatileEvalOutput<CpuVertexBuffer,
+ CpuVertexBuffer,
+ StencilTable,
+ CpuPatchTable,
+ CpuEvaluator> (vertex_stencils,
+ varying_stencils,
+ face_varying_stencils,
+ face_varying_channel,
+ face_varying_width,
+ patch_table,
+ evaluator_cache) {
+ }
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Evaluator wrapper for anonymous API.
+
+CpuEvalOutputAPI::CpuEvalOutputAPI(CpuEvalOutput* implementation,
+ OpenSubdiv::Far::PatchMap* patch_map)
+ : implementation_(implementation),
+ patch_map_(patch_map) {
+}
+
+CpuEvalOutputAPI::~CpuEvalOutputAPI() {
+ delete implementation_;
+}
+
+void CpuEvalOutputAPI::setCoarsePositions(const float* positions,
+ const int start_vertex_index,
+ const int num_vertices) {
+ // TODO(sergey): Add sanity check on indices.
+ implementation_->updateData(positions, start_vertex_index, num_vertices);
+}
+
+void CpuEvalOutputAPI::setVaryingData(const float* varying_data,
+ const int start_vertex_index,
+ const int num_vertices) {
+ // TODO(sergey): Add sanity check on indices.
+ implementation_->updateVaryingData(varying_data,
+ start_vertex_index,
+ num_vertices);
+}
+
+void CpuEvalOutputAPI::setFaceVaryingData(const float* face_varying_data,
+ const int start_vertex_index,
+ const int num_vertices) {
+ // TODO(sergey): Add sanity check on indices.
+ implementation_->updateFaceVaryingData(face_varying_data,
+ start_vertex_index,
+ num_vertices);
+}
+
+void CpuEvalOutputAPI::setCoarsePositionsFromBuffer(
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices) {
+ // TODO(sergey): Add sanity check on indices.
+ const unsigned char* current_buffer = (unsigned char *)buffer;
+ current_buffer += start_offset;
+ for (int i = 0; i < num_vertices; ++i) {
+ const int current_vertex_index = start_vertex_index + i;
+ implementation_->updateData(reinterpret_cast<const float*>(current_buffer),
+ current_vertex_index, 1);
+ current_buffer += stride;
+ }
+}
+
+void CpuEvalOutputAPI::setVaryingDataFromBuffer(
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices) {
+ // TODO(sergey): Add sanity check on indices.
+ const unsigned char* current_buffer = (unsigned char *)buffer;
+ current_buffer += start_offset;
+ for (int i = 0; i < num_vertices; ++i) {
+ const int current_vertex_index = start_vertex_index + i;
+ implementation_->updateVaryingData(
+ reinterpret_cast<const float*>(current_buffer),
+ current_vertex_index, 1);
+ current_buffer += stride;
+ }
+}
+
+void CpuEvalOutputAPI::setFaceVaryingDataFromBuffer(
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices) {
+ // TODO(sergey): Add sanity check on indices.
+ const unsigned char* current_buffer = (unsigned char *)buffer;
+ current_buffer += start_offset;
+ for (int i = 0; i < num_vertices; ++i) {
+ const int current_vertex_index = start_vertex_index + i;
+ implementation_->updateFaceVaryingData(
+ reinterpret_cast<const float*>(current_buffer),
+ current_vertex_index, 1);
+ current_buffer += stride;
+ }
+}
+
+void CpuEvalOutputAPI::refine() {
+ implementation_->refine();
+}
+
+void CpuEvalOutputAPI::evaluateLimit(const int ptex_face_index,
+ float face_u, float face_v,
+ float P[3], float dPdu[3], float dPdv[3]) {
+ assert(face_u >= 0.0f);
+ assert(face_u <= 1.0f);
+ assert(face_v >= 0.0f);
+ assert(face_v <= 1.0f);
+ const PatchTable::PatchHandle* handle =
+ patch_map_->FindPatch(ptex_face_index, face_u, face_v);
+ PatchCoord patch_coord(*handle, face_u, face_v);
+ if (dPdu != NULL || dPdv != NULL) {
+ implementation_->evalPatchesWithDerivatives(patch_coord, P, dPdu, dPdv);
+ } else {
+ implementation_->evalPatchCoord(patch_coord, P);
+ }}
+
+void CpuEvalOutputAPI::evaluateVarying(const int ptex_face_index,
+ float face_u, float face_v,
+ float varying[3]) {
+ assert(face_u >= 0.0f);
+ assert(face_u <= 1.0f);
+ assert(face_v >= 0.0f);
+ assert(face_v <= 1.0f);
+ const PatchTable::PatchHandle* handle =
+ patch_map_->FindPatch(ptex_face_index, face_u, face_v);
+ PatchCoord patch_coord(*handle, face_u, face_v);
+ implementation_->evalPatchVarying(patch_coord, varying);
+}
+
+void CpuEvalOutputAPI::evaluateFaceVarying(const int ptex_face_index,
+ float face_u, float face_v,
+ float face_varying[2]) {
+ assert(face_u >= 0.0f);
+ assert(face_u <= 1.0f);
+ assert(face_v >= 0.0f);
+ assert(face_v <= 1.0f);
+ const PatchTable::PatchHandle* handle =
+ patch_map_->FindPatch(ptex_face_index, face_u, face_v);
+ PatchCoord patch_coord(*handle, face_u, face_v);
+ implementation_->evalPatchFaceVarying(patch_coord, face_varying);
+}
+
+} // namespace opensubdiv_capi
+
+OpenSubdiv_EvaluatorInternal::OpenSubdiv_EvaluatorInternal()
+ : eval_output(NULL),
+ patch_map(NULL),
+ patch_table(NULL) {
+}
+
+OpenSubdiv_EvaluatorInternal::~OpenSubdiv_EvaluatorInternal() {
+ delete eval_output;
+ delete patch_map;
+ delete patch_table;
+}
+
+OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal(
+ OpenSubdiv_TopologyRefiner* topology_refiner) {
+ TopologyRefiner* refiner = topology_refiner->internal->osd_topology_refiner;
+ if (refiner == NULL) {
+ // Happens on bad topology.
+ return NULL;
+ }
+ // TODO(sergey): Base this on actual topology.
+ // const bool bas_varying_data = false;
+ const bool has_face_varying_data =
+ (refiner->GetNumFVarChannels() != 0);
+ const int level = topology_refiner->getSubdivisionLevel(topology_refiner);
+ // TODO(sergey): Query from topology refiner.
+ const bool is_adaptive = topology_refiner->getIsAdaptive(topology_refiner);
+ // Refine the topology with given settings.
+ // TODO(sergey): What if topology is already refined?
+ if (is_adaptive) {
+ TopologyRefiner::AdaptiveOptions options(level);
+ options.considerFVarChannels = has_face_varying_data;
+ options.useInfSharpPatch = false;
+ refiner->RefineAdaptive(options);
+ } else {
+ TopologyRefiner::UniformOptions options(level);
+ refiner->RefineUniform(options);
+ }
+ // Generate stencil table to update the bi-cubic patches control vertices
+ // after they have been re-posed (both for vertex & varying interpolation).
+ //
+ // Vertex stencils.
+ StencilTableFactory::Options vertex_stencil_options;
+ vertex_stencil_options.generateOffsets = true;
+ vertex_stencil_options.generateIntermediateLevels = is_adaptive;
+ const StencilTable* vertex_stencils =
+ StencilTableFactory::Create(*refiner, vertex_stencil_options);
+ // Varying stencils.
+ //
+ // TODO(sergey): Seems currently varying stencils are always required in
+ // OpenSubdiv itself.
+ const StencilTable* varying_stencils = NULL;
+ StencilTableFactory::Options varying_stencil_options;
+ varying_stencil_options.generateOffsets = true;
+ varying_stencil_options.generateIntermediateLevels = is_adaptive;
+ varying_stencil_options.interpolationMode =
+ StencilTableFactory::INTERPOLATE_VARYING;
+ varying_stencils =
+ StencilTableFactory::Create(*refiner, varying_stencil_options);
+ // Face warying stencil.
+ const StencilTable* face_varying_stencils = NULL;
+#ifdef OPENSUBDIV_HAS_FVAR_EVALUATION
+ if (has_face_varying_data) {
+ StencilTableFactory::Options face_varying_stencil_options;
+ face_varying_stencil_options.generateOffsets = true;
+ face_varying_stencil_options.generateIntermediateLevels = is_adaptive;
+ face_varying_stencil_options.interpolationMode =
+ StencilTableFactory::INTERPOLATE_FACE_VARYING;
+ // TODO(sergey): Make it configurable which face varying channel is being
+ // interpolated.
+ face_varying_stencil_options.fvarChannel = 0;
+ face_varying_stencils =
+ StencilTableFactory::Create(*refiner, face_varying_stencil_options);
+ }
+#endif
+ // Generate bi-cubic patch table for the limit surface.
+ // TODO(sergey): Ideally we would want to expose end-cap settings via
+ // C-API to make it more generic. Currently it matches old Blender's
+ // subsurf code.
+ PatchTableFactory::Options patch_options(level);
+ patch_options.SetEndCapType(PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS);
+ patch_options.useInfSharpPatch = false;
+ patch_options.generateFVarTables = has_face_varying_data;
+ patch_options.generateFVarLegacyLinearPatches = false;
+ const PatchTable* patch_table = PatchTableFactory::Create(
+ *refiner, patch_options);
+ // Append local points stencils.
+ const StencilTable* local_point_stencil_table =
+ patch_table->GetLocalPointStencilTable();
+ if (local_point_stencil_table != NULL) {
+ const StencilTable* table =
+ StencilTableFactory::AppendLocalPointStencilTable(
+ *refiner, vertex_stencils, local_point_stencil_table);
+ delete vertex_stencils;
+ vertex_stencils = table;
+ }
+ const StencilTable* local_point_varying_stencil_table =
+ patch_table->GetLocalPointVaryingStencilTable();
+ if (local_point_varying_stencil_table != NULL) {
+ const StencilTable* table =
+ StencilTableFactory::AppendLocalPointStencilTable(
+ *refiner, varying_stencils, local_point_varying_stencil_table);
+ delete varying_stencils;
+ varying_stencils = table;
+ }
+#ifdef OPENSUBDIV_HAS_FVAR_EVALUATION
+ const StencilTable* local_point_face_varying_stencil_table =
+ patch_table->GetLocalPointFaceVaryingStencilTable();
+ if (local_point_face_varying_stencil_table != NULL) {
+ const StencilTable* table =
+ StencilTableFactory::AppendLocalPointStencilTableFaceVarying(
+ *refiner,
+ face_varying_stencils,
+ local_point_face_varying_stencil_table);
+ delete face_varying_stencils;
+ face_varying_stencils = table;
+ }
+#endif
+ // Create OpenSubdiv's CPU side evaluator.
+ // TODO(sergey): Make it possible to use different evaluators.
+ opensubdiv_capi::CpuEvalOutput* eval_output =
+ new opensubdiv_capi::CpuEvalOutput(vertex_stencils,
+ varying_stencils,
+ face_varying_stencils,
+ 0, 2,
+ patch_table);
+ OpenSubdiv::Far::PatchMap* patch_map = new PatchMap(*patch_table);
+ // Wrap everything we need into an object which we control from our side.
+ OpenSubdiv_EvaluatorInternal* evaluator_descr;
+ evaluator_descr = OBJECT_GUARDED_NEW(OpenSubdiv_EvaluatorInternal);
+ evaluator_descr->eval_output =
+ new opensubdiv_capi::CpuEvalOutputAPI(eval_output, patch_map);
+ evaluator_descr->patch_map = patch_map;
+ evaluator_descr->patch_table = patch_table;
+ // TOOD(sergey): Look into whether we've got duplicated stencils arrays.
+ delete vertex_stencils;
+ delete varying_stencils;
+ delete face_varying_stencils;
+ return evaluator_descr;
+}
+
+void openSubdiv_deleteEvaluatorInternal(
+ OpenSubdiv_EvaluatorInternal* evaluator) {
+ OBJECT_GUARDED_DELETE(evaluator, OpenSubdiv_EvaluatorInternal);
+}
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
new file mode 100644
index 00000000000..cc69db6abc6
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
@@ -0,0 +1,134 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_EVALUATOR_INTERNAL_H_
+#define OPENSUBDIV_EVALUATOR_INTERNAL_H_
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <opensubdiv/far/patchMap.h>
+#include <opensubdiv/far/patchTable.h>
+
+struct OpenSubdiv_TopologyRefiner;
+
+namespace opensubdiv_capi {
+
+// Anonymous forward declaration of actual evaluator implementation.
+class CpuEvalOutput;
+
+// Wrapper around implementaiton, which defines API which we are capable to
+// provide over the implementation.
+//
+// TODO(sergey): It is almost the same as C-API object, so ideally need to
+// merge them somehow, but how to do this and keep files with all the templates
+// and such separate?
+class CpuEvalOutputAPI {
+ public:
+ // NOTE: API object becomes an owner of evaluator. Patch we are referencing.
+ CpuEvalOutputAPI(CpuEvalOutput* implementation,
+ OpenSubdiv::Far::PatchMap* patch_map);
+ ~CpuEvalOutputAPI();
+
+ // Set coarse positions from a continuous array of coordinates.
+ void setCoarsePositions(const float* positions,
+ const int start_vertex_index,
+ const int num_vertices);
+ // Set varying data from a continuous array of data.
+ void setVaryingData(const float* varying_data,
+ const int start_vertex_index, const int num_vertices);
+ // Set face varying data from a continuous array of data.
+ //
+ // TODO(sergey): Find a better name for vertex here. It is not the vertex of
+ // geometry, but a vertex of UV map.
+ void setFaceVaryingData(const float* varying_data,
+ const int start_vertex_index, const int num_vertices);
+
+ // Set coarse vertex position from a continuous memory buffer where
+ // first coordinate starts at offset of `start_offset` and there is `stride`
+ // bytes between adjacent vertex coordinates.
+ void setCoarsePositionsFromBuffer(const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices);
+ // Set varying data from a continuous memory buffer where
+ // first coordinate starts at offset of `start_offset` and there is `stride`
+ // bytes between adjacent vertex coordinates.
+ void setVaryingDataFromBuffer(const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices);
+ // Set face varying data from a continuous memory buffer where
+ // first coordinate starts at offset of `start_offset` and there is `stride`
+ // bytes between adjacent vertex coordinates.
+ //
+ // TODO(sergey): Find a better name for vertex here. It is not the vertex of
+ // geometry, but a vertex of UV map.
+ void setFaceVaryingDataFromBuffer(const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices);
+
+ // Refine after coarse positions update.
+ void refine();
+
+ // Evaluate given ptex face at given bilinear coordinate.
+ // If derivatives are NULL, they will not be evaluated.
+ void evaluateLimit(const int ptex_face_index,
+ float face_u, float face_v,
+ float P[3], float dPdu[3], float dPdv[3]);
+
+ // Evaluate varying data at a given bilinear coordinate of given ptex face.
+ void evaluateVarying(const int ptes_face_index,
+ float face_u, float face_v,
+ float varying[3]);
+
+ // Evaluate facee-varying data at a given bilinear coordinate of given
+ // ptex face.
+ void evaluateFaceVarying(const int ptes_face_index,
+ float face_u, float face_v,
+ float face_varying[2]);
+
+ protected:
+ CpuEvalOutput* implementation_;
+ OpenSubdiv::Far::PatchMap* patch_map_;
+};
+
+} // namespace opensubdiv_capi
+
+struct OpenSubdiv_EvaluatorInternal {
+ public:
+ OpenSubdiv_EvaluatorInternal();
+ ~OpenSubdiv_EvaluatorInternal();
+
+ opensubdiv_capi::CpuEvalOutputAPI* eval_output;
+ const OpenSubdiv::Far::PatchMap* patch_map;
+ const OpenSubdiv::Far::PatchTable* patch_table;
+};
+
+OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal(
+ struct OpenSubdiv_TopologyRefiner* topology_refiner);
+
+void openSubdiv_deleteEvaluatorInternal(
+ OpenSubdiv_EvaluatorInternal* evaluator);
+
+#endif // OPENSUBDIV_EVALUATOR_INTERNAL_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
new file mode 100644
index 00000000000..34d27591d0b
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
@@ -0,0 +1,287 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+// Contributor(s): Brecht van Lommel
+
+#include "opensubdiv_gl_mesh_capi.h"
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <opensubdiv/far/stencilTable.h>
+#include <opensubdiv/osd/glMesh.h>
+#include <opensubdiv/osd/glPatchTable.h>
+
+using OpenSubdiv::Far::StencilTable;
+using OpenSubdiv::Osd::GLMeshInterface;
+using OpenSubdiv::Osd::GLPatchTable;
+using OpenSubdiv::Osd::Mesh;
+using OpenSubdiv::Osd::MeshBitset;
+
+// CPU backend.
+#include <opensubdiv/osd/cpuEvaluator.h>
+#include <opensubdiv/osd/cpuGLVertexBuffer.h>
+using OpenSubdiv::Osd::CpuGLVertexBuffer;
+using OpenSubdiv::Osd::CpuEvaluator;
+typedef Mesh<CpuGLVertexBuffer,
+ StencilTable,
+ CpuEvaluator,
+ GLPatchTable> OsdCpuMesh;
+// OpenMP backend.
+#ifdef OPENSUBDIV_HAS_OPENMP
+# include <opensubdiv/osd/ompEvaluator.h>
+using OpenSubdiv::Osd::OmpEvaluator;
+typedef Mesh<CpuGLVertexBuffer,
+ StencilTable,
+ OmpEvaluator,
+ GLPatchTable> OsdOmpMesh;
+#endif
+// OpenCL backend.
+#ifdef OPENSUBDIV_HAS_OPENCL
+# include <opensubdiv/osd/clEvaluator.h>
+# include <opensubdiv/osd/clGLVertexBuffer.h>
+# include "opensubdiv_device_context_opencl.h"
+using OpenSubdiv::Osd::CLEvaluator;
+using OpenSubdiv::Osd::CLGLVertexBuffer;
+using OpenSubdiv::Osd::CLStencilTable;
+/* TODO(sergey): Use CLDeviceContext similar to OSD examples? */
+typedef Mesh<CLGLVertexBuffer,
+ CLStencilTable,
+ CLEvaluator,
+ GLPatchTable,
+ CLDeviceContext> OsdCLMesh;
+static CLDeviceContext g_cl_device_context;
+#endif
+// CUDA backend.
+#ifdef OPENSUBDIV_HAS_CUDA
+# include <opensubdiv/osd/cudaEvaluator.h>
+# include <opensubdiv/osd/cudaGLVertexBuffer.h>
+# include "opensubdiv_device_context_cuda.h"
+using OpenSubdiv::Osd::CudaEvaluator;
+using OpenSubdiv::Osd::CudaGLVertexBuffer;
+using OpenSubdiv::Osd::CudaStencilTable;
+typedef Mesh<CudaGLVertexBuffer,
+ CudaStencilTable,
+ CudaEvaluator,
+ GLPatchTable> OsdCudaMesh;
+static CudaDeviceContext g_cuda_device_context;
+#endif
+// Transform feedback backend.
+#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
+# include <opensubdiv/osd/glVertexBuffer.h>
+# include <opensubdiv/osd/glXFBEvaluator.h>
+using OpenSubdiv::Osd::GLXFBEvaluator;
+using OpenSubdiv::Osd::GLStencilTableTBO;
+using OpenSubdiv::Osd::GLVertexBuffer;
+typedef Mesh<GLVertexBuffer,
+ GLStencilTableTBO,
+ GLXFBEvaluator,
+ GLPatchTable> OsdGLSLTransformFeedbackMesh;
+#endif
+// GLSL compute backend.
+#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
+# include <opensubdiv/osd/glComputeEvaluator.h>
+# include <opensubdiv/osd/glVertexBuffer.h>
+using OpenSubdiv::Osd::GLComputeEvaluator;
+using OpenSubdiv::Osd::GLStencilTableSSBO;
+using OpenSubdiv::Osd::GLVertexBuffer;
+typedef Mesh<GLVertexBuffer,
+ GLStencilTableSSBO,
+ GLComputeEvaluator,
+ GLPatchTable> OsdGLSLComputeMesh;
+#endif
+
+#include <string>
+#include <vector>
+
+#include "MEM_guardedalloc.h"
+
+#include "opensubdiv_topology_refiner_capi.h"
+#include "internal/opensubdiv_gl_mesh_draw.h"
+#include "internal/opensubdiv_gl_mesh_fvar.h"
+#include "internal/opensubdiv_gl_mesh_internal.h"
+#include "internal/opensubdiv_topology_refiner_internal.h"
+
+namespace {
+
+GLMeshInterface* createGLMeshInterface(
+ OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const MeshBitset& bits,
+ const int num_vertex_elements,
+ const int num_varying_elements,
+ const int level,
+ eOpenSubdivEvaluator evaluator_type) {
+ GLMeshInterface* mesh = NULL;
+ switch (evaluator_type) {
+#define CHECK_EVALUATOR_TYPE(type, class) \
+ case OPENSUBDIV_EVALUATOR_##type: \
+ mesh = new class(topology_refiner, \
+ num_vertex_elements, \
+ num_varying_elements, \
+ level, \
+ bits); \
+ break;
+
+#define CHECK_EVALUATOR_TYPE_STUB(type) \
+ case OPENSUBDIV_EVALUATOR_##type: \
+ mesh = NULL; \
+ break;
+
+ CHECK_EVALUATOR_TYPE(CPU, OsdCpuMesh)
+#ifdef OPENSUBDIV_HAS_OPENMP
+ CHECK_EVALUATOR_TYPE(OPENMP, OsdOmpMesh)
+#else
+ CHECK_EVALUATOR_TYPE_STUB(OPENMP)
+#endif
+#ifdef OPENSUBDIV_HAS_OPENCL
+ CHECK_EVALUATOR_TYPE(OPENCL, OsdCLMesh)
+#else
+ CHECK_EVALUATOR_TYPE_STUB(OPENCL)
+#endif
+#ifdef OPENSUBDIV_HAS_CUDA
+ CHECK_EVALUATOR_TYPE(CUDA, OsdCudaMesh)
+#else
+ CHECK_EVALUATOR_TYPE_STUB(CUDA)
+#endif
+#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
+ CHECK_EVALUATOR_TYPE(GLSL_TRANSFORM_FEEDBACK, OsdGLSLTransformFeedbackMesh)
+#else
+ CHECK_EVALUATOR_TYPE_STUB(GLSL_TRANSFORM_FEEDBACK)
+#endif
+#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
+ CHECK_EVALUATOR_TYPE(GLSL_COMPUTE, OsdGLSLComputeMesh)
+#else
+ CHECK_EVALUATOR_TYPE_STUB(GLSL_COMPUTE)
+#endif
+
+#undef CHECK_EVALUATOR_TYPE
+#undef CHECK_EVALUATOR_TYPE_STUB
+ }
+ return mesh;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// GLMesh structure "methods".
+
+opensubdiv_capi::GLMeshFVarData* createFVarData(
+ OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ GLMeshInterface* mesh,
+ const float *fvar_src_buffer) {
+ using opensubdiv_capi::GLMeshFVarData;
+ GLMeshFVarData* fvar_data = new GLMeshFVarData();
+ fvar_data->create(topology_refiner,
+ mesh->GetFarPatchTable(),
+ 2,
+ fvar_src_buffer);
+ return fvar_data;
+}
+
+unsigned int getPatchIndexBuffer(OpenSubdiv_GLMesh* gl_mesh) {
+ return gl_mesh->internal->mesh_interface
+ ->GetPatchTable()
+ ->GetPatchIndexBuffer();
+}
+
+void bindVertexBuffer(OpenSubdiv_GLMesh* gl_mesh) {
+ gl_mesh->internal->mesh_interface->BindVertexBuffer();
+}
+
+void setCoarsePositions(OpenSubdiv_GLMesh* gl_mesh,
+ const float* positions,
+ const int start_vertex,
+ const int num_vertices) {
+ gl_mesh->internal->mesh_interface->UpdateVertexBuffer(positions,
+ start_vertex,
+ num_vertices);
+}
+
+void refine(OpenSubdiv_GLMesh* gl_mesh) {
+ gl_mesh->internal->mesh_interface->Refine();
+}
+
+void synchronize(struct OpenSubdiv_GLMesh* gl_mesh) {
+ gl_mesh->internal->mesh_interface->Synchronize();
+}
+
+void assignFunctionPointers(OpenSubdiv_GLMesh* gl_mesh) {
+ gl_mesh->getPatchIndexBuffer = getPatchIndexBuffer;
+ gl_mesh->bindVertexBuffer = bindVertexBuffer;
+ gl_mesh->setCoarsePositions = setCoarsePositions;
+ gl_mesh->refine = refine;
+ gl_mesh->synchronize = synchronize;
+
+ gl_mesh->prepareDraw = opensubdiv_capi::GLMeshDisplayPrepare;
+ gl_mesh->drawPatches = opensubdiv_capi::GLMeshDisplayDrawPatches;
+}
+
+} // namespace
+
+struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
+ OpenSubdiv_TopologyRefiner* topology_refiner,
+ eOpenSubdivEvaluator evaluator_type) {
+ using OpenSubdiv::Far::TopologyRefiner;
+ TopologyRefiner* osd_topology_refiner =
+ topology_refiner->internal->osd_topology_refiner;
+ // TODO(sergey): Query this from refiner.
+ const bool is_adaptive = false;
+ MeshBitset bits;
+ bits.set(OpenSubdiv::Osd::MeshAdaptive, is_adaptive);
+ bits.set(OpenSubdiv::Osd::MeshUseSingleCreasePatch, 0);
+ bits.set(OpenSubdiv::Osd::MeshInterleaveVarying, 1);
+ bits.set(OpenSubdiv::Osd::MeshFVarData, 1);
+ bits.set(OpenSubdiv::Osd::MeshEndCapBSplineBasis, 1);
+ const int num_vertex_elements = 3;
+ const int num_varying_elements = 3;
+ GLMeshInterface* mesh = createGLMeshInterface(
+ osd_topology_refiner,
+ bits,
+ num_vertex_elements,
+ num_varying_elements,
+ osd_topology_refiner->GetMaxLevel(),
+ evaluator_type);
+ if (mesh == NULL) {
+ return NULL;
+ }
+ OpenSubdiv_GLMesh* gl_mesh = OBJECT_GUARDED_NEW(OpenSubdiv_GLMesh);
+ assignFunctionPointers(gl_mesh);
+ gl_mesh->internal = new OpenSubdiv_GLMeshInternal();
+ gl_mesh->internal->evaluator_type = evaluator_type;
+ gl_mesh->internal->mesh_interface = mesh;
+ // Face-varying support.
+ // TODO(sergey): This part needs to be re-done.
+ if (osd_topology_refiner->GetNumFVarChannels() > 0) {
+ // TODO(sergey): This is a temporary stub to get things compiled. Need
+ // to store base level UVs somewhere else.
+ std::vector<float> uvs;
+ std::vector<float> fvar_data_buffer;
+ opensubdiv_capi::interpolateFVarData(*osd_topology_refiner,
+ uvs,
+ &fvar_data_buffer);
+ gl_mesh->internal->fvar_data = createFVarData(osd_topology_refiner,
+ mesh,
+ &fvar_data_buffer[0]);
+ } else {
+ gl_mesh->internal->fvar_data = NULL;
+ }
+ return gl_mesh;
+}
+
+void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh) {
+ delete gl_mesh->internal;
+ OBJECT_GUARDED_DELETE(gl_mesh, OpenSubdiv_GLMesh);
+}
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc
new file mode 100644
index 00000000000..0d2f8dc9842
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc
@@ -0,0 +1,587 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#include "internal/opensubdiv_gl_mesh_draw.h"
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <GL/glew.h>
+#include <cmath>
+#include <cstdio>
+
+#include <opensubdiv/osd/glMesh.h>
+
+#ifdef OPENSUBDIV_HAS_CUDA
+# include <opensubdiv/osd/cudaGLVertexBuffer.h>
+#endif // OPENSUBDIV_HAS_CUDA
+
+#include <opensubdiv/osd/cpuEvaluator.h>
+#include <opensubdiv/osd/cpuGLVertexBuffer.h>
+
+#include "internal/opensubdiv_gl_mesh_fvar.h"
+#include "internal/opensubdiv_gl_mesh_internal.h"
+#include "opensubdiv_capi.h"
+#include "opensubdiv_gl_mesh_capi.h"
+
+using OpenSubdiv::Osd::GLMeshInterface;
+
+extern "C" char datatoc_gpu_shader_opensubdiv_vertex_glsl[];
+extern "C" char datatoc_gpu_shader_opensubdiv_geometry_glsl[];
+extern "C" char datatoc_gpu_shader_opensubdiv_fragment_glsl[];
+
+// TODO(sergey): Those are a bit of bad level calls :S
+extern "C" {
+void copy_m3_m3(float m1[3][3], float m2[3][3]);
+void copy_m3_m4(float m1[3][3], float m2[4][4]);
+void adjoint_m3_m3(float m1[3][3], float m[3][3]);
+float determinant_m3_array(float m[3][3]);
+bool invert_m3_m3(float m1[3][3], float m2[3][3]);
+bool invert_m3(float m[3][3]);
+void transpose_m3(float mat[3][3]);
+}
+
+#define MAX_LIGHTS 8
+#define SUPPORT_COLOR_MATERIAL
+
+typedef struct Light {
+ float position[4];
+ float ambient[4];
+ float diffuse[4];
+ float specular[4];
+ float spot_direction[4];
+#ifdef SUPPORT_COLOR_MATERIAL
+ float constant_attenuation;
+ float linear_attenuation;
+ float quadratic_attenuation;
+ float spot_cutoff;
+ float spot_exponent;
+ float spot_cos_cutoff;
+ float pad, pad2;
+#endif
+} Light;
+
+typedef struct Lighting {
+ Light lights[MAX_LIGHTS];
+ int num_enabled;
+} Lighting;
+
+typedef struct Transform {
+ float projection_matrix[16];
+ float model_view_matrix[16];
+ float normal_matrix[9];
+} Transform;
+
+static bool g_use_osd_glsl = false;
+static int g_active_uv_index = 0;
+
+static GLuint g_flat_fill_solid_program = 0;
+static GLuint g_flat_fill_texture2d_program = 0;
+static GLuint g_smooth_fill_solid_program = 0;
+static GLuint g_smooth_fill_texture2d_program = 0;
+
+static GLuint g_flat_fill_solid_shadeless_program = 0;
+static GLuint g_flat_fill_texture2d_shadeless_program = 0;
+static GLuint g_smooth_fill_solid_shadeless_program = 0;
+static GLuint g_smooth_fill_texture2d_shadeless_program = 0;
+
+static GLuint g_wireframe_program = 0;
+
+static GLuint g_lighting_ub = 0;
+static Lighting g_lighting_data;
+static Transform g_transform;
+
+namespace {
+
+GLuint compileShader(GLenum shaderType,
+ const char* version,
+ const char* define,
+ const char* source) {
+ const char* sources[] = {
+ version, define,
+#ifdef SUPPORT_COLOR_MATERIAL
+ "#define SUPPORT_COLOR_MATERIAL\n",
+#else
+ "",
+#endif
+ source,
+ };
+
+ GLuint shader = glCreateShader(shaderType);
+ glShaderSource(shader, 4, sources, NULL);
+ glCompileShader(shader);
+
+ GLint status;
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
+ if (status == GL_FALSE) {
+ GLchar emsg[1024];
+ glGetShaderInfoLog(shader, sizeof(emsg), 0, emsg);
+ fprintf(stderr, "Error compiling GLSL: %s\n", emsg);
+ fprintf(stderr, "Version: %s\n", version);
+ fprintf(stderr, "Defines: %s\n", define);
+ fprintf(stderr, "Source: %s\n", source);
+ return 0;
+ }
+
+ return shader;
+}
+
+GLuint linkProgram(const char* version, const char* define) {
+ GLuint vertexShader =
+ compileShader(GL_VERTEX_SHADER, version, define,
+ datatoc_gpu_shader_opensubdiv_vertex_glsl);
+ if (vertexShader == 0) {
+ return 0;
+ }
+ GLuint geometryShader =
+ compileShader(GL_GEOMETRY_SHADER, version, define,
+ datatoc_gpu_shader_opensubdiv_geometry_glsl);
+ if (geometryShader == 0) {
+ return 0;
+ }
+ GLuint fragmentShader =
+ compileShader(GL_FRAGMENT_SHADER, version, define,
+ datatoc_gpu_shader_opensubdiv_fragment_glsl);
+ if (fragmentShader == 0) {
+ return 0;
+ }
+
+ GLuint program = glCreateProgram();
+
+ glAttachShader(program, vertexShader);
+ glAttachShader(program, geometryShader);
+ glAttachShader(program, fragmentShader);
+
+ glBindAttribLocation(program, 0, "position");
+ glBindAttribLocation(program, 1, "normal");
+
+ glLinkProgram(program);
+
+ glDeleteShader(vertexShader);
+ glDeleteShader(geometryShader);
+ glDeleteShader(fragmentShader);
+
+ GLint status;
+ glGetProgramiv(program, GL_LINK_STATUS, &status);
+ if (status == GL_FALSE) {
+ GLchar emsg[1024];
+ glGetProgramInfoLog(program, sizeof(emsg), 0, emsg);
+ fprintf(stderr, "Error linking GLSL program : %s\n", emsg);
+ fprintf(stderr, "Defines: %s\n", define);
+ glDeleteProgram(program);
+ return 0;
+ }
+
+ glUniformBlockBinding(program, glGetUniformBlockIndex(program, "Lighting"),
+ 0);
+
+ if (GLEW_VERSION_4_1) {
+ glProgramUniform1i(
+ program, glGetUniformLocation(program, "texture_buffer"), 0);
+ glProgramUniform1i(
+ program, glGetUniformLocation(program, "FVarDataOffsetBuffer"), 30);
+ glProgramUniform1i(
+ program, glGetUniformLocation(program, "FVarDataBuffer"), 31);
+ } else {
+ glUseProgram(program);
+ glUniform1i(glGetUniformLocation(program, "texture_buffer"), 0);
+ glUniform1i(glGetUniformLocation(program, "FVarDataOffsetBuffer"), 30);
+ glUniform1i(glGetUniformLocation(program, "FVarDataBuffer"), 31);
+ glUseProgram(0);
+ }
+
+ return program;
+}
+
+void bindProgram(OpenSubdiv_GLMesh* gl_mesh, int program) {
+ glUseProgram(program);
+ // Matrices
+ glUniformMatrix4fv(glGetUniformLocation(program, "modelViewMatrix"),
+ 1,
+ false,
+ g_transform.model_view_matrix);
+ glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"),
+ 1,
+ false,
+ g_transform.projection_matrix);
+ glUniformMatrix3fv(glGetUniformLocation(program, "normalMatrix"),
+ 1,
+ false,
+ g_transform.normal_matrix);
+ // Lighting.
+ glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub);
+ glBufferSubData(
+ GL_UNIFORM_BUFFER, 0, sizeof(g_lighting_data), &g_lighting_data);
+ glBindBuffer(GL_UNIFORM_BUFFER, 0);
+ glBindBufferBase(GL_UNIFORM_BUFFER, 0, g_lighting_ub);
+ // Color.
+ {
+ // TODO(sergey): Stop using glGetMaterial.
+ float color[4];
+ glGetMaterialfv(GL_FRONT, GL_DIFFUSE, color);
+ glUniform4fv(glGetUniformLocation(program, "diffuse"), 1, color);
+ glGetMaterialfv(GL_FRONT, GL_SPECULAR, color);
+ glUniform4fv(glGetUniformLocation(program, "specular"), 1, color);
+ glGetMaterialfv(GL_FRONT, GL_SHININESS, color);
+ glUniform1f(glGetUniformLocation(program, "shininess"), color[0]);
+ }
+ // Face-vertex data.
+ opensubdiv_capi::GLMeshFVarData* fvar_data = gl_mesh->internal->fvar_data;
+ if (fvar_data != NULL) {
+ if (fvar_data->texture_buffer) {
+ glActiveTexture(GL_TEXTURE31);
+ glBindTexture(GL_TEXTURE_BUFFER, fvar_data->texture_buffer);
+ glActiveTexture(GL_TEXTURE0);
+ }
+ if (fvar_data->offset_buffer) {
+ glActiveTexture(GL_TEXTURE30);
+ glBindTexture(GL_TEXTURE_BUFFER, fvar_data->offset_buffer);
+ glActiveTexture(GL_TEXTURE0);
+ }
+ glUniform1i(glGetUniformLocation(program, "osd_fvar_count"),
+ fvar_data->fvar_width);
+ if (fvar_data->channel_offsets.size() > 0 && g_active_uv_index >= 0) {
+ glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"),
+ fvar_data->channel_offsets[g_active_uv_index]);
+ } else {
+ glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
+ }
+ } else {
+ glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0);
+ glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
+ }
+}
+
+} // namespace
+
+bool openSubdiv_initGLMeshDrawingResources(void) {
+ static bool need_init = true;
+ static bool init_success = false;
+ if (!need_init) {
+ return init_success;
+ }
+ // TODO(sergey): Update OSD drawing to OpenGL 3.3 core,
+ // then remove following line.
+ return false;
+ const char* version = "";
+ if (GLEW_VERSION_3_2) {
+ version = "#version 150 compatibility\n";
+ } else if (GLEW_VERSION_3_1) {
+ version = "#version 140\n"
+ "#extension GL_ARB_compatibility: enable\n";
+ } else {
+ version = "#version 130\n";
+ // Minimum supported for OpenSubdiv.
+ }
+ g_flat_fill_solid_program = linkProgram(version,
+ "#define USE_COLOR_MATERIAL\n"
+ "#define USE_LIGHTING\n"
+ "#define FLAT_SHADING\n");
+ g_flat_fill_texture2d_program = linkProgram(version,
+ "#define USE_COLOR_MATERIAL\n"
+ "#define USE_LIGHTING\n"
+ "#define USE_TEXTURE_2D\n"
+ "#define FLAT_SHADING\n");
+ g_smooth_fill_solid_program = linkProgram(version,
+ "#define USE_COLOR_MATERIAL\n"
+ "#define USE_LIGHTING\n"
+ "#define SMOOTH_SHADING\n");
+ g_smooth_fill_texture2d_program = linkProgram(version,
+ "#define USE_COLOR_MATERIAL\n"
+ "#define USE_LIGHTING\n"
+ "#define USE_TEXTURE_2D\n"
+ "#define SMOOTH_SHADING\n");
+
+ g_flat_fill_solid_shadeless_program =
+ linkProgram(version,
+ "#define USE_COLOR_MATERIAL\n"
+ "#define FLAT_SHADING\n");
+ g_flat_fill_texture2d_shadeless_program =
+ linkProgram(version,
+ "#define USE_COLOR_MATERIAL\n"
+ "#define USE_TEXTURE_2D\n"
+ "#define FLAT_SHADING\n");
+ g_smooth_fill_solid_shadeless_program =
+ linkProgram(version,
+ "#define USE_COLOR_MATERIAL\n"
+ "#define SMOOTH_SHADING\n");
+ g_smooth_fill_texture2d_shadeless_program =
+ linkProgram(version,
+ "#define USE_COLOR_MATERIAL\n"
+ "#define USE_TEXTURE_2D\n"
+ "#define SMOOTH_SHADING\n");
+ g_wireframe_program = linkProgram(version, "#define WIREFRAME\n");
+
+ glGenBuffers(1, &g_lighting_ub);
+ glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub);
+ glBufferData(GL_UNIFORM_BUFFER,
+ sizeof(g_lighting_data),
+ NULL,
+ GL_STATIC_DRAW);
+ need_init = false;
+ init_success = g_flat_fill_solid_program != 0 &&
+ g_flat_fill_texture2d_program != 0 &&
+ g_smooth_fill_solid_program != 0 &&
+ g_smooth_fill_texture2d_program != 0 && g_wireframe_program;
+ return init_success;
+}
+
+void openSubdiv_deinitGLMeshDrawingResources(void) {
+ if (g_lighting_ub != 0) {
+ glDeleteBuffers(1, &g_lighting_ub);
+ }
+#define SAFE_DELETE_PROGRAM(program) \
+ do { \
+ if (program) { \
+ glDeleteProgram(program); \
+ } \
+ } while (false)
+
+ SAFE_DELETE_PROGRAM(g_flat_fill_solid_program);
+ SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_program);
+ SAFE_DELETE_PROGRAM(g_smooth_fill_solid_program);
+ SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_program);
+ SAFE_DELETE_PROGRAM(g_flat_fill_solid_shadeless_program);
+ SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_shadeless_program);
+ SAFE_DELETE_PROGRAM(g_smooth_fill_solid_shadeless_program);
+ SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_shadeless_program);
+ SAFE_DELETE_PROGRAM(g_wireframe_program);
+
+#undef SAFE_DELETE_PROGRAM
+}
+
+namespace opensubdiv_capi {
+
+namespace {
+
+GLuint prepare_patchDraw(OpenSubdiv_GLMesh* gl_mesh, bool fill_quads) {
+ GLint program = 0;
+ if (!g_use_osd_glsl) {
+ glGetIntegerv(GL_CURRENT_PROGRAM, &program);
+ if (program) {
+ GLint model;
+ glGetIntegerv(GL_SHADE_MODEL, &model);
+ GLint location = glGetUniformLocation(program, "osd_flat_shading");
+ if (location != -1) {
+ glUniform1i(location, model == GL_FLAT);
+ }
+ // Face-vertex data.
+ opensubdiv_capi::GLMeshFVarData* fvar_data = gl_mesh->internal->fvar_data;
+ if (fvar_data != NULL) {
+ if (fvar_data->texture_buffer) {
+ glActiveTexture(GL_TEXTURE31);
+ glBindTexture(GL_TEXTURE_BUFFER, fvar_data->texture_buffer);
+ glActiveTexture(GL_TEXTURE0);
+ }
+ if (fvar_data->offset_buffer) {
+ glActiveTexture(GL_TEXTURE30);
+ glBindTexture(GL_TEXTURE_BUFFER, fvar_data->offset_buffer);
+ glActiveTexture(GL_TEXTURE0);
+ }
+ GLint location = glGetUniformLocation(program, "osd_fvar_count");
+ if (location != -1) {
+ glUniform1i(location, fvar_data->fvar_width);
+ }
+ location = glGetUniformLocation(program, "osd_active_uv_offset");
+ if (location != -1) {
+ if (fvar_data->channel_offsets.size() > 0 && g_active_uv_index >= 0) {
+ glUniform1i(location,
+ fvar_data->channel_offsets[g_active_uv_index]);
+ } else {
+ glUniform1i(location, 0);
+ }
+ }
+ } else {
+ glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0);
+ glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
+ }
+ }
+ return program;
+ }
+ if (fill_quads) {
+ int model;
+ GLboolean use_texture_2d;
+ glGetIntegerv(GL_SHADE_MODEL, &model);
+ glGetBooleanv(GL_TEXTURE_2D, &use_texture_2d);
+ if (model == GL_FLAT) {
+ if (use_texture_2d) {
+ program = g_flat_fill_texture2d_program;
+ } else {
+ program = g_flat_fill_solid_program;
+ }
+ } else {
+ if (use_texture_2d) {
+ program = g_smooth_fill_texture2d_program;
+ } else {
+ program = g_smooth_fill_solid_program;
+ }
+ }
+
+ } else {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ program = g_wireframe_program;
+ }
+ bindProgram(gl_mesh, program);
+ return program;
+}
+
+void perform_drawElements(GLuint program,
+ int patch_index,
+ int num_elements,
+ int start_element) {
+ if (program) {
+ glUniform1i(glGetUniformLocation(program, "PrimitiveIdBase"), patch_index);
+ }
+ glDrawElements(GL_LINES_ADJACENCY,
+ num_elements,
+ GL_UNSIGNED_INT,
+ reinterpret_cast<void*>(start_element * sizeof(unsigned int)));
+}
+
+void finishPatchDraw(bool fill_quads) {
+ // TODO(sergey): Some of the stuff could be done once after the whole
+ // mesh is displayed.
+ /// Restore state.
+ if (!fill_quads) {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ }
+ glBindVertexArray(0);
+ if (g_use_osd_glsl) {
+ // TODO(sergey): Store previously used program and roll back to it?
+ glUseProgram(0);
+ }
+}
+
+void drawPartitionPatchesRange(GLMeshInterface* mesh,
+ GLuint program,
+ int start_patch,
+ int num_patches) {
+ int traversed_patches = 0, num_remained_patches = num_patches;
+ const OpenSubdiv::Osd::PatchArrayVector &patches =
+ mesh->GetPatchTable()->GetPatchArrays();
+ for (int i = 0; i < patches.size(); ++i) {
+ const OpenSubdiv::Osd::PatchArray &patch = patches[i];
+ OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor();
+ OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType();
+ if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) {
+ const int num_block_patches = patch.GetNumPatches();
+ if (start_patch >= traversed_patches &&
+ start_patch < traversed_patches + num_block_patches) {
+ const int num_control_verts = desc.GetNumControlVertices();
+ const int start_draw_patch = start_patch - traversed_patches;
+ const int num_draw_patches = std::min(
+ num_remained_patches, num_block_patches - start_draw_patch);
+ perform_drawElements(
+ program, i + start_draw_patch, num_draw_patches * num_control_verts,
+ patch.GetIndexBase() + start_draw_patch * num_control_verts);
+ num_remained_patches -= num_draw_patches;
+ }
+ if (num_remained_patches == 0) {
+ break;
+ }
+ traversed_patches += num_block_patches;
+ }
+ }
+}
+
+static void drawAllPatches(GLMeshInterface* mesh, GLuint program) {
+ const OpenSubdiv::Osd::PatchArrayVector &patches =
+ mesh->GetPatchTable()->GetPatchArrays();
+ for (int i = 0; i < patches.size(); ++i) {
+ const OpenSubdiv::Osd::PatchArray &patch = patches[i];
+ OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor();
+ OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType();
+
+ if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) {
+ perform_drawElements(program, i,
+ patch.GetNumPatches() * desc.GetNumControlVertices(),
+ patch.GetIndexBase());
+ }
+ }
+}
+
+} // namespace
+
+void GLMeshDisplayPrepare(struct OpenSubdiv_GLMesh* /*gl_mesh*/,
+ const bool use_osd_glsl,
+ const int active_uv_index) {
+ g_active_uv_index = active_uv_index;
+ g_use_osd_glsl = (use_osd_glsl != 0);
+ // Update transformation matrices.
+ glGetFloatv(GL_PROJECTION_MATRIX, g_transform.projection_matrix);
+ glGetFloatv(GL_MODELVIEW_MATRIX, g_transform.model_view_matrix);
+ copy_m3_m4((float(*)[3])g_transform.normal_matrix,
+ (float(*)[4])g_transform.model_view_matrix);
+ invert_m3((float(*)[3])g_transform.normal_matrix);
+ transpose_m3((float(*)[3])g_transform.normal_matrix);
+ // Update OpenGL lights positions, colors etc.
+ g_lighting_data.num_enabled = 0;
+ for (int i = 0; i < MAX_LIGHTS; ++i) {
+ GLboolean enabled;
+ glGetBooleanv(GL_LIGHT0 + i, &enabled);
+ if (enabled) {
+ g_lighting_data.num_enabled++;
+ }
+ // TODO(sergey): Stop using glGetLight.
+ glGetLightfv(GL_LIGHT0 + i, GL_POSITION,
+ g_lighting_data.lights[i].position);
+ glGetLightfv(GL_LIGHT0 + i, GL_AMBIENT, g_lighting_data.lights[i].ambient);
+ glGetLightfv(GL_LIGHT0 + i, GL_DIFFUSE, g_lighting_data.lights[i].diffuse);
+ glGetLightfv(GL_LIGHT0 + i, GL_SPECULAR,
+ g_lighting_data.lights[i].specular);
+ glGetLightfv(GL_LIGHT0 + i, GL_SPOT_DIRECTION,
+ g_lighting_data.lights[i].spot_direction);
+#ifdef SUPPORT_COLOR_MATERIAL
+ glGetLightfv(GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION,
+ &g_lighting_data.lights[i].constant_attenuation);
+ glGetLightfv(GL_LIGHT0 + i, GL_LINEAR_ATTENUATION,
+ &g_lighting_data.lights[i].linear_attenuation);
+ glGetLightfv(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION,
+ &g_lighting_data.lights[i].quadratic_attenuation);
+ glGetLightfv(GL_LIGHT0 + i, GL_SPOT_CUTOFF,
+ &g_lighting_data.lights[i].spot_cutoff);
+ glGetLightfv(GL_LIGHT0 + i, GL_SPOT_EXPONENT,
+ &g_lighting_data.lights[i].spot_exponent);
+ g_lighting_data.lights[i].spot_cos_cutoff =
+ cos(g_lighting_data.lights[i].spot_cutoff);
+#endif
+ }
+}
+
+void GLMeshDisplayDrawPatches(OpenSubdiv_GLMesh* gl_mesh,
+ const bool fill_quads,
+ const int start_patch,
+ const int num_patches) {
+ GLMeshInterface* mesh = gl_mesh->internal->mesh_interface;
+ // Make sure all global invariants are initialized.
+ if (!openSubdiv_initGLMeshDrawingResources()) {
+ return;
+ }
+ /// Setup GLSL/OpenGL to draw patches in current context.
+ GLuint program = prepare_patchDraw(gl_mesh, fill_quads != 0);
+ if (start_patch != -1) {
+ drawPartitionPatchesRange(mesh, program, start_patch, num_patches);
+ } else {
+ drawAllPatches(mesh, program);
+ }
+ // Finish patch drawing by restoring all changes to the OpenGL context.
+ finishPatchDraw(fill_quads != 0);
+}
+
+} // namespace opensubdiv_capi
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h
new file mode 100644
index 00000000000..5421b5cf707
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h
@@ -0,0 +1,39 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_GL_MESH_DRAW_H_
+#define OPENSUBDIV_GL_MESH_DRAW_H_
+
+#include <stdint.h> // for bool
+
+struct OpenSubdiv_GLMesh;
+
+namespace opensubdiv_capi {
+
+void GLMeshDisplayPrepare(struct OpenSubdiv_GLMesh* gl_mesh,
+ const bool use_osd_glsl,
+ const int active_uv_index);
+
+void GLMeshDisplayDrawPatches(OpenSubdiv_GLMesh* gl_mesh,
+ const bool fill_quads,
+ const int start_patch,
+ const int num_patches);
+
+} // namespace opensubdiv_capi
+
+#endif // OPENSUBDIV_GL_MESH_DRAW_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc
new file mode 100644
index 00000000000..5c9033c8dd1
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc
@@ -0,0 +1,175 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#include "internal/opensubdiv_gl_mesh_fvar.h"
+
+#include <GL/glew.h>
+#include <opensubdiv/far/primvarRefiner.h>
+
+namespace opensubdiv_capi {
+
+////////////////////////////////////////////////////////////////////////////////
+// GLMeshFVarData
+
+GLMeshFVarData::GLMeshFVarData()
+ : texture_buffer(0),
+ offset_buffer(0) {
+}
+
+GLMeshFVarData::~GLMeshFVarData() {
+ release();
+}
+
+void GLMeshFVarData::release() {
+ if (texture_buffer) {
+ glDeleteTextures(1, &texture_buffer);
+ }
+ if (offset_buffer) {
+ glDeleteTextures(1, &offset_buffer);
+ }
+ texture_buffer = 0;
+ offset_buffer = 0;
+ fvar_width = 0;
+ channel_offsets.clear();
+}
+
+void GLMeshFVarData::create(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv::Far::PatchTable* patch_table,
+ int fvar_width,
+ const float* fvar_src_data) {
+ release();
+ this->fvar_width = fvar_width;
+ /// Expand fvar data to per-patch array.
+ const int max_level = topology_refiner->GetMaxLevel();
+ const int num_channels = patch_table->GetNumFVarChannels();
+ std::vector<float> data;
+ int fvar_data_offset = 0;
+ channel_offsets.resize(num_channels);
+ for (int channel = 0; channel < num_channels; ++channel) {
+ OpenSubdiv::Far::ConstIndexArray indices =
+ patch_table->GetFVarValues(channel);
+ channel_offsets[channel] = data.size();
+ data.reserve(data.size() + indices.size() * fvar_width);
+ for (int fvert = 0; fvert < indices.size(); ++fvert) {
+ int index = indices[fvert] * fvar_width;
+ for (int i = 0; i < fvar_width; ++i) {
+ data.push_back(fvar_src_data[fvar_data_offset + index++]);
+ }
+ }
+ if (topology_refiner->IsUniform()) {
+ const int num_values_max =
+ topology_refiner->GetLevel(max_level).GetNumFVarValues(channel);
+ fvar_data_offset += num_values_max * fvar_width;
+ } else {
+ const int num_values_total =
+ topology_refiner->GetNumFVarValuesTotal(channel);
+ fvar_data_offset += num_values_total * fvar_width;
+ }
+ }
+ GLuint buffer;
+ glGenBuffers(1, &buffer);
+ glBindBuffer(GL_ARRAY_BUFFER, buffer);
+ glBufferData(GL_ARRAY_BUFFER,
+ data.size() * sizeof(float), &data[0],
+ GL_STATIC_DRAW);
+ glGenTextures(1, &texture_buffer);
+ glBindTexture(GL_TEXTURE_BUFFER, texture_buffer);
+ glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, buffer);
+ glDeleteBuffers(1, &buffer);
+ glGenBuffers(1, &buffer);
+ glBindBuffer(GL_ARRAY_BUFFER, buffer);
+ glBufferData(GL_ARRAY_BUFFER,
+ channel_offsets.size() * sizeof(int),
+ &channel_offsets[0],
+ GL_STATIC_DRAW);
+ glGenTextures(1, &offset_buffer);
+ glBindTexture(GL_TEXTURE_BUFFER, offset_buffer);
+ glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer);
+ glBindTexture(GL_TEXTURE_BUFFER, 0);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Helper functions.
+
+struct FVarVertex {
+ float u, v;
+
+ void Clear() {
+ u = v = 0.0f;
+ }
+
+ void AddWithWeight(FVarVertex const& src, float weight) {
+ u += weight * src.u;
+ v += weight * src.v;
+ }
+};
+
+void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner,
+ const std::vector<float>& uvs,
+ std::vector<float>* fvar_data) {
+ const int fvar_width = 2;
+ const int max_level = refiner.GetMaxLevel();
+ size_t fvar_data_offset = 0, values_offset = 0;
+ for (int channel = 0; channel < refiner.GetNumFVarChannels(); ++channel) {
+ const int num_values = refiner.GetLevel(0).GetNumFVarValues(channel) * 2;
+ const int num_values_max =
+ refiner.GetLevel(max_level).GetNumFVarValues(channel);
+ const int num_values_total = refiner.GetNumFVarValuesTotal(channel);
+ if (num_values_total <= 0) {
+ continue;
+ }
+ OpenSubdiv::Far::PrimvarRefiner primvar_refiner(refiner);
+ if (refiner.IsUniform()) {
+ // For uniform we only keep the highest level of refinement.
+ fvar_data->resize(fvar_data->size() + num_values_max * fvar_width);
+ std::vector<FVarVertex> buffer(num_values_total - num_values_max);
+ FVarVertex* src = &buffer[0];
+ memcpy(src, &uvs[values_offset], num_values * sizeof(float));
+ // Defer the last level to treat separately with its alternate
+ // destination.
+ for (int level = 1; level < max_level; ++level) {
+ FVarVertex* dst =
+ src + refiner.GetLevel(level - 1).GetNumFVarValues(channel);
+ primvar_refiner.InterpolateFaceVarying(level, src, dst, channel);
+ src = dst;
+ }
+ FVarVertex* dst =
+ reinterpret_cast<FVarVertex*>(&(*fvar_data)[fvar_data_offset]);
+ primvar_refiner.InterpolateFaceVarying(max_level, src, dst, channel);
+ fvar_data_offset += num_values_max * fvar_width;
+ } else {
+ // For adaptive we keep all levels.
+ fvar_data->resize(fvar_data->size() + num_values_total * fvar_width);
+ FVarVertex* src =
+ reinterpret_cast<FVarVertex*>(&(*fvar_data)[fvar_data_offset]);
+ memcpy(src, &uvs[values_offset], num_values * sizeof(float));
+ for (int level = 1; level <= max_level; ++level) {
+ FVarVertex* dst =
+ src + refiner.GetLevel(level - 1).GetNumFVarValues(channel);
+ primvar_refiner.InterpolateFaceVarying(level, src, dst, channel);
+ src = dst;
+ }
+ fvar_data_offset += num_values_total * fvar_width;
+ }
+ values_offset += num_values;
+ }
+}
+
+} // namespace opensubdiv_capi
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h
new file mode 100644
index 00000000000..039a94eaf86
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h
@@ -0,0 +1,57 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_GL_MESH_FVAR_H_
+#define OPENSUBDIV_GL_MESH_FVAR_H_
+
+// NOTE: This is a [sane(er)] port of previous ground work for getting UVs to
+// work. Still needs a lot of work to make it easy, correct and have proper
+// data ownership.
+
+#include <opensubdiv/far/topologyRefiner.h>
+#include <opensubdiv/far/patchTable.h>
+
+#include <vector>
+
+namespace opensubdiv_capi {
+
+// The buffer which holds GPU resources for face-varying elements.
+class GLMeshFVarData {
+ public:
+ GLMeshFVarData();
+ ~GLMeshFVarData();
+
+ void release();
+ void create(const OpenSubdiv::Far::TopologyRefiner* refiner,
+ const OpenSubdiv::Far::PatchTable* patch_table,
+ int fvar_width,
+ const float* fvar_src_data);
+
+ unsigned int texture_buffer;
+ unsigned int offset_buffer;
+ std::vector<int> channel_offsets;
+ int fvar_width;
+};
+
+void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner,
+ const std::vector<float>& uvs,
+ std::vector<float>* fvar_data);
+
+} // namespace opensubdiv_capi
+
+#endif // OPENSUBDIV_GL_MESH_FVAR_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc
new file mode 100644
index 00000000000..3abba9cf8f8
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc
@@ -0,0 +1,32 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#include "internal/opensubdiv_gl_mesh_internal.h"
+
+#include "internal/opensubdiv_gl_mesh_fvar.h"
+
+OpenSubdiv_GLMeshInternal::OpenSubdiv_GLMeshInternal()
+ : evaluator_type(OPENSUBDIV_EVALUATOR_CPU),
+ mesh_interface(NULL),
+ fvar_data(NULL) {
+}
+
+OpenSubdiv_GLMeshInternal::~OpenSubdiv_GLMeshInternal() {
+ delete mesh_interface;
+ delete fvar_data;
+}
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h b/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h
new file mode 100644
index 00000000000..7796b450e69
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h
@@ -0,0 +1,43 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_GL_MESH_INTERNAL_H_
+#define OPENSUBDIV_GL_MESH_INTERNAL_H_
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <opensubdiv/osd/glMesh.h>
+
+#include "opensubdiv_capi_type.h"
+
+namespace opensubdiv_capi {
+class GLMeshFVarData;
+} // namespace opensubdiv_capi
+
+typedef struct OpenSubdiv_GLMeshInternal {
+ OpenSubdiv_GLMeshInternal();
+ ~OpenSubdiv_GLMeshInternal();
+
+ eOpenSubdivEvaluator evaluator_type;
+ OpenSubdiv::Osd::GLMeshInterface* mesh_interface;
+ opensubdiv_capi::GLMeshFVarData* fvar_data;
+} OpenSubdiv_GLMeshInternal;
+
+#endif // OPENSUBDIV_GL_MESH_INTERNAL_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_internal.h b/intern/opensubdiv/internal/opensubdiv_internal.h
new file mode 100644
index 00000000000..b9d196bbe9e
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_internal.h
@@ -0,0 +1,38 @@
+// Copyright 2015 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_INTERNAL_H_
+#define OPENSUBDIV_INTERNAL_H_
+
+// Perform full topology validation when exporting it to OpenSubdiv.
+#ifdef NDEBUG
+// Never do for release builds.
+# undef OPENSUBDIV_VALIDATE_TOPOLOGY
+#else
+// TODO(sergey): Always disabled for now, the check doesn't handle multiple
+// non-manifolds from the OpenSubdiv side currently.
+// # undef OPENSUBDIV_VALIDATE_TOPOLOGY
+# define OPENSUBDIV_VALIDATE_TOPOLOGY
+#endif
+
+// Currently OpenSubdiv expects topology to be oriented, but sometimes it's
+// handy to disable orientation code to check whether it causes some weird
+// issues by using pre-oriented model.
+#define OPENSUBDIV_ORIENT_TOPOLOGY
+
+#endif // OPENSUBDIV_INTERNAL_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc
new file mode 100644
index 00000000000..93f6fdc14a1
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc
@@ -0,0 +1,367 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#include "opensubdiv_topology_refiner_capi.h"
+
+#include <vector>
+
+#include "MEM_guardedalloc.h"
+#include "internal/opensubdiv_converter_factory.h"
+#include "internal/opensubdiv_converter_internal.h"
+#include "internal/opensubdiv_internal.h"
+#include "internal/opensubdiv_topology_refiner_internal.h"
+
+namespace {
+
+const OpenSubdiv::Far::TopologyRefiner* getOSDTopologyRefiner(
+ const OpenSubdiv_TopologyRefiner* topology_refiner) {
+ return topology_refiner->internal->osd_topology_refiner;
+}
+
+const OpenSubdiv::Far::TopologyLevel* getOSDTopologyBaseLevel(
+ const OpenSubdiv_TopologyRefiner* topology_refiner) {
+ return &getOSDTopologyRefiner(topology_refiner)->GetLevel(0);
+}
+
+int getSubdivisionLevel(const OpenSubdiv_TopologyRefiner* topology_refiner) {
+ return topology_refiner->internal->settings.level;
+}
+
+bool getIsAdaptive(const OpenSubdiv_TopologyRefiner* topology_refiner) {
+ return topology_refiner->internal->settings.is_adaptive;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Query basic topology information from base level.
+
+int getNumVertices(const OpenSubdiv_TopologyRefiner* topology_refiner) {
+ return getOSDTopologyBaseLevel(topology_refiner)->GetNumVertices();
+}
+
+int getNumEdges(const OpenSubdiv_TopologyRefiner* topology_refiner) {
+ return getOSDTopologyBaseLevel(topology_refiner)->GetNumEdges();
+}
+
+int getNumFaces(const OpenSubdiv_TopologyRefiner* topology_refiner) {
+ return getOSDTopologyBaseLevel(topology_refiner)->GetNumFaces();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// PTex face geometry queries.
+
+int getNumFaceVertices(const OpenSubdiv_TopologyRefiner* topology_refiner,
+ const int face_index) {
+ const OpenSubdiv::Far::TopologyLevel* base_level =
+ getOSDTopologyBaseLevel(topology_refiner);
+ return base_level->GetFaceVertices(face_index).size();
+}
+
+int getNumFacePtexFaces(const OpenSubdiv_TopologyRefiner* topology_refiner,
+ const int face_index) {
+ const int num_face_vertices =
+ topology_refiner->getNumFaceVertices(topology_refiner, face_index);
+ if (num_face_vertices == 4) {
+ return 1;
+ } else {
+ return num_face_vertices;
+ }
+}
+
+int getNumPtexFaces(const OpenSubdiv_TopologyRefiner* topology_refiner) {
+ const int num_faces = topology_refiner->getNumFaces(topology_refiner);
+ int num_ptex_faces = 0;
+ for (int face_index = 0; face_index < num_faces; ++face_index) {
+ num_ptex_faces +=
+ topology_refiner->getNumFacePtexFaces(topology_refiner, face_index);
+ }
+ return num_ptex_faces;
+}
+
+void fillFacePtexIndexOffset(const OpenSubdiv_TopologyRefiner* topology_refiner,
+ int* face_ptex_index_offset) {
+ const int num_faces = topology_refiner->getNumFaces(topology_refiner);
+ int num_ptex_faces = 0;
+ for (int face_index = 0; face_index < num_faces; ++face_index) {
+ face_ptex_index_offset[face_index] = num_ptex_faces;
+ num_ptex_faces +=
+ topology_refiner->getNumFacePtexFaces(topology_refiner, face_index);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Face-varying data.
+
+int getNumFVarChannels(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner) {
+ const OpenSubdiv::Far::TopologyLevel* base_level =
+ getOSDTopologyBaseLevel(topology_refiner);
+ return base_level->GetNumFVarChannels();
+}
+
+OpenSubdiv_FVarLinearInterpolation getFVarLinearInterpolation(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner) {
+ return opensubdiv_capi::getCAPIFVarLinearInterpolationFromOSD(
+ getOSDTopologyRefiner(topology_refiner)->GetFVarLinearInterpolation());
+}
+
+int getNumFVarValues(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner,
+ const int channel) {
+ const OpenSubdiv::Far::TopologyLevel* base_level =
+ getOSDTopologyBaseLevel(topology_refiner);
+ return base_level->GetNumFVarValues(channel);
+}
+
+const int* getFaceFVarValueIndices(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner,
+ const int face_index,
+ const int channel) {
+ const OpenSubdiv::Far::TopologyLevel* base_level =
+ getOSDTopologyBaseLevel(topology_refiner);
+ return &base_level->GetFaceFVarValues(face_index, channel)[0];
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Internal helpers.
+
+void assignFunctionPointers(OpenSubdiv_TopologyRefiner* topology_refiner) {
+ topology_refiner->getSubdivisionLevel = getSubdivisionLevel;
+ topology_refiner->getIsAdaptive = getIsAdaptive;
+ // Basic topology information.
+ topology_refiner->getNumVertices = getNumVertices;
+ topology_refiner->getNumEdges = getNumEdges;
+ topology_refiner->getNumFaces = getNumFaces;
+ topology_refiner->getNumFaceVertices = getNumFaceVertices;
+ // PTex face geometry.
+ topology_refiner->getNumFacePtexFaces = getNumFacePtexFaces;
+ topology_refiner->getNumPtexFaces = getNumPtexFaces;
+ topology_refiner->fillFacePtexIndexOffset = fillFacePtexIndexOffset;
+ // Face-varying data.
+ topology_refiner->getNumFVarChannels = getNumFVarChannels;
+ topology_refiner->getFVarLinearInterpolation = getFVarLinearInterpolation;
+ topology_refiner->getNumFVarValues = getNumFVarValues;
+ topology_refiner->getFaceFVarValueIndices = getFaceFVarValueIndices;
+}
+
+OpenSubdiv_TopologyRefiner* allocateTopologyRefiner() {
+ OpenSubdiv_TopologyRefiner* topology_refiner =
+ OBJECT_GUARDED_NEW(OpenSubdiv_TopologyRefiner);
+ topology_refiner->internal =
+ OBJECT_GUARDED_NEW(OpenSubdiv_TopologyRefinerInternal);
+ assignFunctionPointers(topology_refiner);
+ return topology_refiner;
+}
+
+} // namespace
+
+OpenSubdiv_TopologyRefiner* openSubdiv_createTopologyRefinerFromConverter(
+ OpenSubdiv_Converter* converter,
+ const OpenSubdiv_TopologyRefinerSettings* settings) {
+ OpenSubdiv::Far::TopologyRefiner* osd_topology_refiner =
+ opensubdiv_capi::createOSDTopologyRefinerFromConverter(converter);
+ if (osd_topology_refiner == NULL) {
+ // Happens on empty or bad topology.
+ return NULL;
+ }
+ OpenSubdiv_TopologyRefiner* topology_refiner = allocateTopologyRefiner();
+ topology_refiner->internal->osd_topology_refiner = osd_topology_refiner;
+ // Store setting which we want to keep track of and which can not be stored
+ // in OpenSubdiv's descriptor yet.
+ topology_refiner->internal->settings = *settings;
+ return topology_refiner;
+}
+
+void openSubdiv_deleteTopologyRefiner(
+ OpenSubdiv_TopologyRefiner* topology_refiner) {
+ OBJECT_GUARDED_DELETE(topology_refiner->internal,
+ OpenSubdiv_TopologyRefinerInternal);
+ OBJECT_GUARDED_DELETE(topology_refiner, OpenSubdiv_TopologyRefiner);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Comparison with converter.
+
+namespace {
+
+///////////////////////////////////////////////////////////
+// Quick preliminary checks.
+
+bool checkSchemeTypeMatches(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ const OpenSubdiv::Sdc::SchemeType converter_scheme_type =
+ opensubdiv_capi::getSchemeTypeFromCAPI(
+ converter->getSchemeType(converter));
+ return (converter_scheme_type == topology_refiner->GetSchemeType());
+}
+
+bool checkOptionsMatches(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ typedef OpenSubdiv::Sdc::Options Options;
+ const Options options = topology_refiner->GetSchemeOptions();
+ const Options::FVarLinearInterpolation fvar_interpolation =
+ options.GetFVarLinearInterpolation();
+ const Options::FVarLinearInterpolation converter_fvar_interpolation =
+ opensubdiv_capi::getFVarLinearInterpolationFromCAPI(
+ converter->getFVarLinearInterpolation(converter));
+ if (fvar_interpolation != converter_fvar_interpolation) {
+ return false;
+ }
+ return true;
+}
+
+bool checkGeometryCoountersMatches(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ using OpenSubdiv::Far::TopologyLevel;
+ const TopologyLevel& base_level = topology_refiner->GetLevel(0);
+ return (
+ (converter->getNumVertices(converter) == base_level.GetNumVertices()) &&
+ (converter->getNumEdges(converter) == base_level.GetNumEdges()) &&
+ (converter->getNumFaces(converter) == base_level.GetNumFaces()));
+}
+
+bool checkPreliminaryMatches(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ return checkSchemeTypeMatches(topology_refiner, converter) &&
+ checkOptionsMatches(topology_refiner, converter) &&
+ checkGeometryCoountersMatches(topology_refiner, converter);
+}
+
+///////////////////////////////////////////////////////////
+// Geometry comparison.
+
+bool checkGeometryEdgesMatch(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ using OpenSubdiv::Far::ConstIndexArray;
+ using OpenSubdiv::Far::TopologyLevel;
+ const TopologyLevel& base_level = topology_refiner->GetLevel(0);
+ const int num_edges = base_level.GetNumEdges();
+ for (int edge_index = 0; edge_index < num_edges; ++edge_index) {
+ const ConstIndexArray& edge_vertices =
+ base_level.GetEdgeVertices(edge_index);
+ int conv_edge_vertices[2];
+ converter->getEdgeVertices(converter, edge_index, conv_edge_vertices);
+ if (conv_edge_vertices[0] != edge_vertices[0] ||
+ conv_edge_vertices[1] != edge_vertices[1]) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool checkGeometryFacesMatch(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ using OpenSubdiv::Far::ConstIndexArray;
+ using OpenSubdiv::Far::TopologyLevel;
+ const TopologyLevel& base_level = topology_refiner->GetLevel(0);
+ const int num_faces = base_level.GetNumFaces();
+ // TODO(sergey): Consider using data structure which keeps handful of
+ // elements on stack before doing heep allocation.
+ std::vector<int> conv_face_vertices;
+ for (int face_index = 0; face_index < num_faces; ++face_index) {
+ const ConstIndexArray& face_vertices =
+ base_level.GetFaceVertices(face_index);
+ const int num_face_vertices = face_vertices.size();
+ if (num_face_vertices !=
+ converter->getNumFaceVertices(converter, face_index)) {
+ return false;
+ }
+ conv_face_vertices.resize(num_face_vertices);
+ converter->getFaceVertices(converter, face_index, &conv_face_vertices[0]);
+ // Check face-vertex indices in the direct order (assuming topology
+ // orientation is disabled or did not flip order of the face-vertices).
+ //
+ // TODO(sergey): Can we simply memcmp() with OpenSubdiv's array?
+ bool direct_match = true;
+ for (int face_vertex_index = 0; face_vertex_index < num_face_vertices;
+ ++face_vertex_index) {
+ if (conv_face_vertices[face_vertex_index] !=
+ face_vertices[face_vertex_index]) {
+ direct_match = false;
+ break;
+ }
+ }
+ if (!direct_match) {
+// If face didn't match in direct direction we also test if it matches in
+// reversed direction. This is because conversion might reverse loops to
+// make normals consistent.
+#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
+ for (int face_vertex_index = 0; face_vertex_index < num_face_vertices;
+ ++face_vertex_index) {
+ if (conv_face_vertices[face_vertex_index] !=
+ face_vertices[num_face_vertices - face_vertex_index - 1]) {
+ return false;
+ }
+ }
+#endif
+ return false;
+ }
+ }
+ return true;
+}
+
+bool checkGeometryMatches(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ return checkGeometryEdgesMatch(topology_refiner, converter) &&
+ checkGeometryFacesMatch(topology_refiner, converter);
+}
+
+///////////////////////////////////////////////////////////
+// Compare attributes which affects on topology
+
+bool checkEdgeSharpnessMatch(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ using OpenSubdiv::Far::ConstIndexArray;
+ using OpenSubdiv::Far::TopologyLevel;
+ const TopologyLevel& base_level = topology_refiner->GetLevel(0);
+ const int num_edges = base_level.GetNumEdges();
+ for (int edge_index = 0; edge_index < num_edges; ++edge_index) {
+ const float sharpness = base_level.GetEdgeSharpness(edge_index);
+ const float conv_sharpness =
+ opensubdiv_capi::getCompatibleEdgeSharpness(converter, edge_index);
+ if (sharpness != conv_sharpness) {
+ return false;
+ }
+ }
+ return false;
+}
+
+bool checkTopologyAttributesMatch(
+ const OpenSubdiv::Far::TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ return checkEdgeSharpnessMatch(topology_refiner, converter);
+}
+
+} // namespace
+
+bool openSubdiv_topologyRefinerCompareWithConverter(
+ const OpenSubdiv_TopologyRefiner* topology_refiner,
+ const OpenSubdiv_Converter* converter) {
+ const OpenSubdiv::Far::TopologyRefiner* refiner =
+ getOSDTopologyRefiner(topology_refiner);
+ return (checkPreliminaryMatches(refiner, converter) &&
+ checkGeometryMatches(refiner, converter) &&
+ checkTopologyAttributesMatch(refiner, converter));
+}
diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.cc b/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.cc
new file mode 100644
index 00000000000..4636679761f
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.cc
@@ -0,0 +1,26 @@
+// Copyright 2016 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#include "internal/opensubdiv_topology_refiner_internal.h"
+
+OpenSubdiv_TopologyRefinerInternal::OpenSubdiv_TopologyRefinerInternal()
+ : osd_topology_refiner(NULL) {}
+
+OpenSubdiv_TopologyRefinerInternal::~OpenSubdiv_TopologyRefinerInternal() {
+ delete osd_topology_refiner;
+}
diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.h b/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.h
new file mode 100644
index 00000000000..f7ca6a7ad5e
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.h
@@ -0,0 +1,47 @@
+// Copyright 2016 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_TOPOLOGY_REFINER_INTERNAL_H_
+#define OPENSUBDIV_TOPOLOGY_REFINER_INTERNAL_H_
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+#include <opensubdiv/far/topologyRefiner.h>
+
+#include "opensubdiv_topology_refiner_capi.h"
+
+struct OpenSubdiv_TopologyRefinerInternal {
+ public:
+ OpenSubdiv_TopologyRefinerInternal();
+ ~OpenSubdiv_TopologyRefinerInternal();
+
+ OpenSubdiv::Far::TopologyRefiner* osd_topology_refiner;
+
+ // Subdivision settingsa this refiner is created for.
+ //
+ // We store it here since OpenSubdiv's refiner will only know about level and
+ // "adaptivity" after performing actual "refine" step.
+ //
+ // Ideally, we would also support refining topology without re-importing it
+ // from external world, but that is for later.
+ OpenSubdiv_TopologyRefinerSettings settings;
+};
+
+#endif // OPENSUBDIV_TOPOLOGY_REFINER_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_util.cc b/intern/opensubdiv/internal/opensubdiv_util.cc
new file mode 100644
index 00000000000..87bfce2116c
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_util.cc
@@ -0,0 +1,61 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+// Contributor(s): Brecht van Lommel
+
+#include "internal/opensubdiv_util.h"
+
+#include <GL/glew.h>
+#include <cstring>
+
+#ifdef _MSC_VER
+# include <iso646.h>
+#endif
+
+namespace opensubdiv_capi {
+
+void stringSplit(std::vector<std::string>* tokens,
+ const std::string& str,
+ const std::string& separators,
+ bool skip_empty) {
+ size_t token_start = 0, token_length = 0;
+ for (size_t i = 0; i < str.length(); ++i) {
+ const char ch = str[i];
+ if (separators.find(ch) == std::string::npos) {
+ // Append non-separator char to a token.
+ ++token_length;
+ } else {
+ // Append current token to the list (if any).
+ if (token_length > 0 || !skip_empty) {
+ std::string token = str.substr(token_start, token_length);
+ tokens->push_back(token);
+ }
+ // Re-set token pointers,
+ token_start = i + 1;
+ token_length = 0;
+ }
+ }
+ // Append token which might be at the end of the string.
+ if ((token_length != 0) ||
+ (!skip_empty && token_start > 0 &&
+ separators.find(str[token_start-1]) != std::string::npos)) {
+ std::string token = str.substr(token_start, token_length);
+ tokens->push_back(token);
+ }
+}
+
+} // namespace opensubdiv_capi
diff --git a/intern/opensubdiv/internal/opensubdiv_util.h b/intern/opensubdiv/internal/opensubdiv_util.h
new file mode 100644
index 00000000000..6ed19b37e33
--- /dev/null
+++ b/intern/opensubdiv/internal/opensubdiv_util.h
@@ -0,0 +1,39 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+// Contributor(s): Brecht van Lommel
+
+#ifndef OPENSUBDIV_UTIL_H_
+#define OPENSUBDIV_UTIL_H_
+
+#include <vector>
+#include <string>
+
+namespace opensubdiv_capi {
+
+#define STRINGIFY_ARG(x) "" #x
+#define STRINGIFY_APPEND(a, b) "" a #b
+#define STRINGIFY(x) STRINGIFY_APPEND("", x)
+
+void stringSplit(std::vector<std::string>* tokens,
+ const std::string& str,
+ const std::string& separators,
+ bool skip_empty);
+
+} // namespace opensubdiv_capi
+
+#endif // OPENSUBDIV_UTIL_H_
diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc
deleted file mode 100644
index bb865bc0e0f..00000000000
--- a/intern/opensubdiv/opensubdiv_capi.cc
+++ /dev/null
@@ -1,440 +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) 2013 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin.
- * Brecht van Lommel
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "opensubdiv_capi.h"
-
-#ifdef _MSC_VER
-# include "iso646.h"
-#endif
-
-#include <stdlib.h>
-#include <GL/glew.h>
-
-#include <opensubdiv/version.h>
-#include <opensubdiv/osd/glMesh.h>
-
-/* CPU Backend */
-#include <opensubdiv/osd/cpuGLVertexBuffer.h>
-#include <opensubdiv/osd/cpuEvaluator.h>
-
-#ifdef OPENSUBDIV_HAS_OPENMP
-# include <opensubdiv/osd/ompEvaluator.h>
-#endif /* OPENSUBDIV_HAS_OPENMP */
-
-#ifdef OPENSUBDIV_HAS_OPENCL
-# include <opensubdiv/osd/clGLVertexBuffer.h>
-# include <opensubdiv/osd/clEvaluator.h>
-# include "opensubdiv_device_context_opencl.h"
-#endif /* OPENSUBDIV_HAS_OPENCL */
-
-#ifdef OPENSUBDIV_HAS_CUDA
-# include <opensubdiv/osd/cudaGLVertexBuffer.h>
-# include <opensubdiv/osd/cudaEvaluator.h>
-# include "opensubdiv_device_context_cuda.h"
-#endif /* OPENSUBDIV_HAS_CUDA */
-
-#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
-# include <opensubdiv/osd/glXFBEvaluator.h>
-# include <opensubdiv/osd/glVertexBuffer.h>
-#endif /* OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK */
-
-#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
-# include <opensubdiv/osd/glComputeEvaluator.h>
-# include <opensubdiv/osd/glVertexBuffer.h>
-#endif /* OPENSUBDIV_HAS_GLSL_COMPUTE */
-
-#include <opensubdiv/osd/glPatchTable.h>
-#include <opensubdiv/far/stencilTable.h>
-#include <opensubdiv/far/primvarRefiner.h>
-
-#include "opensubdiv_intern.h"
-#include "opensubdiv_topology_refiner.h"
-
-#include "MEM_guardedalloc.h"
-
-#include <string>
-#include <vector>
-
-using std::string;
-using std::vector;
-
-#define STRINGIFY_ARG(x) "" #x
-#define STRINGIFY_APPEND(a, b) "" a #b
-#define STRINGIFY(x) STRINGIFY_APPEND("", x)
-
-/* **************** Types declaration **************** */
-
-using OpenSubdiv::Osd::GLMeshInterface;
-using OpenSubdiv::Osd::Mesh;
-using OpenSubdiv::Osd::MeshBitset;
-using OpenSubdiv::Far::StencilTable;
-using OpenSubdiv::Osd::GLPatchTable;
-
-using OpenSubdiv::Osd::Mesh;
-
-/* CPU backend */
-using OpenSubdiv::Osd::CpuGLVertexBuffer;
-using OpenSubdiv::Osd::CpuEvaluator;
-typedef Mesh<CpuGLVertexBuffer,
- StencilTable,
- CpuEvaluator,
- GLPatchTable> OsdCpuMesh;
-
-#ifdef OPENSUBDIV_HAS_OPENMP
-using OpenSubdiv::Osd::OmpEvaluator;
-typedef Mesh<CpuGLVertexBuffer,
- StencilTable,
- OmpEvaluator,
- GLPatchTable> OsdOmpMesh;
-#endif /* OPENSUBDIV_HAS_OPENMP */
-
-#ifdef OPENSUBDIV_HAS_OPENCL
-using OpenSubdiv::Osd::CLEvaluator;
-using OpenSubdiv::Osd::CLGLVertexBuffer;
-using OpenSubdiv::Osd::CLStencilTable;
-/* TODO(sergey): Use CLDeviceCOntext similar to OSD examples? */
-typedef Mesh<CLGLVertexBuffer,
- CLStencilTable,
- CLEvaluator,
- GLPatchTable,
- CLDeviceContext> OsdCLMesh;
-static CLDeviceContext g_clDeviceContext;
-#endif /* OPENSUBDIV_HAS_OPENCL */
-
-#ifdef OPENSUBDIV_HAS_CUDA
-using OpenSubdiv::Osd::CudaEvaluator;
-using OpenSubdiv::Osd::CudaGLVertexBuffer;
-using OpenSubdiv::Osd::CudaStencilTable;
-typedef Mesh<CudaGLVertexBuffer,
- CudaStencilTable,
- CudaEvaluator,
- GLPatchTable> OsdCudaMesh;
-static CudaDeviceContext g_cudaDeviceContext;
-#endif /* OPENSUBDIV_HAS_CUDA */
-
-#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
-using OpenSubdiv::Osd::GLXFBEvaluator;
-using OpenSubdiv::Osd::GLStencilTableTBO;
-using OpenSubdiv::Osd::GLVertexBuffer;
-typedef Mesh<GLVertexBuffer,
- GLStencilTableTBO,
- GLXFBEvaluator,
- GLPatchTable> OsdGLSLTransformFeedbackMesh;
-#endif /* OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK */
-
-#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
-using OpenSubdiv::Osd::GLComputeEvaluator;
-using OpenSubdiv::Osd::GLStencilTableSSBO;
-using OpenSubdiv::Osd::GLVertexBuffer;
-typedef Mesh<GLVertexBuffer,
- GLStencilTableSSBO,
- GLComputeEvaluator,
- GLPatchTable> OsdGLSLComputeMesh;
-#endif
-
-namespace {
-
-#if !defined(OPENSUBDIV_VERSION_NUMBER) && !defined(OPENSUBDIV_VERSION_MINOR)
-void stringSplit(vector<string>* tokens,
- const string& str,
- const string& separators,
- bool skip_empty) {
- size_t token_start = 0, token_length = 0;
- for (size_t i = 0; i < str.length(); ++i) {
- const char ch = str[i];
- if (separators.find(ch) == string::npos) {
- /* Append non-separator char to a token. */
- ++token_length;
- } else {
- /* Append current token to the list (if any). */
- if (token_length > 0 || !skip_empty) {
- string token = str.substr(token_start, token_length);
- tokens->push_back(token);
- }
- /* Re-set token pointers, */
- token_start = i + 1;
- token_length = 0;
- }
- }
- /* Append token which might be at the end of the string. */
- if ((token_length != 0) ||
- (!skip_empty && token_start > 0 &&
- separators.find(str[token_start-1]) != string::npos)) {
- string token = str.substr(token_start, token_length);
- tokens->push_back(token);
- }
-}
-#endif
-
-struct FVarVertex {
- float u, v;
- void Clear() {
- u = v = 0.0f;
- }
- void AddWithWeight(FVarVertex const & src, float weight) {
- u += weight * src.u;
- v += weight * src.v;
- }
-};
-
-static void interpolate_fvar_data(OpenSubdiv::Far::TopologyRefiner& refiner,
- const std::vector<float> uvs,
- std::vector<float> &fvar_data) {
- /* TODO(sergey): Make it somehow more generic way. */
- const int fvar_width = 2;
- const int max_level = refiner.GetMaxLevel();
- size_t fvar_data_offset = 0, values_offset = 0;
- for (int channel = 0; channel < refiner.GetNumFVarChannels(); ++channel) {
- const int num_values = refiner.GetLevel(0).GetNumFVarValues(channel) * 2,
- num_values_max = refiner.GetLevel(max_level).GetNumFVarValues(channel),
- num_values_total = refiner.GetNumFVarValuesTotal(channel);
- if (num_values_total <= 0) {
- continue;
- }
- OpenSubdiv::Far::PrimvarRefiner primvar_refiner(refiner);
- if (refiner.IsUniform()) {
- /* For uniform we only keep the highest level of refinement. */
- fvar_data.resize(fvar_data.size() + num_values_max * fvar_width);
- std::vector<FVarVertex> buffer(num_values_total - num_values_max);
- FVarVertex *src = &buffer[0];
- memcpy(src, &uvs[values_offset], num_values * sizeof(float));
- /* Defer the last level to treat separately with its alternate
- * destination.
- */
- for (int level = 1; level < max_level; ++level) {
- FVarVertex *dst = src + refiner.GetLevel(level-1).GetNumFVarValues(channel);
- primvar_refiner.InterpolateFaceVarying(level, src, dst, channel);
- src = dst;
- }
- FVarVertex *dst = reinterpret_cast<FVarVertex *>(&fvar_data[fvar_data_offset]);
- primvar_refiner.InterpolateFaceVarying(max_level, src, dst, channel);
- fvar_data_offset += num_values_max * fvar_width;
- } else {
- /* For adaptive we keep all levels. */
- fvar_data.resize(fvar_data.size() + num_values_total * fvar_width);
- FVarVertex *src = reinterpret_cast<FVarVertex *>(&fvar_data[fvar_data_offset]);
- memcpy(src, &uvs[values_offset], num_values * sizeof(float));
- for (int level = 1; level <= max_level; ++level) {
- FVarVertex *dst = src + refiner.GetLevel(level-1).GetNumFVarValues(channel);
- primvar_refiner.InterpolateFaceVarying(level, src, dst, channel);
- src = dst;
- }
- fvar_data_offset += num_values_total * fvar_width;
- }
- values_offset += num_values;
- }
-}
-
-} // namespace
-
-struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
- OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- int evaluator_type,
- int level)
-{
- using OpenSubdiv::Far::TopologyRefiner;
-
- MeshBitset bits;
- /* TODO(sergey): Adaptive subdivisions are not currently
- * possible because of the lack of tessellation shader.
- */
- bits.set(OpenSubdiv::Osd::MeshAdaptive, 0);
- bits.set(OpenSubdiv::Osd::MeshUseSingleCreasePatch, 0);
- bits.set(OpenSubdiv::Osd::MeshInterleaveVarying, 1);
- bits.set(OpenSubdiv::Osd::MeshFVarData, 1);
- bits.set(OpenSubdiv::Osd::MeshEndCapBSplineBasis, 1);
-
- const int num_vertex_elements = 3;
- const int num_varying_elements = 3;
-
- GLMeshInterface *mesh = NULL;
- TopologyRefiner *refiner = topology_refiner->osd_refiner;
-
- switch(evaluator_type) {
-#define CHECK_EVALUATOR_TYPE(type, class) \
- case OPENSUBDIV_EVALUATOR_ ## type: \
- mesh = new class(refiner, \
- num_vertex_elements, \
- num_varying_elements, \
- level, \
- bits); \
- break;
-
- CHECK_EVALUATOR_TYPE(CPU, OsdCpuMesh)
-
-#ifdef OPENSUBDIV_HAS_OPENMP
- CHECK_EVALUATOR_TYPE(OPENMP, OsdOmpMesh)
-#endif
-
-#ifdef OPENSUBDIV_HAS_OPENCL
- CHECK_EVALUATOR_TYPE(OPENCL, OsdCLMesh)
-#endif
-
-#ifdef OPENSUBDIV_HAS_CUDA
- CHECK_EVALUATOR_TYPE(CUDA, OsdCudaMesh)
-#endif
-
-#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
- CHECK_EVALUATOR_TYPE(GLSL_TRANSFORM_FEEDBACK,
- OsdGLSLTransformFeedbackMesh)
-#endif
-
-#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
- CHECK_EVALUATOR_TYPE(GLSL_COMPUTE, OsdGLSLComputeMesh)
-#endif
-
-#undef CHECK_EVALUATOR_TYPE
- }
-
- if (mesh == NULL) {
- return NULL;
- }
-
- OpenSubdiv_GLMesh *gl_mesh =
- (OpenSubdiv_GLMesh *) OBJECT_GUARDED_NEW(OpenSubdiv_GLMesh);
- gl_mesh->evaluator_type = evaluator_type;
- gl_mesh->descriptor = (OpenSubdiv_GLMeshDescr *) mesh;
- gl_mesh->topology_refiner = topology_refiner;
-
- if (refiner->GetNumFVarChannels() > 0) {
- std::vector<float> fvar_data;
- interpolate_fvar_data(*refiner, topology_refiner->uvs, fvar_data);
- openSubdiv_osdGLAllocFVar(topology_refiner, gl_mesh, &fvar_data[0]);
- }
- else {
- gl_mesh->fvar_data = NULL;
- }
-
- return gl_mesh;
-}
-
-void openSubdiv_deleteOsdGLMesh(struct OpenSubdiv_GLMesh *gl_mesh)
-{
- openSubdiv_osdGLDestroyFVar(gl_mesh);
- switch (gl_mesh->evaluator_type) {
-#define CHECK_EVALUATOR_TYPE(type, class) \
- case OPENSUBDIV_EVALUATOR_ ## type: \
- delete (class *) gl_mesh->descriptor; \
- break;
-
- CHECK_EVALUATOR_TYPE(CPU, OsdCpuMesh)
-
-#ifdef OPENSUBDIV_HAS_OPENMP
- CHECK_EVALUATOR_TYPE(OPENMP, OsdOmpMesh)
-#endif
-
-#ifdef OPENSUBDIV_HAS_OPENCL
- CHECK_EVALUATOR_TYPE(OPENCL, OsdCLMesh)
-#endif
-
-#ifdef OPENSUBDIV_HAS_CUDA
- CHECK_EVALUATOR_TYPE(CUDA, OsdCudaMesh)
-#endif
-
-#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
- CHECK_EVALUATOR_TYPE(GLSL_TRANSFORM_FEEDBACK,
- OsdGLSLTransformFeedbackMesh)
-#endif
-
-#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
- CHECK_EVALUATOR_TYPE(GLSL_COMPUTE, OsdGLSLComputeMesh)
-#endif
-
-#undef CHECK_EVALUATOR_TYPE
- }
-
- /* NOTE: OSD refiner was owned by gl_mesh, no need to free it here. */
- OBJECT_GUARDED_DELETE(gl_mesh->topology_refiner, OpenSubdiv_TopologyRefinerDescr);
- OBJECT_GUARDED_DELETE(gl_mesh, OpenSubdiv_GLMesh);
-}
-
-unsigned int openSubdiv_getOsdGLMeshPatchIndexBuffer(struct OpenSubdiv_GLMesh *gl_mesh)
-{
- return ((GLMeshInterface *)gl_mesh->descriptor)->GetPatchTable()->GetPatchIndexBuffer();
-}
-
-unsigned int openSubdiv_getOsdGLMeshVertexBuffer(struct OpenSubdiv_GLMesh *gl_mesh)
-{
- return ((GLMeshInterface *)gl_mesh->descriptor)->BindVertexBuffer();
-}
-
-void openSubdiv_osdGLMeshUpdateVertexBuffer(struct OpenSubdiv_GLMesh *gl_mesh,
- const float *vertex_data,
- int start_vertex,
- int num_verts)
-{
- ((GLMeshInterface *)gl_mesh->descriptor)->UpdateVertexBuffer(vertex_data,
- start_vertex,
- num_verts);
-}
-
-void openSubdiv_osdGLMeshRefine(struct OpenSubdiv_GLMesh *gl_mesh)
-{
- ((GLMeshInterface *)gl_mesh->descriptor)->Refine();
-}
-
-void openSubdiv_osdGLMeshSynchronize(struct OpenSubdiv_GLMesh *gl_mesh)
-{
- ((GLMeshInterface *)gl_mesh->descriptor)->Synchronize();
-}
-
-void openSubdiv_osdGLMeshBindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh)
-{
- ((GLMeshInterface *)gl_mesh->descriptor)->BindVertexBuffer();
-}
-
-const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefiner(
- OpenSubdiv_GLMesh *gl_mesh)
-{
- return gl_mesh->topology_refiner;
-}
-
-int openSubdiv_getVersionHex(void)
-{
-#if defined(OPENSUBDIV_VERSION_NUMBER)
- return OPENSUBDIV_VERSION_NUMBER;
-#elif defined(OPENSUBDIV_VERSION_MAJOR)
- return OPENSUBDIV_VERSION_MAJOR * 10000 +
- OPENSUBDIV_VERSION_MINOR * 100 +
- OPENSUBDIV_VERSION_PATCH;
-#elif defined(OPENSUBDIV_VERSION)
- const char* version = STRINGIFY(OPENSUBDIV_VERSION);
- if (version[0] == 'v') {
- version += 1;
- }
- int major = 0, minor = 0, patch = 0;
- vector<string> tokens;
- stringSplit(&tokens, version, "_", true);
- if (tokens.size() == 3) {
- major = atoi(tokens[0].c_str());
- minor = atoi(tokens[1].c_str());
- patch = atoi(tokens[2].c_str());
- }
- return major * 10000 + minor * 100 + patch;
-#else
- return 0;
-#endif
-}
diff --git a/intern/opensubdiv/opensubdiv_capi.h b/intern/opensubdiv/opensubdiv_capi.h
index 2c3fcee7dbb..a26ea36b863 100644
--- a/intern/opensubdiv/opensubdiv_capi.h
+++ b/intern/opensubdiv/opensubdiv_capi.h
@@ -1,159 +1,43 @@
-/*
- * ***** 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) 2013 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __OPENSUBDIV_CAPI_H__
-#define __OPENSUBDIV_CAPI_H__
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_CAPI_H_
+#define OPENSUBDIV_CAPI_H_
+
+#include "opensubdiv_capi_type.h"
#ifdef __cplusplus
extern "C" {
#endif
-// Types declaration.
-struct OpenSubdiv_GLMesh;
-struct OpenSubdiv_GLMeshFVarData;
-struct OpenSubdiv_TopologyRefinerDescr;
-
-typedef struct OpenSubdiv_GLMesh OpenSubdiv_GLMesh;
-
-#ifdef __cplusplus
-struct OpenSubdiv_GLMeshDescr;
-
-typedef struct OpenSubdiv_GLMesh {
- int evaluator_type;
- OpenSubdiv_GLMeshDescr *descriptor;
- OpenSubdiv_TopologyRefinerDescr *topology_refiner;
- OpenSubdiv_GLMeshFVarData *fvar_data;
-} OpenSubdiv_GLMesh;
-#endif
-
-// Keep this a bitmask os it's possible to pass available
-// evaluators to Blender.
-enum {
- OPENSUBDIV_EVALUATOR_CPU = (1 << 0),
- OPENSUBDIV_EVALUATOR_OPENMP = (1 << 1),
- OPENSUBDIV_EVALUATOR_OPENCL = (1 << 2),
- OPENSUBDIV_EVALUATOR_CUDA = (1 << 3),
- OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK = (1 << 4),
- OPENSUBDIV_EVALUATOR_GLSL_COMPUTE = (1 << 5),
-};
-
-enum {
- OPENSUBDIV_SCHEME_CATMARK,
- OPENSUBDIV_SCHEME_BILINEAR,
- OPENSUBDIV_SCHEME_LOOP,
-};
-
-/* TODO(sergey): Re-name and avoid bad level data access. */
-OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
- struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- int evaluator_type,
- int level);
-
-void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh);
-unsigned int openSubdiv_getOsdGLMeshPatchIndexBuffer(
- OpenSubdiv_GLMesh *gl_mesh);
-unsigned int openSubdiv_getOsdGLMeshVertexBuffer(OpenSubdiv_GLMesh *gl_mesh);
-void openSubdiv_osdGLMeshUpdateVertexBuffer(OpenSubdiv_GLMesh *gl_mesh,
- const float *vertex_data,
- int start_vertex,
- int num_verts);
-void openSubdiv_osdGLMeshRefine(OpenSubdiv_GLMesh *gl_mesh);
-void openSubdiv_osdGLMeshSynchronize(OpenSubdiv_GLMesh *gl_mesh);
-void openSubdiv_osdGLMeshBindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh);
-
-const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefiner(
- OpenSubdiv_GLMesh *gl_mesh);
-
-/* ** Initialize/Deinitialize global OpenGL drawing buffers/GLSL programs ** */
-bool openSubdiv_osdGLDisplayInit(void);
-void openSubdiv_osdGLDisplayDeinit(void);
-
-/* ** Evaluator API ** */
-
-struct OpenSubdiv_EvaluatorDescr;
-typedef struct OpenSubdiv_EvaluatorDescr OpenSubdiv_EvaluatorDescr;
-
-/* TODO(sergey): Avoid bad-level data access, */
-OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr(
- struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- int subsurf_level);
-
-void openSubdiv_deleteEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr);
-
-void openSubdiv_setEvaluatorCoarsePositions(OpenSubdiv_EvaluatorDescr *evaluator_descr,
- float *positions,
- int start_vert,
- int num_vert);
-
-void openSubdiv_setEvaluatorVaryingData(OpenSubdiv_EvaluatorDescr *evaluator_descr,
- float *varying_data,
- int start_vert,
- int num_vert);
-
-void openSubdiv_evaluateLimit(OpenSubdiv_EvaluatorDescr *evaluator_descr,
- int osd_face_index,
- float face_u, float face_v,
- float P[3],
- float dPdu[3],
- float dPdv[3]);
-
-void openSubdiv_evaluateVarying(OpenSubdiv_EvaluatorDescr *evaluator_descr,
- int osd_face_index,
- float face_u, float face_v,
- float varying[3]);
-
-/* ** Actual drawing ** */
-
-/* Initialize all the invariants which stays the same for every single path,
- * for example lighting model stays untouched for the whole mesh.
- *
- * TODO(sergey): Some of the stuff could be initialized once for all meshes.
- */
-void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl,
- int active_uv_index);
-
-/* Draw specified patches. */
-void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh,
- int fill_quads,
- int start_patch,
- int num_patches);
-
-void openSubdiv_osdGLAllocFVar(struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- OpenSubdiv_GLMesh *gl_mesh,
- const float *fvar_data);
-void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh);
-
-/* ** Utility functions ** */
-int openSubdiv_getAvailableEvaluators(void);
+// Global initialization/deinitialization.
+//
+// Supposed to be called from main thread.
void openSubdiv_init(void);
void openSubdiv_cleanup(void);
+// Bitmask of eOpenSubdivEvaluator.
+int openSubdiv_getAvailableEvaluators(void);
+
int openSubdiv_getVersionHex(void);
#ifdef __cplusplus
}
#endif
-#endif // __OPENSUBDIV_CAPI_H__
+#endif // OPENSUBDIV_CAPI_H_
diff --git a/intern/opensubdiv/opensubdiv_capi_type.h b/intern/opensubdiv/opensubdiv_capi_type.h
new file mode 100644
index 00000000000..b326e53e168
--- /dev/null
+++ b/intern/opensubdiv/opensubdiv_capi_type.h
@@ -0,0 +1,56 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_CAPI_TYPES_H_
+#define OPENSUBDIV_CAPI_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Keep this a bitmask os it's possible to pass available
+// evaluators to Blender.
+typedef enum eOpenSubdivEvaluator {
+ OPENSUBDIV_EVALUATOR_CPU = (1 << 0),
+ OPENSUBDIV_EVALUATOR_OPENMP = (1 << 1),
+ OPENSUBDIV_EVALUATOR_OPENCL = (1 << 2),
+ OPENSUBDIV_EVALUATOR_CUDA = (1 << 3),
+ OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK = (1 << 4),
+ OPENSUBDIV_EVALUATOR_GLSL_COMPUTE = (1 << 5),
+} eOpenSubdivEvaluator;
+
+typedef enum OpenSubdiv_SchemeType {
+ OSD_SCHEME_BILINEAR,
+ OSD_SCHEME_CATMARK,
+ OSD_SCHEME_LOOP,
+} OpenSubdiv_SchemeType;
+
+typedef enum OpenSubdiv_FVarLinearInterpolation {
+ OSD_FVAR_LINEAR_INTERPOLATION_NONE,
+ OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY,
+ OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1,
+ OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2,
+ OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES,
+ OSD_FVAR_LINEAR_INTERPOLATION_ALL,
+} OpenSubdiv_FVarLinearInterpolation;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // OPENSUBDIV_CAPI_TYPES_H_
diff --git a/intern/opensubdiv/opensubdiv_converter.cc b/intern/opensubdiv/opensubdiv_converter.cc
deleted file mode 100644
index ea41a56768f..00000000000
--- a/intern/opensubdiv/opensubdiv_converter.cc
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <cstdio>
-#include <vector>
-
-#ifdef _MSC_VER
-# include "iso646.h"
-#endif
-
-#include <opensubdiv/far/topologyRefinerFactory.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "opensubdiv_converter_capi.h"
-#include "opensubdiv_intern.h"
-#include "opensubdiv_topology_refiner.h"
-
-
-#include <stack>
-
-#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
-namespace {
-
-inline void reverse_face_verts(int *face_verts, int num_verts)
-{
- int last_vert = face_verts[num_verts - 1];
- for (int i = num_verts - 1; i > 0; --i) {
- face_verts[i] = face_verts[i - 1];
- }
- face_verts[0] = last_vert;
-}
-
-struct TopologyRefinerData {
- const OpenSubdiv_Converter& conv;
- std::vector<float> *uvs;
-};
-
-} /* namespace */
-#endif /* OPENSUBDIV_ORIENT_TOPOLOGY */
-
-namespace OpenSubdiv {
-namespace OPENSUBDIV_VERSION {
-namespace Far {
-
-namespace {
-
-template <typename T>
-inline int findInArray(T array, int value)
-{
- return (int)(std::find(array.begin(), array.end(), value) - array.begin());
-}
-
-#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
-inline int get_loop_winding(int vert0_of_face, int vert1_of_face)
-{
- int delta_face = vert1_of_face - vert0_of_face;
- if (abs(delta_face) != 1) {
- if (delta_face > 0) {
- delta_face = -1;
- }
- else {
- delta_face = 1;
- }
- }
- return delta_face;
-}
-
-inline void reverse_face_loops(IndexArray face_verts, IndexArray face_edges)
-{
- for (int i = 0; i < face_verts.size() / 2; ++i) {
- int j = face_verts.size() - i - 1;
- if (i != j) {
- std::swap(face_verts[i], face_verts[j]);
- std::swap(face_edges[i], face_edges[j]);
- }
- }
- reverse_face_verts(&face_verts[0], face_verts.size());
-}
-
-inline void check_oriented_vert_connectivity(const int num_vert_edges,
- const int num_vert_faces,
- const int *vert_edges,
- const int *vert_faces,
- const int *dst_vert_edges,
- const int *dst_vert_faces)
-{
-# ifndef NDEBUG
- for (int i = 0; i < num_vert_faces; ++i) {
- bool found = false;
- for (int j = 0; j < num_vert_faces; ++j) {
- if (vert_faces[i] == dst_vert_faces[j]) {
- found = true;
- break;
- }
- }
- if (!found) {
- assert(!"vert-faces connectivity ruined");
- }
- }
- for (int i = 0; i < num_vert_edges; ++i) {
- bool found = false;
- for (int j = 0; j < num_vert_edges; ++j) {
- if (vert_edges[i] == dst_vert_edges[j]) {
- found = true;
- break;
- }
- }
- if (!found) {
- assert(!"vert-edges connectivity ruined");
- }
- }
-# else
- (void)num_vert_edges;
- (void)num_vert_faces;
- (void)vert_edges;
- (void)vert_faces;
- (void)dst_vert_edges;
- (void)dst_vert_faces;
-# endif
-}
-#endif
-
-} /* namespace */
-
-template <>
-inline bool TopologyRefinerFactory<TopologyRefinerData>::resizeComponentTopology(
- TopologyRefiner& refiner,
- const TopologyRefinerData& cb_data)
-{
- const OpenSubdiv_Converter& conv = cb_data.conv;
- /* Faces and face-verts */
- const int num_faces = conv.get_num_faces(&conv);
- setNumBaseFaces(refiner, num_faces);
- for (int face = 0; face < num_faces; ++face) {
- const int num_verts = conv.get_num_face_verts(&conv, face);
- setNumBaseFaceVertices(refiner, face, num_verts);
- }
- /* Edges and edge-faces. */
- const int num_edges = conv.get_num_edges(&conv);
- setNumBaseEdges(refiner, num_edges);
- for (int edge = 0; edge < num_edges; ++edge) {
- const int num_edge_faces = conv.get_num_edge_faces(&conv, edge);
- setNumBaseEdgeFaces(refiner, edge, num_edge_faces);
- }
- /* Vertices and vert-faces and vert-edges/ */
- const int num_verts = conv.get_num_verts(&conv);
- setNumBaseVertices(refiner, num_verts);
- for (int vert = 0; vert < num_verts; ++vert) {
- const int num_vert_edges = conv.get_num_vert_edges(&conv, vert),
- num_vert_faces = conv.get_num_vert_faces(&conv, vert);
- setNumBaseVertexEdges(refiner, vert, num_vert_edges);
- setNumBaseVertexFaces(refiner, vert, num_vert_faces);
- }
- return true;
-}
-
-template <>
-inline bool TopologyRefinerFactory<TopologyRefinerData>::assignComponentTopology(
- TopologyRefiner& refiner,
- const TopologyRefinerData &cb_data)
-{
- const OpenSubdiv_Converter& conv = cb_data.conv;
- using Far::IndexArray;
- /* Face relations. */
- const int num_faces = conv.get_num_faces(&conv);
- for (int face = 0; face < num_faces; ++face) {
- IndexArray dst_face_verts = getBaseFaceVertices(refiner, face);
- conv.get_face_verts(&conv, face, &dst_face_verts[0]);
- IndexArray dst_face_edges = getBaseFaceEdges(refiner, face);
- conv.get_face_edges(&conv, face, &dst_face_edges[0]);
- }
- /* Edge relations. */
- const int num_edges = conv.get_num_edges(&conv);
- for (int edge = 0; edge < num_edges; ++edge) {
- /* Edge-vertices */
- IndexArray dst_edge_verts = getBaseEdgeVertices(refiner, edge);
- conv.get_edge_verts(&conv, edge, &dst_edge_verts[0]);
- /* Edge-faces */
- IndexArray dst_edge_faces = getBaseEdgeFaces(refiner, edge);
- conv.get_edge_faces(&conv, edge, &dst_edge_faces[0]);
- }
-#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
- /* Make face normals consistent. */
- bool *face_used = new bool[num_faces];
- memset(face_used, 0, sizeof(bool) * num_faces);
- std::stack<int> traverse_stack;
- int face_start = 0, num_traversed_faces = 0;
- /* Traverse all islands. */
- while (num_traversed_faces != num_faces) {
- /* Find first face of any untraversed islands. */
- while (face_used[face_start]) {
- ++face_start;
- }
- /* Add first face to the stack. */
- traverse_stack.push(face_start);
- face_used[face_start] = true;
- /* Go over whole connected component. */
- while (!traverse_stack.empty()) {
- int face = traverse_stack.top();
- traverse_stack.pop();
- IndexArray face_edges = getBaseFaceEdges(refiner, face);
- ConstIndexArray face_verts = getBaseFaceVertices(refiner, face);
- for (int edge_index = 0; edge_index < face_edges.size(); ++edge_index) {
- const int edge = face_edges[edge_index];
- ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge);
- if (edge_faces.size() != 2) {
- /* Can't make consistent normals for non-manifolds. */
- continue;
- }
- ConstIndexArray edge_verts = getBaseEdgeVertices(refiner, edge);
- /* Get winding of the reference face. */
- int vert0_of_face = findInArray(face_verts, edge_verts[0]),
- vert1_of_face = findInArray(face_verts, edge_verts[1]);
- int delta_face = get_loop_winding(vert0_of_face, vert1_of_face);
- for (int edge_face = 0; edge_face < edge_faces.size(); ++edge_face) {
- int other_face = edge_faces[edge_face];
- /* Never re-traverse faces, only move forward. */
- if (face_used[other_face]) {
- continue;
- }
- IndexArray other_face_verts = getBaseFaceVertices(refiner,
- other_face);
- int vert0_of_other_face = findInArray(other_face_verts,
- edge_verts[0]),
- vert1_of_other_face = findInArray(other_face_verts,
- edge_verts[1]);
- int delta_other_face = get_loop_winding(vert0_of_other_face,
- vert1_of_other_face);
- if (delta_face * delta_other_face > 0) {
- IndexArray other_face_verts = getBaseFaceVertices(refiner,
- other_face),
- other_face_edges = getBaseFaceEdges(refiner,
- other_face);
- reverse_face_loops(other_face_verts,
- other_face_edges);
- }
- traverse_stack.push(other_face);
- face_used[other_face] = true;
- }
- }
- ++num_traversed_faces;
- }
- }
-#endif /* OPENSUBDIV_ORIENT_TOPOLOGY */
- /* Vertex relations */
- const int num_verts = conv.get_num_verts(&conv);
- for (int vert = 0; vert < num_verts; ++vert) {
-
- /* Vert-Faces */
- IndexArray dst_vert_faces = getBaseVertexFaces(refiner, vert);
- int num_vert_faces = conv.get_num_vert_faces(&conv, vert);
- int *vert_faces = new int[num_vert_faces];
- conv.get_vert_faces(&conv, vert, vert_faces);
- /* Vert-Edges */
- IndexArray dst_vert_edges = getBaseVertexEdges(refiner, vert);
- int num_vert_edges = conv.get_num_vert_edges(&conv, vert);
- int *vert_edges = new int[num_vert_edges];
- conv.get_vert_edges(&conv, vert, vert_edges);
-#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
- /* ** Order vertex edges and faces in a CCW order. ** */
- memset(face_used, 0, sizeof(bool) * num_faces);
- /* Number of edges and faces added to the ordered array. */
- int edge_count_ordered = 0, face_count_ordered = 0;
- /* Add loose edges straight into the edges array. */
- bool has_fan_connections = false;
- for (int i = 0; i < num_vert_edges; ++i) {
- IndexArray edge_faces = getBaseEdgeFaces(refiner, vert_edges[i]);
- if (edge_faces.size() == 0) {
- dst_vert_edges[edge_count_ordered++] = vert_edges[i];
- }
- else if (edge_faces.size() > 2) {
- has_fan_connections = true;
- }
- }
- if (has_fan_connections) {
- /* OpenSubdiv currently doesn't give us clues how to handle
- * fan face connections. and since handling such connections
- * complicates the loop below we simply don't do special
- * orientation for them.
- */
- memcpy(&dst_vert_edges[0], vert_edges, sizeof(int) * num_vert_edges);
- memcpy(&dst_vert_faces[0], vert_faces, sizeof(int) * num_vert_faces);
- delete [] vert_edges;
- delete [] vert_faces;
- continue;
- }
- /* Perform at max numbder of vert-edges iteration and try to avoid
- * deadlock here for malformed mesh.
- */
- for (int global_iter = 0; global_iter < num_vert_edges; ++global_iter) {
- /* Numbr of edges and faces which are still to be ordered. */
- int num_vert_edges_remained = num_vert_edges - edge_count_ordered,
- num_vert_faces_remained = num_vert_faces - face_count_ordered;
- if (num_vert_edges_remained == 0 && num_vert_faces_remained == 0) {
- /* All done, nothing to do anymore. */
- break;
- }
- /* Face, edge and face-vertex inndex to start traversal from. */
- int face_start = -1, edge_start = -1, face_vert_start = -1;
- if (num_vert_edges_remained == num_vert_faces_remained) {
- /* Vertex is eitehr complete manifold or is connected to seevral
- * manifold islands (hourglass-like configuration), can pick up
- * random edge unused and start from it.
- */
- /* TODO(sergey): Start from previous edge from which traversal
- * began at previous iteration.
- */
- for (int i = 0; i < num_vert_edges; ++i) {
- face_start = vert_faces[i];
- if (!face_used[face_start]) {
- ConstIndexArray
- face_verts = getBaseFaceVertices(refiner, face_start),
- face_edges = getBaseFaceEdges(refiner, face_start);
- face_vert_start = findInArray(face_verts, vert);
- edge_start = face_edges[face_vert_start];
- break;
- }
- }
- }
- else {
- /* Special handle of non-manifold vertex. */
- for (int i = 0; i < num_vert_edges; ++i) {
- edge_start = vert_edges[i];
- IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_start);
- if (edge_faces.size() == 1) {
- face_start = edge_faces[0];
- if (!face_used[face_start]) {
- ConstIndexArray
- face_verts = getBaseFaceVertices(refiner, face_start),
- face_edges = getBaseFaceEdges(refiner, face_start);
- face_vert_start = findInArray(face_verts, vert);
- if (edge_start == face_edges[face_vert_start]) {
- break;
- }
- }
- }
- /* Reset indices for sanity check below. */
- face_start = edge_start = face_vert_start = -1;
- }
- }
- /* Sanity check. */
- assert(face_start != -1 &&
- edge_start != -1 &&
- face_vert_start != -1);
- /* Traverse faces starting from the current one. */
- int edge_first = edge_start;
- dst_vert_faces[face_count_ordered++] = face_start;
- dst_vert_edges[edge_count_ordered++] = edge_start;
- face_used[face_start] = true;
- while (edge_count_ordered < num_vert_edges) {
- IndexArray face_verts = getBaseFaceVertices(refiner, face_start);
- IndexArray face_edges = getBaseFaceEdges(refiner, face_start);
- int face_edge_start = face_vert_start;
- int face_edge_next = (face_edge_start > 0) ? (face_edge_start - 1) : (face_verts.size() - 1);
- Index edge_next = face_edges[face_edge_next];
- if (edge_next == edge_first) {
- /* Multiple manifolds found, stop for now and handle rest
- * in the next iteration.
- */
- break;
- }
- dst_vert_edges[edge_count_ordered++] = edge_next;
- if (face_count_ordered < num_vert_faces) {
- IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_next);
- assert(edge_faces.size() != 0);
- if (edge_faces.size() == 1) {
- assert(edge_faces[0] == face_start);
- break;
- }
- else if (edge_faces.size() != 2) {
- break;
- }
- assert(edge_faces.size() == 2);
- face_start = edge_faces[(edge_faces[0] == face_start) ? 1 : 0];
- face_vert_start = findInArray(getBaseFaceEdges(refiner, face_start), edge_next);
- dst_vert_faces[face_count_ordered++] = face_start;
- face_used[face_start] = true;
- }
- edge_start = edge_next;
- }
- }
- /* Verify ordering doesn't ruin connectivity information. */
- assert(face_count_ordered == num_vert_faces);
- assert(edge_count_ordered == num_vert_edges);
- check_oriented_vert_connectivity(num_vert_edges,
- num_vert_faces,
- vert_edges,
- vert_faces,
- &dst_vert_edges[0],
- &dst_vert_faces[0]);
- /* For the release builds we're failing mesh construction so instead
- * of nasty bugs the unsupported mesh will simply disappear from the
- * viewport.
- */
- if (face_count_ordered != num_vert_faces ||
- edge_count_ordered != num_vert_edges)
- {
- delete [] vert_edges;
- delete [] vert_faces;
- return false;
- }
-#else /* OPENSUBDIV_ORIENT_TOPOLOGY */
- memcpy(&dst_vert_edges[0], vert_edges, sizeof(int) * num_vert_edges);
- memcpy(&dst_vert_faces[0], vert_faces, sizeof(int) * num_vert_faces);
-#endif /* OPENSUBDIV_ORIENT_TOPOLOGY */
- delete [] vert_edges;
- delete [] vert_faces;
- }
-#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
- delete [] face_used;
-#endif
- populateBaseLocalIndices(refiner);
- return true;
-};
-
-template <>
-inline bool TopologyRefinerFactory<TopologyRefinerData>::assignComponentTags(
- TopologyRefiner& refiner,
- const TopologyRefinerData& cb_data)
-{
- const OpenSubdiv_Converter& conv = cb_data.conv;
- typedef OpenSubdiv::Sdc::Crease Crease;
-
- int num_edges = conv.get_num_edges(&conv);
- for (int edge = 0; edge < num_edges; ++edge) {
- float sharpness;
- ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge);
- if (edge_faces.size() == 2) {
- sharpness = conv.get_edge_sharpness(&conv, edge);
- }
- else {
- /* Non-manifold edges must be sharp. */
- sharpness = Crease::SHARPNESS_INFINITE;
- }
- setBaseEdgeSharpness(refiner, edge, sharpness);
- }
-
- /* OpenSubdiv expects non-manifold vertices to be sharp but at the
- * time it handles correct cases when vertex is a corner of plane.
- * Currently mark verts which are adjacent to a loose edge as sharp,
- * but this decision needs some more investigation.
- */
- int num_vert = conv.get_num_verts(&conv);
- for (int vert = 0; vert < num_vert; ++vert) {
- ConstIndexArray vert_edges = getBaseVertexEdges(refiner, vert);
- for (int edge_index = 0; edge_index < vert_edges.size(); ++edge_index) {
- int edge = vert_edges[edge_index];
- ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge);
- if (edge_faces.size() == 0) {
- setBaseVertexSharpness(refiner, vert, Crease::SHARPNESS_INFINITE);
- break;
- }
- }
- if (vert_edges.size() == 2) {
- int edge0 = vert_edges[0],
- edge1 = vert_edges[1];
- float sharpness0 = conv.get_edge_sharpness(&conv, edge0),
- sharpness1 = conv.get_edge_sharpness(&conv, edge1);
- float sharpness = std::min(sharpness0, sharpness1);
- setBaseVertexSharpness(refiner, vert, sharpness);
- }
- }
-
- return true;
-}
-
-template <>
-inline void TopologyRefinerFactory<TopologyRefinerData>::reportInvalidTopology(
- TopologyError /*errCode*/,
- const char *msg,
- const TopologyRefinerData& /*mesh*/)
-{
- printf("OpenSubdiv Error: %s\n", msg);
-}
-
-template <>
-inline bool TopologyRefinerFactory<TopologyRefinerData>::assignFaceVaryingTopology(
- TopologyRefiner& refiner,
- const TopologyRefinerData& cb_data)
-{
- const OpenSubdiv_Converter& conv = cb_data.conv;
- const int num_layers = conv.get_num_uv_layers(&conv);
- if (num_layers <= 0) {
- /* No UV maps, we can skip any face-varying data. */
- return true;
- }
- const int num_faces = getNumBaseFaces(refiner);
- size_t uvs_offset = 0;
- for (int layer = 0; layer < num_layers; ++layer) {
- conv.precalc_uv_layer(&conv, layer);
- const int num_uvs = conv.get_num_uvs(&conv);
- /* Fill in UV coordinates. */
- cb_data.uvs->resize(cb_data.uvs->size() + num_uvs * 2);
- conv.get_uvs(&conv, &cb_data.uvs->at(uvs_offset));
- uvs_offset += num_uvs * 2;
- /* Fill in per-corner index of the UV. */
- const int channel = createBaseFVarChannel(refiner, num_uvs);
- for (int face = 0; face < num_faces; ++face) {
- Far::IndexArray dst_face_uvs = getBaseFaceFVarValues(refiner,
- face,
- channel);
- for (int corner = 0; corner < dst_face_uvs.size(); ++corner) {
- const int uv_index = conv.get_face_corner_uv_index(&conv,
- face,
- corner);
- dst_face_uvs[corner] = uv_index;
- }
- }
- conv.finish_uv_layer(&conv);
- }
- return true;
-}
-
-} /* namespace Far */
-} /* namespace OPENSUBDIV_VERSION */
-} /* namespace OpenSubdiv */
-
-namespace {
-
-OpenSubdiv::Sdc::SchemeType get_capi_scheme_type(OpenSubdiv_SchemeType type)
-{
- switch(type) {
- case OSD_SCHEME_BILINEAR:
- return OpenSubdiv::Sdc::SCHEME_BILINEAR;
- case OSD_SCHEME_CATMARK:
- return OpenSubdiv::Sdc::SCHEME_CATMARK;
- case OSD_SCHEME_LOOP:
- return OpenSubdiv::Sdc::SCHEME_LOOP;
- }
- assert(!"Unknown sceme type passed via C-API");
- return OpenSubdiv::Sdc::SCHEME_CATMARK;
-}
-
-} /* namespace */
-
-struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr(
- OpenSubdiv_Converter *converter)
-{
- typedef OpenSubdiv::Sdc::Options Options;
-
- using OpenSubdiv::Far::TopologyRefinerFactory;
- OpenSubdiv::Sdc::SchemeType scheme_type =
- get_capi_scheme_type(converter->get_type(converter));
- Options options;
- options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY);
- options.SetCreasingMethod(Options::CREASE_UNIFORM);
- if (converter->get_subdiv_uvs(converter)) {
- options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_CORNERS_ONLY);
- }
- else {
- options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_ALL);
- }
-
- TopologyRefinerFactory<TopologyRefinerData>::Options
- topology_options(scheme_type, options);
-#ifdef OPENSUBDIV_VALIDATE_TOPOLOGY
- topology_options.validateFullTopology = true;
-#endif
- OpenSubdiv_TopologyRefinerDescr *result = OBJECT_GUARDED_NEW(OpenSubdiv_TopologyRefinerDescr);
- TopologyRefinerData cb_data = {*converter, &result->uvs};
- /* We don't use guarded allocation here so we can re-use the refiner
- * for GL mesh creation directly.
- */
- result->osd_refiner =
- TopologyRefinerFactory<TopologyRefinerData>::Create(
- cb_data,
- topology_options);
-
- return result;
-}
-
-void openSubdiv_deleteTopologyRefinerDescr(
- OpenSubdiv_TopologyRefinerDescr *topology_refiner)
-{
- delete topology_refiner->osd_refiner;
- OBJECT_GUARDED_DELETE(topology_refiner, OpenSubdiv_TopologyRefinerDescr);
-}
-
-int openSubdiv_topologyRefinerGetSubdivLevel(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner)
-{
- using OpenSubdiv::Far::TopologyRefiner;
- const TopologyRefiner *refiner = topology_refiner->osd_refiner;
- return refiner->GetMaxLevel();
-}
-
-int openSubdiv_topologyRefinerGetNumVerts(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner)
-{
- using OpenSubdiv::Far::TopologyLevel;
- using OpenSubdiv::Far::TopologyRefiner;
- const TopologyRefiner *refiner = topology_refiner->osd_refiner;
- const TopologyLevel &base_level = refiner->GetLevel(0);
- return base_level.GetNumVertices();
-}
-
-int openSubdiv_topologyRefinerGetNumEdges(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner)
-{
- using OpenSubdiv::Far::TopologyLevel;
- using OpenSubdiv::Far::TopologyRefiner;
- const TopologyRefiner *refiner = topology_refiner->osd_refiner;
- const TopologyLevel &base_level = refiner->GetLevel(0);
- return base_level.GetNumEdges();
-}
-
-int openSubdiv_topologyRefinerGetNumFaces(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner)
-{
- using OpenSubdiv::Far::TopologyLevel;
- using OpenSubdiv::Far::TopologyRefiner;
- const TopologyRefiner *refiner = topology_refiner->osd_refiner;
- const TopologyLevel &base_level = refiner->GetLevel(0);
- return base_level.GetNumFaces();
-}
-
-int openSubdiv_topologyRefinerGetNumFaceVerts(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- int face)
-{
- using OpenSubdiv::Far::TopologyLevel;
- using OpenSubdiv::Far::TopologyRefiner;
- const TopologyRefiner *refiner = topology_refiner->osd_refiner;
- const TopologyLevel &base_level = refiner->GetLevel(0);
- return base_level.GetFaceVertices(face).size();
-}
-
-int openSubdiv_topologyRefnerCompareConverter(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- OpenSubdiv_Converter *converter)
-{
- typedef OpenSubdiv::Sdc::Options Options;
- using OpenSubdiv::Far::ConstIndexArray;
- using OpenSubdiv::Far::TopologyRefiner;
- using OpenSubdiv::Far::TopologyLevel;
- const TopologyRefiner *refiner = topology_refiner->osd_refiner;
- const TopologyLevel &base_level = refiner->GetLevel(0);
- const int num_verts = base_level.GetNumVertices();
- const int num_edges = base_level.GetNumEdges();
- const int num_faces = base_level.GetNumFaces();
- /* Quick preliminary check. */
- OpenSubdiv::Sdc::SchemeType scheme_type =
- get_capi_scheme_type(converter->get_type(converter));
- if (scheme_type != refiner->GetSchemeType()) {
- return false;
- }
- const Options options = refiner->GetSchemeOptions();
- Options::FVarLinearInterpolation interp = options.GetFVarLinearInterpolation();
- const bool subdiv_uvs = (interp != Options::FVAR_LINEAR_ALL);
- if (converter->get_subdiv_uvs(converter) != subdiv_uvs) {
- return false;
- }
- if (converter->get_num_verts(converter) != num_verts ||
- converter->get_num_edges(converter) != num_edges ||
- converter->get_num_faces(converter) != num_faces)
- {
- return false;
- }
- /* Compare all edges. */
- for (int edge = 0; edge < num_edges; ++edge) {
- ConstIndexArray edge_verts = base_level.GetEdgeVertices(edge);
- int conv_edge_verts[2];
- converter->get_edge_verts(converter, edge, conv_edge_verts);
- if (conv_edge_verts[0] != edge_verts[0] ||
- conv_edge_verts[1] != edge_verts[1])
- {
- return false;
- }
- }
- /* Compare all faces. */
- std::vector<int> conv_face_verts;
- for (int face = 0; face < num_faces; ++face) {
- ConstIndexArray face_verts = base_level.GetFaceVertices(face);
- if (face_verts.size() != converter->get_num_face_verts(converter,
- face))
- {
- return false;
- }
- conv_face_verts.resize(face_verts.size());
- converter->get_face_verts(converter, face, &conv_face_verts[0]);
- bool direct_match = true;
- for (int i = 0; i < face_verts.size(); ++i) {
- if (conv_face_verts[i] != face_verts[i]) {
- direct_match = false;
- break;
- }
- }
- if (!direct_match) {
- /* If face didn't match in direct direction we also test if it
- * matches in reversed direction. This is because conversion might
- * reverse loops to make normals consistent.
- */
-#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
- reverse_face_verts(&conv_face_verts[0], conv_face_verts.size());
- for (int i = 0; i < face_verts.size(); ++i) {
- if (conv_face_verts[i] != face_verts[i]) {
- return false;
- }
- }
-#else
- return false;
-#endif
- }
- }
- /* Compare sharpness. */
- for (int edge = 0; edge < num_edges; ++edge) {
- ConstIndexArray edge_faces = base_level.GetEdgeFaces(edge);
- float sharpness = base_level.GetEdgeSharpness(edge);
- float conv_sharpness;
- if (edge_faces.size() == 2) {
- conv_sharpness = converter->get_edge_sharpness(converter, edge);
- }
- else {
- conv_sharpness = OpenSubdiv::Sdc::Crease::SHARPNESS_INFINITE;
- }
- if (sharpness != conv_sharpness) {
- return false;
- }
- }
- return true;
-}
diff --git a/intern/opensubdiv/opensubdiv_converter_capi.h b/intern/opensubdiv/opensubdiv_converter_capi.h
index 6eda6ae5d8a..a939f1117e0 100644
--- a/intern/opensubdiv/opensubdiv_converter_capi.h
+++ b/intern/opensubdiv/opensubdiv_converter_capi.h
@@ -1,140 +1,136 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __OPENSUBDIV_CONVERTER_CAPI_H__
-#define __OPENSUBDIV_CONVERTER_CAPI_H__
+// Copyright 2015 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_CONVERTER_CAPI_H_
+#define OPENSUBDIV_CONVERTER_CAPI_H_
+
+#include "opensubdiv_capi_type.h"
#ifdef __cplusplus
extern "C" {
#endif
-struct OpenSubdiv_TopologyRefinerDescr;
-typedef struct OpenSubdiv_TopologyRefinerDescr OpenSubdiv_TopologyRefinerDescr;
-
-typedef struct OpenSubdiv_Converter OpenSubdiv_Converter;
-
-typedef enum OpenSubdiv_SchemeType {
- OSD_SCHEME_BILINEAR,
- OSD_SCHEME_CATMARK,
- OSD_SCHEME_LOOP,
-} OpenSubdiv_SchemeType;
-
typedef struct OpenSubdiv_Converter {
- /* TODO(sergey): Needs to be implemented. */
- /* OpenSubdiv::Sdc::Options get_options() const; */
-
- OpenSubdiv_SchemeType (*get_type)(const OpenSubdiv_Converter *converter);
-
- bool (*get_subdiv_uvs)(const OpenSubdiv_Converter *converter);
-
- int (*get_num_faces)(const OpenSubdiv_Converter *converter);
- int (*get_num_edges)(const OpenSubdiv_Converter *converter);
- int (*get_num_verts)(const OpenSubdiv_Converter *converter);
-
- /* Face relationships. */
- int (*get_num_face_verts)(const OpenSubdiv_Converter *converter,
- int face);
- void (*get_face_verts)(const OpenSubdiv_Converter *converter,
- int face,
- int *face_verts);
- void (*get_face_edges)(const OpenSubdiv_Converter *converter,
- int face,
- int *face_edges);
-
- /* Edge relationships. */
- void (*get_edge_verts)(const OpenSubdiv_Converter *converter,
- int edge,
- int *edge_verts);
- int (*get_num_edge_faces)(const OpenSubdiv_Converter *converter,
- int edge);
- void (*get_edge_faces)(const OpenSubdiv_Converter *converter,
- int edge,
- int *edge_faces);
- float (*get_edge_sharpness)(const OpenSubdiv_Converter *converter,
- int edge);
-
- /* Vertex relationships. */
- int (*get_num_vert_edges)(const OpenSubdiv_Converter *converter, int vert);
- void (*get_vert_edges)(const OpenSubdiv_Converter *converter,
- int vert,
- int *vert_edges);
- int (*get_num_vert_faces)(const OpenSubdiv_Converter *converter, int vert);
- void (*get_vert_faces)(const OpenSubdiv_Converter *converter,
- int vert,
- int *vert_faces);
-
- /* Face-varying data. */
-
- int (*get_num_uv_layers)(const OpenSubdiv_Converter *converter);
-
- void (*precalc_uv_layer)(const OpenSubdiv_Converter *converter, int layer);
- void (*finish_uv_layer)(const OpenSubdiv_Converter *converter);
-
- int (*get_num_uvs)(const OpenSubdiv_Converter *converter);
- void (*get_uvs)(const OpenSubdiv_Converter *converter, float *uvs);
-
- int (*get_face_corner_uv_index)(const OpenSubdiv_Converter *converter,
- int face,
- int corner);
-
- void (*free_user_data)(const OpenSubdiv_Converter *converter);
- void *user_data;
+ OpenSubdiv_SchemeType (*getSchemeType)(
+ const struct OpenSubdiv_Converter* converter);
+
+ OpenSubdiv_FVarLinearInterpolation (*getFVarLinearInterpolation)(
+ const struct OpenSubdiv_Converter* converter);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Global geometry counters.
+ // Number of faces/edges/vertices in the base mesh.
+ int (*getNumFaces)(const struct OpenSubdiv_Converter* converter);
+ int (*getNumEdges)(const struct OpenSubdiv_Converter* converter);
+ int (*getNumVertices)(const struct OpenSubdiv_Converter* converter);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Face relationships.
+
+ // Number of vertices the face consists of.
+ int (*getNumFaceVertices)(const struct OpenSubdiv_Converter* converter,
+ const int face_index);
+ // Array of vertex indices the face consists of.
+ void (*getFaceVertices)(const struct OpenSubdiv_Converter* converter,
+ const int face_index,
+ int* face_vertices);
+ // Array of edge indices the face consists of.
+ // Aligned with the vertex indices array, edge i connects face vertex i
+ // with face index i+1.
+ void (*getFaceEdges)(const struct OpenSubdiv_Converter *converter,
+ const int face_index,
+ int *face_edges);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Edge relationships.
+
+ // Vertices the edge consists of.
+ void (*getEdgeVertices)(const struct OpenSubdiv_Converter* converter,
+ const int edge_index,
+ int edge_vertices[2]);
+ // Number of faces which are sharing the given edge.
+ int (*getNumEdgeFaces)(const struct OpenSubdiv_Converter* converter,
+ const int edge_index);
+ // Array of face indices which are sharing the given edge.
+ void (*getEdgeFaces)(const struct OpenSubdiv_Converter* converter,
+ const int edge,
+ int* edge_faces);
+ // Edge sharpness (aka crease).
+ float (*getEdgeSharpness)(const struct OpenSubdiv_Converter* converter,
+ const int edge_index);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Vertex relationships.
+
+ // Number of edges which are adjacent to the given vertex.
+ int (*getNumVertexEdges)(const struct OpenSubdiv_Converter* converter,
+ const int vertex_index);
+ // Array fo edge indices which are adjacent to the given vertex.
+ void (*getVertexEdges)(const struct OpenSubdiv_Converter* converter,
+ const int vertex_index,
+ int* vertex_edges);
+ // Number of faces which are adjacent to the given vertex.
+ int (*getNumVertexFaces)(const struct OpenSubdiv_Converter* converter,
+ const int vertex_index);
+ // Array fo face indices which are adjacent to the given vertex.
+ void (*getVertexFaces)(const struct OpenSubdiv_Converter* converter,
+ const int vertex_index,
+ int* vertex_faces);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Face-varying data.
+
+ /////////////////////////////////////
+ // UV coordinates.
+
+ // Number of UV layers.
+ int (*getNumUVLayers)(const struct OpenSubdiv_Converter* converter);
+
+ // We need some corner connectivity information, which might not be trivial
+ // to be gathered (might require multiple matching calculations per corver
+ // query).
+ // precalc() is called before any corner connectivity or UV coordinate is
+ // queried from the given layer, allowing converter to calculate and cache
+ // complex complex-to-calculate information.
+ // finish() is called after converter is done porting UV layer to OpenSubdiv,
+ // allowing to free cached data.
+ void (*precalcUVLayer)(const struct OpenSubdiv_Converter* converter,
+ const int layer_index);
+ void (*finishUVLayer)(const struct OpenSubdiv_Converter* converter);
+
+ // Get number of UV coordinates in the current layer (layer which was
+ // specified in precalcUVLayer().
+ int (*getNumUVCoordinates)(const struct OpenSubdiv_Converter* converter);
+ // For the given face index and its corner (known as loop in Blender)
+ // get corrsponding UV coordinate index.
+ int (*getFaceCornerUVIndex)(const struct OpenSubdiv_Converter* converter,
+ const int face_index,
+ const int corner_index);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // User data associated with this converter.
+
+ void (*freeUserData)(const struct OpenSubdiv_Converter* converter);
+ void* user_data;
} OpenSubdiv_Converter;
-OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr(
- OpenSubdiv_Converter *converter);
-
-void openSubdiv_deleteTopologyRefinerDescr(
- OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-/* TODO(sergey): Those calls are not strictly related to conversion.
- * needs some dedicated file perhaps.
- */
-
-int openSubdiv_topologyRefinerGetSubdivLevel(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-int openSubdiv_topologyRefinerGetNumVerts(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-int openSubdiv_topologyRefinerGetNumEdges(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-int openSubdiv_topologyRefinerGetNumFaces(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-int openSubdiv_topologyRefinerGetNumFaceVerts(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- int face);
-
-int openSubdiv_topologyRefnerCompareConverter(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- OpenSubdiv_Converter *converter);
-
#ifdef __cplusplus
}
#endif
-#endif /* __OPENSUBDIV_CONVERTER_CAPI_H__ */
+#endif /* OPENSUBDIV_CONVERTER_CAPI_H_ */
diff --git a/intern/opensubdiv/opensubdiv_device_context_cuda.cc b/intern/opensubdiv/opensubdiv_device_context_cuda.cc
deleted file mode 100644
index 46b66a6b35e..00000000000
--- a/intern/opensubdiv/opensubdiv_device_context_cuda.cc
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Adopted from OpenSubdiv with the following license:
- *
- * Copyright 2015 Pixar
- *
- * Licensed under the Apache License, Version 2.0 (the "Apache License")
- * with the following modification; you may not use this file except in
- * compliance with the Apache License and the following modification to it:
- * Section 6. Trademarks. is deleted and replaced with:
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor
- * and its affiliates, except as required to comply with Section 4(c) of
- * the License and to reproduce the content of the NOTICE file.
- *
- * You may obtain a copy of the Apache License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Apache License with the above modification is
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the Apache License for the specific
- * language governing permissions and limitations under the Apache License.
- */
-
-#ifdef OPENSUBDIV_HAS_CUDA
-
-#ifdef _MSC_VER
-# include "iso646.h"
-#endif
-
-#include "opensubdiv_device_context_cuda.h"
-
-#if defined(_WIN32)
-# include <windows.h>
-#elif defined(__APPLE__)
-# include <OpenGL/OpenGL.h>
-#else
-# include <X11/Xlib.h>
-# include <GL/glx.h>
-#endif
-
-#include <cstdio>
-#include <algorithm>
-#include <cuda.h>
-#include <cuda_runtime_api.h>
-#include <cuda_gl_interop.h>
-
-#define message(fmt, ...)
-//#define message(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
-#define error(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
-
-static int _GetCudaDeviceForCurrentGLContext()
-{
- // Find and use the CUDA device for the current GL context
- unsigned int interopDeviceCount = 0;
- int interopDevices[1];
- cudaError_t status = cudaGLGetDevices(&interopDeviceCount, interopDevices,
- 1, cudaGLDeviceListCurrentFrame);
- if (status == cudaErrorNoDevice or interopDeviceCount != 1) {
- message("CUDA no interop devices found.\n");
- return 0;
- }
- int device = interopDevices[0];
-
-#if defined(_WIN32)
- return device;
-
-#elif defined(__APPLE__)
- return device;
-
-#else // X11
- Display * display = glXGetCurrentDisplay();
- int screen = DefaultScreen(display);
- if (device != screen) {
- error("The CUDA interop device (%d) does not match "
- "the screen used by the current GL context (%d), "
- "which may cause slow performance on systems "
- "with multiple GPU devices.", device, screen);
- }
- message("CUDA init using device for current GL context: %d\n", device);
- return device;
-#endif
-}
-
-/* From "NVIDIA GPU Computing SDK 4.2/C/common/inc/cutil_inline_runtime.h": */
-
-/* Beginning of GPU Architecture definitions */
-inline int _ConvertSMVer2Cores_local(int major, int minor)
-{
- /* Defines for GPU Architecture types (using the SM version to determine
- * the # of cores per SM
- */
- typedef struct {
- int SM; /* 0xMm (hexidecimal notation),
- * M = SM Major version,
- * and m = SM minor version
- */
- int Cores;
- } sSMtoCores;
-
- sSMtoCores nGpuArchCoresPerSM[] =
- { { 0x10, 8 }, /* Tesla Generation (SM 1.0) G80 class */
- { 0x11, 8 }, /* Tesla Generation (SM 1.1) G8x class */
- { 0x12, 8 }, /* Tesla Generation (SM 1.2) G9x class */
- { 0x13, 8 }, /* Tesla Generation (SM 1.3) GT200 class */
- { 0x20, 32 }, /* Fermi Generation (SM 2.0) GF100 class */
- { 0x21, 48 }, /* Fermi Generation (SM 2.1) GF10x class */
- { 0x30, 192}, /* Fermi Generation (SM 3.0) GK10x class */
- { -1, -1 }
- };
-
- int index = 0;
- while (nGpuArchCoresPerSM[index].SM != -1) {
- if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) {
- return nGpuArchCoresPerSM[index].Cores;
- }
- index++;
- }
- printf("MapSMtoCores undefined SMversion %d.%d!\n", major, minor);
- return -1;
-}
-/* End of GPU Architecture definitions. */
-
-/* This function returns the best GPU (with maximum GFLOPS) */
-inline int cutGetMaxGflopsDeviceId()
-{
- int current_device = 0, sm_per_multiproc = 0;
- int max_compute_perf = 0, max_perf_device = -1;
- int device_count = 0, best_SM_arch = 0;
- int compat_major, compat_minor;
-
- cuDeviceGetCount(&device_count);
- /* Find the best major SM Architecture GPU device. */
- while (current_device < device_count) {
- cuDeviceComputeCapability(&compat_major, &compat_minor, current_device);
- if (compat_major > 0 && compat_major < 9999) {
- best_SM_arch = std::max(best_SM_arch, compat_major);
- }
- current_device++;
- }
-
- /* Find the best CUDA capable GPU device. */
- current_device = 0;
- while (current_device < device_count) {
- cuDeviceComputeCapability(&compat_major, &compat_minor, current_device);
- if (compat_major == 9999 && compat_minor == 9999) {
- sm_per_multiproc = 1;
- } else {
- sm_per_multiproc = _ConvertSMVer2Cores_local(compat_major,
- compat_minor);
- }
- int multi_processor_count;
- cuDeviceGetAttribute(&multi_processor_count,
- CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT,
- current_device);
- int clock_rate;
- cuDeviceGetAttribute(&clock_rate,
- CU_DEVICE_ATTRIBUTE_CLOCK_RATE,
- current_device);
- int compute_perf = multi_processor_count * sm_per_multiproc * clock_rate;
- if (compute_perf > max_compute_perf) {
- /* If we find GPU with SM major > 2, search only these */
- if (best_SM_arch > 2) {
- /* If our device==dest_SM_arch, choose this, or else pass. */
- if (compat_major == best_SM_arch) {
- max_compute_perf = compute_perf;
- max_perf_device = current_device;
- }
- } else {
- max_compute_perf = compute_perf;
- max_perf_device = current_device;
- }
- }
- ++current_device;
- }
- return max_perf_device;
-}
-
-bool CudaDeviceContext::HAS_CUDA_VERSION_4_0()
-{
-#ifdef OPENSUBDIV_HAS_CUDA
- static bool cudaInitialized = false;
- static bool cudaLoadSuccess = true;
- if (!cudaInitialized) {
- cudaInitialized = true;
-
-# ifdef OPENSUBDIV_HAS_CUEW
- cudaLoadSuccess = cuewInit(CUEW_INIT_CUDA) == CUEW_SUCCESS;
- if (!cudaLoadSuccess) {
- fprintf(stderr, "Loading CUDA failed.\n");
- }
-# endif
- // Need to initialize CUDA here so getting device
- // with the maximum FPLOS works fine.
- if (cuInit(0) == CUDA_SUCCESS) {
- // This is to deal with cases like NVidia Optimus,
- // when there might be CUDA library installed but
- // NVidia card is not being active.
- if (cutGetMaxGflopsDeviceId() < 0) {
- cudaLoadSuccess = false;
- }
- }
- else {
- cudaLoadSuccess = false;
- }
- }
- return cudaLoadSuccess;
-#else
- return false;
-#endif
-}
-
-CudaDeviceContext::CudaDeviceContext()
- : _initialized(false) {
-}
-
-CudaDeviceContext::~CudaDeviceContext() {
- cudaDeviceReset();
-}
-
-bool CudaDeviceContext::Initialize()
-{
- /* See if any cuda device is available. */
- int deviceCount = 0;
- cudaGetDeviceCount(&deviceCount);
- message("CUDA device count: %d\n", deviceCount);
- if (deviceCount <= 0) {
- return false;
- }
- cudaGLSetGLDevice(_GetCudaDeviceForCurrentGLContext());
- _initialized = true;
- return true;
-}
-
-#endif /* OPENSUBDIV_HAS_CUDA */
diff --git a/intern/opensubdiv/opensubdiv_device_context_cuda.h b/intern/opensubdiv/opensubdiv_device_context_cuda.h
deleted file mode 100644
index eb30b76f507..00000000000
--- a/intern/opensubdiv/opensubdiv_device_context_cuda.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Adopted from OpenSubdiv with the following license:
- *
- * Copyright 2013 Pixar
- *
- * Licensed under the Apache License, Version 2.0 (the "Apache License")
- * with the following modification; you may not use this file except in
- * compliance with the Apache License and the following modification to it:
- * Section 6. Trademarks. is deleted and replaced with:
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor
- * and its affiliates, except as required to comply with Section 4(c) of
- * the License and to reproduce the content of the NOTICE file.
- *
- * You may obtain a copy of the Apache License at
- *
- * http: //www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Apache License with the above modification is
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the Apache License for the specific
- * language governing permissions and limitations under the Apache License.
- *
- */
-
-#ifndef __OPENSUBDIV_DEV_CE_CONTEXT_CUDA_H__
-#define __OPENSUBDIV_DEV_CE_CONTEXT_CUDA_H__
-
-struct ID3D11Device;
-
-class CudaDeviceContext {
-public:
- CudaDeviceContext();
- ~CudaDeviceContext();
-
- static bool HAS_CUDA_VERSION_4_0();
-
- /* Initialze cuda device from the current GL context. */
- bool Initialize();
-
- /* Initialze cuda device from the ID3D11Device/ */
- bool Initialize(ID3D11Device *device);
-
- /* Returns true if the cuda device has already been initialized. */
- bool IsInitialized() const {
- return _initialized;
- }
-private:
- bool _initialized;
-};
-
-#endif /* __OPENSUBDIV_DEV_CE_CONTEXT_OPENCL_H__ */
diff --git a/intern/opensubdiv/opensubdiv_device_context_opencl.cc b/intern/opensubdiv/opensubdiv_device_context_opencl.cc
deleted file mode 100644
index 4cacdc9e845..00000000000
--- a/intern/opensubdiv/opensubdiv_device_context_opencl.cc
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Adopted from OpenSubdiv with the following license:
- *
- * Copyright 2015 Pixar
- *
- * Licensed under the Apache License, Version 2.0 (the "Apache License")
- * with the following modification; you may not use this file except in
- * compliance with the Apache License and the following modification to it:
- * Section 6. Trademarks. is deleted and replaced with:
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor
- * and its affiliates, except as required to comply with Section 4(c) of
- * the License and to reproduce the content of the NOTICE file.
- *
- * You may obtain a copy of the Apache License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Apache License with the above modification is
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the Apache License for the specific
- * language governing permissions and limitations under the Apache License.
- *
- */
-
-#ifdef OPENSUBDIV_HAS_OPENCL
-
-#ifdef _MSC_VER
-# include "iso646.h"
-#endif
-
-#include "opensubdiv_device_context_opencl.h"
-
-#if defined(_WIN32)
-# include <windows.h>
-#elif defined(__APPLE__)
-# include <OpenGL/OpenGL.h>
-#else
-# include <GL/glx.h>
-#endif
-
-#include <cstdio>
-#include <cstring>
-#include <string>
-
-#define message(...) // fprintf(stderr, __VA_ARGS__)
-#define error(...) fprintf(stderr, __VA_ARGS__)
-
-/* Returns the first found platform. */
-static cl_platform_id findPlatform() {
- cl_uint numPlatforms;
- cl_int ciErrNum = clGetPlatformIDs(0, NULL, &numPlatforms);
- if (ciErrNum != CL_SUCCESS) {
- error("Error %d in clGetPlatformIDs call.\n", ciErrNum);
- return NULL;
- }
- if (numPlatforms == 0) {
- error("No OpenCL platform found.\n");
- return NULL;
- }
- cl_platform_id *clPlatformIDs = new cl_platform_id[numPlatforms];
- ciErrNum = clGetPlatformIDs(numPlatforms, clPlatformIDs, NULL);
- char chBuffer[1024];
- for (cl_uint i = 0; i < numPlatforms; ++i) {
- ciErrNum = clGetPlatformInfo(clPlatformIDs[i], CL_PLATFORM_NAME,
- 1024, chBuffer,NULL);
- if (ciErrNum == CL_SUCCESS) {
- cl_platform_id platformId = clPlatformIDs[i];
- delete[] clPlatformIDs;
- return platformId;
- }
- }
- delete[] clPlatformIDs;
- return NULL;
-}
-
-/* Return. the device in clDevices which supports the extension. */
-static int findExtensionSupportedDevice(cl_device_id *clDevices,
- int numDevices,
- const char *extensionName) {
- /* Find a device that supports sharing with GL/D3D11
- * (SLI / X-fire configurations)
- */
- cl_int ciErrNum;
- for (int i = 0; i < numDevices; ++i) {
- /* Get extensions string size. */
- size_t extensionSize;
- ciErrNum = clGetDeviceInfo(clDevices[i],
- CL_DEVICE_EXTENSIONS, 0, NULL,
- &extensionSize);
- if (ciErrNum != CL_SUCCESS) {
- error("Error %d in clGetDeviceInfo\n", ciErrNum);
- return -1;
- }
- if (extensionSize > 0) {
- /* Get extensions string. */
- char *extensions = new char[extensionSize];
- ciErrNum = clGetDeviceInfo(clDevices[i], CL_DEVICE_EXTENSIONS,
- extensionSize, extensions,
- &extensionSize);
- if (ciErrNum != CL_SUCCESS) {
- error("Error %d in clGetDeviceInfo\n", ciErrNum);
- delete[] extensions;
- continue;
- }
- std::string extString(extensions);
- delete[] extensions;
- /* Parse string. This is bit deficient since the extentions
- * is space separated.
- *
- * The actual string would be "cl_khr_d3d11_sharing"
- * or "cl_nv_d3d11_sharing"
- */
- if (extString.find(extensionName) != std::string::npos) {
- return i;
- }
- }
- }
- return -1;
-}
-
-CLDeviceContext::CLDeviceContext()
- : _clContext(NULL),
- _clCommandQueue(NULL) {
-}
-
-CLDeviceContext::~CLDeviceContext() {
- if (_clCommandQueue)
- clReleaseCommandQueue(_clCommandQueue);
- if (_clContext)
- clReleaseContext(_clContext);
-}
-
-bool CLDeviceContext::HAS_CL_VERSION_1_1()
-{
-#ifdef OPENSUBDIV_HAS_CLEW
- static bool clewInitialized = false;
- static bool clewLoadSuccess;
- if (not clewInitialized) {
- clewInitialized = true;
- clewLoadSuccess = clewInit() == CLEW_SUCCESS;
- if (!clewLoadSuccess) {
- error("Loading OpenCL failed.\n");
- }
- }
- return clewLoadSuccess;
-#endif
- return true;
-}
-
-bool CLDeviceContext::Initialize()
-{
-#ifdef OPENSUBDIV_HAS_CLEW
- if (!clGetPlatformIDs) {
- error("Error clGetPlatformIDs function not bound.\n");
- return false;
- }
-#endif
- cl_int ciErrNum;
- cl_platform_id cpPlatform = findPlatform();
-
-#if defined(_WIN32)
- cl_context_properties props[] = {
- CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
- CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
- CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform,
- 0
- };
-#elif defined(__APPLE__)
- CGLContextObj kCGLContext = CGLGetCurrentContext();
- CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext);
- cl_context_properties props[] = {
- CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, (cl_context_properties)kCGLShareGroup,
- 0
- };
-#else
- cl_context_properties props[] = {
- CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
- CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
- CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform,
- 0
- };
-#endif
-
-#if defined(__APPLE__)
- _clContext = clCreateContext(props, 0, NULL, clLogMessagesToStdoutAPPLE,
- NULL, &ciErrNum);
- if (ciErrNum != CL_SUCCESS) {
- error("Error %d in clCreateContext\n", ciErrNum);
- return false;
- }
-
- size_t devicesSize = 0;
- clGetGLContextInfoAPPLE(_clContext, kCGLContext,
- CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE,
- 0, NULL, &devicesSize);
- int numDevices = int(devicesSize / sizeof(cl_device_id));
- if (numDevices == 0) {
- error("No sharable devices.\n");
- return false;
- }
- cl_device_id *clDevices = new cl_device_id[numDevices];
- clGetGLContextInfoAPPLE(_clContext, kCGLContext,
- CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE,
- numDevices * sizeof(cl_device_id), clDevices, NULL);
- int clDeviceUsed = 0;
-
-#else // not __APPLE__
- /* Get the number of GPU devices available to the platform. */
- cl_uint numDevices = 0;
- clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
- if (numDevices == 0) {
- error("No CL GPU device found.\n");
- return false;
- }
-
- /* Create the device list. */
- cl_device_id *clDevices = new cl_device_id[numDevices];
- clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, numDevices, clDevices, NULL);
-
- const char *extension = "cl_khr_gl_sharing";
- int clDeviceUsed = findExtensionSupportedDevice(clDevices, numDevices,
- extension);
-
- if (clDeviceUsed < 0) {
- error("No device found that supports CL/GL context sharing\n");
- delete[] clDevices;
- return false;
- }
-
- _clContext = clCreateContext(props, 1, &clDevices[clDeviceUsed],
- NULL, NULL, &ciErrNum);
-#endif // not __APPLE__
- if (ciErrNum != CL_SUCCESS) {
- error("Error %d in clCreateContext\n", ciErrNum);
- delete[] clDevices;
- return false;
- }
- _clCommandQueue = clCreateCommandQueue(_clContext, clDevices[clDeviceUsed],
- 0, &ciErrNum);
- delete[] clDevices;
- if (ciErrNum != CL_SUCCESS) {
- error("Error %d in clCreateCommandQueue\n", ciErrNum);
- return false;
- }
- return true;
-}
-
-#endif /* OPENSUBDIV_HAS_OPENCL */
diff --git a/intern/opensubdiv/opensubdiv_device_context_opencl.h b/intern/opensubdiv/opensubdiv_device_context_opencl.h
deleted file mode 100644
index a640dce1f07..00000000000
--- a/intern/opensubdiv/opensubdiv_device_context_opencl.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Adopted from OpenSubdiv with the following license:
- *
- * Copyright 2015 Pixar
- *
- * Licensed under the Apache License, Version 2.0 (the "Apache License")
- * with the following modification; you may not use this file except in
- * compliance with the Apache License and the following modification to it:
- * Section 6. Trademarks. is deleted and replaced with:
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor
- * and its affiliates, except as required to comply with Section 4(c) of
- * the License and to reproduce the content of the NOTICE file.
- *
- * You may obtain a copy of the Apache License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Apache License with the above modification is
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the Apache License for the specific
- * language governing permissions and limitations under the Apache License.
- *
- */
-
-#ifndef __OPENSUBDIV_DEV_CE_CONTEXT_OPENCL_H__
-#define __OPENSUBDIV_DEV_CE_CONTEXT_OPENCL_H__
-
-#include <opensubdiv/osd/opencl.h>
-
-class CLDeviceContext {
-public:
- CLDeviceContext();
- ~CLDeviceContext();
-
- static bool HAS_CL_VERSION_1_1 ();
-
- bool Initialize();
-
- bool IsInitialized() const {
- return (_clContext != NULL);
- }
-
- cl_context GetContext() const {
- return _clContext;
- }
- cl_command_queue GetCommandQueue() const {
- return _clCommandQueue;
- }
-
-protected:
- cl_context _clContext;
- cl_command_queue _clCommandQueue;
-};
-
-#endif /* __OPENSUBDIV_DEV_CE_CONTEXT_OPENCL_H__ */
diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.cc b/intern/opensubdiv/opensubdiv_evaluator_capi.cc
deleted file mode 100644
index c4a128213dd..00000000000
--- a/intern/opensubdiv/opensubdiv_evaluator_capi.cc
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "opensubdiv_capi.h"
-
-#include <cstdio>
-#include <vector>
-
-#ifdef _MSC_VER
-# include "iso646.h"
-#endif
-
-#include <opensubdiv/far/patchMap.h>
-#include <opensubdiv/far/patchTable.h>
-#include <opensubdiv/far/patchTableFactory.h>
-#include <opensubdiv/osd/cpuEvaluator.h>
-#include <opensubdiv/osd/cpuPatchTable.h>
-#include <opensubdiv/osd/cpuVertexBuffer.h>
-#include <opensubdiv/osd/mesh.h>
-#include <opensubdiv/osd/types.h>
-
-#include "opensubdiv_intern.h"
-
-#include "MEM_guardedalloc.h"
-
-using OpenSubdiv::Osd::BufferDescriptor;
-using OpenSubdiv::Osd::PatchCoord;
-using OpenSubdiv::Far::PatchMap;
-using OpenSubdiv::Far::PatchTable;
-using OpenSubdiv::Far::PatchTableFactory;
-using OpenSubdiv::Far::StencilTable;
-using OpenSubdiv::Far::StencilTableFactory;
-using OpenSubdiv::Far::TopologyRefiner;
-
-namespace {
-
-/* Helper class to wrap numerous of patch coords into a buffer.
- * Used to pass coordinates to the CPU evaluator. Other evaluators
- * are not supported.
- */
-class PatchCoordBuffer : public std::vector<PatchCoord> {
-public:
- static PatchCoordBuffer *Create(int size)
- {
- PatchCoordBuffer *buffer = new PatchCoordBuffer();
- buffer->resize(size);
- return buffer;
- }
- PatchCoord *BindCpuBuffer() {
- return (PatchCoord*)&(*this)[0];
- }
- int GetNumVertices() {
- return size();
- }
- void UpdateData(const PatchCoord *patch_coords,
- int num_patch_coords)
- {
- memcpy(&(*this)[0],
- (void*)patch_coords,
- num_patch_coords * sizeof(PatchCoord));
- }
-};
-
-/* Helper class to wrap single of patch coord into a buffer.
- * Used to pass coordinates to the CPU evaluator. Other evaluators
- * are not supported.
- */
-class SinglePatchCoordBuffer {
-public:
- SinglePatchCoordBuffer() {
- }
- SinglePatchCoordBuffer(const PatchCoord& patch_coord)
- : patch_coord_(patch_coord){
- }
- static SinglePatchCoordBuffer *Create()
- {
- SinglePatchCoordBuffer *buffer = new SinglePatchCoordBuffer();
- return buffer;
- }
- PatchCoord *BindCpuBuffer() {
- return (PatchCoord*)&patch_coord_;
- }
- int GetNumVertices() {
- return 1;
- }
- void UpdateData(const PatchCoord& patch_coord)
- {
- patch_coord_ = patch_coord;
- }
-protected:
- PatchCoord patch_coord_;
-};
-
-/* Helper class which is aimed to be used in cases when buffer
- * is small enough and better to be allocated in stack rather
- * than in heap.
- *
- * TODO(sergey): Check if bare arrays could be used by CPU evalautor.
- */
-template <int element_size, int num_verts>
-class StackAllocatedBuffer {
-public:
- static PatchCoordBuffer *Create(int /*size*/)
- {
- StackAllocatedBuffer<element_size, num_verts> *buffer =
- new StackAllocatedBuffer<element_size, num_verts>();
- return buffer;
- }
- float *BindCpuBuffer() {
- return &data_[0];
- }
- int GetNumVertices() {
- return num_verts;
- }
- /* TODO(sergey): Support UpdateData(). */
-protected:
- float data_[element_size * num_verts];
-};
-
-/* Volatile evaluator which can be used from threads.
- *
- * TODO(sergey): Make it possible to evaluate coordinates in chuncks.
- */
-template<typename SRC_VERTEX_BUFFER,
- typename EVAL_VERTEX_BUFFER,
- typename STENCIL_TABLE,
- typename PATCH_TABLE,
- typename EVALUATOR,
- typename DEVICE_CONTEXT = void>
-class VolatileEvalOutput {
-public:
- typedef OpenSubdiv::Osd::EvaluatorCacheT<EVALUATOR> EvaluatorCache;
-
- VolatileEvalOutput(const StencilTable *vertex_stencils,
- const StencilTable *varying_stencils,
- int num_coarse_verts,
- int num_total_verts,
- const PatchTable *patch_table,
- EvaluatorCache *evaluator_cache = NULL,
- DEVICE_CONTEXT *device_context = NULL)
- : src_desc_( /*offset*/ 0, /*length*/ 3, /*stride*/ 3),
- src_varying_desc_(/*offset*/ 0, /*length*/ 3, /*stride*/ 3),
- num_coarse_verts_(num_coarse_verts),
- evaluator_cache_ (evaluator_cache),
- device_context_(device_context)
- {
- using OpenSubdiv::Osd::convertToCompatibleStencilTable;
- src_data_ = SRC_VERTEX_BUFFER::Create(3, num_total_verts, device_context_);
- src_varying_data_ = SRC_VERTEX_BUFFER::Create(3, num_total_verts, device_context_);
- patch_table_ = PATCH_TABLE::Create(patch_table, device_context_);
- patch_coords_ = NULL;
- vertex_stencils_ = convertToCompatibleStencilTable<STENCIL_TABLE>(vertex_stencils,
- device_context_);
- varying_stencils_ = convertToCompatibleStencilTable<STENCIL_TABLE>(varying_stencils,
- device_context_);
- }
-
- ~VolatileEvalOutput()
- {
- delete src_data_;
- delete src_varying_data_;
- delete patch_table_;
- delete vertex_stencils_;
- delete varying_stencils_;
- }
-
- void UpdateData(const float *src, int start_vertex, int num_vertices)
- {
- src_data_->UpdateData(src, start_vertex, num_vertices, device_context_);
- }
-
- void UpdateVaryingData(const float *src, int start_vertex, int num_vertices)
- {
- src_varying_data_->UpdateData(src,
- start_vertex,
- num_vertices,
- device_context_);
- }
-
- void Refine()
- {
- BufferDescriptor dst_desc = src_desc_;
- dst_desc.offset += num_coarse_verts_ * src_desc_.stride;
-
- const EVALUATOR *eval_instance =
- OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
- src_desc_,
- dst_desc,
- device_context_);
-
- EVALUATOR::EvalStencils(src_data_, src_desc_,
- src_data_, dst_desc,
- vertex_stencils_,
- eval_instance,
- device_context_);
-
- dst_desc = src_varying_desc_;
- dst_desc.offset += num_coarse_verts_ * src_varying_desc_.stride;
- eval_instance =
- OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
- src_varying_desc_,
- dst_desc,
- device_context_);
-
- EVALUATOR::EvalStencils(src_varying_data_, src_varying_desc_,
- src_varying_data_, dst_desc,
- varying_stencils_,
- eval_instance,
- device_context_);
- }
-
- void EvalPatchCoord(PatchCoord& patch_coord, float P[3])
- {
- StackAllocatedBuffer<6, 1> vertex_data;
- BufferDescriptor vertex_desc(0, 3, 6);
- SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
- const EVALUATOR *eval_instance =
- OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
- src_desc_,
- vertex_desc,
- device_context_);
- EVALUATOR::EvalPatches(src_data_, src_desc_,
- &vertex_data, vertex_desc,
- patch_coord_buffer.GetNumVertices(),
- &patch_coord_buffer,
- patch_table_, eval_instance, device_context_);
- float *refined_verts = vertex_data.BindCpuBuffer();
- memcpy(P, refined_verts, sizeof(float) * 3);
- }
-
- void EvalPatchesWithDerivatives(PatchCoord& patch_coord,
- float P[3],
- float dPdu[3],
- float dPdv[3])
- {
- StackAllocatedBuffer<6, 1> vertex_data, derivatives;
- BufferDescriptor vertex_desc(0, 3, 6),
- du_desc(0, 3, 6),
- dv_desc(3, 3, 6);
- SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
- const EVALUATOR *eval_instance =
- OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
- src_desc_,
- vertex_desc,
- du_desc,
- dv_desc,
- device_context_);
- EVALUATOR::EvalPatches(src_data_, src_desc_,
- &vertex_data, vertex_desc,
- &derivatives, du_desc,
- &derivatives, dv_desc,
- patch_coord_buffer.GetNumVertices(),
- &patch_coord_buffer,
- patch_table_, eval_instance, device_context_);
- float *refined_verts = vertex_data.BindCpuBuffer();
- memcpy(P, refined_verts, sizeof(float) * 3);
- if (dPdu != NULL || dPdv != NULL) {
- float *refined_drivatives = derivatives.BindCpuBuffer();
- if (dPdu) {
- memcpy(dPdu, refined_drivatives, sizeof(float) * 3);
- }
- if (dPdv) {
- memcpy(dPdv, refined_drivatives + 3, sizeof(float) * 3);
- }
- }
- }
-
- void EvalPatchVarying(PatchCoord& patch_coord,
- float varying[3]) {
- StackAllocatedBuffer<3, 1> varying_data;
- BufferDescriptor varying_desc(0, 3, 3);
- SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
- EVALUATOR const *eval_instance =
- OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
- src_varying_desc_,
- varying_desc,
- device_context_);
-
- EVALUATOR::EvalPatches(src_varying_data_, src_varying_desc_,
- &varying_data, varying_desc,
- patch_coord_buffer.GetNumVertices(),
- &patch_coord_buffer,
- patch_table_, eval_instance, device_context_);
- float *refined_varying = varying_data.BindCpuBuffer();
- memcpy(varying, refined_varying, sizeof(float) * 3);
- }
-private:
- SRC_VERTEX_BUFFER *src_data_;
- SRC_VERTEX_BUFFER *src_varying_data_;
- PatchCoordBuffer *patch_coords_;
- PATCH_TABLE *patch_table_;
- BufferDescriptor src_desc_;
- BufferDescriptor src_varying_desc_;
- int num_coarse_verts_;
-
- const STENCIL_TABLE *vertex_stencils_;
- const STENCIL_TABLE *varying_stencils_;
-
- EvaluatorCache *evaluator_cache_;
- DEVICE_CONTEXT *device_context_;
-};
-
-} /* namespace */
-
-typedef VolatileEvalOutput<OpenSubdiv::Osd::CpuVertexBuffer,
- OpenSubdiv::Osd::CpuVertexBuffer,
- OpenSubdiv::Far::StencilTable,
- OpenSubdiv::Osd::CpuPatchTable,
- OpenSubdiv::Osd::CpuEvaluator> CpuEvalOutput;
-
-typedef struct OpenSubdiv_EvaluatorDescr {
- CpuEvalOutput *eval_output;
- const PatchMap *patch_map;
- const PatchTable *patch_table;
-} OpenSubdiv_EvaluatorDescr;
-
-OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr(
- OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- int subsurf_level)
-{
- /* TODO(sergey): Look into re-using refiner with GLMesh. */
- TopologyRefiner *refiner = (TopologyRefiner *)topology_refiner;
- if(refiner == NULL) {
- /* Happens on bad topology. */
- return NULL;
- }
-
- const StencilTable *vertex_stencils = NULL;
- const StencilTable *varying_stencils = NULL;
- int num_total_verts = 0;
-
- /* Apply uniform refinement to the mesh so that we can use the
- * limit evaluation API features.
- */
- TopologyRefiner::UniformOptions options(subsurf_level);
- refiner->RefineUniform(options);
-
- /* Generate stencil table to update the bi-cubic patches control
- * vertices after they have been re-posed (both for vertex & varying
- * interpolation).
- */
- StencilTableFactory::Options soptions;
- soptions.generateOffsets = true;
- soptions.generateIntermediateLevels = false;
-
- vertex_stencils = StencilTableFactory::Create(*refiner, soptions);
-
- soptions.interpolationMode = StencilTableFactory::INTERPOLATE_VARYING;
- varying_stencils = StencilTableFactory::Create(*refiner, soptions);
-
- /* Generate bi-cubic patch table for the limit surface. */
- PatchTableFactory::Options poptions;
- poptions.SetEndCapType(PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS);
-
- const PatchTable *patch_table = PatchTableFactory::Create(*refiner, poptions);
-
- /* Append local points stencils. */
- /* TODO(sergey): Do we really need to worry about local points stencils? */
- if (const StencilTable *local_point_stencil_table =
- patch_table->GetLocalPointStencilTable())
- {
- const StencilTable *table =
- StencilTableFactory::AppendLocalPointStencilTable(*refiner,
- vertex_stencils,
- local_point_stencil_table);
- delete vertex_stencils;
- vertex_stencils = table;
- }
- if (const StencilTable *local_point_varying_stencil_table =
- patch_table->GetLocalPointVaryingStencilTable())
- {
- const StencilTable *table =
- StencilTableFactory::AppendLocalPointStencilTable(*refiner,
- varying_stencils,
- local_point_varying_stencil_table);
- delete varying_stencils;
- varying_stencils = table;
- }
-
- /* Total number of vertices = coarse verts + refined verts + gregory basis verts. */
- num_total_verts = vertex_stencils->GetNumControlVertices() +
- vertex_stencils->GetNumStencils();
-
- const int num_coarse_verts = refiner->GetLevel(0).GetNumVertices();
-
- CpuEvalOutput *eval_output = new CpuEvalOutput(vertex_stencils,
- varying_stencils,
- num_coarse_verts,
- num_total_verts,
- patch_table);
-
- OpenSubdiv::Far::PatchMap *patch_map = new PatchMap(*patch_table);
-
- OpenSubdiv_EvaluatorDescr *evaluator_descr;
- evaluator_descr = OBJECT_GUARDED_NEW(OpenSubdiv_EvaluatorDescr);
- evaluator_descr->eval_output = eval_output;
- evaluator_descr->patch_map = patch_map;
- evaluator_descr->patch_table = patch_table;
-
- /* TOOD(sergey): Look into whether w've got duplicated stencils arrays. */
- delete varying_stencils;
- delete vertex_stencils;
-
- delete refiner;
-
- return evaluator_descr;
-}
-
-void openSubdiv_deleteEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr)
-{
- delete evaluator_descr->eval_output;
- delete evaluator_descr->patch_map;
- delete evaluator_descr->patch_table;
- OBJECT_GUARDED_DELETE(evaluator_descr, OpenSubdiv_EvaluatorDescr);
-}
-
-void openSubdiv_setEvaluatorCoarsePositions(OpenSubdiv_EvaluatorDescr *evaluator_descr,
- float *positions,
- int start_vert,
- int num_verts)
-{
- /* TODO(sergey): Add sanity check on indices. */
- evaluator_descr->eval_output->UpdateData(positions, start_vert, num_verts);
- /* TODO(sergey): Consider moving this to a separate call,
- * so we can updatwe coordinates in chunks.
- */
- evaluator_descr->eval_output->Refine();
-}
-
-void openSubdiv_setEvaluatorVaryingData(OpenSubdiv_EvaluatorDescr *evaluator_descr,
- float *varying_data,
- int start_vert,
- int num_verts)
-{
- /* TODO(sergey): Add sanity check on indices. */
- evaluator_descr->eval_output->UpdateVaryingData(varying_data, start_vert, num_verts);
- /* TODO(sergey): Get rid of this ASAP. */
- evaluator_descr->eval_output->Refine();
-}
-
-void openSubdiv_evaluateLimit(OpenSubdiv_EvaluatorDescr *evaluator_descr,
- int osd_face_index,
- float face_u, float face_v,
- float P[3],
- float dPdu[3],
- float dPdv[3])
-{
- assert((face_u >= 0.0f) && (face_u <= 1.0f) && (face_v >= 0.0f) && (face_v <= 1.0f));
- const PatchTable::PatchHandle *handle =
- evaluator_descr->patch_map->FindPatch(osd_face_index, face_u, face_v);
- PatchCoord patch_coord(*handle, face_u, face_v);
- if (dPdu != NULL || dPdv != NULL) {
- evaluator_descr->eval_output->EvalPatchesWithDerivatives(patch_coord,
- P,
- dPdu,
- dPdv);
- }
- else {
- evaluator_descr->eval_output->EvalPatchCoord(patch_coord, P);
- }
-}
-
-void openSubdiv_evaluateVarying(OpenSubdiv_EvaluatorDescr *evaluator_descr,
- int osd_face_index,
- float face_u, float face_v,
- float varying[3])
-{
- assert((face_u >= 0.0f) && (face_u <= 1.0f) && (face_v >= 0.0f) && (face_v <= 1.0f));
- const PatchTable::PatchHandle *handle =
- evaluator_descr->patch_map->FindPatch(osd_face_index, face_u, face_v);
- PatchCoord patch_coord(*handle, face_u, face_v);
- evaluator_descr->eval_output->EvalPatchVarying(patch_coord, varying);
-}
diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.h b/intern/opensubdiv/opensubdiv_evaluator_capi.h
new file mode 100644
index 00000000000..07a55cfd349
--- /dev/null
+++ b/intern/opensubdiv/opensubdiv_evaluator_capi.h
@@ -0,0 +1,117 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_EVALUATOR_CAPI_H_
+#define OPENSUBDIV_EVALUATOR_CAPI_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct OpenSubdiv_EvaluatorInternal;
+struct OpenSubdiv_TopologyRefiner;
+
+typedef struct OpenSubdiv_Evaluator {
+ // Set coarse positions from a continuous array of coordinates.
+ void (*setCoarsePositions)(struct OpenSubdiv_Evaluator* evaluator,
+ const float* positions,
+ const int start_vertex_index,
+ const int num_vertices);
+ // Set varying data from a continuous array of data.
+ void (*setVaryingData)(struct OpenSubdiv_Evaluator* evaluator,
+ const float* varying_data,
+ const int start_vertex_index, const int num_vertices);
+ // Set face varying data from a continuous array of data.
+ //
+ // TODO(sergey): Find a better name for vertex here. It is not the vertex of
+ // geometry, but a vertex of UV map.
+ void (*setFaceVaryingData)(struct OpenSubdiv_Evaluator* evaluator,
+ const float* face_varying_data,
+ const int start_vertex_index,
+ const int num_vertices);
+
+ // Set coarse vertex position from a continuous memory buffer where
+ // first coordinate starts at offset of `start_offset` and there is `stride`
+ // bytes between adjacent vertex coordinates.
+ void (*setCoarsePositionsFromBuffer)(struct OpenSubdiv_Evaluator* evaluator,
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices);
+ // Set varying data from a continuous memory buffer where
+ // first coordinate starts at offset of `start_offset` and there is `stride`
+ // bytes between adjacent vertex coordinates.
+ void (*setVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator* evaluator,
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices);
+ // Set face varying data from a continuous memory buffer where
+ // first coordinate starts at offset of `start_offset` and there is `stride`
+ // bytes between adjacent vertex coordinates.
+ //
+ // TODO(sergey): Find a better name for vertex here. It is not the vertex of
+ // geometry, but a vertex of UV map.
+ void (*setFaceVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator* evaluator,
+ const void* buffer,
+ const int start_offset,
+ const int stride,
+ const int start_vertex_index,
+ const int num_vertices);
+
+ // Refine after coarse positions update.
+ void (*refine)(struct OpenSubdiv_Evaluator* evaluator);
+
+ // Evaluate given ptex face at given bilinear coordinate.
+ // If derivatives are NULL, they will not be evaluated.
+ void (*evaluateLimit)(struct OpenSubdiv_Evaluator* evaluator,
+ const int ptex_face_index,
+ float face_u, float face_v,
+ float P[3], float dPdu[3], float dPdv[3]);
+
+ // Evaluate varying data at a given bilinear coordinate of given ptex face.
+ void (*evaluateVarying)(struct OpenSubdiv_Evaluator* evaluator,
+ const int ptex_face_index,
+ float face_u, float face_v,
+ float varying[3]);
+
+ // Evaluate face-varying data at a given bilinear coordinate of given
+ // ptex face.
+ void (*evaluateFaceVarying)(struct OpenSubdiv_Evaluator* evaluator,
+ const int ptex_face_index,
+ float face_u, float face_v,
+ float face_varying[2]);
+
+ // Internal storage for the use in this module only.
+ //
+ // This is where actual OpenSubdiv's evaluator is living.
+ struct OpenSubdiv_EvaluatorInternal* internal;
+} OpenSubdiv_Evaluator;
+
+OpenSubdiv_Evaluator* openSubdiv_createEvaluatorFromTopologyRefiner(
+ struct OpenSubdiv_TopologyRefiner* topology_refiner);
+
+void openSubdiv_deleteEvaluator(OpenSubdiv_Evaluator* evaluator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // OPENSUBDIV_EVALUATOR_CAPI_H_
diff --git a/intern/opensubdiv/opensubdiv_gl_mesh_capi.h b/intern/opensubdiv/opensubdiv_gl_mesh_capi.h
new file mode 100644
index 00000000000..971f6b9dcd3
--- /dev/null
+++ b/intern/opensubdiv/opensubdiv_gl_mesh_capi.h
@@ -0,0 +1,92 @@
+// Copyright 2013 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_CAPI_GL_MESH_CAPI_H_
+#define OPENSUBDIV_CAPI_GL_MESH_CAPI_H_
+
+#include <stdint.h> // for bool
+
+#include "opensubdiv_capi_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct OpenSubdiv_GLMeshInternal;
+
+// Mesh which is displayable in OpenGL context.
+typedef struct OpenSubdiv_GLMesh {
+ //////////////////////////////////////////////////////////////////////////////
+ // Subdivision/topology part.
+
+ // Returns the GL index buffer containing the patch control vertices.
+ unsigned int (*getPatchIndexBuffer)(struct OpenSubdiv_GLMesh* gl_mesh);
+
+ // Bind GL buffer which contains vertices (VBO).
+ // TODO(sergey): Is this a coarse vertices?
+ void (*bindVertexBuffer)(struct OpenSubdiv_GLMesh* gl_mesh);
+
+ // Set coarse positions from a continuous array of coordinates.
+ void (*setCoarsePositions)(struct OpenSubdiv_GLMesh* gl_mesh,
+ const float* positions,
+ const int start_vertex,
+ const int num_vertices);
+ // TODO(sergey): setCoarsePositionsFromBuffer().
+
+ // Refine after coarse positions update.
+ void (*refine)(struct OpenSubdiv_GLMesh* gl_mesh);
+
+ // Synchronize after coarse positions update and refine.
+ void (*synchronize)(struct OpenSubdiv_GLMesh* gl_mesh);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Drawing part.
+
+ // Prepare mesh for display.
+ void (*prepareDraw)(struct OpenSubdiv_GLMesh* gl_mesh,
+ const bool use_osd_glsl,
+ const int active_uv_index);
+
+ // Draw given range of patches.
+ //
+ // If fill_quads is false, then patches are drawn in wireframe.
+ void (*drawPatches)(struct OpenSubdiv_GLMesh *gl_mesh,
+ const bool fill_quads,
+ const int start_patch, const int num_patches);
+
+ // Internal storage for the use in this module only.
+ //
+ // Tease: This contains an actual OpenSubdiv's Mesh object.
+ struct OpenSubdiv_GLMeshInternal* internal;
+} OpenSubdiv_GLMesh;
+
+OpenSubdiv_GLMesh* openSubdiv_createOsdGLMeshFromTopologyRefiner(
+ struct OpenSubdiv_TopologyRefiner* topology_refiner,
+ eOpenSubdivEvaluator evaluator_type);
+
+void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh);
+
+// Global resources needed for GL mesh drawing.
+bool openSubdiv_initGLMeshDrawingResources(void);
+void openSubdiv_deinitGLMeshDrawingResources(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // OPENSUBDIV_CAPI_GL_MESH_CAPI_H_
diff --git a/intern/opensubdiv/opensubdiv_gpu_capi.cc b/intern/opensubdiv/opensubdiv_gpu_capi.cc
deleted file mode 100644
index 7d8085c1ff5..00000000000
--- a/intern/opensubdiv/opensubdiv_gpu_capi.cc
+++ /dev/null
@@ -1,787 +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) 2013 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "opensubdiv_capi.h"
-
-#ifdef _MSC_VER
-# include "iso646.h"
-#endif
-
-#include <cstdio>
-#include <cmath>
-#include <GL/glew.h>
-
-#include <opensubdiv/osd/glMesh.h>
-
-#ifdef OPENSUBDIV_HAS_CUDA
-# include <opensubdiv/osd/cudaGLVertexBuffer.h>
-#endif /* OPENSUBDIV_HAS_CUDA */
-
-#include <opensubdiv/osd/cpuGLVertexBuffer.h>
-#include <opensubdiv/osd/cpuEvaluator.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "opensubdiv_capi.h"
-#include "opensubdiv_topology_refiner.h"
-
-using OpenSubdiv::Osd::GLMeshInterface;
-
-extern "C" char datatoc_gpu_shader_opensubdiv_vertex_glsl[];
-extern "C" char datatoc_gpu_shader_opensubdiv_geometry_glsl[];
-extern "C" char datatoc_gpu_shader_opensubdiv_fragment_glsl[];
-
-/* TODO(sergey): This is bit of bad level calls :S */
-extern "C" {
-void copy_m3_m3(float m1[3][3], float m2[3][3]);
-void copy_m3_m4(float m1[3][3], float m2[4][4]);
-void adjoint_m3_m3(float m1[3][3], float m[3][3]);
-float determinant_m3_array(float m[3][3]);
-bool invert_m3_m3(float m1[3][3], float m2[3][3]);
-bool invert_m3(float m[3][3]);
-void transpose_m3(float mat[3][3]);
-}
-
-#define MAX_LIGHTS 8
-#define SUPPORT_COLOR_MATERIAL
-
-typedef struct Light {
- float position[4];
- float ambient[4];
- float diffuse[4];
- float specular[4];
- float spot_direction[4];
-#ifdef SUPPORT_COLOR_MATERIAL
- float constant_attenuation;
- float linear_attenuation;
- float quadratic_attenuation;
- float spot_cutoff;
- float spot_exponent;
- float spot_cos_cutoff;
- float pad, pad2;
-#endif
-} Light;
-
-typedef struct Lighting {
- Light lights[MAX_LIGHTS];
- int num_enabled;
-} Lighting;
-
-typedef struct Transform {
- float projection_matrix[16];
- float model_view_matrix[16];
- float normal_matrix[9];
-} Transform;
-
-static bool g_use_osd_glsl = false;
-static int g_active_uv_index = 0;
-
-static GLuint g_flat_fill_solid_program = 0;
-static GLuint g_flat_fill_texture2d_program = 0;
-static GLuint g_smooth_fill_solid_program = 0;
-static GLuint g_smooth_fill_texture2d_program = 0;
-
-static GLuint g_flat_fill_solid_shadeless_program = 0;
-static GLuint g_flat_fill_texture2d_shadeless_program = 0;
-static GLuint g_smooth_fill_solid_shadeless_program = 0;
-static GLuint g_smooth_fill_texture2d_shadeless_program = 0;
-
-static GLuint g_wireframe_program = 0;
-
-static GLuint g_lighting_ub = 0;
-static Lighting g_lighting_data;
-static Transform g_transform;
-
-struct OpenSubdiv_GLMeshFVarData
-{
- OpenSubdiv_GLMeshFVarData() :
- texture_buffer(0), offset_buffer(0) {
- }
-
- ~OpenSubdiv_GLMeshFVarData()
- {
- Release();
- }
-
- void Release()
- {
- if (texture_buffer) {
- glDeleteTextures(1, &texture_buffer);
- }
- if (offset_buffer) {
- glDeleteTextures(1, &offset_buffer);
- }
- texture_buffer = 0;
- offset_buffer = 0;
- fvar_width = 0;
- channel_offsets.clear();
- }
-
- void Create(const OpenSubdiv::Far::TopologyRefiner *refiner,
- const OpenSubdiv::Far::PatchTable *patch_table,
- int fvar_width,
- const float *fvar_src_data)
- {
- Release();
-
- this->fvar_width = fvar_width;
-
- /* Expand fvar data to per-patch array */
- const int max_level = refiner->GetMaxLevel();
- const int num_channels = patch_table->GetNumFVarChannels();
- std::vector<float> data;
- int fvar_data_offset = 0;
- channel_offsets.resize(num_channels);
- for (int channel = 0; channel < num_channels; ++channel) {
- OpenSubdiv::Far::ConstIndexArray indices =
- patch_table->GetFVarValues(channel);
-
- channel_offsets[channel] = data.size();
- data.reserve(data.size() + indices.size() * fvar_width);
-
- for (int fvert = 0; fvert < (int)indices.size(); ++fvert) {
- int index = indices[fvert] * fvar_width;
- for (int i = 0; i < fvar_width; ++i) {
- data.push_back(fvar_src_data[fvar_data_offset + index++]);
- }
- }
- if (refiner->IsUniform()) {
- const int num_values_max = refiner->GetLevel(max_level).GetNumFVarValues(channel);
- fvar_data_offset += num_values_max * fvar_width;
- } else {
- const int num_values_total = refiner->GetNumFVarValuesTotal(channel);
- fvar_data_offset += num_values_total * fvar_width;
- }
- }
-
- GLuint buffer;
- glGenBuffers(1, &buffer);
- glBindBuffer(GL_ARRAY_BUFFER, buffer);
- glBufferData(GL_ARRAY_BUFFER, data.size()*sizeof(float),
- &data[0], GL_STATIC_DRAW);
-
- glGenTextures(1, &texture_buffer);
- glBindTexture(GL_TEXTURE_BUFFER, texture_buffer);
- glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, buffer);
-
- glDeleteBuffers(1, &buffer);
-
- glGenBuffers(1, &buffer);
- glBindBuffer(GL_ARRAY_BUFFER, buffer);
- glBufferData(GL_ARRAY_BUFFER, channel_offsets.size()*sizeof(int),
- &channel_offsets[0], GL_STATIC_DRAW);
-
- glGenTextures(1, &offset_buffer);
- glBindTexture(GL_TEXTURE_BUFFER, offset_buffer);
- glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer);
- glBindTexture(GL_TEXTURE_BUFFER, 0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- }
- GLuint texture_buffer;
- GLuint offset_buffer;
- std::vector<int> channel_offsets;
- int fvar_width;
-};
-
-namespace {
-
-GLuint compileShader(GLenum shaderType,
- const char *version,
- const char *define,
- const char *source)
-{
- const char *sources[] = {
- version,
- define,
-#ifdef SUPPORT_COLOR_MATERIAL
- "#define SUPPORT_COLOR_MATERIAL\n",
-#else
- "",
-#endif
- source,
- };
-
- GLuint shader = glCreateShader(shaderType);
- glShaderSource(shader, 4, sources, NULL);
- glCompileShader(shader);
-
- GLint status;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
- if (status == GL_FALSE) {
- GLchar emsg[1024];
- glGetShaderInfoLog(shader, sizeof(emsg), 0, emsg);
- fprintf(stderr, "Error compiling GLSL: %s\n", emsg);
- fprintf(stderr, "Version: %s\n", version);
- fprintf(stderr, "Defines: %s\n", define);
- fprintf(stderr, "Source: %s\n", source);
- return 0;
- }
-
- return shader;
-}
-
-GLuint linkProgram(const char *version, const char *define)
-{
- GLuint vertexShader = compileShader(GL_VERTEX_SHADER,
- version,
- define,
- datatoc_gpu_shader_opensubdiv_vertex_glsl);
- if (vertexShader == 0) {
- return 0;
- }
- GLuint geometryShader = compileShader(GL_GEOMETRY_SHADER,
- version,
- define,
- datatoc_gpu_shader_opensubdiv_geometry_glsl);
- if (geometryShader == 0) {
- return 0;
- }
- GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER,
- version,
- define,
- datatoc_gpu_shader_opensubdiv_fragment_glsl );
- if (fragmentShader == 0) {
- return 0;
- }
-
- GLuint program = glCreateProgram();
-
- glAttachShader(program, vertexShader);
- glAttachShader(program, geometryShader);
- glAttachShader(program, fragmentShader);
-
- glBindAttribLocation(program, 0, "position");
- glBindAttribLocation(program, 1, "normal");
-
- glLinkProgram(program);
-
- glDeleteShader(vertexShader);
- glDeleteShader(geometryShader);
- glDeleteShader(fragmentShader);
-
- GLint status;
- glGetProgramiv(program, GL_LINK_STATUS, &status);
- if (status == GL_FALSE) {
- GLchar emsg[1024];
- glGetProgramInfoLog(program, sizeof(emsg), 0, emsg);
- fprintf(stderr, "Error linking GLSL program : %s\n", emsg);
- fprintf(stderr, "Defines: %s\n", define);
- glDeleteProgram(program);
- return 0;
- }
-
- glUniformBlockBinding(program,
- glGetUniformBlockIndex(program, "Lighting"),
- 0);
-
- if (GLEW_VERSION_4_1) {
- glProgramUniform1i(program,
- glGetUniformLocation(program, "texture_buffer"),
- 0); /* GL_TEXTURE0 */
-
- glProgramUniform1i(program,
- glGetUniformLocation(program, "FVarDataOffsetBuffer"),
- 30); /* GL_TEXTURE30 */
-
- glProgramUniform1i(program,
- glGetUniformLocation(program, "FVarDataBuffer"),
- 31); /* GL_TEXTURE31 */
- }
- else {
- glUseProgram(program);
- glUniform1i(glGetUniformLocation(program, "texture_buffer"), 0); /* GL_TEXTURE0 */
- glUniform1i(glGetUniformLocation(program, "FVarDataOffsetBuffer"), 30); /* GL_TEXTURE30 */
- glUniform1i(glGetUniformLocation(program, "FVarDataBuffer"), 31); /* GL_TEXTURE31 */
- glUseProgram(0);
- }
-
- return program;
-}
-
-void bindProgram(OpenSubdiv_GLMesh *gl_mesh, int program)
-{
- glUseProgram(program);
-
- /* Matrices */
- glUniformMatrix4fv(glGetUniformLocation(program, "modelViewMatrix"),
- 1, false,
- g_transform.model_view_matrix);
- glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"),
- 1, false,
- g_transform.projection_matrix);
- glUniformMatrix3fv(glGetUniformLocation(program, "normalMatrix"),
- 1, false,
- g_transform.normal_matrix);
-
- /* Lighting */
- glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub);
- glBufferSubData(GL_UNIFORM_BUFFER,
- 0, sizeof(g_lighting_data), &g_lighting_data);
- glBindBuffer(GL_UNIFORM_BUFFER, 0);
-
- glBindBufferBase(GL_UNIFORM_BUFFER, 0, g_lighting_ub);
-
- /* Color */
- {
- /* TODO: stop using glGetMaterial */
- float color[4];
- glGetMaterialfv(GL_FRONT, GL_DIFFUSE, color);
- glUniform4fv(glGetUniformLocation(program, "diffuse"), 1, color);
-
- glGetMaterialfv(GL_FRONT, GL_SPECULAR, color);
- glUniform4fv(glGetUniformLocation(program, "specular"), 1, color);
-
- glGetMaterialfv(GL_FRONT, GL_SHININESS, color);
- glUniform1f(glGetUniformLocation(program, "shininess"), color[0]);
- }
-
- /* Face-vertex data */
- if (gl_mesh->fvar_data != NULL) {
- if (gl_mesh->fvar_data->texture_buffer) {
- glActiveTexture(GL_TEXTURE31);
- glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->texture_buffer);
- glActiveTexture(GL_TEXTURE0);
- }
-
- if (gl_mesh->fvar_data->offset_buffer) {
- glActiveTexture(GL_TEXTURE30);
- glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->offset_buffer);
- glActiveTexture(GL_TEXTURE0);
- }
-
- glUniform1i(glGetUniformLocation(program, "osd_fvar_count"),
- gl_mesh->fvar_data->fvar_width);
- if (gl_mesh->fvar_data->channel_offsets.size() > 0 &&
- g_active_uv_index >= 0)
- {
- glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"),
- gl_mesh->fvar_data->channel_offsets[g_active_uv_index]);
- } else {
- glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
- }
- } else {
- glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0);
- glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
- }
-}
-
-} /* namespace */
-
-bool openSubdiv_osdGLDisplayInit(void)
-{
- static bool need_init = true;
- static bool init_success = false;
-
- if (need_init) {
- /* TODO: update OSD drawing to OpenGL 3.3 core, then remove following line */
- return false;
-
- const char *version = "";
- if (GLEW_VERSION_3_2) {
- version = "#version 150 compatibility\n";
- }
- else if (GLEW_VERSION_3_1) {
- version = "#version 140\n"
- "#extension GL_ARB_compatibility: enable\n";
- }
- else {
- version = "#version 130\n";
- /* minimum supported for OpenSubdiv */
- }
-
- g_flat_fill_solid_program = linkProgram(
- version,
- "#define USE_COLOR_MATERIAL\n"
- "#define USE_LIGHTING\n"
- "#define FLAT_SHADING\n");
- g_flat_fill_texture2d_program = linkProgram(
- version,
- "#define USE_COLOR_MATERIAL\n"
- "#define USE_LIGHTING\n"
- "#define USE_TEXTURE_2D\n"
- "#define FLAT_SHADING\n");
- g_smooth_fill_solid_program = linkProgram(
- version,
- "#define USE_COLOR_MATERIAL\n"
- "#define USE_LIGHTING\n"
- "#define SMOOTH_SHADING\n");
- g_smooth_fill_texture2d_program = linkProgram(
- version,
- "#define USE_COLOR_MATERIAL\n"
- "#define USE_LIGHTING\n"
- "#define USE_TEXTURE_2D\n"
- "#define SMOOTH_SHADING\n");
-
- g_flat_fill_solid_shadeless_program = linkProgram(
- version,
- "#define USE_COLOR_MATERIAL\n"
- "#define FLAT_SHADING\n");
- g_flat_fill_texture2d_shadeless_program = linkProgram(
- version,
- "#define USE_COLOR_MATERIAL\n"
- "#define USE_TEXTURE_2D\n"
- "#define FLAT_SHADING\n");
- g_smooth_fill_solid_shadeless_program = linkProgram(
- version,
- "#define USE_COLOR_MATERIAL\n"
- "#define SMOOTH_SHADING\n");
- g_smooth_fill_texture2d_shadeless_program = linkProgram(
- version,
- "#define USE_COLOR_MATERIAL\n"
- "#define USE_TEXTURE_2D\n"
- "#define SMOOTH_SHADING\n");
-
- g_wireframe_program = linkProgram(
- version,
- "#define WIREFRAME\n");
-
- glGenBuffers(1, &g_lighting_ub);
- glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub);
- glBufferData(GL_UNIFORM_BUFFER,
- sizeof(g_lighting_data), NULL, GL_STATIC_DRAW);
-
- need_init = false;
- init_success = g_flat_fill_solid_program != 0 &&
- g_flat_fill_texture2d_program != 0 &&
- g_smooth_fill_solid_program != 0 &&
- g_smooth_fill_texture2d_program != 0 &&
- g_wireframe_program;
- }
- return init_success;
-}
-
-void openSubdiv_osdGLDisplayDeinit(void)
-{
- if (g_lighting_ub != 0) {
- glDeleteBuffers(1, &g_lighting_ub);
- }
-#define SAFE_DELETE_PROGRAM(program) \
- do { \
- if (program) { \
- glDeleteProgram(program); \
- } \
- } while (false)
-
- SAFE_DELETE_PROGRAM(g_flat_fill_solid_program);
- SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_program);
- SAFE_DELETE_PROGRAM(g_smooth_fill_solid_program);
- SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_program);
- SAFE_DELETE_PROGRAM(g_flat_fill_solid_shadeless_program);
- SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_shadeless_program);
- SAFE_DELETE_PROGRAM(g_smooth_fill_solid_shadeless_program);
- SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_shadeless_program);
- SAFE_DELETE_PROGRAM(g_wireframe_program);
-
-#undef SAFE_DELETE_PROGRAM
-}
-
-void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl,
- int active_uv_index)
-{
- g_active_uv_index = active_uv_index;
- g_use_osd_glsl = (use_osd_glsl != 0);
-
- /* Update transformation matrices. */
- glGetFloatv(GL_PROJECTION_MATRIX, g_transform.projection_matrix);
- glGetFloatv(GL_MODELVIEW_MATRIX, g_transform.model_view_matrix);
-
- copy_m3_m4((float (*)[3])g_transform.normal_matrix,
- (float (*)[4])g_transform.model_view_matrix);
- invert_m3((float (*)[3])g_transform.normal_matrix);
- transpose_m3((float (*)[3])g_transform.normal_matrix);
-
- /* Update OpenGL lights positions, colors etc. */
- g_lighting_data.num_enabled = 0;
- for (int i = 0; i < MAX_LIGHTS; ++i) {
- GLboolean enabled;
- glGetBooleanv(GL_LIGHT0 + i, &enabled);
- if (enabled) {
- g_lighting_data.num_enabled++;
- }
-
- /* TODO: stop using glGetLight */
- glGetLightfv(GL_LIGHT0 + i,
- GL_POSITION,
- g_lighting_data.lights[i].position);
- glGetLightfv(GL_LIGHT0 + i,
- GL_AMBIENT,
- g_lighting_data.lights[i].ambient);
- glGetLightfv(GL_LIGHT0 + i,
- GL_DIFFUSE,
- g_lighting_data.lights[i].diffuse);
- glGetLightfv(GL_LIGHT0 + i,
- GL_SPECULAR,
- g_lighting_data.lights[i].specular);
- glGetLightfv(GL_LIGHT0 + i,
- GL_SPOT_DIRECTION,
- g_lighting_data.lights[i].spot_direction);
-#ifdef SUPPORT_COLOR_MATERIAL
- glGetLightfv(GL_LIGHT0 + i,
- GL_CONSTANT_ATTENUATION,
- &g_lighting_data.lights[i].constant_attenuation);
- glGetLightfv(GL_LIGHT0 + i,
- GL_LINEAR_ATTENUATION,
- &g_lighting_data.lights[i].linear_attenuation);
- glGetLightfv(GL_LIGHT0 + i,
- GL_QUADRATIC_ATTENUATION,
- &g_lighting_data.lights[i].quadratic_attenuation);
- glGetLightfv(GL_LIGHT0 + i,
- GL_SPOT_CUTOFF,
- &g_lighting_data.lights[i].spot_cutoff);
- glGetLightfv(GL_LIGHT0 + i,
- GL_SPOT_EXPONENT,
- &g_lighting_data.lights[i].spot_exponent);
- g_lighting_data.lights[i].spot_cos_cutoff =
- cos(g_lighting_data.lights[i].spot_cutoff);
-#endif
- }
-}
-
-static GLuint prepare_patchDraw(OpenSubdiv_GLMesh *gl_mesh,
- bool fill_quads)
-{
- GLint program = 0;
- if (!g_use_osd_glsl) {
- glGetIntegerv(GL_CURRENT_PROGRAM, &program);
- if (program) {
- GLint model;
- glGetIntegerv(GL_SHADE_MODEL, &model);
-
- GLint location = glGetUniformLocation(program, "osd_flat_shading");
- if (location != -1) {
- glUniform1i(location, model == GL_FLAT);
- }
-
- /* Face-vertex data */
- if (gl_mesh->fvar_data != NULL) {
- if (gl_mesh->fvar_data->texture_buffer) {
- glActiveTexture(GL_TEXTURE31);
- glBindTexture(GL_TEXTURE_BUFFER,
- gl_mesh->fvar_data->texture_buffer);
- glActiveTexture(GL_TEXTURE0);
- }
-
- if (gl_mesh->fvar_data->offset_buffer) {
- glActiveTexture(GL_TEXTURE30);
- glBindTexture(GL_TEXTURE_BUFFER,
- gl_mesh->fvar_data->offset_buffer);
- glActiveTexture(GL_TEXTURE0);
- }
-
- GLint location = glGetUniformLocation(program, "osd_fvar_count");
- if (location != -1) {
- glUniform1i(location, gl_mesh->fvar_data->fvar_width);
- }
-
- location = glGetUniformLocation(program, "osd_active_uv_offset");
- if (location != -1) {
- if (gl_mesh->fvar_data->channel_offsets.size() > 0 &&
- g_active_uv_index >= 0)
- {
- glUniform1i(location,
- gl_mesh->fvar_data->channel_offsets[g_active_uv_index]);
- } else {
- glUniform1i(location, 0);
- }
- }
- } else {
- glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0);
- glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
- }
- }
- return program;
- }
-
- if (fill_quads) {
- int model;
- GLboolean use_texture_2d;
- glGetIntegerv(GL_SHADE_MODEL, &model);
- glGetBooleanv(GL_TEXTURE_2D, &use_texture_2d);
-
- if (model == GL_FLAT) {
- if (use_texture_2d) {
- program = g_flat_fill_texture2d_program;
- }
- else {
- program = g_flat_fill_solid_program;
- }
- }
- else {
- if (use_texture_2d) {
- program = g_smooth_fill_texture2d_program;
- }
- else {
- program = g_smooth_fill_solid_program;
- }
- }
-
- }
- else {
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- program = g_wireframe_program;
- }
-
- bindProgram(gl_mesh, program);
-
- return program;
-}
-
-static void perform_drawElements(GLuint program,
- int patch_index,
- int num_elements,
- int start_element)
-{
- if (program) {
- glUniform1i(glGetUniformLocation(program, "PrimitiveIdBase"),
- patch_index);
- }
- glDrawElements(GL_LINES_ADJACENCY,
- num_elements,
- GL_UNSIGNED_INT,
- (void *)(start_element * sizeof(unsigned int)));
-}
-
-static void finish_patchDraw(bool fill_quads)
-{
- /* TODO(sergey): Some of the stuff could be done once after the whole
- * mesh is displayed.
- */
-
- /* Restore state. */
- if (!fill_quads) {
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- }
- glBindVertexArray(0);
-
- if (g_use_osd_glsl) {
- /* TODO(sergey): Store previously used program and roll back to it? */
- glUseProgram(0);
- }
-}
-
-static void draw_partition_patches_range(GLMeshInterface *mesh,
- GLuint program,
- int start_patch,
- int num_patches)
-{
- int traversed_patches = 0, num_remained_patches = num_patches;
- const OpenSubdiv::Osd::PatchArrayVector& patches =
- mesh->GetPatchTable()->GetPatchArrays();
- for (int i = 0; i < (int)patches.size(); ++i) {
- const OpenSubdiv::Osd::PatchArray& patch = patches[i];
- OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor();
- OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType();
-
- if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) {
- const int num_block_patches = patch.GetNumPatches();
- if (start_patch >= traversed_patches &&
- start_patch < traversed_patches + num_block_patches)
- {
- const int num_control_verts = desc.GetNumControlVertices();
- const int start_draw_patch = start_patch - traversed_patches;
- const int num_draw_patches = std::min(num_remained_patches,
- num_block_patches - start_draw_patch);
- perform_drawElements(program,
- i + start_draw_patch,
- num_draw_patches * num_control_verts,
- patch.GetIndexBase() + start_draw_patch * num_control_verts);
- num_remained_patches -= num_draw_patches;
- }
- if (num_remained_patches == 0) {
- break;
- }
- traversed_patches += num_block_patches;
- }
- }
-}
-
-static void draw_all_patches(GLMeshInterface *mesh,
- GLuint program)
-{
- const OpenSubdiv::Osd::PatchArrayVector& patches =
- mesh->GetPatchTable()->GetPatchArrays();
- for (int i = 0; i < (int)patches.size(); ++i) {
- const OpenSubdiv::Osd::PatchArray& patch = patches[i];
- OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor();
- OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType();
-
- if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) {
- perform_drawElements(program,
- i,
- patch.GetNumPatches() * desc.GetNumControlVertices(),
- patch.GetIndexBase());
- }
- }
-}
-
-void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh,
- int fill_quads,
- int start_patch,
- int num_patches)
-{
- GLMeshInterface *mesh =
- (GLMeshInterface *)(gl_mesh->descriptor);
-
- /* Make sure all global invariants are initialized. */
- if (!openSubdiv_osdGLDisplayInit()) {
- return;
- }
-
- /* Setup GLSL/OpenGL to draw patches in current context. */
- GLuint program = prepare_patchDraw(gl_mesh, fill_quads != 0);
-
- if (start_patch != -1) {
- draw_partition_patches_range(mesh,
- program,
- start_patch,
- num_patches);
- }
- else {
- draw_all_patches(mesh, program);
- }
-
- /* Finish patch drawing by restoring all changes to the OpenGL context. */
- finish_patchDraw(fill_quads != 0);
-}
-
-void openSubdiv_osdGLAllocFVar(OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- OpenSubdiv_GLMesh *gl_mesh,
- const float *fvar_data)
-{
- GLMeshInterface *mesh =
- (GLMeshInterface *)(gl_mesh->descriptor);
- gl_mesh->fvar_data = OBJECT_GUARDED_NEW(OpenSubdiv_GLMeshFVarData);
- gl_mesh->fvar_data->Create(topology_refiner->osd_refiner,
- mesh->GetFarPatchTable(),
- 2,
- fvar_data);
-}
-
-void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh)
-{
- if (gl_mesh->fvar_data != NULL) {
- OBJECT_GUARDED_DELETE(gl_mesh->fvar_data, OpenSubdiv_GLMeshFVarData);
- }
-}
diff --git a/intern/opensubdiv/opensubdiv_topology_refiner_capi.h b/intern/opensubdiv/opensubdiv_topology_refiner_capi.h
new file mode 100644
index 00000000000..fe4db0ca67c
--- /dev/null
+++ b/intern/opensubdiv/opensubdiv_topology_refiner_capi.h
@@ -0,0 +1,151 @@
+// Copyright 2018 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the 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.
+//
+// Author: Sergey Sharybin
+
+#ifndef OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
+#define OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
+
+#include <stdint.h> // for bool
+
+#include "opensubdiv_capi_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct OpenSubdiv_Converter;
+struct OpenSubdiv_TopologyRefinerInternal;
+
+// Those settings don't really belong to OpenSubdiv's topology refiner, but
+// we are keeping track of them on our side of topology refiner. This is to
+// make it possible to ensure we are not trying to abuse same OpenSubdiv's
+// topology refiner with different subdivision levels or with different
+// adaptive settings.
+typedef struct OpenSubdiv_TopologyRefinerSettings {
+ bool is_adaptive;
+ int level;
+} OpenSubdiv_TopologyRefinerSettings;
+
+typedef struct OpenSubdiv_TopologyRefiner {
+ // Query subdivision level the refiner is created for.
+ int (*getSubdivisionLevel)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner);
+ bool (*getIsAdaptive)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner);
+
+ // NOTE: All queries are querying base level.
+ //
+ // TODO(sergey): Consider making it more obvious in function naming,
+ // but since it's unlikely (or at least, will be uncommon use) for API
+ // which queries final geometry, we should be fine with this name for
+ // now.
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Query basic topology information from base level.
+
+ int (*getNumVertices)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner);
+ int (*getNumEdges)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner);
+ int (*getNumFaces)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner);
+ int (*getNumFaceVertices)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner,
+ const int face_index);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // PTex face geometry queries.
+
+ // Ptex face corresponds to OpenSubdiv's internal "patch" and to Blender's
+ // subdivision grid. The rule commes as:
+ // - Triangle face consist of 3 ptex faces, ordered in the order of
+ // face-vertices.
+ // - Quad face consists of a single ptex face.
+ // - N-gons (similar to triangle) consists of N ptex faces, ordered same
+ // way as for triangle.
+ int (*getNumFacePtexFaces)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner,
+ const int face_index);
+ int (*getNumPtexFaces)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner);
+
+ // Initialize a per-base-face offset measured in ptex face indices.
+ //
+ // Basically, face_ptex_offset[base_face_index] is a total number of ptex
+ // faces created for bases faces [0 .. base_face_index - 1].
+ //
+ // The array must contain at least total number of ptex faces elements.
+ void (*fillFacePtexIndexOffset)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner,
+ int* face_ptex_index_offset);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Face-varying data.
+
+ // Number of face-varying channels (or how they are called in Blender layers).
+ int (*getNumFVarChannels)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner);
+ // Get face-varying interpolation type.
+ OpenSubdiv_FVarLinearInterpolation (*getFVarLinearInterpolation)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner);
+ // Get total number of face-varying values in a particular channel.
+ int (*getNumFVarValues)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner,
+ const int channel);
+ // Get face-varying value indices associated with a particular face.
+ //
+ // This is an array of indices inside of face-varying array, array elements
+ // are aligned with face corners (or loops in Blender terminology).
+ const int* (*getFaceFVarValueIndices)(
+ const struct OpenSubdiv_TopologyRefiner* topology_refiner,
+ const int face_index,
+ const int channel);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Internal use.
+
+ // Internal storage for the use in this module only.
+ //
+ // Tease: Contains actual OpenSubdiv's refiner and (optionally) some other
+ // data and state needed for an internbal use.
+ struct OpenSubdiv_TopologyRefinerInternal* internal;
+} OpenSubdiv_TopologyRefiner;
+
+// NOTE: Will return NULL in cases of bad topology.
+// NOTE: Mesh without faces is considered a bad topology.
+OpenSubdiv_TopologyRefiner* openSubdiv_createTopologyRefinerFromConverter(
+ struct OpenSubdiv_Converter* converter,
+ const OpenSubdiv_TopologyRefinerSettings* settings);
+
+void openSubdiv_deleteTopologyRefiner(
+ OpenSubdiv_TopologyRefiner* topology_refiner);
+
+// Compare given topology refiner with converter. Returns truth if topology
+// refiner matches given converter, false otherwise.
+//
+// This allows users to construct converter (which is supposed to be cheap)
+// and compare with existing refiner before going into more computationally
+// complicated parts of subdivision process.
+bool openSubdiv_topologyRefinerCompareWithConverter(
+ const OpenSubdiv_TopologyRefiner* topology_refiner,
+ const struct OpenSubdiv_Converter* converter);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
diff --git a/intern/opensubdiv/opensubdiv_utils_capi.cc b/intern/opensubdiv/opensubdiv_utils_capi.cc
deleted file mode 100644
index 72e3751e6b3..00000000000
--- a/intern/opensubdiv/opensubdiv_utils_capi.cc
+++ /dev/null
@@ -1,88 +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) 2013 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin.
- * Brecht van Lommel
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "opensubdiv_capi.h"
-
-#include <cstring>
-#include <GL/glew.h>
-
-#ifdef _MSC_VER
-# include "iso646.h"
-#endif
-
-#ifdef OPENSUBDIV_HAS_OPENCL
-# include "opensubdiv_device_context_opencl.h"
-#endif /* OPENSUBDIV_HAS_OPENCL */
-
-#ifdef OPENSUBDIV_HAS_CUDA
-# include "opensubdiv_device_context_cuda.h"
-#endif /* OPENSUBDIV_HAS_CUDA */
-
-int openSubdiv_getAvailableEvaluators(void)
-{
- int flags = OPENSUBDIV_EVALUATOR_CPU;
-
-#ifdef OPENSUBDIV_HAS_OPENMP
- flags |= OPENSUBDIV_EVALUATOR_OPENMP;
-#endif /* OPENSUBDIV_HAS_OPENMP */
-
-#ifdef OPENSUBDIV_HAS_OPENCL
- if (CLDeviceContext::HAS_CL_VERSION_1_1()) {
- flags |= OPENSUBDIV_EVALUATOR_OPENCL;
- }
-#endif /* OPENSUBDIV_HAS_OPENCL */
-
-#ifdef OPENSUBDIV_HAS_CUDA
- if (CudaDeviceContext::HAS_CUDA_VERSION_4_0()) {
- flags |= OPENSUBDIV_EVALUATOR_CUDA;
- }
-#endif /* OPENSUBDIV_HAS_OPENCL */
-
-#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
- if (GLEW_VERSION_4_1) {
- flags |= OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK;
- }
-#endif /* OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK */
-
-#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
- if (GLEW_VERSION_4_3 || GLEW_ARB_compute_shader) {
- flags |= OPENSUBDIV_EVALUATOR_GLSL_COMPUTE;
- }
-#endif /* OPENSUBDIV_HAS_GLSL_COMPUTE */
-
- return flags;
-}
-
-void openSubdiv_init(void)
-{
- /* Ensure all OpenGL strings are cached. */
- (void)openSubdiv_getAvailableEvaluators();
-}
-
-void openSubdiv_cleanup(void)
-{
- openSubdiv_osdGLDisplayDeinit();
-}
diff --git a/intern/opensubdiv/gpu_shader_opensubdiv_fragment.glsl b/intern/opensubdiv/shader/gpu_shader_opensubdiv_fragment.glsl
index 1e36d549360..1e36d549360 100644
--- a/intern/opensubdiv/gpu_shader_opensubdiv_fragment.glsl
+++ b/intern/opensubdiv/shader/gpu_shader_opensubdiv_fragment.glsl
diff --git a/intern/opensubdiv/gpu_shader_opensubdiv_geometry.glsl b/intern/opensubdiv/shader/gpu_shader_opensubdiv_geometry.glsl
index b16a5cca733..b16a5cca733 100644
--- a/intern/opensubdiv/gpu_shader_opensubdiv_geometry.glsl
+++ b/intern/opensubdiv/shader/gpu_shader_opensubdiv_geometry.glsl
diff --git a/intern/opensubdiv/gpu_shader_opensubdiv_vertex.glsl b/intern/opensubdiv/shader/gpu_shader_opensubdiv_vertex.glsl
index 6fcf5ad20cd..6fcf5ad20cd 100644
--- a/intern/opensubdiv/gpu_shader_opensubdiv_vertex.glsl
+++ b/intern/opensubdiv/shader/gpu_shader_opensubdiv_vertex.glsl
diff --git a/release/datafiles/blender_icons.svg b/release/datafiles/blender_icons.svg
index a14f2903b71..4174c575e67 100644
--- a/release/datafiles/blender_icons.svg
+++ b/release/datafiles/blender_icons.svg
@@ -32021,6 +32021,190 @@
style="fill:url(#linearGradient25387-9);fill-rule:evenodd;stroke:none" />
</g>
</mask>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient1610"
+ id="linearGradient15405"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-19,294.91429)"
+ x1="461.66425"
+ y1="16.23234"
+ x2="432.875"
+ y2="14.936845" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient319"
+ id="linearGradient15407"
+ gradientUnits="userSpaceOnUse"
+ x1="62.793919"
+ y1="133.73566"
+ x2="64.109718"
+ y2="135.18265" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient1610-36-6-5"
+ id="linearGradient15602"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(144,188)"
+ x1="209"
+ y1="238"
+ x2="226.625"
+ y2="251.71078" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient18495"
+ id="radialGradient27973-2-2"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.39459,-0.991726,0.917787,0.36517,234.80511,750.0215)"
+ cx="450.06522"
+ cy="25.190212"
+ fx="450.06522"
+ fy="25.190212"
+ r="5.5" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient18134"
+ id="radialGradient27975-7-6"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.121304,-0.696283,0.871429,0.151818,359.51331,621.7)"
+ cx="450.72842"
+ cy="19.250505"
+ fx="450.72842"
+ fy="19.250505"
+ r="5.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient1610"
+ id="linearGradient17086"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-19,294.91429)"
+ x1="461.66425"
+ y1="16.23234"
+ x2="432.875"
+ y2="14.936845" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient319"
+ id="linearGradient17088"
+ gradientUnits="userSpaceOnUse"
+ x1="62.793919"
+ y1="133.73566"
+ x2="64.109718"
+ y2="135.18265" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient319"
+ id="linearGradient17090"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-1,0,0,1,883.51417,295)"
+ x1="456.81198"
+ y1="15.545153"
+ x2="441.9628"
+ y2="13.21724" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient1610-36-6-5"
+ id="linearGradient17092"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(144,188)"
+ x1="209"
+ y1="238"
+ x2="226.625"
+ y2="251.71078" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient18495"
+ id="radialGradient27973-2-2-2"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.39459,-0.991726,0.917787,0.36517,234.80511,750.0215)"
+ cx="450.06522"
+ cy="25.190212"
+ fx="450.06522"
+ fy="25.190212"
+ r="5.5" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient18134"
+ id="radialGradient27975-7-6-7"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.121304,-0.696283,0.871429,0.151818,359.51331,621.7)"
+ cx="450.72842"
+ cy="19.250505"
+ fx="450.72842"
+ fy="19.250505"
+ r="5.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient319"
+ id="linearGradient17532"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-1,0,0,1,883.51417,295)"
+ x1="456.81198"
+ y1="15.545153"
+ x2="441.9628"
+ y2="13.21724" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient1610-36-6-5"
+ id="linearGradient17534"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(144,188)"
+ x1="209"
+ y1="238"
+ x2="226.625"
+ y2="251.71078" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient1610-36-6-5"
+ id="linearGradient17536"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(144,188)"
+ x1="209"
+ y1="238"
+ x2="226.625"
+ y2="251.71078" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient18495"
+ id="radialGradient27973-2-2-2-0"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.39459,-0.991726,0.917787,0.36517,234.80511,750.0215)"
+ cx="450.06522"
+ cy="25.190212"
+ fx="450.06522"
+ fy="25.190212"
+ r="5.5" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient18134"
+ id="radialGradient27975-7-6-7-4"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.121304,-0.696283,0.871429,0.151818,359.51331,621.7)"
+ cx="450.72842"
+ cy="19.250505"
+ fx="450.72842"
+ fy="19.250505"
+ r="5.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient319"
+ id="linearGradient17802"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-1,0,0,1,883.51417,295)"
+ x1="456.81198"
+ y1="15.545153"
+ x2="441.9628"
+ y2="13.21724" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient1610-36-6-5"
+ id="linearGradient17804"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(144,188)"
+ x1="209"
+ y1="238"
+ x2="226.625"
+ y2="251.71078" />
</defs>
<sodipodi:namedview
id="base"
@@ -93198,6 +93382,412 @@
id="g8298" />
</g>
</g>
+ <g
+ style="display:inline;enable-background:new"
+ id="ICON_RESTRICT_VIEW_OFF-4"
+ transform="matrix(0.53591163,0,0,0.55801106,-126.5083,-25.447517)">
+ <rect
+ y="302"
+ x="404"
+ height="16"
+ width="16.000004"
+ id="rect27916-7"
+ style="display:inline;opacity:0;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" />
+ <g
+ id="g28110-8">
+ <path
+ id="path27918-4"
+ d="m 412,306.45213 c -3.54545,0 -5.90909,1.5 -6.49999,3.04787 0.5909,1.45213 2.95581,3.77094 6.49999,3.75 3.54709,-0.021 5.9091,-2.29787 6.50001,-3.75 -0.59091,-1.54787 -2.95455,-3.04787 -6.50001,-3.04787 z"
+ style="fill:url(#linearGradient15405);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ sodipodi:nodetypes="ccscz"
+ inkscape:connector-curvature="0" />
+ <ellipse
+ id="path27920-5"
+ style="fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ transform="matrix(0.7500463,0,0,1.0294111,88.73017,294.07354)"
+ cx="431"
+ cy="14.5"
+ rx="3.9999149"
+ ry="2.91429" />
+ <circle
+ id="path27922-0"
+ style="display:inline;fill:url(#linearGradient15407);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.74699998;marker:none"
+ transform="matrix(2.249956,0,0,2.251405,267.75278,4.81032)"
+ cx="64"
+ cy="135"
+ r="1" />
+ <path
+ sodipodi:nodetypes="ccscs"
+ style="fill:none;stroke:#000000;stroke-width:0.69999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 412,306.5 c -3.5,0 -5,1.5 -6.5,3 1.5,1.5 2.75,4 6.5,4 3.75,0 5,-2.5 6.5,-4 -1.5,-1.5 -3,-3 -6.5,-3 z"
+ id="path27924-3"
+ inkscape:connector-curvature="0" />
+ <rect
+ y="307.91428"
+ x="411"
+ height="2"
+ width="2"
+ id="rect27926-6"
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" />
+ <circle
+ id="path27928-1"
+ style="display:inline;opacity:0.7;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.74699998;marker:none"
+ transform="translate(347,172.91429)"
+ cx="64"
+ cy="135"
+ r="1" />
+ </g>
+ </g>
+ <path
+ style="display:inline;fill:none;fill-rule:evenodd;stroke:#b4b4b4;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new"
+ d="M 101.24481,150.52549 92.852426,137.08557"
+ id="path15475-0"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <g
+ transform="matrix(0.69944752,0,0,0.70386741,-158,-165.92486)"
+ style="display:inline;enable-background:new"
+ id="ICON_RESTRICT_SELECT_OFF-7-8">
+ <path
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc"
+ id="path45378-1-5-6-4-8"
+ d="m 367.75,440.75 1.75,-1.5 2.5,5.25 1.75,-1 -2.25,-5 h 2.5 l -6.25,-6.25 z"
+ style="display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient15602);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;enable-background:accumulate" />
+ <rect
+ y="430"
+ x="362"
+ height="16"
+ width="16"
+ id="rect45374-0-5-6-5-4"
+ style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path17835-7-25-3"
+ d="m 367.5,431.5 7,7.25 h -3 l 2.5,4.75 -1.75,1 -2.5,-5 -2.25,2.25 z"
+ style="fill:none;stroke:#000000;stroke-width:0.89999998;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path17845-9-4-1"
+ d="m 368.34375,433.75 v 5.75"
+ style="fill:none;stroke:#ffffff;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="ICON_RESTRICT_VIEW_OFF-4-6"
+ transform="matrix(0.53591163,0,0,0.55801106,-105.5083,-25.447514)">
+ <rect
+ y="302"
+ x="404"
+ height="16"
+ width="16.000004"
+ id="rect27916-7-4"
+ style="display:inline;opacity:0;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" />
+ <g
+ id="g28110-8-5">
+ <path
+ id="path27918-4-2"
+ d="m 412,306.45213 c -3.54545,0 -5.90909,1.5 -6.49999,3.04787 0.5909,1.45213 2.95581,3.77094 6.49999,3.75 3.54709,-0.021 5.9091,-2.29787 6.50001,-3.75 -0.59091,-1.54787 -2.95455,-3.04787 -6.50001,-3.04787 z"
+ style="fill:url(#linearGradient17086);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ sodipodi:nodetypes="ccscz"
+ inkscape:connector-curvature="0" />
+ <ellipse
+ id="path27920-5-0"
+ style="fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ transform="matrix(0.7500463,0,0,1.0294111,88.73017,294.07354)"
+ cx="431"
+ cy="14.5"
+ rx="3.9999149"
+ ry="2.91429" />
+ <circle
+ id="path27922-0-2"
+ style="display:inline;fill:url(#linearGradient17088);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.74699998;marker:none"
+ transform="matrix(2.249956,0,0,2.251405,267.75278,4.81032)"
+ cx="64"
+ cy="135"
+ r="1" />
+ <path
+ sodipodi:nodetypes="ccscs"
+ style="fill:none;stroke:#000000;stroke-width:0.69999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 412,306.5 c -3.5,0 -5,1.5 -6.5,3 1.5,1.5 2.75,4 6.5,4 3.75,0 5,-2.5 6.5,-4 -1.5,-1.5 -3,-3 -6.5,-3 z"
+ id="path27924-3-9"
+ inkscape:connector-curvature="0" />
+ <rect
+ y="307.91428"
+ x="411"
+ height="2"
+ width="2"
+ id="rect27926-6-0"
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" />
+ <circle
+ id="path27928-1-9"
+ style="display:inline;opacity:0.7;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.74699998;marker:none"
+ transform="translate(347,172.91429)"
+ cx="64"
+ cy="135"
+ r="1" />
+ </g>
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="ICON_RESTRICT_VIEW_ON-0-9"
+ transform="matrix(0.51332204,0,0,0.45193371,-106.94628,7.531493)">
+ <g
+ transform="translate(0.4838899)"
+ id="g27934-6-4">
+ <path
+ sodipodi:nodetypes="ccscz"
+ style="display:inline;opacity:0.25;fill:url(#radialGradient27973-2-2);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ d="m 432.51611,305.45213 c -3,0 -7,2.04787 -5.5,4.04787 0.5,1.45213 2.49969,3.02073 5.49861,2.99979 3.00139,-0.021 4.82513,-1.62106 5.50139,-2.99995 2,-2.49984 -2.5,-4.04771 -5.5,-4.04771 z"
+ id="path27936-3-5"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path27938-2-1"
+ d="m 432.51611,305.45213 c -3,0 -7.75,2.04787 -6.25,4.04787 0.5,1.45213 3.25108,3.52094 6.25,3.5 3.00139,-0.021 5.82374,-2.12111 6.5,-3.5 2,-2.49984 -3.5,-4.04787 -6.5,-4.04787 z"
+ style="display:inline;opacity:0.18000004;fill:url(#radialGradient27975-7-6);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ sodipodi:nodetypes="ccscz"
+ inkscape:connector-curvature="0" />
+ <path
+ style="opacity:0.25;fill:none;stroke:url(#linearGradient17090);stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ d="m 438.51611,309.5 c -2,4 -10,4 -12,0"
+ id="path27940-0-0"
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path27942-6-3"
+ d="m 426.01611,309.5 c 2,5 11,5 13,0"
+ style="opacity:0.3;fill:none;stroke:#000000;stroke-width:1.00000012px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ style="opacity:0.25;fill:none;stroke:none"
+ id="rect27944-1-7"
+ width="15.983887"
+ height="16"
+ x="425.01611"
+ y="302" />
+ </g>
+ <g
+ transform="matrix(0.67292818,0,0,0.69502762,-127.10972,-162.15459)"
+ style="display:inline;opacity:0.3;enable-background:new"
+ id="ICON_RESTRICT_SELECT_ON-6-8">
+ <path
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc"
+ id="path45378-1-5-0-5-8"
+ d="m 367.75,440.75 1.75,-1.5 2.5,5.25 1.75,-1 -2.25,-5 h 2.5 l -6.25,-6.25 z"
+ style="display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient17092);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;enable-background:accumulate" />
+ <rect
+ y="430"
+ x="362"
+ height="16"
+ width="16"
+ id="rect45374-0-5-0-6-6"
+ style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path17835-6-9-0"
+ d="m 367.5,431.5 7,7.25 h -3 l 2.5,4.75 -1.75,1 -2.5,-5 -2.25,2.25 z"
+ style="fill:none;stroke:#000000;stroke-width:0.89999998;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path17845-4-3-4"
+ d="m 368.34375,433.75 v 5.75"
+ style="fill:none;stroke:#ffffff;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ <path
+ style="display:inline;fill:none;fill-rule:evenodd;stroke:#b4b4b4;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new"
+ d="m 122.24481,150.52549 -8.39238,-13.43992"
+ id="path15475-0-6"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <g
+ style="display:inline;enable-background:new"
+ id="ICON_RESTRICT_VIEW_ON-0-9-9"
+ transform="matrix(0.51332204,0,0,0.45193371,-85.946279,7.5314909)">
+ <g
+ transform="translate(0.4838899)"
+ id="g27934-6-4-0">
+ <path
+ sodipodi:nodetypes="ccscz"
+ style="display:inline;opacity:0.25;fill:url(#radialGradient27973-2-2-2);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ d="m 432.51611,305.45213 c -3,0 -7,2.04787 -5.5,4.04787 0.5,1.45213 2.49969,3.02073 5.49861,2.99979 3.00139,-0.021 4.82513,-1.62106 5.50139,-2.99995 2,-2.49984 -2.5,-4.04771 -5.5,-4.04771 z"
+ id="path27936-3-5-2"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path27938-2-1-4"
+ d="m 432.51611,305.45213 c -3,0 -7.75,2.04787 -6.25,4.04787 0.5,1.45213 3.25108,3.52094 6.25,3.5 3.00139,-0.021 5.82374,-2.12111 6.5,-3.5 2,-2.49984 -3.5,-4.04787 -6.5,-4.04787 z"
+ style="display:inline;opacity:0.18000004;fill:url(#radialGradient27975-7-6-7);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ sodipodi:nodetypes="ccscz"
+ inkscape:connector-curvature="0" />
+ <path
+ style="opacity:0.25;fill:none;stroke:url(#linearGradient17532);stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ d="m 438.51611,309.5 c -2,4 -10,4 -12,0"
+ id="path27940-0-0-7"
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path27942-6-3-6"
+ d="m 426.01611,309.5 c 2,5 11,5 13,0"
+ style="opacity:0.3;fill:none;stroke:#000000;stroke-width:1.00000012px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ style="opacity:0.25;fill:none;stroke:none"
+ id="rect27944-1-7-5"
+ width="15.983887"
+ height="16"
+ x="425.01611"
+ y="302" />
+ </g>
+ <g
+ transform="matrix(0.67292818,0,0,0.69502762,-106.10972,-162.15459)"
+ style="display:inline;opacity:0.3;enable-background:new"
+ id="ICON_RESTRICT_SELECT_ON-6-8-7">
+ <path
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc"
+ id="path45378-1-5-0-5-8-1"
+ d="m 367.75,440.75 1.75,-1.5 2.5,5.25 1.75,-1 -2.25,-5 h 2.5 l -6.25,-6.25 z"
+ style="display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient17534);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;enable-background:accumulate" />
+ <rect
+ y="430"
+ x="362"
+ height="16"
+ width="16"
+ id="rect45374-0-5-0-6-6-3"
+ style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path17835-6-9-0-3"
+ d="m 367.5,431.5 7,7.25 h -3 l 2.5,4.75 -1.75,1 -2.5,-5 -2.25,2.25 z"
+ style="fill:none;stroke:#000000;stroke-width:0.89999998;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path17845-4-3-4-3"
+ d="m 368.34375,433.75 v 5.75"
+ style="fill:none;stroke:#ffffff;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ <path
+ style="display:inline;fill:none;fill-rule:evenodd;stroke:#b4b4b4;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new"
+ d="m 143.24481,150.52549 -8.39238,-13.43992"
+ id="path15475-0-6-8"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <g
+ transform="matrix(0.69944752,0,0,0.70386741,-116,-165.92486)"
+ style="display:inline;enable-background:new"
+ id="ICON_RESTRICT_SELECT_OFF-7-8-7-5">
+ <path
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc"
+ id="path45378-1-5-6-4-8-6-1"
+ d="m 367.75,440.75 1.75,-1.5 2.5,5.25 1.75,-1 -2.25,-5 h 2.5 l -6.25,-6.25 z"
+ style="display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient17536);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;enable-background:accumulate" />
+ <rect
+ y="430"
+ x="362"
+ height="16"
+ width="16"
+ id="rect45374-0-5-6-5-4-0-0"
+ style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path17835-7-25-3-9-8"
+ d="m 367.5,431.5 7,7.25 h -3 l 2.5,4.75 -1.75,1 -2.5,-5 -2.25,2.25 z"
+ style="fill:none;stroke:#000000;stroke-width:0.89999998;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path17845-9-4-1-7-7"
+ d="m 368.34375,433.75 v 5.75"
+ style="fill:none;stroke:#ffffff;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="ICON_RESTRICT_VIEW_ON-0-9-9-3"
+ transform="matrix(0.51332204,0,0,0.45193371,-65.946279,7.5314909)">
+ <g
+ transform="translate(0.4838899)"
+ id="g27934-6-4-0-1">
+ <path
+ sodipodi:nodetypes="ccscz"
+ style="display:inline;opacity:0.25;fill:url(#radialGradient27973-2-2-2-0);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ d="m 432.51611,305.45213 c -3,0 -7,2.04787 -5.5,4.04787 0.5,1.45213 2.49969,3.02073 5.49861,2.99979 3.00139,-0.021 4.82513,-1.62106 5.50139,-2.99995 2,-2.49984 -2.5,-4.04771 -5.5,-4.04771 z"
+ id="path27936-3-5-2-8"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path27938-2-1-4-3"
+ d="m 432.51611,305.45213 c -3,0 -7.75,2.04787 -6.25,4.04787 0.5,1.45213 3.25108,3.52094 6.25,3.5 3.00139,-0.021 5.82374,-2.12111 6.5,-3.5 2,-2.49984 -3.5,-4.04787 -6.5,-4.04787 z"
+ style="display:inline;opacity:0.18000004;fill:url(#radialGradient27975-7-6-7-4);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ sodipodi:nodetypes="ccscz"
+ inkscape:connector-curvature="0" />
+ <path
+ style="opacity:0.25;fill:none;stroke:url(#linearGradient17802);stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ d="m 438.51611,309.5 c -2,4 -10,4 -12,0"
+ id="path27940-0-0-7-4"
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path27942-6-3-6-2"
+ d="m 426.01611,309.5 c 2,5 11,5 13,0"
+ style="opacity:0.3;fill:none;stroke:#000000;stroke-width:1.00000012px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ style="opacity:0.25;fill:none;stroke:none"
+ id="rect27944-1-7-5-2"
+ width="15.983887"
+ height="16"
+ x="425.01611"
+ y="302" />
+ </g>
+ <g
+ transform="matrix(0.67292818,0,0,0.69502762,-86.109719,-162.15459)"
+ style="display:inline;opacity:0.3;enable-background:new"
+ id="ICON_RESTRICT_SELECT_ON-6-8-7-4">
+ <path
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc"
+ id="path45378-1-5-0-5-8-1-5"
+ d="m 367.75,440.75 1.75,-1.5 2.5,5.25 1.75,-1 -2.25,-5 h 2.5 l -6.25,-6.25 z"
+ style="display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient17804);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;enable-background:accumulate" />
+ <rect
+ y="430"
+ x="362"
+ height="16"
+ width="16"
+ id="rect45374-0-5-0-6-6-3-1"
+ style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path17835-6-9-0-3-7"
+ d="m 367.5,431.5 7,7.25 h -3 l 2.5,4.75 -1.75,1 -2.5,-5 -2.25,2.25 z"
+ style="fill:none;stroke:#000000;stroke-width:0.89999998;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path17845-4-3-4-3-5"
+ d="m 368.34375,433.75 v 5.75"
+ style="fill:none;stroke:#ffffff;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ <path
+ style="display:inline;fill:#ffffff;fill-rule:evenodd;stroke:#b4b4b4;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new"
+ d="m 163.24481,150.52549 -8.39238,-13.43992"
+ id="path15475-0-6-8-7"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
</g>
<g
inkscape:groupmode="layer"
diff --git a/release/datafiles/blender_icons16/icon16_vis_sel_00.dat b/release/datafiles/blender_icons16/icon16_vis_sel_00.dat
new file mode 100644
index 00000000000..b08d4cbaffa
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_vis_sel_00.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_vis_sel_01.dat b/release/datafiles/blender_icons16/icon16_vis_sel_01.dat
new file mode 100644
index 00000000000..8f8f40603eb
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_vis_sel_01.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_vis_sel_10.dat b/release/datafiles/blender_icons16/icon16_vis_sel_10.dat
new file mode 100644
index 00000000000..7f92955de3c
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_vis_sel_10.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_vis_sel_11.dat b/release/datafiles/blender_icons16/icon16_vis_sel_11.dat
new file mode 100644
index 00000000000..fd2bc8f4fe8
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_vis_sel_11.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_vis_sel_00.dat b/release/datafiles/blender_icons32/icon32_vis_sel_00.dat
new file mode 100644
index 00000000000..afcba867e96
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_vis_sel_00.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_vis_sel_01.dat b/release/datafiles/blender_icons32/icon32_vis_sel_01.dat
new file mode 100644
index 00000000000..0d6375aae99
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_vis_sel_01.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_vis_sel_10.dat b/release/datafiles/blender_icons32/icon32_vis_sel_10.dat
new file mode 100644
index 00000000000..3b86427cb47
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_vis_sel_10.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_vis_sel_11.dat b/release/datafiles/blender_icons32/icon32_vis_sel_11.dat
new file mode 100644
index 00000000000..7762a97e9e8
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_vis_sel_11.dat
Binary files differ
diff --git a/release/datafiles/blender_icons_update.py b/release/datafiles/blender_icons_update.py
index 68f4ef23082..3aeb6697824 100755
--- a/release/datafiles/blender_icons_update.py
+++ b/release/datafiles/blender_icons_update.py
@@ -11,8 +11,8 @@ def run(cmd):
BASEDIR = os.path.abspath(os.path.dirname(__file__))
-inkscape_bin = "inkscape"
-blender_bin = "blender"
+inkscape_bin = os.environ.get("INKSCAPE_BIN", "inkscape")
+blender_bin = os.environ.get("BLENDER_BIN", "blender")
if sys.platform == 'darwin':
inkscape_app_path = '/Applications/Inkscape.app/Contents/Resources/script'
diff --git a/release/datafiles/studiolights/world/sl02.jpg b/release/datafiles/studiolights/world/sl02.jpg
deleted file mode 100644
index 1c9ce99a0d8..00000000000
--- a/release/datafiles/studiolights/world/sl02.jpg
+++ /dev/null
Binary files differ
diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index f26ace08ed5..11a9fbaca00 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -20,39 +20,39 @@ const bTheme U_theme_default = {
.name = "Default",
.tui = {
.wcol_regular = {
- .outline = RGBA(0x38393eff),
- .inner = RGBA(0x505158ff),
- .inner_sel = RGBA(0x80858aff),
- .item = RGBA(0x38393eff),
+ .outline = RGBA(0x373737ff),
+ .inner = RGBA(0x585858ff),
+ .inner_sel = RGBA(0x5680c2e6),
+ .item = RGBA(0x3e3e3eff),
.text = RGBA(0xebebebff),
.text_sel = RGBA(0xffffffff),
.shadedown = -5,
.roundness = 0.2f,
},
.wcol_tool = {
- .outline = RGBA(0x2f2f34ff),
- .inner = RGBA(0x505158ff),
- .inner_sel = RGBA(0x2f2f34ff),
- .item = RGBA(0xe6ebffff),
+ .outline = RGBA(0x373737ff),
+ .inner = RGBA(0x585858ff),
+ .inner_sel = RGBA(0x5680c2ff),
+ .item = RGBA(0xffffffff),
.text = RGBA(0xf2f2f2ff),
.text_sel = RGBA(0xffffffff),
.shadedown = -5,
.roundness = 0.2f,
},
.wcol_toolbar_item = {
- .outline = RGBA(0x191919ff),
- .inner = RGBA(0x505158ff),
- .inner_sel = RGBA(0x2d2d33ff),
- .item = RGBA(0x191919ff),
+ .outline = RGBA(0x373737ff),
+ .inner = RGBA(0x585858ff),
+ .inner_sel = RGBA(0x5680c2ff),
+ .item = RGBA(0xffffff8f),
.text = RGBA(0xffffffff),
.text_sel = RGBA(0xffffffff),
- .roundness = 0.25f,
+ .roundness = 0.2f,
},
.wcol_text = {
- .outline = RGBA(0x43454dff),
- .inner = RGBA(0x2d2e33ff),
- .inner_sel = RGBA(0x717280ff),
- .item = RGBA(0x599eb3ff),
+ .outline = RGBA(0x444444ff),
+ .inner = RGBA(0x1f1f1fff),
+ .inner_sel = RGBA(0x808080ff),
+ .item = RGBA(0x333333ff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
.shaded = 1,
@@ -60,9 +60,9 @@ const bTheme U_theme_default = {
.roundness = 0.2f,
},
.wcol_radio = {
- .outline = RGBA(0x424352ff),
- .inner = RGBA(0x505158ff),
- .inner_sel = RGBA(0x2d2d33ff),
+ .outline = RGBA(0x373737ff),
+ .inner = RGBA(0x595959ff),
+ .inner_sel = RGBA(0x597cb3e6),
.item = RGBA(0xffffffff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
@@ -71,70 +71,69 @@ const bTheme U_theme_default = {
.roundness = 0.2f,
},
.wcol_option = {
- .outline = RGBA(0x424352ff),
- .inner = RGBA(0x5c5c66cc),
- .inner_sel = RGBA(0x70707cff),
+ .outline = RGBA(0x373737ff),
+ .inner = RGBA(0x666666ff),
+ .inner_sel = RGBA(0x5680c2e6),
.item = RGBA(0xffffffff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
.shadedown = -15,
- .roundness = 0.25f,
+ .roundness = 0.2f,
},
.wcol_toggle = {
- .outline = RGBA(0x43434dff),
- .inner = RGBA(0x595966ff),
- .inner_sel = RGBA(0x3f7d80ff),
+ .outline = RGBA(0x373737ff),
+ .inner = RGBA(0x595959ff),
+ .inner_sel = RGBA(0x5680c2e6),
.item = RGBA(0x191919ff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
- .roundness = 0.25f,
+ .roundness = 0.2f,
},
.wcol_num = {
- .outline = RGBA(0x46464dff),
- .inner = RGBA(0x505158ff),
- .inner_sel = RGBA(0x3f7780ff),
- .item = RGBA(0x46464dff),
+ .outline = RGBA(0x444444ff),
+ .inner = RGBA(0x595959ff),
+ .inner_sel = RGBA(0xb3b3b366),
+ .item = RGBA(0x333333ff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
- .shaded = 1,
- .roundness = 0.3f,
+ .roundness = 0.2f,
},
.wcol_numslider = {
- .outline = RGBA(0x46464dff),
- .inner = RGBA(0x3f3f47ff),
- .inner_sel = RGBA(0x3f7780ff),
- .item = RGBA(0x505158ff),
+ .outline = RGBA(0x444444ff),
+ .inner = RGBA(0x595959ff),
+ .inner_sel = RGBA(0x333333ff),
+ .item = RGBA(0x5680c2e6),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
.shaded = 1,
.shadetop = -4,
- .roundness = 0.4f,
+ .roundness = 0.2f,
},
.wcol_tab = {
- .outline = RGBA(0x28292dff),
- .inner = RGBA(0x323239ff),
- .inner_sel = RGBA(0x43444bff),
- .item = RGBA(0x28292dff),
- .text = RGBA(0xbebebeff),
+ .outline = RGBA(0x2d2d2dff),
+ .inner = RGBA(0x323232ff),
+ .inner_sel = RGBA(0x4b4b4bff),
+ .item = RGBA(0x2d2d2dff),
+ .text = RGBA(0xa4a4a4ff),
.text_sel = RGBA(0xffffffff),
- .roundness = 0.15f,
+ .roundness = 0.2f,
},
.wcol_menu = {
- .outline = RGBA(0x43454dff),
- .inner = RGBA(0x29282eff),
- .inner_sel = RGBA(0x505158ff),
+ .outline = RGBA(0x444444ff),
+ .inner = RGBA(0x2c2c2cff),
+ .inner_sel = RGBA(0x696e76ff),
.item = RGBA(0xe6e6e6ff),
.text = RGBA(0xeeeeeeff),
- .text_sel = RGBA(0xccccccff),
+ .text_sel = RGBA(0xffffffff),
.shadetop = 10,
.shadedown = -10,
.roundness = 0.2f,
},
.wcol_pulldown = {
- .outline = RGBA(0x43454dff),
- .inner = RGBA(0x29282e99),
- .inner_sel = RGBA(0x505158ff),
- .item = RGBA(0x696a72ff),
+ .outline = RGBA(0x4d4d4dff),
+ .inner = RGBA(0x2e2e2e99),
+ .inner_sel = RGBA(0x5680c2ff),
+ .item = RGBA(0x727272ff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
.shadetop = 25,
@@ -142,26 +141,26 @@ const bTheme U_theme_default = {
.roundness = 0.2f,
},
.wcol_menu_back = {
- .outline = RGBA(0x29282eff),
+ .outline = RGBA(0x19191aff),
.inner = RGBA(0x1f1f1fef),
- .inner_sel = RGBA(0x505158ff),
- .item = RGBA(0x696a72ff),
+ .inner_sel = RGBA(0x585858ff),
+ .item = RGBA(0x727272ff),
.text = RGBA(0xb3b3b3ff),
.text_sel = RGBA(0xffffffff),
.shadetop = 25,
.shadedown = -20,
- .roundness = 0.25f,
+ .roundness = 0.2f,
},
.wcol_menu_item = {
- .inner_sel = RGBA(0x505158ff),
- .item = RGBA(0xacacac80),
+ .inner_sel = RGBA(0x597cb3e6),
+ .item = RGBA(0xffffff8f),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
.shadetop = 38,
- .roundness = 0.25f,
+ .roundness = 0.2f,
},
.wcol_tooltip = {
- .outline = RGBA(0x2f3035ff),
+ .outline = RGBA(0x19191aff),
.inner = RGBA(0x19191aef),
.inner_sel = RGBA(0x19191aef),
.item = RGBA(0x19191aef),
@@ -169,22 +168,22 @@ const bTheme U_theme_default = {
.text_sel = RGBA(0xffffffff),
.shadetop = 25,
.shadedown = -20,
- .roundness = 0.25f,
+ .roundness = 0.2f,
},
.wcol_box = {
- .outline = RGBA(0x2d2e33ff),
- .inner = RGBA(0x43454dff),
- .inner_sel = RGBA(0x3f7780ff),
+ .outline = RGBA(0x444444ff),
+ .inner = RGBA(0x00000033),
+ .inner_sel = RGBA(0x696e76ff),
.item = RGBA(0x191919ff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
.roundness = 0.2f,
},
.wcol_scroll = {
- .outline = RGBA(0x2f3035ff),
- .inner = RGBA(0x585a6700),
- .inner_sel = RGBA(0x599eb3ff),
- .item = RGBA(0x585a67ff),
+ .outline = RGBA(0x424242ff),
+ .inner = RGBA(0x67676700),
+ .inner_sel = RGBA(0xb3b3b3ff),
+ .item = RGBA(0x676767ff),
.text = RGBA(0xffffffff),
.text_sel = RGBA(0xffffffff),
.shadetop = 5,
@@ -192,80 +191,80 @@ const bTheme U_theme_default = {
.roundness = 0.5f,
},
.wcol_progress = {
- .outline = RGBA(0xb3b3b3ff),
- .inner = RGBA(0xccccccff),
- .inner_sel = RGBA(0x646464b4),
- .item = RGBA(0x599eb3ff),
+ .outline = RGBA(0x585858ff),
+ .inner = RGBA(0x2c2c2cff),
+ .inner_sel = RGBA(0x5680c2ff),
+ .item = RGBA(0x5680c2ff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
- .roundness = 0.25f,
+ .roundness = 0.2f,
},
.wcol_list_item = {
- .outline = RGBA(0x28292dff),
- .inner = RGBA(0x28292d00),
- .inner_sel = RGBA(0x5f616fff),
- .item = RGBA(0x599eb3ff),
- .text = RGBA(0xeeeeeeff),
+ .outline = RGBA(0x2d2d2dff),
+ .inner = RGBA(0x2d2d2d00),
+ .inner_sel = RGBA(0x696e76ff),
+ .item = RGBA(0xb3b3b3ff),
+ .text = RGBA(0xe1e1e1ff),
.text_sel = RGBA(0xffffffff),
.roundness = 0.2f,
},
.wcol_pie_menu = {
- .outline = RGBA(0x29282eff),
- .inner = RGBA(0x29282eff),
- .inner_sel = RGBA(0x505158ff),
- .item = RGBA(0x696a72ff),
+ .outline = RGBA(0x212121ff),
+ .inner = RGBA(0x212121ef),
+ .inner_sel = RGBA(0x585858ff),
+ .item = RGBA(0x597cb3ff),
.text = RGBA(0xeeeeeeff),
.text_sel = RGBA(0xffffffff),
.shadetop = 10,
.shadedown = -10,
- .roundness = 0.5f,
+ .roundness = 0.2f,
},
.wcol_state = {
- .inner_anim = RGBA(0x73be4cff),
+ .inner_anim = RGBA(0x53992eff),
.inner_anim_sel = RGBA(0x5aa633ff),
- .inner_key = RGBA(0xf0eb64ff),
+ .inner_key = RGBA(0xb3ae36ff),
.inner_key_sel = RGBA(0xd7d34bff),
- .inner_driven = RGBA(0xb400ffff),
+ .inner_driven = RGBA(0x9000ccff),
.inner_driven_sel = RGBA(0x9900e6ff),
+ .inner_overridden = RGBA(0x19c3c300),
+ .inner_overridden_sel = RGBA(0x118f8f00),
.blend = 0.5f,
},
.widget_emboss = RGBA(0x00000005),
.menu_shadow_fac = 0.3f,
.menu_shadow_width = 4,
- .editor_outline = RGBA(0x1c1d20ff),
+ .editor_outline = RGBA(0x1f1f1fff),
.icon_alpha = 1.0f,
- .icon_saturation = 0.4f,
+ .icon_saturation = 0.5f,
.xaxis = RGBA(0xff3352ff),
.yaxis = RGBA(0x8bdc00ff),
.zaxis = RGBA(0x2890ffff),
- .manipulator_hi = RGBA(0xffffffff),
- .manipulator_primary = RGBA(0xf5f14dff),
- .manipulator_secondary = RGBA(0x63ffffff),
- .manipulator_a = RGBA(0x4da84dff),
- .manipulator_b = RGBA(0xa33535ff),
+ .gizmo_hi = RGBA(0xffffffff),
+ .gizmo_primary = RGBA(0xf5f14dff),
+ .gizmo_secondary = RGBA(0x63ffffff),
+ .gizmo_a = RGBA(0x4da84dff),
+ .gizmo_b = RGBA(0xa33535ff),
},
.tbuts = {
- .back = RGBA(0x3a3c4200),
- .title = RGBA(0xeeeeeeff),
- .text = RGBA(0xffffffff),
+ .back = RGBA(0x42424200),
+ .title = RGBA(0xd4d4d4ff),
+ .text = RGBA(0xe5e5e5ff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
- .sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
+ .header = RGBA(0x42424200),
+ .back = RGBA(0x00000028),
+ .sub_back = RGBA(0x00000024),
},
.vertex_size = 3,
.outline_width = 1,
@@ -275,34 +274,31 @@ const bTheme U_theme_default = {
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c4200),
+ .header = RGBA(0x42424200),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303500),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x35353500),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242e6),
+ .back = RGBA(0x333333f0),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.gradients = {
- .gradient = RGBA(0x2d2d2e00),
- .high_gradient = RGBA(0x474748ff),
- .show_grad = 1,
+ .gradient = RGBA(0x39393900),
+ .high_gradient = RGBA(0x393939ff),
},
- .grid = RGBA(0x1f1f23ff),
+ .grid = RGBA(0x232323ff),
.wire = RGBA(0x000000ff),
.wire_edit = RGBA(0x111111ff),
.select = RGBA(0xed5700ff),
- .lamp = RGBA(0x000000ff),
+ .lamp = RGBA(0x00000028),
.speaker = RGBA(0x000000ff),
.empty = RGBA(0x000000ff),
.camera = RGBA(0x000000ff),
@@ -365,67 +361,64 @@ const bTheme U_theme_default = {
.paint_curve_handle = RGBA(0x7fff7f7f),
},
.tfile = {
- .back = RGBA(0x2f303500),
+ .back = RGBA(0x35353500),
.title = RGBA(0xffffffff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x29282eff),
+ .header = RGBA(0x2e2e2eff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
- .hilite = RGBA(0x5b8199ff),
+ .hilite = RGBA(0x4f76b3ff),
.vertex_size = 3,
.outline_width = 1,
.facedot_size = 4,
},
.tipo = {
- .back = RGBA(0x2f303500),
+ .back = RGBA(0x42424200),
.title = RGBA(0xffffffff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x29282eff),
+ .header = RGBA(0x2e2e2eff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
- .list = RGBA(0x29282eff),
+ .list = RGBA(0x2e2e2eff),
.list_title = RGBA(0xffffffff),
- .list_text = RGBA(0xccccccff),
+ .list_text = RGBA(0x000000ff),
.list_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.shade1 = RGBA(0x96969600),
- .shade2 = RGBA(0x29282e64),
- .grid = RGBA(0x17171aff),
- .group = RGBA(0x247f0dff),
- .group_active = RGBA(0x46a431ff),
+ .shade2 = RGBA(0x2e2e2e64),
+ .grid = RGBA(0x2a2a2aff),
+ .group = RGBA(0x44992eff),
+ .group_active = RGBA(0x5ccd3eff),
+ .vertex = RGBA(0x000000ff),
.vertex_select = RGBA(0xff8500ff),
- .cframe = RGBA(0x308837ff),
+ .cframe = RGBA(0x5680c2ff),
.lastsel_point = RGBA(0xffffffff),
.handle_auto = RGBA(0x909000ff),
.handle_vect = RGBA(0x409030ff),
@@ -435,8 +428,8 @@ const bTheme U_theme_default = {
.handle_sel_vect = RGBA(0x40c030ff),
.handle_sel_align = RGBA(0xf090a0ff),
.handle_sel_auto_clamped = RGBA(0xf0af90ff),
- .ds_channel = RGBA(0x26537fff),
- .ds_subchannel = RGBA(0x6a90b2ff),
+ .ds_channel = RGBA(0x5a85b2ff),
+ .ds_subchannel = RGBA(0x7d98b3ff),
.vertex_size = 6,
.outline_width = 1,
.facedot_size = 4,
@@ -444,27 +437,25 @@ const bTheme U_theme_default = {
.handle_vertex_size = 5,
},
.tinfo = {
- .back = RGBA(0x3a3c4200),
+ .back = RGBA(0x42424200),
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.vertex_size = 3,
.outline_width = 1,
@@ -480,43 +471,41 @@ const bTheme U_theme_default = {
.info_debug = RGBA(0xd3d3d3ff),
},
.tact = {
- .back = RGBA(0x3a3c4200),
+ .back = RGBA(0x42424200),
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
- .list = RGBA(0x29282eff),
+ .list = RGBA(0x2e2e2eff),
.list_title = RGBA(0xd8d8d8ff),
- .list_text = RGBA(0xffffffff),
+ .list_text = RGBA(0x000000ff),
.list_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.shade1 = RGBA(0xc0c0c000),
.shade2 = RGBA(0x70707064),
.hilite = RGBA(0x60c040ff),
- .grid = RGBA(0x17171aff),
- .group = RGBA(0x278c0eff),
- .group_active = RGBA(0x4eb335ff),
+ .grid = RGBA(0x2a2a2aff),
+ .group = RGBA(0x44992eff),
+ .group_active = RGBA(0x5ccd3eff),
.strip = RGBA(0x1a151580),
.strip_select = RGBA(0xff8c00ff),
- .cframe = RGBA(0x308837ff),
- .ds_channel = RGBA(0x2e6399ff),
- .ds_subchannel = RGBA(0x5a7996ff),
+ .cframe = RGBA(0x5680c2ff),
+ .ds_channel = RGBA(0x5a85b2ff),
+ .ds_subchannel = RGBA(0x7d98b3ff),
.keytype_keyframe = RGBA(0xe8e8e8ff),
.keytype_extreme = RGBA(0xe8b3ccff),
.keytype_breakdown = RGBA(0xb3dbe8ff),
@@ -532,40 +521,38 @@ const bTheme U_theme_default = {
.facedot_size = 4,
.keyframe_scale_fac = 1.0f,
.handle_vertex_size = 4,
- .anim_active = RGBA(0x66310066),
+ .anim_active = RGBA(0xa14d0066),
},
.tnla = {
- .back = RGBA(0x2f303500),
+ .back = RGBA(0x35353500),
.title = RGBA(0xffffffff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x29282eff),
+ .header = RGBA(0x212121ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
- .list = RGBA(0x29282eff),
+ .list = RGBA(0x2e2e2eff),
.list_title = RGBA(0xffffffff),
.list_text = RGBA(0xccccccff),
.list_text_hi = RGBA(0xccccccff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.shade1 = RGBA(0x96969600),
.grid = RGBA(0x5e5e5eff),
.strip = RGBA(0x0c0a0a80),
.strip_select = RGBA(0xff8c00ff),
- .cframe = RGBA(0x308837ff),
+ .cframe = RGBA(0x5680c2ff),
.keyborder = RGBA(0x000000ff),
.keyborder_select = RGBA(0x000000ff),
.vertex_size = 3,
@@ -584,33 +571,31 @@ const bTheme U_theme_default = {
.nla_sound_sel = RGBA(0x1f7a7aff),
},
.tseq = {
- .back = RGBA(0x3a3c4200),
+ .back = RGBA(0x42424200),
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.shade1 = RGBA(0xa0a0a000),
.grid = RGBA(0x404040ff),
.vertex_select = RGBA(0xff8500ff),
.bone_pose = RGBA(0x50c8ff50),
- .cframe = RGBA(0x308837ff),
+ .cframe = RGBA(0x5680c2ff),
.vertex_size = 3,
.outline_width = 1,
.facedot_size = 4,
@@ -632,23 +617,21 @@ const bTheme U_theme_default = {
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.wire_edit = RGBA(0xc0c0c0ff),
.vertex_select = RGBA(0xff8500ff),
@@ -684,27 +667,25 @@ const bTheme U_theme_default = {
.metadatatext = RGBA(0xffffffff),
},
.text = {
- .back = RGBA(0x22242700),
+ .back = RGBA(0x30303000),
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x42424200),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x42424200),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.shade2 = RGBA(0x19191aff),
.hilite = RGBA(0xff0000ff),
@@ -722,33 +703,31 @@ const bTheme U_theme_default = {
.syntaxr = RGBA(0xc4753bff),
},
.toops = {
- .back = RGBA(0x3a3c4200),
+ .back = RGBA(0x35353500),
.title = RGBA(0xffffffff),
- .text = RGBA(0xdededeff),
+ .text = RGBA(0xc3c3c3ff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3f3f45ff),
+ .header = RGBA(0x454545ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.vertex_size = 3,
.outline_width = 1,
.facedot_size = 4,
.match = RGBA(0x337f334c),
- .selected_highlight = RGBA(0x747a834c),
+ .selected_highlight = RGBA(0x696e764c),
},
.ttime = {
.vertex_size = 3,
@@ -756,149 +735,142 @@ const bTheme U_theme_default = {
.facedot_size = 4,
},
.tnode = {
- .back = RGBA(0x2a2c3200),
+ .back = RGBA(0x23232300),
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
- .list = RGBA(0x29282eff),
+ .list = RGBA(0x2e2e2eff),
.list_title = RGBA(0xffffffff),
.list_text = RGBA(0xccccccff),
.list_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.shade2 = RGBA(0x7f707064),
.wire = RGBA(0x808080ff),
- .select = RGBA(0x099be6ff),
+ .select = RGBA(0xed5700ff),
.active = RGBA(0xffffffff),
.edge_select = RGBA(0xffffffff),
- .console_output = RGBA(0xdfc300ff),
+ .console_output = RGBA(0x1a1a1aff),
.vertex_size = 3,
.outline_width = 1,
.facedot_size = 4,
- .syntaxl = RGBA(0x5a5c66ff),
- .syntaxs = RGBA(0x977474ff),
- .syntaxb = RGBA(0xffcb4dff),
- .syntaxn = RGBA(0xff6675ff),
+ .syntaxl = RGBA(0x565656ff),
+ .syntaxs = RGBA(0x975b5bff),
+ .syntaxb = RGBA(0xccb83dff),
+ .syntaxn = RGBA(0xe64555ff),
.syntaxv = RGBA(0x66c4ffff),
- .syntaxc = RGBA(0x59b36aff),
+ .syntaxc = RGBA(0x426628ff),
.syntaxd = RGBA(0x749797ff),
.syntaxr = RGBA(0x808080ff),
- .nodeclass_output = RGBA(0xff6675ff),
- .nodeclass_filter = RGBA(0x6c696fff),
- .nodeclass_vector = RGBA(0x9999ffff),
- .nodeclass_texture = RGBA(0xffc399ff),
- .nodeclass_shader = RGBA(0xa7ff99ff),
- .nodeclass_script = RGBA(0x6c696fff),
+ .nodeclass_output = RGBA(0xb33641ff),
+ .nodeclass_filter = RGBA(0x584d80ff),
+ .nodeclass_vector = RGBA(0x9b80ffff),
+ .nodeclass_texture = RGBA(0xe68745ff),
+ .nodeclass_shader = RGBA(0x39c884ff),
+ .nodeclass_script = RGBA(0x084d4dff),
.nodeclass_pattern = RGBA(0x6c696fff),
.nodeclass_layout = RGBA(0x6c696fff),
- .movie = RGBA(0x9b9b9ba0),
+ .movie = RGBA(0x1a1a1acc),
.gp_vertex_size = 3,
+ .gp_vertex = RGBA(0x97979700),
.gp_vertex_select = RGBA(0xff8500ff),
},
.tuserpref = {
- .back = RGBA(0x3a3c4200),
+ .back = RGBA(0x42424200),
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x42424200),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.vertex_size = 3,
.outline_width = 1,
.facedot_size = 4,
},
.tconsole = {
- .back = RGBA(0x22242700),
+ .back = RGBA(0x30303000),
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
- .console_output = RGBA(0xb3c2ffff),
- .console_input = RGBA(0xffffffff),
- .console_info = RGBA(0x47b347ff),
- .console_error = RGBA(0xde6f6fff),
- .console_cursor = RGBA(0xde5959ff),
+ .console_output = RGBA(0x71a8ffff),
+ .console_input = RGBA(0xf2f2f2ff),
+ .console_info = RGBA(0x95d600ff),
+ .console_error = RGBA(0xff4d84ff),
+ .console_cursor = RGBA(0xff0000ff),
.console_select = RGBA(0xffffff30),
.vertex_size = 3,
.outline_width = 1,
.facedot_size = 4,
},
.tclip = {
- .back = RGBA(0x3a3c4200),
+ .back = RGBA(0x42424200),
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x3a3c42ff),
+ .header = RGBA(0x424242ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.list = RGBA(0x666666ff),
.list_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.strip = RGBA(0x0c0a0a80),
.strip_select = RGBA(0xff8c00ff),
- .cframe = RGBA(0x308837ff),
+ .cframe = RGBA(0x5680c2ff),
.handle_auto = RGBA(0x909000ff),
.handle_align = RGBA(0x803060ff),
.handle_sel_auto = RGBA(0xf0ff40ff),
@@ -918,27 +890,25 @@ const bTheme U_theme_default = {
.gp_vertex_size = 1,
},
.ttopbar = {
- .back = RGBA(0x43444b00),
+ .back = RGBA(0x4b4b4b00),
.title = RGBA(0xffffffff),
.text = RGBA(0xffffffff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x1f1f23ff),
+ .header = RGBA(0x232323ff),
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f303599),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x424242ff),
.button_title = RGBA(0xffffffff),
- .button_text = RGBA(0xffffffff),
+ .button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.vertex_size = 3,
.outline_width = 1,
@@ -946,25 +916,23 @@ const bTheme U_theme_default = {
.gp_vertex_size = 3,
},
.tstatusbar = {
- .back = RGBA(0x29282e00),
- .title = RGBA(0xe4e8ffff),
- .text = RGBA(0x747a83ff),
+ .back = RGBA(0x2e2e2e00),
+ .title = RGBA(0xffffffff),
+ .text = RGBA(0x838383ff),
.text_hi = RGBA(0xffffffff),
- .header = RGBA(0x1f1f23ff),
- .header_text = RGBA(0x959eaaff),
+ .header = RGBA(0x303030ff),
+ .header_text = RGBA(0xaaaaaaff),
.header_text_hi = RGBA(0xffffffff),
- .tab_active = RGBA(0x43444bff),
- .tab_inactive = RGBA(0x323239ff),
- .tab_back = RGBA(0x1f1f23ff),
- .tab_outline = RGBA(0x28292dff),
- .button = RGBA(0x2f3035ff),
+ .tab_active = RGBA(0x5680c2ff),
+ .tab_inactive = RGBA(0x424242ff),
+ .tab_back = RGBA(0x232323ff),
+ .tab_outline = RGBA(0x2d2d2dff),
+ .button = RGBA(0x353535ff),
.button_text_hi = RGBA(0xffffffff),
.panelcolors = {
- .header = RGBA(0x3a3c42cc),
- .back = RGBA(0x2c2e33b3),
+ .header = RGBA(0x424242cc),
+ .back = RGBA(0x333333b3),
.sub_back = RGBA(0x0000003e),
- .show_header = 1,
- .show_back = 1,
},
.vertex_size = 3,
.outline_width = 1,
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py
index c74286c8fb6..86185b96e9d 100644
--- a/release/scripts/modules/addon_utils.py
+++ b/release/scripts/modules/addon_utils.py
@@ -78,7 +78,7 @@ def modules_refresh(module_cache=addons_fake_modules):
try:
file_mod = open(mod_path, "r", encoding='UTF-8')
except OSError as ex:
- print("Error opening file %r: %s" % (mod_path, ex))
+ print("Error opening file:", mod_path, ex)
return None
with file_mod:
@@ -116,7 +116,7 @@ def modules_refresh(module_cache=addons_fake_modules):
try:
ast_data = ast.parse(data, filename=mod_path)
except:
- print("Syntax error 'ast.parse' can't read %r" % mod_path)
+ print("Syntax error 'ast.parse' can't read:", repr(mod_path))
import traceback
traceback.print_exc()
ast_data = None
@@ -138,7 +138,7 @@ def modules_refresh(module_cache=addons_fake_modules):
mod.__file__ = mod_path
mod.__time__ = os.path.getmtime(mod_path)
except:
- print("AST error parsing bl_info for %s" % mod_name)
+ print("AST error parsing bl_info for:", mod_name)
import traceback
traceback.print_exc()
raise
@@ -148,8 +148,11 @@ def modules_refresh(module_cache=addons_fake_modules):
return mod
else:
- print("fake_module: addon missing 'bl_info' "
- "gives bad performance!: %r" % mod_path)
+ print(
+ "fake_module: addon missing 'bl_info' "
+ "gives bad performance!:",
+ repr(mod_path),
+ )
return None
modules_stale = set(module_cache.keys())
@@ -167,17 +170,21 @@ def modules_refresh(module_cache=addons_fake_modules):
mod = module_cache.get(mod_name)
if mod:
if mod.__file__ != mod_path:
- print("multiple addons with the same name:\n %r\n %r" %
- (mod.__file__, mod_path))
+ print(
+ "multiple addons with the same name:\n"
+ " " f"{mod.__file__!r}" "\n"
+ " " f"{mod_path!r}"
+ )
error_duplicates.append((mod.bl_info["name"], mod.__file__, mod_path))
elif mod.__time__ != os.path.getmtime(mod_path):
- print("reloading addon:",
- mod_name,
- mod.__time__,
- os.path.getmtime(mod_path),
- mod_path,
- )
+ print(
+ "reloading addon:",
+ mod_name,
+ mod.__time__,
+ os.path.getmtime(mod_path),
+ repr(mod_path),
+ )
del module_cache[mod_name]
mod = None
@@ -209,6 +216,8 @@ def modules(module_cache=addons_fake_modules, *, refresh=True):
)
)
return mod_list
+
+
modules._is_first = True
@@ -231,10 +240,12 @@ def check(module_name):
)
if loaded_state is Ellipsis:
- print("Warning: addon-module %r found module "
- "but without __addon_enabled__ field, "
- "possible name collision from file: %r" %
- (module_name, getattr(mod, "__file__", "<unknown>")))
+ print(
+ "Warning: addon-module " f"{module_name:s}" " found module "
+ "but without '__addon_enabled__' field, "
+ "possible name collision from file:",
+ repr(getattr(mod, "__file__", "<unknown>")),
+ )
loaded_state = False
@@ -301,8 +312,10 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
try:
mod.unregister()
except Exception as ex:
- print("Exception in module unregister(): %r" %
- getattr(mod, "__file__", module_name))
+ print(
+ "Exception in module unregister():",
+ repr(getattr(mod, "__file__", module_name)),
+ )
handle_error(ex)
return None
@@ -311,7 +324,7 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
mtime_new = os.path.getmtime(mod.__file__)
if mtime_orig != mtime_new:
import importlib
- print("module changed on disk:", mod.__file__, "reloading...")
+ print("module changed on disk:", repr(mod.__file__), "reloading...")
try:
importlib.reload(mod)
@@ -341,7 +354,7 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
except Exception as ex:
# if the addon doesn't exist, dont print full traceback
if type(ex) is ImportError and ex.name == module_name:
- print("addon not found: %r" % module_name)
+ print("addon not found:", repr(module_name))
else:
handle_error(ex)
@@ -349,6 +362,29 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
_addon_remove(module_name)
return None
+ # 1.1) fail when add-on is too old
+ # This is a temporary 2.8x migration check, so we can manage addons that are supported.
+
+ # Silent default, we know these need updating.
+ if module_name in {
+ "io_anim_bvh",
+ "io_mesh_ply",
+ "io_mesh_stl",
+ "io_mesh_uv_layout",
+ "io_scene_3ds",
+ "io_scene_fbx",
+ "io_scene_obj",
+ "io_scene_x3d",
+ }:
+ return None
+
+ try:
+ if mod.bl_info.get("blender", (0, 0, 0)) < (2, 80, 0):
+ raise Exception(f"Add-on '{module_name:s}' has not been upgraded to 2.8, ignoring")
+ except Exception as ex:
+ handle_error(ex)
+ return None
+
# 2) try register collected modules
# removed, addons need to handle own registration now.
@@ -362,8 +398,10 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
try:
mod.register()
except Exception as ex:
- print("Exception in module register(): %r" %
- getattr(mod, "__file__", module_name))
+ print(
+ "Exception in module register():",
+ getattr(mod, "__file__", module_name),
+ )
handle_error(ex)
del sys.modules[module_name]
if default_set:
@@ -413,12 +451,15 @@ def disable(module_name, *, default_set=False, handle_error=None):
try:
mod.unregister()
except Exception as ex:
- print("Exception in module unregister(): %r" %
- getattr(mod, "__file__", module_name))
+ mod_path = getattr(mod, "__file__", module_name)
+ print("Exception in module unregister():", repr(mod_path))
+ del mod_path
handle_error(ex)
else:
- print("addon_utils.disable: %s not %s." %
- (module_name, "disabled" if mod is None else "loaded"))
+ print(
+ "addon_utils.disable: " f"{module_name:s}" " not",
+ ("disabled" if mod is None else "loaded")
+ )
# could be in more than once, unlikely but better do this just in case.
if default_set:
diff --git a/release/scripts/modules/bl_app_override/__init__.py b/release/scripts/modules/bl_app_override/__init__.py
index f17878b4822..2104b10bf85 100644
--- a/release/scripts/modules/bl_app_override/__init__.py
+++ b/release/scripts/modules/bl_app_override/__init__.py
@@ -172,6 +172,7 @@ def ui_draw_filter_register(
class Wrapper(cls_real):
__slots__ = ()
+
def __getattribute__(self, attr):
if attr == "layout":
return UILayout_Fake(self_real.layout)
diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
index bbeb1780355..b395aab7772 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
@@ -120,8 +120,11 @@ def check(check_ctxt, msgs, key, msgsrc, settings):
key[1][0].isalpha() and not key[1][0].isupper()):
not_capitalized.add(key)
if end_point is not None:
- if (key[1].strip().endswith('.') and not key[1].strip().endswith('...') and
- key[1] not in settings.WARN_MSGID_END_POINT_ALLOWED):
+ if (
+ key[1].strip().endswith('.') and
+ (not key[1].strip().endswith('...')) and
+ key[1] not in settings.WARN_MSGID_END_POINT_ALLOWED
+ ):
end_point.add(key)
if undoc_ops is not None:
if key[1] == settings.UNDOC_OPS_STR:
@@ -183,8 +186,10 @@ def print_info(reports, pot):
# if py_in_rna and key in py_in_rna:
# _print("\t\t-> RNA message also used in py UI code!")
if spell_errors and spell_errors.get(key):
- lines = ["\t\t-> {}: misspelled, suggestions are ({})".format(w, "'" + "', '".join(errs) + "'")
- for w, errs in spell_errors[key]]
+ lines = [
+ "\t\t-> {}: misspelled, suggestions are ({})".format(w, "'" + "', '".join(errs) + "'")
+ for w, errs in spell_errors[key]
+ ]
_print("\n".join(lines))
_print("\t\t{}".format("\n\t\t".join(pot.msgs[key].sources)))
@@ -215,13 +220,13 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
"""
def class_blacklist():
blacklist_rna_class = {getattr(bpy.types, cls_id) for cls_id in (
- # core classes
- "Context", "Event", "Function", "UILayout", "UnknownType", "Property", "Struct",
- # registerable classes
- "Panel", "Menu", "Header", "RenderEngine", "Operator", "OperatorMacro", "Macro", "KeyingSetInfo",
- # window classes
- "Window",
- )
+ # core classes
+ "Context", "Event", "Function", "UILayout", "UnknownType", "Property", "Struct",
+ # registerable classes
+ "Panel", "Menu", "Header", "RenderEngine", "Operator", "OperatorMacro", "Macro", "KeyingSetInfo",
+ # window classes
+ "Window",
+ )
}
# More builtin classes we don't need to parse.
@@ -380,12 +385,13 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
# Dump Messages
operator_categories = {}
+
def process_cls_list(cls_list):
if not cls_list:
return
def full_class_id(cls):
- """Gives us 'ID.Lamp.AreaLamp' which is best for sorting."""
+ """Gives us 'ID.Light.AreaLight' which is best for sorting."""
# Always the same issue, some classes listed in blacklist should actually no more exist (they have been
# unregistered), but are still listed by __subclasses__() calls... :/
if cls in blacklist_rna_class:
@@ -447,6 +453,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings):
i18n_contexts = bpy.app.translations.contexts
root_paths = tuple(bpy.utils.resource_path(t) for t in ('USER', 'LOCAL', 'SYSTEM'))
+
def make_rel(path):
for rp in root_paths:
if path.startswith(rp):
@@ -510,6 +517,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings):
return [_extract_string_merge(estr_ls, nds_ls) for estr_ls, nds_ls in bag]
i18n_ctxt_ids = {v for v in bpy.app.translations.contexts_C_to_py.values()}
+
def _ctxt_to_ctxt(node):
# We must try, to some extend, to get contexts from vars instead of only literal strings...
ctxt = extract_strings(node)[0]
@@ -561,9 +569,9 @@ def dump_py_messages_from_files(msgs, reports, files, settings):
translate_kw = {
"text": ((("text_ctxt",), _ctxt_to_ctxt),
(("operator",), _op_to_ctxt),
- ),
- "msgid": ((("msgctxt",), _ctxt_to_ctxt),
),
+ "msgid": ((("msgctxt",), _ctxt_to_ctxt),
+ ),
"message": (),
}
@@ -611,7 +619,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings):
func_translate_args[func_id] = pgettext_variants_args
for func_id in func_ids:
func_translate_args[func_id] = pgettext_variants_args
- #print(func_translate_args)
+ # print(func_translate_args)
# Break recursive nodes look up on some kind of nodes.
# E.g. we don't want to get strings inside subscripts (blah["foo"])!
@@ -666,7 +674,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings):
if kw.arg == arg_kw:
context_elements[arg_kw] = kw.value
break
- #print(context_elements)
+ # print(context_elements)
for kws, proc in translate_kw[msgid]:
if set(kws) <= context_elements.keys():
args = tuple(context_elements[k] for k in kws)
@@ -676,7 +684,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings):
msgctxts[msgid] = ctxt
break
- #print(translate_args)
+ # print(translate_args)
# do nothing if not found
for arg_kw, (arg_pos, _) in func_args.items():
msgctxt = msgctxts[arg_kw]
@@ -706,7 +714,7 @@ def dump_py_messages(msgs, reports, addons, settings, addons_only=False):
return []
if os.path.isdir(path):
return [os.path.join(dpath, fn) for dpath, _, fnames in os.walk(path) for fn in fnames
- if not fn.startswith("_") and fn.endswith(".py")]
+ if not fn.startswith("_") and fn.endswith(".py")]
return [path]
files = []
@@ -738,7 +746,9 @@ def dump_src_messages(msgs, reports, settings):
pygettexts = tuple(re.compile(r).search for r in settings.PYGETTEXT_KEYWORDS)
_clean_str = re.compile(settings.str_clean_re).finditer
- clean_str = lambda s: "".join(m.group("clean") for m in _clean_str(s))
+
+ def clean_str(s):
+ return "".join(m.group("clean") for m in _clean_str(s))
def dump_src_file(path, rel_path, msgs, reports, settings):
def process_entry(_msgctxt, _msgid):
@@ -873,10 +883,10 @@ def dump_messages(do_messages, do_checks, settings):
process_msg(msgs, settings.DEFAULT_CONTEXT, cat[1],
"Language categories’ labels from bl_i18n_utils/settings.py", reports, None, settings)
- #pot.check()
+ # pot.check()
pot.unescape() # Strings gathered in py/C source code may contain escaped chars...
print_info(reports, pot)
- #pot.check()
+ # pot.check()
if do_messages:
print("Writing messages…")
diff --git a/release/scripts/modules/bl_i18n_utils/merge_po.py b/release/scripts/modules/bl_i18n_utils/merge_po.py
index ecb26123999..7e3c8a42b17 100755
--- a/release/scripts/modules/bl_i18n_utils/merge_po.py
+++ b/release/scripts/modules/bl_i18n_utils/merge_po.py
@@ -43,14 +43,17 @@ else:
# XXX This is a quick hack to make it work with new I18n... objects! To be reworked!
def main():
import argparse
- parser = argparse.ArgumentParser(description=
- "Merge one or more .po files into the first dest one.\n"
- "If a msgkey (msgctxt, msgid) is present in more than one merged po, the one in the first file "
- "wins, unless it’s marked as fuzzy and one later is not.\n"
- "The fuzzy flag is removed if necessary.\n"
- "All other comments are never modified.\n"
- "Commented messages in dst will always remain commented, and commented messages are never merged "
- "from sources.")
+ parser = argparse.ArgumentParser(
+ description=(
+ "Merge one or more .po files into the first dest one.\n"
+ "If a msgkey (msgctxt, msgid) is present in more than one merged po, the one in the first file "
+ "wins, unless it’s marked as fuzzy and one later is not.\n"
+ "The fuzzy flag is removed if necessary.\n"
+ "All other comments are never modified.\n"
+ "Commented messages in dst will always remain commented, and commented messages are never merged "
+ "from sources."
+ ),
+ )
parser.add_argument('-s', '--stats', action="store_true", help="Show statistics info.")
parser.add_argument('-r', '--replace', action="store_true",
help="Replace existing messages of same \"level\" already in dest po.")
diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py
index 5fdb6b88cbf..880721176e0 100644
--- a/release/scripts/modules/bl_i18n_utils/utils.py
+++ b/release/scripts/modules/bl_i18n_utils/utils.py
@@ -32,9 +32,9 @@ import tempfile
#import time
from bl_i18n_utils import (
- settings,
- utils_rtl,
- )
+ settings,
+ utils_rtl,
+)
import bpy
@@ -44,6 +44,8 @@ from bpy.app.translations import locale_explode
_valid_po_path_re = re.compile(r"^\S+:[0-9]+$")
+
+
def is_valid_po_path(path):
return bool(_valid_po_path_re.match(path))
@@ -57,9 +59,10 @@ def get_best_similar(data):
# We also consider to never make a match when len differs more than -len_key / 2, +len_key * 2 (which is valid
# as long as use_similar is not below ~0.7).
# Gives an overall ~20% of improvement!
- #tmp = difflib.get_close_matches(key[1], similar_pool, n=1, cutoff=use_similar)
- #if tmp:
- #tmp = tmp[0]
+
+ # tmp = difflib.get_close_matches(key[1], similar_pool, n=1, cutoff=use_similar)
+ # if tmp:
+ # tmp = tmp[0]
tmp = None
s = difflib.SequenceMatcher()
s.set_seq2(key[1])
@@ -178,9 +181,11 @@ def enable_addons(addons=None, support=None, disable=False, check_only=False):
userpref = bpy.context.user_preferences
used_ext = {ext.module for ext in userpref.addons}
- ret = [mod for mod in addon_utils.modules()
- if ((addons and mod.__name__ in addons) or
- (not addons and addon_utils.module_bl_info(mod)["support"] in support))]
+ ret = [
+ mod for mod in addon_utils.modules()
+ if ((addons and mod.__name__ in addons) or
+ (not addons and addon_utils.module_bl_info(mod)["support"] in support))
+ ]
if not check_only:
for mod in ret:
@@ -229,18 +234,21 @@ class I18nMessage:
def _get_msgctxt(self):
return "".join(self.msgctxt_lines)
+
def _set_msgctxt(self, ctxt):
self.msgctxt_lines = [ctxt]
msgctxt = property(_get_msgctxt, _set_msgctxt)
def _get_msgid(self):
return "".join(self.msgid_lines)
+
def _set_msgid(self, msgid):
self.msgid_lines = [msgid]
msgid = property(_get_msgid, _set_msgid)
def _get_msgstr(self):
return "".join(self.msgstr_lines)
+
def _set_msgstr(self, msgstr):
self.msgstr_lines = [msgstr]
msgstr = property(_get_msgstr, _set_msgstr)
@@ -250,12 +258,15 @@ class I18nMessage:
lstrip2 = len(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM)
return ([l[lstrip1:] for l in self.comment_lines if l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE)] +
[l[lstrip2:] for l in self.comment_lines
- if l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM)])
+ if l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM)])
+
def _set_sources(self, sources):
cmmlines = self.comment_lines.copy()
for l in cmmlines:
- if (l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE) or
- l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM)):
+ if (
+ l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE) or
+ l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM)
+ ):
self.comment_lines.remove(l)
lines_src = []
lines_src_custom = []
@@ -791,7 +802,7 @@ class I18nMessages:
if len(k) > 1 and src_rna in src_to_msg:
k &= src_to_msg[src_rna]
msgmap["rna_tip"]["key"] = k
- #print(k)
+ # print(k)
btip = getattr(msgs, msgmap["but_tip"]["msgstr"])
#print("button tip: " + btip)
if btip and btip not in {rtip, etip}:
@@ -1051,12 +1062,13 @@ class I18nMessages:
import subprocess
with tempfile.NamedTemporaryFile(mode='w+', encoding="utf-8") as tmp_po_f:
self.write_messages_to_po(tmp_po_f)
- cmd = (self.settings.GETTEXT_MSGFMT_EXECUTABLE,
- "--statistics", # show stats
- tmp_po_f.name,
- "-o",
- fname,
- )
+ cmd = (
+ self.settings.GETTEXT_MSGFMT_EXECUTABLE,
+ "--statistics", # show stats
+ tmp_po_f.name,
+ "-o",
+ fname,
+ )
print("Running ", " ".join(cmd))
ret = subprocess.call(cmd)
print("Finished.")
@@ -1081,6 +1093,7 @@ class I18nMessages:
EOT = b"0x04" # Used to concatenate context and msgid
_msgid_offset = 0
_msgstr_offset = 0
+
def _gen(v):
nonlocal _msgid_offset, _msgstr_offset
msgid = v.msgid.encode("utf-8")
@@ -1188,6 +1201,7 @@ class I18n:
def _py_file_get(self):
return self.src.get(self.settings.PARSER_PY_ID)
+
def _py_file_set(self, value):
self.src[self.settings.PARSER_PY_ID] = value
py_file = property(_py_file_get, _py_file_set)
@@ -1252,7 +1266,8 @@ class I18n:
_ctx_txt = "s are"
else:
_ctx_txt = " is"
- lines = (("",
+ lines = ((
+ "",
"Average stats for all {} translations:\n".format(self.nbr_trans),
" {:>6.1%} done!\n".format(self.lvl / self.nbr_trans),
" {:>6.1%} of messages are tooltips.\n".format(self.lvl_ttips / self.nbr_trans),
@@ -1350,10 +1365,10 @@ class I18n:
comment_lines = [self.settings.PO_COMMENT_PREFIX + c for c in user_comments] + common_comment_lines
self.trans[uid].msgs[key] = I18nMessage(ctxt, [key[1]], [msgstr], comment_lines, False, is_fuzzy,
settings=self.settings)
- #key = self.settings.PO_HEADER_KEY
- #for uid, trans in self.trans.items():
- #if key not in trans.msgs:
- #trans.msgs[key]
+ # key = self.settings.PO_HEADER_KEY
+ # for uid, trans in self.trans.items():
+ # if key not in trans.msgs:
+ # trans.msgs[key]
self.unescape()
def write(self, kind, langs=set()):
diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
index fb3a18c6bea..16b0b107927 100644
--- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py
+++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
@@ -31,7 +31,7 @@ from mathutils import (
)
-INTERN_PREVIEW_TYPES = {'MATERIAL', 'LAMP', 'WORLD', 'TEXTURE', 'IMAGE'}
+INTERN_PREVIEW_TYPES = {'MATERIAL', 'LIGHT', 'WORLD', 'TEXTURE', 'IMAGE'}
OBJECT_TYPES_RENDER = {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'}
@@ -73,15 +73,15 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
# Helpers.
RenderContext = collections.namedtuple("RenderContext", (
- "scene", "world", "camera", "lamp", "camera_data", "lamp_data", "image", # All those are names!
- "backup_scene", "backup_world", "backup_camera", "backup_lamp", "backup_camera_data", "backup_lamp_data",
+ "scene", "world", "camera", "light", "camera_data", "light_data", "image", # All those are names!
+ "backup_scene", "backup_world", "backup_camera", "backup_light", "backup_camera_data", "backup_light_data",
))
RENDER_PREVIEW_SIZE = bpy.app.render_preview_size
def render_context_create(engine, objects_ignored):
if engine == '__SCENE':
- backup_scene, backup_world, backup_camera, backup_lamp, backup_camera_data, backup_lamp_data = [()] * 6
+ backup_scene, backup_world, backup_camera, backup_light, backup_camera_data, backup_light_data = [()] * 6
scene = bpy.context.screen.scene
exclude_props = {('world',), ('camera',), ('tool_settings',), ('preview',)}
backup_scene = tuple(rna_backup_gen(scene, exclude_props=exclude_props))
@@ -96,20 +96,20 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
camera.rotation_euler = Euler((1.1635528802871704, 0.0, 0.7853981852531433), 'XYZ') # (66.67, 0.0, 45.0)
scene.camera = camera
scene.objects.link(camera)
- # TODO: add lamp if none found in scene?
- lamp = None
- lamp_data = None
+ # TODO: add light if none found in scene?
+ light = None
+ light_data = None
else:
- backup_scene, backup_world, backup_camera, backup_lamp, backup_camera_data, backup_lamp_data = [None] * 6
+ backup_scene, backup_world, backup_camera, backup_light, backup_camera_data, backup_light_data = [None] * 6
scene = bpy.data.scenes.new("TEMP_preview_render_scene")
world = bpy.data.worlds.new("TEMP_preview_render_world")
camera_data = bpy.data.cameras.new("TEMP_preview_render_camera")
camera = bpy.data.objects.new("TEMP_preview_render_camera", camera_data)
- lamp_data = bpy.data.lamps.new("TEMP_preview_render_lamp", 'SPOT')
- lamp = bpy.data.objects.new("TEMP_preview_render_lamp", lamp_data)
+ light_data = bpy.data.lights.new("TEMP_preview_render_light", 'SPOT')
+ light = bpy.data.objects.new("TEMP_preview_render_light", light_data)
- objects_ignored.add((camera.name, lamp.name))
+ objects_ignored.add((camera.name, light.name))
scene.world = world
@@ -117,26 +117,14 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
scene.camera = camera
scene.objects.link(camera)
- lamp.rotation_euler = Euler((0.7853981852531433, 0.0, 1.7453292608261108), 'XYZ') # (45.0, 0.0, 100.0)
- lamp_data.falloff_type = 'CONSTANT'
- lamp_data.spot_size = 1.0471975803375244 # 60
- scene.objects.link(lamp)
-
- if engine == 'BLENDER_RENDER':
- scene.render.engine = 'BLENDER_RENDER'
- scene.render.alpha_mode = 'TRANSPARENT'
-
- world.use_sky_blend = True
- world.horizon_color = 0.9, 0.9, 0.9
- world.zenith_color = 0.5, 0.5, 0.5
- world.ambient_color = 0.1, 0.1, 0.1
- world.light_settings.use_environment_light = True
- world.light_settings.environment_energy = 1.0
- world.light_settings.environment_color = 'SKY_COLOR'
- elif engine == 'CYCLES':
- scene.render.engine = 'CYCLES'
- scene.cycles.film_transparent = True
- # TODO: define Cycles world?
+ light.rotation_euler = Euler((0.7853981852531433, 0.0, 1.7453292608261108), 'XYZ') # (45.0, 0.0, 100.0)
+ light_data.falloff_type = 'CONSTANT'
+ light_data.spot_size = 1.0471975803375244 # 60
+ scene.objects.link(light)
+
+ scene.render.engine = 'CYCLES'
+ scene.cycles.film_transparent = True
+ # TODO: define Cycles world?
scene.render.image_settings.file_format = 'PNG'
scene.render.image_settings.color_depth = '8'
@@ -154,9 +142,9 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
image.filepath = scene.render.filepath
return RenderContext(
- scene.name, world.name if world else None, camera.name, lamp.name if lamp else None,
- camera_data.name, lamp_data.name if lamp_data else None, image.name,
- backup_scene, backup_world, backup_camera, backup_lamp, backup_camera_data, backup_lamp_data,
+ scene.name, world.name if world else None, camera.name, light.name if light else None,
+ camera_data.name, light_data.name if light_data else None, image.name,
+ backup_scene, backup_world, backup_camera, backup_light, backup_camera_data, backup_light_data,
)
def render_context_delete(render_context):
@@ -171,8 +159,8 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
scene.camera = None
if render_context.camera:
scene.objects.unlink(bpy.data.objects[render_context.camera, None])
- if render_context.lamp:
- scene.objects.unlink(bpy.data.objects[render_context.lamp, None])
+ if render_context.light:
+ scene.objects.unlink(bpy.data.objects[render_context.light, None])
bpy.data.scenes.remove(scene, do_unlink=True)
scene = None
else:
@@ -213,18 +201,18 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
print("ERROR:", e)
success = False
- if render_context.lamp:
+ if render_context.light:
try:
- lamp = bpy.data.objects[render_context.lamp, None]
- if render_context.backup_lamp is None:
+ light = bpy.data.objects[render_context.light, None]
+ if render_context.backup_light is None:
if scene is not None:
- scene.objects.unlink(lamp)
- lamp.user_clear()
- bpy.data.objects.remove(lamp)
- bpy.data.lamps.remove(bpy.data.lamps[render_context.lamp_data, None])
+ scene.objects.unlink(light)
+ light.user_clear()
+ bpy.data.objects.remove(light)
+ bpy.data.lights.remove(bpy.data.lights[render_context.light_data, None])
else:
- rna_backup_restore(lamp, render_context.backup_lamp)
- rna_backup_restore(bpy.data.lamps[render_context.lamp_data, None], render_context.backup_lamp_data)
+ rna_backup_restore(light, render_context.backup_light)
+ rna_backup_restore(bpy.data.lights[render_context.light_data, None], render_context.backup_light_data)
except Exception as e:
print("ERROR:", e)
success = False
@@ -239,17 +227,6 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
return success
- def objects_render_engine_guess(obs):
- for obname, libpath in obs:
- ob = bpy.data.objects[obname, libpath]
- for matslot in ob.material_slots:
- mat = matslot.material
- if mat and mat.use_nodes and mat.node_tree:
- for nd in mat.node_tree.nodes:
- if nd.shading_compatibility == {'NEW_SHADING'}:
- return 'CYCLES'
- return 'BLENDER_RENDER'
-
def object_bbox_merge(bbox, ob, ob_space, offset_matrix):
# Take collections instances into account (including linked one in this case).
if ob.type == 'EMPTY' and ob.dupli_type == 'COLLECTION':
@@ -305,7 +282,7 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
scene = bpy.data.scenes[render_context.scene, None]
if objects is not None:
camera = bpy.data.objects[render_context.camera, None]
- lamp = bpy.data.objects[render_context.lamp, None] if render_context.lamp is not None else None
+ light = bpy.data.objects[render_context.light, None] if render_context.light is not None else None
cos = objects_bbox_calc(camera, objects, offset_matrix)
loc, ortho_scale = camera.camera_fit_coords(scene, cos)
camera.location = loc
@@ -320,9 +297,9 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
max_dist = dist
camera.data.clip_start = min_dist / 2
camera.data.clip_end = max_dist * 2
- if lamp:
- loc, ortho_scale = lamp.camera_fit_coords(scene, cos)
- lamp.location = loc
+ if light:
+ loc, ortho_scale = light.camera_fit_coords(scene, cos)
+ light.location = loc
scene.update()
bpy.ops.render.render(write_still=True)
@@ -360,11 +337,10 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
continue
objects = ((root.name, None),)
- render_engine = objects_render_engine_guess(objects)
- render_context = render_contexts.get(render_engine, None)
+ render_context = render_contexts.get('CYCLES', None)
if render_context is None:
- render_context = render_context_create(render_engine, objects_ignored)
- render_contexts[render_engine] = render_context
+ render_context = render_context_create('CYCLES', objects_ignored)
+ render_contexts['CYCLES'] = render_context
scene = bpy.data.scenes[render_context.scene, None]
bpy.context.screen.scene = scene
@@ -405,11 +381,10 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
# Here too, we do want to keep linked objects members of local collection...
objects = tuple((ob.name, ob.library.filepath if ob.library else None) for ob in grp.objects)
- render_engine = objects_render_engine_guess(objects)
- render_context = render_contexts.get(render_engine, None)
+ render_context = render_contexts.get('CYCLES', None)
if render_context is None:
- render_context = render_context_create(render_engine, objects_ignored)
- render_contexts[render_engine] = render_context
+ render_context = render_context_create('CYCLES', objects_ignored)
+ render_contexts['CYCLES'] = render_context
scene = bpy.data.scenes[render_context.scene, None]
bpy.context.screen.scene = scene
@@ -442,7 +417,7 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
if not has_camera:
# We had to add a temp camera, now we need to place it to see interesting objects!
objects = tuple((ob.name, ob.library.filepath if ob.library else None) for ob in scene.objects
- if (not ob.hide_render) and (ob.type in OBJECT_TYPES_RENDER))
+ if (not ob.hide_render) and (ob.type in OBJECT_TYPES_RENDER))
preview_render_do(render_context, 'scenes', scene.name, objects)
diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py
index 30c3ed2388b..3b4fb255005 100755
--- a/release/scripts/modules/blend_render_info.py
+++ b/release/scripts/modules/blend_render_info.py
@@ -98,5 +98,6 @@ def main():
for value in read_blend_rend_chunk(arg):
print("%d %d %s" % value)
+
if __name__ == '__main__':
main()
diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py
index a549395597b..6d8ed1c1780 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -228,4 +228,5 @@ class BPyOpsSubModOp:
return ("<function bpy.ops.%s.%s at 0x%x'>" %
(self._module, self._func, id(self)))
+
ops_fake_module = BPyOps()
diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py
index a88e60d0022..6af78bbb4c0 100644
--- a/release/scripts/modules/bpy/path.py
+++ b/release/scripts/modules/bpy/path.py
@@ -183,6 +183,8 @@ def clean_name(name, replace="_"):
trans = maketrans_init()
return name.translate(trans)
+
+
clean_name._trans_cache = {}
@@ -223,6 +225,7 @@ def display_name(name):
name = _clean_utf8(name)
return name
+
def display_name_to_filepath(name):
"""
Performs the reverse of display_name using literal versions of characters
diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py
index c3175f93f4e..80e48697b2f 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -34,7 +34,6 @@ __all__ = (
"refresh_script_paths",
"app_template_paths",
"register_class",
- "register_module",
"register_manual_map",
"unregister_manual_map",
"register_classes_factory",
@@ -50,7 +49,6 @@ __all__ = (
"smpte_from_seconds",
"units",
"unregister_class",
- "unregister_module",
"user_resource",
)
@@ -166,10 +164,6 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
for module_name in [ext.module for ext in _user_preferences.addons]:
_addon_utils.disable(module_name)
- # *AFTER* unregistering all add-ons, otherwise all calls to
- # unregister_module() will silently fail (do nothing).
- _bpy_types.TypeMap.clear()
-
def register_module_call(mod):
register = getattr(mod, "register", None)
if register:
@@ -488,11 +482,11 @@ def smpte_from_frame(frame, fps=None, fps_base=None):
return (
"%s%02d:%02d:%02d:%02d" % (
- sign,
- int(frame / (3600 * fps)), # HH
- int((frame / (60 * fps)) % 60), # MM
- int((frame / fps) % 60), # SS
- int(frame % fps), # FF
+ sign,
+ int(frame / (3600 * fps)), # HH
+ int((frame / (60 * fps)) % 60), # MM
+ int((frame / fps) % 60), # SS
+ int(frame % fps), # FF
))
@@ -581,8 +575,13 @@ def keyconfig_set(filepath, report=None):
try:
error_msg = ""
with open(filepath, 'r', encoding='utf-8') as keyfile:
- exec(compile(keyfile.read(), filepath, "exec"),
- {"__file__": filepath})
+ exec(
+ compile(keyfile.read(), filepath, "exec"),
+ {
+ "__file__": filepath,
+ "__name__": "__main__",
+ }
+ )
except:
import traceback
error_msg = traceback.format_exc()
@@ -650,58 +649,6 @@ def user_resource(resource_type, path="", create=False):
return target_path
-def _bpy_module_classes(module, is_registered=False):
- typemap_list = _bpy_types.TypeMap.get(module, ())
- i = 0
- while i < len(typemap_list):
- cls_weakref = typemap_list[i]
- cls = cls_weakref()
-
- if cls is None:
- del typemap_list[i]
- else:
- if is_registered == cls.is_registered:
- yield cls
- i += 1
-
-
-def register_module(module, verbose=False):
- if verbose:
- print("bpy.utils.register_module(%r): ..." % module)
- cls = None
- for cls in _bpy_module_classes(module, is_registered=False):
- if verbose:
- print(" %r" % cls)
- try:
- register_class(cls)
- except:
- print("bpy.utils.register_module(): "
- "failed to registering class %r" % cls)
- import traceback
- traceback.print_exc()
- if verbose:
- print("done.\n")
- if cls is None:
- raise Exception("register_module(%r): defines no classes" % module)
-
-
-def unregister_module(module, verbose=False):
- if verbose:
- print("bpy.utils.unregister_module(%r): ..." % module)
- for cls in _bpy_module_classes(module, is_registered=True):
- if verbose:
- print(" %r" % cls)
- try:
- unregister_class(cls)
- except:
- print("bpy.utils.unregister_module(): "
- "failed to unregistering class %r" % cls)
- import traceback
- traceback.print_exc()
- if verbose:
- print("done.\n")
-
-
def register_classes_factory(classes):
"""
Utility function to create register and unregister functions
@@ -773,6 +720,7 @@ def _blender_default_map():
del _sys.modules["rna_manual_reference"]
return ret
+
# hooks for doc lookups
_manual_map = [_blender_default_map]
diff --git a/release/scripts/modules/bpy_extras/__init__.py b/release/scripts/modules/bpy_extras/__init__.py
index cd176e77aed..1caef074d43 100644
--- a/release/scripts/modules/bpy_extras/__init__.py
+++ b/release/scripts/modules/bpy_extras/__init__.py
@@ -31,4 +31,4 @@ __all__ = (
"mesh_utils",
"node_utils",
"view3d_utils",
- )
+)
diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py
index 75d2065a3d1..7216add2c2c 100644
--- a/release/scripts/modules/bpy_extras/anim_utils.py
+++ b/release/scripts/modules/bpy_extras/anim_utils.py
@@ -174,7 +174,7 @@ def bake_action_iter(
# Bendy Bones
if pbone.bone.bbone_segments > 1:
- bbones[name] = {bb_prop : getattr(pbone, bb_prop) for bb_prop in BBONE_PROPS}
+ bbones[name] = {bb_prop: getattr(pbone, bb_prop) for bb_prop in BBONE_PROPS}
return matrix, bbones
if do_parents_clear:
diff --git a/release/scripts/modules/bpy_extras/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py
index f772aab2b14..49fce7d27c7 100644
--- a/release/scripts/modules/bpy_extras/image_utils.py
+++ b/release/scripts/modules/bpy_extras/image_utils.py
@@ -20,7 +20,7 @@
__all__ = (
"load_image",
- )
+)
# limited replacement for BPyImage.comprehensiveImageLoad
diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py
index 8a516f12b17..a0c1c3e5c84 100644
--- a/release/scripts/modules/bpy_extras/io_utils.py
+++ b/release/scripts/modules/bpy_extras/io_utils.py
@@ -32,7 +32,7 @@ __all__ = (
"path_reference_copy",
"path_reference_mode",
"unique_name"
- )
+)
import bpy
from bpy.props import (
@@ -52,24 +52,18 @@ def _check_axis_conversion(op):
class ExportHelper:
- filepath = StringProperty(
- name="File Path",
- description="Filepath used for exporting the file",
- maxlen=1024,
- subtype='FILE_PATH',
- )
- check_existing = BoolProperty(
- name="Check Existing",
- description="Check and warn on overwriting existing files",
- default=True,
- options={'HIDDEN'},
- )
-
- # needed for mix-ins
- order = [
- "filepath",
- "check_existing",
- ]
+ filepath: StringProperty(
+ name="File Path",
+ description="Filepath used for exporting the file",
+ maxlen=1024,
+ subtype='FILE_PATH',
+ )
+ check_existing: BoolProperty(
+ name="Check Existing",
+ description="Check and warn on overwriting existing files",
+ default=True,
+ options={'HIDDEN'},
+ )
# subclasses can override with decorator
# True == use ext, False == no ext, None == do nothing.
@@ -112,17 +106,12 @@ class ExportHelper:
class ImportHelper:
- filepath = StringProperty(
- name="File Path",
- description="Filepath used for importing the file",
- maxlen=1024,
- subtype='FILE_PATH',
- )
-
- # needed for mix-ins
- order = [
- "filepath",
- ]
+ filepath: StringProperty(
+ name="File Path",
+ description="Filepath used for importing the file",
+ maxlen=1024,
+ subtype='FILE_PATH',
+ )
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
@@ -138,43 +127,40 @@ def orientation_helper_factory(name, axis_forward='Y', axis_up='Z'):
def _update_axis_forward(self, context):
if self.axis_forward[-1] == self.axis_up[-1]:
self.axis_up = (self.axis_up[0:-1] +
- 'XYZ'[('XYZ'.index(self.axis_up[-1]) + 1) % 3])
+ 'XYZ'[('XYZ'.index(self.axis_up[-1]) + 1) % 3])
members['axis_forward'] = EnumProperty(
- name="Forward",
- items=(('X', "X Forward", ""),
- ('Y', "Y Forward", ""),
- ('Z', "Z Forward", ""),
- ('-X', "-X Forward", ""),
- ('-Y', "-Y Forward", ""),
- ('-Z', "-Z Forward", ""),
- ),
- default=axis_forward,
- update=_update_axis_forward,
- )
+ name="Forward",
+ items=(
+ ('X', "X Forward", ""),
+ ('Y', "Y Forward", ""),
+ ('Z', "Z Forward", ""),
+ ('-X', "-X Forward", ""),
+ ('-Y', "-Y Forward", ""),
+ ('-Z', "-Z Forward", ""),
+ ),
+ default=axis_forward,
+ update=_update_axis_forward,
+ )
def _update_axis_up(self, context):
if self.axis_up[-1] == self.axis_forward[-1]:
self.axis_forward = (self.axis_forward[0:-1] +
- 'XYZ'[('XYZ'.index(self.axis_forward[-1]) + 1) % 3])
+ 'XYZ'[('XYZ'.index(self.axis_forward[-1]) + 1) % 3])
members['axis_up'] = EnumProperty(
- name="Up",
- items=(('X', "X Up", ""),
- ('Y', "Y Up", ""),
- ('Z', "Z Up", ""),
- ('-X', "-X Up", ""),
- ('-Y', "-Y Up", ""),
- ('-Z', "-Z Up", ""),
- ),
- default=axis_up,
- update=_update_axis_up,
- )
-
- members["order"] = [
- "axis_forward",
- "axis_up",
- ]
+ name="Up",
+ items=(
+ ('X', "X Up", ""),
+ ('Y', "Y Up", ""),
+ ('Z', "Z Up", ""),
+ ('-X', "-X Up", ""),
+ ('-Y', "-Y Up", ""),
+ ('-Z', "-Z Up", ""),
+ ),
+ default=axis_up,
+ update=_update_axis_up,
+ )
return type(name, (object,), members)
@@ -205,7 +191,7 @@ _axis_convert_matrix = (
((1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, -1.0)),
((1.0, 0.0, 0.0), (0.0, 0.0, 1.0), (0.0, -1.0, 0.0)),
((1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, 1.0, 0.0)),
- )
+)
# store args as a single int
# (X Y Z -X -Y -Z) --> (0, 1, 2, 3, 4, 5)
@@ -282,7 +268,7 @@ _axis_convert_lut = (
{0x408, 0x810, 0xA20, 0x228, 0x081, 0x891, 0x699, 0x2A9, 0x102, 0x50A,
0x71A, 0xB22, 0x4CB, 0x8D3, 0xAE3, 0x2EB, 0x144, 0x954, 0x75C, 0x36C,
0x045, 0x44D, 0x65D, 0xA65},
- )
+)
_axis_convert_num = {'X': 0, 'Y': 1, 'Z': 2, '-X': 3, '-Y': 4, '-Z': 5}
@@ -303,11 +289,11 @@ def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'):
"can't use up/forward on the same axis")
value = reduce(int.__or__, (_axis_convert_num[a] << (i * 3)
- for i, a in enumerate((from_forward,
- from_up,
- to_forward,
- to_up,
- ))))
+ for i, a in enumerate((from_forward,
+ from_up,
+ to_forward,
+ to_up,
+ ))))
for i, axis_lut in enumerate(_axis_convert_lut):
if value in axis_lut:
@@ -392,20 +378,21 @@ def unpack_face_list(list_of_tuples):
path_reference_mode = EnumProperty(
- name="Path Mode",
- description="Method used to reference paths",
- items=(('AUTO', "Auto", "Use Relative paths with subdirectories only"),
- ('ABSOLUTE', "Absolute", "Always write absolute paths"),
- ('RELATIVE', "Relative", "Always write relative paths "
- "(where possible)"),
- ('MATCH', "Match", "Match Absolute/Relative "
- "setting with input path"),
- ('STRIP', "Strip Path", "Filename only"),
- ('COPY', "Copy", "Copy the file to the destination path "
- "(or subdirectory)"),
- ),
- default='AUTO',
- )
+ name="Path Mode",
+ description="Method used to reference paths",
+ items=(
+ ('AUTO', "Auto", "Use Relative paths with subdirectories only"),
+ ('ABSOLUTE', "Absolute", "Always write absolute paths"),
+ ('RELATIVE', "Relative", "Always write relative paths "
+ "(where possible)"),
+ ('MATCH', "Match", "Match Absolute/Relative "
+ "setting with input path"),
+ ('STRIP', "Strip Path", "Filename only"),
+ ('COPY', "Copy", "Copy the file to the destination path "
+ "(or subdirectory)"),
+ ),
+ default='AUTO',
+)
def path_reference(filepath,
diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py
index b8fd96e2ec8..c629cf462aa 100644
--- a/release/scripts/modules/bpy_extras/keyconfig_utils.py
+++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py
@@ -177,8 +177,8 @@ def addon_keymap_register(wm, keymaps_description):
for km_info, km_items in keymaps_description:
km_name, km_sptype, km_regtype, km_ismodal = km_info
kmap = [k for k in kconf.keymaps
- if k.name == km_name and k.region_type == km_regtype and
- k.space_type == km_sptype and k.is_modal == km_ismodal]
+ if k.name == km_name and k.region_type == km_regtype and
+ k.space_type == km_sptype and k.is_modal == km_ismodal]
if kmap:
kmap = kmap[0]
else:
@@ -202,8 +202,8 @@ def addon_keymap_unregister(wm, keymaps_description):
for km_info, km_items in keymaps_description:
km_name, km_sptype, km_regtype, km_ismodal = km_info
kmaps = (k for k in kconf.keymaps
- if k.name == km_name and k.region_type == km_regtype and
- k.space_type == km_sptype and k.is_modal == km_ismodal)
+ if k.name == km_name and k.region_type == km_regtype and
+ k.space_type == km_sptype and k.is_modal == km_ismodal)
for kmap in kmaps:
for kmi_kwargs, props in km_items:
idname = kmi_kwargs["idname"]
@@ -240,9 +240,9 @@ def _export_properties(prefix, properties, kmi_id, lines=None):
lines = []
def string_value(value):
- if isinstance(value, str) or isinstance(value, bool) or isinstance(value, float) or isinstance(value, int):
+ if isinstance(value, (str, bool, float, int)):
return repr(value)
- elif getattr(value, '__len__', False):
+ elif hasattr(value, "__len__"):
return repr(list(value))
print("Export key configuration: can't write ", value)
@@ -296,8 +296,10 @@ def _kmistr(kmi, is_modal):
return "".join(s)
-def keyconfig_export(wm, kc, filepath):
-
+def keyconfig_export(
+ wm, kc, filepath, *,
+ all_keymaps=False,
+):
f = open(filepath, "w")
f.write("import bpy\n")
@@ -327,7 +329,7 @@ def keyconfig_export(wm, kc, filepath):
keymaps = []
edited_kc = FakeKeyConfig()
for km in wm.keyconfigs.user.keymaps:
- if km.is_user_modified:
+ if all_keymaps or km.is_user_modified:
edited_kc.keymaps.append(km)
# merge edited keymaps with non-default keyconfig, if it exists
if kc != wm.keyconfigs.default:
@@ -406,3 +408,11 @@ def keyconfig_test(kc):
if testEntry(kc, entry):
result = True
return result
+
+
+# Note, we may eventually replace existing logic with this
+# so key configs are always data.
+from .keyconfig_utils_experimental import (
+ keyconfig_export_as_data,
+ keyconfig_import_from_data,
+)
diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py b/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py
new file mode 100644
index 00000000000..cd82460e8e0
--- /dev/null
+++ b/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py
@@ -0,0 +1,244 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+__all__ = (
+ "keyconfig_export_as_data",
+ "keyconfig_import_from_data",
+)
+
+
+def indent(levels):
+ return levels * " "
+
+
+def round_float_32(f):
+ from struct import pack, unpack
+ return unpack("f", pack("f", f))[0]
+
+
+def repr_f32(f):
+ f_round = round_float_32(f)
+ f_str = repr(f)
+ f_str_frac = f_str.partition(".")[2]
+ if not f_str_frac:
+ return f_str
+ for i in range(1, len(f_str_frac)):
+ f_test = round(f, i)
+ f_test_round = round_float_32(f_test)
+ if f_test_round == f_round:
+ return "%.*f" % (i, f_test)
+ return f_str
+
+
+def kmi_args_as_data(kmi):
+ s = [
+ f"\"type\": '{kmi.type}'",
+ f"\"value\": '{kmi.value}'"
+ ]
+
+ if kmi.any:
+ s.append("\"any\": True")
+ else:
+ if kmi.shift:
+ s.append("\"shift\": True")
+ if kmi.ctrl:
+ s.append("\"ctrl\": True")
+ if kmi.alt:
+ s.append("\"alt\": True")
+ if kmi.oskey:
+ s.append("\"oskey\": True")
+ if kmi.key_modifier and kmi.key_modifier != 'NONE':
+ s.append(f"\"key_modifier\": '{kmi.key_modifier}'")
+
+ return "{" + ", ".join(s) + "}"
+
+
+def _kmi_properties_to_lines_recursive(level, properties, lines):
+ from bpy.types import OperatorProperties
+
+ def string_value(value):
+ if isinstance(value, (str, bool, int)):
+ return repr(value)
+ elif isinstance(value, float):
+ return repr_f32(value)
+ elif getattr(value, '__len__', False):
+ return repr(tuple(value))
+ raise Exception(f"Export key configuration: can't write {value!r}")
+
+ for pname in properties.bl_rna.properties.keys():
+ if pname != "rna_type":
+ value = getattr(properties, pname)
+ if isinstance(value, OperatorProperties):
+ lines_test = []
+ _kmi_properties_to_lines_recursive(level + 2, value, lines_test)
+ if lines_test:
+ lines.append(f"(")
+ lines.append(f"\"{pname}\",\n")
+ lines.append(f"{indent(level + 3)}" "[")
+ lines.extend(lines_test)
+ lines.append("],\n")
+ lines.append(f"{indent(level + 3)}" "),\n" f"{indent(level + 2)}")
+ del lines_test
+ elif properties.is_property_set(pname):
+ value = string_value(value)
+ lines.append((f"(\"{pname}\", {value:s}),\n" f"{indent(level + 2)}"))
+
+
+def _kmi_properties_to_lines(level, kmi_props, lines):
+ if kmi_props is None:
+ return
+
+ lines_test = [f"\"properties\":\n" f"{indent(level + 1)}" "["]
+ _kmi_properties_to_lines_recursive(level, kmi_props, lines_test)
+ if len(lines_test) > 1:
+ lines_test.append("],\n")
+ lines.extend(lines_test)
+
+
+def _kmi_attrs_or_none(level, kmi):
+ lines = []
+ _kmi_properties_to_lines(level + 1, kmi.properties, lines)
+ if kmi.active is False:
+ lines.append(f"{indent(level)}\"active\":" "False,\n")
+ if not lines:
+ return None
+ return "".join(lines)
+
+
+def keyconfig_export_as_data(wm, kc, filepath, *, all_keymaps=False):
+ # Alternate foramt
+
+ # Generate a list of keymaps to export:
+ #
+ # First add all user_modified keymaps (found in keyconfigs.user.keymaps list),
+ # then add all remaining keymaps from the currently active custom keyconfig.
+ #
+ # This will create a final list of keymaps that can be used as a "diff" against
+ # the default blender keyconfig, recreating the current setup from a fresh blender
+ # without needing to export keymaps which haven't been edited.
+
+ from .keyconfig_utils import keyconfig_merge
+
+ class FakeKeyConfig:
+ keymaps = []
+ edited_kc = FakeKeyConfig()
+ for km in wm.keyconfigs.user.keymaps:
+ if all_keymaps or km.is_user_modified:
+ edited_kc.keymaps.append(km)
+ # merge edited keymaps with non-default keyconfig, if it exists
+ if kc != wm.keyconfigs.default:
+ export_keymaps = keyconfig_merge(edited_kc, kc)
+ else:
+ export_keymaps = keyconfig_merge(edited_kc, edited_kc)
+
+ with open(filepath, "w") as fh:
+ fw = fh.write
+ fw("keyconfig_data = \\\n[")
+
+ for km, kc_x in export_keymaps:
+ km = km.active()
+ fw("(")
+ fw(f"\"{km.name:s}\",\n")
+ fw(f"{indent(2)}" "{")
+ fw(f"\"space_type\": '{km.space_type:s}'")
+ fw(f", \"region_type\": '{km.region_type:s}'")
+ # We can detect from the kind of items.
+ if km.is_modal:
+ fw(", \"modal\": True")
+ fw("},\n")
+ fw(f"{indent(2)}" "{")
+ is_modal = km.is_modal
+ fw(f"\"items\":\n")
+ fw(f"{indent(3)}[")
+ for kmi in km.keymap_items:
+ if is_modal:
+ kmi_id = kmi.propvalue
+ else:
+ kmi_id = kmi.idname
+ fw(f"(")
+ kmi_args = kmi_args_as_data(kmi)
+ kmi_data = _kmi_attrs_or_none(4, kmi)
+ fw(f"\"{kmi_id:s}\"")
+ if kmi_data is None:
+ fw(f", ")
+ else:
+ fw(",\n" f"{indent(5)}")
+
+ fw(kmi_args)
+ if kmi_data is None:
+ fw(", None),\n")
+ else:
+ fw(",\n")
+ fw(f"{indent(5)}" "{")
+ fw(kmi_data)
+ fw(f"{indent(6)}")
+ fw("},\n" f"{indent(5)}")
+ fw("),\n")
+ fw(f"{indent(4)}")
+ fw("],\n" f"{indent(3)}")
+ fw("},\n" f"{indent(2)}")
+ fw("),\n" f"{indent(1)}")
+
+ fw("]\n")
+ fw("\n\n")
+ fw("if __name__ == \"__main__\":\n")
+ fw(" import os\n")
+ fw(" from bpy_extras.keyconfig_utils import keyconfig_import_from_data\n")
+ fw(" keyconfig_import_from_data(os.path.splitext(os.path.basename(__file__))[0], keyconfig_data)\n")
+
+
+def keyconfig_import_from_data(name, keyconfig_data):
+ # Load data in the format defined above.
+ #
+ # Runs at load time, keep this fast!
+
+ def kmi_props_setattr(kmi_props, attr, value):
+ if type(value) is list:
+ kmi_subprop = getattr(kmi_props, attr)
+ for subattr, subvalue in value:
+ kmi_props_setattr(kmi_subprop, subattr, subvalue)
+ return
+
+ try:
+ setattr(kmi_props, attr, value)
+ except AttributeError:
+ print(f"Warning: property '{attr}' not found in keymap item '{kmi_props.__class__.__name__}'")
+ except Exception as ex:
+ print(f"Warning: {ex!r}")
+
+ import bpy
+ wm = bpy.context.window_manager
+ kc = wm.keyconfigs.new(name)
+ del name
+
+ for (km_name, km_args, km_content) in keyconfig_data:
+ km = kc.keymaps.new(km_name, **km_args)
+ is_modal = km_args.get("modal", False)
+ new_fn = getattr(km.keymap_items, "new_modal" if is_modal else "new")
+ for (kmi_idname, kmi_args, kmi_data) in km_content["items"]:
+ kmi = new_fn(kmi_idname, **kmi_args)
+ if kmi_data is not None:
+ if not kmi_data.get("active", True):
+ kmi.active = False
+ kmi_props_data = kmi_data.get("properties", None)
+ if kmi_props_data is not None:
+ kmi_props = kmi.properties
+ for attr, value in kmi_props_data:
+ kmi_props_setattr(kmi_props, attr, value)
diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py
index 4293930e823..43b02e5c881 100644
--- a/release/scripts/modules/bpy_extras/mesh_utils.py
+++ b/release/scripts/modules/bpy_extras/mesh_utils.py
@@ -27,7 +27,7 @@ __all__ = (
"edge_loops_from_edges",
"ngon_tessellate",
"face_random_points",
- )
+)
def mesh_linked_uv_islands(mesh):
@@ -286,7 +286,7 @@ def edge_loops_from_edges(mesh, edges=None):
ok = True
while ok:
ok = False
- #for i, ed in enumerate(edges):
+ # for i, ed in enumerate(edges):
i = len(edges)
while i:
i -= 1
@@ -303,7 +303,7 @@ def edge_loops_from_edges(mesh, edges=None):
vert_end = line_poly[-1]
ok = 1
del edges[i]
- #break
+ # break
elif v1 == vert_start:
line_poly.insert(0, v2)
vert_start = line_poly[0]
@@ -315,7 +315,7 @@ def edge_loops_from_edges(mesh, edges=None):
vert_start = line_poly[0]
ok = 1
del edges[i]
- #break
+ # break
line_polys.append(line_poly)
return line_polys
@@ -481,7 +481,7 @@ def ngon_tessellate(from_data, indices, fix_loops=True):
ii += len(verts)
fill = tessellate_polygon([[v[0] for v in loop] for loop in loop_list])
- #draw_loops(loop_list)
+ # draw_loops(loop_list)
#raise Exception("done loop")
# map to original indices
fill = [[vert_map[i] for i in reversed(f)] for f in fill]
diff --git a/release/scripts/modules/bpy_extras/node_utils.py b/release/scripts/modules/bpy_extras/node_utils.py
index 9a2be5b9f68..d4c6d5cd45a 100644
--- a/release/scripts/modules/bpy_extras/node_utils.py
+++ b/release/scripts/modules/bpy_extras/node_utils.py
@@ -20,8 +20,7 @@
__all__ = (
"find_node_input",
- "find_output_node",
- )
+)
# XXX Names are not unique. Returns the first match.
@@ -31,20 +30,3 @@ def find_node_input(node, name):
return input
return None
-
-# Return the output node to display in the UI. In case multiple node types are
-# specified, node types earlier in the list get priority.
-def find_output_node(ntree, nodetypes):
- if ntree:
- output_node = None
- for nodetype in nodetypes:
- for node in ntree.nodes:
- if getattr(node, "type", None) == nodetype:
- if getattr(node, "is_active_output", True):
- return node
- if not output_node:
- output_node = node
- if output_node:
- return output_node
-
- return None
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index fd1f253df03..7719e2f6e30 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -26,7 +26,7 @@ __all__ = (
"object_add_grid_scale_apply_operator",
"object_image_guess",
"world_to_camera_view",
- )
+)
import bpy
@@ -194,19 +194,19 @@ class AddObjectHelper:
if not self.view_align:
self.rotation.zero()
- view_align = BoolProperty(
- name="Align to View",
- default=False,
- update=view_align_update_callback,
- )
- location = FloatVectorProperty(
- name="Location",
- subtype='TRANSLATION',
- )
- rotation = FloatVectorProperty(
- name="Rotation",
- subtype='EULER',
- )
+ view_align: BoolProperty(
+ name="Align to View",
+ default=False,
+ update=view_align_update_callback,
+ )
+ location: FloatVectorProperty(
+ name="Location",
+ subtype='TRANSLATION',
+ )
+ rotation: FloatVectorProperty(
+ name="Rotation",
+ subtype='EULER',
+ )
@classmethod
def poll(self, context):
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index ee49e8a6630..d6d4ecd6fce 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -61,7 +61,7 @@ class Library(bpy_types.ID):
# we could make this an attribute in rna.
attr_links = ("actions", "armatures", "brushes", "cameras",
"curves", "grease_pencil", "collections", "images",
- "lamps", "lattices", "materials", "metaballs",
+ "lights", "lattices", "materials", "metaballs",
"meshes", "node_groups", "objects", "scenes",
"sounds", "speakers", "textures", "texts",
"fonts", "worlds")
@@ -144,9 +144,15 @@ class WindowManager(bpy_types.ID):
finally:
self.popmenu_end__internal(popup)
- def popover(self, draw_func, keymap=None):
+ def popover(
+ self, draw_func, *,
+ ui_units_x=0,
+ keymap=None,
+ ):
import bpy
- popup = self.popover_begin__internal()
+ popup = self.popover_begin__internal(
+ ui_units_x=ui_units_x,
+ )
try:
draw_func(popup, bpy.context)
@@ -527,10 +533,6 @@ class Text(bpy_types.ID):
self.write(string)
-# values are module: [(cls, path, line), ...]
-TypeMap = {}
-
-
class Sound(bpy_types.ID):
__slots__ = ()
@@ -542,59 +544,19 @@ class Sound(bpy_types.ID):
class RNAMeta(type):
-
- def __new__(cls, name, bases, classdict, **args):
- result = type.__new__(cls, name, bases, classdict)
- if bases and bases[0] is not StructRNA:
- from _weakref import ref as ref
- module = result.__module__
-
- # first part of packages only
- if "." in module:
- module = module[:module.index(".")]
-
- TypeMap.setdefault(module, []).append(ref(result))
-
- return result
-
+ # TODO(campbell): move to C-API
@property
def is_registered(cls):
return "bl_rna" in cls.__dict__
-class OrderedDictMini(dict):
-
- def __init__(self, *args):
- self.order = []
- dict.__init__(self, args)
-
- def __setitem__(self, key, val):
- dict.__setitem__(self, key, val)
- if key not in self.order:
- self.order.append(key)
-
- def __delitem__(self, key):
- dict.__delitem__(self, key)
- self.order.remove(key)
-
-
class RNAMetaPropGroup(StructMetaPropGroup, RNAMeta):
pass
-class OrderedMeta(RNAMeta):
-
- def __init__(cls, name, bases, attributes):
- if attributes.__class__ is OrderedDictMini:
- cls.order = attributes.order
-
- def __prepare__(name, bases, **kwargs):
- return OrderedDictMini() # collections.OrderedDict()
-
-
# Same as 'Operator'
# only without 'as_keywords'
-class Manipulator(StructRNA, metaclass=OrderedMeta):
+class Gizmo(StructRNA):
__slots__ = ()
def __getattribute__(self, attr):
@@ -619,24 +581,24 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
return super().__delattr__(attr)
from _bpy import (
- _rna_manipulator_target_set_handler as target_set_handler,
- _rna_manipulator_target_get_value as target_get_value,
- _rna_manipulator_target_set_value as target_set_value,
- _rna_manipulator_target_get_range as target_get_range,
+ _rna_gizmo_target_set_handler as target_set_handler,
+ _rna_gizmo_target_get_value as target_get_value,
+ _rna_gizmo_target_set_value as target_set_value,
+ _rna_gizmo_target_get_range as target_get_range,
)
- # Convenience wrappers around private `_gawain` module.
+ # Convenience wrappers around private `_gpu` module.
def draw_custom_shape(self, shape, *, matrix=None, select_id=None):
"""
- Draw a shape created form :class:`bpy.types.Manipulator.draw_custom_shape`.
+ Draw a shape created form :class:`bpy.types.Gizmo.draw_custom_shape`.
:arg shape: The cached shape to draw.
:type shape: Undefined.
:arg matrix: 4x4 matrix, when not given
- :class:`bpy.types.Manipulator.matrix_world` is used.
+ :class:`bpy.types.Gizmo.matrix_world` is used.
:type matrix: :class:`mathutils.Matrix`
:arg select_id: The selection id.
- Only use when drawing within :class:`bpy.types.Manipulator.draw_select`.
+ Only use when drawing within :class:`bpy.types.Gizmo.draw_select`.
:type select_it: int
"""
import gpu
@@ -665,7 +627,7 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
@staticmethod
def new_custom_shape(type, verts):
"""
- Create a new shape that can be passed to :class:`bpy.types.Manipulator.draw_custom_shape`.
+ Create a new shape that can be passed to :class:`bpy.types.Gizmo.draw_custom_shape`.
:arg type: The type of shape to create in (POINTS, LINES, TRIS, LINE_STRIP).
:type type: string
@@ -676,25 +638,25 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
:return: The newly created shape.
:rtype: Undefined (it may change).
"""
- from _gawain.types import (
- Gwn_Batch,
- Gwn_VertBuf,
- Gwn_VertFormat,
+ from _gpu.types import (
+ GPUBatch,
+ GPUVertBuf,
+ GPUVertFormat,
)
dims = len(verts[0])
if dims not in {2, 3}:
raise ValueError("Expected 2D or 3D vertex")
- fmt = Gwn_VertFormat()
+ fmt = GPUVertFormat()
pos_id = fmt.attr_add(id="pos", comp_type='F32', len=dims, fetch_mode='FLOAT')
- vbo = Gwn_VertBuf(len=len(verts), format=fmt)
+ vbo = GPUVertBuf(len=len(verts), format=fmt)
vbo.fill(id=pos_id, data=verts)
- batch = Gwn_Batch(type=type, buf=vbo)
+ batch = GPUBatch(type=type, buf=vbo)
return (batch, dims)
# Only defined so operators members can be used by accessing self.order
# with doc generation 'self.properties.bl_rna.properties' can fail
-class Operator(StructRNA, metaclass=OrderedMeta):
+class Operator(StructRNA):
__slots__ = ()
def __getattribute__(self, attr):
@@ -726,7 +688,7 @@ class Operator(StructRNA, metaclass=OrderedMeta):
if attr not in ignore}
-class Macro(StructRNA, metaclass=OrderedMeta):
+class Macro(StructRNA):
# bpy_types is imported before ops is defined
# so we have to do a local import on each run
__slots__ = ()
@@ -942,7 +904,6 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
props = row.operator(add_operator, text="", icon='ZOOMIN')
props.name = wm.preset_name
-
def draw_preset(self, context):
"""
Define these on the subclass:
diff --git a/release/scripts/modules/bpyml.py b/release/scripts/modules/bpyml.py
index f2a73501672..3cdbf848a24 100644
--- a/release/scripts/modules/bpyml.py
+++ b/release/scripts/modules/bpyml.py
@@ -153,6 +153,7 @@ def topretty_py(py_data, indent=" "):
return "\n".join(lines)
+
if __name__ == "__main__":
# testing code.
diff --git a/release/scripts/modules/console/complete_import.py b/release/scripts/modules/console/complete_import.py
index e7218594a86..b9b7c6cb779 100644
--- a/release/scripts/modules/console/complete_import.py
+++ b/release/scripts/modules/console/complete_import.py
@@ -19,12 +19,12 @@
# ##### END GPL LICENSE BLOCK #####
# Original copyright (see docstring):
-#*****************************************************************************
+# ****************************************************************************
# Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
-#*****************************************************************************
+# ****************************************************************************
# <pep8 compliant>
diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py
index a740f31c830..68ff1ed60a7 100644
--- a/release/scripts/modules/console_python.py
+++ b/release/scripts/modules/console_python.py
@@ -224,6 +224,7 @@ def execute(context, is_interactive):
return {'FINISHED'}
+
execute.hooks = []
diff --git a/release/scripts/modules/console_shell.py b/release/scripts/modules/console_shell.py
index 83367e72e67..474e2c6ff81 100644
--- a/release/scripts/modules/console_shell.py
+++ b/release/scripts/modules/console_shell.py
@@ -40,6 +40,7 @@ def shell_run(text):
add_scrollback(output, style)
+
PROMPT = "$ "
@@ -64,7 +65,7 @@ def execute(context, is_interactive):
def autocomplete(context):
- #~ sc = context.space_data
+ # sc = context.space_data
# TODO
return {'CANCELLED'}
diff --git a/release/scripts/modules/graphviz_export.py b/release/scripts/modules/graphviz_export.py
index 88f8b15a728..fbe23a05940 100644
--- a/release/scripts/modules/graphviz_export.py
+++ b/release/scripts/modules/graphviz_export.py
@@ -140,7 +140,7 @@ def graph_armature(obj, filepath, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=Tr
return None
#rna_path_bone = rna_path[:rna_path.index("]") + 1]
- #return obj.path_resolve(rna_path_bone)
+ # return obj.path_resolve(rna_path_bone)
bone_name = rna_path.split("[")[1].split("]")[0]
return obj.pose.bones[bone_name[1:-1]]
@@ -179,6 +179,7 @@ def graph_armature(obj, filepath, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=Tr
print("\nSaved:", filepath)
return True
+
if __name__ == "__main__":
import os
tmppath = "/tmp/test.dot"
diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py
index 470bb7258f9..35bae1e69b7 100644
--- a/release/scripts/modules/keyingsets_utils.py
+++ b/release/scripts/modules/keyingsets_utils.py
@@ -36,7 +36,7 @@ __all__ = (
"RKS_GEN_rotation",
"RKS_GEN_scaling",
"RKS_GEN_bendy_bones",
- )
+)
import bpy
@@ -221,6 +221,7 @@ def RKS_GEN_scaling(ksi, context, ks, data):
# ------
+
# Property identifiers for Bendy Bones
bbone_property_ids = (
"bbone_curveinx",
diff --git a/release/scripts/modules/nodeitems_utils.py b/release/scripts/modules/nodeitems_utils.py
index 117e35dd028..699b6ce0528 100644
--- a/release/scripts/modules/nodeitems_utils.py
+++ b/release/scripts/modules/nodeitems_utils.py
@@ -121,7 +121,7 @@ def register_node_categories(identifier, cat_list):
"category": cat,
"poll": cat.poll,
"draw": draw_node_item,
- })
+ })
panel_type = type("NODE_PT_category_" + cat.identifier, (bpy.types.Panel,), {
"bl_space_type": 'NODE_EDITOR',
"bl_region_type": 'TOOLS',
@@ -130,7 +130,7 @@ def register_node_categories(identifier, cat_list):
"category": cat,
"poll": cat.poll,
"draw": draw_node_item,
- })
+ })
menu_types.append(menu_type)
panel_types.append(panel_type)
diff --git a/release/scripts/modules/rna_keymap_ui.py b/release/scripts/modules/rna_keymap_ui.py
index aa1aa4925a3..e151a81913b 100644
--- a/release/scripts/modules/rna_keymap_ui.py
+++ b/release/scripts/modules/rna_keymap_ui.py
@@ -25,7 +25,7 @@ __all__ = (
"draw_filtered",
"draw_hierarchy",
"draw_keymaps",
- )
+)
import bpy
@@ -174,7 +174,7 @@ def draw_kmi(display_keymaps, kc, km, kmi, layout, level):
sub.prop(kmi, "propvalue", text="")
else:
# One day...
- #~ sub.prop_search(kmi, "idname", bpy.context.window_manager, "operators_all", text="")
+ # sub.prop_search(kmi, "idname", bpy.context.window_manager, "operators_all", text="")
sub.prop(kmi, "idname", text="")
if map_type not in {'TEXTINPUT', 'TIMER'}:
@@ -207,6 +207,7 @@ def draw_kmi(display_keymaps, kc, km, kmi, layout, level):
draw_km(display_keymaps, kc, kmm, None, layout, level + 1)
layout.context_pointer_set("keymap", km)
+
_EVENT_TYPES = set()
_EVENT_TYPE_MAP = {}
_EVENT_TYPE_MAP_EXTRA = {}
@@ -234,10 +235,10 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout):
"RMB": 'RIGHTMOUSE',
"LMB": 'LEFTMOUSE',
"MMB": 'MIDDLEMOUSE',
- })
+ })
_EVENT_TYPE_MAP_EXTRA.update({
"%d" % i: "NUMPAD_%d" % i for i in range(10)
- })
+ })
# done with once off init
filter_text_split = filter_text.strip()
@@ -251,7 +252,7 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout):
"cmd": "oskey",
"oskey": "oskey",
"any": "any",
- }
+ }
# KeyMapItem like dict, use for comparing against
# attr: {states, ...}
kmi_test_dict = {}
@@ -260,8 +261,8 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout):
kmi_test_type = []
# initialize? - so if a if a kmi has a MOD assigned it wont show up.
- #~ for kv in key_mod.values():
- #~ kmi_test_dict[kv] = {False}
+ # for kv in key_mod.values():
+ # kmi_test_dict[kv] = {False}
# altname: attr
for kk, kv in key_mod.items():
@@ -374,7 +375,7 @@ def draw_keymaps(context, layout):
row = subcol.row(align=True)
- #~ row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config")
+ # row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config")
text = bpy.path.display_name(wm.keyconfigs.active.name)
if not text:
text = "Blender (default)"
@@ -382,8 +383,8 @@ def draw_keymaps(context, layout):
row.operator("wm.keyconfig_preset_add", text="", icon='ZOOMIN')
row.operator("wm.keyconfig_preset_add", text="", icon='ZOOMOUT').remove_active = True
- #~ layout.context_pointer_set("keyconfig", wm.keyconfigs.active)
- #~ row.operator("wm.keyconfig_remove", text="", icon='X')
+ # layout.context_pointer_set("keyconfig", wm.keyconfigs.active)
+ # row.operator("wm.keyconfig_remove", text="", icon='X')
row.separator()
rowsub = row.split(align=True, percentage=0.33)
# postpone drawing into rowsub, so we can set alert!
diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py
index e50922593de..0d17c11456e 100644
--- a/release/scripts/modules/rna_prop_ui.py
+++ b/release/scripts/modules/rna_prop_ui.py
@@ -129,14 +129,25 @@ def draw(layout, context, context_member, property_type, use_edit=True):
props.data_path = context_member
del row
+ show_developer_ui = context.user_preferences.view.show_developer_ui
rna_properties = {prop.identifier for prop in rna_item.bl_rna.properties if prop.is_runtime} if items else None
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
+
for key, val in items:
if key == '_RNA_UI':
continue
- row = layout.row()
+ is_rna = (key in rna_properties)
+
+ # only show API defined for developers
+ if is_rna and not show_developer_ui:
+ continue
+
to_dict = getattr(val, "to_dict", None)
to_list = getattr(val, "to_list", None)
@@ -150,19 +161,20 @@ def draw(layout, context, context_member, property_type, use_edit=True):
else:
val_draw = val
+ row = flow.row(align=True)
box = row.box()
if use_edit:
split = box.split(percentage=0.75)
- row = split.row()
+ row = split.row(align=True)
else:
- row = box.row()
+ row = box.row(align=True)
- row.label(text=key, translate=False)
+ row.alignment = 'RIGHT'
- # explicit exception for arrays
- is_rna = (key in rna_properties)
+ row.label(text=key, translate=False)
+ # explicit exception for arrays.
if to_dict or to_list:
row.label(text=val_draw, translate=False)
else:
@@ -181,6 +193,8 @@ def draw(layout, context, context_member, property_type, use_edit=True):
else:
row.label(text="API Defined")
+ del flow
+
class PropertyPanel:
"""
diff --git a/release/scripts/presets/interface_theme/24x_blues.xml b/release/scripts/presets/interface_theme/24x_blues.xml
index 36cfeeb5980..18b866eeb0f 100644
--- a/release/scripts/presets/interface_theme/24x_blues.xml
+++ b/release/scripts/presets/interface_theme/24x_blues.xml
@@ -253,7 +253,7 @@
text_keyframe="#ddd700"
camera="#000000"
empty="#000000"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
vertex="#000000"
vertex_select="#ff8500"
diff --git a/release/scripts/presets/interface_theme/back_to_black.xml b/release/scripts/presets/interface_theme/back_to_black.xml
index 1636f5b5cf6..464625d0ba5 100644
--- a/release/scripts/presets/interface_theme/back_to_black.xml
+++ b/release/scripts/presets/interface_theme/back_to_black.xml
@@ -253,7 +253,7 @@
text_keyframe="#ddd700"
camera="#535353"
empty="#535353"
- lamp="#fff0d328"
+ light="#fff0d328"
speaker="#535353"
vertex="#72cfdd"
vertex_select="#ff8500"
diff --git a/release/scripts/presets/interface_theme/blender_24x.xml b/release/scripts/presets/interface_theme/blender_24x.xml
index 818e557adf0..d0459e02115 100644
--- a/release/scripts/presets/interface_theme/blender_24x.xml
+++ b/release/scripts/presets/interface_theme/blender_24x.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
camera="#000000"
view_overlay="#000000"
diff --git a/release/scripts/presets/interface_theme/blender_27x.xml b/release/scripts/presets/interface_theme/blender_27x.xml
index 6a78dd5fc8f..db9d042ae55 100644
--- a/release/scripts/presets/interface_theme/blender_27x.xml
+++ b/release/scripts/presets/interface_theme/blender_27x.xml
@@ -304,7 +304,7 @@
text_keyframe="#ddd700"
camera="#000000"
empty="#000000"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
vertex="#000000"
vertex_select="#ff8500"
diff --git a/release/scripts/presets/interface_theme/dark_blue_gradient.xml b/release/scripts/presets/interface_theme/dark_blue_gradient.xml
index d226f8531b2..589aeab3a50 100644
--- a/release/scripts/presets/interface_theme/dark_blue_gradient.xml
+++ b/release/scripts/presets/interface_theme/dark_blue_gradient.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
camera="#000000"
view_overlay="#000000"
diff --git a/release/scripts/presets/interface_theme/default++.xml b/release/scripts/presets/interface_theme/default++.xml
index 413fbc1aa71..3599a094381 100644
--- a/release/scripts/presets/interface_theme/default++.xml
+++ b/release/scripts/presets/interface_theme/default++.xml
@@ -253,7 +253,7 @@
text_keyframe="#ddd700"
camera="#000000"
empty="#000000"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
vertex="#000000"
vertex_select="#ff8500"
diff --git a/release/scripts/presets/interface_theme/elsyiun.xml b/release/scripts/presets/interface_theme/elsyiun.xml
index b9292856fe9..51af13a6009 100644
--- a/release/scripts/presets/interface_theme/elsyiun.xml
+++ b/release/scripts/presets/interface_theme/elsyiun.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
camera="#000000"
view_overlay="#000000"
diff --git a/release/scripts/presets/interface_theme/flatty_light.xml b/release/scripts/presets/interface_theme/flatty_light.xml
index bdcf381f8f9..497b6575731 100644
--- a/release/scripts/presets/interface_theme/flatty_light.xml
+++ b/release/scripts/presets/interface_theme/flatty_light.xml
@@ -304,7 +304,7 @@
text_keyframe="#ddd700"
camera="#b3b3b3"
empty="#b3b3b3"
- lamp="#cccccc33"
+ light="#cccccc33"
speaker="#b3b3b3"
vertex="#000000"
vertex_select="#ff8500"
diff --git a/release/scripts/presets/interface_theme/graph.xml b/release/scripts/presets/interface_theme/graph.xml
index a032d8bd3b2..904fcdf41ec 100644
--- a/release/scripts/presets/interface_theme/graph.xml
+++ b/release/scripts/presets/interface_theme/graph.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
camera="#8d8c8d"
view_overlay="#000000"
diff --git a/release/scripts/presets/interface_theme/hexagon.xml b/release/scripts/presets/interface_theme/hexagon.xml
index 4b24abc5fa7..1ca52b76253 100644
--- a/release/scripts/presets/interface_theme/hexagon.xml
+++ b/release/scripts/presets/interface_theme/hexagon.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
camera="#000000"
view_overlay="#000000"
diff --git a/release/scripts/presets/interface_theme/modern_minimalist.xml b/release/scripts/presets/interface_theme/modern_minimalist.xml
index 8ba9402ecdb..3b982514f4f 100644
--- a/release/scripts/presets/interface_theme/modern_minimalist.xml
+++ b/release/scripts/presets/interface_theme/modern_minimalist.xml
@@ -253,7 +253,7 @@
text_keyframe="#ddd700"
camera="#8d8c8d"
empty="#8d8c8d"
- lamp="#8d8c8d40"
+ light="#8d8c8d40"
speaker="#8d8c8d"
vertex="#bfbfbf"
vertex_select="#00bdff"
diff --git a/release/scripts/presets/interface_theme/north.xml b/release/scripts/presets/interface_theme/north.xml
index 69cb90a64ce..8ab51261994 100644
--- a/release/scripts/presets/interface_theme/north.xml
+++ b/release/scripts/presets/interface_theme/north.xml
@@ -253,7 +253,7 @@
text_keyframe="#ddd700"
camera="#000000"
empty="#000000"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
vertex="#000000"
vertex_select="#f2b252"
diff --git a/release/scripts/presets/interface_theme/rtheme.xml b/release/scripts/presets/interface_theme/rtheme.xml
index 27f33aa2fe5..34d4f6bd0db 100644
--- a/release/scripts/presets/interface_theme/rtheme.xml
+++ b/release/scripts/presets/interface_theme/rtheme.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#00000028"
+ light="#00000028"
speaker="#000000"
camera="#000000"
view_overlay="#000000"
diff --git a/release/scripts/presets/interface_theme/sandyslate.xml b/release/scripts/presets/interface_theme/sandyslate.xml
index c5bae419bca..0b4756a40e8 100644
--- a/release/scripts/presets/interface_theme/sandyslate.xml
+++ b/release/scripts/presets/interface_theme/sandyslate.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#ff000080"
+ light="#ff000080"
speaker="#979797"
camera="#ff0000"
view_overlay="#000000"
diff --git a/release/scripts/presets/interface_theme/science_lab.xml b/release/scripts/presets/interface_theme/science_lab.xml
index 2fe4cf99e41..e8a32f6ac29 100644
--- a/release/scripts/presets/interface_theme/science_lab.xml
+++ b/release/scripts/presets/interface_theme/science_lab.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#dbac00b9"
+ light="#dbac00b9"
speaker="#229cd8"
camera="#e28400"
view_overlay="#666666"
diff --git a/release/scripts/presets/interface_theme/softblend.xml b/release/scripts/presets/interface_theme/softblend.xml
index ab0a5994838..ce20f7d4085 100644
--- a/release/scripts/presets/interface_theme/softblend.xml
+++ b/release/scripts/presets/interface_theme/softblend.xml
@@ -244,7 +244,7 @@
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#ffe56666"
+ light="#ffe56666"
speaker="#c2e787"
camera="#000000"
view_overlay="#000000"
diff --git a/release/scripts/presets/interface_theme/true_blue_menu.xml b/release/scripts/presets/interface_theme/true_blue_menu.xml
index 2b464ae120e..26e39f3bcdf 100644
--- a/release/scripts/presets/interface_theme/true_blue_menu.xml
+++ b/release/scripts/presets/interface_theme/true_blue_menu.xml
@@ -253,7 +253,7 @@
text_keyframe="#ddd700"
camera="#000000"
empty="#a78721"
- lamp="#d6df1628"
+ light="#d6df1628"
speaker="#a83f2d"
vertex="#657780"
vertex_select="#00cccb"
diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py
index 9410c20bac2..c71b7456cff 100644
--- a/release/scripts/presets/keyconfig/blender_27x.py
+++ b/release/scripts/presets/keyconfig/blender_27x.py
@@ -1,3975 +1,8645 @@
-import bpy
-from sys import platform
-
-def kmi_props_setattr(kmi_props, attr, value):
- try:
- setattr(kmi_props, attr, value)
- except AttributeError:
- print("Warning: property '%s' not found in keymap item '%s'" %
- (attr, kmi_props.__class__.__name__))
- except Exception as e:
- print("Warning: %r" % e)
-
-import os
-wm = bpy.context.window_manager
-kc = wm.keyconfigs.new(os.path.splitext(os.path.basename(__file__))[0])
-del os
-
-# Map Image Editor Tool: VIEW, Select Border
-km = kc.keymaps.new('Image Editor Tool: VIEW, Select Border', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('uv.select_border', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-
-# Map Image Editor Tool: VIEW, Select Circle
-km = kc.keymaps.new('Image Editor Tool: VIEW, Select Circle', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('uv.select_circle', 'ACTIONMOUSE', 'PRESS')
-
-# Map Image Editor Tool: VIEW, Select Lasso
-km = kc.keymaps.new('Image Editor Tool: VIEW, Select Lasso', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('uv.select_lasso', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-
-# Map 3D View Tool: All, Cursor
-km = kc.keymaps.new('3D View Tool: All, Cursor', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'cursor_transform', True)
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: OBJECT, Select Border
-km = kc.keymaps.new('3D View Tool: OBJECT, Select Border', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.select_border', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('view3d.select_border', 'EVT_TWEAK_A', 'ANY', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-
-# Map 3D View Tool: OBJECT, Select Circle
-km = kc.keymaps.new('3D View Tool: OBJECT, Select Circle', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.select_circle', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('view3d.select_circle', 'ACTIONMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-
-# Map 3D View Tool: OBJECT, Select Lasso
-km = kc.keymaps.new('3D View Tool: OBJECT, Select Lasso', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-
-# Map 3D View Tool: OBJECT, Move
-km = kc.keymaps.new('3D View Tool: OBJECT, Move', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: OBJECT, Rotate
-km = kc.keymaps.new('3D View Tool: OBJECT, Rotate', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.rotate', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: OBJECT, Scale
-km = kc.keymaps.new('3D View Tool: OBJECT, Scale', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.resize', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: OBJECT, Ruler/Protractor
-km = kc.keymaps.new('3D View Tool: OBJECT, Ruler/Protractor', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.ruler_add', 'EVT_TWEAK_A', 'ANY')
-
-# Map 3D View Tool: POSE, Breakdowner
-km = kc.keymaps.new('3D View Tool: POSE, Breakdowner', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('pose.breakdown', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: POSE, Push
-km = kc.keymaps.new('3D View Tool: POSE, Push', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('pose.push', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: POSE, Relax
-km = kc.keymaps.new('3D View Tool: POSE, Relax', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('pose.relax', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_ARMATURE, Roll
-km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Roll', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'mode', 'BONE_ROLL')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_ARMATURE, Bone Size
-km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Bone Size', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.transform', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'BONE_SIZE')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_ARMATURE, Bone Envelope
-km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Bone Envelope', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.transform', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'BONE_ENVELOPE')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_ARMATURE, Extrude
-km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Extrude', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('armature.click_extrude', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_ARMATURE, Extrude to Cursor
-km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Extrude to Cursor', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('armature.click_extrude', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_MESH, Add Cube
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Add Cube', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'CLICK')
-kmi = km.keymap_items.new('mesh.primitive_cube_add_manipulator', 'EVT_TWEAK_A', 'ANY')
-
-# Map 3D View Tool: EDIT_MESH, Extrude Region
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Extrude Region', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.extrude_context_move', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties.TRANSFORM_OT_translate, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_MESH, Extrude Individual
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Extrude Individual', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.extrude_faces_move', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties.TRANSFORM_OT_shrink_fatten, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_MESH, Extrude to Cursor
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Extrude to Cursor', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_MESH, Inset Faces
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Inset Faces', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.inset', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_MESH, Bevel
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Bevel', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.bevel', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_MESH, Loop Cut
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Loop Cut', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.loopcut_slide', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_MESH, Offset Edge Loop Cut
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Offset Edge Loop Cut', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.offset_edge_loops_slide', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_MESH, Knife
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Knife', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.knife_tool', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-
-# Map 3D View Tool: EDIT_MESH, Bisect
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Bisect', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.bisect', 'EVT_TWEAK_A', 'ANY')
-
-# Map 3D View Tool: EDIT_MESH, Poly Build
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Poly Build', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.polybuild_face_at_cursor_move', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties.TRANSFORM_OT_translate, 'release_confirm', True)
-kmi = km.keymap_items.new('mesh.polybuild_split_at_cursor_move', 'ACTIONMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties.TRANSFORM_OT_translate, 'release_confirm', True)
-kmi = km.keymap_items.new('mesh.polybuild_dissolve_at_cursor', 'ACTIONMOUSE', 'CLICK', alt=True)
-kmi = km.keymap_items.new('mesh.polybuild_hover', 'MOUSEMOVE', 'ANY', alt=True)
-kmi_props_setattr(kmi.properties, 'use_boundary', False)
-kmi = km.keymap_items.new('mesh.polybuild_hover', 'MOUSEMOVE', 'ANY', any=True)
-kmi_props_setattr(kmi.properties, 'use_boundary', True)
-
-# Map 3D View Tool: EDIT_MESH, Spin
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Spin', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.spin', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_MESH, Spin (Duplicate)
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Spin (Duplicate)', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.spin', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'dupli', True)
-
-# Map 3D View Tool: EDIT_MESH, Smooth
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Smooth', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.vertices_smooth', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_MESH, Randomize
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Randomize', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.vertex_random', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_MESH, Edge Slide
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Edge Slide', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.edge_slide', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_MESH, Vertex Slide
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Vertex Slide', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.vert_slide', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_MESH, Shrink/Fatten
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Shrink/Fatten', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.shrink_fatten', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_MESH, Push/Pull
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Push/Pull', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('transform.push_pull', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_MESH, Rip Region
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Rip Region', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.rip_move', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties.TRANSFORM_OT_translate, 'release_confirm', True)
-
-# Map 3D View Tool: EDIT_MESH, Rip Edge
-km = kc.keymaps.new('3D View Tool: EDIT_MESH, Rip Edge', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.rip_edge_edge_move', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: EDIT_CURVE, Draw
-km = kc.keymaps.new('3D View Tool: EDIT_CURVE, Draw', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('curve.draw', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-
-# Map 3D View Tool: EDIT_CURVE, Extrude Cursor
-km = kc.keymaps.new('3D View Tool: EDIT_CURVE, Extrude Cursor', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('curve.vertex_add', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: PARTICLE, Cursor Click
-km = kc.keymaps.new('3D View Tool: PARTICLE, Cursor Click', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'CLICK')
-
-# Map 3D View Tool: PAINT_WEIGHT, Sample Weight
-km = kc.keymaps.new('3D View Tool: PAINT_WEIGHT, Sample Weight', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paint.weight_sample', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: PAINT_WEIGHT, Sample Vertex Group
-km = kc.keymaps.new('3D View Tool: PAINT_WEIGHT, Sample Vertex Group', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paint.weight_sample_group', 'ACTIONMOUSE', 'PRESS')
-
-# Map 3D View Tool: PAINT_WEIGHT, Gradient
-km = kc.keymaps.new('3D View Tool: PAINT_WEIGHT, Gradient', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paint.weight_gradient', 'EVT_TWEAK_A', 'ANY')
-
-# Map Window
-km = kc.keymaps.new('Window', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('wm.window_new', 'W', 'PRESS', ctrl=True, alt=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, oskey=True)
- kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_file_open_recent')
- kmi = km.keymap_items.new('wm.open_mainfile', 'O', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('wm.save_mainfile', 'S', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('wm.save_as_mainfile', 'S', 'PRESS', shift=True, oskey=True)
- kmi = km.keymap_items.new('wm.quit_blender', 'Q', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.save_homefile', 'U', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_file_open_recent')
-kmi = km.keymap_items.new('wm.open_mainfile', 'O', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.open_mainfile', 'F1', 'PRESS')
-kmi = km.keymap_items.new('wm.link', 'O', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('wm.append', 'F1', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.save_mainfile', 'S', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.save_mainfile', 'W', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.save_as_mainfile', 'S', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('wm.save_as_mainfile', 'F2', 'PRESS')
-kmi = km.keymap_items.new('wm.save_as_mainfile', 'S', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'copy', True)
-kmi = km.keymap_items.new('wm.window_fullscreen_toggle', 'F11', 'PRESS', alt=True)
-kmi = km.keymap_items.new('wm.quit_blender', 'Q', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.doc_view_manual_ui_context', 'F1', 'PRESS', alt=True)
-kmi = km.keymap_items.new('wm.redraw_timer', 'T', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('wm.debug_menu', 'D', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('wm.call_menu', 'NDOF_BUTTON_MENU', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'USERPREF_MT_ndof_settings')
-kmi = km.keymap_items.new('wm.search_menu', 'SPACE', 'PRESS')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F3', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'NODE_EDITOR')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F4', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'CONSOLE')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F5', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'VIEW_3D')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F6', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'GRAPH_EDITOR')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F7', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'PROPERTIES')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F8', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'SEQUENCE_EDITOR')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F9', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'OUTLINER')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F10', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'IMAGE_EDITOR')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F11', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'TEXT_EDITOR')
-kmi = km.keymap_items.new('wm.context_set_enum', 'F12', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'area.type')
-kmi_props_setattr(kmi.properties, 'value', 'DOPESHEET_EDITOR')
-kmi = km.keymap_items.new('wm.context_scale_float', 'NDOF_BUTTON_PLUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'user_preferences.inputs.ndof_sensitivity')
-kmi_props_setattr(kmi.properties, 'value', 1.1)
-kmi = km.keymap_items.new('wm.context_scale_float', 'NDOF_BUTTON_MINUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'user_preferences.inputs.ndof_sensitivity')
-kmi_props_setattr(kmi.properties, 'value', 1.0 / 1.0)
-kmi = km.keymap_items.new('wm.context_scale_float', 'NDOF_BUTTON_PLUS', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'user_preferences.inputs.ndof_sensitivity')
-kmi_props_setattr(kmi.properties, 'value', 1.5)
-kmi = km.keymap_items.new('wm.context_scale_float', 'NDOF_BUTTON_MINUS', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'user_preferences.inputs.ndof_sensitivity')
-kmi_props_setattr(kmi.properties, 'value', 2.0 / 3.0)
-kmi = km.keymap_items.new('info.reports_display_update', 'TIMER_REPORT', 'ANY', any=True)
-
-# Map Screen
-km = kc.keymaps.new('Screen', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('screen.animation_step', 'TIMER0', 'ANY', any=True)
-kmi = km.keymap_items.new('screen.region_blend', 'TIMERREGION', 'ANY', any=True)
-kmi = km.keymap_items.new('screen.screen_set', 'RIGHT_ARROW', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('screen.screen_set', 'LEFT_ARROW', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('screen.screen_full_area', 'SPACE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('screen.screen_full_area', 'SPACE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'use_hide_panels', True)
-kmi = km.keymap_items.new('screen.screenshot', 'F3', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('screen.screencast', 'F3', 'PRESS', alt=True)
-kmi = km.keymap_items.new('screen.space_context_cycle', 'TAB', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'direction', 'NEXT')
-kmi = km.keymap_items.new('screen.space_context_cycle', 'TAB', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'direction', 'PREV')
-kmi = km.keymap_items.new('screen.region_quadview', 'Q', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('screen.repeat_history', 'F3', 'PRESS')
-kmi = km.keymap_items.new('screen.repeat_last', 'R', 'PRESS', shift=True)
-kmi = km.keymap_items.new('screen.region_flip', 'F5', 'PRESS')
-kmi = km.keymap_items.new('screen.redo_last', 'F6', 'PRESS')
-kmi = km.keymap_items.new('script.reload', 'F8', 'PRESS')
-kmi = km.keymap_items.new('file.execute', 'RET', 'PRESS')
-kmi = km.keymap_items.new('file.execute', 'NUMPAD_ENTER', 'PRESS')
-kmi = km.keymap_items.new('file.cancel', 'ESC', 'PRESS')
-if platform == "darwin":
- kmi = km.keymap_items.new('ed.undo', 'Z', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('ed.redo', 'Z', 'PRESS', shift=True, oskey=True)
- kmi = km.keymap_items.new('ed.undo_history', 'Z', 'PRESS', alt=True, oskey=True)
-kmi = km.keymap_items.new('ed.undo', 'Z', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('ed.redo', 'Z', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('ed.undo_history', 'Z', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('render.render', 'F12', 'PRESS')
-kmi_props_setattr(kmi.properties, 'use_viewport', True)
-kmi = km.keymap_items.new('render.render', 'F12', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'animation', True)
-kmi_props_setattr(kmi.properties, 'use_viewport', True)
-kmi = km.keymap_items.new('render.view_cancel', 'ESC', 'PRESS')
-kmi = km.keymap_items.new('render.view_show', 'F11', 'PRESS')
-kmi = km.keymap_items.new('render.play_rendered_anim', 'F11', 'PRESS', ctrl=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('screen.userpref_show', 'COMMA', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('screen.userpref_show', 'U', 'PRESS', ctrl=True, alt=True)
-
-# Map Screen Editing
-km = kc.keymaps.new('Screen Editing', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('screen.actionzone', 'LEFTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'modifier', 0)
-kmi = km.keymap_items.new('screen.actionzone', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'modifier', 1)
-kmi = km.keymap_items.new('screen.actionzone', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'modifier', 2)
-kmi = km.keymap_items.new('screen.area_split', 'NONE', 'ANY')
-kmi = km.keymap_items.new('screen.area_join', 'NONE', 'ANY')
-kmi = km.keymap_items.new('screen.area_dupli', 'NONE', 'ANY', shift=True)
-kmi = km.keymap_items.new('screen.area_swap', 'NONE', 'ANY', ctrl=True)
-kmi = km.keymap_items.new('screen.region_scale', 'NONE', 'ANY')
-kmi = km.keymap_items.new('screen.screen_full_area', 'NONE', 'ANY')
-kmi_props_setattr(kmi.properties, 'use_hide_panels', True)
-kmi = km.keymap_items.new('screen.area_move', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('screen.area_options', 'RIGHTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('screen.header', 'F9', 'PRESS', alt=True)
-
-# Map User Interface
-km = kc.keymaps.new('User Interface', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('ui.eyedropper_color', 'E', 'PRESS')
-kmi = km.keymap_items.new('ui.eyedropper_colorband', 'E', 'PRESS')
-kmi = km.keymap_items.new('ui.eyedropper_colorband_point', 'E', 'PRESS', alt=True)
-kmi = km.keymap_items.new('ui.eyedropper_id', 'E', 'PRESS')
-kmi = km.keymap_items.new('ui.eyedropper_depth', 'E', 'PRESS')
-kmi = km.keymap_items.new('ui.copy_data_path_button', 'C', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('ui.copy_data_path_button', 'C', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'full_path', True)
-kmi = km.keymap_items.new('anim.keyframe_insert_button', 'I', 'PRESS')
-kmi = km.keymap_items.new('anim.keyframe_delete_button', 'I', 'PRESS', alt=True)
-kmi = km.keymap_items.new('anim.keyframe_clear_button', 'I', 'PRESS', shift=True, alt=True)
-kmi = km.keymap_items.new('anim.driver_button_add', 'D', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('anim.driver_button_remove', 'D', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('anim.keyingset_button_add', 'K', 'PRESS')
-kmi = km.keymap_items.new('anim.keyingset_button_remove', 'K', 'PRESS', alt=True)
-
-# Map View2D
-km = kc.keymaps.new('View2D', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view2d.scroller_activate', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.scroller_activate', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.pan', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.pan', 'MIDDLEMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view2d.pan', 'TRACKPADPAN', 'ANY')
-kmi = km.keymap_items.new('view2d.scroll_right', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('view2d.scroll_left', 'WHEELUPMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('view2d.scroll_down', 'WHEELDOWNMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view2d.scroll_up', 'WHEELUPMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view2d.ndof', 'NDOF_MOTION', 'ANY')
-kmi = km.keymap_items.new('view2d.zoom_out', 'WHEELOUTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.zoom_in', 'WHEELINMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.zoom_out', 'NUMPAD_MINUS', 'PRESS')
-kmi = km.keymap_items.new('view2d.zoom_in', 'NUMPAD_PLUS', 'PRESS')
-kmi = km.keymap_items.new('view2d.zoom', 'TRACKPADPAN', 'ANY', ctrl=True)
-kmi = km.keymap_items.new('view2d.smoothview', 'TIMER1', 'ANY', any=True)
-kmi = km.keymap_items.new('view2d.scroll_down', 'WHEELDOWNMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.scroll_up', 'WHEELUPMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.scroll_right', 'WHEELDOWNMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.scroll_left', 'WHEELUPMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('view2d.zoom', 'TRACKPADZOOM', 'ANY')
-kmi = km.keymap_items.new('view2d.zoom_border', 'B', 'PRESS', shift=True)
-
-# Map Header
-km = kc.keymaps.new('Header', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('screen.header_toolbox', 'RIGHTMOUSE', 'PRESS')
-
-# Map View2D Buttons List
-km = kc.keymaps.new('View2D Buttons List', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view2d.scroller_activate', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.scroller_activate', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.pan', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.pan', 'TRACKPADPAN', 'ANY')
-kmi = km.keymap_items.new('view2d.scroll_down', 'WHEELDOWNMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.scroll_up', 'WHEELUPMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view2d.scroll_down', 'PAGE_DOWN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'page', True)
-kmi = km.keymap_items.new('view2d.scroll_up', 'PAGE_UP', 'PRESS')
-kmi_props_setattr(kmi.properties, 'page', True)
-kmi = km.keymap_items.new('view2d.zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('view2d.zoom', 'TRACKPADZOOM', 'ANY')
-kmi = km.keymap_items.new('view2d.zoom', 'TRACKPADPAN', 'ANY', ctrl=True)
-kmi = km.keymap_items.new('view2d.zoom_out', 'NUMPAD_MINUS', 'PRESS')
-kmi = km.keymap_items.new('view2d.zoom_in', 'NUMPAD_PLUS', 'PRESS')
-kmi = km.keymap_items.new('view2d.reset', 'HOME', 'PRESS')
-
-# Map Frames
-km = kc.keymaps.new('Frames', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('screen.frame_offset', 'UP_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'delta', 10)
-kmi = km.keymap_items.new('screen.frame_offset', 'DOWN_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'delta', -10)
-kmi = km.keymap_items.new('screen.frame_offset', 'LEFT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('screen.frame_offset', 'RIGHT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('screen.frame_offset', 'WHEELDOWNMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('screen.frame_offset', 'WHEELUPMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('screen.frame_jump', 'UP_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'end', True)
-kmi = km.keymap_items.new('screen.frame_jump', 'DOWN_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'end', False)
-kmi = km.keymap_items.new('screen.frame_jump', 'RIGHT_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'end', True)
-kmi = km.keymap_items.new('screen.frame_jump', 'LEFT_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'end', False)
-kmi = km.keymap_items.new('screen.keyframe_jump', 'UP_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'next', True)
-kmi = km.keymap_items.new('screen.keyframe_jump', 'DOWN_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'next', False)
-kmi = km.keymap_items.new('screen.keyframe_jump', 'MEDIA_LAST', 'PRESS')
-kmi_props_setattr(kmi.properties, 'next', True)
-kmi = km.keymap_items.new('screen.keyframe_jump', 'MEDIA_FIRST', 'PRESS')
-kmi_props_setattr(kmi.properties, 'next', False)
-kmi = km.keymap_items.new('screen.animation_play', 'A', 'PRESS', alt=True)
-kmi = km.keymap_items.new('screen.animation_play', 'A', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'reverse', True)
-kmi = km.keymap_items.new('screen.animation_cancel', 'ESC', 'PRESS')
-kmi = km.keymap_items.new('screen.animation_play', 'MEDIA_PLAY', 'PRESS')
-kmi = km.keymap_items.new('screen.animation_cancel', 'MEDIA_STOP', 'PRESS')
-
-# Map Property Editor
-km = kc.keymaps.new('Property Editor', space_type='PROPERTIES', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('buttons.toolbox', 'RIGHTMOUSE', 'PRESS')
-
-# Map Markers
-km = kc.keymaps.new('Markers', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
-kmi = km.keymap_items.new('marker.move', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('marker.duplicate', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'camera', True)
-kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'camera', True)
-kmi = km.keymap_items.new('marker.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('marker.select_all', 'A', 'PRESS')
-kmi = km.keymap_items.new('marker.delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('marker.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('marker.move', 'G', 'PRESS')
-kmi = km.keymap_items.new('marker.camera_bind', 'B', 'PRESS', ctrl=True)
-
-# Map Animation
-km = kc.keymaps.new('Animation', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('anim.change_frame', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('wm.context_toggle', 'T', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_seconds')
-kmi = km.keymap_items.new('anim.previewrange_set', 'P', 'PRESS')
-kmi = km.keymap_items.new('anim.previewrange_clear', 'P', 'PRESS', alt=True)
-
-# Map Dopesheet
-km = kc.keymaps.new('Dopesheet', space_type='DOPESHEET_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'column', False)
-kmi_props_setattr(kmi.properties, 'channel', False)
-kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'column', True)
-kmi_props_setattr(kmi.properties, 'channel', False)
-kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'column', False)
-kmi_props_setattr(kmi.properties, 'channel', False)
-kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'column', True)
-kmi_props_setattr(kmi.properties, 'channel', False)
-kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'column', False)
-kmi_props_setattr(kmi.properties, 'channel', True)
-kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'column', False)
-kmi_props_setattr(kmi.properties, 'channel', True)
-kmi = km.keymap_items.new('action.select_leftright', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CHECK')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('action.select_leftright', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CHECK')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('action.select_leftright', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'LEFT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('action.select_leftright', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'RIGHT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('action.select_all_toggle', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'invert', False)
-kmi = km.keymap_items.new('action.select_all_toggle', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'invert', True)
-kmi = km.keymap_items.new('action.select_border', 'B', 'PRESS')
-kmi_props_setattr(kmi.properties, 'axis_range', False)
-kmi = km.keymap_items.new('action.select_border', 'B', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'axis_range', True)
-kmi = km.keymap_items.new('action.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('action.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('action.select_circle', 'C', 'PRESS')
-kmi = km.keymap_items.new('action.select_column', 'K', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'KEYS')
-kmi = km.keymap_items.new('action.select_column', 'K', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CFRA')
-kmi = km.keymap_items.new('action.select_column', 'K', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'MARKERS_COLUMN')
-kmi = km.keymap_items.new('action.select_column', 'K', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'MARKERS_BETWEEN')
-kmi = km.keymap_items.new('action.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('action.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('action.select_linked', 'L', 'PRESS')
-kmi = km.keymap_items.new('action.frame_jump', 'G', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('action.snap', 'S', 'PRESS', shift=True)
-kmi = km.keymap_items.new('action.mirror', 'M', 'PRESS', shift=True)
-kmi = km.keymap_items.new('action.handle_type', 'V', 'PRESS')
-kmi = km.keymap_items.new('action.interpolation_type', 'T', 'PRESS')
-kmi = km.keymap_items.new('action.extrapolation_type', 'E', 'PRESS', shift=True)
-kmi = km.keymap_items.new('action.keyframe_type', 'R', 'PRESS')
-kmi = km.keymap_items.new('action.sample', 'O', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'DOPESHEET_MT_delete')
-kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'DOPESHEET_MT_delete')
-kmi = km.keymap_items.new('action.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('action.keyframe_insert', 'I', 'PRESS')
-kmi = km.keymap_items.new('action.copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('action.paste', 'V', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('action.paste', 'V', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'flipped', True)
-if platform == "darwin":
- kmi = km.keymap_items.new('action.copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('action.paste', 'V', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('action.paste', 'V', 'PRESS', shift=True, oskey=True)
- kmi_props_setattr(kmi.properties, 'flipped', True)
-kmi = km.keymap_items.new('action.previewrange_set', 'P', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('action.view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('action.view_all', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('action.view_selected', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('action.view_frame', 'NUMPAD_0', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_editable_toggle', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('transform.transform', 'G', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_TRANSLATE')
-kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_S', 'ANY')
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_TRANSLATE')
-kmi = km.keymap_items.new('transform.transform', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_EXTEND')
-kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_SCALE')
-kmi = km.keymap_items.new('transform.transform', 'T', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_SLIDE')
-kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_proportional_action')
-kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
-kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True)
-
-# Map Dopesheet Generic
-km = kc.keymaps.new('Dopesheet Generic', space_type='DOPESHEET_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('action.properties', 'N', 'PRESS')
-
-# Map Outliner
-km = kc.keymaps.new('Outliner', space_type='OUTLINER', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('outliner.highlight_update', 'MOUSEMOVE', 'ANY', any=True)
-kmi = km.keymap_items.new('outliner.item_rename', 'LEFTMOUSE', 'DOUBLE_CLICK')
-kmi = km.keymap_items.new('outliner.item_activate', 'LEFTMOUSE', 'CLICK')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'recursive', False)
-kmi = km.keymap_items.new('outliner.item_activate', 'LEFTMOUSE', 'CLICK', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'recursive', False)
-kmi = km.keymap_items.new('outliner.item_activate', 'LEFTMOUSE', 'CLICK', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'recursive', True)
-kmi = km.keymap_items.new('outliner.item_activate', 'LEFTMOUSE', 'CLICK', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'recursive', True)
-kmi = km.keymap_items.new('outliner.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('outliner.item_openclose', 'RET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'all', False)
-kmi = km.keymap_items.new('outliner.item_openclose', 'RET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'all', True)
-kmi = km.keymap_items.new('outliner.item_rename', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('outliner.operation', 'RIGHTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('outliner.item_drag_drop', 'EVT_TWEAK_L', 'ANY')
-kmi = km.keymap_items.new('outliner.show_hierarchy', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('outliner.show_active', 'PERIOD', 'PRESS')
-kmi = km.keymap_items.new('outliner.show_active', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('outliner.scroll_page', 'PAGE_DOWN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'up', False)
-kmi = km.keymap_items.new('outliner.scroll_page', 'PAGE_UP', 'PRESS')
-kmi_props_setattr(kmi.properties, 'up', True)
-kmi = km.keymap_items.new('outliner.show_one_level', 'NUMPAD_PLUS', 'PRESS')
-kmi = km.keymap_items.new('outliner.show_one_level', 'NUMPAD_MINUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'open', False)
-kmi = km.keymap_items.new('outliner.selected_toggle', 'A', 'PRESS')
-kmi = km.keymap_items.new('outliner.expanded_toggle', 'A', 'PRESS', shift=True)
-kmi = km.keymap_items.new('outliner.keyingset_add_selected', 'K', 'PRESS')
-kmi = km.keymap_items.new('outliner.keyingset_remove_selected', 'K', 'PRESS', alt=True)
-kmi = km.keymap_items.new('anim.keyframe_insert', 'I', 'PRESS')
-kmi = km.keymap_items.new('anim.keyframe_delete', 'I', 'PRESS', alt=True)
-kmi = km.keymap_items.new('outliner.drivers_add_selected', 'D', 'PRESS')
-kmi = km.keymap_items.new('outliner.drivers_delete_selected', 'D', 'PRESS', alt=True)
-kmi = km.keymap_items.new('outliner.collection_new', 'C', 'PRESS')
-kmi = km.keymap_items.new('outliner.collection_delete', 'X', 'PRESS')
-
-# Map 3D View Generic
-km = kc.keymaps.new('3D View Generic', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.properties', 'N', 'PRESS')
-kmi = km.keymap_items.new('view3d.toolshelf', 'T', 'PRESS')
-
-# Map Grease Pencil
-km = kc.keymaps.new('Grease Pencil', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('gpencil.draw', 'LEFTMOUSE', 'PRESS', key_modifier='D')
-kmi_props_setattr(kmi.properties, 'mode', 'DRAW')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('gpencil.draw', 'LEFTMOUSE', 'PRESS', ctrl=True, key_modifier='D')
-kmi_props_setattr(kmi.properties, 'mode', 'DRAW_STRAIGHT')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('gpencil.draw', 'RIGHTMOUSE', 'PRESS', ctrl=True, key_modifier='D')
-kmi_props_setattr(kmi.properties, 'mode', 'DRAW_POLY')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('gpencil.draw', 'RIGHTMOUSE', 'PRESS', key_modifier='D')
-kmi_props_setattr(kmi.properties, 'mode', 'ERASER')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('gpencil.draw', 'ERASER', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'ERASER')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('gpencil.editmode_toggle', 'TAB', 'PRESS', key_modifier='D')
-kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS', key_modifier='D')
-kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_pie_tool_palette')
-kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS', key_modifier='D')
-kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_pie_settings_palette')
-kmi = km.keymap_items.new('gpencil.blank_frame_add', 'B', 'PRESS', key_modifier='D')
-kmi = km.keymap_items.new('gpencil.active_frames_delete_all', 'X', 'PRESS', key_modifier='D')
-
-# Map Grease Pencil Stroke Edit Mode
-km = kc.keymaps.new('Grease Pencil Stroke Edit Mode', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('gpencil.editmode_toggle', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('wm.call_menu_pie', 'E', 'PRESS', key_modifier='D')
-kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_pie_sculpt')
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'user_preferences.edit.grease_pencil_eraser_radius')
-kmi = km.keymap_items.new('gpencil.interpolate', 'E', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('gpencil.interpolate_sequence', 'E', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('gpencil.brush_paint', 'LEFTMOUSE', 'PRESS', key_modifier='E')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('gpencil.brush_paint', 'LEFTMOUSE', 'PRESS', ctrl=True, key_modifier='E')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('gpencil.brush_paint', 'LEFTMOUSE', 'PRESS', shift=True, key_modifier='E')
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.gpencil_sculpt.brush.strength')
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.gpencil_sculpt.brush.size')
-kmi = km.keymap_items.new('gpencil.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('gpencil.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('gpencil.select_circle', 'C', 'PRESS')
-kmi = km.keymap_items.new('gpencil.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('gpencil.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('gpencil.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('gpencil.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('gpencil.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('gpencil.select', 'SELECTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('gpencil.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('gpencil.select', 'SELECTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'entire_strokes', True)
-kmi = km.keymap_items.new('gpencil.select_linked', 'L', 'PRESS')
-kmi = km.keymap_items.new('gpencil.select_linked', 'L', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('gpencil.select_grouped', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('gpencil.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('gpencil.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('gpencil.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_gpencil_delete')
-kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_gpencil_delete')
-kmi = km.keymap_items.new('gpencil.dissolve', 'X', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('gpencil.dissolve', 'DEL', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('gpencil.active_frames_delete_all', 'X', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_gpencil_edit_specials')
-kmi = km.keymap_items.new('gpencil.stroke_join', 'J', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('gpencil.stroke_join', 'J', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'JOINCOPY')
-kmi = km.keymap_items.new('gpencil.copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('gpencil.paste', 'V', 'PRESS', ctrl=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('gpencil.copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('gpencil.paste', 'V', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_snap')
-kmi = km.keymap_items.new('gpencil.convert', 'C', 'PRESS', alt=True)
-kmi = km.keymap_items.new('gpencil.reveal', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('gpencil.hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('gpencil.hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('gpencil.selection_opacity_toggle', 'H', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('gpencil.layer_isolate', 'NUMPAD_ASTERIX', 'PRESS')
-kmi = km.keymap_items.new('gpencil.move_to_layer', 'M', 'PRESS')
-kmi = km.keymap_items.new('gpencil.brush_select', 'ONE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 0)
-kmi = km.keymap_items.new('gpencil.brush_select', 'TWO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 1)
-kmi = km.keymap_items.new('gpencil.brush_select', 'THREE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 2)
-kmi = km.keymap_items.new('gpencil.brush_select', 'FOUR', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 3)
-kmi = km.keymap_items.new('gpencil.brush_select', 'FIVE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 4)
-kmi = km.keymap_items.new('gpencil.brush_select', 'SIX', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 5)
-kmi = km.keymap_items.new('gpencil.brush_select', 'SEVEN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 6)
-kmi = km.keymap_items.new('gpencil.brush_select', 'EIGHT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 7)
-kmi = km.keymap_items.new('gpencil.brush_select', 'NINE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 8)
-kmi = km.keymap_items.new('gpencil.brush_select', 'ZERO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'index', 9)
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-kmi = km.keymap_items.new('transform.mirror', 'M', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('transform.bend', 'W', 'PRESS', shift=True)
-kmi = km.keymap_items.new('transform.tosphere', 'S', 'PRESS', shift=True, alt=True)
-kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'GPENCIL_SHRINKFATTEN')
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED')
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'CONNECTED')
-
-# Map Face Mask
-km = kc.keymaps.new('Face Mask', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paint.face_select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('paint.face_select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('paint.face_select_hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('paint.face_select_hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('paint.face_select_reveal', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('paint.face_select_linked', 'L', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('paint.face_select_linked_pick', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('paint.face_select_linked_pick', 'L', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-
-# Map Weight Paint Vertex Selection
-km = kc.keymaps.new('Weight Paint Vertex Selection', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paint.vert_select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('paint.vert_select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('view3d.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('view3d.select_circle', 'C', 'PRESS')
-
-# Map Pose
-km = kc.keymaps.new('Pose', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('object.parent_set', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_add')
-kmi = km.keymap_items.new('pose.hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('pose.hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('pose.reveal', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_pose_apply')
-kmi = km.keymap_items.new('pose.rot_clear', 'R', 'PRESS', alt=True)
-kmi = km.keymap_items.new('pose.loc_clear', 'G', 'PRESS', alt=True)
-kmi = km.keymap_items.new('pose.scale_clear', 'S', 'PRESS', alt=True)
-kmi = km.keymap_items.new('pose.quaternions_flip', 'F', 'PRESS', alt=True)
-kmi = km.keymap_items.new('pose.rotation_mode_set', 'R', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('pose.copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('pose.paste', 'V', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'flipped', False)
-kmi = km.keymap_items.new('pose.paste', 'V', 'PRESS', shift=True, ctrl=True)
-if platform == "darwin":
- kmi_props_setattr(kmi.properties, 'flipped', True)
- kmi = km.keymap_items.new('pose.copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('pose.paste', 'V', 'PRESS', oskey=True)
- kmi_props_setattr(kmi.properties, 'flipped', False)
- kmi = km.keymap_items.new('pose.paste', 'V', 'PRESS', shift=True, oskey=True)
-kmi_props_setattr(kmi.properties, 'flipped', True)
-kmi = km.keymap_items.new('pose.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('pose.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('pose.select_parent', 'P', 'PRESS', shift=True)
-kmi = km.keymap_items.new('pose.select_hierarchy', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'PARENT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('pose.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'PARENT')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('pose.select_hierarchy', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'CHILD')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('pose.select_hierarchy', 'RIGHT_BRACKET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'CHILD')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('pose.select_linked', 'L', 'PRESS')
-kmi = km.keymap_items.new('pose.select_grouped', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('pose.select_mirror', 'F', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('pose.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('pose.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('pose.ik_add', 'I', 'PRESS', shift=True)
-kmi = km.keymap_items.new('pose.ik_clear', 'I', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_pose_group')
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_toggle')
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_enable')
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True)
-kmi_props_setattr(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('armature.armature_layers', 'M', 'PRESS', shift=True)
-kmi = km.keymap_items.new('pose.bone_layers', 'M', 'PRESS')
-kmi = km.keymap_items.new('pose.toggle_bone_selection_overlay', 'Z', 'PRESS')
-kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'BONE_SIZE')
-kmi = km.keymap_items.new('anim.keyframe_insert_menu', 'I', 'PRESS')
-kmi = km.keymap_items.new('anim.keyframe_delete_v3d', 'I', 'PRESS', alt=True)
-kmi = km.keymap_items.new('anim.keying_set_active_set', 'I', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('poselib.browse_interactive', 'L', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('poselib.pose_add', 'L', 'PRESS', shift=True)
-kmi = km.keymap_items.new('poselib.pose_remove', 'L', 'PRESS', alt=True)
-kmi = km.keymap_items.new('poselib.pose_rename', 'L', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('pose.push', 'E', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('pose.relax', 'E', 'PRESS', alt=True)
-kmi = km.keymap_items.new('pose.breakdown', 'E', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_pose_specials')
-kmi = km.keymap_items.new('wm.call_menu', 'P', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_pose_propagate')
-
-# Map Object Mode
-km = kc.keymaps.new('Object Mode', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_proportional_edit_objects')
-kmi = km.keymap_items.new('object.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('object.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('object.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('object.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('object.select_linked', 'L', 'PRESS', shift=True)
-kmi = km.keymap_items.new('object.select_grouped', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('object.select_mirror', 'M', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'PARENT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'PARENT')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('object.select_hierarchy', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'CHILD')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('object.select_hierarchy', 'RIGHT_BRACKET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'CHILD')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('object.parent_set', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('object.parent_no_inverse_set', 'P', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('object.parent_clear', 'P', 'PRESS', alt=True)
-kmi = km.keymap_items.new('object.track_set', 'T', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('object.track_clear', 'T', 'PRESS', alt=True)
-kmi = km.keymap_items.new('object.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('object.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('object.location_clear', 'G', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'clear_delta', False)
-kmi = km.keymap_items.new('object.rotation_clear', 'R', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'clear_delta', False)
-kmi = km.keymap_items.new('object.scale_clear', 'S', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'clear_delta', False)
-kmi = km.keymap_items.new('object.origin_clear', 'O', 'PRESS', alt=True)
-kmi = km.keymap_items.new('object.delete', 'X', 'PRESS')
-kmi_props_setattr(kmi.properties, 'use_global', False)
-kmi = km.keymap_items.new('object.delete', 'X', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'use_global', True)
-kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'use_global', False)
-kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'use_global', True)
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_add')
-kmi = km.keymap_items.new('object.duplicates_make_real', 'A', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_object_apply')
-kmi = km.keymap_items.new('wm.call_menu', 'U', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_make_single_user')
-kmi = km.keymap_items.new('wm.call_menu', 'L', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_make_links')
-kmi = km.keymap_items.new('object.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('object.duplicate_move_linked', 'D', 'PRESS', alt=True)
-kmi = km.keymap_items.new('object.join', 'J', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('object.convert', 'C', 'PRESS', alt=True)
-kmi = km.keymap_items.new('object.proxy_make', 'P', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('object.make_local', 'L', 'PRESS')
-kmi = km.keymap_items.new('anim.keyframe_insert_menu', 'I', 'PRESS')
-kmi = km.keymap_items.new('anim.keyframe_delete_v3d', 'I', 'PRESS', alt=True)
-kmi = km.keymap_items.new('anim.keying_set_active_set', 'I', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('collection.create', 'G', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('collection.objects_remove', 'G', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('collection.objects_remove_all', 'G', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('collection.objects_add_active', 'G', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('collection.objects_remove_active', 'G', 'PRESS', shift=True, alt=True)
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_object_specials')
-kmi = km.keymap_items.new('object.data_transfer', 'T', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 0)
-kmi = km.keymap_items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 1)
-kmi = km.keymap_items.new('object.subdivision_set', 'TWO', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 2)
-kmi = km.keymap_items.new('object.subdivision_set', 'THREE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 3)
-kmi = km.keymap_items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 4)
-kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 5)
-kmi = km.keymap_items.new('object.move_to_collection', 'M', 'PRESS')
-
-# Map Paint Curve
-km = kc.keymaps.new('Paint Curve', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paintcurve.add_point_slide', 'ACTIONMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('paintcurve.select', 'SELECTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('paintcurve.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('paintcurve.slide', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('paintcurve.slide', 'ACTIONMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'align', True)
-kmi = km.keymap_items.new('paintcurve.select', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('paintcurve.cursor', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('paintcurve.delete_point', 'X', 'PRESS')
-kmi = km.keymap_items.new('paintcurve.delete_point', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('paintcurve.draw', 'RET', 'PRESS')
-kmi = km.keymap_items.new('paintcurve.draw', 'NUMPAD_ENTER', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-
-# Map Curve
-km = kc.keymaps.new('Curve', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_edit_curve_add')
-kmi = km.keymap_items.new('curve.handle_type_set', 'V', 'PRESS')
-kmi = km.keymap_items.new('curve.vertex_add', 'ACTIONMOUSE', 'CLICK', ctrl=True)
-kmi = km.keymap_items.new('curve.draw', 'ACTIONMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('curve.draw', 'PEN', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'wait_for_input', False)
-kmi = km.keymap_items.new('curve.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('curve.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('curve.select_row', 'R', 'PRESS', shift=True)
-kmi = km.keymap_items.new('curve.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('curve.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('curve.select_linked', 'L', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('curve.select_similar', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('curve.select_linked_pick', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('curve.select_linked_pick', 'L', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('curve.shortest_path_pick', 'SELECTMOUSE', 'CLICK', ctrl=True)
-kmi = km.keymap_items.new('curve.separate', 'P', 'PRESS')
-kmi = km.keymap_items.new('curve.split', 'Y', 'PRESS')
-kmi = km.keymap_items.new('curve.extrude_move', 'E', 'PRESS')
-kmi = km.keymap_items.new('curve.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('curve.make_segment', 'F', 'PRESS')
-kmi = km.keymap_items.new('curve.cyclic_toggle', 'C', 'PRESS', alt=True)
-kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_curve_delete')
-kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_curve_delete')
-kmi = km.keymap_items.new('curve.dissolve_verts', 'X', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('curve.dissolve_verts', 'DEL', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('curve.tilt_clear', 'T', 'PRESS', alt=True)
-kmi = km.keymap_items.new('transform.tilt', 'T', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CURVE_SHRINKFATTEN')
-kmi = km.keymap_items.new('curve.reveal', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('curve.hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('curve.hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('curve.normals_make_consistent', 'N', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('object.vertex_parent_set', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_curve_specials')
-kmi = km.keymap_items.new('wm.call_menu', 'H', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_hook')
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED')
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'CONNECTED')
-
-# Map Image Paint
-km = kc.keymaps.new('Image Paint', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paint.image_paint', 'LEFTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'NORMAL')
-kmi = km.keymap_items.new('paint.image_paint', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'INVERT')
-kmi = km.keymap_items.new('paint.brush_colors_flip', 'X', 'PRESS')
-kmi = km.keymap_items.new('paint.grab_clone', 'RIGHTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('paint.sample_color', 'S', 'PRESS')
-kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 0)
-kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 1)
-kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 2)
-kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 3)
-kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 4)
-kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 5)
-kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 6)
-kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 7)
-kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 8)
-kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 9)
-kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 10)
-kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 11)
-kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 12)
-kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 13)
-kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 14)
-kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 15)
-kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 16)
-kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 17)
-kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 18)
-kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'image_paint')
-kmi_props_setattr(kmi.properties, 'index', 19)
-kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 0.9)
-kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.image_paint.brush.size')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.image_paint.brush.mask_texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.image_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.image_paint.brush.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color')
-kmi_props_setattr(kmi.properties, 'zoom_path', 'space_data.zoom')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.image_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', True)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.image_paint.brush.strength')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.image_paint.brush.mask_texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.image_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.image_paint.brush.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.image_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', True)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.image_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', '')
-kmi_props_setattr(kmi.properties, 'use_secondary', '')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.image_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.image_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.image_paint.brush.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.image_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.image_paint.brush.mask_texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', '')
-kmi_props_setattr(kmi.properties, 'use_secondary', '')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.image_paint.brush.mask_texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.image_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.image_paint.brush.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.image_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', True)
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'SCALE')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'ROTATION')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'SCALE')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'ROTATION')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'image_paint_object.data.use_paint_mask')
-kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.image_paint.brush.use_smooth_stroke')
-kmi = km.keymap_items.new('wm.call_menu', 'R', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_angle_control')
-kmi = km.keymap_items.new('wm.context_menu_enum', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.image_paint.brush.stroke_method')
-
-# Map Vertex Paint
-km = kc.keymaps.new('Vertex Paint', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paint.vertex_paint', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('paint.brush_colors_flip', 'X', 'PRESS')
-kmi = km.keymap_items.new('paint.sample_color', 'S', 'PRESS')
-kmi = km.keymap_items.new('paint.vertex_color_set', 'K', 'PRESS', shift=True)
-kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 0)
-kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 1)
-kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 2)
-kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 3)
-kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 4)
-kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 5)
-kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 6)
-kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 7)
-kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 8)
-kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 9)
-kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 10)
-kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 11)
-kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 12)
-kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 13)
-kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 14)
-kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 15)
-kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 16)
-kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 17)
-kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 18)
-kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint')
-kmi_props_setattr(kmi.properties, 'index', 19)
-kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 0.9)
-kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.vertex_paint.brush.size')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.vertex_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.vertex_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.vertex_paint.brush.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.vertex_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.vertex_paint.brush.strength')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.vertex_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.vertex_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.vertex_paint.brush.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.vertex_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.vertex_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', '')
-kmi_props_setattr(kmi.properties, 'use_secondary', '')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.vertex_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.vertex_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.vertex_paint.brush.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.vertex_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'SCALE')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'ROTATION')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'SCALE')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'ROTATION')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'vertex_paint_object.data.use_paint_mask')
-kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.vertex_paint.brush.use_smooth_stroke')
-kmi = km.keymap_items.new('wm.call_menu', 'R', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_angle_control')
-kmi = km.keymap_items.new('wm.context_menu_enum', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.vertex_paint.brush.stroke_method')
-
-# Map Weight Paint
-km = kc.keymaps.new('Weight Paint', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('paint.weight_paint', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('paint.weight_sample', 'ACTIONMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('paint.weight_sample_group', 'ACTIONMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('paint.weight_gradient', 'LEFTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'type', 'LINEAR')
-kmi = km.keymap_items.new('paint.weight_gradient', 'LEFTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'type', 'RADIAL')
-kmi = km.keymap_items.new('paint.weight_set', 'K', 'PRESS', shift=True)
-kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 0)
-kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 1)
-kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 2)
-kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 3)
-kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 4)
-kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 5)
-kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 6)
-kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 7)
-kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 8)
-kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 9)
-kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 10)
-kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 11)
-kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 12)
-kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 13)
-kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 14)
-kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 15)
-kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 16)
-kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 17)
-kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 18)
-kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'weight_paint')
-kmi_props_setattr(kmi.properties, 'index', 19)
-kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 0.9)
-kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.weight_paint.brush.size')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.weight_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.weight_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.weight_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.weight_paint.brush.strength')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.weight_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.weight_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.weight_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.radial_control', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.weight_paint.brush.weight')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.weight')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_weight')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.weight_paint.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.weight_paint.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.weight_paint.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.context_menu_enum', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.vertex_paint.brush.stroke_method')
-kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'weight_paint_object.data.use_paint_mask')
-kmi = km.keymap_items.new('wm.context_toggle', 'V', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'weight_paint_object.data.use_paint_mask_vertex')
-kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.weight_paint.brush.use_smooth_stroke')
-
-# Map Sculpt
-km = kc.keymaps.new('Sculpt', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'NORMAL')
-kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'INVERT')
-kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'SMOOTH')
-kmi = km.keymap_items.new('paint.hide_show', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'action', 'SHOW')
-kmi_props_setattr(kmi.properties, 'area', 'INSIDE')
-kmi = km.keymap_items.new('paint.hide_show', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'HIDE')
-kmi_props_setattr(kmi.properties, 'area', 'INSIDE')
-kmi = km.keymap_items.new('paint.hide_show', 'H', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'action', 'SHOW')
-kmi_props_setattr(kmi.properties, 'area', 'ALL')
-kmi = km.keymap_items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 0)
-kmi = km.keymap_items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 1)
-kmi = km.keymap_items.new('object.subdivision_set', 'TWO', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 2)
-kmi = km.keymap_items.new('object.subdivision_set', 'THREE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 3)
-kmi = km.keymap_items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 4)
-kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 5)
-kmi = km.keymap_items.new('paint.mask_flood_fill', 'M', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'VALUE')
-kmi_props_setattr(kmi.properties, 'value', 0.0)
-kmi = km.keymap_items.new('paint.mask_flood_fill', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'INVERT')
-kmi = km.keymap_items.new('paint.mask_lasso_gesture', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'scene.tool_settings.sculpt.show_mask')
-kmi = km.keymap_items.new('sculpt.dynamic_topology_toggle', 'D', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('sculpt.set_detail_size', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('object.subdivision_set', 'PAGE_UP', 'PRESS')
-kmi_props_setattr(kmi.properties, 'level', 1)
-kmi_props_setattr(kmi.properties, 'relative', True)
-kmi = km.keymap_items.new('object.subdivision_set', 'PAGE_DOWN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'level', -1)
-kmi_props_setattr(kmi.properties, 'relative', True)
-kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 0)
-kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 1)
-kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 2)
-kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 3)
-kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 4)
-kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 5)
-kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 6)
-kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 7)
-kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 8)
-kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 9)
-kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 10)
-kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 11)
-kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 12)
-kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 13)
-kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 14)
-kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 15)
-kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 16)
-kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 17)
-kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 18)
-kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'sculpt')
-kmi_props_setattr(kmi.properties, 'index', 19)
-kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 0.9)
-kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.sculpt.brush.size')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.sculpt.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.sculpt.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.sculpt.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.sculpt.brush.strength')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.sculpt.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.sculpt.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.sculpt.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.sculpt.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', '')
-kmi_props_setattr(kmi.properties, 'use_secondary', '')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.sculpt.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.sculpt.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.sculpt.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'SCALE')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'ROTATION')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'SCALE')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'ROTATION')
-kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY')
-kmi = km.keymap_items.new('paint.brush_select', 'X', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'DRAW')
-kmi = km.keymap_items.new('paint.brush_select', 'S', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'SMOOTH')
-kmi = km.keymap_items.new('paint.brush_select', 'P', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'PINCH')
-kmi = km.keymap_items.new('paint.brush_select', 'I', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'INFLATE')
-kmi = km.keymap_items.new('paint.brush_select', 'G', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'GRAB')
-kmi = km.keymap_items.new('paint.brush_select', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'LAYER')
-kmi = km.keymap_items.new('paint.brush_select', 'T', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'FLATTEN')
-kmi = km.keymap_items.new('paint.brush_select', 'C', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'CLAY')
-kmi = km.keymap_items.new('paint.brush_select', 'C', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'CREASE')
-kmi = km.keymap_items.new('paint.brush_select', 'K', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'SNAKE_HOOK')
-kmi = km.keymap_items.new('paint.brush_select', 'M', 'PRESS')
-kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT')
-kmi_props_setattr(kmi.properties, 'sculpt_tool', 'MASK')
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi_props_setattr(kmi.properties, 'create_missing', True)
-kmi = km.keymap_items.new('wm.context_menu_enum', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.sculpt.brush.stroke_method')
-kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.sculpt.brush.use_smooth_stroke')
-kmi = km.keymap_items.new('wm.call_menu', 'R', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_angle_control')
-
-# Map Mesh
-km = kc.keymaps.new('Mesh', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mesh.loopcut_slide', 'R', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mesh.offset_edge_loops_slide', 'R', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('mesh.inset', 'I', 'PRESS')
-kmi = km.keymap_items.new('mesh.poke', 'P', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mesh.bevel', 'B', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'vertex_only', False)
-kmi = km.keymap_items.new('mesh.bevel', 'B', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'vertex_only', True)
-kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', False)
-kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('mesh.edgering_select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', False)
-kmi = km.keymap_items.new('mesh.edgering_select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('mesh.shortest_path_pick', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'use_fill', False)
-kmi = km.keymap_items.new('mesh.shortest_path_pick', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'use_fill', True)
-kmi = km.keymap_items.new('mesh.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('mesh.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('mesh.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mesh.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mesh.select_next_item', 'NUMPAD_PLUS', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('mesh.select_prev_item', 'NUMPAD_MINUS', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('mesh.select_non_manifold', 'M', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('mesh.select_linked', 'L', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mesh.select_linked_pick', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('mesh.select_linked_pick', 'L', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('mesh.faces_select_linked_flat', 'F', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_select_similar')
-kmi = km.keymap_items.new('wm.call_menu', 'TAB', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_select_mode')
-kmi = km.keymap_items.new('mesh.hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('mesh.hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('mesh.reveal', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mesh.normals_make_consistent', 'N', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'inside', False)
-kmi = km.keymap_items.new('mesh.normals_make_consistent', 'N', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'inside', True)
-kmi = km.keymap_items.new('view3d.edit_mesh_extrude_move_normal', 'E', 'PRESS')
-kmi = km.keymap_items.new('wm.call_menu', 'E', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_extrude')
-kmi = km.keymap_items.new('transform.edge_crease', 'E', 'PRESS', shift=True)
-kmi = km.keymap_items.new('mesh.spin', 'R', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mesh.fill', 'F', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mesh.beautify_fill', 'F', 'PRESS', shift=True, alt=True)
-kmi = km.keymap_items.new('mesh.quads_convert_to_tris', 'T', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'quad_method', 'BEAUTY')
-kmi_props_setattr(kmi.properties, 'ngon_method', 'BEAUTY')
-kmi = km.keymap_items.new('mesh.quads_convert_to_tris', 'T', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'quad_method', 'FIXED')
-kmi_props_setattr(kmi.properties, 'ngon_method', 'CLIP')
-kmi = km.keymap_items.new('mesh.tris_convert_to_quads', 'J', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mesh.rip_move', 'V', 'PRESS')
-kmi_props_setattr(kmi.properties.MESH_OT_rip, 'use_fill', False)
-kmi = km.keymap_items.new('mesh.rip_move', 'V', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties.MESH_OT_rip, 'use_fill', True)
-kmi = km.keymap_items.new('mesh.rip_edge_move', 'D', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mesh.merge', 'M', 'PRESS', alt=True)
-kmi = km.keymap_items.new('transform.shrink_fatten', 'S', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mesh.edge_face_add', 'F', 'PRESS')
-kmi = km.keymap_items.new('mesh.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_mesh_add')
-kmi = km.keymap_items.new('mesh.separate', 'P', 'PRESS')
-kmi = km.keymap_items.new('mesh.split', 'Y', 'PRESS')
-kmi = km.keymap_items.new('mesh.vert_connect_path', 'J', 'PRESS')
-kmi = km.keymap_items.new('transform.vert_slide', 'V', 'PRESS', shift=True)
-kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'CLICK', ctrl=True)
-kmi_props_setattr(kmi.properties, 'rotate_source', True)
-kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'CLICK', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'rotate_source', False)
-kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_delete')
-kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_delete')
-kmi = km.keymap_items.new('mesh.dissolve_mode', 'X', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mesh.dissolve_mode', 'DEL', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mesh.knife_tool', 'K', 'PRESS')
-kmi_props_setattr(kmi.properties, 'use_occlude_geometry', True)
-kmi_props_setattr(kmi.properties, 'only_selected', False)
-kmi = km.keymap_items.new('mesh.knife_tool', 'K', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'use_occlude_geometry', False)
-kmi_props_setattr(kmi.properties, 'only_selected', True)
-kmi = km.keymap_items.new('object.vertex_parent_set', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_specials')
-kmi = km.keymap_items.new('wm.call_menu', 'F', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_faces')
-kmi = km.keymap_items.new('wm.call_menu', 'E', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_edges')
-kmi = km.keymap_items.new('wm.call_menu', 'V', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_vertices')
-kmi = km.keymap_items.new('wm.call_menu', 'H', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_hook')
-kmi = km.keymap_items.new('wm.call_menu', 'U', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_uv_map')
-kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_vertex_group')
-kmi = km.keymap_items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 0)
-kmi = km.keymap_items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 1)
-kmi = km.keymap_items.new('object.subdivision_set', 'TWO', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 2)
-kmi = km.keymap_items.new('object.subdivision_set', 'THREE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 3)
-kmi = km.keymap_items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 4)
-kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'level', 5)
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED')
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'CONNECTED')
-
-# Map Armature
-km = kc.keymaps.new('Armature', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('armature.hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('armature.hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('armature.reveal', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('armature.align', 'A', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('armature.calculate_roll', 'N', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('armature.roll_clear', 'R', 'PRESS', alt=True)
-kmi = km.keymap_items.new('armature.switch_direction', 'F', 'PRESS', alt=True)
-kmi = km.keymap_items.new('armature.bone_primitive_add', 'A', 'PRESS', shift=True)
-kmi = km.keymap_items.new('armature.parent_set', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('armature.parent_clear', 'P', 'PRESS', alt=True)
-kmi = km.keymap_items.new('armature.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('armature.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('armature.select_mirror', 'M', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('armature.select_hierarchy', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'PARENT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('armature.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'PARENT')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('armature.select_hierarchy', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'CHILD')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('armature.select_hierarchy', 'RIGHT_BRACKET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'CHILD')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('armature.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('armature.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('armature.select_similar', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('armature.select_linked', 'L', 'PRESS')
-kmi = km.keymap_items.new('armature.shortest_path_pick', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_armature_delete')
-kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_armature_delete')
-kmi = km.keymap_items.new('armature.dissolve', 'X', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('armature.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('armature.extrude_move', 'E', 'PRESS')
-kmi = km.keymap_items.new('armature.extrude_forked', 'E', 'PRESS', shift=True)
-kmi = km.keymap_items.new('armature.click_extrude', 'ACTIONMOUSE', 'CLICK', ctrl=True)
-kmi = km.keymap_items.new('armature.fill', 'F', 'PRESS')
-kmi = km.keymap_items.new('armature.merge', 'M', 'PRESS', alt=True)
-kmi = km.keymap_items.new('armature.split', 'Y', 'PRESS')
-kmi = km.keymap_items.new('armature.separate', 'P', 'PRESS')
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_toggle')
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_enable')
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True)
-kmi_props_setattr(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('armature.armature_layers', 'M', 'PRESS', shift=True)
-kmi = km.keymap_items.new('armature.bone_layers', 'M', 'PRESS')
-kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'BONE_SIZE')
-kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'BONE_ENVELOPE')
-kmi = km.keymap_items.new('transform.transform', 'R', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'BONE_ROLL')
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_armature_specials')
-
-# Map Metaball
-km = kc.keymaps.new('Metaball', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('object.metaball_add', 'A', 'PRESS', shift=True)
-kmi = km.keymap_items.new('mball.reveal_metaelems', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mball.hide_metaelems', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('mball.hide_metaelems', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('mball.delete_metaelems', 'X', 'PRESS')
-kmi = km.keymap_items.new('mball.delete_metaelems', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('mball.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('mball.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('mball.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('mball.select_similar', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED')
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'CONNECTED')
-
-# Map Lattice
-km = kc.keymaps.new('Lattice', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('lattice.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('lattice.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('lattice.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('lattice.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('object.vertex_parent_set', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('lattice.flip', 'F', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'H', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_hook')
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED')
-
-# Map Particle
-km = kc.keymaps.new('Particle', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('particle.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('particle.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('particle.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('particle.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('particle.select_linked', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('particle.select_linked', 'L', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('particle.delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('particle.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('particle.reveal', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('particle.hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('particle.hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('particle.brush_edit', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('particle.brush_edit', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.particle_edit.brush.size')
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.particle_edit.brush.strength')
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_particle_specials')
-kmi = km.keymap_items.new('particle.weight_set', 'K', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED')
-
-# Map Font
-km = kc.keymaps.new('Font', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('font.style_toggle', 'B', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'style', 'BOLD')
-kmi = km.keymap_items.new('font.style_toggle', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'style', 'ITALIC')
-kmi = km.keymap_items.new('font.style_toggle', 'U', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'style', 'UNDERLINE')
-kmi = km.keymap_items.new('font.style_toggle', 'P', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'style', 'SMALL_CAPS')
-kmi = km.keymap_items.new('font.delete', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_OR_SELECTION')
-kmi = km.keymap_items.new('font.delete', 'DEL', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
-kmi = km.keymap_items.new('font.delete', 'BACK_SPACE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_OR_SELECTION')
-kmi = km.keymap_items.new('font.delete', 'BACK_SPACE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_OR_SELECTION')
-kmi = km.keymap_items.new('font.delete', 'BACK_SPACE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
-kmi = km.keymap_items.new('font.move', 'HOME', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN')
-kmi = km.keymap_items.new('font.move', 'END', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
-kmi = km.keymap_items.new('font.move', 'LEFT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('font.move', 'RIGHT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER')
-kmi = km.keymap_items.new('font.move', 'LEFT_ARROW', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
-kmi = km.keymap_items.new('font.move', 'RIGHT_ARROW', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
-kmi = km.keymap_items.new('font.move', 'UP_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_LINE')
-kmi = km.keymap_items.new('font.move', 'DOWN_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_LINE')
-kmi = km.keymap_items.new('font.move', 'PAGE_UP', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_PAGE')
-kmi = km.keymap_items.new('font.move', 'PAGE_DOWN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_PAGE')
-kmi = km.keymap_items.new('font.move_select', 'HOME', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN')
-kmi = km.keymap_items.new('font.move_select', 'END', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
-kmi = km.keymap_items.new('font.move_select', 'LEFT_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('font.move_select', 'RIGHT_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER')
-kmi = km.keymap_items.new('font.move_select', 'LEFT_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
-kmi = km.keymap_items.new('font.move_select', 'RIGHT_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
-kmi = km.keymap_items.new('font.move_select', 'UP_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_LINE')
-kmi = km.keymap_items.new('font.move_select', 'DOWN_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_LINE')
-kmi = km.keymap_items.new('font.move_select', 'PAGE_UP', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_PAGE')
-kmi = km.keymap_items.new('font.move_select', 'PAGE_DOWN', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_PAGE')
-kmi = km.keymap_items.new('font.change_spacing', 'LEFT_ARROW', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('font.change_spacing', 'RIGHT_ARROW', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('font.change_character', 'UP_ARROW', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('font.change_character', 'DOWN_ARROW', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('font.select_all', 'A', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('font.text_copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('font.text_cut', 'X', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('font.text_paste', 'V', 'PRESS', ctrl=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('font.select_all', 'A', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('font.text_copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('font.text_cut', 'X', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('font.text_paste', 'V', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('font.line_break', 'RET', 'PRESS')
-kmi = km.keymap_items.new('font.text_insert', 'TEXTINPUT', 'ANY', any=True)
-kmi = km.keymap_items.new('font.text_insert', 'BACK_SPACE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'accent', True)
-
-# Map Object Non-modal
-km = kc.keymaps.new('Object Non-modal', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'EDIT')
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'POSE')
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('object.mode_set', 'V', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'VERTEX_PAINT')
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'WEIGHT_PAINT')
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('object.origin_set', 'C', 'PRESS', shift=True, ctrl=True, alt=True)
-
-# Map 3D View
-km = kc.keymaps.new('3D View', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'CLICK')
-kmi = km.keymap_items.new('view3d.rotate', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('view3d.move', 'MIDDLEMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view3d.zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('view3d.dolly', 'MIDDLEMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('view3d.view_selected', 'NUMPAD_PERIOD', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'use_all_regions', True)
-kmi = km.keymap_items.new('view3d.view_selected', 'NUMPAD_PERIOD', 'PRESS')
-kmi_props_setattr(kmi.properties, 'use_all_regions', False)
-kmi = km.keymap_items.new('view3d.view_lock_to_active', 'NUMPAD_PERIOD', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view3d.view_lock_clear', 'NUMPAD_PERIOD', 'PRESS', alt=True)
-kmi = km.keymap_items.new('view3d.navigate', 'F', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view3d.smoothview', 'TIMER1', 'ANY', any=True)
-kmi = km.keymap_items.new('view3d.rotate', 'TRACKPADPAN', 'ANY')
-kmi = km.keymap_items.new('view3d.rotate', 'MOUSEROTATE', 'ANY')
-kmi = km.keymap_items.new('view3d.move', 'TRACKPADPAN', 'ANY', shift=True)
-kmi = km.keymap_items.new('view3d.zoom', 'TRACKPADZOOM', 'ANY')
-kmi = km.keymap_items.new('view3d.zoom', 'TRACKPADPAN', 'ANY', ctrl=True)
-kmi = km.keymap_items.new('view3d.zoom', 'NUMPAD_PLUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('view3d.zoom', 'NUMPAD_MINUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('view3d.zoom', 'EQUAL', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('view3d.zoom', 'MINUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('view3d.zoom', 'WHEELINMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('view3d.zoom', 'WHEELOUTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('view3d.dolly', 'NUMPAD_PLUS', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('view3d.dolly', 'NUMPAD_MINUS', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('view3d.dolly', 'EQUAL', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'delta', 1)
-kmi = km.keymap_items.new('view3d.dolly', 'MINUS', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'delta', -1)
-kmi = km.keymap_items.new('view3d.zoom_camera_1_to_1', 'NUMPAD_ENTER', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view3d.view_center_camera', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('view3d.view_center_lock', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('view3d.view_center_cursor', 'HOME', 'PRESS', alt=True)
-kmi = km.keymap_items.new('view3d.view_center_pick', 'F', 'PRESS', alt=True)
-kmi = km.keymap_items.new('view3d.view_all', 'HOME', 'PRESS')
-kmi_props_setattr(kmi.properties, 'center', False)
-kmi = km.keymap_items.new('view3d.view_all', 'HOME', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'use_all_regions', True)
-kmi_props_setattr(kmi.properties, 'center', False)
-kmi = km.keymap_items.new('view3d.view_all', 'C', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'center', True)
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_0', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'CAMERA')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'FRONT')
-kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_2', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'ORBITDOWN')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'RIGHT')
-kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_4', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'ORBITLEFT')
-kmi = km.keymap_items.new('view3d.view_persportho', 'NUMPAD_5', 'PRESS')
-kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_6', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'ORBITRIGHT')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'TOP')
-kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_8', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'ORBITUP')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'BACK')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'LEFT')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'BOTTOM')
-kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_2', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PANDOWN')
-kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_4', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PANLEFT')
-kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_6', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PANRIGHT')
-kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_8', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PANUP')
-kmi = km.keymap_items.new('view3d.view_roll', 'NUMPAD_4', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'LEFT')
-kmi = km.keymap_items.new('view3d.view_roll', 'NUMPAD_6', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'RIGHT')
-kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_9', 'PRESS')
-kmi_props_setattr(kmi.properties, 'angle', 3.1415927410125732)
-kmi_props_setattr(kmi.properties, 'type', 'ORBITRIGHT')
-kmi = km.keymap_items.new('view3d.view_pan', 'WHEELUPMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PANRIGHT')
-kmi = km.keymap_items.new('view3d.view_pan', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PANLEFT')
-kmi = km.keymap_items.new('view3d.view_pan', 'WHEELUPMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PANUP')
-kmi = km.keymap_items.new('view3d.view_pan', 'WHEELDOWNMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PANDOWN')
-kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELUPMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'type', 'ORBITLEFT')
-kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'type', 'ORBITRIGHT')
-kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELUPMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'type', 'ORBITUP')
-kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELDOWNMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'type', 'ORBITDOWN')
-kmi = km.keymap_items.new('view3d.view_roll', 'WHEELUPMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'LEFT')
-kmi = km.keymap_items.new('view3d.view_roll', 'WHEELDOWNMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'RIGHT')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'FRONT')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'RIGHT')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'TOP')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'BACK')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'LEFT')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'BOTTOM')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.ndof_orbit_zoom', 'NDOF_MOTION', 'ANY')
-kmi = km.keymap_items.new('view3d.ndof_orbit', 'NDOF_MOTION', 'ANY', ctrl=True)
-kmi = km.keymap_items.new('view3d.ndof_pan', 'NDOF_MOTION', 'ANY', shift=True)
-kmi = km.keymap_items.new('view3d.ndof_all', 'NDOF_MOTION', 'ANY', shift=True, ctrl=True)
-kmi = km.keymap_items.new('view3d.view_selected', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'use_all_regions', False)
-kmi = km.keymap_items.new('view3d.view_roll', 'NDOF_BUTTON_ROLL_CCW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'LEFT')
-kmi = km.keymap_items.new('view3d.view_roll', 'NDOF_BUTTON_ROLL_CCW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'RIGHT')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_FRONT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'FRONT')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_BACK', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'BACK')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_LEFT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'LEFT')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_RIGHT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'RIGHT')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_TOP', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'TOP')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_BOTTOM', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'BOTTOM')
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_FRONT', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'FRONT')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_RIGHT', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'RIGHT')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_TOP', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'TOP')
-kmi_props_setattr(kmi.properties, 'align_active', True)
-kmi = km.keymap_items.new('view3d.layers', 'ACCENT_GRAVE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'nr', 0)
-kmi = km.keymap_items.new('view3d.layers', 'ONE', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 1)
-kmi = km.keymap_items.new('view3d.layers', 'TWO', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 2)
-kmi = km.keymap_items.new('view3d.layers', 'THREE', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 3)
-kmi = km.keymap_items.new('view3d.layers', 'FOUR', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 4)
-kmi = km.keymap_items.new('view3d.layers', 'FIVE', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 5)
-kmi = km.keymap_items.new('view3d.layers', 'SIX', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 6)
-kmi = km.keymap_items.new('view3d.layers', 'SEVEN', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 7)
-kmi = km.keymap_items.new('view3d.layers', 'EIGHT', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 8)
-kmi = km.keymap_items.new('view3d.layers', 'NINE', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 9)
-kmi = km.keymap_items.new('view3d.layers', 'ZERO', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'nr', 10)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'Z', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.shading.type')
-kmi_props_setattr(kmi.properties, 'value_1', 'SOLID')
-kmi_props_setattr(kmi.properties, 'value_2', 'TEXTURED')
-kmi = km.keymap_items.new('view3d.toggle_render', 'Z', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view3d.toggle_xray_draw_option', 'Z', 'PRESS')
-kmi = km.keymap_items.new('wm.context_toggle', 'Z', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.use_occlude_geometry')
-kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', False)
-kmi_props_setattr(kmi.properties, 'center', False)
-kmi_props_setattr(kmi.properties, 'enumerate', False)
-kmi_props_setattr(kmi.properties, 'object', False)
-kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi_props_setattr(kmi.properties, 'center', False)
-kmi_props_setattr(kmi.properties, 'enumerate', False)
-kmi_props_setattr(kmi.properties, 'object', False)
-kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', False)
-kmi_props_setattr(kmi.properties, 'center', True)
-kmi_props_setattr(kmi.properties, 'enumerate', False)
-kmi_props_setattr(kmi.properties, 'object', True)
-kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', False)
-kmi_props_setattr(kmi.properties, 'center', False)
-kmi_props_setattr(kmi.properties, 'enumerate', True)
-kmi_props_setattr(kmi.properties, 'object', False)
-kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi_props_setattr(kmi.properties, 'center', True)
-kmi_props_setattr(kmi.properties, 'enumerate', False)
-kmi_props_setattr(kmi.properties, 'object', False)
-kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', False)
-kmi_props_setattr(kmi.properties, 'center', True)
-kmi_props_setattr(kmi.properties, 'enumerate', True)
-kmi_props_setattr(kmi.properties, 'object', False)
-kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi_props_setattr(kmi.properties, 'center', False)
-kmi_props_setattr(kmi.properties, 'enumerate', True)
-kmi_props_setattr(kmi.properties, 'object', False)
-kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi_props_setattr(kmi.properties, 'center', True)
-kmi_props_setattr(kmi.properties, 'enumerate', True)
-kmi_props_setattr(kmi.properties, 'object', False)
-kmi = km.keymap_items.new('view3d.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('view3d.select_circle', 'C', 'PRESS')
-kmi = km.keymap_items.new('view3d.clip_border', 'B', 'PRESS', alt=True)
-kmi = km.keymap_items.new('view3d.zoom_border', 'B', 'PRESS', shift=True)
-kmi = km.keymap_items.new('view3d.render_border', 'B', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'camera_only', True)
-kmi = km.keymap_items.new('view3d.render_border', 'B', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'camera_only', False)
-kmi = km.keymap_items.new('view3d.clear_render_border', 'B', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('view3d.camera_to_view', 'NUMPAD_0', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('view3d.object_as_camera', 'NUMPAD_0', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_snap')
-if platform == "darwin":
- kmi = km.keymap_items.new('view3d.copybuffer', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('view3d.pastebuffer', 'V', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('view3d.copybuffer', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('view3d.pastebuffer', 'V', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'BOUNDING_BOX_CENTER')
-kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'MEDIAN_POINT')
-kmi = km.keymap_items.new('wm.context_toggle', 'COMMA', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_transform_pivot_point_align')
-kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'CURSOR')
-kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'INDIVIDUAL_ORIGINS')
-kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'ACTIVE_ELEMENT')
-kmi = km.keymap_items.new('wm.context_toggle', 'SPACE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_manipulator')
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-kmi = km.keymap_items.new('transform.bend', 'W', 'PRESS', shift=True)
-kmi = km.keymap_items.new('transform.tosphere', 'S', 'PRESS', shift=True, alt=True)
-kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('transform.select_orientation', 'SPACE', 'PRESS', alt=True)
-kmi = km.keymap_items.new('transform.create_orientation', 'SPACE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'use', True)
-kmi = km.keymap_items.new('transform.mirror', 'M', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_snap')
-kmi = km.keymap_items.new('wm.context_menu_enum', 'TAB', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.snap_element')
-kmi = km.keymap_items.new('object.transform_axis_target', 'T', 'PRESS', shift=True)
-kmi = km.keymap_items.new('transform.translate', 'T', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'texture_space', True)
-kmi = km.keymap_items.new('transform.resize', 'T', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'texture_space', True)
-kmi = km.keymap_items.new('transform.skin_resize', 'A', 'PRESS', ctrl=True)
-
-# Map Manipulators
-km = kc.keymaps.new('Manipulators', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-
-# Map Backdrop Transform Widget
-km = kc.keymaps.new('Backdrop Transform Widget', space_type='NODE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Backdrop Crop Widget
-km = kc.keymaps.new('Backdrop Crop Widget', space_type='NODE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Sun Beams Widget
-km = kc.keymaps.new('Sun Beams Widget', space_type='NODE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Corner Pin Widget
-km = kc.keymaps.new('Corner Pin Widget', space_type='NODE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map UV Transform Manipulator
-km = kc.keymaps.new('UV Transform Manipulator', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Spot Lamp Widgets
-km = kc.keymaps.new('Spot Lamp Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Area Lamp Widgets
-km = kc.keymaps.new('Area Lamp Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Target Lamp Widgets
-km = kc.keymaps.new('Target Lamp Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Force Field Widgets
-km = kc.keymaps.new('Force Field Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Camera Widgets
-km = kc.keymaps.new('Camera Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Camera View Widgets
-km = kc.keymaps.new('Camera View Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Armature Spline Widgets
-km = kc.keymaps.new('Armature Spline Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map View3D Navigate
-km = kc.keymaps.new('View3D Navigate', space_type='VIEW_3D', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True)
-
-# Map Animation Channels
-km = kc.keymaps.new('Animation Channels', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'children_only', True)
-kmi = km.keymap_items.new('anim.channels_rename', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('anim.channels_rename', 'LEFTMOUSE', 'DOUBLE_CLICK')
-kmi = km.keymap_items.new('anim.channel_select_keys', 'LEFTMOUSE', 'DOUBLE_CLICK')
-kmi = km.keymap_items.new('anim.channel_select_keys', 'LEFTMOUSE', 'DOUBLE_CLICK', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('anim.channels_select_all_toggle', 'A', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_select_all_toggle', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'invert', True)
-kmi = km.keymap_items.new('anim.channels_select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_select_border', 'EVT_TWEAK_L', 'ANY')
-kmi = km.keymap_items.new('anim.channels_delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_setting_toggle', 'W', 'PRESS', shift=True)
-kmi = km.keymap_items.new('anim.channels_setting_enable', 'W', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('anim.channels_setting_disable', 'W', 'PRESS', alt=True)
-kmi = km.keymap_items.new('anim.channels_editable_toggle', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_expand', 'NUMPAD_PLUS', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_collapse', 'NUMPAD_MINUS', 'PRESS')
-kmi = km.keymap_items.new('anim.channels_expand', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'all', False)
-kmi = km.keymap_items.new('anim.channels_collapse', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'all', False)
-kmi = km.keymap_items.new('anim.channels_move', 'PAGE_UP', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'UP')
-kmi = km.keymap_items.new('anim.channels_move', 'PAGE_DOWN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'DOWN')
-kmi = km.keymap_items.new('anim.channels_move', 'PAGE_UP', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'TOP')
-kmi = km.keymap_items.new('anim.channels_move', 'PAGE_DOWN', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'BOTTOM')
-kmi = km.keymap_items.new('anim.channels_group', 'G', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('anim.channels_ungroup', 'G', 'PRESS', alt=True)
-
-# Map UV Editor
-km = kc.keymaps.new('UV Editor', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('wm.context_toggle', 'Q', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_uv_sculpt')
-kmi = km.keymap_items.new('uv.mark_seam', 'E', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('uv.select', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('uv.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('uv.select_loop', 'SELECTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('uv.select_loop', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('uv.select_split', 'Y', 'PRESS')
-kmi = km.keymap_items.new('uv.select_border', 'B', 'PRESS')
-kmi_props_setattr(kmi.properties, 'pinned', False)
-kmi = km.keymap_items.new('uv.select_border', 'B', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'pinned', True)
-kmi = km.keymap_items.new('uv.circle_select', 'C', 'PRESS')
-kmi = km.keymap_items.new('uv.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('uv.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('uv.select_linked', 'L', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('uv.select_linked_pick', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('uv.select_linked', 'L', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('uv.select_linked_pick', 'L', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('uv.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('uv.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('uv.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('uv.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('uv.select_pinned', 'P', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'IMAGE_MT_uvs_weldalign')
-kmi = km.keymap_items.new('uv.stitch', 'V', 'PRESS')
-kmi = km.keymap_items.new('uv.pin', 'P', 'PRESS')
-kmi_props_setattr(kmi.properties, 'clear', False)
-kmi = km.keymap_items.new('uv.pin', 'P', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'clear', True)
-kmi = km.keymap_items.new('uv.unwrap', 'E', 'PRESS')
-kmi = km.keymap_items.new('uv.minimize_stretch', 'V', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('uv.pack_islands', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('uv.average_islands_scale', 'A', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('uv.hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('uv.hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('uv.reveal', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('uv.cursor_set', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'IMAGE_MT_uvs_snap')
-kmi = km.keymap_items.new('wm.call_menu', 'TAB', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'name', 'IMAGE_MT_uvs_select_mode')
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit')
-kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED')
-kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED')
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('transform.mirror', 'M', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_snap')
-kmi = km.keymap_items.new('wm.context_menu_enum', 'TAB', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.snap_uv_element')
-
-# Map UV Sculpt
-km = kc.keymaps.new('UV Sculpt', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('wm.context_toggle', 'Q', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_uv_sculpt')
-kmi = km.keymap_items.new('sculpt.uv_sculpt_stroke', 'LEFTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'NORMAL')
-kmi = km.keymap_items.new('sculpt.uv_sculpt_stroke', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'INVERT')
-kmi = km.keymap_items.new('sculpt.uv_sculpt_stroke', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'RELAX')
-kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 0.9)
-kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.uv_sculpt.brush.size')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.uv_sculpt.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.uv_sculpt.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.uv_sculpt.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.uv_sculpt.brush.strength')
-kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength')
-kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength')
-kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.uv_sculpt.brush.texture_slot.angle')
-kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.uv_sculpt.brush.cursor_color_add')
-kmi_props_setattr(kmi.properties, 'fill_color_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_path', '')
-kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '')
-kmi_props_setattr(kmi.properties, 'zoom_path', '')
-kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.uv_sculpt.brush')
-kmi_props_setattr(kmi.properties, 'secondary_tex', False)
-kmi = km.keymap_items.new('brush.uv_sculpt_tool_set', 'S', 'PRESS')
-kmi_props_setattr(kmi.properties, 'tool', 'RELAX')
-kmi = km.keymap_items.new('brush.uv_sculpt_tool_set', 'P', 'PRESS')
-kmi_props_setattr(kmi.properties, 'tool', 'PINCH')
-kmi = km.keymap_items.new('brush.uv_sculpt_tool_set', 'G', 'PRESS')
-kmi_props_setattr(kmi.properties, 'tool', 'GRAB')
-
-# Map Mask Editing
-km = kc.keymaps.new('Mask Editing', space_type='EMPTY', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('mask.new', 'N', 'PRESS', alt=True)
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'MASK_MT_add')
-kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff')
-kmi_props_setattr(kmi.properties, 'wrap', True)
-kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_proportional_edit_mask')
-kmi = km.keymap_items.new('mask.add_vertex_slide', 'ACTIONMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mask.add_feather_vertex_slide', 'ACTIONMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('mask.delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('mask.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('mask.select', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', False)
-kmi = km.keymap_items.new('mask.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('mask.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('mask.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('mask.select_linked', 'L', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mask.select_linked_pick', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('mask.select_linked_pick', 'L', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('mask.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('mask.select_circle', 'C', 'PRESS')
-kmi = km.keymap_items.new('mask.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('mask.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('mask.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mask.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mask.hide_view_clear', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mask.hide_view_set', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('mask.hide_view_set', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('clip.select', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('mask.cyclic_toggle', 'C', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mask.slide_point', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('mask.slide_spline_curvature', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('mask.handle_type_set', 'V', 'PRESS')
-kmi = km.keymap_items.new('mask.normals_make_consistent', 'N', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mask.parent_set', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mask.parent_clear', 'P', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mask.shape_key_insert', 'I', 'PRESS')
-kmi = km.keymap_items.new('mask.shape_key_clear', 'I', 'PRESS', alt=True)
-kmi = km.keymap_items.new('mask.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('mask.copy_splines', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('mask.paste_splines', 'V', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('uv.cursor_set', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'MASK_SHRINKFATTEN')
-
-# Map Graph Editor Generic
-km = kc.keymaps.new('Graph Editor Generic', space_type='GRAPH_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('graph.properties', 'N', 'PRESS')
-kmi = km.keymap_items.new('graph.extrapolation_type', 'E', 'PRESS', shift=True)
-kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('graph.hide', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('graph.hide', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('graph.reveal', 'H', 'PRESS', alt=True)
-
-# Map Graph Editor
-km = kc.keymaps.new('Graph Editor', space_type='GRAPH_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('wm.context_toggle', 'H', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_handles')
-kmi = km.keymap_items.new('graph.cursor_set', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'column', False)
-kmi_props_setattr(kmi.properties, 'curves', False)
-kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'column', True)
-kmi_props_setattr(kmi.properties, 'curves', False)
-kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'column', False)
-kmi_props_setattr(kmi.properties, 'curves', False)
-kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'column', True)
-kmi_props_setattr(kmi.properties, 'curves', False)
-kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'column', False)
-kmi_props_setattr(kmi.properties, 'curves', True)
-kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'column', False)
-kmi_props_setattr(kmi.properties, 'curves', True)
-kmi = km.keymap_items.new('graph.select_leftright', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CHECK')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('graph.select_leftright', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CHECK')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('graph.select_leftright', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'LEFT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('graph.select_leftright', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'RIGHT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('graph.select_all_toggle', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'invert', False)
-kmi = km.keymap_items.new('graph.select_all_toggle', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'invert', True)
-kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS')
-kmi_props_setattr(kmi.properties, 'axis_range', False)
-kmi_props_setattr(kmi.properties, 'include_handles', False)
-kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'axis_range', True)
-kmi_props_setattr(kmi.properties, 'include_handles', False)
-kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'axis_range', False)
-kmi_props_setattr(kmi.properties, 'include_handles', True)
-kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'axis_range', True)
-kmi_props_setattr(kmi.properties, 'include_handles', True)
-kmi = km.keymap_items.new('graph.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('graph.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('graph.select_circle', 'C', 'PRESS')
-kmi = km.keymap_items.new('graph.select_column', 'K', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'KEYS')
-kmi = km.keymap_items.new('graph.select_column', 'K', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CFRA')
-kmi = km.keymap_items.new('graph.select_column', 'K', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'mode', 'MARKERS_COLUMN')
-kmi = km.keymap_items.new('graph.select_column', 'K', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'mode', 'MARKERS_BETWEEN')
-kmi = km.keymap_items.new('graph.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('graph.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('graph.select_linked', 'L', 'PRESS')
-kmi = km.keymap_items.new('graph.frame_jump', 'G', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('graph.snap', 'S', 'PRESS', shift=True)
-kmi = km.keymap_items.new('graph.mirror', 'M', 'PRESS', shift=True)
-kmi = km.keymap_items.new('graph.handle_type', 'V', 'PRESS')
-kmi = km.keymap_items.new('graph.interpolation_type', 'T', 'PRESS')
-kmi = km.keymap_items.new('graph.easing_type', 'E', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('graph.smooth', 'O', 'PRESS', alt=True)
-kmi = km.keymap_items.new('graph.sample', 'O', 'PRESS', shift=True)
-kmi = km.keymap_items.new('graph.bake', 'C', 'PRESS', alt=True)
-kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'GRAPH_MT_delete')
-kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'GRAPH_MT_delete')
-kmi = km.keymap_items.new('graph.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('graph.keyframe_insert', 'I', 'PRESS')
-kmi = km.keymap_items.new('graph.click_insert', 'ACTIONMOUSE', 'CLICK', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('graph.click_insert', 'ACTIONMOUSE', 'CLICK', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('graph.copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('graph.paste', 'V', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('graph.paste', 'V', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'flipped', True)
-if platform == "darwin":
- kmi = km.keymap_items.new('graph.copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('graph.paste', 'V', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('graph.paste', 'V', 'PRESS', shift=True, oskey=True)
- kmi_props_setattr(kmi.properties, 'flipped', True)
-kmi = km.keymap_items.new('graph.previewrange_set', 'P', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('graph.view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('graph.view_all', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('graph.view_selected', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('graph.view_frame', 'NUMPAD_0', 'PRESS')
-kmi = km.keymap_items.new('graph.fmodifier_add', 'M', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'only_active', False)
-kmi = km.keymap_items.new('anim.channels_editable_toggle', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.transform', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_EXTEND')
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_proportional_fcurve')
-kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'BOUNDING_BOX_CENTER')
-kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'CURSOR')
-kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'INDIVIDUAL_ORIGINS')
-kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
-kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True)
-
-# Map Image Generic
-km = kc.keymaps.new('Image Generic', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('image.new', 'N', 'PRESS', alt=True)
-kmi = km.keymap_items.new('image.open', 'O', 'PRESS', alt=True)
-kmi = km.keymap_items.new('image.reload', 'R', 'PRESS', alt=True)
-kmi = km.keymap_items.new('image.read_viewlayers', 'R', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('image.save', 'S', 'PRESS', alt=True)
-kmi = km.keymap_items.new('image.save_as', 'F3', 'PRESS')
-kmi = km.keymap_items.new('image.properties', 'N', 'PRESS')
-kmi = km.keymap_items.new('image.toolshelf', 'T', 'PRESS')
-kmi = km.keymap_items.new('image.cycle_render_slot', 'J', 'PRESS')
-kmi = km.keymap_items.new('image.cycle_render_slot', 'J', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'reverse', True)
-
-# Map Image
-km = kc.keymaps.new('Image', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('image.view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('image.view_all', 'HOME', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'fit_view', True)
-kmi = km.keymap_items.new('image.view_selected', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('image.view_pan', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('image.view_pan', 'MIDDLEMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('image.view_pan', 'TRACKPADPAN', 'ANY')
-kmi = km.keymap_items.new('image.view_all', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('image.view_ndof', 'NDOF_MOTION', 'ANY')
-kmi = km.keymap_items.new('image.view_zoom_in', 'WHEELINMOUSE', 'PRESS')
-kmi = km.keymap_items.new('image.view_zoom_out', 'WHEELOUTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('image.view_zoom_in', 'NUMPAD_PLUS', 'PRESS')
-kmi = km.keymap_items.new('image.view_zoom_out', 'NUMPAD_MINUS', 'PRESS')
-kmi = km.keymap_items.new('image.view_zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('image.view_zoom', 'TRACKPADZOOM', 'ANY')
-kmi = km.keymap_items.new('image.view_zoom', 'TRACKPADPAN', 'ANY', ctrl=True)
-kmi = km.keymap_items.new('image.view_zoom_border', 'B', 'PRESS', shift=True)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_8', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'ratio', 8.0)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_4', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'ratio', 4.0)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_2', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'ratio', 2.0)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_8', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'ratio', 8.0)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_4', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'ratio', 4.0)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_2', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'ratio', 2.0)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_1', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 1.0)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_2', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 0.5)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_4', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 0.25)
-kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_8', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 0.125)
-kmi = km.keymap_items.new('image.change_frame', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('image.sample', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('image.curves_point_set', 'ACTIONMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'point', 'BLACK_POINT')
-kmi = km.keymap_items.new('image.curves_point_set', 'ACTIONMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'point', 'WHITE_POINT')
-kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'EDIT')
-kmi_props_setattr(kmi.properties, 'toggle', True)
-kmi = km.keymap_items.new('wm.context_set_int', 'ONE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index')
-kmi_props_setattr(kmi.properties, 'value', 0)
-kmi = km.keymap_items.new('wm.context_set_int', 'TWO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index')
-kmi_props_setattr(kmi.properties, 'value', 1)
-kmi = km.keymap_items.new('wm.context_set_int', 'THREE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index')
-kmi_props_setattr(kmi.properties, 'value', 2)
-kmi = km.keymap_items.new('wm.context_set_int', 'FOUR', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index')
-kmi_props_setattr(kmi.properties, 'value', 3)
-kmi = km.keymap_items.new('wm.context_set_int', 'FIVE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index')
-kmi_props_setattr(kmi.properties, 'value', 4)
-kmi = km.keymap_items.new('wm.context_set_int', 'SIX', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index')
-kmi_props_setattr(kmi.properties, 'value', 5)
-kmi = km.keymap_items.new('wm.context_set_int', 'SEVEN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index')
-kmi_props_setattr(kmi.properties, 'value', 6)
-kmi = km.keymap_items.new('wm.context_set_int', 'EIGHT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index')
-kmi_props_setattr(kmi.properties, 'value', 7)
-kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'CENTER')
-kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'MEDIAN')
-kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'CURSOR')
-kmi = km.keymap_items.new('image.render_border', 'B', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('image.clear_render_border', 'B', 'PRESS', ctrl=True, alt=True)
-
-# Map Node Generic
-km = kc.keymaps.new('Node Generic', space_type='NODE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('node.properties', 'N', 'PRESS')
-kmi = km.keymap_items.new('node.toolbar', 'T', 'PRESS')
-
-# Map Node Editor
-km = kc.keymaps.new('Node Editor', space_type='NODE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select_border', 'EVT_TWEAK_S', 'ANY')
-kmi_props_setattr(kmi.properties, 'tweak', True)
-kmi = km.keymap_items.new('node.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('node.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('node.select_circle', 'C', 'PRESS')
-kmi = km.keymap_items.new('node.link', 'LEFTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'detach', False)
-kmi = km.keymap_items.new('node.link', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'detach', True)
-kmi = km.keymap_items.new('node.resize', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('node.add_reroute', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('node.links_cut', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.select_link_viewer', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('node.backimage_move', 'MIDDLEMOUSE', 'PRESS', alt=True)
-kmi = km.keymap_items.new('node.backimage_zoom', 'V', 'PRESS')
-kmi_props_setattr(kmi.properties, 'factor', 1.0 / 1.2)
-kmi = km.keymap_items.new('node.backimage_zoom', 'V', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'factor', 1.2)
-kmi = km.keymap_items.new('node.backimage_fit', 'HOME', 'PRESS', alt=True)
-kmi = km.keymap_items.new('node.backimage_sample', 'ACTIONMOUSE', 'PRESS', alt=True)
-kmi = km.keymap_items.new('node.link_make', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'replace', False)
-kmi = km.keymap_items.new('node.link_make', 'F', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'replace', True)
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'NODE_MT_add')
-kmi = km.keymap_items.new('node.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('node.duplicate_move_keep_inputs', 'D', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('node.parent_set', 'P', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.detach', 'P', 'PRESS', alt=True)
-kmi = km.keymap_items.new('node.join', 'J', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.hide_toggle', 'H', 'PRESS')
-kmi = km.keymap_items.new('node.mute_toggle', 'M', 'PRESS')
-kmi = km.keymap_items.new('node.preview_toggle', 'H', 'PRESS', shift=True)
-kmi = km.keymap_items.new('node.hide_socket_toggle', 'H', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('node.view_all', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('node.view_selected', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('node.select_border', 'B', 'PRESS')
-kmi_props_setattr(kmi.properties, 'tweak', False)
-kmi = km.keymap_items.new('node.delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('node.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('node.delete_reconnect', 'X', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('node.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('node.select_linked_to', 'L', 'PRESS', shift=True)
-kmi = km.keymap_items.new('node.select_linked_from', 'L', 'PRESS')
-kmi = km.keymap_items.new('node.select_grouped', 'G', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('node.select_grouped', 'G', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('node.select_same_type_step', 'RIGHT_BRACKET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'prev', False)
-kmi = km.keymap_items.new('node.select_same_type_step', 'LEFT_BRACKET', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'prev', True)
-kmi = km.keymap_items.new('node.find_node', 'F', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.group_make', 'G', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.group_ungroup', 'G', 'PRESS', alt=True)
-kmi = km.keymap_items.new('node.group_separate', 'P', 'PRESS')
-kmi = km.keymap_items.new('node.group_edit', 'TAB', 'PRESS')
-kmi_props_setattr(kmi.properties, 'exit', False)
-kmi = km.keymap_items.new('node.group_edit', 'TAB', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'exit', True)
-kmi = km.keymap_items.new('node.read_viewlayers', 'R', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.render_changed', 'Z', 'PRESS')
-kmi = km.keymap_items.new('node.clipboard_copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.clipboard_paste', 'V', 'PRESS', ctrl=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('node.clipboard_copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('node.clipboard_paste', 'V', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('node.viewer_border', 'B', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.clear_viewer_border', 'B', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('node.translate_attach', 'G', 'PRESS')
-kmi = km.keymap_items.new('node.translate_attach', 'EVT_TWEAK_A', 'ANY')
-kmi = km.keymap_items.new('node.translate_attach', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_A', 'ANY')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi_props_setattr(kmi.properties, 'release_confirm', True)
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-kmi = km.keymap_items.new('node.move_detach_links', 'D', 'PRESS', alt=True)
-kmi = km.keymap_items.new('node.move_detach_links_release', 'EVT_TWEAK_A', 'ANY', alt=True)
-kmi = km.keymap_items.new('node.move_detach_links', 'EVT_TWEAK_S', 'ANY', alt=True)
-kmi = km.keymap_items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_snap')
-kmi = km.keymap_items.new('wm.context_menu_enum', 'TAB', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.snap_node_element')
-
-# Map Info
-km = kc.keymaps.new('Info', space_type='INFO', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('info.select_pick', 'SELECTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('info.select_all_toggle', 'A', 'PRESS')
-kmi = km.keymap_items.new('info.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('info.report_replay', 'R', 'PRESS')
-kmi = km.keymap_items.new('info.report_delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('info.report_delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('info.report_copy', 'C', 'PRESS', ctrl=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('info.report_copy', 'C', 'PRESS', oskey=True)
-
-# Map File Browser
-km = kc.keymaps.new('File Browser', space_type='FILE_BROWSER', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('file.parent', 'UP_ARROW', 'PRESS', alt=True)
-kmi = km.keymap_items.new('file.previous', 'LEFT_ARROW', 'PRESS', alt=True)
-kmi = km.keymap_items.new('file.next', 'RIGHT_ARROW', 'PRESS', alt=True)
-kmi = km.keymap_items.new('file.refresh', 'R', 'PRESS')
-kmi = km.keymap_items.new('file.parent', 'P', 'PRESS')
-kmi = km.keymap_items.new('file.previous', 'BACK_SPACE', 'PRESS')
-kmi = km.keymap_items.new('file.next', 'BACK_SPACE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.context_toggle', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.params.show_hidden')
-kmi = km.keymap_items.new('file.directory_new', 'I', 'PRESS')
-kmi = km.keymap_items.new('file.delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('file.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('file.smoothscroll', 'TIMER1', 'ANY', any=True)
-kmi = km.keymap_items.new('file.bookmark_toggle', 'T', 'PRESS')
-kmi = km.keymap_items.new('file.bookmark_add', 'B', 'PRESS', ctrl=True)
-
-# Map File Browser Main
-km = kc.keymaps.new('File Browser Main', space_type='FILE_BROWSER', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('file.execute', 'LEFTMOUSE', 'DOUBLE_CLICK')
-kmi_props_setattr(kmi.properties, 'need_active', True)
-kmi = km.keymap_items.new('file.refresh', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK')
-kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'fill', True)
-kmi = km.keymap_items.new('file.select', 'RIGHTMOUSE', 'CLICK')
-kmi_props_setattr(kmi.properties, 'open', False)
-kmi = km.keymap_items.new('file.select', 'RIGHTMOUSE', 'CLICK', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'open', False)
-kmi = km.keymap_items.new('file.select', 'RIGHTMOUSE', 'CLICK', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'fill', True)
-kmi_props_setattr(kmi.properties, 'open', False)
-kmi = km.keymap_items.new('file.select_walk', 'UP_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'UP')
-kmi = km.keymap_items.new('file.select_walk', 'UP_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'UP')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('file.select_walk', 'UP_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'direction', 'UP')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'fill', True)
-kmi = km.keymap_items.new('file.select_walk', 'DOWN_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'DOWN')
-kmi = km.keymap_items.new('file.select_walk', 'DOWN_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'DOWN')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('file.select_walk', 'DOWN_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'direction', 'DOWN')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'fill', True)
-kmi = km.keymap_items.new('file.select_walk', 'LEFT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'LEFT')
-kmi = km.keymap_items.new('file.select_walk', 'LEFT_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'LEFT')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('file.select_walk', 'LEFT_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'direction', 'LEFT')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'fill', True)
-kmi = km.keymap_items.new('file.select_walk', 'RIGHT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'direction', 'RIGHT')
-kmi = km.keymap_items.new('file.select_walk', 'RIGHT_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'direction', 'RIGHT')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('file.select_walk', 'RIGHT_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'direction', 'RIGHT')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'fill', True)
-kmi = km.keymap_items.new('file.previous', 'BUTTON4MOUSE', 'CLICK')
-kmi = km.keymap_items.new('file.next', 'BUTTON5MOUSE', 'CLICK')
-kmi = km.keymap_items.new('file.select_all_toggle', 'A', 'PRESS')
-kmi = km.keymap_items.new('file.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('file.select_border', 'EVT_TWEAK_L', 'ANY')
-kmi = km.keymap_items.new('file.rename', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('file.highlight', 'MOUSEMOVE', 'ANY', any=True)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'increment', 1)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'increment', 10)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'increment', 100)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'increment', -1)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'increment', -10)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'increment', -100)
-
-# Map File Browser Buttons
-km = kc.keymaps.new('File Browser Buttons', space_type='FILE_BROWSER', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'increment', 1)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'increment', 10)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'increment', 100)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS')
-kmi_props_setattr(kmi.properties, 'increment', -1)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'increment', -10)
-kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'increment', -100)
-
-# Map NLA Generic
-km = kc.keymaps.new('NLA Generic', space_type='NLA_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('nla.properties', 'N', 'PRESS')
-kmi = km.keymap_items.new('nla.tweakmode_enter', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('nla.tweakmode_exit', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('nla.tweakmode_enter', 'TAB', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'isolate_action', True)
-kmi = km.keymap_items.new('nla.tweakmode_exit', 'TAB', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'isolate_action', True)
-kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True)
-
-# Map NLA Channels
-km = kc.keymaps.new('NLA Channels', space_type='NLA_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('nla.channels_click', 'LEFTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('nla.channels_click', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('nla.tracks_add', 'A', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'above_selected', False)
-kmi = km.keymap_items.new('nla.tracks_add', 'A', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'above_selected', True)
-kmi = km.keymap_items.new('nla.tracks_delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('nla.tracks_delete', 'DEL', 'PRESS')
-
-# Map NLA Editor
-km = kc.keymaps.new('NLA Editor', space_type='NLA_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('nla.click_select', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('nla.click_select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('nla.select_leftright', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CHECK')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('nla.select_leftright', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'mode', 'CHECK')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('nla.select_leftright', 'LEFT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'LEFT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('nla.select_leftright', 'RIGHT_BRACKET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'RIGHT')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('nla.select_all_toggle', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'invert', False)
-kmi = km.keymap_items.new('nla.select_all_toggle', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'invert', True)
-kmi = km.keymap_items.new('nla.select_border', 'B', 'PRESS')
-kmi_props_setattr(kmi.properties, 'axis_range', False)
-kmi = km.keymap_items.new('nla.select_border', 'B', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'axis_range', True)
-kmi = km.keymap_items.new('nla.previewrange_set', 'P', 'PRESS', ctrl=True, alt=True)
-kmi = km.keymap_items.new('nla.view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('nla.view_all', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('nla.view_selected', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('nla.view_frame', 'NUMPAD_0', 'PRESS')
-kmi = km.keymap_items.new('nla.actionclip_add', 'A', 'PRESS', shift=True)
-kmi = km.keymap_items.new('nla.transition_add', 'T', 'PRESS', shift=True)
-kmi = km.keymap_items.new('nla.soundclip_add', 'K', 'PRESS', shift=True)
-kmi = km.keymap_items.new('nla.meta_add', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('nla.meta_remove', 'G', 'PRESS', alt=True)
-kmi = km.keymap_items.new('nla.duplicate', 'D', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'linked', False)
-kmi = km.keymap_items.new('nla.duplicate', 'D', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'linked', True)
-kmi = km.keymap_items.new('nla.make_single_user', 'U', 'PRESS')
-kmi = km.keymap_items.new('nla.delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('nla.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('nla.split', 'Y', 'PRESS')
-kmi = km.keymap_items.new('nla.mute_toggle', 'H', 'PRESS')
-kmi = km.keymap_items.new('nla.swap', 'F', 'PRESS', alt=True)
-kmi = km.keymap_items.new('nla.move_up', 'PAGE_UP', 'PRESS')
-kmi = km.keymap_items.new('nla.move_down', 'PAGE_DOWN', 'PRESS')
-kmi = km.keymap_items.new('nla.apply_scale', 'A', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('nla.clear_scale', 'S', 'PRESS', alt=True)
-kmi = km.keymap_items.new('nla.snap', 'S', 'PRESS', shift=True)
-kmi = km.keymap_items.new('nla.fmodifier_add', 'M', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('transform.transform', 'G', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION')
-kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_S', 'ANY')
-kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION')
-kmi = km.keymap_items.new('transform.transform', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_EXTEND')
-kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_SCALE')
-kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
-kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True)
-
-# Map Text Generic
-km = kc.keymaps.new('Text Generic', space_type='TEXT_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('text.start_find', 'F', 'PRESS', ctrl=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('text.start_find', 'F', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('text.jump', 'J', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.find', 'G', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.replace', 'H', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.properties', 'T', 'PRESS', ctrl=True)
-
-# Map Text
-km = kc.keymaps.new('Text', space_type='TEXT_EDITOR', region_type='WINDOW', modal=False)
-
-if platform == "darwin":
- kmi = km.keymap_items.new('text.move', 'LEFT_ARROW', 'PRESS', oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN')
- kmi = km.keymap_items.new('text.move', 'RIGHT_ARROW', 'PRESS', oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
- kmi = km.keymap_items.new('text.move', 'LEFT_ARROW', 'PRESS', alt=True)
- kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
- kmi = km.keymap_items.new('text.move', 'RIGHT_ARROW', 'PRESS', alt=True)
- kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
- kmi = km.keymap_items.new('text.move', 'UP_ARROW', 'PRESS', oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'FILE_TOP')
- kmi = km.keymap_items.new('text.move', 'DOWN_ARROW', 'PRESS', oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'FILE_BOTTOM')
- kmi = km.keymap_items.new('text.move_select', 'LEFT_ARROW', 'PRESS', shift=True, oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN')
- kmi = km.keymap_items.new('text.move_select', 'RIGHT_ARROW', 'PRESS', shift=True, oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
- kmi = km.keymap_items.new('text.move_select', 'LEFT_ARROW', 'PRESS', shift=True, alt=True)
- kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
- kmi = km.keymap_items.new('text.move_select', 'RIGHT_ARROW', 'PRESS', shift=True, alt=True)
- kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
- kmi = km.keymap_items.new('text.move_select', 'UP_ARROW', 'PRESS', shift=True, oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'FILE_TOP')
- kmi = km.keymap_items.new('text.move_select', 'DOWN_ARROW', 'PRESS', shift=True, oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'FILE_BOTTOM')
- kmi = km.keymap_items.new('text.delete', 'BACK_SPACE', 'PRESS', alt=True)
- kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
- kmi = km.keymap_items.new('text.save', 'S', 'PRESS', alt=True, oskey=True)
- kmi = km.keymap_items.new('text.save_as', 'S', 'PRESS', shift=True, alt=True, oskey=True)
- kmi = km.keymap_items.new('text.cut', 'X', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('text.copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('text.paste', 'V', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('text.find_set_selected', 'E', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('text.select_all', 'A', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('text.select_line', 'A', 'PRESS', shift=True, oskey=True)
-kmi = km.keymap_items.new('wm.context_cycle_int', 'WHEELUPMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size')
-kmi_props_setattr(kmi.properties, 'reverse', False)
-kmi = km.keymap_items.new('wm.context_cycle_int', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size')
-kmi_props_setattr(kmi.properties, 'reverse', True)
-kmi = km.keymap_items.new('wm.context_cycle_int', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size')
-kmi_props_setattr(kmi.properties, 'reverse', False)
-kmi = km.keymap_items.new('wm.context_cycle_int', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size')
-kmi_props_setattr(kmi.properties, 'reverse', True)
-kmi = km.keymap_items.new('text.new', 'N', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.open', 'O', 'PRESS', alt=True)
-kmi = km.keymap_items.new('text.reload', 'R', 'PRESS', alt=True)
-kmi = km.keymap_items.new('text.save', 'S', 'PRESS', alt=True)
-kmi = km.keymap_items.new('text.save_as', 'S', 'PRESS', shift=True, ctrl=True, alt=True)
-kmi = km.keymap_items.new('text.run_script', 'P', 'PRESS', alt=True)
-kmi = km.keymap_items.new('text.cut', 'X', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.paste', 'V', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.cut', 'DEL', 'PRESS', shift=True)
-kmi = km.keymap_items.new('text.copy', 'INSERT', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.paste', 'INSERT', 'PRESS', shift=True)
-kmi = km.keymap_items.new('text.duplicate_line', 'D', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.select_all', 'A', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.select_line', 'A', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('text.select_word', 'LEFTMOUSE', 'DOUBLE_CLICK')
-kmi = km.keymap_items.new('text.move_lines', 'UP_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'direction', 'UP')
-kmi = km.keymap_items.new('text.move_lines', 'DOWN_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'direction', 'DOWN')
-kmi = km.keymap_items.new('text.indent', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('text.unindent', 'TAB', 'PRESS', shift=True)
-kmi = km.keymap_items.new('text.uncomment', 'D', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('text.move', 'HOME', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN')
-kmi = km.keymap_items.new('text.move', 'END', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
-kmi = km.keymap_items.new('text.move', 'E', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
-kmi = km.keymap_items.new('text.move', 'E', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
-kmi = km.keymap_items.new('text.move', 'LEFT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('text.move', 'RIGHT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER')
-kmi = km.keymap_items.new('text.move', 'LEFT_ARROW', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
-kmi = km.keymap_items.new('text.move', 'RIGHT_ARROW', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
-kmi = km.keymap_items.new('text.move', 'UP_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_LINE')
-kmi = km.keymap_items.new('text.move', 'DOWN_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_LINE')
-kmi = km.keymap_items.new('text.move', 'PAGE_UP', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_PAGE')
-kmi = km.keymap_items.new('text.move', 'PAGE_DOWN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_PAGE')
-kmi = km.keymap_items.new('text.move', 'HOME', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'FILE_TOP')
-kmi = km.keymap_items.new('text.move', 'END', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'FILE_BOTTOM')
-kmi = km.keymap_items.new('text.move_select', 'HOME', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN')
-kmi = km.keymap_items.new('text.move_select', 'END', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
-kmi = km.keymap_items.new('text.move_select', 'LEFT_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('text.move_select', 'RIGHT_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER')
-kmi = km.keymap_items.new('text.move_select', 'LEFT_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
-kmi = km.keymap_items.new('text.move_select', 'RIGHT_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
-kmi = km.keymap_items.new('text.move_select', 'UP_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_LINE')
-kmi = km.keymap_items.new('text.move_select', 'DOWN_ARROW', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_LINE')
-kmi = km.keymap_items.new('text.move_select', 'PAGE_UP', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_PAGE')
-kmi = km.keymap_items.new('text.move_select', 'PAGE_DOWN', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_PAGE')
-kmi = km.keymap_items.new('text.move_select', 'HOME', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'FILE_TOP')
-kmi = km.keymap_items.new('text.move_select', 'END', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'FILE_BOTTOM')
-kmi = km.keymap_items.new('text.delete', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER')
-kmi = km.keymap_items.new('text.delete', 'BACK_SPACE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('text.delete', 'BACK_SPACE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('text.delete', 'DEL', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
-kmi = km.keymap_items.new('text.delete', 'BACK_SPACE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
-kmi = km.keymap_items.new('text.overwrite_toggle', 'INSERT', 'PRESS')
-kmi = km.keymap_items.new('text.scroll_bar', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('text.scroll_bar', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('text.scroll', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('text.scroll', 'TRACKPADPAN', 'ANY')
-kmi = km.keymap_items.new('text.selection_set', 'EVT_TWEAK_L', 'ANY')
-kmi = km.keymap_items.new('text.cursor_set', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('text.selection_set', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'select', True)
-kmi = km.keymap_items.new('text.scroll', 'WHEELUPMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'lines', -1)
-kmi = km.keymap_items.new('text.scroll', 'WHEELDOWNMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'lines', 1)
-kmi = km.keymap_items.new('text.line_break', 'RET', 'PRESS')
-kmi = km.keymap_items.new('text.line_break', 'NUMPAD_ENTER', 'PRESS')
-kmi = km.keymap_items.new('wm.call_menu', 'RIGHTMOUSE', 'PRESS', any=True)
-kmi_props_setattr(kmi.properties, 'name', 'TEXT_MT_toolbox')
-kmi = km.keymap_items.new('text.autocomplete', 'SPACE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('text.line_number', 'TEXTINPUT', 'ANY', any=True)
-kmi = km.keymap_items.new('text.insert', 'TEXTINPUT', 'ANY', any=True)
-
-# Map SequencerCommon
-km = kc.keymaps.new('SequencerCommon', space_type='SEQUENCE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('sequencer.properties', 'N', 'PRESS')
-kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'scene.sequence_editor.show_overlay')
-kmi = km.keymap_items.new('sequencer.view_toggle', 'TAB', 'PRESS', ctrl=True)
-
-# Map Sequencer
-km = kc.keymaps.new('Sequencer', space_type='SEQUENCE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('sequencer.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('sequencer.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('sequencer.cut', 'K', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'SOFT')
-kmi = km.keymap_items.new('sequencer.cut', 'K', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'HARD')
-kmi = km.keymap_items.new('sequencer.mute', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('sequencer.mute', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('sequencer.unmute', 'H', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('sequencer.unmute', 'H', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('sequencer.lock', 'L', 'PRESS', shift=True)
-kmi = km.keymap_items.new('sequencer.unlock', 'L', 'PRESS', shift=True, alt=True)
-kmi = km.keymap_items.new('sequencer.reassign_inputs', 'R', 'PRESS')
-kmi = km.keymap_items.new('sequencer.reload', 'R', 'PRESS', alt=True)
-kmi = km.keymap_items.new('sequencer.reload', 'R', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'adjust_length', True)
-kmi = km.keymap_items.new('sequencer.offset_clear', 'O', 'PRESS', alt=True)
-kmi = km.keymap_items.new('sequencer.duplicate_move', 'D', 'PRESS', shift=True)
-kmi = km.keymap_items.new('sequencer.delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('sequencer.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('sequencer.copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('sequencer.paste', 'V', 'PRESS', ctrl=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('sequencer.copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('sequencer.paste', 'V', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('sequencer.images_separate', 'Y', 'PRESS')
-kmi = km.keymap_items.new('sequencer.meta_toggle', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('sequencer.meta_make', 'G', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('sequencer.meta_separate', 'G', 'PRESS', alt=True)
-kmi = km.keymap_items.new('sequencer.view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('sequencer.view_all', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('sequencer.view_selected', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('sequencer.view_frame', 'NUMPAD_0', 'PRESS')
-kmi = km.keymap_items.new('sequencer.strip_jump', 'PAGE_UP', 'PRESS')
-kmi_props_setattr(kmi.properties, 'next', True)
-kmi_props_setattr(kmi.properties, 'center', False)
-kmi = km.keymap_items.new('sequencer.strip_jump', 'PAGE_DOWN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'next', False)
-kmi_props_setattr(kmi.properties, 'center', False)
-kmi = km.keymap_items.new('sequencer.strip_jump', 'PAGE_UP', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'next', True)
-kmi_props_setattr(kmi.properties, 'center', True)
-kmi = km.keymap_items.new('sequencer.strip_jump', 'PAGE_DOWN', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'next', False)
-kmi_props_setattr(kmi.properties, 'center', True)
-kmi = km.keymap_items.new('sequencer.swap', 'LEFT_ARROW', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'side', 'LEFT')
-kmi = km.keymap_items.new('sequencer.swap', 'RIGHT_ARROW', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'side', 'RIGHT')
-kmi = km.keymap_items.new('sequencer.gap_remove', 'BACK_SPACE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'all', False)
-kmi = km.keymap_items.new('sequencer.gap_remove', 'BACK_SPACE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'all', True)
-kmi = km.keymap_items.new('sequencer.gap_insert', 'EQUAL', 'PRESS', shift=True)
-kmi = km.keymap_items.new('sequencer.snap', 'S', 'PRESS', shift=True)
-kmi = km.keymap_items.new('sequencer.swap_inputs', 'S', 'PRESS', alt=True)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'ONE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 1)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'TWO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 2)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'THREE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 3)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'FOUR', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 4)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'FIVE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 5)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'SIX', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 6)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'SEVEN', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 7)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'EIGHT', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 8)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'NINE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 9)
-kmi = km.keymap_items.new('sequencer.cut_multicam', 'ZERO', 'PRESS')
-kmi_props_setattr(kmi.properties, 'camera', 10)
-kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'linked_handle', False)
-kmi_props_setattr(kmi.properties, 'left_right', 'NONE')
-kmi_props_setattr(kmi.properties, 'linked_time', False)
-kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'linked_handle', False)
-kmi_props_setattr(kmi.properties, 'left_right', 'NONE')
-kmi_props_setattr(kmi.properties, 'linked_time', False)
-kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'linked_handle', True)
-kmi_props_setattr(kmi.properties, 'left_right', 'NONE')
-kmi_props_setattr(kmi.properties, 'linked_time', False)
-kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'linked_handle', True)
-kmi_props_setattr(kmi.properties, 'left_right', 'NONE')
-kmi_props_setattr(kmi.properties, 'linked_time', False)
-kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi_props_setattr(kmi.properties, 'linked_handle', False)
-kmi_props_setattr(kmi.properties, 'left_right', 'MOUSE')
-kmi_props_setattr(kmi.properties, 'linked_time', True)
-kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi_props_setattr(kmi.properties, 'linked_handle', False)
-kmi_props_setattr(kmi.properties, 'left_right', 'NONE')
-kmi_props_setattr(kmi.properties, 'linked_time', True)
-kmi = km.keymap_items.new('sequencer.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('sequencer.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('sequencer.select_linked_pick', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('sequencer.select_linked_pick', 'L', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('sequencer.select_linked', 'L', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('sequencer.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('sequencer.select_grouped', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'SEQUENCER_MT_add')
-kmi = km.keymap_items.new('wm.call_menu', 'C', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'SEQUENCER_MT_change')
-kmi = km.keymap_items.new('sequencer.slip', 'S', 'PRESS')
-kmi = km.keymap_items.new('wm.context_set_int', 'O', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'scene.sequence_editor.overlay_frame')
-kmi_props_setattr(kmi.properties, 'value', 0)
-kmi = km.keymap_items.new('transform.seq_slide', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.seq_slide', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.transform', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'mode', 'TIME_EXTEND')
-kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
-kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True)
-
-# Map SequencerPreview
-km = kc.keymaps.new('SequencerPreview', space_type='SEQUENCE_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('sequencer.view_all_preview', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('sequencer.view_all_preview', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('sequencer.view_ghost_border', 'O', 'PRESS')
-kmi = km.keymap_items.new('sequencer.view_zoom_ratio', 'NUMPAD_1', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 1.0)
-kmi = km.keymap_items.new('sequencer.sample', 'ACTIONMOUSE', 'PRESS')
-
-# Map Console
-km = kc.keymaps.new('Console', space_type='CONSOLE', region_type='WINDOW', modal=False)
-
-if platform == "darwin":
- kmi = km.keymap_items.new('console.move', 'LEFT_ARROW', 'PRESS', oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN')
- kmi = km.keymap_items.new('console.move', 'RIGHT_ARROW', 'PRESS', oskey=True)
- kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
-kmi = km.keymap_items.new('console.move', 'LEFT_ARROW', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
-kmi = km.keymap_items.new('console.move', 'RIGHT_ARROW', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
-kmi = km.keymap_items.new('console.move', 'HOME', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN')
-kmi = km.keymap_items.new('console.move', 'END', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'LINE_END')
-kmi = km.keymap_items.new('wm.context_cycle_int', 'WHEELUPMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size')
-kmi_props_setattr(kmi.properties, 'reverse', False)
-kmi = km.keymap_items.new('wm.context_cycle_int', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size')
-kmi_props_setattr(kmi.properties, 'reverse', True)
-kmi = km.keymap_items.new('wm.context_cycle_int', 'NUMPAD_PLUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size')
-kmi_props_setattr(kmi.properties, 'reverse', False)
-kmi = km.keymap_items.new('wm.context_cycle_int', 'NUMPAD_MINUS', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size')
-kmi_props_setattr(kmi.properties, 'reverse', True)
-kmi = km.keymap_items.new('console.move', 'LEFT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('console.move', 'RIGHT_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER')
-kmi = km.keymap_items.new('console.history_cycle', 'UP_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'reverse', True)
-kmi = km.keymap_items.new('console.history_cycle', 'DOWN_ARROW', 'PRESS')
-kmi_props_setattr(kmi.properties, 'reverse', False)
-kmi = km.keymap_items.new('console.delete', 'DEL', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER')
-kmi = km.keymap_items.new('console.delete', 'BACK_SPACE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('console.delete', 'BACK_SPACE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER')
-kmi = km.keymap_items.new('console.delete', 'DEL', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD')
-kmi = km.keymap_items.new('console.delete', 'BACK_SPACE', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD')
-kmi = km.keymap_items.new('console.clear_line', 'RET', 'PRESS', shift=True)
-kmi = km.keymap_items.new('console.clear_line', 'NUMPAD_ENTER', 'PRESS', shift=True)
-kmi = km.keymap_items.new('console.execute', 'RET', 'PRESS')
-kmi_props_setattr(kmi.properties, 'interactive', True)
-kmi = km.keymap_items.new('console.execute', 'NUMPAD_ENTER', 'PRESS')
-kmi_props_setattr(kmi.properties, 'interactive', True)
-kmi = km.keymap_items.new('console.autocomplete', 'SPACE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('console.copy_as_script', 'C', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('console.copy', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('console.paste', 'V', 'PRESS', ctrl=True)
-if platform == "darwin":
- kmi = km.keymap_items.new('console.copy', 'C', 'PRESS', oskey=True)
- kmi = km.keymap_items.new('console.paste', 'V', 'PRESS', oskey=True)
-kmi = km.keymap_items.new('console.select_set', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('console.select_word', 'LEFTMOUSE', 'DOUBLE_CLICK')
-kmi = km.keymap_items.new('console.insert', 'TAB', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'text', '\t')
-kmi = km.keymap_items.new('console.indent', 'TAB', 'PRESS')
-kmi = km.keymap_items.new('console.unindent', 'TAB', 'PRESS', shift=True)
-kmi = km.keymap_items.new('console.insert', 'TEXTINPUT', 'ANY', any=True)
-
-# Map Clip
-km = kc.keymaps.new('Clip', space_type='CLIP_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('clip.open', 'O', 'PRESS', alt=True)
-kmi = km.keymap_items.new('clip.tools', 'T', 'PRESS')
-kmi = km.keymap_items.new('clip.properties', 'N', 'PRESS')
-kmi = km.keymap_items.new('clip.track_markers', 'LEFT_ARROW', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'backwards', True)
-kmi_props_setattr(kmi.properties, 'sequence', False)
-kmi = km.keymap_items.new('clip.track_markers', 'RIGHT_ARROW', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'backwards', False)
-kmi_props_setattr(kmi.properties, 'sequence', False)
-kmi = km.keymap_items.new('clip.track_markers', 'T', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'backwards', False)
-kmi_props_setattr(kmi.properties, 'sequence', True)
-kmi = km.keymap_items.new('clip.track_markers', 'T', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'backwards', True)
-kmi_props_setattr(kmi.properties, 'sequence', True)
-kmi = km.keymap_items.new('wm.context_toggle_enum', 'TAB', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.mode')
-kmi_props_setattr(kmi.properties, 'value_1', 'TRACKING')
-kmi_props_setattr(kmi.properties, 'value_2', 'MASK')
-kmi = km.keymap_items.new('clip.solve_camera', 'S', 'PRESS', shift=True)
-kmi = km.keymap_items.new('clip.set_solver_keyframe', 'Q', 'PRESS')
-kmi_props_setattr(kmi.properties, 'keyframe', 'KEYFRAME_A')
-kmi = km.keymap_items.new('clip.set_solver_keyframe', 'E', 'PRESS')
-kmi_props_setattr(kmi.properties, 'keyframe', 'KEYFRAME_B')
-kmi = km.keymap_items.new('clip.prefetch', 'P', 'PRESS')
-
-# Map Clip Editor
-km = kc.keymaps.new('Clip Editor', space_type='CLIP_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('clip.view_pan', 'MIDDLEMOUSE', 'PRESS')
-kmi = km.keymap_items.new('clip.view_pan', 'MIDDLEMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('clip.view_pan', 'TRACKPADPAN', 'ANY')
-kmi = km.keymap_items.new('clip.view_zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('clip.view_zoom', 'TRACKPADZOOM', 'ANY')
-kmi = km.keymap_items.new('clip.view_zoom', 'TRACKPADPAN', 'ANY', ctrl=True)
-kmi = km.keymap_items.new('clip.view_zoom_in', 'WHEELINMOUSE', 'PRESS')
-kmi = km.keymap_items.new('clip.view_zoom_out', 'WHEELOUTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('clip.view_zoom_in', 'NUMPAD_PLUS', 'PRESS')
-kmi = km.keymap_items.new('clip.view_zoom_out', 'NUMPAD_MINUS', 'PRESS')
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_8', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'ratio', 8.0)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_4', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'ratio', 4.0)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_2', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'ratio', 2.0)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_8', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'ratio', 8.0)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_4', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'ratio', 4.0)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_2', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'ratio', 2.0)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_1', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 1.0)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_2', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 0.5)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_4', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 0.25)
-kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_8', 'PRESS')
-kmi_props_setattr(kmi.properties, 'ratio', 0.125)
-kmi = km.keymap_items.new('clip.view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('clip.view_all', 'F', 'PRESS')
-kmi_props_setattr(kmi.properties, 'fit_view', True)
-kmi = km.keymap_items.new('clip.view_selected', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('clip.view_all', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('clip.view_ndof', 'NDOF_MOTION', 'ANY')
-kmi = km.keymap_items.new('clip.frame_jump', 'LEFT_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'position', 'PATHSTART')
-kmi = km.keymap_items.new('clip.frame_jump', 'RIGHT_ARROW', 'PRESS', shift=True, ctrl=True)
-kmi_props_setattr(kmi.properties, 'position', 'PATHEND')
-kmi = km.keymap_items.new('clip.frame_jump', 'LEFT_ARROW', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'position', 'FAILEDPREV')
-kmi = km.keymap_items.new('clip.frame_jump', 'RIGHT_ARROW', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'position', 'PATHSTART')
-kmi = km.keymap_items.new('clip.change_frame', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('clip.select', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('clip.select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('clip.select_all', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('clip.select_all', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('clip.select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('clip.select_circle', 'C', 'PRESS')
-kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'name', 'CLIP_MT_select_grouped')
-kmi = km.keymap_items.new('clip.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'deselect', False)
-kmi = km.keymap_items.new('clip.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True, alt=True)
-kmi_props_setattr(kmi.properties, 'deselect', True)
-kmi = km.keymap_items.new('clip.add_marker_slide', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('clip.delete_marker', 'DEL', 'PRESS', shift=True)
-kmi = km.keymap_items.new('clip.delete_marker', 'X', 'PRESS', shift=True)
-kmi = km.keymap_items.new('clip.slide_marker', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('clip.disable_markers', 'D', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('clip.delete_track', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('clip.delete_track', 'X', 'PRESS')
-kmi = km.keymap_items.new('clip.lock_tracks', 'L', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'LOCK')
-kmi = km.keymap_items.new('clip.lock_tracks', 'L', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'action', 'UNLOCK')
-kmi = km.keymap_items.new('clip.hide_tracks', 'H', 'PRESS')
-kmi_props_setattr(kmi.properties, 'unselected', False)
-kmi = km.keymap_items.new('clip.hide_tracks', 'H', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'unselected', True)
-kmi = km.keymap_items.new('clip.hide_tracks_clear', 'H', 'PRESS', alt=True)
-kmi = km.keymap_items.new('clip.slide_plane_marker', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('clip.keyframe_insert', 'I', 'PRESS')
-kmi = km.keymap_items.new('clip.keyframe_delete', 'I', 'PRESS', alt=True)
-kmi = km.keymap_items.new('clip.join_tracks', 'J', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS')
-kmi_props_setattr(kmi.properties, 'name', 'CLIP_MT_tracking_specials')
-kmi = km.keymap_items.new('wm.context_toggle', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.lock_selection')
-kmi = km.keymap_items.new('wm.context_toggle', 'D', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_disabled')
-kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_marker_search')
-kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.use_mute_footage')
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'action', 'REMAINED')
-kmi_props_setattr(kmi.properties, 'clear_active', False)
-kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'action', 'UPTO')
-kmi_props_setattr(kmi.properties, 'clear_active', False)
-kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'action', 'ALL')
-kmi_props_setattr(kmi.properties, 'clear_active', False)
-kmi = km.keymap_items.new('clip.cursor_set', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'BOUNDING_BOX_CENTER')
-kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'MEDIAN_POINT')
-kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'CURSOR')
-kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point')
-kmi_props_setattr(kmi.properties, 'value', 'INDIVIDUAL_ORIGINS')
-kmi = km.keymap_items.new('clip.copy_tracks', 'C', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('clip.paste_tracks', 'V', 'PRESS', ctrl=True)
-
-# Map Clip Graph Editor
-km = kc.keymaps.new('Clip Graph Editor', space_type='CLIP_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('clip.change_frame', 'ACTIONMOUSE', 'PRESS')
-kmi = km.keymap_items.new('clip.graph_select', 'SELECTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', False)
-kmi = km.keymap_items.new('clip.graph_select', 'SELECTMOUSE', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('clip.graph_select_all_markers', 'A', 'PRESS')
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('clip.graph_select_all_markers', 'I', 'PRESS', ctrl=True)
-kmi_props_setattr(kmi.properties, 'action', 'INVERT')
-kmi = km.keymap_items.new('clip.graph_select_border', 'B', 'PRESS')
-kmi = km.keymap_items.new('clip.graph_delete_curve', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('clip.graph_delete_curve', 'X', 'PRESS')
-kmi = km.keymap_items.new('clip.graph_delete_knot', 'DEL', 'PRESS', shift=True)
-kmi = km.keymap_items.new('clip.graph_delete_knot', 'X', 'PRESS', shift=True)
-kmi = km.keymap_items.new('clip.graph_view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('clip.graph_view_all', 'NDOF_BUTTON_FIT', 'PRESS')
-kmi = km.keymap_items.new('clip.graph_center_current_frame', 'NUMPAD_PERIOD', 'PRESS')
-kmi = km.keymap_items.new('wm.context_toggle', 'L', 'PRESS')
-kmi_props_setattr(kmi.properties, 'data_path', 'space_data.lock_time_cursor')
-kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', alt=True)
-kmi_props_setattr(kmi.properties, 'action', 'REMAINED')
-kmi_props_setattr(kmi.properties, 'clear_active', True)
-kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'action', 'UPTO')
-kmi_props_setattr(kmi.properties, 'clear_active', True)
-kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', shift=True, alt=True)
-kmi_props_setattr(kmi.properties, 'action', 'ALL')
-kmi_props_setattr(kmi.properties, 'clear_active', True)
-kmi = km.keymap_items.new('clip.graph_disable_markers', 'D', 'PRESS', shift=True)
-kmi_props_setattr(kmi.properties, 'action', 'TOGGLE')
-kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS')
-kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
-kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS')
-kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS')
-
-# Map Clip Dopesheet Editor
-km = kc.keymaps.new('Clip Dopesheet Editor', space_type='CLIP_EDITOR', region_type='WINDOW', modal=False)
-
-kmi = km.keymap_items.new('clip.dopesheet_select_channel', 'LEFTMOUSE', 'PRESS')
-kmi_props_setattr(kmi.properties, 'extend', True)
-kmi = km.keymap_items.new('clip.dopesheet_view_all', 'HOME', 'PRESS')
-kmi = km.keymap_items.new('clip.dopesheet_view_all', 'NDOF_BUTTON_FIT', 'PRESS')
+keyconfig_data = \
+[("Window",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("wm.window_new", {"type": 'W', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("wm.read_homefile", {"type": 'N', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.save_homefile", {"type": 'U', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'O', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("name", 'INFO_MT_file_open_recent'),
+ ],
+ },
+ ),
+ ("wm.open_mainfile", {"type": 'O', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.open_mainfile", {"type": 'F1', "value": 'PRESS'}, None),
+ ("wm.link", {"type": 'O', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("wm.append", {"type": 'F1', "value": 'PRESS', "shift": True}, None),
+ ("wm.save_mainfile", {"type": 'S', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.save_mainfile", {"type": 'W', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.save_as_mainfile", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("wm.save_as_mainfile", {"type": 'F2', "value": 'PRESS'}, None),
+ ("wm.save_as_mainfile",
+ {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("copy", True),
+ ],
+ },
+ ),
+ ("wm.window_fullscreen_toggle", {"type": 'F11', "value": 'PRESS', "alt": True}, None),
+ ("wm.quit_blender", {"type": 'Q', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.doc_view_manual_ui_context", {"type": 'F1', "value": 'PRESS', "alt": True}, None),
+ ("wm.redraw_timer", {"type": 'T', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("wm.debug_menu", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("wm.call_menu",
+ {"type": 'NDOF_BUTTON_MENU', "value": 'PRESS'},
+ {"properties":
+ [("name", 'USERPREF_MT_ndof_settings'),
+ ],
+ },
+ ),
+ ("wm.search_menu", {"type": 'SPACE', "value": 'PRESS'}, None),
+ ("wm.context_set_enum",
+ {"type": 'F3', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'NODE_EDITOR'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F4', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'CONSOLE'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F5', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'VIEW_3D'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F6', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'GRAPH_EDITOR'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F7', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'PROPERTIES'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F8', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'SEQUENCE_EDITOR'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F9', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'OUTLINER'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F10', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'IMAGE_EDITOR'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F11', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'TEXT_EDITOR'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'F12', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'area.type'),
+ ("value", 'DOPESHEET_EDITOR'),
+ ],
+ },
+ ),
+ ("wm.context_scale_float",
+ {"type": 'NDOF_BUTTON_PLUS', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'user_preferences.inputs.ndof_sensitivity'),
+ ("value", 1.1),
+ ],
+ },
+ ),
+ ("wm.context_scale_float",
+ {"type": 'NDOF_BUTTON_MINUS', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'user_preferences.inputs.ndof_sensitivity'),
+ ("value", 1.0),
+ ],
+ },
+ ),
+ ("wm.context_scale_float",
+ {"type": 'NDOF_BUTTON_PLUS', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'user_preferences.inputs.ndof_sensitivity'),
+ ("value", 1.5),
+ ],
+ },
+ ),
+ ("wm.context_scale_float",
+ {"type": 'NDOF_BUTTON_MINUS', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'user_preferences.inputs.ndof_sensitivity'),
+ ("value", 0.6666667),
+ ],
+ },
+ ),
+ ("info.reports_display_update", {"type": 'TIMER_REPORT', "value": 'ANY', "any": True}, None),
+ ],
+ },
+ ),
+ ("Screen",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("screen.animation_step", {"type": 'TIMER0', "value": 'ANY', "any": True}, None),
+ ("screen.region_blend", {"type": 'TIMERREGION', "value": 'ANY', "any": True}, None),
+ ("screen.screen_set",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("screen.screen_set",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("screen.screen_full_area", {"type": 'SPACE', "value": 'PRESS', "shift": True}, None),
+ ("screen.screen_full_area",
+ {"type": 'SPACE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("use_hide_panels", True),
+ ],
+ },
+ ),
+ ("screen.screenshot", {"type": 'F3', "value": 'PRESS', "ctrl": True}, None),
+ ("screen.screencast", {"type": 'F3', "value": 'PRESS', "alt": True}, None),
+ ("screen.space_context_cycle",
+ {"type": 'TAB', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("direction", 'NEXT'),
+ ],
+ },
+ ),
+ ("screen.space_context_cycle",
+ {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("direction", 'PREV'),
+ ],
+ },
+ ),
+ ("screen.region_quadview", {"type": 'Q', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("screen.repeat_history", {"type": 'F3', "value": 'PRESS'}, None),
+ ("screen.repeat_last", {"type": 'R', "value": 'PRESS', "shift": True}, None),
+ ("screen.region_flip", {"type": 'F5', "value": 'PRESS'}, None),
+ ("screen.redo_last", {"type": 'F6', "value": 'PRESS'}, None),
+ ("script.reload", {"type": 'F8', "value": 'PRESS'}, None),
+ ("file.execute", {"type": 'RET', "value": 'PRESS'}, None),
+ ("file.execute", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None),
+ ("file.cancel", {"type": 'ESC', "value": 'PRESS'}, None),
+ ("ed.undo", {"type": 'Z', "value": 'PRESS', "ctrl": True}, None),
+ ("ed.redo", {"type": 'Z', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("ed.undo_history", {"type": 'Z', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("render.render",
+ {"type": 'F12', "value": 'PRESS'},
+ {"properties":
+ [("use_viewport", True),
+ ],
+ },
+ ),
+ ("render.render",
+ {"type": 'F12', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("animation", True),
+ ("use_viewport", True),
+ ],
+ },
+ ),
+ ("render.view_cancel", {"type": 'ESC', "value": 'PRESS'}, None),
+ ("render.view_show", {"type": 'F11', "value": 'PRESS'}, None),
+ ("render.play_rendered_anim", {"type": 'F11', "value": 'PRESS', "ctrl": True}, None),
+ ("screen.userpref_show", {"type": 'U', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ],
+ },
+ ),
+ ("User Interface",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("ui.eyedropper_color", {"type": 'E', "value": 'PRESS'}, None),
+ ("ui.eyedropper_colorband", {"type": 'E', "value": 'PRESS'}, None),
+ ("ui.eyedropper_colorband_point", {"type": 'E', "value": 'PRESS', "alt": True}, None),
+ ("ui.eyedropper_id", {"type": 'E', "value": 'PRESS'}, None),
+ ("ui.eyedropper_depth", {"type": 'E', "value": 'PRESS'}, None),
+ ("ui.copy_data_path_button", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("ui.copy_data_path_button",
+ {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("full_path", True),
+ ],
+ },
+ ),
+ ("anim.keyframe_insert_button", {"type": 'I', "value": 'PRESS'}, None),
+ ("anim.keyframe_delete_button", {"type": 'I', "value": 'PRESS', "alt": True}, None),
+ ("anim.keyframe_clear_button", {"type": 'I', "value": 'PRESS', "shift": True, "alt": True}, None),
+ ("anim.driver_button_add", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
+ ("anim.driver_button_remove", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("anim.keyingset_button_add", {"type": 'K', "value": 'PRESS'}, None),
+ ("anim.keyingset_button_remove", {"type": 'K', "value": 'PRESS', "alt": True}, None),
+ ],
+ },
+ ),
+ ("View2D",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("view2d.scroller_activate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("view2d.scroller_activate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("view2d.pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
+ ("view2d.scroll_right", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("view2d.scroll_left", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("view2d.ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None),
+ ("view2d.zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None),
+ ("view2d.zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None),
+ ("view2d.zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None),
+ ("view2d.zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None),
+ ("view2d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None),
+ ("view2d.smoothview", {"type": 'TIMER1', "value": 'ANY', "any": True}, None),
+ ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None),
+ ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None),
+ ("view2d.scroll_right", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None),
+ ("view2d.scroll_left", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None),
+ ("view2d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("view2d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None),
+ ("view2d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None),
+ ],
+ },
+ ),
+ ("Header",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("screen.header_toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("View2D Buttons List",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("view2d.scroller_activate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("view2d.scroller_activate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("view2d.pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
+ ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None),
+ ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None),
+ ("view2d.scroll_down",
+ {"type": 'PAGE_DOWN', "value": 'PRESS'},
+ {"properties":
+ [("page", True),
+ ],
+ },
+ ),
+ ("view2d.scroll_up",
+ {"type": 'PAGE_UP', "value": 'PRESS'},
+ {"properties":
+ [("page", True),
+ ],
+ },
+ ),
+ ("view2d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("view2d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None),
+ ("view2d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None),
+ ("view2d.zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None),
+ ("view2d.zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None),
+ ("view2d.reset", {"type": 'HOME', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Frames",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("screen.frame_offset",
+ {"type": 'UP_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("delta", 10),
+ ],
+ },
+ ),
+ ("screen.frame_offset",
+ {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("delta", -10),
+ ],
+ },
+ ),
+ ("screen.frame_offset",
+ {"type": 'LEFT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("screen.frame_offset",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("screen.frame_offset",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("screen.frame_offset",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("screen.frame_jump",
+ {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("end", True),
+ ],
+ },
+ ),
+ ("screen.frame_jump",
+ {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("end", False),
+ ],
+ },
+ ),
+ ("screen.frame_jump",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("end", True),
+ ],
+ },
+ ),
+ ("screen.frame_jump",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("end", False),
+ ],
+ },
+ ),
+ ("screen.keyframe_jump",
+ {"type": 'UP_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("next", True),
+ ],
+ },
+ ),
+ ("screen.keyframe_jump",
+ {"type": 'DOWN_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("next", False),
+ ],
+ },
+ ),
+ ("screen.keyframe_jump",
+ {"type": 'MEDIA_LAST', "value": 'PRESS'},
+ {"properties":
+ [("next", True),
+ ],
+ },
+ ),
+ ("screen.keyframe_jump",
+ {"type": 'MEDIA_FIRST', "value": 'PRESS'},
+ {"properties":
+ [("next", False),
+ ],
+ },
+ ),
+ ("screen.animation_play", {"type": 'A', "value": 'PRESS', "alt": True}, None),
+ ("screen.animation_play",
+ {"type": 'A', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("reverse", True),
+ ],
+ },
+ ),
+ ("screen.animation_cancel", {"type": 'ESC', "value": 'PRESS'}, None),
+ ("screen.animation_play", {"type": 'MEDIA_PLAY', "value": 'PRESS'}, None),
+ ("screen.animation_cancel", {"type": 'MEDIA_STOP', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Property Editor",
+ {"space_type": 'PROPERTIES', "region_type": 'WINDOW'},
+ {"items":
+ [("buttons.toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Info",
+ {"space_type": 'INFO', "region_type": 'WINDOW'},
+ {"items":
+ [("info.select_pick", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None),
+ ("info.select_all_toggle", {"type": 'A', "value": 'PRESS'}, None),
+ ("info.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("info.report_replay", {"type": 'R', "value": 'PRESS'}, None),
+ ("info.report_delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("Outliner",
+ {"space_type": 'OUTLINER', "region_type": 'WINDOW'},
+ {"items":
+ [("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None),
+ ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
+ ("outliner.item_activate",
+ {"type": 'LEFTMOUSE', "value": 'CLICK'},
+ {"properties":
+ [("extend", False),
+ ("recursive", False),
+ ],
+ },
+ ),
+ ("outliner.item_activate",
+ {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
+ {"properties":
+ [("extend", True),
+ ("recursive", False),
+ ],
+ },
+ ),
+ ("outliner.item_activate",
+ {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ("recursive", True),
+ ],
+ },
+ ),
+ ("outliner.item_activate",
+ {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ("recursive", True),
+ ],
+ },
+ ),
+ ("outliner.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("outliner.item_openclose",
+ {"type": 'RET', "value": 'PRESS'},
+ {"properties":
+ [("all", False),
+ ],
+ },
+ ),
+ ("outliner.item_openclose",
+ {"type": 'RET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("all", True),
+ ],
+ },
+ ),
+ ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("outliner.operation", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None),
+ ("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+ ("outliner.show_hierarchy", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("outliner.show_active", {"type": 'PERIOD', "value": 'PRESS'}, None),
+ ("outliner.show_active", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("outliner.scroll_page",
+ {"type": 'PAGE_DOWN', "value": 'PRESS'},
+ {"properties":
+ [("up", False),
+ ],
+ },
+ ),
+ ("outliner.scroll_page",
+ {"type": 'PAGE_UP', "value": 'PRESS'},
+ {"properties":
+ [("up", True),
+ ],
+ },
+ ),
+ ("outliner.show_one_level", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None),
+ ("outliner.show_one_level",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS'},
+ {"properties":
+ [("open", False),
+ ],
+ },
+ ),
+ ("outliner.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("outliner.expanded_toggle", {"type": 'A', "value": 'PRESS', "shift": True}, None),
+ ("outliner.keyingset_add_selected", {"type": 'K', "value": 'PRESS'}, None),
+ ("outliner.keyingset_remove_selected", {"type": 'K', "value": 'PRESS', "alt": True}, None),
+ ("anim.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None),
+ ("anim.keyframe_delete", {"type": 'I', "value": 'PRESS', "alt": True}, None),
+ ("outliner.drivers_add_selected", {"type": 'D', "value": 'PRESS'}, None),
+ ("outliner.drivers_delete_selected", {"type": 'D', "value": 'PRESS', "alt": True}, None),
+ ("outliner.collection_new", {"type": 'C', "value": 'PRESS'}, None),
+ ("outliner.collection_delete", {"type": 'X', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("3D View Generic",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("view3d.properties", {"type": 'N', "value": 'PRESS'}, None),
+ ("view3d.toolshelf", {"type": 'T', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Grease Pencil",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("gpencil.draw",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "key_modifier": 'D'},
+ {"properties":
+ [("mode", 'DRAW'),
+ ("wait_for_input", False),
+ ],
+ },
+ ),
+ ("gpencil.draw",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'D'},
+ {"properties":
+ [("mode", 'DRAW_STRAIGHT'),
+ ("wait_for_input", False),
+ ],
+ },
+ ),
+ ("gpencil.draw",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'D'},
+ {"properties":
+ [("mode", 'DRAW_POLY'),
+ ("wait_for_input", False),
+ ],
+ },
+ ),
+ ("gpencil.draw",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "key_modifier": 'D'},
+ {"properties":
+ [("mode", 'ERASER'),
+ ("wait_for_input", False),
+ ],
+ },
+ ),
+ ("gpencil.draw",
+ {"type": 'ERASER', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'ERASER'),
+ ("wait_for_input", False),
+ ],
+ },
+ ),
+ ("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS', "key_modifier": 'D'}, None),
+ ("wm.call_menu_pie",
+ {"type": 'Q', "value": 'PRESS', "key_modifier": 'D'},
+ {"properties":
+ [("name", 'GPENCIL_MT_pie_tool_palette'),
+ ],
+ },
+ ),
+ ("wm.call_menu_pie",
+ {"type": 'W', "value": 'PRESS', "key_modifier": 'D'},
+ {"properties":
+ [("name", 'GPENCIL_MT_pie_settings_palette'),
+ ],
+ },
+ ),
+ ("gpencil.blank_frame_add", {"type": 'B', "value": 'PRESS', "key_modifier": 'D'}, None),
+ ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "key_modifier": 'D'}, None),
+ ],
+ },
+ ),
+ ("Grease Pencil Stroke Edit Mode",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("wm.call_menu_pie",
+ {"type": 'E', "value": 'PRESS', "key_modifier": 'D'},
+ {"properties":
+ [("name", 'GPENCIL_MT_pie_sculpt'),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path_primary", 'user_preferences.edit.grease_pencil_eraser_radius'),
+ ],
+ },
+ ),
+ ("gpencil.interpolate", {"type": 'E', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("gpencil.interpolate_sequence", {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("gpencil.brush_paint",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "key_modifier": 'E'},
+ {"properties":
+ [("wait_for_input", False),
+ ],
+ },
+ ),
+ ("gpencil.brush_paint",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'E'},
+ {"properties":
+ [("wait_for_input", False),
+ ],
+ },
+ ),
+ ("gpencil.brush_paint",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "key_modifier": 'E'},
+ {"properties":
+ [("wait_for_input", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.strength'),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.size'),
+ ],
+ },
+ ),
+ ("gpencil.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("gpencil.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("gpencil.select_circle", {"type": 'C', "value": 'PRESS'}, None),
+ ("gpencil.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("gpencil.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("gpencil.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("gpencil.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("gpencil.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("gpencil.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None),
+ ("gpencil.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("gpencil.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("entire_strokes", True),
+ ],
+ },
+ ),
+ ("gpencil.select_linked", {"type": 'L', "value": 'PRESS'}, None),
+ ("gpencil.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None),
+ ("gpencil.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("wm.call_menu",
+ {"type": 'X', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_gpencil_delete'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_gpencil_delete'),
+ ],
+ },
+ ),
+ ("gpencil.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.dissolve", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "shift": True}, None),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'GPENCIL_MT_gpencil_edit_specials'),
+ ],
+ },
+ ),
+ ("gpencil.stroke_join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.stroke_join",
+ {"type": 'J', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'JOINCOPY'),
+ ],
+ },
+ ),
+ ("gpencil.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'S', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'GPENCIL_MT_snap'),
+ ],
+ },
+ ),
+ ("gpencil.convert", {"type": 'C', "value": 'PRESS', "alt": True}, None),
+ ("gpencil.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("gpencil.hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("gpencil.hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("gpencil.selection_opacity_toggle", {"type": 'H', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.layer_isolate", {"type": 'NUMPAD_ASTERIX', "value": 'PRESS'}, None),
+ ("gpencil.move_to_layer", {"type": 'M', "value": 'PRESS'}, None),
+ ("gpencil.brush_select",
+ {"type": 'ONE', "value": 'PRESS'},
+ {"properties":
+ [("index", 0),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'TWO', "value": 'PRESS'},
+ {"properties":
+ [("index", 1),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'THREE', "value": 'PRESS'},
+ {"properties":
+ [("index", 2),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'FOUR', "value": 'PRESS'},
+ {"properties":
+ [("index", 3),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'FIVE', "value": 'PRESS'},
+ {"properties":
+ [("index", 4),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'SIX', "value": 'PRESS'},
+ {"properties":
+ [("index", 5),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'SEVEN', "value": 'PRESS'},
+ {"properties":
+ [("index", 6),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'EIGHT', "value": 'PRESS'},
+ {"properties":
+ [("index", 7),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'NINE', "value": 'PRESS'},
+ {"properties":
+ [("index", 8),
+ ],
+ },
+ ),
+ ("gpencil.brush_select",
+ {"type": 'ZERO', "value": 'PRESS'},
+ {"properties":
+ [("index", 9),
+ ],
+ },
+ ),
+ ("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+ ("transform.bend", {"type": 'W', "value": 'PRESS', "shift": True}, None),
+ ("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None),
+ ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("transform.transform",
+ {"type": 'S', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'GPENCIL_SHRINKFATTEN'),
+ ],
+ },
+ ),
+ ("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'ENABLED'),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'CONNECTED'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Face Mask",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("paint.face_select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("paint.face_select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("paint.face_select_hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("paint.face_select_hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("paint.face_select_reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("paint.face_select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+ ("paint.face_select_linked_pick",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("paint.face_select_linked_pick",
+ {"type": 'L', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Weight Paint Vertex Selection",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("paint.vert_select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("paint.vert_select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("view3d.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("view3d.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("view3d.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Pose",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'INFO_MT_add'),
+ ],
+ },
+ ),
+ ("pose.hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("pose.hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("pose.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_pose_apply'),
+ ],
+ },
+ ),
+ ("pose.rot_clear", {"type": 'R', "value": 'PRESS', "alt": True}, None),
+ ("pose.loc_clear", {"type": 'G', "value": 'PRESS', "alt": True}, None),
+ ("pose.scale_clear", {"type": 'S', "value": 'PRESS', "alt": True}, None),
+ ("pose.quaternions_flip", {"type": 'F', "value": 'PRESS', "alt": True}, None),
+ ("pose.rotation_mode_set", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
+ ("pose.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("pose.paste",
+ {"type": 'V', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("flipped", False),
+ ],
+ },
+ ),
+ ("pose.paste",
+ {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("flipped", True),
+ ],
+ },
+ ),
+ ("pose.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("pose.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("pose.select_parent", {"type": 'P', "value": 'PRESS', "shift": True}, None),
+ ("pose.select_hierarchy",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'PARENT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("pose.select_hierarchy",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'PARENT'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("pose.select_hierarchy",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'CHILD'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("pose.select_hierarchy",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'CHILD'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("pose.select_linked", {"type": 'L', "value": 'PRESS'}, None),
+ ("pose.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None),
+ ("pose.select_mirror", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("pose.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("pose.constraints_clear", {"type": 'C', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("pose.ik_add", {"type": 'I', "value": 'PRESS', "shift": True}, None),
+ ("pose.ik_clear", {"type": 'I', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("wm.call_menu",
+ {"type": 'G', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_pose_group'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_bone_options_toggle'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_bone_options_enable'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_bone_options_disable'),
+ ],
+ },
+ ),
+ ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None),
+ ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None),
+ ("pose.bone_layers", {"type": 'M', "value": 'PRESS'}, None),
+ ("wm.context_toggle",
+ {"type": 'Z', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.overlay.show_bone_select'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("mode", 'BONE_SIZE'),
+ ],
+ },
+ ),
+ ("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None),
+ ("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None),
+ ("anim.keying_set_active_set", {"type": 'I', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("poselib.browse_interactive", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+ ("poselib.pose_add", {"type": 'L', "value": 'PRESS', "shift": True}, None),
+ ("poselib.pose_remove", {"type": 'L', "value": 'PRESS', "alt": True}, None),
+ ("poselib.pose_rename", {"type": 'L', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("pose.push", {"type": 'E', "value": 'PRESS', "ctrl": True}, None),
+ ("pose.relax", {"type": 'E', "value": 'PRESS', "alt": True}, None),
+ ("pose.breakdown", {"type": 'E', "value": 'PRESS', "shift": True}, None),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_pose_specials'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'P', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_pose_propagate'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Object Mode",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.use_proportional_edit_objects'),
+ ],
+ },
+ ),
+ ("object.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("object.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("object.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("object.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("object.select_linked", {"type": 'L', "value": 'PRESS', "shift": True}, None),
+ ("object.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None),
+ ("object.select_mirror", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("object.select_hierarchy",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'PARENT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("object.select_hierarchy",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'PARENT'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("object.select_hierarchy",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'CHILD'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("object.select_hierarchy",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'CHILD'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("object.parent_no_inverse_set", {"type": 'P', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("object.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None),
+ ("object.track_set", {"type": 'T', "value": 'PRESS', "ctrl": True}, None),
+ ("object.track_clear", {"type": 'T', "value": 'PRESS', "alt": True}, None),
+ ("object.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("object.constraints_clear", {"type": 'C', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("object.location_clear",
+ {"type": 'G', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("clear_delta", False),
+ ],
+ },
+ ),
+ ("object.rotation_clear",
+ {"type": 'R', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("clear_delta", False),
+ ],
+ },
+ ),
+ ("object.scale_clear",
+ {"type": 'S', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("clear_delta", False),
+ ],
+ },
+ ),
+ ("object.origin_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None),
+ ("object.delete",
+ {"type": 'X', "value": 'PRESS'},
+ {"properties":
+ [("use_global", False),
+ ],
+ },
+ ),
+ ("object.delete",
+ {"type": 'X', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("use_global", True),
+ ],
+ },
+ ),
+ ("object.delete",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("use_global", False),
+ ],
+ },
+ ),
+ ("object.delete",
+ {"type": 'DEL', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("use_global", True),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'INFO_MT_add'),
+ ],
+ },
+ ),
+ ("object.duplicates_make_real", {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_object_apply'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'U', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_make_single_user'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'L', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_make_links'),
+ ],
+ },
+ ),
+ ("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True}, None),
+ ("object.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
+ ("object.convert", {"type": 'C', "value": 'PRESS', "alt": True}, None),
+ ("object.proxy_make", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("object.make_local", {"type": 'L', "value": 'PRESS'}, None),
+ ("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None),
+ ("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None),
+ ("anim.keying_set_active_set", {"type": 'I', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("collection.create", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
+ ("collection.objects_remove", {"type": 'G', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("collection.objects_remove_all", {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("collection.objects_add_active", {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("collection.objects_remove_active", {"type": 'G', "value": 'PRESS', "shift": True, "alt": True}, None),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_object_specials'),
+ ],
+ },
+ ),
+ ("object.data_transfer", {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("object.subdivision_set",
+ {"type": 'ZERO', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 0),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'ONE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 1),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'TWO', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 2),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'THREE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 3),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'FOUR', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 4),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'FIVE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 5),
+ ],
+ },
+ ),
+ ("object.move_to_collection", {"type": 'M', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Paint Curve",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("paintcurve.add_point_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("paintcurve.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None),
+ ("paintcurve.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("paintcurve.slide", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("paintcurve.slide",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("align", True),
+ ],
+ },
+ ),
+ ("paintcurve.select",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("toggle", True),
+ ],
+ },
+ ),
+ ("paintcurve.cursor", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("paintcurve.delete_point", {"type": 'X', "value": 'PRESS'}, None),
+ ("paintcurve.delete_point", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("paintcurve.draw", {"type": 'RET', "value": 'PRESS'}, None),
+ ("paintcurve.draw", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Curve",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'INFO_MT_edit_curve_add'),
+ ],
+ },
+ ),
+ ("curve.handle_type_set", {"type": 'V', "value": 'PRESS'}, None),
+ ("curve.vertex_add", {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, None),
+ ("curve.draw",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("wait_for_input", False),
+ ],
+ },
+ ),
+ ("curve.draw",
+ {"type": 'PEN', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("wait_for_input", False),
+ ],
+ },
+ ),
+ ("curve.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("curve.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("curve.select_row", {"type": 'R', "value": 'PRESS', "shift": True}, None),
+ ("curve.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("curve.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("curve.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+ ("curve.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None),
+ ("curve.select_linked_pick",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("curve.select_linked_pick",
+ {"type": 'L', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("curve.shortest_path_pick", {"type": 'SELECTMOUSE', "value": 'CLICK', "ctrl": True}, None),
+ ("curve.separate", {"type": 'P', "value": 'PRESS'}, None),
+ ("curve.split", {"type": 'Y', "value": 'PRESS'}, None),
+ ("curve.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
+ ("curve.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("curve.make_segment", {"type": 'F', "value": 'PRESS'}, None),
+ ("curve.cyclic_toggle", {"type": 'C', "value": 'PRESS', "alt": True}, None),
+ ("wm.call_menu",
+ {"type": 'X', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_curve_delete'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_curve_delete'),
+ ],
+ },
+ ),
+ ("curve.dissolve_verts", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
+ ("curve.dissolve_verts", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
+ ("curve.tilt_clear", {"type": 'T', "value": 'PRESS', "alt": True}, None),
+ ("transform.tilt", {"type": 'T', "value": 'PRESS', "ctrl": True}, None),
+ ("transform.transform",
+ {"type": 'S', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'CURVE_SHRINKFATTEN'),
+ ],
+ },
+ ),
+ ("curve.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("curve.hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("curve.hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("curve.normals_make_consistent", {"type": 'N', "value": 'PRESS', "ctrl": True}, None),
+ ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_curve_specials'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'H', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_hook'),
+ ],
+ },
+ ),
+ ("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'ENABLED'),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'CONNECTED'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Image Paint",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("paint.image_paint",
+ {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'NORMAL'),
+ ],
+ },
+ ),
+ ("paint.image_paint",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'INVERT'),
+ ],
+ },
+ ),
+ ("paint.brush_colors_flip", {"type": 'X', "value": 'PRESS'}, None),
+ ("paint.grab_clone", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None),
+ ("paint.sample_color", {"type": 'S', "value": 'PRESS'}, None),
+ ("brush.active_index_set",
+ {"type": 'ONE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 0),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'TWO', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 1),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'THREE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 2),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FOUR', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 3),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FIVE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 4),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SIX', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 5),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SEVEN', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 6),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'EIGHT', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 7),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'NINE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 8),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ZERO', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 9),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ONE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 10),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'TWO', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 11),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'THREE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 12),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FOUR', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 13),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FIVE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 14),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SIX', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 15),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SEVEN', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 16),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'EIGHT', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 17),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'NINE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 18),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ZERO', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'image_paint'),
+ ("index", 19),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 0.9),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 1.1111112),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("data_path_primary", 'tool_settings.image_paint.brush.size'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.size'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'),
+ ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'),
+ ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'),
+ ("fill_color_path", 'tool_settings.image_paint.brush.color'),
+ ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'),
+ ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'),
+ ("zoom_path", 'space_data.zoom'),
+ ("image_id", 'tool_settings.image_paint.brush'),
+ ("secondary_tex", True),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.image_paint.brush.strength'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'),
+ ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'),
+ ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'),
+ ("fill_color_path", 'tool_settings.image_paint.brush.color'),
+ ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'),
+ ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.image_paint.brush'),
+ ("secondary_tex", True),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.image_paint.brush.texture_slot.angle'),
+ ("data_path_secondary", ''),
+ ("use_secondary", ''),
+ ("rotation_path", 'tool_settings.image_paint.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'),
+ ("fill_color_path", 'tool_settings.image_paint.brush.color'),
+ ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'),
+ ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.image_paint.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.image_paint.brush.mask_texture_slot.angle'),
+ ("data_path_secondary", ''),
+ ("use_secondary", ''),
+ ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'),
+ ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'),
+ ("fill_color_path", 'tool_settings.image_paint.brush.color'),
+ ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'),
+ ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.image_paint.brush'),
+ ("secondary_tex", True),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TRANSLATION'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'SCALE'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'ROTATION'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'TRANSLATION'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("mode", 'SCALE'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("mode", 'ROTATION'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'M', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'image_paint_object.data.use_paint_mask'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'S', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.image_paint.brush.use_smooth_stroke'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'R', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_angle_control'),
+ ],
+ },
+ ),
+ ("wm.context_menu_enum",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.image_paint.brush.stroke_method'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Vertex Paint",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("paint.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("paint.brush_colors_flip", {"type": 'X', "value": 'PRESS'}, None),
+ ("paint.sample_color", {"type": 'S', "value": 'PRESS'}, None),
+ ("paint.vertex_color_set", {"type": 'K', "value": 'PRESS', "shift": True}, None),
+ ("brush.active_index_set",
+ {"type": 'ONE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 0),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'TWO', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 1),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'THREE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 2),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FOUR', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 3),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FIVE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 4),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SIX', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 5),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SEVEN', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 6),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'EIGHT', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 7),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'NINE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 8),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ZERO', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 9),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ONE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 10),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'TWO', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 11),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'THREE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 12),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FOUR', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 13),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FIVE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 14),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SIX', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 15),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SEVEN', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 16),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'EIGHT', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 17),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'NINE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 18),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ZERO', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'vertex_paint'),
+ ("index", 19),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 0.9),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 1.1111112),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("data_path_primary", 'tool_settings.vertex_paint.brush.size'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.size'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'),
+ ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'),
+ ("fill_color_path", 'tool_settings.vertex_paint.brush.color'),
+ ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'),
+ ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.vertex_paint.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.vertex_paint.brush.strength'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'),
+ ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'),
+ ("fill_color_path", 'tool_settings.vertex_paint.brush.color'),
+ ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'),
+ ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.vertex_paint.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.vertex_paint.brush.texture_slot.angle'),
+ ("data_path_secondary", ''),
+ ("use_secondary", ''),
+ ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'),
+ ("fill_color_path", 'tool_settings.vertex_paint.brush.color'),
+ ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'),
+ ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.vertex_paint.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TRANSLATION'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'SCALE'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'ROTATION'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'TRANSLATION'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("mode", 'SCALE'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("mode", 'ROTATION'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'M', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'vertex_paint_object.data.use_paint_mask'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'S', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.vertex_paint.brush.use_smooth_stroke'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'R', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_angle_control'),
+ ],
+ },
+ ),
+ ("wm.context_menu_enum",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.vertex_paint.brush.stroke_method'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Weight Paint",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("paint.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("paint.weight_sample", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("paint.weight_sample_group", {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("paint.weight_gradient",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("type", 'LINEAR'),
+ ],
+ },
+ ),
+ ("paint.weight_gradient",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("type", 'RADIAL'),
+ ],
+ },
+ ),
+ ("paint.weight_set", {"type": 'K', "value": 'PRESS', "shift": True}, None),
+ ("brush.active_index_set",
+ {"type": 'ONE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 0),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'TWO', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 1),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'THREE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 2),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FOUR', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 3),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FIVE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 4),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SIX', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 5),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SEVEN', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 6),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'EIGHT', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 7),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'NINE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 8),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ZERO', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 9),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ONE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 10),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'TWO', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 11),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'THREE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 12),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FOUR', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 13),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FIVE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 14),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SIX', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 15),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SEVEN', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 16),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'EIGHT', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 17),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'NINE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 18),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ZERO', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'weight_paint'),
+ ("index", 19),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 0.9),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 1.1111112),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("data_path_primary", 'tool_settings.weight_paint.brush.size'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.size'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'),
+ ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'),
+ ("fill_color_path", ''),
+ ("fill_color_override_path", ''),
+ ("fill_color_override_test_path", ''),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.weight_paint.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.weight_paint.brush.strength'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'),
+ ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'),
+ ("fill_color_path", ''),
+ ("fill_color_override_path", ''),
+ ("fill_color_override_test_path", ''),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.weight_paint.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("data_path_primary", 'tool_settings.weight_paint.brush.weight'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.weight'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_weight'),
+ ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'),
+ ("fill_color_path", ''),
+ ("fill_color_override_path", ''),
+ ("fill_color_override_test_path", ''),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.weight_paint.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.context_menu_enum",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.vertex_paint.brush.stroke_method'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'M', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'weight_paint_object.data.use_paint_mask'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'V', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'weight_paint_object.data.use_paint_mask_vertex'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'S', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.weight_paint.brush.use_smooth_stroke'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Sculpt",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("sculpt.brush_stroke",
+ {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'NORMAL'),
+ ],
+ },
+ ),
+ ("sculpt.brush_stroke",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'INVERT'),
+ ],
+ },
+ ),
+ ("sculpt.brush_stroke",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'SMOOTH'),
+ ],
+ },
+ ),
+ ("paint.hide_show",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("action", 'SHOW'),
+ ("area", 'INSIDE'),
+ ],
+ },
+ ),
+ ("paint.hide_show",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("action", 'HIDE'),
+ ("area", 'INSIDE'),
+ ],
+ },
+ ),
+ ("paint.hide_show",
+ {"type": 'H', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("action", 'SHOW'),
+ ("area", 'ALL'),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'ZERO', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 0),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'ONE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 1),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'TWO', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 2),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'THREE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 3),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'FOUR', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 4),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'FIVE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 5),
+ ],
+ },
+ ),
+ ("paint.mask_flood_fill",
+ {"type": 'M', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'VALUE'),
+ ("value", 0.0),
+ ],
+ },
+ ),
+ ("paint.mask_flood_fill",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'INVERT'),
+ ],
+ },
+ ),
+ ("paint.mask_lasso_gesture", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("wm.context_toggle",
+ {"type": 'M', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'scene.tool_settings.sculpt.show_mask'),
+ ],
+ },
+ ),
+ ("sculpt.dynamic_topology_toggle", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
+ ("sculpt.set_detail_size", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("object.subdivision_set",
+ {"type": 'PAGE_UP', "value": 'PRESS'},
+ {"properties":
+ [("level", 1),
+ ("relative", True),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'PAGE_DOWN', "value": 'PRESS'},
+ {"properties":
+ [("level", -1),
+ ("relative", True),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ONE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 0),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'TWO', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 1),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'THREE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 2),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FOUR', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 3),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FIVE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 4),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SIX', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 5),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SEVEN', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 6),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'EIGHT', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 7),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'NINE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 8),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ZERO', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 9),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ONE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 10),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'TWO', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 11),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'THREE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 12),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FOUR', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 13),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'FIVE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 14),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SIX', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 15),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'SEVEN', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 16),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'EIGHT', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 17),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'NINE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 18),
+ ],
+ },
+ ),
+ ("brush.active_index_set",
+ {"type": 'ZERO', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'sculpt'),
+ ("index", 19),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 0.9),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 1.1111112),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("data_path_primary", 'tool_settings.sculpt.brush.size'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.size'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'),
+ ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'),
+ ("fill_color_path", ''),
+ ("fill_color_override_path", ''),
+ ("fill_color_override_test_path", ''),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.sculpt.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.sculpt.brush.strength'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'),
+ ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'),
+ ("fill_color_path", ''),
+ ("fill_color_override_path", ''),
+ ("fill_color_override_test_path", ''),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.sculpt.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.sculpt.brush.texture_slot.angle'),
+ ("data_path_secondary", ''),
+ ("use_secondary", ''),
+ ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'),
+ ("fill_color_path", ''),
+ ("fill_color_override_path", ''),
+ ("fill_color_override_test_path", ''),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.sculpt.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TRANSLATION'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'SCALE'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'ROTATION'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'TRANSLATION'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("mode", 'SCALE'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("brush.stencil_control",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("mode", 'ROTATION'),
+ ("texmode", 'SECONDARY'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'X', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'DRAW'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'S', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'SMOOTH'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'P', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'PINCH'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'I', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'INFLATE'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'G', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'GRAB'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'LAYER'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'T', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'FLATTEN'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'C', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'CLAY'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'C', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'CREASE'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'K', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'SNAKE_HOOK'),
+ ],
+ },
+ ),
+ ("paint.brush_select",
+ {"type": 'M', "value": 'PRESS'},
+ {"properties":
+ [("paint_mode", 'SCULPT'),
+ ("sculpt_tool", 'MASK'),
+ ("toggle", True),
+ ("create_missing", True),
+ ],
+ },
+ ),
+ ("wm.context_menu_enum",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.sculpt.brush.stroke_method'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'S', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.sculpt.brush.use_smooth_stroke'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'R', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_angle_control'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Mesh",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("mesh.loopcut_slide", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
+ ("mesh.offset_edge_loops_slide", {"type": 'R', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("mesh.inset", {"type": 'I', "value": 'PRESS'}, None),
+ ("mesh.poke", {"type": 'P', "value": 'PRESS', "alt": True}, None),
+ ("mesh.bevel",
+ {"type": 'B', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("vertex_only", False),
+ ],
+ },
+ ),
+ ("mesh.bevel",
+ {"type": 'B', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("vertex_only", True),
+ ],
+ },
+ ),
+ ("mesh.loop_select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", False),
+ ],
+ },
+ ),
+ ("mesh.loop_select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("mesh.edgering_select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", False),
+ ],
+ },
+ ),
+ ("mesh.edgering_select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("mesh.shortest_path_pick",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("use_fill", False),
+ ],
+ },
+ ),
+ ("mesh.shortest_path_pick",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("use_fill", True),
+ ],
+ },
+ ),
+ ("mesh.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("mesh.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("mesh.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("mesh.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("mesh.select_next_item", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("mesh.select_prev_item", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("mesh.select_non_manifold", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("mesh.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+ ("mesh.select_linked_pick",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("mesh.select_linked_pick",
+ {"type": 'L', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("mesh.faces_select_linked_flat", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("wm.call_menu",
+ {"type": 'G', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_select_similar'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'TAB', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_select_mode'),
+ ],
+ },
+ ),
+ ("mesh.hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("mesh.hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("mesh.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("mesh.normals_make_consistent",
+ {"type": 'N', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("inside", False),
+ ],
+ },
+ ),
+ ("mesh.normals_make_consistent",
+ {"type": 'N', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("inside", True),
+ ],
+ },
+ ),
+ ("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'}, None),
+ ("wm.call_menu",
+ {"type": 'E', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_extrude'),
+ ],
+ },
+ ),
+ ("transform.edge_crease", {"type": 'E', "value": 'PRESS', "shift": True}, None),
+ ("mesh.spin", {"type": 'R', "value": 'PRESS', "alt": True}, None),
+ ("mesh.fill", {"type": 'F', "value": 'PRESS', "alt": True}, None),
+ ("mesh.beautify_fill", {"type": 'F', "value": 'PRESS', "shift": True, "alt": True}, None),
+ ("mesh.quads_convert_to_tris",
+ {"type": 'T', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("quad_method", 'BEAUTY'),
+ ("ngon_method", 'BEAUTY'),
+ ],
+ },
+ ),
+ ("mesh.quads_convert_to_tris",
+ {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("quad_method", 'FIXED'),
+ ("ngon_method", 'CLIP'),
+ ],
+ },
+ ),
+ ("mesh.tris_convert_to_quads", {"type": 'J', "value": 'PRESS', "alt": True}, None),
+ ("mesh.rip_move",
+ {"type": 'V', "value": 'PRESS'},
+ {"properties":
+ [("MESH_OT_rip",
+ [("use_fill", False),
+ ],
+ ),
+ ],
+ },
+ ),
+ ("mesh.rip_move",
+ {"type": 'V', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("MESH_OT_rip",
+ [("use_fill", True),
+ ],
+ ),
+ ],
+ },
+ ),
+ ("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True}, None),
+ ("mesh.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None),
+ ("transform.shrink_fatten", {"type": 'S', "value": 'PRESS', "alt": True}, None),
+ ("mesh.edge_face_add", {"type": 'F', "value": 'PRESS'}, None),
+ ("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'INFO_MT_mesh_add'),
+ ],
+ },
+ ),
+ ("mesh.separate", {"type": 'P', "value": 'PRESS'}, None),
+ ("mesh.split", {"type": 'Y', "value": 'PRESS'}, None),
+ ("mesh.vert_connect_path", {"type": 'J', "value": 'PRESS'}, None),
+ ("transform.vert_slide", {"type": 'V', "value": 'PRESS', "shift": True}, None),
+ ("mesh.dupli_extrude_cursor",
+ {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True},
+ {"properties":
+ [("rotate_source", True),
+ ],
+ },
+ ),
+ ("mesh.dupli_extrude_cursor",
+ {"type": 'ACTIONMOUSE', "value": 'CLICK', "shift": True, "ctrl": True},
+ {"properties":
+ [("rotate_source", False),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'X', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_delete'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_delete'),
+ ],
+ },
+ ),
+ ("mesh.dissolve_mode", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
+ ("mesh.dissolve_mode", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
+ ("mesh.knife_tool",
+ {"type": 'K', "value": 'PRESS'},
+ {"properties":
+ [("use_occlude_geometry", True),
+ ("only_selected", False),
+ ],
+ },
+ ),
+ ("mesh.knife_tool",
+ {"type": 'K', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("use_occlude_geometry", False),
+ ("only_selected", True),
+ ],
+ },
+ ),
+ ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_specials'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'F', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_faces'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'E', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_edges'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'V', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_mesh_vertices'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'H', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_hook'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'U', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_uv_map'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'G', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_vertex_group'),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'ZERO', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 0),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'ONE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 1),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'TWO', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 2),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'THREE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 3),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'FOUR', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 4),
+ ],
+ },
+ ),
+ ("object.subdivision_set",
+ {"type": 'FIVE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("level", 5),
+ ],
+ },
+ ),
+ ("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'ENABLED'),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'CONNECTED'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Armature",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("armature.hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("armature.hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("armature.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("armature.align", {"type": 'A', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("armature.calculate_roll", {"type": 'N', "value": 'PRESS', "ctrl": True}, None),
+ ("armature.roll_clear", {"type": 'R', "value": 'PRESS', "alt": True}, None),
+ ("armature.switch_direction", {"type": 'F', "value": 'PRESS', "alt": True}, None),
+ ("armature.bone_primitive_add", {"type": 'A', "value": 'PRESS', "shift": True}, None),
+ ("armature.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("armature.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None),
+ ("armature.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("armature.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("armature.select_mirror",
+ {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("armature.select_hierarchy",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'PARENT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("armature.select_hierarchy",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'PARENT'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("armature.select_hierarchy",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'CHILD'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("armature.select_hierarchy",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'CHILD'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("armature.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("armature.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("armature.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None),
+ ("armature.select_linked", {"type": 'L', "value": 'PRESS'}, None),
+ ("armature.shortest_path_pick", {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'X', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_armature_delete'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_edit_armature_delete'),
+ ],
+ },
+ ),
+ ("armature.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
+ ("armature.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("armature.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
+ ("armature.extrude_forked", {"type": 'E', "value": 'PRESS', "shift": True}, None),
+ ("armature.click_extrude", {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, None),
+ ("armature.fill", {"type": 'F', "value": 'PRESS'}, None),
+ ("armature.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None),
+ ("armature.split", {"type": 'Y', "value": 'PRESS'}, None),
+ ("armature.separate", {"type": 'P', "value": 'PRESS'}, None),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_bone_options_toggle'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_bone_options_enable'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_bone_options_disable'),
+ ],
+ },
+ ),
+ ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None),
+ ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None),
+ ("armature.bone_layers", {"type": 'M', "value": 'PRESS'}, None),
+ ("transform.transform",
+ {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("mode", 'BONE_SIZE'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'S', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'BONE_ENVELOPE'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'R', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'BONE_ROLL'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_armature_specials'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Metaball",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("object.metaball_add", {"type": 'A', "value": 'PRESS', "shift": True}, None),
+ ("mball.reveal_metaelems", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("mball.hide_metaelems",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("mball.hide_metaelems",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("mball.delete_metaelems", {"type": 'X', "value": 'PRESS'}, None),
+ ("mball.delete_metaelems", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("mball.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("mball.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("mball.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("mball.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None),
+ ("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'ENABLED'),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'CONNECTED'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Lattice",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("lattice.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("lattice.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("lattice.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("lattice.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("lattice.flip", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'H', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_hook'),
+ ],
+ },
+ ),
+ ("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'ENABLED'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Particle",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("particle.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("particle.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("particle.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("particle.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("particle.select_linked",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("particle.select_linked",
+ {"type": 'L', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("particle.delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("particle.delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("particle.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("particle.hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("particle.hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("particle.brush_edit", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("particle.brush_edit", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("data_path_primary", 'tool_settings.particle_edit.brush.size'),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.particle_edit.brush.strength'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'VIEW3D_MT_particle_specials'),
+ ],
+ },
+ ),
+ ("particle.weight_set", {"type": 'K', "value": 'PRESS', "shift": True}, None),
+ ("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'ENABLED'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Font",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("font.style_toggle",
+ {"type": 'B', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("style", 'BOLD'),
+ ],
+ },
+ ),
+ ("font.style_toggle",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("style", 'ITALIC'),
+ ],
+ },
+ ),
+ ("font.style_toggle",
+ {"type": 'U', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("style", 'UNDERLINE'),
+ ],
+ },
+ ),
+ ("font.style_toggle",
+ {"type": 'P', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("style", 'SMALL_CAPS'),
+ ],
+ },
+ ),
+ ("font.delete",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_OR_SELECTION'),
+ ],
+ },
+ ),
+ ("font.delete",
+ {"type": 'DEL', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'NEXT_WORD'),
+ ],
+ },
+ ),
+ ("font.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_OR_SELECTION'),
+ ],
+ },
+ ),
+ ("font.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_OR_SELECTION'),
+ ],
+ },
+ ),
+ ("font.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PREVIOUS_WORD'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'HOME', "value": 'PRESS'},
+ {"properties":
+ [("type", 'LINE_BEGIN'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'END', "value": 'PRESS'},
+ {"properties":
+ [("type", 'LINE_END'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'LEFT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_CHARACTER'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PREVIOUS_WORD'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'NEXT_WORD'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'UP_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_LINE'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'DOWN_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_LINE'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'PAGE_UP', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_PAGE'),
+ ],
+ },
+ ),
+ ("font.move",
+ {"type": 'PAGE_DOWN', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_PAGE'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'HOME', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'LINE_BEGIN'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'END', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'LINE_END'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'NEXT_CHARACTER'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'PREVIOUS_WORD'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'NEXT_WORD'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'UP_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_LINE'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'NEXT_LINE'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'PAGE_UP', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_PAGE'),
+ ],
+ },
+ ),
+ ("font.move_select",
+ {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'NEXT_PAGE'),
+ ],
+ },
+ ),
+ ("font.change_spacing",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("font.change_spacing",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("font.change_character",
+ {"type": 'UP_ARROW', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("font.change_character",
+ {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("font.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None),
+ ("font.text_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("font.text_cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
+ ("font.text_paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("font.line_break", {"type": 'RET', "value": 'PRESS'}, None),
+ ("font.text_insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
+ ("font.text_insert",
+ {"type": 'BACK_SPACE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("accent", True),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Object Non-modal",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("object.mode_set",
+ {"type": 'TAB', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'EDIT'),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("object.mode_set",
+ {"type": 'TAB', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'POSE'),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("object.mode_set",
+ {"type": 'V', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'VERTEX_PAINT'),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("object.mode_set",
+ {"type": 'TAB', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'WEIGHT_PAINT'),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("object.origin_set", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ],
+ },
+ ),
+ ("3D View",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("view3d.cursor3d", {"type": 'ACTIONMOUSE', "value": 'CLICK'}, None),
+ ("view3d.rotate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("view3d.move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("view3d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("view3d.dolly", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("view3d.view_selected",
+ {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("use_all_regions", True),
+ ],
+ },
+ ),
+ ("view3d.view_selected",
+ {"type": 'NUMPAD_PERIOD', "value": 'PRESS'},
+ {"properties":
+ [("use_all_regions", False),
+ ],
+ },
+ ),
+ ("view3d.view_lock_to_active", {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "shift": True}, None),
+ ("view3d.view_lock_clear", {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "alt": True}, None),
+ ("view3d.navigate", {"type": 'F', "value": 'PRESS', "shift": True}, None),
+ ("view3d.smoothview", {"type": 'TIMER1', "value": 'ANY', "any": True}, None),
+ ("view3d.rotate", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
+ ("view3d.rotate", {"type": 'MOUSEROTATE', "value": 'ANY'}, None),
+ ("view3d.move", {"type": 'TRACKPADPAN', "value": 'ANY', "shift": True}, None),
+ ("view3d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None),
+ ("view3d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None),
+ ("view3d.zoom",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS'},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("view3d.zoom",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS'},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("view3d.zoom",
+ {"type": 'EQUAL', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("view3d.zoom",
+ {"type": 'MINUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("view3d.zoom",
+ {"type": 'WHEELINMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("view3d.zoom",
+ {"type": 'WHEELOUTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("view3d.dolly",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("view3d.dolly",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("view3d.dolly",
+ {"type": 'EQUAL', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("delta", 1),
+ ],
+ },
+ ),
+ ("view3d.dolly",
+ {"type": 'MINUS', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("delta", -1),
+ ],
+ },
+ ),
+ ("view3d.zoom_camera_1_to_1", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None),
+ ("view3d.view_center_camera", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("view3d.view_center_lock", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("view3d.view_center_cursor", {"type": 'HOME', "value": 'PRESS', "alt": True}, None),
+ ("view3d.view_center_pick", {"type": 'F', "value": 'PRESS', "alt": True}, None),
+ ("view3d.view_all",
+ {"type": 'HOME', "value": 'PRESS'},
+ {"properties":
+ [("center", False),
+ ],
+ },
+ ),
+ ("view3d.view_all",
+ {"type": 'HOME', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("use_all_regions", True),
+ ("center", False),
+ ],
+ },
+ ),
+ ("view3d.view_all",
+ {"type": 'C', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("center", True),
+ ],
+ },
+ ),
+ ("view3d.view_camera", {"type": 'NUMPAD_0', "value": 'PRESS'}, None),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_1', "value": 'PRESS'},
+ {"properties":
+ [("type", 'FRONT'),
+ ],
+ },
+ ),
+ ("view3d.view_orbit",
+ {"type": 'NUMPAD_2', "value": 'PRESS'},
+ {"properties":
+ [("type", 'ORBITDOWN'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_3', "value": 'PRESS'},
+ {"properties":
+ [("type", 'RIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_orbit",
+ {"type": 'NUMPAD_4', "value": 'PRESS'},
+ {"properties":
+ [("type", 'ORBITLEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_persportho", {"type": 'NUMPAD_5', "value": 'PRESS'}, None),
+ ("view3d.view_orbit",
+ {"type": 'NUMPAD_6', "value": 'PRESS'},
+ {"properties":
+ [("type", 'ORBITRIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_7', "value": 'PRESS'},
+ {"properties":
+ [("type", 'TOP'),
+ ],
+ },
+ ),
+ ("view3d.view_orbit",
+ {"type": 'NUMPAD_8', "value": 'PRESS'},
+ {"properties":
+ [("type", 'ORBITUP'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_1', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'BACK'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_3', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'LEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_7', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'BOTTOM'),
+ ],
+ },
+ ),
+ ("view3d.view_pan",
+ {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PANDOWN'),
+ ],
+ },
+ ),
+ ("view3d.view_pan",
+ {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PANLEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_pan",
+ {"type": 'NUMPAD_6', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PANRIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_pan",
+ {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PANUP'),
+ ],
+ },
+ ),
+ ("view3d.view_roll",
+ {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'LEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_roll",
+ {"type": 'NUMPAD_6', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'RIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_orbit",
+ {"type": 'NUMPAD_9', "value": 'PRESS'},
+ {"properties":
+ [("angle", 3.1415927),
+ ("type", 'ORBITRIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_pan",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PANRIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_pan",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PANLEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_pan",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PANUP'),
+ ],
+ },
+ ),
+ ("view3d.view_pan",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PANDOWN'),
+ ],
+ },
+ ),
+ ("view3d.view_orbit",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("type", 'ORBITLEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_orbit",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("type", 'ORBITRIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_orbit",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("type", 'ORBITUP'),
+ ],
+ },
+ ),
+ ("view3d.view_orbit",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("type", 'ORBITDOWN'),
+ ],
+ },
+ ),
+ ("view3d.view_roll",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'LEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_roll",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'RIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_1', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'FRONT'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_3', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'RIGHT'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_7', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'TOP'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_1', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'BACK'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_3', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'LEFT'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NUMPAD_7', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'BOTTOM'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.ndof_orbit_zoom", {"type": 'NDOF_MOTION', "value": 'ANY'}, None),
+ ("view3d.ndof_orbit", {"type": 'NDOF_MOTION', "value": 'ANY', "ctrl": True}, None),
+ ("view3d.ndof_pan", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True}, None),
+ ("view3d.ndof_all", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True, "ctrl": True}, None),
+ ("view3d.view_selected",
+ {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'},
+ {"properties":
+ [("use_all_regions", False),
+ ],
+ },
+ ),
+ ("view3d.view_roll",
+ {"type": 'NDOF_BUTTON_ROLL_CCW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'LEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_roll",
+ {"type": 'NDOF_BUTTON_ROLL_CCW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'RIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_FRONT', "value": 'PRESS'},
+ {"properties":
+ [("type", 'FRONT'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_BACK', "value": 'PRESS'},
+ {"properties":
+ [("type", 'BACK'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_LEFT', "value": 'PRESS'},
+ {"properties":
+ [("type", 'LEFT'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_RIGHT', "value": 'PRESS'},
+ {"properties":
+ [("type", 'RIGHT'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS'},
+ {"properties":
+ [("type", 'TOP'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_BOTTOM', "value": 'PRESS'},
+ {"properties":
+ [("type", 'BOTTOM'),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_FRONT', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'FRONT'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_RIGHT', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'RIGHT'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.view_axis",
+ {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'TOP'),
+ ("align_active", True),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'ACCENT_GRAVE', "value": 'PRESS'},
+ {"properties":
+ [("nr", 0),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'ONE', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 1),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'TWO', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 2),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'THREE', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 3),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'FOUR', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 4),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'FIVE', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 5),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'SIX', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 6),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'SEVEN', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 7),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'EIGHT', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 8),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'NINE', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 9),
+ ],
+ },
+ ),
+ ("view3d.layers",
+ {"type": 'ZERO', "value": 'PRESS', "any": True},
+ {"properties":
+ [("nr", 10),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'Z', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'space_data.shading.type'),
+ ("value_1", 'SOLID'),
+ ("value_2", 'TEXTURED'),
+ ],
+ },
+ ),
+ ("view3d.toggle_render", {"type": 'Z', "value": 'PRESS', "shift": True}, None),
+ ("view3d.toggle_xray_draw_option", {"type": 'Z', "value": 'PRESS'}, None),
+ ("wm.context_toggle",
+ {"type": 'Z', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.use_occlude_geometry'),
+ ],
+ },
+ ),
+ ("view3d.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", False),
+ ("center", False),
+ ("enumerate", False),
+ ("object", False),
+ ],
+ },
+ ),
+ ("view3d.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", True),
+ ("center", False),
+ ("enumerate", False),
+ ("object", False),
+ ],
+ },
+ ),
+ ("view3d.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", False),
+ ("center", True),
+ ("enumerate", False),
+ ("object", True),
+ ],
+ },
+ ),
+ ("view3d.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", False),
+ ("center", False),
+ ("enumerate", True),
+ ("object", False),
+ ],
+ },
+ ),
+ ("view3d.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ("deselect", False),
+ ("toggle", True),
+ ("center", True),
+ ("enumerate", False),
+ ("object", False),
+ ],
+ },
+ ),
+ ("view3d.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", False),
+ ("center", True),
+ ("enumerate", True),
+ ("object", False),
+ ],
+ },
+ ),
+ ("view3d.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", True),
+ ("center", False),
+ ("enumerate", True),
+ ("object", False),
+ ],
+ },
+ ),
+ ("view3d.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", True),
+ ("center", True),
+ ("enumerate", True),
+ ("object", False),
+ ],
+ },
+ ),
+ ("view3d.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("view3d.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("view3d.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None),
+ ("view3d.clip_border", {"type": 'B', "value": 'PRESS', "alt": True}, None),
+ ("view3d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None),
+ ("view3d.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None),
+ ("view3d.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("view3d.camera_to_view", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("view3d.object_as_camera", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'S', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'VIEW3D_MT_snap'),
+ ],
+ },
+ ),
+ ("view3d.copybuffer", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("view3d.pastebuffer", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.context_set_enum",
+ {"type": 'COMMA', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.transform_pivot_point'),
+ ("value", 'BOUNDING_BOX_CENTER'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'COMMA', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'tool_settings.transform_pivot_point'),
+ ("value", 'MEDIAN_POINT'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'COMMA', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'tool_settings.use_transform_pivot_point_align'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'PERIOD', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.transform_pivot_point'),
+ ("value", 'CURSOR'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'PERIOD', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'tool_settings.transform_pivot_point'),
+ ("value", 'INDIVIDUAL_ORIGINS'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'PERIOD', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'tool_settings.transform_pivot_point'),
+ ("value", 'ACTIVE_ELEMENT'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'SPACE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.show_manipulator'),
+ ],
+ },
+ ),
+ ("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ("transform.bend", {"type": 'W', "value": 'PRESS', "shift": True}, None),
+ ("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None),
+ ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("transform.select_orientation", {"type": 'SPACE', "value": 'PRESS', "alt": True}, None),
+ ("transform.create_orientation",
+ {"type": 'SPACE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("use", True),
+ ],
+ },
+ ),
+ ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.context_toggle",
+ {"type": 'TAB', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.use_snap'),
+ ],
+ },
+ ),
+ ("wm.context_menu_enum",
+ {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("data_path", 'tool_settings.snap_element'),
+ ],
+ },
+ ),
+ ("object.transform_axis_target", {"type": 'T', "value": 'PRESS', "shift": True}, None),
+ ("transform.translate",
+ {"type": 'T', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("texture_space", True),
+ ],
+ },
+ ),
+ ("transform.resize",
+ {"type": 'T', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("texture_space", True),
+ ],
+ },
+ ),
+ ("transform.skin_resize", {"type": 'A', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("Manipulators",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [],
+ },
+ ),
+ ("Backdrop Transform Widget",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Backdrop Crop Widget",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Sun Beams Widget",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Corner Pin Widget",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("UV Transform Manipulator",
+ {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Spot Light Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Area Light Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Target Light Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Force Field Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Camera Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Camera View Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Armature Spline Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("View3D Navigate",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Animation",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("anim.change_frame", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("wm.context_toggle",
+ {"type": 'T', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.show_seconds'),
+ ],
+ },
+ ),
+ ("anim.previewrange_set", {"type": 'P', "value": 'PRESS'}, None),
+ ("anim.previewrange_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None),
+ ],
+ },
+ ),
+ ("Animation Channels",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("anim.channels_click", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("anim.channels_click",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("anim.channels_click",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("children_only", True),
+ ],
+ },
+ ),
+ ("anim.channels_rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("anim.channels_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
+ ("anim.channel_select_keys", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
+ ("anim.channel_select_keys",
+ {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+ ("anim.channels_select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("anim.channels_select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("anim.channels_select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("anim.channels_select_border", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+ ("anim.channels_delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("anim.channels_delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("anim.channels_setting_toggle", {"type": 'W', "value": 'PRESS', "shift": True}, None),
+ ("anim.channels_setting_enable", {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("anim.channels_setting_disable", {"type": 'W', "value": 'PRESS', "alt": True}, None),
+ ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("anim.channels_expand", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None),
+ ("anim.channels_collapse", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None),
+ ("anim.channels_expand",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("all", False),
+ ],
+ },
+ ),
+ ("anim.channels_collapse",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("all", False),
+ ],
+ },
+ ),
+ ("anim.channels_move",
+ {"type": 'PAGE_UP', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'UP'),
+ ],
+ },
+ ),
+ ("anim.channels_move",
+ {"type": 'PAGE_DOWN', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'DOWN'),
+ ],
+ },
+ ),
+ ("anim.channels_move",
+ {"type": 'PAGE_UP', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'TOP'),
+ ],
+ },
+ ),
+ ("anim.channels_move",
+ {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'BOTTOM'),
+ ],
+ },
+ ),
+ ("anim.channels_group", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
+ ("anim.channels_ungroup", {"type": 'G', "value": 'PRESS', "alt": True}, None),
+ ],
+ },
+ ),
+ ("UV Editor",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("wm.context_toggle",
+ {"type": 'Q', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.use_uv_sculpt'),
+ ],
+ },
+ ),
+ ("uv.mark_seam", {"type": 'E', "value": 'PRESS', "ctrl": True}, None),
+ ("uv.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("uv.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("uv.select_loop",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("uv.select_loop",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("uv.select_split", {"type": 'Y', "value": 'PRESS'}, None),
+ ("uv.select_border",
+ {"type": 'B', "value": 'PRESS'},
+ {"properties":
+ [("pinned", False),
+ ],
+ },
+ ),
+ ("uv.select_border",
+ {"type": 'B', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("pinned", True),
+ ],
+ },
+ ),
+ ("uv.circle_select", {"type": 'C', "value": 'PRESS'}, None),
+ ("uv.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("uv.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("uv.select_linked",
+ {"type": 'L', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ("deselect", False),
+ ],
+ },
+ ),
+ ("uv.select_linked_pick",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("extend", True),
+ ("deselect", False),
+ ],
+ },
+ ),
+ ("uv.select_linked",
+ {"type": 'L', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", True),
+ ],
+ },
+ ),
+ ("uv.select_linked_pick",
+ {"type": 'L', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", True),
+ ],
+ },
+ ),
+ ("uv.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("uv.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("uv.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("uv.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("uv.select_pinned", {"type": 'P', "value": 'PRESS', "shift": True}, None),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'IMAGE_MT_uvs_weldalign'),
+ ],
+ },
+ ),
+ ("uv.stitch", {"type": 'V', "value": 'PRESS'}, None),
+ ("uv.pin",
+ {"type": 'P', "value": 'PRESS'},
+ {"properties":
+ [("clear", False),
+ ],
+ },
+ ),
+ ("uv.pin",
+ {"type": 'P', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("clear", True),
+ ],
+ },
+ ),
+ ("uv.unwrap", {"type": 'E', "value": 'PRESS'}, None),
+ ("uv.minimize_stretch", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("uv.pack_islands", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("uv.average_islands_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None),
+ ("uv.hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("uv.hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("uv.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("uv.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("wm.call_menu",
+ {"type": 'S', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'IMAGE_MT_uvs_snap'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'TAB', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("name", 'IMAGE_MT_uvs_select_mode'),
+ ],
+ },
+ ),
+ ("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit'),
+ ("value_1", 'DISABLED'),
+ ("value_2", 'ENABLED'),
+ ],
+ },
+ ),
+ ("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.context_toggle",
+ {"type": 'TAB', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.use_snap'),
+ ],
+ },
+ ),
+ ("wm.context_menu_enum",
+ {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("data_path", 'tool_settings.snap_uv_element'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("UV Sculpt",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("wm.context_toggle",
+ {"type": 'Q', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.use_uv_sculpt'),
+ ],
+ },
+ ),
+ ("sculpt.uv_sculpt_stroke",
+ {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'NORMAL'),
+ ],
+ },
+ ),
+ ("sculpt.uv_sculpt_stroke",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'INVERT'),
+ ],
+ },
+ ),
+ ("sculpt.uv_sculpt_stroke",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'RELAX'),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 0.9),
+ ],
+ },
+ ),
+ ("brush.scale_size",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("scalar", 1.1111112),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("data_path_primary", 'tool_settings.uv_sculpt.brush.size'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.size'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'),
+ ("rotation_path", 'tool_settings.uv_sculpt.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.uv_sculpt.brush.cursor_color_add'),
+ ("fill_color_path", ''),
+ ("fill_color_override_path", ''),
+ ("fill_color_override_test_path", ''),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.uv_sculpt.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("wm.radial_control",
+ {"type": 'F', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path_primary", 'tool_settings.uv_sculpt.brush.strength'),
+ ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'),
+ ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'),
+ ("rotation_path", 'tool_settings.uv_sculpt.brush.texture_slot.angle'),
+ ("color_path", 'tool_settings.uv_sculpt.brush.cursor_color_add'),
+ ("fill_color_path", ''),
+ ("fill_color_override_path", ''),
+ ("fill_color_override_test_path", ''),
+ ("zoom_path", ''),
+ ("image_id", 'tool_settings.uv_sculpt.brush'),
+ ("secondary_tex", False),
+ ],
+ },
+ ),
+ ("brush.uv_sculpt_tool_set",
+ {"type": 'S', "value": 'PRESS'},
+ {"properties":
+ [("tool", 'RELAX'),
+ ],
+ },
+ ),
+ ("brush.uv_sculpt_tool_set",
+ {"type": 'P', "value": 'PRESS'},
+ {"properties":
+ [("tool", 'PINCH'),
+ ],
+ },
+ ),
+ ("brush.uv_sculpt_tool_set",
+ {"type": 'G', "value": 'PRESS'},
+ {"properties":
+ [("tool", 'GRAB'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Mask Editing",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("mask.new", {"type": 'N', "value": 'PRESS', "alt": True}, None),
+ ("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'MASK_MT_add'),
+ ],
+ },
+ ),
+ ("wm.context_cycle_enum",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.proportional_edit_falloff'),
+ ("wrap", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.use_proportional_edit_mask'),
+ ],
+ },
+ ),
+ ("mask.add_vertex_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("mask.add_feather_vertex_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("mask.delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("mask.delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("mask.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", False),
+ ],
+ },
+ ),
+ ("mask.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", False),
+ ("deselect", False),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("mask.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("mask.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("mask.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+ ("mask.select_linked_pick",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("mask.select_linked_pick",
+ {"type": 'L', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("mask.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("mask.select_circle", {"type": 'C', "value": 'PRESS'}, None),
+ ("mask.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("mask.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("mask.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("mask.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("mask.hide_view_clear", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("mask.hide_view_set",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("mask.hide_view_set",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("clip.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("mask.cyclic_toggle", {"type": 'C', "value": 'PRESS', "alt": True}, None),
+ ("mask.slide_point", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("mask.slide_spline_curvature", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("mask.handle_type_set", {"type": 'V', "value": 'PRESS'}, None),
+ ("mask.normals_make_consistent", {"type": 'N', "value": 'PRESS', "ctrl": True}, None),
+ ("mask.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("mask.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None),
+ ("mask.shape_key_insert", {"type": 'I', "value": 'PRESS'}, None),
+ ("mask.shape_key_clear", {"type": 'I', "value": 'PRESS', "alt": True}, None),
+ ("mask.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("mask.copy_splines", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("mask.paste_splines", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("uv.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ("transform.transform",
+ {"type": 'S', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'MASK_SHRINKFATTEN'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Markers",
+ {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+ {"items":
+ [("marker.add", {"type": 'M', "value": 'PRESS'}, None),
+ ("marker.move", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("marker.duplicate", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("marker.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None),
+ ("marker.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("marker.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ("camera", True),
+ ],
+ },
+ ),
+ ("marker.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ("camera", True),
+ ],
+ },
+ ),
+ ("marker.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("marker.select_all", {"type": 'A', "value": 'PRESS'}, None),
+ ("marker.delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("marker.delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+ ("marker.move", {"type": 'G', "value": 'PRESS'}, None),
+ ("marker.camera_bind", {"type": 'B', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("Graph Editor Generic",
+ {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("graph.properties", {"type": 'N', "value": 'PRESS'}, None),
+ ("graph.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None),
+ ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+ ("graph.hide",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("graph.hide",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("graph.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ],
+ },
+ ),
+ ("Graph Editor",
+ {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("wm.context_toggle",
+ {"type": 'H', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.show_handles'),
+ ],
+ },
+ ),
+ ("graph.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("graph.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ("column", False),
+ ("curves", False),
+ ],
+ },
+ ),
+ ("graph.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("extend", False),
+ ("column", True),
+ ("curves", False),
+ ],
+ },
+ ),
+ ("graph.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ("column", False),
+ ("curves", False),
+ ],
+ },
+ ),
+ ("graph.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ("column", True),
+ ("curves", False),
+ ],
+ },
+ ),
+ ("graph.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ("column", False),
+ ("curves", True),
+ ],
+ },
+ ),
+ ("graph.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ("column", False),
+ ("curves", True),
+ ],
+ },
+ ),
+ ("graph.select_leftright",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'CHECK'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("graph.select_leftright",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("mode", 'CHECK'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("graph.select_leftright",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'LEFT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("graph.select_leftright",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'RIGHT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("graph.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("graph.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("graph.select_border",
+ {"type": 'B', "value": 'PRESS'},
+ {"properties":
+ [("axis_range", False),
+ ("include_handles", False),
+ ],
+ },
+ ),
+ ("graph.select_border",
+ {"type": 'B', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("axis_range", True),
+ ("include_handles", False),
+ ],
+ },
+ ),
+ ("graph.select_border",
+ {"type": 'B', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("axis_range", False),
+ ("include_handles", True),
+ ],
+ },
+ ),
+ ("graph.select_border",
+ {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("axis_range", True),
+ ("include_handles", True),
+ ],
+ },
+ ),
+ ("graph.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("graph.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("graph.select_circle", {"type": 'C', "value": 'PRESS'}, None),
+ ("graph.select_column",
+ {"type": 'K', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'KEYS'),
+ ],
+ },
+ ),
+ ("graph.select_column",
+ {"type": 'K', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'CFRA'),
+ ],
+ },
+ ),
+ ("graph.select_column",
+ {"type": 'K', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'MARKERS_COLUMN'),
+ ],
+ },
+ ),
+ ("graph.select_column",
+ {"type": 'K', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'MARKERS_BETWEEN'),
+ ],
+ },
+ ),
+ ("graph.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("graph.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("graph.select_linked", {"type": 'L', "value": 'PRESS'}, None),
+ ("graph.frame_jump", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
+ ("graph.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None),
+ ("graph.mirror", {"type": 'M', "value": 'PRESS', "shift": True}, None),
+ ("graph.handle_type", {"type": 'V', "value": 'PRESS'}, None),
+ ("graph.interpolation_type", {"type": 'T', "value": 'PRESS'}, None),
+ ("graph.easing_type", {"type": 'E', "value": 'PRESS', "ctrl": True}, None),
+ ("graph.smooth", {"type": 'O', "value": 'PRESS', "alt": True}, None),
+ ("graph.sample", {"type": 'O', "value": 'PRESS', "shift": True}, None),
+ ("graph.bake", {"type": 'C', "value": 'PRESS', "alt": True}, None),
+ ("wm.call_menu",
+ {"type": 'X', "value": 'PRESS'},
+ {"properties":
+ [("name", 'GRAPH_MT_delete'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("name", 'GRAPH_MT_delete'),
+ ],
+ },
+ ),
+ ("graph.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("graph.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None),
+ ("graph.click_insert",
+ {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("graph.click_insert",
+ {"type": 'ACTIONMOUSE', "value": 'CLICK', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("graph.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("graph.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("graph.paste",
+ {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("flipped", True),
+ ],
+ },
+ ),
+ ("graph.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("graph.view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("graph.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("graph.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("graph.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None),
+ ("graph.fmodifier_add",
+ {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("only_active", False),
+ ],
+ },
+ ),
+ ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.transform",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TIME_EXTEND'),
+ ],
+ },
+ ),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ("wm.context_toggle",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.use_proportional_fcurve'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'COMMA', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'BOUNDING_BOX_CENTER'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'PERIOD', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'CURSOR'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'PERIOD', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'INDIVIDUAL_ORIGINS'),
+ ],
+ },
+ ),
+ ("marker.add", {"type": 'M', "value": 'PRESS'}, None),
+ ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("Image Generic",
+ {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("image.new", {"type": 'N', "value": 'PRESS', "alt": True}, None),
+ ("image.open", {"type": 'O', "value": 'PRESS', "alt": True}, None),
+ ("image.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None),
+ ("image.read_viewlayers", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
+ ("image.save", {"type": 'S', "value": 'PRESS', "alt": True}, None),
+ ("image.save_as", {"type": 'F3', "value": 'PRESS'}, None),
+ ("image.properties", {"type": 'N', "value": 'PRESS'}, None),
+ ("image.toolshelf", {"type": 'T', "value": 'PRESS'}, None),
+ ("image.cycle_render_slot", {"type": 'J', "value": 'PRESS'}, None),
+ ("image.cycle_render_slot",
+ {"type": 'J', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("reverse", True),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Image",
+ {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("image.view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("image.view_all",
+ {"type": 'HOME', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("fit_view", True),
+ ],
+ },
+ ),
+ ("image.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("image.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
+ ("image.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("image.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None),
+ ("image.view_zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None),
+ ("image.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None),
+ ("image.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None),
+ ("image.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None),
+ ("image.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("image.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None),
+ ("image.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None),
+ ("image.view_zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("ratio", 8.0),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("ratio", 4.0),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("ratio", 2.0),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_8', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("ratio", 8.0),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("ratio", 4.0),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_2', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("ratio", 2.0),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_1', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 1.0),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_2', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 0.5),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_4', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 0.25),
+ ],
+ },
+ ),
+ ("image.view_zoom_ratio",
+ {"type": 'NUMPAD_8', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 0.125),
+ ],
+ },
+ ),
+ ("image.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("image.sample", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("image.curves_point_set",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("point", 'BLACK_POINT'),
+ ],
+ },
+ ),
+ ("image.curves_point_set",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("point", 'WHITE_POINT'),
+ ],
+ },
+ ),
+ ("object.mode_set",
+ {"type": 'TAB', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'EDIT'),
+ ("toggle", True),
+ ],
+ },
+ ),
+ ("wm.context_set_int",
+ {"type": 'ONE', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.image.render_slots.active_index'),
+ ("value", 0),
+ ],
+ },
+ ),
+ ("wm.context_set_int",
+ {"type": 'TWO', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.image.render_slots.active_index'),
+ ("value", 1),
+ ],
+ },
+ ),
+ ("wm.context_set_int",
+ {"type": 'THREE', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.image.render_slots.active_index'),
+ ("value", 2),
+ ],
+ },
+ ),
+ ("wm.context_set_int",
+ {"type": 'FOUR', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.image.render_slots.active_index'),
+ ("value", 3),
+ ],
+ },
+ ),
+ ("wm.context_set_int",
+ {"type": 'FIVE', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.image.render_slots.active_index'),
+ ("value", 4),
+ ],
+ },
+ ),
+ ("wm.context_set_int",
+ {"type": 'SIX', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.image.render_slots.active_index'),
+ ("value", 5),
+ ],
+ },
+ ),
+ ("wm.context_set_int",
+ {"type": 'SEVEN', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.image.render_slots.active_index'),
+ ("value", 6),
+ ],
+ },
+ ),
+ ("wm.context_set_int",
+ {"type": 'EIGHT', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.image.render_slots.active_index'),
+ ("value", 7),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'COMMA', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'CENTER'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'COMMA', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'MEDIAN'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'PERIOD', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'CURSOR'),
+ ],
+ },
+ ),
+ ("image.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None),
+ ("image.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ],
+ },
+ ),
+ ("Node Generic",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("node.properties", {"type": 'N', "value": 'PRESS'}, None),
+ ("node.toolbar", {"type": 'T', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Node Editor",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("node.select",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select_border",
+ {"type": 'EVT_TWEAK_S', "value": 'ANY'},
+ {"properties":
+ [("tweak", True),
+ ],
+ },
+ ),
+ ("node.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("node.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("node.select_circle", {"type": 'C', "value": 'PRESS'}, None),
+ ("node.link",
+ {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("detach", False),
+ ],
+ },
+ ),
+ ("node.link",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("detach", True),
+ ],
+ },
+ ),
+ ("node.resize", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("node.add_reroute", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("node.links_cut", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("node.select_link_viewer", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("node.backimage_move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "alt": True}, None),
+ ("node.backimage_zoom",
+ {"type": 'V', "value": 'PRESS'},
+ {"properties":
+ [("factor", 0.8333333),
+ ],
+ },
+ ),
+ ("node.backimage_zoom",
+ {"type": 'V', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("factor", 1.2),
+ ],
+ },
+ ),
+ ("node.backimage_fit", {"type": 'HOME', "value": 'PRESS', "alt": True}, None),
+ ("node.backimage_sample", {"type": 'ACTIONMOUSE', "value": 'PRESS', "alt": True}, None),
+ ("node.link_make",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("replace", False),
+ ],
+ },
+ ),
+ ("node.link_make",
+ {"type": 'F', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("replace", True),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'NODE_MT_add'),
+ ],
+ },
+ ),
+ ("node.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("node.duplicate_move_keep_inputs", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("node.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
+ ("node.detach", {"type": 'P', "value": 'PRESS', "alt": True}, None),
+ ("node.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
+ ("node.hide_toggle", {"type": 'H', "value": 'PRESS'}, None),
+ ("node.mute_toggle", {"type": 'M', "value": 'PRESS'}, None),
+ ("node.preview_toggle", {"type": 'H', "value": 'PRESS', "shift": True}, None),
+ ("node.hide_socket_toggle", {"type": 'H', "value": 'PRESS', "ctrl": True}, None),
+ ("node.view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("node.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("node.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("node.select_border",
+ {"type": 'B', "value": 'PRESS'},
+ {"properties":
+ [("tweak", False),
+ ],
+ },
+ ),
+ ("node.delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("node.delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("node.delete_reconnect", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
+ ("node.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("node.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("node.select_linked_to", {"type": 'L', "value": 'PRESS', "shift": True}, None),
+ ("node.select_linked_from", {"type": 'L', "value": 'PRESS'}, None),
+ ("node.select_grouped",
+ {"type": 'G', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("node.select_grouped",
+ {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("node.select_same_type_step",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("prev", False),
+ ],
+ },
+ ),
+ ("node.select_same_type_step",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("prev", True),
+ ],
+ },
+ ),
+ ("node.find_node", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+ ("node.group_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
+ ("node.group_ungroup", {"type": 'G', "value": 'PRESS', "alt": True}, None),
+ ("node.group_separate", {"type": 'P', "value": 'PRESS'}, None),
+ ("node.group_edit",
+ {"type": 'TAB', "value": 'PRESS'},
+ {"properties":
+ [("exit", False),
+ ],
+ },
+ ),
+ ("node.group_edit",
+ {"type": 'TAB', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("exit", True),
+ ],
+ },
+ ),
+ ("node.read_viewlayers", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
+ ("node.render_changed", {"type": 'Z', "value": 'PRESS'}, None),
+ ("node.clipboard_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("node.clipboard_paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("node.viewer_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None),
+ ("node.clear_viewer_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("node.translate_attach", {"type": 'G', "value": 'PRESS'}, None),
+ ("node.translate_attach", {"type": 'EVT_TWEAK_A', "value": 'ANY'}, None),
+ ("node.translate_attach", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.translate",
+ {"type": 'G', "value": 'PRESS'},
+ {"properties":
+ [("release_confirm", True),
+ ],
+ },
+ ),
+ ("transform.translate",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY'},
+ {"properties":
+ [("release_confirm", True),
+ ],
+ },
+ ),
+ ("transform.translate",
+ {"type": 'EVT_TWEAK_S', "value": 'ANY'},
+ {"properties":
+ [("release_confirm", True),
+ ],
+ },
+ ),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ("node.move_detach_links", {"type": 'D', "value": 'PRESS', "alt": True}, None),
+ ("node.move_detach_links_release", {"type": 'EVT_TWEAK_A', "value": 'ANY', "alt": True}, None),
+ ("node.move_detach_links", {"type": 'EVT_TWEAK_S', "value": 'ANY', "alt": True}, None),
+ ("wm.context_toggle",
+ {"type": 'TAB', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'tool_settings.use_snap'),
+ ],
+ },
+ ),
+ ("wm.context_menu_enum",
+ {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("data_path", 'tool_settings.snap_node_element'),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("File Browser",
+ {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'},
+ {"items":
+ [("file.parent", {"type": 'UP_ARROW', "value": 'PRESS', "alt": True}, None),
+ ("file.previous", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, None),
+ ("file.next", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, None),
+ ("file.refresh", {"type": 'R', "value": 'PRESS'}, None),
+ ("file.parent", {"type": 'P', "value": 'PRESS'}, None),
+ ("file.previous", {"type": 'BACK_SPACE', "value": 'PRESS'}, None),
+ ("file.next", {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, None),
+ ("wm.context_toggle",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.params.show_hidden'),
+ ],
+ },
+ ),
+ ("file.directory_new", {"type": 'I', "value": 'PRESS'}, None),
+ ("file.delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("file.delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("file.smoothscroll", {"type": 'TIMER1', "value": 'ANY', "any": True}, None),
+ ("file.bookmark_toggle", {"type": 'T', "value": 'PRESS'}, None),
+ ("file.bookmark_add", {"type": 'B', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("File Browser Main",
+ {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'},
+ {"items":
+ [("file.execute",
+ {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'},
+ {"properties":
+ [("need_active", True),
+ ],
+ },
+ ),
+ ("file.refresh", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None),
+ ("file.select",
+ {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("file.select",
+ {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ("fill", True),
+ ],
+ },
+ ),
+ ("file.select",
+ {"type": 'RIGHTMOUSE', "value": 'CLICK'},
+ {"properties":
+ [("open", False),
+ ],
+ },
+ ),
+ ("file.select",
+ {"type": 'RIGHTMOUSE', "value": 'CLICK', "shift": True},
+ {"properties":
+ [("extend", True),
+ ("open", False),
+ ],
+ },
+ ),
+ ("file.select",
+ {"type": 'RIGHTMOUSE', "value": 'CLICK', "alt": True},
+ {"properties":
+ [("extend", True),
+ ("fill", True),
+ ("open", False),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'UP_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'UP'),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'UP_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'UP'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("direction", 'UP'),
+ ("extend", True),
+ ("fill", True),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'DOWN_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'DOWN'),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'DOWN'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("direction", 'DOWN'),
+ ("extend", True),
+ ("fill", True),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'LEFT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'LEFT'),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'LEFT'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("direction", 'LEFT'),
+ ("extend", True),
+ ("fill", True),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("direction", 'RIGHT'),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("direction", 'RIGHT'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("file.select_walk",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("direction", 'RIGHT'),
+ ("extend", True),
+ ("fill", True),
+ ],
+ },
+ ),
+ ("file.previous", {"type": 'BUTTON4MOUSE', "value": 'CLICK'}, None),
+ ("file.next", {"type": 'BUTTON5MOUSE', "value": 'CLICK'}, None),
+ ("file.select_all_toggle", {"type": 'A', "value": 'PRESS'}, None),
+ ("file.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("file.select_border", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+ ("file.rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("file.highlight", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None),
+ ("file.filenum",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS'},
+ {"properties":
+ [("increment", 1),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("increment", 10),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("increment", 100),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS'},
+ {"properties":
+ [("increment", -1),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("increment", -10),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("increment", -100),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("File Browser Buttons",
+ {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'},
+ {"items":
+ [("file.filenum",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS'},
+ {"properties":
+ [("increment", 1),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("increment", 10),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("increment", 100),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS'},
+ {"properties":
+ [("increment", -1),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("increment", -10),
+ ],
+ },
+ ),
+ ("file.filenum",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("increment", -100),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("Dopesheet Generic",
+ {"space_type": 'DOPESHEET_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("action.properties", {"type": 'N', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Dopesheet",
+ {"space_type": 'DOPESHEET_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("action.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ("column", False),
+ ("channel", False),
+ ],
+ },
+ ),
+ ("action.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("extend", False),
+ ("column", True),
+ ("channel", False),
+ ],
+ },
+ ),
+ ("action.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ("column", False),
+ ("channel", False),
+ ],
+ },
+ ),
+ ("action.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ("column", True),
+ ("channel", False),
+ ],
+ },
+ ),
+ ("action.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", False),
+ ("column", False),
+ ("channel", True),
+ ],
+ },
+ ),
+ ("action.clickselect",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ("column", False),
+ ("channel", True),
+ ],
+ },
+ ),
+ ("action.select_leftright",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'CHECK'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("action.select_leftright",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("mode", 'CHECK'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("action.select_leftright",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'LEFT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("action.select_leftright",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'RIGHT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("action.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("action.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("action.select_border",
+ {"type": 'B', "value": 'PRESS'},
+ {"properties":
+ [("axis_range", False),
+ ],
+ },
+ ),
+ ("action.select_border",
+ {"type": 'B', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("axis_range", True),
+ ],
+ },
+ ),
+ ("action.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("action.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("action.select_circle", {"type": 'C', "value": 'PRESS'}, None),
+ ("action.select_column",
+ {"type": 'K', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'KEYS'),
+ ],
+ },
+ ),
+ ("action.select_column",
+ {"type": 'K', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'CFRA'),
+ ],
+ },
+ ),
+ ("action.select_column",
+ {"type": 'K', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'MARKERS_COLUMN'),
+ ],
+ },
+ ),
+ ("action.select_column",
+ {"type": 'K', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("mode", 'MARKERS_BETWEEN'),
+ ],
+ },
+ ),
+ ("action.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("action.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("action.select_linked", {"type": 'L', "value": 'PRESS'}, None),
+ ("action.frame_jump", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
+ ("action.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None),
+ ("action.mirror", {"type": 'M', "value": 'PRESS', "shift": True}, None),
+ ("action.handle_type", {"type": 'V', "value": 'PRESS'}, None),
+ ("action.interpolation_type", {"type": 'T', "value": 'PRESS'}, None),
+ ("action.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None),
+ ("action.keyframe_type", {"type": 'R', "value": 'PRESS'}, None),
+ ("action.sample", {"type": 'O', "value": 'PRESS', "shift": True}, None),
+ ("wm.call_menu",
+ {"type": 'X', "value": 'PRESS'},
+ {"properties":
+ [("name", 'DOPESHEET_MT_delete'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("name", 'DOPESHEET_MT_delete'),
+ ],
+ },
+ ),
+ ("action.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("action.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None),
+ ("action.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("action.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("action.paste",
+ {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("flipped", True),
+ ],
+ },
+ ),
+ ("action.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("action.view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("action.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("action.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("action.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None),
+ ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+ ("transform.transform",
+ {"type": 'G', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TIME_TRANSLATE'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'EVT_TWEAK_S', "value": 'ANY'},
+ {"properties":
+ [("mode", 'TIME_TRANSLATE'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TIME_EXTEND'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'S', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TIME_SCALE'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'T', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("mode", 'TIME_SLIDE'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'tool_settings.use_proportional_action'),
+ ],
+ },
+ ),
+ ("marker.add", {"type": 'M', "value": 'PRESS'}, None),
+ ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("NLA Generic",
+ {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("nla.properties", {"type": 'N', "value": 'PRESS'}, None),
+ ("nla.tweakmode_enter", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("nla.tweakmode_exit", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("nla.tweakmode_enter",
+ {"type": 'TAB', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("isolate_action", True),
+ ],
+ },
+ ),
+ ("nla.tweakmode_exit",
+ {"type": 'TAB', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("isolate_action", True),
+ ],
+ },
+ ),
+ ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("NLA Channels",
+ {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("nla.channels_click",
+ {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("nla.channels_click",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("nla.tracks_add",
+ {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("above_selected", False),
+ ],
+ },
+ ),
+ ("nla.tracks_add",
+ {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("above_selected", True),
+ ],
+ },
+ ),
+ ("nla.tracks_delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("nla.tracks_delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("NLA Editor",
+ {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("nla.click_select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("nla.click_select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("nla.select_leftright",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("mode", 'CHECK'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("nla.select_leftright",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("mode", 'CHECK'),
+ ("extend", True),
+ ],
+ },
+ ),
+ ("nla.select_leftright",
+ {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'LEFT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("nla.select_leftright",
+ {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'RIGHT'),
+ ("extend", False),
+ ],
+ },
+ ),
+ ("nla.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("nla.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("nla.select_border",
+ {"type": 'B', "value": 'PRESS'},
+ {"properties":
+ [("axis_range", False),
+ ],
+ },
+ ),
+ ("nla.select_border",
+ {"type": 'B', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("axis_range", True),
+ ],
+ },
+ ),
+ ("nla.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None),
+ ("nla.view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("nla.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("nla.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("nla.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None),
+ ("nla.actionclip_add", {"type": 'A', "value": 'PRESS', "shift": True}, None),
+ ("nla.transition_add", {"type": 'T', "value": 'PRESS', "shift": True}, None),
+ ("nla.soundclip_add", {"type": 'K', "value": 'PRESS', "shift": True}, None),
+ ("nla.meta_add", {"type": 'G', "value": 'PRESS', "shift": True}, None),
+ ("nla.meta_remove", {"type": 'G', "value": 'PRESS', "alt": True}, None),
+ ("nla.duplicate",
+ {"type": 'D', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("linked", False),
+ ],
+ },
+ ),
+ ("nla.duplicate",
+ {"type": 'D', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("linked", True),
+ ],
+ },
+ ),
+ ("nla.make_single_user", {"type": 'U', "value": 'PRESS'}, None),
+ ("nla.delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("nla.delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("nla.split", {"type": 'Y', "value": 'PRESS'}, None),
+ ("nla.mute_toggle", {"type": 'H', "value": 'PRESS'}, None),
+ ("nla.swap", {"type": 'F', "value": 'PRESS', "alt": True}, None),
+ ("nla.move_up", {"type": 'PAGE_UP', "value": 'PRESS'}, None),
+ ("nla.move_down", {"type": 'PAGE_DOWN', "value": 'PRESS'}, None),
+ ("nla.apply_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None),
+ ("nla.clear_scale", {"type": 'S', "value": 'PRESS', "alt": True}, None),
+ ("nla.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None),
+ ("nla.fmodifier_add", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("transform.transform",
+ {"type": 'G', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TRANSLATION'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'EVT_TWEAK_S', "value": 'ANY'},
+ {"properties":
+ [("mode", 'TRANSLATION'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TIME_EXTEND'),
+ ],
+ },
+ ),
+ ("transform.transform",
+ {"type": 'S', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TIME_SCALE'),
+ ],
+ },
+ ),
+ ("marker.add", {"type": 'M', "value": 'PRESS'}, None),
+ ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("Text Generic",
+ {"space_type": 'TEXT_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("text.start_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+ ("text.jump", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
+ ("text.find", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
+ ("text.replace", {"type": 'H', "value": 'PRESS', "ctrl": True}, None),
+ ("text.properties", {"type": 'T', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("Text",
+ {"space_type": 'TEXT_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("wm.context_cycle_int",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.font_size'),
+ ("reverse", False),
+ ],
+ },
+ ),
+ ("wm.context_cycle_int",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.font_size'),
+ ("reverse", True),
+ ],
+ },
+ ),
+ ("wm.context_cycle_int",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.font_size'),
+ ("reverse", False),
+ ],
+ },
+ ),
+ ("wm.context_cycle_int",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.font_size'),
+ ("reverse", True),
+ ],
+ },
+ ),
+ ("text.new", {"type": 'N', "value": 'PRESS', "ctrl": True}, None),
+ ("text.open", {"type": 'O', "value": 'PRESS', "alt": True}, None),
+ ("text.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None),
+ ("text.save", {"type": 'S', "value": 'PRESS', "alt": True}, None),
+ ("text.save_as", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
+ ("text.run_script", {"type": 'P', "value": 'PRESS', "alt": True}, None),
+ ("text.cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
+ ("text.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("text.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("text.cut", {"type": 'DEL', "value": 'PRESS', "shift": True}, None),
+ ("text.copy", {"type": 'INSERT', "value": 'PRESS', "ctrl": True}, None),
+ ("text.paste", {"type": 'INSERT', "value": 'PRESS', "shift": True}, None),
+ ("text.duplicate_line", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
+ ("text.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None),
+ ("text.select_line", {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("text.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
+ ("text.move_lines",
+ {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("direction", 'UP'),
+ ],
+ },
+ ),
+ ("text.move_lines",
+ {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("direction", 'DOWN'),
+ ],
+ },
+ ),
+ ("text.indent", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("text.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None),
+ ("text.uncomment", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("text.move",
+ {"type": 'HOME', "value": 'PRESS'},
+ {"properties":
+ [("type", 'LINE_BEGIN'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'END', "value": 'PRESS'},
+ {"properties":
+ [("type", 'LINE_END'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'E', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'LINE_END'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'LINE_END'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'LEFT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_CHARACTER'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PREVIOUS_WORD'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'NEXT_WORD'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'UP_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_LINE'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'DOWN_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_LINE'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'PAGE_UP', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_PAGE'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'PAGE_DOWN', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_PAGE'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'HOME', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'FILE_TOP'),
+ ],
+ },
+ ),
+ ("text.move",
+ {"type": 'END', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'FILE_BOTTOM'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'HOME', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'LINE_BEGIN'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'END', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'LINE_END'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'NEXT_CHARACTER'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'PREVIOUS_WORD'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'NEXT_WORD'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'UP_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_LINE'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'NEXT_LINE'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'PAGE_UP', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_PAGE'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'NEXT_PAGE'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'HOME', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'FILE_TOP'),
+ ],
+ },
+ ),
+ ("text.move_select",
+ {"type": 'END', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("type", 'FILE_BOTTOM'),
+ ],
+ },
+ ),
+ ("text.delete",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_CHARACTER'),
+ ],
+ },
+ ),
+ ("text.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("text.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("text.delete",
+ {"type": 'DEL', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'NEXT_WORD'),
+ ],
+ },
+ ),
+ ("text.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PREVIOUS_WORD'),
+ ],
+ },
+ ),
+ ("text.overwrite_toggle", {"type": 'INSERT', "value": 'PRESS'}, None),
+ ("text.scroll_bar", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("text.scroll_bar", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("text.scroll", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("text.scroll", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
+ ("text.selection_set", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+ ("text.cursor_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("text.selection_set",
+ {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("select", True),
+ ],
+ },
+ ),
+ ("text.scroll",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("lines", -1),
+ ],
+ },
+ ),
+ ("text.scroll",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("lines", 1),
+ ],
+ },
+ ),
+ ("text.line_break", {"type": 'RET', "value": 'PRESS'}, None),
+ ("text.line_break", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None),
+ ("wm.call_menu",
+ {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True},
+ {"properties":
+ [("name", 'TEXT_MT_toolbox'),
+ ],
+ },
+ ),
+ ("text.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None),
+ ("text.line_number", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
+ ("text.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
+ ],
+ },
+ ),
+ ("SequencerCommon",
+ {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("sequencer.properties", {"type": 'N', "value": 'PRESS'}, None),
+ ("wm.context_toggle",
+ {"type": 'O', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("data_path", 'scene.sequence_editor.show_overlay'),
+ ],
+ },
+ ),
+ ("sequencer.view_toggle", {"type": 'TAB', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("Sequencer",
+ {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("sequencer.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("sequencer.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("sequencer.cut",
+ {"type": 'K', "value": 'PRESS'},
+ {"properties":
+ [("type", 'SOFT'),
+ ],
+ },
+ ),
+ ("sequencer.cut",
+ {"type": 'K', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'HARD'),
+ ],
+ },
+ ),
+ ("sequencer.mute",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("sequencer.mute",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("sequencer.unmute",
+ {"type": 'H', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("sequencer.unmute",
+ {"type": 'H', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("sequencer.lock", {"type": 'L', "value": 'PRESS', "shift": True}, None),
+ ("sequencer.unlock", {"type": 'L', "value": 'PRESS', "shift": True, "alt": True}, None),
+ ("sequencer.reassign_inputs", {"type": 'R', "value": 'PRESS'}, None),
+ ("sequencer.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None),
+ ("sequencer.reload",
+ {"type": 'R', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("adjust_length", True),
+ ],
+ },
+ ),
+ ("sequencer.offset_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None),
+ ("sequencer.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
+ ("sequencer.delete", {"type": 'X', "value": 'PRESS'}, None),
+ ("sequencer.delete", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("sequencer.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("sequencer.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("sequencer.images_separate", {"type": 'Y', "value": 'PRESS'}, None),
+ ("sequencer.meta_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("sequencer.meta_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
+ ("sequencer.meta_separate", {"type": 'G', "value": 'PRESS', "alt": True}, None),
+ ("sequencer.view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("sequencer.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("sequencer.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("sequencer.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None),
+ ("sequencer.strip_jump",
+ {"type": 'PAGE_UP', "value": 'PRESS'},
+ {"properties":
+ [("next", True),
+ ("center", False),
+ ],
+ },
+ ),
+ ("sequencer.strip_jump",
+ {"type": 'PAGE_DOWN', "value": 'PRESS'},
+ {"properties":
+ [("next", False),
+ ("center", False),
+ ],
+ },
+ ),
+ ("sequencer.strip_jump",
+ {"type": 'PAGE_UP', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("next", True),
+ ("center", True),
+ ],
+ },
+ ),
+ ("sequencer.strip_jump",
+ {"type": 'PAGE_DOWN', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("next", False),
+ ("center", True),
+ ],
+ },
+ ),
+ ("sequencer.swap",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("side", 'LEFT'),
+ ],
+ },
+ ),
+ ("sequencer.swap",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("side", 'RIGHT'),
+ ],
+ },
+ ),
+ ("sequencer.gap_remove",
+ {"type": 'BACK_SPACE', "value": 'PRESS'},
+ {"properties":
+ [("all", False),
+ ],
+ },
+ ),
+ ("sequencer.gap_remove",
+ {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("all", True),
+ ],
+ },
+ ),
+ ("sequencer.gap_insert", {"type": 'EQUAL', "value": 'PRESS', "shift": True}, None),
+ ("sequencer.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None),
+ ("sequencer.swap_inputs", {"type": 'S', "value": 'PRESS', "alt": True}, None),
+ ("sequencer.cut_multicam",
+ {"type": 'ONE', "value": 'PRESS'},
+ {"properties":
+ [("camera", 1),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'TWO', "value": 'PRESS'},
+ {"properties":
+ [("camera", 2),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'THREE', "value": 'PRESS'},
+ {"properties":
+ [("camera", 3),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'FOUR', "value": 'PRESS'},
+ {"properties":
+ [("camera", 4),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'FIVE', "value": 'PRESS'},
+ {"properties":
+ [("camera", 5),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'SIX', "value": 'PRESS'},
+ {"properties":
+ [("camera", 6),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'SEVEN', "value": 'PRESS'},
+ {"properties":
+ [("camera", 7),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'EIGHT', "value": 'PRESS'},
+ {"properties":
+ [("camera", 8),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'NINE', "value": 'PRESS'},
+ {"properties":
+ [("camera", 9),
+ ],
+ },
+ ),
+ ("sequencer.cut_multicam",
+ {"type": 'ZERO', "value": 'PRESS'},
+ {"properties":
+ [("camera", 10),
+ ],
+ },
+ ),
+ ("sequencer.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ("linked_handle", False),
+ ("left_right", 'NONE'),
+ ("linked_time", False),
+ ],
+ },
+ ),
+ ("sequencer.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ("linked_handle", False),
+ ("left_right", 'NONE'),
+ ("linked_time", False),
+ ],
+ },
+ ),
+ ("sequencer.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("extend", False),
+ ("linked_handle", True),
+ ("left_right", 'NONE'),
+ ("linked_time", False),
+ ],
+ },
+ ),
+ ("sequencer.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("extend", True),
+ ("linked_handle", True),
+ ("left_right", 'NONE'),
+ ("linked_time", False),
+ ],
+ },
+ ),
+ ("sequencer.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("extend", False),
+ ("linked_handle", False),
+ ("left_right", 'MOUSE'),
+ ("linked_time", True),
+ ],
+ },
+ ),
+ ("sequencer.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("extend", True),
+ ("linked_handle", False),
+ ("left_right", 'NONE'),
+ ("linked_time", True),
+ ],
+ },
+ ),
+ ("sequencer.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
+ ("sequencer.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
+ ("sequencer.select_linked_pick",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("sequencer.select_linked_pick",
+ {"type": 'L', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("sequencer.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+ ("sequencer.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("sequencer.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None),
+ ("wm.call_menu",
+ {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'SEQUENCER_MT_add'),
+ ],
+ },
+ ),
+ ("wm.call_menu",
+ {"type": 'C', "value": 'PRESS'},
+ {"properties":
+ [("name", 'SEQUENCER_MT_change'),
+ ],
+ },
+ ),
+ ("sequencer.slip", {"type": 'S', "value": 'PRESS'}, None),
+ ("wm.context_set_int",
+ {"type": 'O', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'scene.sequence_editor.overlay_frame'),
+ ("value", 0),
+ ],
+ },
+ ),
+ ("transform.seq_slide", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.seq_slide", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.transform",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("mode", 'TIME_EXTEND'),
+ ],
+ },
+ ),
+ ("marker.add", {"type": 'M', "value": 'PRESS'}, None),
+ ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("SequencerPreview",
+ {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("sequencer.view_all_preview", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("sequencer.view_all_preview", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("sequencer.view_ghost_border", {"type": 'O', "value": 'PRESS'}, None),
+ ("sequencer.view_zoom_ratio",
+ {"type": 'NUMPAD_1', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 1.0),
+ ],
+ },
+ ),
+ ("sequencer.sample", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Console",
+ {"space_type": 'CONSOLE', "region_type": 'WINDOW'},
+ {"items":
+ [("console.move",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PREVIOUS_WORD'),
+ ],
+ },
+ ),
+ ("console.move",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'NEXT_WORD'),
+ ],
+ },
+ ),
+ ("console.move",
+ {"type": 'HOME', "value": 'PRESS'},
+ {"properties":
+ [("type", 'LINE_BEGIN'),
+ ],
+ },
+ ),
+ ("console.move",
+ {"type": 'END', "value": 'PRESS'},
+ {"properties":
+ [("type", 'LINE_END'),
+ ],
+ },
+ ),
+ ("wm.context_cycle_int",
+ {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.font_size'),
+ ("reverse", False),
+ ],
+ },
+ ),
+ ("wm.context_cycle_int",
+ {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.font_size'),
+ ("reverse", True),
+ ],
+ },
+ ),
+ ("wm.context_cycle_int",
+ {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.font_size'),
+ ("reverse", False),
+ ],
+ },
+ ),
+ ("wm.context_cycle_int",
+ {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.font_size'),
+ ("reverse", True),
+ ],
+ },
+ ),
+ ("console.move",
+ {"type": 'LEFT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("console.move",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_CHARACTER'),
+ ],
+ },
+ ),
+ ("console.history_cycle",
+ {"type": 'UP_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("reverse", True),
+ ],
+ },
+ ),
+ ("console.history_cycle",
+ {"type": 'DOWN_ARROW', "value": 'PRESS'},
+ {"properties":
+ [("reverse", False),
+ ],
+ },
+ ),
+ ("console.delete",
+ {"type": 'DEL', "value": 'PRESS'},
+ {"properties":
+ [("type", 'NEXT_CHARACTER'),
+ ],
+ },
+ ),
+ ("console.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS'},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("console.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("type", 'PREVIOUS_CHARACTER'),
+ ],
+ },
+ ),
+ ("console.delete",
+ {"type": 'DEL', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'NEXT_WORD'),
+ ],
+ },
+ ),
+ ("console.delete",
+ {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("type", 'PREVIOUS_WORD'),
+ ],
+ },
+ ),
+ ("console.clear_line", {"type": 'RET', "value": 'PRESS', "shift": True}, None),
+ ("console.clear_line", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None),
+ ("console.execute",
+ {"type": 'RET', "value": 'PRESS'},
+ {"properties":
+ [("interactive", True),
+ ],
+ },
+ ),
+ ("console.execute",
+ {"type": 'NUMPAD_ENTER', "value": 'PRESS'},
+ {"properties":
+ [("interactive", True),
+ ],
+ },
+ ),
+ ("console.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None),
+ ("console.copy_as_script", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None),
+ ("console.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("console.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ("console.select_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("console.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
+ ("console.insert",
+ {"type": 'TAB', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("text", '\t'),
+ ],
+ },
+ ),
+ ("console.indent", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None),
+ ("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
+ ],
+ },
+ ),
+ ("Clip",
+ {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("clip.open", {"type": 'O', "value": 'PRESS', "alt": True}, None),
+ ("clip.tools", {"type": 'T', "value": 'PRESS'}, None),
+ ("clip.properties", {"type": 'N', "value": 'PRESS'}, None),
+ ("clip.track_markers",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("backwards", True),
+ ("sequence", False),
+ ],
+ },
+ ),
+ ("clip.track_markers",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("backwards", False),
+ ("sequence", False),
+ ],
+ },
+ ),
+ ("clip.track_markers",
+ {"type": 'T', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("backwards", False),
+ ("sequence", True),
+ ],
+ },
+ ),
+ ("clip.track_markers",
+ {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("backwards", True),
+ ("sequence", True),
+ ],
+ },
+ ),
+ ("wm.context_toggle_enum",
+ {"type": 'TAB', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.mode'),
+ ("value_1", 'TRACKING'),
+ ("value_2", 'MASK'),
+ ],
+ },
+ ),
+ ("clip.solve_camera", {"type": 'S', "value": 'PRESS', "shift": True}, None),
+ ("clip.set_solver_keyframe",
+ {"type": 'Q', "value": 'PRESS'},
+ {"properties":
+ [("keyframe", 'KEYFRAME_A'),
+ ],
+ },
+ ),
+ ("clip.set_solver_keyframe",
+ {"type": 'E', "value": 'PRESS'},
+ {"properties":
+ [("keyframe", 'KEYFRAME_B'),
+ ],
+ },
+ ),
+ ("clip.prefetch", {"type": 'P', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Clip Editor",
+ {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
+ ("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("clip.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
+ ("clip.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("clip.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None),
+ ("clip.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None),
+ ("clip.view_zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None),
+ ("clip.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None),
+ ("clip.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None),
+ ("clip.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("ratio", 8.0),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("ratio", 4.0),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("ratio", 2.0),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_8', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("ratio", 8.0),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("ratio", 4.0),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_2', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("ratio", 2.0),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_1', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 1.0),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_2', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 0.5),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_4', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 0.25),
+ ],
+ },
+ ),
+ ("clip.view_zoom_ratio",
+ {"type": 'NUMPAD_8', "value": 'PRESS'},
+ {"properties":
+ [("ratio", 0.125),
+ ],
+ },
+ ),
+ ("clip.view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("clip.view_all",
+ {"type": 'F', "value": 'PRESS'},
+ {"properties":
+ [("fit_view", True),
+ ],
+ },
+ ),
+ ("clip.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("clip.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("clip.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None),
+ ("clip.frame_jump",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("position", 'PATHSTART'),
+ ],
+ },
+ ),
+ ("clip.frame_jump",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties":
+ [("position", 'PATHEND'),
+ ],
+ },
+ ),
+ ("clip.frame_jump",
+ {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("position", 'FAILEDPREV'),
+ ],
+ },
+ ),
+ ("clip.frame_jump",
+ {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("position", 'PATHSTART'),
+ ],
+ },
+ ),
+ ("clip.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("clip.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("clip.select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("clip.select_all",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("clip.select_all",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("clip.select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("clip.select_circle", {"type": 'C', "value": 'PRESS'}, None),
+ ("wm.call_menu",
+ {"type": 'G', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("name", 'CLIP_MT_select_grouped'),
+ ],
+ },
+ ),
+ ("clip.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True},
+ {"properties":
+ [("deselect", False),
+ ],
+ },
+ ),
+ ("clip.select_lasso",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True},
+ {"properties":
+ [("deselect", True),
+ ],
+ },
+ ),
+ ("clip.add_marker_slide", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("clip.delete_marker", {"type": 'DEL', "value": 'PRESS', "shift": True}, None),
+ ("clip.delete_marker", {"type": 'X', "value": 'PRESS', "shift": True}, None),
+ ("clip.slide_marker", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("clip.disable_markers",
+ {"type": 'D', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("clip.delete_track", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("clip.delete_track", {"type": 'X', "value": 'PRESS'}, None),
+ ("clip.lock_tracks",
+ {"type": 'L', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'LOCK'),
+ ],
+ },
+ ),
+ ("clip.lock_tracks",
+ {"type": 'L', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("action", 'UNLOCK'),
+ ],
+ },
+ ),
+ ("clip.hide_tracks",
+ {"type": 'H', "value": 'PRESS'},
+ {"properties":
+ [("unselected", False),
+ ],
+ },
+ ),
+ ("clip.hide_tracks",
+ {"type": 'H', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("unselected", True),
+ ],
+ },
+ ),
+ ("clip.hide_tracks_clear", {"type": 'H', "value": 'PRESS', "alt": True}, None),
+ ("clip.slide_plane_marker", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("clip.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None),
+ ("clip.keyframe_delete", {"type": 'I', "value": 'PRESS', "alt": True}, None),
+ ("clip.join_tracks", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.call_menu",
+ {"type": 'W', "value": 'PRESS'},
+ {"properties":
+ [("name", 'CLIP_MT_tracking_specials'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.lock_selection'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'D', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'space_data.show_disabled'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'S', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("data_path", 'space_data.show_marker_search'),
+ ],
+ },
+ ),
+ ("wm.context_toggle",
+ {"type": 'M', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.use_mute_footage'),
+ ],
+ },
+ ),
+ ("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ("clip.clear_track_path",
+ {"type": 'T', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("action", 'REMAINED'),
+ ("clear_active", False),
+ ],
+ },
+ ),
+ ("clip.clear_track_path",
+ {"type": 'T', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("action", 'UPTO'),
+ ("clear_active", False),
+ ],
+ },
+ ),
+ ("clip.clear_track_path",
+ {"type": 'T', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("action", 'ALL'),
+ ("clear_active", False),
+ ],
+ },
+ ),
+ ("clip.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("wm.context_set_enum",
+ {"type": 'COMMA', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'BOUNDING_BOX_CENTER'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'COMMA', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'MEDIAN_POINT'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'PERIOD', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'CURSOR'),
+ ],
+ },
+ ),
+ ("wm.context_set_enum",
+ {"type": 'PERIOD', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("data_path", 'space_data.pivot_point'),
+ ("value", 'INDIVIDUAL_ORIGINS'),
+ ],
+ },
+ ),
+ ("clip.copy_tracks", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+ ("clip.paste_tracks", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
+ ],
+ },
+ ),
+ ("Clip Graph Editor",
+ {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("clip.change_frame", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None),
+ ("clip.graph_select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", False),
+ ],
+ },
+ ),
+ ("clip.graph_select",
+ {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("clip.graph_select_all_markers",
+ {"type": 'A', "value": 'PRESS'},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("clip.graph_select_all_markers",
+ {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties":
+ [("action", 'INVERT'),
+ ],
+ },
+ ),
+ ("clip.graph_select_border", {"type": 'B', "value": 'PRESS'}, None),
+ ("clip.graph_delete_curve", {"type": 'DEL', "value": 'PRESS'}, None),
+ ("clip.graph_delete_curve", {"type": 'X', "value": 'PRESS'}, None),
+ ("clip.graph_delete_knot", {"type": 'DEL', "value": 'PRESS', "shift": True}, None),
+ ("clip.graph_delete_knot", {"type": 'X', "value": 'PRESS', "shift": True}, None),
+ ("clip.graph_view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("clip.graph_view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ("clip.graph_center_current_frame", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
+ ("wm.context_toggle",
+ {"type": 'L', "value": 'PRESS'},
+ {"properties":
+ [("data_path", 'space_data.lock_time_cursor'),
+ ],
+ },
+ ),
+ ("clip.clear_track_path",
+ {"type": 'T', "value": 'PRESS', "alt": True},
+ {"properties":
+ [("action", 'REMAINED'),
+ ("clear_active", True),
+ ],
+ },
+ ),
+ ("clip.clear_track_path",
+ {"type": 'T', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("action", 'UPTO'),
+ ("clear_active", True),
+ ],
+ },
+ ),
+ ("clip.clear_track_path",
+ {"type": 'T', "value": 'PRESS', "shift": True, "alt": True},
+ {"properties":
+ [("action", 'ALL'),
+ ("clear_active", True),
+ ],
+ },
+ ),
+ ("clip.graph_disable_markers",
+ {"type": 'D', "value": 'PRESS', "shift": True},
+ {"properties":
+ [("action", 'TOGGLE'),
+ ],
+ },
+ ),
+ ("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None),
+ ("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
+ ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("Clip Dopesheet Editor",
+ {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'},
+ {"items":
+ [("clip.dopesheet_select_channel",
+ {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties":
+ [("extend", True),
+ ],
+ },
+ ),
+ ("clip.dopesheet_view_all", {"type": 'HOME', "value": 'PRESS'}, None),
+ ("clip.dopesheet_view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
+ ],
+ },
+ ),
+ ("3D View Tool: OBJECT, Move",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("transform.translate",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY'},
+ {"properties":
+ [("release_confirm", True),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("3D View Tool: OBJECT, Rotate",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("transform.rotate",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY'},
+ {"properties":
+ [("release_confirm", True),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("3D View Tool: OBJECT, Scale",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("transform.resize",
+ {"type": 'EVT_TWEAK_A', "value": 'ANY'},
+ {"properties":
+ [("release_confirm", True),
+ ],
+ },
+ ),
+ ],
+ },
+ ),
+ ("3D View Tool: OBJECT, Ruler/Protractor",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("view3d.ruler_add", {"type": 'EVT_TWEAK_A', "value": 'ANY'}, None),
+ ],
+ },
+ ),
+ ("3D View Tool: PARTICLE, Cursor Click",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("view3d.cursor3d", {"type": 'ACTIONMOUSE', "value": 'CLICK'}, None),
+ ],
+ },
+ ),
+ ("Spot Lamp Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Area Lamp Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ("Target Lamp Widgets",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items":
+ [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ],
+ },
+ ),
+ ]
+
+
+if __name__ == "__main__":
+ import os
+ from bpy_extras.keyconfig_utils import keyconfig_import_from_data
+ keyconfig_import_from_data(os.path.splitext(os.path.basename(__file__))[0], keyconfig_data)
diff --git a/release/scripts/presets/sunsky/classic.py b/release/scripts/presets/sunsky/classic.py
deleted file mode 100644
index edb065d553c..00000000000
--- a/release/scripts/presets/sunsky/classic.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import bpy
-bpy.context.lamp.sky.atmosphere_turbidity = 4.0
-bpy.context.lamp.sky.sky_blend_type = 'ADD'
-bpy.context.lamp.sky.sky_blend = 1.0
-bpy.context.lamp.sky.horizon_brightness = 10.0
-bpy.context.lamp.sky.spread = 1.49011614159e-09
-bpy.context.lamp.sky.sky_color_space = 'SMPTE'
-bpy.context.lamp.sky.sky_exposure = 1.0
-bpy.context.lamp.sky.sun_brightness = 1.00000011921
-bpy.context.lamp.sky.sun_size = 1.00000166893
-bpy.context.lamp.sky.backscattered_light = 0.0
-bpy.context.lamp.sky.sun_intensity = 4.0
-bpy.context.lamp.sky.atmosphere_inscattering = 1.0
-bpy.context.lamp.sky.atmosphere_extinction = 1.0
diff --git a/release/scripts/presets/sunsky/desert.py b/release/scripts/presets/sunsky/desert.py
deleted file mode 100644
index 8dd587a6eaf..00000000000
--- a/release/scripts/presets/sunsky/desert.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import bpy
-bpy.context.lamp.sky.atmosphere_turbidity = 6.0
-bpy.context.lamp.sky.sky_blend_type = 'ADD'
-bpy.context.lamp.sky.sky_blend = 1.0
-bpy.context.lamp.sky.horizon_brightness = 4.99999761581
-bpy.context.lamp.sky.spread = 1.49011614159e-09
-bpy.context.lamp.sky.sky_color_space = 'SMPTE'
-bpy.context.lamp.sky.sky_exposure = 1.0
-bpy.context.lamp.sky.sun_brightness = 1.00000011921
-bpy.context.lamp.sky.sun_size = 4.0
-bpy.context.lamp.sky.backscattered_light = 1.0
-bpy.context.lamp.sky.sun_intensity = 1.0
-bpy.context.lamp.sky.atmosphere_inscattering = 1.0
-bpy.context.lamp.sky.atmosphere_extinction = 1.0
diff --git a/release/scripts/presets/sunsky/mountain.py b/release/scripts/presets/sunsky/mountain.py
deleted file mode 100644
index f0540af8100..00000000000
--- a/release/scripts/presets/sunsky/mountain.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import bpy
-bpy.context.lamp.sky.atmosphere_turbidity = 2.00000023842
-bpy.context.lamp.sky.sky_blend_type = 'ADD'
-bpy.context.lamp.sky.sky_blend = 1.0
-bpy.context.lamp.sky.horizon_brightness = 0.100000016391
-bpy.context.lamp.sky.spread = 1.0
-bpy.context.lamp.sky.sky_color_space = 'SMPTE'
-bpy.context.lamp.sky.sky_exposure = 1.0
-bpy.context.lamp.sky.sun_brightness = 1.99999988079
-bpy.context.lamp.sky.sun_size = 4.0
-bpy.context.lamp.sky.backscattered_light = -1.0
-bpy.context.lamp.sky.sun_intensity = 10.0
-bpy.context.lamp.sky.atmosphere_inscattering = 1.0
-bpy.context.lamp.sky.atmosphere_extinction = 1.0
diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py
index cc7f69ca7ca..4460af173ff 100644
--- a/release/scripts/startup/bl_operators/add_mesh_torus.py
+++ b/release/scripts/startup/bl_operators/add_mesh_torus.py
@@ -134,19 +134,19 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
self.abso_major_rad = self.major_radius + self.minor_radius
self.abso_minor_rad = self.major_radius - self.minor_radius
- major_segments = IntProperty(
+ major_segments: IntProperty(
name="Major Segments",
description="Number of segments for the main ring of the torus",
min=3, max=256,
default=48,
)
- minor_segments = IntProperty(
+ minor_segments: IntProperty(
name="Minor Segments",
description="Number of segments for the minor ring of the torus",
min=3, max=256,
default=12,
)
- mode = bpy.props.EnumProperty(
+ mode: bpy.props.EnumProperty(
name="Torus Dimensions",
items=(("MAJOR_MINOR", "Major/Minor",
"Use the major/minor radii for torus dimensions"),
@@ -154,7 +154,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
"Use the exterior/interior radii for torus dimensions")),
update=mode_update_callback,
)
- major_radius = FloatProperty(
+ major_radius: FloatProperty(
name="Major Radius",
description=("Radius from the origin to the "
"center of the cross sections"),
@@ -163,7 +163,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
subtype='DISTANCE',
unit='LENGTH',
)
- minor_radius = FloatProperty(
+ minor_radius: FloatProperty(
name="Minor Radius",
description="Radius of the torus' cross section",
min=0.01, max=100.0,
@@ -171,7 +171,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
subtype='DISTANCE',
unit='LENGTH',
)
- abso_major_rad = FloatProperty(
+ abso_major_rad: FloatProperty(
name="Exterior Radius",
description="Total Exterior Radius of the torus",
min=0.01, max=100.0,
@@ -179,7 +179,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
subtype='DISTANCE',
unit='LENGTH',
)
- abso_minor_rad = FloatProperty(
+ abso_minor_rad: FloatProperty(
name="Interior Radius",
description="Total Interior Radius of the torus",
min=0.01, max=100.0,
@@ -187,7 +187,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
subtype='DISTANCE',
unit='LENGTH',
)
- generate_uvs = BoolProperty(
+ generate_uvs: BoolProperty(
name="Generate UVs",
description="Generate a default UV map",
default=False,
diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py
index 250c88b9009..31325cf0b50 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -40,20 +40,20 @@ class ANIM_OT_keying_set_export(Operator):
bl_idname = "anim.keying_set_export"
bl_label = "Export Keying Set..."
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
name="Filter folders",
default=True,
options={'HIDDEN'},
)
- filter_text = BoolProperty(
+ filter_text: BoolProperty(
name="Filter text",
default=True,
options={'HIDDEN'},
)
- filter_python = BoolProperty(
+ filter_python: BoolProperty(
name="Filter python",
default=True,
options={'HIDDEN'},
@@ -110,7 +110,7 @@ class ANIM_OT_keying_set_export(Operator):
# - special handling is needed for "nested" ID-blocks
# (e.g. nodetree in Material)
if ksp.id.bl_rna.identifier.startswith("ShaderNodeTree"):
- # Find material or lamp using this node tree...
+ # Find material or light using this node tree...
id_bpy_path = "bpy.data.nodes[\"%s\"]"
found = False
@@ -121,14 +121,14 @@ class ANIM_OT_keying_set_export(Operator):
break
if not found:
- for lamp in bpy.data.lamps:
- if lamp.node_tree == ksp.id:
- id_bpy_path = "bpy.data.lamps[\"%s\"].node_tree" % (lamp.name)
+ for light in bpy.data.lights:
+ if light.node_tree == ksp.id:
+ id_bpy_path = "bpy.data.lights[\"%s\"].node_tree" % (light.name)
found = True
break
if not found:
- self.report({'WARN'}, "Could not find material or lamp using Shader Node Tree - %s" % (ksp.id))
+ self.report({'WARN'}, "Could not find material or light using Shader Node Tree - %s" % (ksp.id))
elif ksp.id.bl_rna.identifier.startswith("CompositorNodeTree"):
# Find compositor nodetree using this node tree...
for scene in bpy.data.scenes:
@@ -203,51 +203,51 @@ class BakeAction(Operator):
bl_label = "Bake Action"
bl_options = {'REGISTER', 'UNDO'}
- frame_start = IntProperty(
+ frame_start: IntProperty(
name="Start Frame",
description="Start frame for baking",
min=0, max=300000,
default=1,
)
- frame_end = IntProperty(
+ frame_end: IntProperty(
name="End Frame",
description="End frame for baking",
min=1, max=300000,
default=250,
)
- step = IntProperty(
+ step: IntProperty(
name="Frame Step",
description="Frame Step",
min=1, max=120,
default=1,
)
- only_selected = BoolProperty(
+ only_selected: BoolProperty(
name="Only Selected Bones",
description="Only key selected bones (Pose baking only)",
default=True,
)
- visual_keying = BoolProperty(
+ visual_keying: BoolProperty(
name="Visual Keying",
description="Keyframe from the final transformations (with constraints applied)",
default=False,
)
- clear_constraints = BoolProperty(
+ clear_constraints: BoolProperty(
name="Clear Constraints",
description="Remove all constraints from keyed object/bones, and do 'visual' keying",
default=False,
)
- clear_parents = BoolProperty(
+ clear_parents: BoolProperty(
name="Clear Parents",
description="Bake animation onto the object then clear parents (objects only)",
default=False,
)
- use_current_action = BoolProperty(
+ use_current_action: BoolProperty(
name="Overwrite Current Action",
description="Bake animation into current action, instead of creating a new one "
"(useful for baking only part of bones in an armature)",
default=False,
)
- bake_types = EnumProperty(
+ bake_types: EnumProperty(
name="Bake Data",
description="Which data's transformations to bake",
options={'ENUM_FLAG'},
@@ -302,7 +302,7 @@ class ClearUselessActions(Operator):
bl_label = "Clear Useless Actions"
bl_options = {'REGISTER', 'UNDO'}
- only_unused = BoolProperty(
+ only_unused: BoolProperty(
name="Only Unused",
description="Only unused (Fake User only) actions get considered",
default=True,
@@ -341,7 +341,7 @@ class UpdateAnimatedTransformConstraint(Operator):
bl_label = "Update Animated Transform Constraints"
bl_options = {'REGISTER', 'UNDO'}
- use_convert_to_radians = BoolProperty(
+ use_convert_to_radians: BoolProperty(
name="Convert To Radians",
description="Convert fcurves/drivers affecting rotations to radians (Warning: use this only once!)",
default=True,
diff --git a/release/scripts/startup/bl_operators/bmesh/find_adjacent.py b/release/scripts/startup/bl_operators/bmesh/find_adjacent.py
index 2e2d4c948d2..5d8011249bc 100644
--- a/release/scripts/startup/bl_operators/bmesh/find_adjacent.py
+++ b/release/scripts/startup/bl_operators/bmesh/find_adjacent.py
@@ -26,7 +26,7 @@ import bmesh
__all__ = (
"select_prev",
"select_next",
- )
+)
def other_edges_over_face(e):
@@ -303,8 +303,9 @@ def select_next(bm, report):
for fn in (pass_fn, set, sum_set, len):
uuid_cmp_test = fn(uuid_cmp)
ele_pair_next_uuid_test = [
- (ele, uuid) for (ele, uuid) in ele_pair_next_uuid
- if uuid_cmp_test == fn(uuid)]
+ (ele, uuid) for (ele, uuid) in ele_pair_next_uuid
+ if uuid_cmp_test == fn(uuid)
+ ]
if len(ele_pair_next_uuid_test) > 1:
ele_pair_next_uuid = ele_pair_next_uuid_test
elif len(ele_pair_next_uuid_test) == 1:
diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py
index 5f3075b403f..2717a4f62a3 100644
--- a/release/scripts/startup/bl_operators/clip.py
+++ b/release/scripts/startup/bl_operators/clip.py
@@ -133,7 +133,7 @@ class CLIP_OT_filter_tracks(bpy.types.Operator):
bl_idname = "clip.filter_tracks"
bl_options = {'UNDO', 'REGISTER'}
- track_threshold = FloatProperty(
+ track_threshold: FloatProperty(
name="Track Threshold",
description="Filter Threshold to select problematic tracks",
default=5.0,
@@ -915,17 +915,17 @@ class CLIP_OT_setup_tracking_scene(Operator):
return [(layers_a[i] | layers_b[i]) for i in range(len(layers_a))]
@staticmethod
- def _createLamp(scene):
- lamp = bpy.data.lamps.new(name="Lamp", type='POINT')
- lampob = bpy.data.objects.new(name="Lamp", object_data=lamp)
- scene.objects.link(lampob)
+ def _createLight(scene):
+ light = bpy.data.lights.new(name="Light", type='POINT')
+ lightob = bpy.data.objects.new(name="Light", object_data=light)
+ scene.objects.link(lightob)
- lampob.matrix_local = Matrix.Translation((4.076, 1.005, 5.904))
+ lightob.matrix_local = Matrix.Translation((4.076, 1.005, 5.904))
- lamp.distance = 30
- lamp.shadow_method = 'RAY_SHADOW'
+ light.distance = 30
+ light.shadow_method = 'RAY_SHADOW'
- return lampob
+ return lightob
def _createSampleObject(self, scene):
vertices = self._getPlaneVertices(1.0, -1.0) + \
@@ -947,20 +947,20 @@ class CLIP_OT_setup_tracking_scene(Operator):
all_layers = self._mergeLayers(fg.layers, bg.layers)
- # ensure all lamps are active on foreground and background
- has_lamp = False
+ # ensure all lights are active on foreground and background
+ has_light = False
has_mesh = False
for ob in scene.objects:
- if ob.type == 'LAMP':
+ if ob.type == 'LIGHT':
ob.layers = all_layers
- has_lamp = True
+ has_light = True
elif ob.type == 'MESH' and "is_ground" not in ob:
has_mesh = True
- # create sample lamp if there's no lamps in the scene
- if not has_lamp:
- lamp = self._createLamp(scene)
- lamp.layers = all_layers
+ # create sample light if there's no lights in the scene
+ if not has_light:
+ light = self._createLight(scene)
+ light.layers = all_layers
# create sample object if there's no meshes in the scene
if not has_mesh:
diff --git a/release/scripts/startup/bl_operators/console.py b/release/scripts/startup/bl_operators/console.py
index 2d32f84805e..b62b9310224 100644
--- a/release/scripts/startup/bl_operators/console.py
+++ b/release/scripts/startup/bl_operators/console.py
@@ -37,7 +37,7 @@ class ConsoleExec(Operator):
bl_idname = "console.execute"
bl_label = "Console Execute"
- interactive = BoolProperty(
+ interactive: BoolProperty(
options={'SKIP_SAVE'},
)
@@ -137,7 +137,7 @@ class ConsoleLanguage(Operator):
bl_idname = "console.language"
bl_label = "Console Language"
- language = StringProperty(
+ language: StringProperty(
name="Language",
maxlen=32,
)
diff --git a/release/scripts/startup/bl_operators/file.py b/release/scripts/startup/bl_operators/file.py
index cf03b4fccdb..44948879fe6 100644
--- a/release/scripts/startup/bl_operators/file.py
+++ b/release/scripts/startup/bl_operators/file.py
@@ -37,56 +37,56 @@ class WM_OT_previews_batch_generate(Operator):
# -----------
# File props.
- files = CollectionProperty(
+ files: CollectionProperty(
type=bpy.types.OperatorFileListElement,
options={'HIDDEN', 'SKIP_SAVE'},
)
- directory = StringProperty(
+ directory: StringProperty(
maxlen=1024,
subtype='FILE_PATH',
options={'HIDDEN', 'SKIP_SAVE'},
)
# Show only images/videos, and directories!
- filter_blender = BoolProperty(
+ filter_blender: BoolProperty(
default=True,
options={'HIDDEN', 'SKIP_SAVE'},
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
default=True,
options={'HIDDEN', 'SKIP_SAVE'},
)
# -----------
# Own props.
- use_scenes = BoolProperty(
+ use_scenes: BoolProperty(
default=True,
name="Scenes",
description="Generate scenes' previews",
)
- use_collections = BoolProperty(
+ use_collections: BoolProperty(
default=True,
name="Collections",
description="Generate collections' previews",
)
- use_objects = BoolProperty(
+ use_objects: BoolProperty(
default=True,
name="Objects",
description="Generate objects' previews",
)
- use_intern_data = BoolProperty(
+ use_intern_data: BoolProperty(
default=True,
name="Mat/Tex/...",
description="Generate 'internal' previews (materials, textures, images, etc.)",
)
- use_trusted = BoolProperty(
+ use_trusted: BoolProperty(
default=False,
name="Trusted Blend Files",
description="Enable python evaluation for selected files",
)
- use_backups = BoolProperty(
+ use_backups: BoolProperty(
default=True,
name="Save Backups",
description="Keep a backup (.blend1) version of the files when saving with generated previews",
@@ -147,56 +147,56 @@ class WM_OT_previews_batch_clear(Operator):
# -----------
# File props.
- files = CollectionProperty(
+ files: CollectionProperty(
type=bpy.types.OperatorFileListElement,
options={'HIDDEN', 'SKIP_SAVE'},
)
- directory = StringProperty(
+ directory: StringProperty(
maxlen=1024,
subtype='FILE_PATH',
options={'HIDDEN', 'SKIP_SAVE'},
)
# Show only images/videos, and directories!
- filter_blender = BoolProperty(
+ filter_blender: BoolProperty(
default=True,
options={'HIDDEN', 'SKIP_SAVE'},
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
default=True,
options={'HIDDEN', 'SKIP_SAVE'},
)
# -----------
# Own props.
- use_scenes = BoolProperty(
+ use_scenes: BoolProperty(
default=True,
name="Scenes",
description="Clear scenes' previews",
)
- use_collections = BoolProperty(
+ use_collections: BoolProperty(
default=True,
name="Collections",
description="Clear collections' previews",
)
- use_objects = BoolProperty(
+ use_objects: BoolProperty(
default=True,
name="Objects",
description="Clear objects' previews",
)
- use_intern_data = BoolProperty(
+ use_intern_data: BoolProperty(
default=True,
name="Mat/Tex/...",
description="Clear 'internal' previews (materials, textures, images, etc.)",
)
- use_trusted = BoolProperty(
+ use_trusted: BoolProperty(
default=False,
name="Trusted Blend Files",
description="Enable python evaluation for selected files",
)
- use_backups = BoolProperty(
+ use_backups: BoolProperty(
default=True,
name="Save Backups",
description="Keep a backup (.blend1) version of the files when saving with cleared previews",
diff --git a/release/scripts/startup/bl_operators/freestyle.py b/release/scripts/startup/bl_operators/freestyle.py
index 88368792b8b..894808de3ed 100644
--- a/release/scripts/startup/bl_operators/freestyle.py
+++ b/release/scripts/startup/bl_operators/freestyle.py
@@ -34,13 +34,13 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
bl_label = "Fill Range by Selection"
bl_options = {'INTERNAL'}
- type = EnumProperty(
+ type: EnumProperty(
name="Type", description="Type of the modifier to work on",
items=(("COLOR", "Color", "Color modifier type"),
("ALPHA", "Alpha", "Alpha modifier type"),
("THICKNESS", "Thickness", "Thickness modifier type")),
)
- name = StringProperty(
+ name: StringProperty(
name="Name",
description="Name of the modifier to work on",
)
@@ -198,9 +198,9 @@ class SCENE_OT_freestyle_module_open(bpy.types.Operator):
bl_label = "Open Style Module File"
bl_options = {'INTERNAL'}
- filepath = StringProperty(subtype='FILE_PATH')
+ filepath: StringProperty(subtype='FILE_PATH')
- make_internal = BoolProperty(
+ make_internal: BoolProperty(
name="Make internal",
description="Make module file internal after loading",
default=True)
diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py
index 5c5ca329cda..28e5e59d780 100644
--- a/release/scripts/startup/bl_operators/image.py
+++ b/release/scripts/startup/bl_operators/image.py
@@ -29,7 +29,7 @@ class EditExternally(Operator):
bl_label = "Image Edit Externally"
bl_options = {'REGISTER'}
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
)
diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py
index 87b589a5d46..1149d7a0dfb 100644
--- a/release/scripts/startup/bl_operators/mesh.py
+++ b/release/scripts/startup/bl_operators/mesh.py
@@ -33,7 +33,7 @@ class MeshMirrorUV(Operator):
bl_label = "Copy Mirrored UV coords"
bl_options = {'REGISTER', 'UNDO'}
- direction = EnumProperty(
+ direction: EnumProperty(
name="Axis Direction",
items=(
('POSITIVE', "Positive", ""),
@@ -41,7 +41,7 @@ class MeshMirrorUV(Operator):
),
)
- precision = IntProperty(
+ precision: IntProperty(
name="Precision",
description=("Tolerance for finding vertex duplicates"),
min=1, max=16,
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index bb8f991e526..fbebee2d8a1 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -34,7 +34,7 @@ from bpy.props import (
class NodeSetting(PropertyGroup):
- value = StringProperty(
+ value: StringProperty(
name="Value",
description="Python expression to be evaluated "
"as the initial node setting",
@@ -45,16 +45,16 @@ class NodeSetting(PropertyGroup):
# Base class for node 'Add' operators
class NodeAddOperator:
- type = StringProperty(
+ type: StringProperty(
name="Node Type",
description="Node type",
)
- use_transform = BoolProperty(
+ use_transform: BoolProperty(
name="Use Transform",
description="Start transform operator after inserting the node",
default=False,
)
- settings = CollectionProperty(
+ settings: CollectionProperty(
name="Settings",
description="Settings to be applied on the newly created node",
type=NodeSetting,
@@ -152,7 +152,7 @@ class NODE_OT_add_and_link_node(NodeAddOperator, Operator):
bl_label = "Add and Link Node"
bl_options = {'REGISTER', 'UNDO'}
- link_socket_index = IntProperty(
+ link_socket_index: IntProperty(
name="Link Socket Index",
description="Index of the socket to link",
)
@@ -210,7 +210,7 @@ class NODE_OT_add_search(NodeAddOperator, Operator):
return item
return None
- node_item = EnumProperty(
+ node_item: EnumProperty(
name="Node Type",
description="Node type",
items=node_enum_items,
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index fb321463d33..be379ec6089 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -35,19 +35,19 @@ class SelectPattern(Operator):
bl_label = "Select Pattern"
bl_options = {'REGISTER', 'UNDO'}
- pattern = StringProperty(
+ pattern: StringProperty(
name="Pattern",
description="Name filter using '*', '?' and "
"'[abc]' unix style wildcards",
maxlen=64,
default="*",
)
- case_sensitive = BoolProperty(
+ case_sensitive: BoolProperty(
name="Case Sensitive",
description="Do a case sensitive compare",
default=False,
)
- extend = BoolProperty(
+ extend: BoolProperty(
name="Extend",
description="Extend the existing selection",
default=True,
@@ -115,7 +115,7 @@ class SelectCamera(Operator):
bl_label = "Select Camera"
bl_options = {'REGISTER', 'UNDO'}
- extend = BoolProperty(
+ extend: BoolProperty(
name="Extend",
description="Extend the selection",
default=False
@@ -152,15 +152,15 @@ class SelectHierarchy(Operator):
bl_label = "Select Hierarchy"
bl_options = {'REGISTER', 'UNDO'}
- direction = EnumProperty(
+ direction: EnumProperty(
items=(('PARENT', "Parent", ""),
('CHILD', "Child", ""),
),
name="Direction",
description="Direction to select in the hierarchy",
- default='PARENT')
-
- extend = BoolProperty(
+ default='PARENT',
+ )
+ extend: BoolProperty(
name="Extend",
description="Extend the existing selection",
default=False,
@@ -221,14 +221,13 @@ class SubdivisionSet(Operator):
bl_label = "Subdivision Set"
bl_options = {'REGISTER', 'UNDO'}
- level = IntProperty(
+ level: IntProperty(
name="Level",
min=-100, max=100,
soft_min=-6, soft_max=6,
default=1,
)
-
- relative = BoolProperty(
+ relative: BoolProperty(
name="Relative",
description=("Apply the subsurf level as an offset "
"relative to the current level"),
@@ -312,7 +311,7 @@ class ShapeTransfer(Operator):
bl_label = "Transfer Shape Key"
bl_options = {'REGISTER', 'UNDO'}
- mode = EnumProperty(
+ mode: EnumProperty(
items=(('OFFSET',
"Offset",
"Apply the relative positional offset",
@@ -330,7 +329,7 @@ class ShapeTransfer(Operator):
description="Relative shape positions to the new shape method",
default='OFFSET',
)
- use_clamp = BoolProperty(
+ use_clamp: BoolProperty(
name="Clamp Offset",
description=("Clamp the transformation to the distance each "
"vertex moves in the original shape"),
@@ -696,7 +695,7 @@ class TransformsToDeltas(Operator):
bl_label = "Transforms to Deltas"
bl_options = {'REGISTER', 'UNDO'}
- mode = EnumProperty(
+ mode: EnumProperty(
items=(
('ALL', "All Transforms", "Transfer location, rotation, and scale transforms"),
('LOC', "Location", "Transfer location transforms only"),
@@ -707,7 +706,7 @@ class TransformsToDeltas(Operator):
description="Which transforms to transfer",
default='ALL',
)
- reset_values = BoolProperty(
+ reset_values: BoolProperty(
name="Reset Values",
description=("Clear transform values after transferring to deltas"),
default=True,
diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py
index 11c1514e4bf..f627fd30162 100644
--- a/release/scripts/startup/bl_operators/object_align.py
+++ b/release/scripts/startup/bl_operators/object_align.py
@@ -363,7 +363,7 @@ class AlignObjects(Operator):
bl_label = "Align Objects"
bl_options = {'REGISTER', 'UNDO'}
- bb_quality = BoolProperty(
+ bb_quality: BoolProperty(
name="High Quality",
description=(
"Enables high quality calculation of the "
@@ -372,7 +372,7 @@ class AlignObjects(Operator):
),
default=True,
)
- align_mode = EnumProperty(
+ align_mode: EnumProperty(
name="Align Mode:",
description="Side of object to use for alignment",
items=(
@@ -382,7 +382,7 @@ class AlignObjects(Operator):
),
default='OPT_2',
)
- relative_to = EnumProperty(
+ relative_to: EnumProperty(
name="Relative To:",
description="Reference location to align to",
items=(
@@ -393,7 +393,7 @@ class AlignObjects(Operator):
),
default='OPT_4',
)
- align_axis = EnumProperty(
+ align_axis: EnumProperty(
name="Align",
description="Align to axis",
items=(
diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py
index f087022b6fd..36dc1b46590 100644
--- a/release/scripts/startup/bl_operators/object_quick_effects.py
+++ b/release/scripts/startup/bl_operators/object_quick_effects.py
@@ -52,7 +52,7 @@ class QuickFur(Operator):
bl_label = "Quick Fur"
bl_options = {'REGISTER', 'UNDO'}
- density = EnumProperty(
+ density: EnumProperty(
name="Fur Density",
items=(
('LIGHT', "Light", ""),
@@ -61,13 +61,13 @@ class QuickFur(Operator):
),
default='MEDIUM',
)
- view_percentage = IntProperty(
+ view_percentage: IntProperty(
name="View %",
min=1, max=100,
soft_min=1, soft_max=100,
default=10,
)
- length = FloatProperty(
+ length: FloatProperty(
name="Length",
min=0.001, max=100,
soft_min=0.01, soft_max=10,
@@ -118,7 +118,7 @@ class QuickExplode(Operator):
bl_label = "Quick Explode"
bl_options = {'REGISTER', 'UNDO'}
- style = EnumProperty(
+ style: EnumProperty(
name="Explode Style",
items=(
('EXPLODE', "Explode", ""),
@@ -126,40 +126,40 @@ class QuickExplode(Operator):
),
default='EXPLODE',
)
- amount = IntProperty(
+ amount: IntProperty(
name="Amount of pieces",
min=2, max=10000,
soft_min=2, soft_max=10000,
default=100,
)
- frame_duration = IntProperty(
+ frame_duration: IntProperty(
name="Duration",
min=1, max=300000,
soft_min=1, soft_max=10000,
default=50,
)
- frame_start = IntProperty(
+ frame_start: IntProperty(
name="Start Frame",
min=1, max=300000,
soft_min=1, soft_max=10000,
default=1,
)
- frame_end = IntProperty(
+ frame_end: IntProperty(
name="End Frame",
min=1, max=300000,
soft_min=1, soft_max=10000,
default=10,
)
- velocity = FloatProperty(
+ velocity: FloatProperty(
name="Outwards Velocity",
min=0, max=300000,
soft_min=0, soft_max=10,
default=1,
)
- fade = BoolProperty(
+ fade: BoolProperty(
name="Fade",
description="Fade the pieces over time",
default=True,
@@ -306,7 +306,7 @@ class QuickSmoke(Operator):
bl_label = "Quick Smoke"
bl_options = {'REGISTER', 'UNDO'}
- style = EnumProperty(
+ style: EnumProperty(
name="Smoke Style",
items=(
('SMOKE', "Smoke", ""),
@@ -316,7 +316,7 @@ class QuickSmoke(Operator):
default='SMOKE',
)
- show_flows = BoolProperty(
+ show_flows: BoolProperty(
name="Render Smoke Objects",
description="Keep the smoke objects visible during rendering",
default=False,
@@ -410,7 +410,7 @@ class QuickFluid(Operator):
bl_label = "Quick Fluid"
bl_options = {'REGISTER', 'UNDO'}
- style = EnumProperty(
+ style: EnumProperty(
name="Fluid Style",
items=(
('INFLOW', "Inflow", ""),
@@ -418,19 +418,19 @@ class QuickFluid(Operator):
),
default='BASIC',
)
- initial_velocity = FloatVectorProperty(
+ initial_velocity: FloatVectorProperty(
name="Initial Velocity",
description="Initial velocity of the fluid",
min=-100.0, max=100.0,
default=(0.0, 0.0, 0.0),
subtype='VELOCITY',
)
- show_flows = BoolProperty(
+ show_flows: BoolProperty(
name="Render Fluid Objects",
description="Keep the fluid objects visible during rendering",
default=False,
)
- start_baking = BoolProperty(
+ start_baking: BoolProperty(
name="Start Fluid Bake",
description=("Start baking the fluid immediately "
"after creating the domain object"),
diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py
index dbc9461ad5a..6e2dad079ee 100644
--- a/release/scripts/startup/bl_operators/object_randomize_transform.py
+++ b/release/scripts/startup/bl_operators/object_randomize_transform.py
@@ -103,25 +103,25 @@ class RandomizeLocRotSize(Operator):
bl_label = "Randomize Transform"
bl_options = {'REGISTER', 'UNDO'}
- random_seed = IntProperty(
+ random_seed: IntProperty(
name="Random Seed",
description="Seed value for the random generator",
min=0,
max=10000,
default=0,
)
- use_delta = BoolProperty(
+ use_delta: BoolProperty(
name="Transform Delta",
description=("Randomize delta transform values "
"instead of regular transform"),
default=False,
)
- use_loc = BoolProperty(
+ use_loc: BoolProperty(
name="Randomize Location",
description="Randomize the location values",
default=True,
)
- loc = FloatVectorProperty(
+ loc: FloatVectorProperty(
name="Location",
description=("Maximum distance the objects "
"can spread over each axis"),
@@ -130,12 +130,12 @@ class RandomizeLocRotSize(Operator):
default=(0.0, 0.0, 0.0),
subtype='TRANSLATION',
)
- use_rot = BoolProperty(
+ use_rot: BoolProperty(
name="Randomize Rotation",
description="Randomize the rotation values",
default=True,
)
- rot = FloatVectorProperty(
+ rot: FloatVectorProperty(
name="Rotation",
description="Maximum rotation over each axis",
min=-3.141592, # math.pi
@@ -143,25 +143,25 @@ class RandomizeLocRotSize(Operator):
default=(0.0, 0.0, 0.0),
subtype='EULER',
)
- use_scale = BoolProperty(
+ use_scale: BoolProperty(
name="Randomize Scale",
description="Randomize the scale values",
default=True,
)
- scale_even = BoolProperty(
+ scale_even: BoolProperty(
name="Scale Even",
description="Use the same scale value for all axis",
default=False,
)
- '''scale_min = FloatProperty(
+ '''scale_min: FloatProperty(
name="Minimun Scale Factor",
description="Lowest scale percentage possible",
min=-1.0, max=1.0, precision=3,
default=0.15,
)'''
- scale = FloatVectorProperty(
+ scale: FloatVectorProperty(
name="Scale",
description="Maximum scale randomization over each axis",
min=-100.0,
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 780183fb713..530194e5bb7 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -41,28 +41,21 @@ class AddPresetBase:
# only because invoke_props_popup requires. Also do not add to search menu.
bl_options = {'REGISTER', 'INTERNAL'}
- name = StringProperty(
+ name: StringProperty(
name="Name",
description="Name of the preset, used to make the path name",
maxlen=64,
options={'SKIP_SAVE'},
)
- remove_name = BoolProperty(
+ remove_name: BoolProperty(
default=False,
options={'HIDDEN', 'SKIP_SAVE'},
)
- remove_active = BoolProperty(
+ remove_active: BoolProperty(
default=False,
options={'HIDDEN', 'SKIP_SAVE'},
)
- # needed for mix-ins
- order = [
- "name",
- "remove_name",
- "remove_active",
- ]
-
@staticmethod
def as_filename(name): # could reuse for other presets
@@ -225,11 +218,11 @@ class ExecutePreset(Operator):
bl_idname = "script.execute_preset"
bl_label = "Execute a Python Preset"
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
options={'SKIP_SAVE'},
)
- menu_idname = StringProperty(
+ menu_idname: StringProperty(
name="Menu ID Name",
description="ID name of the menu this was called from",
options={'SKIP_SAVE'},
@@ -264,15 +257,13 @@ class PresetMenu(Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'HEADER'
bl_label = "Presets"
- path_menu = Menu.path_menu
+ path_menu: Menu.path_menu
@classmethod
def draw_panel_header(cls, layout):
layout.emboss = 'NONE'
layout.popover(
- cls.bl_space_type,
- cls.bl_region_type,
- cls.__name__,
+ panel=cls.__name__,
icon='PRESET',
text="",
)
@@ -283,9 +274,7 @@ class PresetMenu(Panel):
text = cls.bl_label
layout.popover(
- cls.bl_space_type,
- cls.bl_region_type,
- cls.__name__,
+ panel=cls.__name__,
icon='PRESET',
text=text,
)
@@ -333,7 +322,7 @@ class AddPresetCamera(AddPresetBase, Operator):
preset_subdir = "camera"
- use_focal_length = BoolProperty(
+ use_focal_length: BoolProperty(
name="Include Focal Length",
description="Include focal length into the preset",
options={'SKIP_SAVE'},
@@ -480,7 +469,7 @@ class AddPresetTrackingCamera(AddPresetBase, Operator):
preset_subdir = "tracking_camera"
- use_focal_length = BoolProperty(
+ use_focal_length: BoolProperty(
name="Include Focal Length",
description="Include focal length into the preset",
options={'SKIP_SAVE'},
@@ -605,7 +594,7 @@ class AddPresetOperator(AddPresetBase, Operator):
bl_label = "Operator Preset"
preset_menu = "WM_MT_operator_presets"
- operator = StringProperty(
+ operator: StringProperty(
name="Operator",
maxlen=64,
options={'HIDDEN', 'SKIP_SAVE'},
diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py
index 9fa8188e946..36150a63895 100644
--- a/release/scripts/startup/bl_operators/rigidbody.py
+++ b/release/scripts/startup/bl_operators/rigidbody.py
@@ -92,19 +92,19 @@ class BakeToKeyframes(Operator):
bl_label = "Bake To Keyframes"
bl_options = {'REGISTER', 'UNDO'}
- frame_start = IntProperty(
+ frame_start: IntProperty(
name="Start Frame",
description="Start frame for baking",
min=0, max=300000,
default=1,
)
- frame_end = IntProperty(
+ frame_end: IntProperty(
name="End Frame",
description="End frame for baking",
min=1, max=300000,
default=250,
)
- step = IntProperty(
+ step: IntProperty(
name="Frame Step",
description="Frame Step",
min=1, max=120,
@@ -216,7 +216,7 @@ class ConnectRigidBodies(Operator):
bl_label = "Connect Rigid Bodies"
bl_options = {'REGISTER', 'UNDO'}
- con_type = EnumProperty(
+ con_type: EnumProperty(
name="Type",
description="Type of generated constraint",
# XXX Would be nice to get icons too, but currently not possible ;)
@@ -226,7 +226,7 @@ class ConnectRigidBodies(Operator):
),
default='FIXED',
)
- pivot_type = EnumProperty(
+ pivot_type: EnumProperty(
name="Location",
description="Constraint pivot location",
items=(
@@ -236,7 +236,7 @@ class ConnectRigidBodies(Operator):
),
default='CENTER',
)
- connection_pattern = EnumProperty(
+ connection_pattern: EnumProperty(
name="Connection Pattern",
description="Pattern used to connect objects",
items=(
diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
index 46cf07be0f5..27c8487eaa9 100644
--- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
+++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
@@ -149,7 +149,7 @@ class PlayRenderedAnim(Operator):
opts = [file, f"{scene.frame_start:d}-{scene.frame_end:d}"]
cmd.extend(opts)
elif preset == 'RV':
- opts = ["-fps", str(rd.fps), "-play", f"[ {file} ]"]
+ opts = ["-fps", str(rd.fps), "-play", f"[ {file:s} ]"]
cmd.extend(opts)
elif preset == 'MPLAYER':
opts = []
diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py
index c9a7aa93805..b1152157cf8 100644
--- a/release/scripts/startup/bl_operators/sequencer.py
+++ b/release/scripts/startup/bl_operators/sequencer.py
@@ -82,7 +82,7 @@ class SequencerCutMulticam(Operator):
bl_label = "Cut multicam"
bl_options = {'REGISTER', 'UNDO'}
- camera = IntProperty(
+ camera: IntProperty(
name="Camera",
min=1, max=32,
soft_min=1, soft_max=32,
diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py
index 7620b354a08..5c870849cc5 100644
--- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py
+++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py
@@ -226,7 +226,7 @@ class FollowActiveQuads(Operator):
bl_label = "Follow Active Quads"
bl_options = {'REGISTER', 'UNDO'}
- mode = bpy.props.EnumProperty(
+ mode: bpy.props.EnumProperty(
name="Edge Length Mode",
description="Method to space UV edge loops",
items=(('EVEN', "Even", "Space all UVs evenly"),
diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py
index 0d5bc3136a5..95a3d18304b 100644
--- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py
+++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py
@@ -616,7 +616,7 @@ class LightMapPack(Operator):
# This fixes infinite image creation reported there [#30968] (sergey)
bl_options = {'UNDO'}
- PREF_CONTEXT = bpy.props.EnumProperty(
+ PREF_CONTEXT: bpy.props.EnumProperty(
name="Selection",
items=(
('SEL_FACES', "Selected Faces", "Space all UVs evenly"),
@@ -626,7 +626,7 @@ class LightMapPack(Operator):
)
# Image & UVs...
- PREF_PACK_IN_ONE = BoolProperty(
+ PREF_PACK_IN_ONE: BoolProperty(
name="Share Tex Space",
description=(
"Objects Share texture space, map all objects "
@@ -634,12 +634,12 @@ class LightMapPack(Operator):
),
default=True,
)
- PREF_NEW_UVLAYER = BoolProperty(
+ PREF_NEW_UVLAYER: BoolProperty(
name="New UV Map",
description="Create a new UV map for every mesh packed",
default=False,
)
- PREF_APPLY_IMAGE = BoolProperty(
+ PREF_APPLY_IMAGE: BoolProperty(
name="New Image",
description=(
"Assign new images for every mesh (only one if "
@@ -647,20 +647,20 @@ class LightMapPack(Operator):
),
default=False,
)
- PREF_IMG_PX_SIZE = IntProperty(
+ PREF_IMG_PX_SIZE: IntProperty(
name="Image Size",
description="Width and Height for the new image",
min=64, max=5000,
default=512,
)
# UV Packing...
- PREF_BOX_DIV = IntProperty(
+ PREF_BOX_DIV: IntProperty(
name="Pack Quality",
description="Pre Packing before the complex boxpack",
min=1, max=48,
default=12,
)
- PREF_MARGIN_DIV = FloatProperty(
+ PREF_MARGIN_DIV: FloatProperty(
name="Margin",
description="Size of the margin as a division of the UV",
min=0.001, max=1.0,
diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
index aebc0ae0313..fe15b9fa345 100644
--- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py
+++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
@@ -1055,31 +1055,31 @@ class SmartProject(Operator):
bl_label = "Smart UV Project"
bl_options = {'REGISTER', 'UNDO'}
- angle_limit = FloatProperty(
+ angle_limit: FloatProperty(
name="Angle Limit",
description="Lower for more projection groups, higher for less distortion",
min=1.0, max=89.0,
default=66.0,
)
- island_margin = FloatProperty(
+ island_margin: FloatProperty(
name="Island Margin",
description="Margin to reduce bleed from adjacent islands",
unit='LENGTH', subtype='DISTANCE',
min=0.0, max=1.0,
default=0.0,
)
- user_area_weight = FloatProperty(
+ user_area_weight: FloatProperty(
name="Area Weight",
description="Weight projections vector by faces with larger areas",
min=0.0, max=1.0,
default=0.0,
)
- use_aspect = BoolProperty(
+ use_aspect: BoolProperty(
name="Correct Aspect",
description="Map UVs taking image aspect ratio into account",
default=True
)
- stretch_to_bounds = BoolProperty(
+ stretch_to_bounds: BoolProperty(
name="Stretch to UV Bounds",
description="Stretch the final output to texture bounds",
default=True,
diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
index 1173e0047bb..335c3d8bbda 100644
--- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py
+++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
@@ -138,33 +138,33 @@ class VertexPaintDirt(Operator):
bl_label = "Dirty Vertex Colors"
bl_options = {'REGISTER', 'UNDO'}
- blur_strength = FloatProperty(
+ blur_strength: FloatProperty(
name="Blur Strength",
description="Blur strength per iteration",
min=0.01, max=1.0,
default=1.0,
)
- blur_iterations = IntProperty(
+ blur_iterations: IntProperty(
name="Blur Iterations",
description="Number of times to blur the colors (higher blurs more)",
min=0, max=40,
default=1,
)
- clean_angle = FloatProperty(
+ clean_angle: FloatProperty(
name="Highlight Angle",
description="Less than 90 limits the angle used in the tonal range",
min=0.0, max=pi,
default=pi,
unit="ROTATION",
)
- dirt_angle = FloatProperty(
+ dirt_angle: FloatProperty(
name="Dirt Angle",
description="Less than 90 limits the angle used in the tonal range",
min=0.0, max=pi,
default=0.0,
unit="ROTATION",
)
- dirt_only = BoolProperty(
+ dirt_only: BoolProperty(
name="Dirt Only",
description="Don't calculate cleans for convex areas",
default=False,
diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py
index f56c83be7d1..b43f4446802 100644
--- a/release/scripts/startup/bl_operators/view3d.py
+++ b/release/scripts/startup/bl_operators/view3d.py
@@ -143,37 +143,37 @@ class VIEW3D_OT_select_or_deselect_all(Operator):
bl_idname = "view3d.select_or_deselect_all"
bl_options = {'UNDO'}
- extend = BoolProperty(
+ extend: BoolProperty(
name="Extend",
description="Extend selection instead of deselecting everything first",
default=False,
)
- toggle = BoolProperty(
+ toggle: BoolProperty(
name="Toggle",
description="Toggle the selection",
default=False,
)
- deselect = BoolProperty(
+ deselect: BoolProperty(
name="Deselect",
description="Remove from selection",
default=False,
)
- center = BoolProperty(
+ center: BoolProperty(
name="Center",
description="Use the object center when selecting, in editmode used to extend object selection",
default=False,
)
- enumerate = BoolProperty(
+ enumerate: BoolProperty(
name="Enumerate",
description="List objects under the mouse (object mode only)",
default=False,
)
- object = BoolProperty(
+ object: BoolProperty(
name="Object",
description="Use object selection (editmode only)",
default=False,
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 440beaaa240..0ccdd3cf5c6 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -162,12 +162,12 @@ class BRUSH_OT_active_index_set(Operator):
bl_idname = "brush.active_index_set"
bl_label = "Set Brush Number"
- mode = StringProperty(
+ mode: StringProperty(
name="Mode",
description="Paint mode to set brush for",
maxlen=1024,
)
- index = IntProperty(
+ index: IntProperty(
name="Number",
description="Brush number",
)
@@ -199,8 +199,8 @@ class WM_OT_context_set_boolean(Operator):
bl_label = "Context Set Boolean"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = BoolProperty(
+ data_path: rna_path_prop
+ value: BoolProperty(
name="Value",
description="Assignment value",
default=True,
@@ -215,13 +215,13 @@ class WM_OT_context_set_int(Operator): # same as enum
bl_label = "Context Set"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = IntProperty(
+ data_path: rna_path_prop
+ value: IntProperty(
name="Value",
description="Assign value",
default=0,
)
- relative = rna_relative_prop
+ relative: rna_relative_prop
execute = execute_context_assign
@@ -232,8 +232,8 @@ class WM_OT_context_scale_float(Operator):
bl_label = "Context Scale Float"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = FloatProperty(
+ data_path: rna_path_prop
+ value: FloatProperty(
name="Value",
description="Assign value",
default=1.0,
@@ -260,13 +260,13 @@ class WM_OT_context_scale_int(Operator):
bl_label = "Context Scale Int"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = FloatProperty(
+ data_path: rna_path_prop
+ value: FloatProperty(
name="Value",
description="Assign value",
default=1.0,
)
- always_step = BoolProperty(
+ always_step: BoolProperty(
name="Always Step",
description="Always adjust the value by a minimum of 1 when 'value' is not 1.0",
default=True,
@@ -303,13 +303,13 @@ class WM_OT_context_set_float(Operator): # same as enum
bl_label = "Context Set Float"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = FloatProperty(
+ data_path: rna_path_prop
+ value: FloatProperty(
name="Value",
description="Assignment value",
default=0.0,
)
- relative = rna_relative_prop
+ relative: rna_relative_prop
execute = execute_context_assign
@@ -320,8 +320,8 @@ class WM_OT_context_set_string(Operator): # same as enum
bl_label = "Context Set String"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = StringProperty(
+ data_path: rna_path_prop
+ value: StringProperty(
name="Value",
description="Assign value",
maxlen=1024,
@@ -336,8 +336,8 @@ class WM_OT_context_set_enum(Operator):
bl_label = "Context Set Enum"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = StringProperty(
+ data_path: rna_path_prop
+ value: StringProperty(
name="Value",
description="Assignment value (as a string)",
maxlen=1024,
@@ -352,8 +352,8 @@ class WM_OT_context_set_value(Operator):
bl_label = "Context Set Value"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = StringProperty(
+ data_path: rna_path_prop
+ value: StringProperty(
name="Value",
description="Assignment value (as a string)",
maxlen=1024,
@@ -373,7 +373,7 @@ class WM_OT_context_toggle(Operator):
bl_label = "Context Toggle"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
+ data_path: rna_path_prop
def execute(self, context):
data_path = self.data_path
@@ -392,13 +392,13 @@ class WM_OT_context_toggle_enum(Operator):
bl_label = "Context Toggle Values"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value_1 = StringProperty(
+ data_path: rna_path_prop
+ value_1: StringProperty(
name="Value",
description="Toggle enum",
maxlen=1024,
)
- value_2 = StringProperty(
+ value_2: StringProperty(
name="Value",
description="Toggle enum",
maxlen=1024,
@@ -431,9 +431,9 @@ class WM_OT_context_cycle_int(Operator):
bl_label = "Context Int Cycle"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- reverse = rna_reverse_prop
- wrap = rna_wrap_prop
+ data_path: rna_path_prop
+ reverse: rna_reverse_prop
+ wrap: rna_wrap_prop
def execute(self, context):
data_path = self.data_path
@@ -467,9 +467,9 @@ class WM_OT_context_cycle_enum(Operator):
bl_label = "Context Enum Cycle"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- reverse = rna_reverse_prop
- wrap = rna_wrap_prop
+ data_path: rna_path_prop
+ reverse: rna_reverse_prop
+ wrap: rna_wrap_prop
def execute(self, context):
data_path = self.data_path
@@ -524,8 +524,8 @@ class WM_OT_context_cycle_array(Operator):
bl_label = "Context Array Cycle"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- reverse = rna_reverse_prop
+ data_path: rna_path_prop
+ reverse: rna_reverse_prop
def execute(self, context):
data_path = self.data_path
@@ -549,7 +549,8 @@ class WM_OT_context_menu_enum(Operator):
bl_idname = "wm.context_menu_enum"
bl_label = "Context Enum Menu"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
+
+ data_path: rna_path_prop
def execute(self, context):
data_path = self.data_path
@@ -575,7 +576,8 @@ class WM_OT_context_pie_enum(Operator):
bl_idname = "wm.context_pie_enum"
bl_label = "Context Enum Pie"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
+
+ data_path: rna_path_prop
def invoke(self, context, event):
wm = context.window_manager
@@ -602,12 +604,13 @@ class WM_OT_operator_pie_enum(Operator):
bl_idname = "wm.operator_pie_enum"
bl_label = "Operator Enum Pie"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = StringProperty(
+
+ data_path: StringProperty(
name="Operator",
description="Operator name (in python as string)",
maxlen=1024,
)
- prop_string = StringProperty(
+ prop_string: StringProperty(
name="Property",
description="Property name (as a string)",
maxlen=1024,
@@ -646,8 +649,8 @@ class WM_OT_context_set_id(Operator):
bl_label = "Set Library ID"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path_prop
- value = StringProperty(
+ data_path: rna_path_prop
+ value: StringProperty(
name="Value",
description="Assign value",
maxlen=1024,
@@ -697,10 +700,10 @@ class WM_OT_context_collection_boolean_set(Operator):
bl_label = "Context Collection Boolean Set"
bl_options = {'UNDO', 'REGISTER', 'INTERNAL'}
- data_path_iter = data_path_iter
- data_path_item = data_path_item
+ data_path_iter: data_path_iter
+ data_path_item: data_path_item
- type = EnumProperty(
+ type: EnumProperty(
name="Type",
items=(('TOGGLE', "Toggle", ""),
('ENABLE', "Enable", ""),
@@ -756,22 +759,22 @@ class WM_OT_context_modal_mouse(Operator):
bl_label = "Context Modal Mouse"
bl_options = {'GRAB_CURSOR', 'BLOCKING', 'UNDO', 'INTERNAL'}
- data_path_iter = data_path_iter
- data_path_item = data_path_item
- header_text = StringProperty(
+ data_path_iter: data_path_iter
+ data_path_item: data_path_item
+ header_text: StringProperty(
name="Header Text",
description="Text to display in header during scale",
)
- input_scale = FloatProperty(
+ input_scale: FloatProperty(
description="Scale the mouse movement by this value before applying the delta",
default=0.01,
)
- invert = BoolProperty(
+ invert: BoolProperty(
description="Invert the mouse input",
default=False,
)
- initial_x = IntProperty(options={'HIDDEN'})
+ initial_x: IntProperty(options={'HIDDEN'})
def _values_store(self, context):
data_path_iter = self.data_path_iter
@@ -864,7 +867,7 @@ class WM_OT_url_open(Operator):
bl_label = ""
bl_options = {'INTERNAL'}
- url = StringProperty(
+ url: StringProperty(
name="URL",
description="URL to open",
)
@@ -881,7 +884,7 @@ class WM_OT_path_open(Operator):
bl_label = ""
bl_options = {'INTERNAL'}
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
options={'SKIP_SAVE'},
)
@@ -996,7 +999,7 @@ class WM_OT_doc_view_manual(Operator):
bl_idname = "wm.doc_view_manual"
bl_label = "View Manual"
- doc_id = doc_id
+ doc_id: doc_id
@staticmethod
def _find_reference(rna_id, url_mapping, verbose=True):
@@ -1050,7 +1053,7 @@ class WM_OT_doc_view(Operator):
bl_idname = "wm.doc_view"
bl_label = "View Documentation"
- doc_id = doc_id
+ doc_id: doc_id
if bpy.app.version_cycle == "release":
_prefix = ("https://docs.blender.org/api/blender_python_api_current")
else:
@@ -1114,16 +1117,16 @@ class WM_OT_properties_edit(Operator):
# register only because invoke_props_popup requires.
bl_options = {'REGISTER', 'INTERNAL'}
- data_path = rna_path
- property = rna_property
- value = rna_value
- min = rna_min
- max = rna_max
- use_soft_limits = rna_use_soft_limits
- is_overridable_static = rna_is_overridable_static
- soft_min = rna_min
- soft_max = rna_max
- description = StringProperty(
+ data_path: rna_path
+ property: rna_property
+ value: rna_value
+ min: rna_min
+ max: rna_max
+ use_soft_limits: rna_use_soft_limits
+ is_overridable_static: rna_is_overridable_static
+ soft_min: rna_min
+ soft_max: rna_max
+ description: StringProperty(
name="Tooltip",
)
@@ -1319,7 +1322,7 @@ class WM_OT_properties_add(Operator):
bl_label = "Add Property"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path
+ data_path: rna_path
def execute(self, context):
from rna_prop_ui import (
@@ -1362,7 +1365,7 @@ class WM_OT_properties_context_change(Operator):
bl_label = ""
bl_options = {'INTERNAL'}
- context = StringProperty(
+ context: StringProperty(
name="Context",
maxlen=64,
)
@@ -1378,8 +1381,8 @@ class WM_OT_properties_remove(Operator):
bl_label = "Remove Property"
bl_options = {'UNDO', 'INTERNAL'}
- data_path = rna_path
- property = rna_property
+ data_path: rna_path
+ property: rna_property
def execute(self, context):
from rna_prop_ui import (
@@ -1400,7 +1403,7 @@ class WM_OT_keyconfig_activate(Operator):
bl_idname = "wm.keyconfig_activate"
bl_label = "Activate Keyconfig"
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
)
@@ -1435,7 +1438,7 @@ class WM_OT_appconfig_activate(Operator):
bl_idname = "wm.appconfig_activate"
bl_label = "Activate Application Configuration"
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
)
@@ -1460,7 +1463,7 @@ class WM_OT_sysinfo(Operator):
bl_idname = "wm.sysinfo"
bl_label = "Save System Info"
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
options={'SKIP_SAVE'},
)
@@ -1538,26 +1541,26 @@ class WM_OT_keyconfig_import(Operator):
bl_idname = "wm.keyconfig_import"
bl_label = "Import Key Configuration..."
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
default="keymap.py",
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
name="Filter folders",
default=True,
options={'HIDDEN'},
)
- filter_text = BoolProperty(
+ filter_text: BoolProperty(
name="Filter text",
default=True,
options={'HIDDEN'},
)
- filter_python = BoolProperty(
+ filter_python: BoolProperty(
name="Filter python",
default=True,
options={'HIDDEN'},
)
- keep_original = BoolProperty(
+ keep_original: BoolProperty(
name="Keep original",
description="Keep original file after copying to configuration folder",
default=True,
@@ -1605,21 +1608,26 @@ class WM_OT_keyconfig_export(Operator):
bl_idname = "wm.keyconfig_export"
bl_label = "Export Key Configuration..."
- filepath = StringProperty(
+ all: BoolProperty(
+ name="All Keymaps",
+ default=False,
+ description="Write all keymaps (not just user modified)",
+ )
+ filepath: StringProperty(
subtype='FILE_PATH',
default="keymap.py",
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
name="Filter folders",
default=True,
options={'HIDDEN'},
)
- filter_text = BoolProperty(
+ filter_text: BoolProperty(
name="Filter text",
default=True,
options={'HIDDEN'},
)
- filter_python = BoolProperty(
+ filter_python: BoolProperty(
name="Filter python",
default=True,
options={'HIDDEN'},
@@ -1636,10 +1644,11 @@ class WM_OT_keyconfig_export(Operator):
wm = context.window_manager
- keyconfig_utils.keyconfig_export(
+ keyconfig_utils.keyconfig_export_as_data(
wm,
wm.keyconfigs.active,
self.filepath,
+ all_keymaps=self.all,
)
return {'FINISHED'}
@@ -1655,7 +1664,7 @@ class WM_OT_keymap_restore(Operator):
bl_idname = "wm.keymap_restore"
bl_label = "Restore Key Map(s)"
- all = BoolProperty(
+ all: BoolProperty(
name="All Keymaps",
description="Restore all keymaps to default",
)
@@ -1678,7 +1687,7 @@ class WM_OT_keyitem_restore(Operator):
bl_idname = "wm.keyitem_restore"
bl_label = "Restore Key Map Item"
- item_id = IntProperty(
+ item_id: IntProperty(
name="Item Identifier",
description="Identifier of the item to remove",
)
@@ -1725,7 +1734,7 @@ class WM_OT_keyitem_remove(Operator):
bl_idname = "wm.keyitem_remove"
bl_label = "Remove Key Map Item"
- item_id = IntProperty(
+ item_id: IntProperty(
name="Item Identifier",
description="Identifier of the item to remove",
)
@@ -1793,7 +1802,7 @@ class WM_OT_addon_enable(Operator):
bl_idname = "wm.addon_enable"
bl_label = "Enable Add-on"
- module = StringProperty(
+ module: StringProperty(
name="Module",
description="Module name of the add-on to enable",
)
@@ -1839,7 +1848,7 @@ class WM_OT_addon_disable(Operator):
bl_idname = "wm.addon_disable"
bl_label = "Disable Add-on"
- module = StringProperty(
+ module: StringProperty(
name="Module",
description="Module name of the add-on to disable",
)
@@ -1868,7 +1877,7 @@ class WM_OT_owner_enable(Operator):
bl_idname = "wm.owner_enable"
bl_label = "Enable Add-on"
- owner_id = StringProperty(
+ owner_id: StringProperty(
name="UI Tag",
)
@@ -1883,7 +1892,7 @@ class WM_OT_owner_disable(Operator):
bl_idname = "wm.owner_disable"
bl_label = "Disable UI Tag"
- owner_id = StringProperty(
+ owner_id: StringProperty(
name="UI Tag",
)
@@ -1899,20 +1908,20 @@ class WM_OT_theme_install(Operator):
bl_idname = "wm.theme_install"
bl_label = "Install Theme..."
- overwrite = BoolProperty(
+ overwrite: BoolProperty(
name="Overwrite",
description="Remove existing theme file if exists",
default=True,
)
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
name="Filter folders",
default=True,
options={'HIDDEN'},
)
- filter_glob = StringProperty(
+ filter_glob: StringProperty(
default="*.xml",
options={'HIDDEN'},
)
@@ -1976,31 +1985,31 @@ class WM_OT_addon_install(Operator):
bl_idname = "wm.addon_install"
bl_label = "Install Add-on from File..."
- overwrite = BoolProperty(
+ overwrite: BoolProperty(
name="Overwrite",
description="Remove existing add-ons with the same ID",
default=True,
)
- target = EnumProperty(
+ target: EnumProperty(
name="Target Path",
items=(('DEFAULT', "Default", ""),
('PREFS', "User Prefs", "")),
)
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
name="Filter folders",
default=True,
options={'HIDDEN'},
)
- filter_python = BoolProperty(
+ filter_python: BoolProperty(
name="Filter python",
default=True,
options={'HIDDEN'},
)
- filter_glob = StringProperty(
+ filter_glob: StringProperty(
default="*.py;*.zip",
options={'HIDDEN'},
)
@@ -2130,7 +2139,7 @@ class WM_OT_addon_remove(Operator):
bl_idname = "wm.addon_remove"
bl_label = "Remove Add-on"
- module = StringProperty(
+ module: StringProperty(
name="Module",
description="Module name of the add-on to remove",
)
@@ -2190,7 +2199,7 @@ class WM_OT_addon_expand(Operator):
bl_label = ""
bl_options = {'INTERNAL'}
- module = StringProperty(
+ module: StringProperty(
name="Module",
description="Module name of the add-on to expand",
)
@@ -2214,7 +2223,7 @@ class WM_OT_addon_userpref_show(Operator):
bl_label = ""
bl_options = {'INTERNAL'}
- module = StringProperty(
+ module: StringProperty(
name="Module",
description="Module name of the add-on to expand",
)
@@ -2245,21 +2254,21 @@ class WM_OT_app_template_install(Operator):
bl_idname = "wm.app_template_install"
bl_label = "Install Template from File..."
- overwrite = BoolProperty(
+ overwrite: BoolProperty(
name="Overwrite",
description="Remove existing template with the same ID",
default=True,
)
- filepath = StringProperty(
+ filepath: StringProperty(
subtype='FILE_PATH',
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
name="Filter folders",
default=True,
options={'HIDDEN'},
)
- filter_glob = StringProperty(
+ filter_glob: StringProperty(
default="*.zip",
options={'HIDDEN'},
)
@@ -2344,19 +2353,18 @@ class WM_OT_tool_set_by_name(Operator):
bl_idname = "wm.tool_set_by_name"
bl_label = "Set Tool By Name"
- name = StringProperty(
+ name: StringProperty(
name="Text",
description="Display name of the tool",
)
-
- cycle = BoolProperty(
+ cycle: BoolProperty(
name="Cycle",
description="Cycle through tools in this group",
default=False,
options={'SKIP_SAVE'},
)
- space_type = rna_space_type_prop
+ space_type: rna_space_type_prop
def execute(self, context):
from bl_ui.space_toolsystem_common import (
@@ -2398,9 +2406,13 @@ class WM_OT_toolbar(Operator):
def draw_menu(popover, context):
layout = popover.layout
+
+ layout.operator_context = 'INVOKE_DEFAULT'
+ layout.operator("wm.search_menu", text="Search Commands...", icon='VIEWZOOM')
+
cls.draw_cls(layout, context, detect_layout=False, scale_y=1.0)
- wm.popover(draw_menu, keymap=keymap)
+ wm.popover(draw_menu, ui_units_x=8, keymap=keymap)
return {'FINISHED'}
@@ -2410,27 +2422,27 @@ class WM_OT_studiolight_install(Operator):
bl_idname = "wm.studiolight_install"
bl_label = "Install Custom Studio Light"
- files = CollectionProperty(
+ files: CollectionProperty(
name="File Path",
type=OperatorFileListElement,
)
- directory = StringProperty(
+ directory: StringProperty(
subtype='DIR_PATH',
)
- filter_folder = BoolProperty(
+ filter_folder: BoolProperty(
name="Filter folders",
default=True,
options={'HIDDEN'},
)
- filter_glob = StringProperty(
+ filter_glob: StringProperty(
default="*.png;*.jpg;*.hdr;*.exr",
options={'HIDDEN'},
)
- orientation = EnumProperty(
+ orientation: EnumProperty(
items=(
- ("MATCAP", "MatCap", ""),
- ("WORLD", "World", ""),
- ("CAMERA", "Camera", ""),
+ ('MATCAP', "MatCap", ""),
+ ('WORLD', "World", ""),
+ ('CAMERA', "Camera", ""),
)
)
@@ -2476,7 +2488,7 @@ class WM_OT_studiolight_install(Operator):
class WM_OT_studiolight_uninstall(Operator):
bl_idname = 'wm.studiolight_uninstall'
bl_label = "Uninstall Studio Light"
- index = bpy.props.IntProperty()
+ index: bpy.props.IntProperty()
def _remove_path(self, path):
if path.exists():
@@ -2487,9 +2499,12 @@ class WM_OT_studiolight_uninstall(Operator):
userpref = context.user_preferences
for studio_light in userpref.studio_lights:
if studio_light.index == self.index:
- self._remove_path(pathlib.Path(studio_light.path))
- self._remove_path(pathlib.Path(studio_light.path_irr_cache))
- self._remove_path(pathlib.Path(studio_light.path_sh_cache))
+ if len(studio_light.path) > 0:
+ self._remove_path(pathlib.Path(studio_light.path))
+ if len(studio_light.path_irr_cache) > 0:
+ self._remove_path(pathlib.Path(studio_light.path_irr_cache))
+ if len(studio_light.path_sh_cache) > 0:
+ self._remove_path(pathlib.Path(studio_light.path_sh_cache))
userpref.studio_lights.remove(studio_light)
return {'FINISHED'}
return {'CANCELLED'}
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index da9054fb681..51ba45cdcd7 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -34,7 +34,7 @@ _modules = [
"properties_data_camera",
"properties_data_curve",
"properties_data_empty",
- "properties_data_lamp",
+ "properties_data_light",
"properties_data_lattice",
"properties_data_mesh",
"properties_data_metaball",
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index 6cfc4b6ea3f..63d80638ae2 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -328,7 +328,7 @@ class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from
class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "object.data"
_property_type = bpy.types.Armature
diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py
index cc593fbb0a2..6d364ee6539 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -402,7 +402,7 @@ class BONE_PT_deform(BoneButtonsPanel, Panel):
class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_property_type = bpy.types.Bone, bpy.types.EditBone, bpy.types.PoseBone
@property
diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py
index 3b5f21d616e..f66419a7f8e 100644
--- a/release/scripts/startup/bl_ui/properties_data_camera.py
+++ b/release/scripts/startup/bl_ui/properties_data_camera.py
@@ -39,7 +39,7 @@ class CAMERA_PT_presets(PresetMenu):
preset_subdir = "camera"
preset_operator = "script.execute_preset"
preset_add_operator = "camera.preset_add"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
class SAFE_AREAS_PT_presets(PresetMenu):
@@ -47,13 +47,13 @@ class SAFE_AREAS_PT_presets(PresetMenu):
preset_subdir = "safe_areas"
preset_operator = "script.execute_preset"
preset_add_operator = "safe_areas.preset_add"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
class DATA_PT_context_camera(CameraButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -62,18 +62,15 @@ class DATA_PT_context_camera(CameraButtonsPanel, Panel):
cam = context.camera
space = context.space_data
- split = layout.split(percentage=0.65)
if ob:
- split.template_ID(ob, "data")
- split.separator()
+ layout.template_ID(ob, "data")
elif cam:
- split.template_ID(space, "pin_id")
- split.separator()
+ layout.template_ID(space, "pin_id")
class DATA_PT_lens(CameraButtonsPanel, Panel):
bl_label = "Lens"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -114,7 +111,7 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
sub = col.column(align=True)
sub.prop(ccam, "longitude_min", text="Longiture Min")
sub.prop(ccam, "longitude_max", text="Max")
- elif engine in {'BLENDER_RENDER', 'BLENDER_EEVEE'}:
+ elif engine in {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}:
if cam.lens_unit == 'MILLIMETERS':
col.prop(cam, "lens")
elif cam.lens_unit == 'FOV':
@@ -136,7 +133,7 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
bl_label = "Stereoscopy"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -184,7 +181,7 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
class DATA_PT_camera(CameraButtonsPanel, Panel):
bl_label = "Camera"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header_preset(self, context):
CAMERA_PT_presets.draw_panel_header(self.layout)
@@ -267,7 +264,7 @@ class DATA_PT_camera_dof_aperture(CameraButtonsPanel, Panel):
class DATA_PT_camera_background_image(CameraButtonsPanel, Panel):
bl_label = "Background Images"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
cam = context.camera
@@ -366,9 +363,9 @@ class DATA_PT_camera_background_image(CameraButtonsPanel, Panel):
class DATA_PT_camera_display(CameraButtonsPanel, Panel):
- bl_label = "Display"
+ bl_label = "Viewport Display"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -401,7 +398,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel):
class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
bl_label = "Safe Areas"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
cam = context.camera
@@ -420,7 +417,7 @@ class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "object.data"
_property_type = bpy.types.Camera
diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py
index c0ab9da949f..4002568fb7d 100644
--- a/release/scripts/startup/bl_ui/properties_data_curve.py
+++ b/release/scripts/startup/bl_ui/properties_data_curve.py
@@ -135,7 +135,7 @@ class DATA_PT_shape_curve(CurveButtonsPanel, Panel):
class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -459,7 +459,7 @@ class DATA_PT_text_boxes(CurveButtonsPanelText, Panel):
class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "object.data"
_property_type = bpy.types.Curve
diff --git a/release/scripts/startup/bl_ui/properties_data_empty.py b/release/scripts/startup/bl_ui/properties_data_empty.py
index 1da3d9621aa..ab12d0f5c5f 100644
--- a/release/scripts/startup/bl_ui/properties_data_empty.py
+++ b/release/scripts/startup/bl_ui/properties_data_empty.py
@@ -50,7 +50,7 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
row = layout.row(align=True)
layout.prop(ob, "color", text="Transparency", index=3, slider=True)
- col = layout.col(align=True)
+ col = layout.column(align=True)
col.prop(ob, "empty_image_offset", text="Offset X", index=0)
col.prop(ob, "empty_image_offset", text="Y", index=1)
diff --git a/release/scripts/startup/bl_ui/properties_data_lamp.py b/release/scripts/startup/bl_ui/properties_data_lamp.py
deleted file mode 100644
index d613967584c..00000000000
--- a/release/scripts/startup/bl_ui/properties_data_lamp.py
+++ /dev/null
@@ -1,363 +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 #####
-
-# <pep8 compliant>
-import bpy
-from bpy.types import Menu, Panel
-from rna_prop_ui import PropertyPanel
-
-
-class DataButtonsPanel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "data"
-
- @classmethod
- def poll(cls, context):
- engine = context.engine
- return context.lamp and (engine in cls.COMPAT_ENGINES)
-
-
-class DATA_PT_context_lamp(DataButtonsPanel, Panel):
- bl_label = ""
- bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
-
- def draw(self, context):
- layout = self.layout
-
- ob = context.object
- lamp = context.lamp
- space = context.space_data
-
- split = layout.split(percentage=0.65)
-
- if ob:
- split.template_ID(ob, "data")
- elif lamp:
- split.template_ID(space, "pin_id")
-
-
-class DATA_PT_preview(DataButtonsPanel, Panel):
- bl_label = "Preview"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
-
- def draw(self, context):
- self.layout.template_preview(context.lamp)
-
-
-class DATA_PT_lamp(DataButtonsPanel, Panel):
- bl_label = "Lamp"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- lamp = context.lamp
-
- layout.row().prop(lamp, "type", expand=True)
-
- layout.use_property_split = True
-
- col = col.column()
- col.prop(lamp, "color")
- col.prop(lamp, "energy")
-
- if lamp.type in {'POINT', 'SPOT'}:
-
- col = col.column()
- col.label(text="Falloff")
- col.prop(lamp, "falloff_type")
- col.prop(lamp, "distance")
- col.prop(lamp, "shadow_soft_size")
-
- if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
- sub = col.column(align=True)
- sub.prop(lamp, "linear_attenuation", slider=True, text="Linear")
- sub.prop(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
-
- elif lamp.falloff_type == 'INVERSE_COEFFICIENTS':
- col.label(text="Inverse Coefficients")
- sub = col.column(align=True)
- sub.prop(lamp, "constant_coefficient", text="Constant")
- sub.prop(lamp, "linear_coefficient", text="Linear")
- sub.prop(lamp, "quadratic_coefficient", text="Quadratic")
-
- if lamp.type == 'AREA':
- col.prop(lamp, "distance")
-
- col = split.column()
- col.label()
-
-
-class DATA_PT_EEVEE_lamp(DataButtonsPanel, Panel):
- bl_label = "Lamp"
- COMPAT_ENGINES = {'BLENDER_EEVEE'}
-
- def draw(self, context):
- layout = self.layout
- lamp = context.lamp
-
- layout.row().prop(lamp, "type", expand=True)
-
- layout.use_property_split = True
-
- col = layout.column()
- col.prop(lamp, "color")
- col.prop(lamp, "energy")
- col.prop(lamp, "specular_factor", text="Specular")
-
- col.separator()
-
- if lamp.type in {'POINT', 'SPOT', 'SUN'}:
- col.prop(lamp, "shadow_soft_size", text="Radius")
- elif lamp.type == 'AREA':
- col.prop(lamp, "shape")
-
- sub = col.column(align=True)
-
- if lamp.shape in {'SQUARE', 'DISK'}:
- sub.prop(lamp, "size")
- elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
- sub.prop(lamp, "size", text="Size X")
- sub.prop(lamp, "size_y", text="Y")
-
-
-class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
- bl_label = "Shadow"
- COMPAT_ENGINES = {'BLENDER_EEVEE'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
- return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- lamp = context.lamp
- self.layout.prop(lamp, "use_shadow", text="")
-
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
-
- lamp = context.lamp
-
- layout.active = lamp.use_shadow
-
- col = layout.column()
- sub = col.column(align=True)
- sub.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
- sub.prop(lamp, "shadow_buffer_clip_end", text="End")
-
- col.prop(lamp, "shadow_buffer_soft", text="Softness")
-
- col.separator()
-
- col.prop(lamp, "shadow_buffer_bias", text="Bias")
- col.prop(lamp, "shadow_buffer_exp", text="Exponent")
- col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias")
-
-
-class DATA_PT_EEVEE_shadow_cascaded_shadow_map(DataButtonsPanel, Panel):
- bl_label = "Cascaded Shadow Map"
- bl_parent_id = "DATA_PT_EEVEE_shadow"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_EEVEE'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
-
- return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
- lamp = context.lamp
- layout.use_property_split = True
-
- col = layout.column()
-
- col.prop(lamp, "shadow_cascade_count", text="Count")
- col.prop(lamp, "shadow_cascade_fade", text="Fade")
-
- col.prop(lamp, "shadow_cascade_max_distance", text="Max Distance")
- col.prop(lamp, "shadow_cascade_exponent", text="Distribution")
-
-
-class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel):
- bl_label = "Contact Shadows"
- bl_parent_id = "DATA_PT_EEVEE_shadow"
- COMPAT_ENGINES = {'BLENDER_EEVEE'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
- return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- lamp = context.lamp
-
- layout = self.layout
- layout.active = lamp.use_shadow
- layout.prop(lamp, "use_contact_shadow", text="")
-
- def draw(self, context):
- layout = self.layout
- lamp = context.lamp
- layout.use_property_split = True
-
- col = layout.column()
- col.active = lamp.use_shadow and lamp.use_contact_shadow
-
- col.prop(lamp, "contact_shadow_distance", text="Distance")
- col.prop(lamp, "contact_shadow_soft_size", text="Softness")
- col.prop(lamp, "contact_shadow_bias", text="Bias")
- col.prop(lamp, "contact_shadow_thickness", text="Thickness")
-
-
-class DATA_PT_area(DataButtonsPanel, Panel):
- bl_label = "Area Shape"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
- return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- lamp = context.lamp
-
- col = layout.column()
- col.row().prop(lamp, "shape", expand=True)
- sub = col.row(align=True)
-
- if lamp.shape in {'SQUARE', 'DISK'}:
- sub.prop(lamp, "size")
- elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
- sub.prop(lamp, "size", text="Size X")
- sub.prop(lamp, "size_y", text="Size Y")
-
-
-class DATA_PT_spot(DataButtonsPanel, Panel):
- bl_label = "Spot Shape"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
- return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- lamp = context.lamp
-
- split = layout.split()
-
- col = split.column()
- sub = col.column()
- sub.prop(lamp, "spot_size", text="Size")
- sub.prop(lamp, "spot_blend", text="Blend", slider=True)
- col.prop(lamp, "use_square")
- col.prop(lamp, "show_cone")
-
- col = split.column()
-
- col.active = (lamp.shadow_method != 'BUFFER_SHADOW' or lamp.shadow_buffer_type != 'DEEP')
- col.prop(lamp, "use_halo")
- sub = col.column(align=True)
- sub.active = lamp.use_halo
- sub.prop(lamp, "halo_intensity", text="Intensity")
- if lamp.shadow_method == 'BUFFER_SHADOW':
- sub.prop(lamp, "halo_step", text="Step")
-
-
-class DATA_PT_spot(DataButtonsPanel, Panel):
- bl_label = "Spot Shape"
- bl_parent_id = "DATA_PT_EEVEE_lamp"
- COMPAT_ENGINES = {'BLENDER_EEVEE'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
- return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
-
- lamp = context.lamp
-
- col = layout.column()
-
- col.prop(lamp, "spot_size", text="Size")
- col.prop(lamp, "spot_blend", text="Blend", slider=True)
-
- col.prop(lamp, "show_cone")
-
-
-class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
- bl_label = "Falloff Curve"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
-
- return (lamp and lamp.type in {'POINT', 'SPOT'} and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- lamp = context.lamp
-
- self.layout.template_curve_mapping(lamp, "falloff_curve", use_negative_slope=True)
-
-
-class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
- _context_path = "object.data"
- _property_type = bpy.types.Lamp
-
-
-classes = (
- DATA_PT_context_lamp,
- DATA_PT_preview,
- DATA_PT_lamp,
- DATA_PT_EEVEE_lamp,
- DATA_PT_EEVEE_shadow,
- DATA_PT_EEVEE_shadow_contact,
- DATA_PT_EEVEE_shadow_cascaded_shadow_map,
- DATA_PT_area,
- DATA_PT_spot,
- DATA_PT_falloff_curve,
- DATA_PT_custom_props_lamp,
-)
-
-if __name__ == "__main__": # only for live edit.
- from bpy.utils import register_class
- for cls in classes:
- register_class(cls)
diff --git a/release/scripts/startup/bl_ui/properties_data_lattice.py b/release/scripts/startup/bl_ui/properties_data_lattice.py
index 40e82bc0a52..9aa8a4dee64 100644
--- a/release/scripts/startup/bl_ui/properties_data_lattice.py
+++ b/release/scripts/startup/bl_ui/properties_data_lattice.py
@@ -85,7 +85,7 @@ class DATA_PT_lattice(DataButtonsPanel, Panel):
class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "object.data"
_property_type = bpy.types.Lattice
diff --git a/release/scripts/startup/bl_ui/properties_data_light.py b/release/scripts/startup/bl_ui/properties_data_light.py
new file mode 100644
index 00000000000..f5c985f2abe
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_data_light.py
@@ -0,0 +1,295 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+import bpy
+from bpy.types import Menu, Panel
+from rna_prop_ui import PropertyPanel
+
+
+class DataButtonsPanel:
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_context = "data"
+
+ @classmethod
+ def poll(cls, context):
+ engine = context.engine
+ return context.light and (engine in cls.COMPAT_ENGINES)
+
+
+class DATA_PT_context_light(DataButtonsPanel, Panel):
+ bl_label = ""
+ bl_options = {'HIDE_HEADER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ ob = context.object
+ light = context.light
+ space = context.space_data
+
+ if ob:
+ layout.template_ID(ob, "data")
+ elif light:
+ layout.template_ID(space, "pin_id")
+
+
+class DATA_PT_preview(DataButtonsPanel, Panel):
+ bl_label = "Preview"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ def draw(self, context):
+ self.layout.template_preview(context.light)
+
+
+class DATA_PT_light(DataButtonsPanel, Panel):
+ bl_label = "Light"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_OPENGL'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ light = context.light
+
+ layout.row().prop(light, "type", expand=True)
+
+
+class DATA_PT_EEVEE_light(DataButtonsPanel, Panel):
+ bl_label = "Light"
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ def draw(self, context):
+ layout = self.layout
+ light = context.light
+
+ layout.row().prop(light, "type", expand=True)
+
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.prop(light, "color")
+ col.prop(light, "energy")
+ col.prop(light, "specular_factor", text="Specular")
+
+ col.separator()
+
+ if light.type in {'POINT', 'SPOT', 'SUN'}:
+ col.prop(light, "shadow_soft_size", text="Radius")
+ elif light.type == 'AREA':
+ col.prop(light, "shape")
+
+ sub = col.column(align=True)
+
+ if light.shape in {'SQUARE', 'DISK'}:
+ sub.prop(light, "size")
+ elif light.shape in {'RECTANGLE', 'ELLIPSE'}:
+ sub.prop(light, "size", text="Size X")
+ sub.prop(light, "size_y", text="Y")
+
+
+class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
+ bl_label = "Shadow"
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ light = context.light
+ engine = context.engine
+ return (light and light.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ light = context.light
+ self.layout.prop(light, "use_shadow", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ light = context.light
+
+ layout.active = light.use_shadow
+
+ col = layout.column()
+ sub = col.column(align=True)
+ sub.prop(light, "shadow_buffer_clip_start", text="Clip Start")
+ sub.prop(light, "shadow_buffer_clip_end", text="End")
+
+ col.prop(light, "shadow_buffer_soft", text="Softness")
+
+ col.separator()
+
+ col.prop(light, "shadow_buffer_bias", text="Bias")
+ col.prop(light, "shadow_buffer_exp", text="Exponent")
+ col.prop(light, "shadow_buffer_bleed_bias", text="Bleed Bias")
+
+
+class DATA_PT_EEVEE_shadow_cascaded_shadow_map(DataButtonsPanel, Panel):
+ bl_label = "Cascaded Shadow Map"
+ bl_parent_id = "DATA_PT_EEVEE_shadow"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ light = context.light
+ engine = context.engine
+
+ return (light and light.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ light = context.light
+ layout.use_property_split = True
+
+ col = layout.column()
+
+ col.prop(light, "shadow_cascade_count", text="Count")
+ col.prop(light, "shadow_cascade_fade", text="Fade")
+
+ col.prop(light, "shadow_cascade_max_distance", text="Max Distance")
+ col.prop(light, "shadow_cascade_exponent", text="Distribution")
+
+
+class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel):
+ bl_label = "Contact Shadows"
+ bl_parent_id = "DATA_PT_EEVEE_shadow"
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ light = context.light
+ engine = context.engine
+ return (light and light.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ light = context.light
+
+ layout = self.layout
+ layout.active = light.use_shadow
+ layout.prop(light, "use_contact_shadow", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ light = context.light
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.active = light.use_shadow and light.use_contact_shadow
+
+ col.prop(light, "contact_shadow_distance", text="Distance")
+ col.prop(light, "contact_shadow_soft_size", text="Softness")
+ col.prop(light, "contact_shadow_bias", text="Bias")
+ col.prop(light, "contact_shadow_thickness", text="Thickness")
+
+
+class DATA_PT_area(DataButtonsPanel, Panel):
+ bl_label = "Area Shape"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_OPENGL'}
+
+ @classmethod
+ def poll(cls, context):
+ light = context.light
+ engine = context.engine
+ return (light and light.type == 'AREA') and (engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+
+ light = context.light
+
+ col = layout.column()
+ col.row().prop(light, "shape", expand=True)
+ sub = col.row(align=True)
+
+ if light.shape in {'SQUARE', 'DISK'}:
+ sub.prop(light, "size")
+ elif light.shape in {'RECTANGLE', 'ELLIPSE'}:
+ sub.prop(light, "size", text="Size X")
+ sub.prop(light, "size_y", text="Size Y")
+
+
+class DATA_PT_spot(DataButtonsPanel, Panel):
+ bl_label = "Spot Shape"
+ bl_parent_id = "DATA_PT_EEVEE_light"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+
+ @classmethod
+ def poll(cls, context):
+ light = context.light
+ engine = context.engine
+ return (light and light.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ light = context.light
+
+ col = layout.column()
+
+ col.prop(light, "spot_size", text="Size")
+ col.prop(light, "spot_blend", text="Blend", slider=True)
+
+ col.prop(light, "show_cone")
+
+
+class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
+ bl_label = "Falloff Curve"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ light = context.light
+ engine = context.engine
+
+ return (light and light.type in {'POINT', 'SPOT'} and light.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ light = context.light
+
+ self.layout.template_curve_mapping(light, "falloff_curve", use_negative_slope=True)
+
+
+class DATA_PT_custom_props_light(DataButtonsPanel, PropertyPanel, Panel):
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ _context_path = "object.data"
+ _property_type = bpy.types.Light
+
+
+classes = (
+ DATA_PT_context_light,
+ DATA_PT_preview,
+ DATA_PT_light,
+ DATA_PT_EEVEE_light,
+ DATA_PT_EEVEE_shadow,
+ DATA_PT_EEVEE_shadow_contact,
+ DATA_PT_EEVEE_shadow_cascaded_shadow_map,
+ DATA_PT_area,
+ DATA_PT_spot,
+ DATA_PT_falloff_curve,
+ DATA_PT_custom_props_light,
+)
+
+if __name__ == "__main__": # only for live edit.
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)
diff --git a/release/scripts/startup/bl_ui/properties_data_lightprobe.py b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
index 10b66dd0033..5924a796b65 100644
--- a/release/scripts/startup/bl_ui/properties_data_lightprobe.py
+++ b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
@@ -155,12 +155,9 @@ class DATA_PT_lightprobe_display(DataButtonsPanel, Panel):
col = layout.column()
- if probe.type != 'PLANAR':
- col.prop(probe, "data_draw_size", text="Size")
- else:
+ if probe.type == 'PLANAR':
col.prop(ob, "empty_draw_size", text="Arrow Size")
-
- col.prop(probe, "show_data")
+ col.prop(probe, "show_data")
if probe.type in {'GRID', 'CUBEMAP'}:
col.prop(probe, "show_influence")
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index e8015327c1d..214852cc826 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -24,7 +24,6 @@ from rna_prop_ui import PropertyPanel
class MESH_MT_vertex_group_specials(Menu):
bl_label = "Vertex Group Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -48,7 +47,6 @@ class MESH_MT_vertex_group_specials(Menu):
class MESH_MT_shape_key_specials(Menu):
bl_label = "Shape Key Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -137,7 +135,7 @@ class MeshButtonsPanel:
class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -154,7 +152,7 @@ class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
class DATA_PT_normals(MeshButtonsPanel, Panel):
bl_label = "Normals"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -174,7 +172,7 @@ class DATA_PT_normals(MeshButtonsPanel, Panel):
class DATA_PT_texture_space(MeshButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -194,7 +192,7 @@ class DATA_PT_texture_space(MeshButtonsPanel, Panel):
class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
bl_label = "Vertex Groups"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -241,7 +239,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
class DATA_PT_face_maps(MeshButtonsPanel, Panel):
bl_label = "Face Maps"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -283,7 +281,7 @@ class DATA_PT_face_maps(MeshButtonsPanel, Panel):
class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
bl_label = "Shape Keys"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -373,7 +371,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
bl_label = "UV Maps"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -392,7 +390,7 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
bl_label = "Vertex Colors"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -412,7 +410,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
class DATA_PT_customdata(MeshButtonsPanel, Panel):
bl_label = "Geometry Data"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -439,7 +437,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "object.data"
_property_type = bpy.types.Mesh
diff --git a/release/scripts/startup/bl_ui/properties_data_metaball.py b/release/scripts/startup/bl_ui/properties_data_metaball.py
index 2a61e6cda79..75015a57f5f 100644
--- a/release/scripts/startup/bl_ui/properties_data_metaball.py
+++ b/release/scripts/startup/bl_ui/properties_data_metaball.py
@@ -71,7 +71,7 @@ class DATA_PT_metaball(DataButtonsPanel, Panel):
class DATA_PT_mball_texture_space(DataButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -125,7 +125,7 @@ class DATA_PT_metaball_element(DataButtonsPanel, Panel):
class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "object.data"
_property_type = bpy.types.MetaBall
diff --git a/release/scripts/startup/bl_ui/properties_data_speaker.py b/release/scripts/startup/bl_ui/properties_data_speaker.py
index 2a3dc4d02c1..d7c93095489 100644
--- a/release/scripts/startup/bl_ui/properties_data_speaker.py
+++ b/release/scripts/startup/bl_ui/properties_data_speaker.py
@@ -36,7 +36,7 @@ class DataButtonsPanel:
class DATA_PT_context_speaker(DataButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -55,7 +55,7 @@ class DATA_PT_context_speaker(DataButtonsPanel, Panel):
class DATA_PT_speaker(DataButtonsPanel, Panel):
bl_label = "Sound"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -76,7 +76,7 @@ class DATA_PT_speaker(DataButtonsPanel, Panel):
class DATA_PT_distance(DataButtonsPanel, Panel):
bl_label = "Distance"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -99,7 +99,7 @@ class DATA_PT_distance(DataButtonsPanel, Panel):
class DATA_PT_cone(DataButtonsPanel, Panel):
bl_label = "Cone"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -121,7 +121,7 @@ class DATA_PT_cone(DataButtonsPanel, Panel):
class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "object.data"
_property_type = bpy.types.Speaker
diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py
index 450ca80bbc2..c766c8dedbc 100644
--- a/release/scripts/startup/bl_ui/properties_mask_common.py
+++ b/release/scripts/startup/bl_ui/properties_mask_common.py
@@ -378,6 +378,12 @@ class MASK_MT_select(Menu):
def draw(self, context):
layout = self.layout
+ layout.operator("mask.select_all", text="All").action = 'SELECT'
+ layout.operator("mask.select_all", text="None").action = 'DESELECT'
+ layout.operator("mask.select_all", text="Invert").action = 'INVERT'
+
+ layout.separator()
+
layout.operator("mask.select_border")
layout.operator("mask.select_circle")
@@ -388,8 +394,6 @@ class MASK_MT_select(Menu):
layout.separator()
- layout.operator("mask.select_all").action = 'TOGGLE'
- layout.operator("mask.select_all", text="Inverse").action = 'INVERT'
layout.operator("mask.select_linked", text="Select Linked")
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index fdbf0b240c4..0e3e50b3497 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -21,7 +21,7 @@ import bpy
from bpy.types import Menu, Panel, UIList
from rna_prop_ui import PropertyPanel
from bpy.app.translations import pgettext_iface as iface_
-from bpy_extras.node_utils import find_node_input, find_output_node
+from bpy_extras.node_utils import find_node_input
class MATERIAL_MT_specials(Menu):
@@ -65,6 +65,7 @@ class MaterialButtonsPanel:
class MATERIAL_PT_preview(MaterialButtonsPanel, Panel):
bl_label = "Preview"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE'}
def draw(self, context):
@@ -72,7 +73,7 @@ class MATERIAL_PT_preview(MaterialButtonsPanel, Panel):
class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "material"
_property_type = bpy.types.Material
@@ -81,7 +82,7 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
bl_label = ""
bl_context = "material"
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -118,29 +119,27 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+ row = layout.row()
+
+ if ob:
+ row.template_ID(ob, "active_material", new="material.new")
+
+ if slot:
+ icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA'
+ row.prop(slot, "link", icon=icon_link, icon_only=True)
+
if ob.mode == 'EDIT':
row = layout.row(align=True)
row.operator("object.material_slot_assign", text="Assign")
row.operator("object.material_slot_select", text="Select")
row.operator("object.material_slot_deselect", text="Deselect")
- split = layout.split(percentage=0.65)
-
- if ob:
- split.template_ID(ob, "active_material", new="material.new")
- row = split.row()
-
- if slot:
- row.prop(slot, "link", text="")
- else:
- row.label()
elif mat:
- split.template_ID(space, "pin_id")
- split.separator()
+ row.template_ID(space, "pin_id")
def panel_node_draw(layout, ntree, output_type):
- node = find_output_node(ntree, output_type)
+ node = ntree.get_output_node('EEVEE')
if node:
input = find_node_input(node, 'Surface')
@@ -171,7 +170,7 @@ class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel):
layout.separator()
if mat.use_nodes:
- panel_node_draw(layout, mat.node_tree, ('OUTPUT_EEVEE_MATERIAL', 'OUTPUT_MATERIAL'))
+ panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL')
else:
layout.use_property_split = True
layout.prop(mat, "diffuse_color", text="Base Color")
@@ -242,11 +241,11 @@ classes = (
MATERIAL_MT_specials,
MATERIAL_UL_matslots,
MATERIAL_PT_preview,
- MATERIAL_PT_custom_props,
EEVEE_MATERIAL_PT_context_material,
EEVEE_MATERIAL_PT_surface,
EEVEE_MATERIAL_PT_options,
MATERIAL_PT_viewport,
+ MATERIAL_PT_custom_props,
)
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 63b708ae059..64bc8d52068 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -359,7 +359,7 @@ class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit fr
class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "object"
_property_type = bpy.types.Object
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 05538e71faf..9d891a07989 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -67,7 +67,7 @@ def particle_get_settings(context):
class PARTICLE_MT_specials(Menu):
bl_label = "Particle Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -88,7 +88,7 @@ class PARTICLE_PT_hair_dynamics_presets(PresetMenu):
preset_subdir = "hair_dynamics"
preset_operator = "script.execute_preset"
preset_add_operator = "particle.hair_dynamics_preset_add"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
class ParticleButtonsPanel:
@@ -132,7 +132,7 @@ class PARTICLE_UL_particle_systems(bpy.types.UIList):
class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -235,7 +235,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
bl_label = "Emission"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -287,7 +287,7 @@ class PARTICLE_PT_emission_source(ParticleButtonsPanel, Panel):
bl_label = "Source"
bl_parent_id = "PARTICLE_PT_emission"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -325,7 +325,7 @@ class PARTICLE_PT_emission_source(ParticleButtonsPanel, Panel):
class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
bl_label = "Hair Dynamics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -406,7 +406,7 @@ class PARTICLE_PT_hair_dynamics_structure(ParticleButtonsPanel, Panel):
bl_label = "Structure"
bl_parent_id = "PARTICLE_PT_hair_dynamics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -438,7 +438,7 @@ class PARTICLE_PT_hair_dynamics_volume(ParticleButtonsPanel, Panel):
bl_label = "Volume"
bl_parent_id = "PARTICLE_PT_hair_dynamics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -470,7 +470,7 @@ class PARTICLE_PT_hair_dynamics_volume(ParticleButtonsPanel, Panel):
class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
bl_label = "Cache"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -501,7 +501,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel):
bl_label = "Velocity"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -550,7 +550,7 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel):
class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
bl_label = "Rotation"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -603,7 +603,7 @@ class PARTICLE_PT_rotation_angular_velocity(ParticleButtonsPanel, Panel):
bl_label = "Angular Velocity"
bl_parent_id = "PARTICLE_PT_rotation"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -628,7 +628,7 @@ class PARTICLE_PT_rotation_angular_velocity(ParticleButtonsPanel, Panel):
class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
bl_label = "Physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -826,7 +826,7 @@ class PARTICLE_PT_physics_deflection(ParticleButtonsPanel, Panel):
bl_label = "Deflection"
bl_parent_id = "PARTICLE_PT_physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -852,7 +852,7 @@ class PARTICLE_PT_physics_deflection(ParticleButtonsPanel, Panel):
class PARTICLE_PT_physics_forces(ParticleButtonsPanel, Panel):
bl_label = "Forces"
bl_parent_id = "PARTICLE_PT_physics"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -879,7 +879,7 @@ class PARTICLE_PT_physics_integration(ParticleButtonsPanel, Panel):
bl_label = "Integration"
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = "PARTICLE_PT_physics"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -911,7 +911,7 @@ class PARTICLE_PT_physics_integration(ParticleButtonsPanel, Panel):
class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
bl_label = "Boid Brain"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1015,7 +1015,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
bl_label = "Render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1055,7 +1055,7 @@ class PARTICLE_PT_render_extra(ParticleButtonsPanel, Panel):
bl_label = "Extra"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1082,7 +1082,7 @@ class PARTICLE_PT_render_line(ParticleButtonsPanel, Panel):
bl_label = "Line"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1110,7 +1110,7 @@ class PARTICLE_PT_render_path(ParticleButtonsPanel, Panel):
bl_label = "Path"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1145,7 +1145,7 @@ class PARTICLE_PT_render_path_timing(ParticleButtonsPanel, Panel):
bl_label = "Timing"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1177,7 +1177,7 @@ class PARTICLE_PT_render_object(ParticleButtonsPanel, Panel):
bl_label = "Object"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1205,7 +1205,7 @@ class PARTICLE_PT_render_collection(ParticleButtonsPanel, Panel):
bl_label = "Collection"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1237,7 +1237,7 @@ class PARTICLE_PT_render_collection_use_count(ParticleButtonsPanel, Panel):
bl_label = "Use Count"
bl_parent_id = "PARTICLE_PT_render_collection"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1288,7 +1288,7 @@ class PARTICLE_PT_render_billboards_alignment(ParticleButtonsPanel, Panel):
bl_label = "Billboard Alignment"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1314,7 +1314,7 @@ class PARTICLE_PT_render_billboards_tilt(ParticleButtonsPanel, Panel):
bl_label = "Billboard Tilt"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1348,7 +1348,7 @@ class PARTICLE_PT_render_billboards_uv(ParticleButtonsPanel, Panel):
bl_label = "Billboard UVs"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1384,7 +1384,7 @@ class PARTICLE_PT_render_trails(ParticleButtonsPanel, Panel):
bl_label = "Trails"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1412,7 +1412,7 @@ class PARTICLE_PT_render_trails(ParticleButtonsPanel, Panel):
class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
bl_label = "Viewport Display"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1474,7 +1474,7 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
bl_label = "Children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1530,7 +1530,7 @@ class PARTICLE_PT_children_parting(ParticleButtonsPanel, Panel):
bl_label = "Parting"
bl_parent_id = "PARTICLE_PT_children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1555,7 +1555,7 @@ class PARTICLE_PT_children_clumping(ParticleButtonsPanel, Panel):
bl_label = "Clumping"
bl_parent_id = "PARTICLE_PT_children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1597,7 +1597,7 @@ class PARTICLE_PT_children_roughness(ParticleButtonsPanel, Panel):
bl_label = "Roughness"
bl_parent_id = "PARTICLE_PT_children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1639,7 +1639,7 @@ class PARTICLE_PT_children_kink(ParticleButtonsPanel, Panel):
bl_label = "Kink"
bl_parent_id = "PARTICLE_PT_children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1690,7 +1690,7 @@ class PARTICLE_PT_children_kink(ParticleButtonsPanel, Panel):
class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel):
bl_label = "Field Weights"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1711,7 +1711,7 @@ class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel):
class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel):
bl_label = "Force Field Settings"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -1727,7 +1727,7 @@ class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel):
class PARTICLE_PT_force_fields_type1(ParticleButtonsPanel, Panel):
bl_label = "Type 1"
bl_parent_id = "PARTICLE_PT_force_fields"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -1743,7 +1743,7 @@ class PARTICLE_PT_force_fields_type1(ParticleButtonsPanel, Panel):
class PARTICLE_PT_force_fields_type2(ParticleButtonsPanel, Panel):
bl_label = "Type 2"
bl_parent_id = "PARTICLE_PT_force_fields"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -1760,7 +1760,7 @@ class PARTICLE_PT_force_fields_type1_falloff(ParticleButtonsPanel, Panel):
bl_label = "Falloff"
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = "PARTICLE_PT_force_fields_type1"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -1775,7 +1775,7 @@ class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel):
bl_label = "Falloff"
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = "PARTICLE_PT_force_fields_type2"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -1789,7 +1789,7 @@ class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel):
class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
bl_label = "Vertex Groups"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1862,7 +1862,7 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
class PARTICLE_PT_textures(ParticleButtonsPanel, Panel):
bl_label = "Textures"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1894,7 +1894,7 @@ class PARTICLE_PT_textures(ParticleButtonsPanel, Panel):
class PARTICLE_PT_hair_shape(ParticleButtonsPanel, Panel):
bl_label = "Hair Shape"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -1921,7 +1921,7 @@ class PARTICLE_PT_hair_shape(ParticleButtonsPanel, Panel):
class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "particle_system.settings"
_property_type = bpy.types.ParticleSettings
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 2f659af3891..7775722784b 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -51,7 +51,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
bl_label = "Cloth"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header_preset(self, context):
CLOTH_PT_presets.draw_panel_header(self.layout)
@@ -129,7 +129,7 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
md = context.cloth
@@ -140,7 +140,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
bl_label = "Collision"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
cloth = context.cloth.collision_settings
@@ -181,7 +181,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
bl_label = "Stiffness Scaling"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
cloth = context.cloth.settings
@@ -215,7 +215,7 @@ class PHYSICS_PT_cloth_sewing(PhysicButtonsPanel, Panel):
bl_label = "Sewing Springs"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
cloth = context.cloth.settings
@@ -250,7 +250,7 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
cloth = context.cloth.settings
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index e071de0108b..2da84ad84da 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -56,7 +56,7 @@ def physics_add_special(self, layout, data, name, addop, removeop, typeicon):
class PHYSICS_PT_add(PhysicButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
obj = context.object
@@ -97,7 +97,7 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel):
'CONSTRAINT') # RB_TODO needs better icon
-# cache-type can be 'PSYS' 'HAIR' 'SMOKE' etc
+# cache-type can be 'PSYS' 'HAIR' 'SMOKE' etc.
def point_cache_ui(self, context, cache, enabled, cachetype):
layout = self.layout
@@ -112,8 +112,8 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
col.operator("ptcache.add", icon='ZOOMIN', text="")
col.operator("ptcache.remove", icon='ZOOMOUT', text="")
- row = layout.row()
if cachetype in {'PSYS', 'HAIR', 'SMOKE'}:
+ row = layout.row()
row.prop(cache, "use_external")
if cachetype == 'SMOKE':
@@ -131,7 +131,9 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
cache_info = cache.info
if cache_info:
- layout.label(text=cache_info)
+ col = layout.column()
+ col.alignment = 'RIGHT'
+ col.label(text=cache_info)
else:
if cachetype in {'SMOKE', 'DYNAMIC_PAINT'}:
if not bpy.data.is_saved:
@@ -147,45 +149,54 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
col.enabled = enabled
col.prop(cache, "frame_start", text="Simulation Start")
col.prop(cache, "frame_end")
+
if cachetype not in {'SMOKE', 'CLOTH', 'DYNAMIC_PAINT', 'RIGID_BODY'}:
col.prop(cache, "frame_step")
- if cachetype != 'SMOKE':
- layout.label(text=cache.info)
+ cache_info = cache.info
+ if cachetype != 'SMOKE' and cache_info: # avoid empty space.
+ col = layout.column(align=True)
+ col.alignment = 'RIGHT'
+ col.label(text=cache_info)
can_bake = True
if cachetype not in {'SMOKE', 'DYNAMIC_PAINT', 'RIGID_BODY'}:
- split = layout.split()
- split.enabled = enabled and bpy.data.is_saved
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
+ flow.enabled = enabled and bpy.data.is_saved
- col = split.column()
- col.prop(cache, "use_disk_cache")
+ flow.use_property_split = True
- col = split.column()
- col.active = cache.use_disk_cache
- col.prop(cache, "use_library_path", "Use Lib Path")
+ # NOTE: TODO temporarly used until the animate properties are properly skipped.
+ flow.use_property_decorate = False # No animation (remove this later on)
- row = layout.row()
- row.enabled = enabled and bpy.data.is_saved
- row.active = cache.use_disk_cache
- row.label(text="Compression:")
- row.prop(cache, "compression", expand=True)
+ col = flow.column()
+ col.prop(cache, "use_disk_cache")
- layout.separator()
+ subcol = col.column()
+ subcol.active = cache.use_disk_cache
+ subcol.prop(cache, "use_library_path", "Use Lib Path")
+
+ col = flow.column()
+ col.enabled = enabled and bpy.data.is_saved
+ col.active = cache.use_disk_cache
+ col.prop(cache, "compression", text="Compression", expand=True)
if cache.id_data.library and not cache.use_disk_cache:
can_bake = False
col = layout.column(align=True)
- col.label(text="Linked object baking requires Disk Cache to be enabled", icon='INFO')
+ col.alignment = 'RIGHT'
+
+ col.separator()
+
+ col.label(text="Linked object baking requires Disk Cache to be enabled")
else:
layout.separator()
- split = layout.split()
- split.active = can_bake
-
- col = split.column()
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
+ col = flow.column()
+ col.active = can_bake
if cache.is_baked is True:
col.operator("ptcache.free_bake", text="Free Bake")
@@ -200,7 +211,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
sub.enabled = enabled
sub.operator("ptcache.bake_from_cache", text="Current Cache to Bake")
- col = split.column()
+ col = flow.column()
col.operator("ptcache.bake_all", text="Bake All Dynamics").bake = True
col.operator("ptcache.free_bake_all", text="Free All Bakes")
col.operator("ptcache.bake_all", text="Update All To Frame").bake = False
@@ -212,31 +223,31 @@ def effector_weights_ui(self, context, weights, weight_type):
layout.prop(weights, "group")
- layout.use_property_split = False
-
- split = layout.split()
-
- split.prop(weights, "gravity", slider=True)
- split.prop(weights, "all", slider=True)
+ # NOTE: TODO temporarly used until the animate properties are properly skipped
+ layout.use_property_decorate = False # No animation (remove this later on)
- layout.separator()
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- split = layout.split()
-
- col = split.column()
+ col = flow.column()
+ col.prop(weights, "gravity", slider=True)
+ col.prop(weights, "all", slider=True)
col.prop(weights, "force", slider=True)
col.prop(weights, "vortex", slider=True)
+
+ col = flow.column()
col.prop(weights, "magnetic", slider=True)
+ col.prop(weights, "harmonic", slider=True)
+ col.prop(weights, "charge", slider=True)
+ col.prop(weights, "lennardjones", slider=True)
+
+ col = flow.column()
col.prop(weights, "wind", slider=True)
col.prop(weights, "curve_guide", slider=True)
col.prop(weights, "texture", slider=True)
if weight_type != 'SMOKE':
col.prop(weights, "smokeflow", slider=True)
- col = split.column()
- col.prop(weights, "harmonic", slider=True)
- col.prop(weights, "charge", slider=True)
- col.prop(weights, "lennardjones", slider=True)
+ col = flow.column()
col.prop(weights, "turbulence", slider=True)
col.prop(weights, "drag", slider=True)
col.prop(weights, "boid", slider=True)
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index 6a66dafadf0..611f477a31b 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -60,7 +60,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -129,7 +129,7 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel):
bl_label = "Advanced"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -206,7 +206,7 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
bl_label = "Output"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -300,7 +300,7 @@ class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel):
bl_label = "Initial Color"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -337,7 +337,7 @@ class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel):
bl_label = "Effects"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -387,7 +387,7 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -409,7 +409,7 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
bl_label = "Source"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -463,7 +463,7 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel):
bl_label = "Velocity"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -500,7 +500,7 @@ class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, Panel):
bl_label = "Waves"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py
index 3b01015047f..1a4e24fbc0c 100644
--- a/release/scripts/startup/bl_ui/properties_physics_field.py
+++ b/release/scripts/startup/bl_ui/properties_physics_field.py
@@ -38,7 +38,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
bl_label = "Force Fields"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -112,7 +112,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
class PHYSICS_PT_field_falloff(PhysicButtonsPanel, Panel):
bl_label = "Falloff"
bl_parent_id = "PHYSICS_PT_field"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -170,7 +170,7 @@ class PHYSICS_PT_field_falloff(PhysicButtonsPanel, Panel):
class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
bl_label = "Collision"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -199,7 +199,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
class PHYSICS_PT_collision_particle(PhysicButtonsPanel, Panel):
bl_label = "Particle"
bl_parent_id = "PHYSICS_PT_collision"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -241,7 +241,7 @@ class PHYSICS_PT_collision_particle(PhysicButtonsPanel, Panel):
class PHYSICS_PT_collision_softbody(PhysicButtonsPanel, Panel):
bl_label = "Softbody"
bl_parent_id = "PHYSICS_PT_collision"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
index de8bca229e4..013822793de 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -29,7 +29,7 @@ class PHYSICS_PT_rigidbody_panel:
class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Rigid Body"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -57,7 +57,7 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Collisions"
bl_parent_id = 'PHYSICS_PT_rigid_body'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -102,8 +102,8 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Dynamics"
bl_parent_id = 'PHYSICS_PT_rigid_body'
- bl_default_closed = True
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
index aca989fd0ba..69491f36c63 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
@@ -29,7 +29,7 @@ class PHYSICS_PT_rigidbody_constraint_panel:
class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Rigid Body Constraint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index acbaecbda4c..0a4f1c71126 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -39,7 +39,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
bl_label = "Smoke"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -138,7 +138,7 @@ class PHYSICS_PT_smoke_flow_advanced(PhysicButtonsPanel, Panel):
bl_label = "Advanced"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -174,7 +174,7 @@ class PHYSICS_PT_smoke_fire(PhysicButtonsPanel, Panel):
bl_label = "Flames"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -205,7 +205,7 @@ class PHYSICS_PT_smoke_adaptive_domain(PhysicButtonsPanel, Panel):
bl_label = "Adaptive Domain"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -240,7 +240,7 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
bl_label = "High Resolution"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -280,7 +280,7 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
bl_label = "Groups"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -309,7 +309,7 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -346,7 +346,7 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py
index 68db165875e..77440bdc628 100644
--- a/release/scripts/startup/bl_ui/properties_physics_softbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py
@@ -46,7 +46,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
bl_label = "Soft Body"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -77,7 +77,7 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
md = context.soft_body
@@ -88,7 +88,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
bl_label = "Goal"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -129,7 +129,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
bl_label = "Edges"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -180,7 +180,7 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
bl_label = "Self Collision"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -210,7 +210,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel):
bl_label = "Solver"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -244,7 +244,7 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
md = context.soft_body
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 580c31465b3..b1c5edf97e7 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -21,6 +21,11 @@
import bpy
from bpy.types import Menu, Panel, UIList
from bl_operators.presets import PresetMenu
+from .space_view3d import (
+ VIEW3D_PT_shading_lighting,
+ VIEW3D_PT_shading_color,
+ VIEW3D_PT_shading_options,
+)
class RENDER_PT_presets(PresetMenu):
@@ -79,7 +84,7 @@ class RENDER_PT_context(Panel):
class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
bl_label = "Dimensions"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_frame_rate_args_prev = None
_preset_class = None
@@ -166,7 +171,7 @@ class RENDER_PT_frame_remapping(RenderButtonsPanel, Panel):
bl_label = "Time Remapping"
bl_parent_id = "RENDER_PT_dimensions"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -183,7 +188,7 @@ class RENDER_PT_frame_remapping(RenderButtonsPanel, Panel):
class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
bl_label = "Post Processing"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -201,7 +206,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
class RENDER_PT_stamp(RenderButtonsPanel, Panel):
bl_label = "Metadata"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -242,7 +247,7 @@ class RENDER_PT_stamp_burn(RenderButtonsPanel, Panel):
bl_label = "Burn Into Image"
bl_parent_id = "RENDER_PT_stamp"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
rd = context.scene.render
@@ -266,7 +271,7 @@ class RENDER_PT_stamp_burn(RenderButtonsPanel, Panel):
class RENDER_PT_output(RenderButtonsPanel, Panel):
bl_label = "Output"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -298,7 +303,7 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
class RENDER_PT_encoding(RenderButtonsPanel, Panel):
bl_label = "Encoding"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header_preset(self, context):
RENDER_PT_ffmpeg_presets.draw_panel_header(self.layout)
@@ -395,7 +400,7 @@ class RENDER_UL_renderviews(UIList):
class RENDER_PT_stereoscopy(RenderButtonsPanel, Panel):
bl_label = "Stereoscopy"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
@@ -712,15 +717,49 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
scene = context.scene
props = scene.eevee
col = layout.column()
+ col.operator("scene.light_cache_bake", text="Bake Indirect Lighting", icon='RENDER_STILL')
+ col.operator("scene.light_cache_bake", text="Bake Cubemap Only", icon='LIGHTPROBE_CUBEMAP').subset = "CUBEMAPS"
+ col.operator("scene.light_cache_free", text="Free Lighting Cache")
+
+ cache_info = scene.eevee.gi_cache_info
+ if cache_info:
+ col.label(text=cache_info)
+
+ col.prop(props, "gi_auto_bake")
+
col.prop(props, "gi_diffuse_bounces")
col.prop(props, "gi_cubemap_resolution")
col.prop(props, "gi_visibility_resolution", text="Diffuse Occlusion")
+ layout.use_property_split = False
+ row = layout.split(percentage=0.5)
+ row.alignment = 'RIGHT'
+ row.label("Cubemap Display")
+
+ sub = row.row(align=True)
+ sub.prop(props, "gi_cubemap_draw_size", text="Size")
+ if props.gi_show_cubemaps:
+ sub.prop(props, "gi_show_cubemaps", text="", toggle=True, icon='HIDE_OFF')
+ else:
+ sub.prop(props, "gi_show_cubemaps", text="", toggle=True, icon='HIDE_ON')
+
+ row = layout.split(percentage=0.5)
+ row.alignment = 'RIGHT'
+ row.label("Irradiance Display")
+
+ sub = row.row(align=True)
+ sub.prop(props, "gi_irradiance_draw_size", text="Size")
+ if props.gi_show_irradiance:
+ sub.prop(props, "gi_show_irradiance", text="", toggle=True, icon='HIDE_OFF')
+ else:
+ sub.prop(props, "gi_show_irradiance", text="", toggle=True, icon='HIDE_ON')
+
class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
bl_label = "Film"
@@ -743,7 +782,7 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
col.prop(rd, "alpha_mode", text="Alpha")
-class RENDER_PT_hair(RenderButtonsPanel, Panel):
+class RENDER_PT_eevee_hair(RenderButtonsPanel, Panel):
bl_label = "Hair"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@@ -764,6 +803,60 @@ class RENDER_PT_hair(RenderButtonsPanel, Panel):
layout.prop(rd, "hair_subdiv")
+class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
+ bl_label = "Film"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_OPENGL'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ rd = context.scene.render
+
+ layout.prop(rd, "use_antialiasing")
+
+ layout.prop(rd, "antialiasing_samples")
+ layout.prop(rd, "alpha_mode")
+
+
+class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
+ bl_label = "Lighting"
+ COMPAT_ENGINES = {'BLENDER_OPENGL'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ VIEW3D_PT_shading_lighting.draw(self, context)
+
+
+class RENDER_PT_opengl_color(RenderButtonsPanel, Panel):
+ bl_label = "Color"
+ COMPAT_ENGINES = {'BLENDER_OPENGL'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ VIEW3D_PT_shading_color.draw(self, context)
+
+
+class RENDER_PT_opengl_options(RenderButtonsPanel, Panel):
+ bl_label = "Options"
+ COMPAT_ENGINES = {'BLENDER_OPENGL'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ VIEW3D_PT_shading_options.draw(self, context)
+
+
classes = (
RENDER_PT_presets,
RENDER_PT_ffmpeg_presets,
@@ -778,7 +871,7 @@ classes = (
RENDER_PT_stamp_burn,
RENDER_UL_renderviews,
RENDER_PT_stereoscopy,
- RENDER_PT_hair,
+ RENDER_PT_eevee_hair,
RENDER_PT_eevee_sampling,
RENDER_PT_eevee_film,
RENDER_PT_eevee_shadows,
@@ -790,6 +883,10 @@ classes = (
RENDER_PT_eevee_motion_blur,
RENDER_PT_eevee_depth_of_field,
RENDER_PT_eevee_bloom,
+ RENDER_PT_opengl_film,
+ RENDER_PT_opengl_lighting,
+ RENDER_PT_opengl_color,
+ RENDER_PT_opengl_options,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 1394a9388d0..38bfc6ad294 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -17,9 +17,9 @@
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
+
import bpy
from bpy.types import (
- Menu,
Panel,
UIList,
)
@@ -66,11 +66,12 @@ class SceneButtonsPanel:
class SCENE_PT_scene(SceneButtonsPanel, Panel):
bl_label = "Scene"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
+
scene = context.scene
layout.prop(scene, "camera")
@@ -80,7 +81,7 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel):
class SCENE_PT_unit(SceneButtonsPanel, Panel):
bl_label = "Units"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header_preset(self, context):
SCENE_PT_units_length_presets.draw_panel_header(self.layout)
@@ -92,13 +93,13 @@ class SCENE_PT_unit(SceneButtonsPanel, Panel):
layout.use_property_split = True
- col = layout.column()
- col.prop(unit, "system")
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
- col = layout.column()
+ col = flow.column()
+ col.prop(unit, "system")
col.prop(unit, "system_rotation")
- col = layout.column()
+ col = flow.column()
col.enabled = unit.system != 'NONE'
col.prop(unit, "scale_length")
col.prop(unit, "use_separate")
@@ -147,25 +148,28 @@ class SceneKeyingSetsPanel:
propname = prop
row = layout.row(align=True)
- row.prop(item, toggle_prop, text="", icon='STYLUS_PRESSURE', toggle=True) # XXX: needs dedicated icon
- subrow = row.row()
+ subrow = row.row(align=True)
subrow.active = getattr(item, toggle_prop)
+
if subrow.active:
subrow.prop(item, prop, text=label)
else:
subrow.prop(owner, propname, text=label)
+ row.prop(item, toggle_prop, text="", icon='STYLUS_PRESSURE', toggle=True) # XXX: needs dedicated icon
+
class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
bl_label = "Keying Sets"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
scene = context.scene
+
row = layout.row()
col = row.column()
@@ -175,26 +179,62 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False)
+
ks = scene.keying_sets.active
if ks and ks.is_path_absolute:
- row = layout.row()
-
- col = row.column()
+ col = flow.column()
col.prop(ks, "bl_description")
- subcol = col.column()
+ subcol = flow.column()
subcol.operator_context = 'INVOKE_DEFAULT'
subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
- col = row.column()
- col.label(text="Keyframing Settings:")
- self.draw_keyframing_settings(context, col, ks, None)
+
+class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
+ bl_label = "Keyframing Settings"
+ bl_parent_id = "SCENE_PT_keying_sets"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ ks = context.scene.keying_sets.active
+ return (ks and ks.is_path_absolute)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ scene = context.scene
+ ks = scene.keying_sets.active
+
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
+
+ col = flow.column(align=True)
+ col.alignment = 'RIGHT'
+ col.label(text="General Override")
+
+ self.draw_keyframing_settings(context, col, ks, None)
+
+ ksp = ks.paths.active
+ if ksp:
+ col.separator()
+
+ col = flow.column(align=True)
+ col.alignment = 'RIGHT'
+ col.label(text="Active Set Override")
+
+ self.draw_keyframing_settings(context, col, ks, ksp)
class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
bl_label = "Active Keying Set"
bl_parent_id = "SCENE_PT_keying_sets"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -219,39 +259,45 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
+ # TODO: 1) the template_any_ID needs to be fixed for the text alignment.
+ # 2) use_property_decorate has to properly skip the non animatable properties.
+ # Properties affected with needless draw:
+ # group_method, template_any_ID dropdown, use_entire_array
+
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation (remove this later on).
+
+ flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=True)
+
ksp = ks.paths.active
if ksp:
- col = layout.column()
- col.label(text="Target:")
- col.template_any_ID(ksp, "id", "id_type")
- col.template_path_builder(ksp, "data_path", ksp.id)
-
- row = col.row(align=True)
- row.label(text="Array Target:")
- row.prop(ksp, "use_entire_array", text="All Items")
- if ksp.use_entire_array:
- row.label(text=" ") # padding
- else:
- row.prop(ksp, "array_index", text="Index")
+ col = flow.column(align=True)
+ col.alignment = 'RIGHT'
+
+ col.template_any_ID(ksp, "id", "id_type", text="Target ID-Block")
- layout.separator()
+ col.separator()
- row = layout.row()
- col = row.column()
- col.label(text="F-Curve Grouping:")
- col.prop(ksp, "group_method", text="")
+ col.template_path_builder(ksp, "data_path", ksp.id, text="Data Path")
+
+ col = flow.column()
+
+ col.prop(ksp, "use_entire_array", text="Array All Items")
+
+ if not ksp.use_entire_array:
+ col.prop(ksp, "array_index", text="Index")
+
+ col.separator()
+
+ col.prop(ksp, "group_method", text="F-Curve Grouping")
if ksp.group_method == 'NAMED':
col.prop(ksp, "group")
- col = row.column()
- col.label(text="Keyframing Settings:")
- self.draw_keyframing_settings(context, col, ks, ksp)
-
class SCENE_PT_color_management(SceneButtonsPanel, Panel):
bl_label = "Color Management"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -260,16 +306,19 @@ class SCENE_PT_color_management(SceneButtonsPanel, Panel):
scene = context.scene
view = scene.view_settings
- col = layout.column()
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
+
+ col = flow.column()
col.prop(scene.display_settings, "display_device")
col.separator()
- col = layout.column()
col.prop(view, "view_transform")
+ col.prop(view, "look")
+
+ col = flow.column()
col.prop(view, "exposure")
col.prop(view, "gamma")
- col.prop(view, "look")
col.separator()
@@ -280,7 +329,7 @@ class SCENE_PT_color_management_curves(SceneButtonsPanel, Panel):
bl_label = "Use Curves"
bl_parent_id = "SCENE_PT_color_management"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
@@ -304,7 +353,7 @@ class SCENE_PT_color_management_curves(SceneButtonsPanel, Panel):
class SCENE_PT_audio(SceneButtonsPanel, Panel):
bl_label = "Audio"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -314,21 +363,28 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel):
rd = context.scene.render
ffmpeg = rd.ffmpeg
- layout.prop(scene, "audio_volume")
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- col = layout.column()
- col.prop(scene, "audio_distance_model")
+ col = flow.column()
+ col.prop(scene, "audio_volume")
+ col.separator()
+
+ col.prop(scene, "audio_distance_model")
col.prop(ffmpeg, "audio_channels")
+
+ col.separator()
+
+ col = flow.column()
col.prop(ffmpeg, "audio_mixrate", text="Sample Rate")
- layout.separator()
+ col.separator()
- col = layout.column(align=True)
+ col = col.column(align=True)
col.prop(scene, "audio_doppler_speed", text="Doppler Speed")
col.prop(scene, "audio_doppler_factor", text="Doppler Factor")
- layout.separator()
+ col.separator()
layout.operator("sound.bake_animation")
@@ -336,7 +392,7 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel):
class SCENE_PT_physics(SceneButtonsPanel, Panel):
bl_label = "Gravity"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
self.layout.prop(context.scene, "use_gravity", text="")
@@ -355,7 +411,7 @@ class SCENE_PT_physics(SceneButtonsPanel, Panel):
class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
bl_label = "Rigid Body World"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -372,7 +428,6 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
layout.use_property_split = True
scene = context.scene
-
rbw = scene.rigidbody_world
if rbw is None:
@@ -380,7 +435,28 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
else:
layout.operator("rigidbody.world_remove")
- col = layout.column()
+
+class SCENE_PT_rigid_body_world_settings(SceneButtonsPanel, Panel):
+ bl_label = "Settings"
+ bl_parent_id = "SCENE_PT_rigid_body_world"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and scene.rigidbody_world and (context.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ rbw = scene.rigidbody_world
+
+ if rbw:
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
+
+ col = flow.column()
col.active = rbw.enabled
col = col.column()
@@ -389,6 +465,9 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
col = col.column()
col.prop(rbw, "time_scale", text="Speed")
+
+ col = flow.column()
+ col.active = rbw.enabled
col.prop(rbw, "use_split_impulse")
col = col.column()
@@ -400,7 +479,7 @@ class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = "SCENE_PT_rigid_body_world"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -418,7 +497,7 @@ class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = "SCENE_PT_rigid_body_world"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -435,7 +514,7 @@ class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
class SCENE_PT_simplify(SceneButtonsPanel, Panel):
bl_label = "Simplify"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
rd = context.scene.render
@@ -448,7 +527,7 @@ class SCENE_PT_simplify(SceneButtonsPanel, Panel):
class SCENE_PT_simplify_viewport(SceneButtonsPanel, Panel):
bl_label = "Viewport"
bl_parent_id = "SCENE_PT_simplify"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -458,15 +537,19 @@ class SCENE_PT_simplify_viewport(SceneButtonsPanel, Panel):
layout.active = rd.use_simplify
- col = layout.column()
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
+
+ col = flow.column()
col.prop(rd, "simplify_subdivision", text="Max Subdivision")
+
+ col = flow.column()
col.prop(rd, "simplify_child_particles", text="Max Child Particles")
class SCENE_PT_simplify_render(SceneButtonsPanel, Panel):
bl_label = "Render"
bl_parent_id = "SCENE_PT_simplify"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -476,48 +559,17 @@ class SCENE_PT_simplify_render(SceneButtonsPanel, Panel):
layout.active = rd.use_simplify
- col = layout.column()
- col.prop(rd, "simplify_subdivision_render", text="Max Subdivision")
- col.prop(rd, "simplify_child_particles_render", text="Max Child Particles")
-
-
-class SCENE_PT_viewport_display(SceneButtonsPanel, Panel):
- bl_label = "Viewport Display"
- bl_options = {'DEFAULT_CLOSED'}
-
- @classmethod
- def poll(cls, context):
- return True
-
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- scene = context.scene
- col = layout.column()
- col.prop(scene.display, "light_direction")
- col.prop(scene.display, "shadow_shift")
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
+ col = flow.column()
+ col.prop(rd, "simplify_subdivision_render", text="Max Subdivision")
-class SCENE_PT_viewport_display_ssao(SceneButtonsPanel, Panel):
- bl_label = "Screen Space Ambient Occlusion"
- bl_parent_id = "SCENE_PT_viewport_display"
-
- @classmethod
- def poll(cls, context):
- return True
-
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- scene = context.scene
- col = layout.column()
- col.prop(scene.display, "matcap_ssao_samples")
- col.prop(scene.display, "matcap_ssao_distance")
- col.prop(scene.display, "matcap_ssao_attenuation")
+ col = flow.column()
+ col.prop(rd, "simplify_child_particles_render", text="Max Child Particles")
class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "scene"
_property_type = bpy.types.Scene
@@ -529,13 +581,13 @@ classes = (
SCENE_PT_unit,
SCENE_PT_keying_sets,
SCENE_PT_keying_set_paths,
+ SCENE_PT_keyframing_settings,
SCENE_PT_color_management,
SCENE_PT_color_management_curves,
- SCENE_PT_viewport_display,
- SCENE_PT_viewport_display_ssao,
SCENE_PT_audio,
SCENE_PT_physics,
SCENE_PT_rigid_body_world,
+ SCENE_PT_rigid_body_world_settings,
SCENE_PT_rigid_body_cache,
SCENE_PT_rigid_body_field_weights,
SCENE_PT_simplify,
diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index 16e29d1ecc8..d937f2470b8 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -83,7 +83,7 @@ class TextureButtonsPanel:
class TEXTURE_PT_preview(TextureButtonsPanel, Panel):
bl_label = "Preview"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -112,7 +112,7 @@ class TEXTURE_PT_context(TextureButtonsPanel, Panel):
bl_label = ""
bl_context = "texture"
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -123,34 +123,35 @@ class TEXTURE_PT_context(TextureButtonsPanel, Panel):
use_pin_id = space.use_pin_id
user = context.texture_user
+ col = layout.column()
+
if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)):
pin_id = None
if not pin_id:
- layout.template_texture_user()
+ col.template_texture_user()
- if user or pin_id:
- layout.separator()
-
- split = layout.split(percentage=0.65)
- col = split.column()
+ col.separator()
+ if user or pin_id:
if pin_id:
col.template_ID(space, "pin_id")
else:
propname = context.texture_user_property.identifier
col.template_ID(user, propname, new="texture.new")
+ col.separator()
+
if tex:
- split = layout.split(percentage=0.2)
- split.label(text="Type:")
+ split = col.split(percentage=0.2)
+ split.label(text="Type")
split.prop(tex, "type", text="")
class TEXTURE_PT_node(TextureButtonsPanel, Panel):
bl_label = "Node"
bl_context = "texture"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -168,7 +169,7 @@ class TEXTURE_PT_node(TextureButtonsPanel, Panel):
class TEXTURE_PT_node_mapping(TextureButtonsPanel, Panel):
bl_label = "Mapping"
bl_context = "texture"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -199,39 +200,6 @@ class TEXTURE_PT_node_mapping(TextureButtonsPanel, Panel):
row.prop(mapping, "mapping_z", text="")
-class TEXTURE_PT_colors(TextureButtonsPanel, Panel):
- bl_label = "Colors"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
-
- @classmethod
- def poll(cls, context):
- tex = context.texture
- return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
-
- tex = context.texture
-
- col = layout.column()
- sub = col.column(align=True)
- sub.prop(tex, "factor_red", text="Multiply R")
- sub.prop(tex, "factor_green", text="G")
- sub.prop(tex, "factor_blue", text="B")
-
- col.prop(tex, "intensity")
- col.prop(tex, "contrast")
- col.prop(tex, "saturation")
-
- col.prop(tex, "use_clamp", text="Clamp")
- col.prop(tex, "use_color_ramp", text="Ramp")
- if tex.use_color_ramp:
- layout.use_property_split = False
- layout.template_color_ramp(tex, "color_ramp", expand=True)
-
-
class TextureTypePanel(TextureButtonsPanel):
@classmethod
@@ -244,7 +212,7 @@ class TextureTypePanel(TextureButtonsPanel):
class TEXTURE_PT_clouds(TextureTypePanel, Panel):
bl_label = "Clouds"
tex_type = 'CLOUDS'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -268,7 +236,7 @@ class TEXTURE_PT_clouds(TextureTypePanel, Panel):
class TEXTURE_PT_wood(TextureTypePanel, Panel):
bl_label = "Wood"
tex_type = 'WOOD'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -297,7 +265,7 @@ class TEXTURE_PT_wood(TextureTypePanel, Panel):
class TEXTURE_PT_marble(TextureTypePanel, Panel):
bl_label = "Marble"
tex_type = 'MARBLE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -324,7 +292,7 @@ class TEXTURE_PT_marble(TextureTypePanel, Panel):
class TEXTURE_PT_magic(TextureTypePanel, Panel):
bl_label = "Magic"
tex_type = 'MAGIC'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -339,7 +307,7 @@ class TEXTURE_PT_magic(TextureTypePanel, Panel):
class TEXTURE_PT_blend(TextureTypePanel, Panel):
bl_label = "Blend"
tex_type = 'BLEND'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -357,7 +325,7 @@ class TEXTURE_PT_blend(TextureTypePanel, Panel):
class TEXTURE_PT_stucci(TextureTypePanel, Panel):
bl_label = "Stucci"
tex_type = 'STUCCI'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -377,125 +345,137 @@ class TEXTURE_PT_stucci(TextureTypePanel, Panel):
class TEXTURE_PT_image(TextureTypePanel, Panel):
bl_label = "Image"
tex_type = 'IMAGE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
tex = context.texture
-
layout.template_image(tex, "image", tex.image_user)
def texture_filter_common(tex, layout):
- layout.label(text="Filter:")
- layout.prop(tex, "filter_type", text="")
+ layout.prop(tex, "filter_type", text="Filter Type")
if tex.use_mipmap and tex.filter_type in {'AREA', 'EWA', 'FELINE'}:
if tex.filter_type == 'FELINE':
layout.prop(tex, "filter_lightprobes", text="Light Probes")
else:
layout.prop(tex, "filter_eccentricity", text="Eccentricity")
- layout.prop(tex, "filter_size")
- layout.prop(tex, "use_filter_size_min")
+ layout.prop(tex, "filter_size", text="Size")
+ layout.prop(tex, "use_filter_size_min", text="Minimum Size")
class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
- bl_label = "Image Sampling"
+ bl_label = "Sampling"
bl_options = {'DEFAULT_CLOSED'}
+ bl_parent_id = 'TEXTURE_PT_image'
tex_type = 'IMAGE'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
idblock = context_tex_datablock(context)
tex = context.texture
slot = getattr(context, "texture_slot", None)
- split = layout.split()
-
- col = split.column()
- col.label(text="Alpha:")
- row = col.row()
- row.active = bool(tex.image and tex.image.use_alpha)
- row.prop(tex, "use_alpha", text="Use")
- col.prop(tex, "use_calculate_alpha", text="Calculate")
- col.prop(tex, "invert_alpha", text="Invert")
- col.separator()
+ col = flow.column()
col.prop(tex, "use_flip_axis", text="Flip X/Y Axis")
+ col.prop(tex, "use_interpolation")
- col = split.column()
+ col.separator()
+ col = flow.column()
col.prop(tex, "use_mipmap")
- row = col.row()
- row.active = tex.use_mipmap
- row.prop(tex, "use_mipmap_gauss")
- col.prop(tex, "use_interpolation")
+ sub = col.column()
+ sub.active = tex.use_mipmap
+ sub.prop(tex, "use_mipmap_gauss", text="Gaussian Filter")
+ col.separator()
+
+ col = flow.column()
texture_filter_common(tex, col)
-class TEXTURE_PT_image_mapping(TextureTypePanel, Panel):
- bl_label = "Image Mapping"
+class TEXTURE_PT_image_alpha(TextureTypePanel, Panel):
+ bl_label = "Alpha"
bl_options = {'DEFAULT_CLOSED'}
+ bl_parent_id = 'TEXTURE_PT_image'
tex_type = 'IMAGE'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ def draw_header(self, context):
+ tex = context.texture
+ self.layout.prop(tex, "use_alpha", text="")
+
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
tex = context.texture
- layout.prop(tex, "extension")
+ col = layout.column()
+ col.active = bool(tex.image and tex.image.use_alpha)
+ col.prop(tex, "use_calculate_alpha", text="Calculate")
+ col.prop(tex, "invert_alpha", text="Invert")
- split = layout.split()
+
+class TEXTURE_PT_image_mapping(TextureTypePanel, Panel):
+ bl_label = "Mapping"
+ bl_options = {'DEFAULT_CLOSED'}
+ bl_parent_id = 'TEXTURE_PT_image'
+ tex_type = 'IMAGE'
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
+
+ tex = context.texture
+
+ col = flow.column()
+ col.prop(tex, "extension")
if tex.extension == 'REPEAT':
- col = split.column(align=True)
- col.label(text="Repeat:")
- col.prop(tex, "repeat_x", text="X")
- col.prop(tex, "repeat_y", text="Y")
-
- col = split.column(align=True)
- col.label(text="Mirror:")
- row = col.row(align=True)
- row.prop(tex, "use_mirror_x", text="X")
- row.active = (tex.repeat_x > 1)
- row = col.row(align=True)
- row.prop(tex, "use_mirror_y", text="Y")
- row.active = (tex.repeat_y > 1)
- layout.separator()
+ sub = col.column(align=True)
+ sub.prop(tex, "repeat_x", text="Repeat X")
+ sub.prop(tex, "repeat_y", text="Y")
- elif tex.extension == 'CHECKER':
- col = split.column(align=True)
- row = col.row(align=True)
- row.prop(tex, "use_checker_even", text="Even")
- row.prop(tex, "use_checker_odd", text="Odd")
+ sub = col.column()
+ sub.prop(tex, "use_mirror_x", text="Mirror X")
+ sub.active = (tex.repeat_x > 1)
- col = split.column()
- col.prop(tex, "checker_distance", text="Distance")
+ sub = col.column()
+ sub.prop(tex, "use_mirror_y", text="Y")
+ sub.active = (tex.repeat_y > 1)
- layout.separator()
+ elif tex.extension == 'CHECKER':
+ col = layout.column(align=True)
+ col.prop(tex, "use_checker_even", text="Even")
+ col.prop(tex, "use_checker_odd", text="Odd")
- split = layout.split()
+ col = layout.column()
+ col.prop(tex, "checker_distance", text="Distance")
- col = split.column(align=True)
+ col = flow.column()
+ sub = col.column(align=True)
# col.prop(tex, "crop_rectangle")
- col.label(text="Crop Minimum:")
- col.prop(tex, "crop_min_x", text="X")
- col.prop(tex, "crop_min_y", text="Y")
+ sub.prop(tex, "crop_min_x", text="Crop Minimum X")
+ sub.prop(tex, "crop_min_y", text="Y")
- col = split.column(align=True)
- col.label(text="Crop Maximum:")
- col.prop(tex, "crop_max_x", text="X")
- col.prop(tex, "crop_max_y", text="Y")
+ sub = col.column(align=True)
+ sub.prop(tex, "crop_max_x", text="Crop Maximum X")
+ sub.prop(tex, "crop_max_y", text="Y")
class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
bl_label = "Musgrave"
tex_type = 'MUSGRAVE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -531,7 +511,7 @@ class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
class TEXTURE_PT_voronoi(TextureTypePanel, Panel):
bl_label = "Voronoi"
tex_type = 'VORONOI'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -567,7 +547,7 @@ class TEXTURE_PT_voronoi(TextureTypePanel, Panel):
class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
bl_label = "Distorted Noise"
tex_type = 'DISTORTED_NOISE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
@@ -587,7 +567,7 @@ class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
class TextureSlotPanel(TextureButtonsPanel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -599,7 +579,7 @@ class TextureSlotPanel(TextureButtonsPanel):
class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
bl_label = "Mapping"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -677,7 +657,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
class TEXTURE_PT_influence(TextureSlotPanel, Panel):
bl_label = "Influence"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -762,8 +742,41 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
col.prop(tex, "use_stencil")
+class TEXTURE_PT_colors(TextureButtonsPanel, Panel):
+ bl_label = "Colors"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+
+ @classmethod
+ def poll(cls, context):
+ tex = context.texture
+ return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ tex = context.texture
+
+ col = layout.column()
+ sub = col.column(align=True)
+ sub.prop(tex, "factor_red", text="Multiply R")
+ sub.prop(tex, "factor_green", text="G")
+ sub.prop(tex, "factor_blue", text="B")
+
+ col.prop(tex, "intensity")
+ col.prop(tex, "contrast")
+ col.prop(tex, "saturation")
+
+ col.prop(tex, "use_clamp", text="Clamp")
+ col.prop(tex, "use_color_ramp", text="Ramp")
+ if tex.use_color_ramp:
+ layout.use_property_split = False
+ layout.template_color_ramp(tex, "color_ramp", expand=True)
+
+
class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "texture"
_property_type = Texture
@@ -781,7 +794,6 @@ classes = (
TEXTURE_PT_node_mapping,
TEXTURE_PT_mapping,
TEXTURE_PT_influence,
- TEXTURE_PT_colors,
TEXTURE_PT_clouds,
TEXTURE_PT_wood,
TEXTURE_PT_marble,
@@ -789,11 +801,13 @@ classes = (
TEXTURE_PT_blend,
TEXTURE_PT_stucci,
TEXTURE_PT_image,
+ TEXTURE_PT_image_alpha,
TEXTURE_PT_image_sampling,
TEXTURE_PT_image_mapping,
TEXTURE_PT_musgrave,
TEXTURE_PT_voronoi,
TEXTURE_PT_distortednoise,
+ TEXTURE_PT_colors,
TEXTURE_PT_custom_props,
)
diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py
index 05dc15216a2..f96bf041311 100644
--- a/release/scripts/startup/bl_ui/properties_view_layer.py
+++ b/release/scripts/startup/bl_ui/properties_view_layer.py
@@ -34,7 +34,7 @@ class ViewLayerButtonsPanel:
class VIEWLAYER_PT_layer(ViewLayerButtonsPanel, Panel):
bl_label = "View Layer"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py
index bba7f9e132a..7395fa13d9a 100644
--- a/release/scripts/startup/bl_ui/properties_world.py
+++ b/release/scripts/startup/bl_ui/properties_world.py
@@ -20,7 +20,7 @@
import bpy
from bpy.types import Panel
from rna_prop_ui import PropertyPanel
-from bpy_extras.node_utils import find_node_input, find_output_node
+from bpy_extras.node_utils import find_node_input
class WorldButtonsPanel:
@@ -37,7 +37,7 @@ class WorldButtonsPanel:
class WORLD_PT_context_world(WorldButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
@classmethod
def poll(cls, context):
@@ -50,11 +50,10 @@ class WORLD_PT_context_world(WorldButtonsPanel, Panel):
world = context.world
space = context.space_data
- split = layout.split(percentage=0.85)
if scene:
- split.template_ID(scene, "world", new="world.new")
+ layout.template_ID(scene, "world", new="world.new")
elif world:
- split.template_ID(space, "pin_id")
+ layout.template_ID(space, "pin_id")
class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel):
@@ -84,14 +83,13 @@ class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel):
class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "world"
_property_type = bpy.types.World
class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel):
bl_label = "Surface"
- bl_context = "world"
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
@@ -109,7 +107,7 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel):
if world.use_nodes:
ntree = world.node_tree
- node = find_output_node(ntree, ('OUTPUT_WORLD',))
+ node = ntree.get_output_node('EEVEE')
if node:
input = find_node_input(node, 'Surface')
@@ -120,14 +118,30 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel):
else:
layout.label(text="No output node")
else:
- layout.prop(world, "horizon_color", text="Color")
+ layout.prop(world, "color")
+
+
+class WORLD_PT_viewport_display(WorldButtonsPanel, Panel):
+ bl_label = "Viewport Display"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ @classmethod
+ def poll(cls, context):
+ return context.world
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ world = context.world
+ layout.prop(world, "color")
classes = (
WORLD_PT_context_world,
- WORLD_PT_custom_props,
EEVEE_WORLD_PT_surface,
EEVEE_WORLD_PT_mist,
+ WORLD_PT_viewport_display,
+ WORLD_PT_custom_props,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index e03d53a1870..efd5e195fb8 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -132,8 +132,8 @@ class DopesheetFilterPopoverBase:
flow.prop(dopesheet, "show_cameras", text="Cameras")
if bpy.data.grease_pencil:
flow.prop(dopesheet, "show_gpencil", text="Grease Pencil Objects")
- if bpy.data.lamps:
- flow.prop(dopesheet, "show_lamps", text="Lamps")
+ if bpy.data.lights:
+ flow.prop(dopesheet, "show_lights", text="Lights")
if bpy.data.materials:
flow.prop(dopesheet, "show_materials", text="Materials")
if bpy.data.textures:
@@ -263,9 +263,7 @@ class DOPESHEET_HT_editor_buttons(Header):
row.prop(st.dopesheet, "filter_text", text="")
layout.popover(
- space_type='DOPESHEET_EDITOR',
- region_type='HEADER',
- panel_type="DOPESHEET_PT_filters",
+ panel="DOPESHEET_PT_filters",
text="",
icon='FILTER',
)
@@ -280,11 +278,10 @@ class DOPESHEET_HT_editor_buttons(Header):
sub.active = toolsettings.use_proportional_action
sub.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
-
row = layout.row(align=True)
row.operator("action.copy", text="", icon='COPYDOWN')
row.operator("action.paste", text="", icon='PASTEDOWN')
- if st.mode not in ('GPENCIL', 'MASK'):
+ if st.mode not in {'GPENCIL', 'MASK'}:
row.operator("action.paste", text="", icon='PASTEFLIPDOWN').flipped = True
@@ -359,9 +356,9 @@ class DOPESHEET_MT_select(Menu):
def draw(self, context):
layout = self.layout
- # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
- layout.operator("action.select_all_toggle").invert = False
- layout.operator("action.select_all_toggle", text="Invert Selection").invert = True
+ layout.operator("action.select_all", text="All").action = 'SELECT'
+ layout.operator("action.select_all", text="None").action = 'DESELECT'
+ layout.operator("action.select_all", text="Invert").action = 'INVERT'
layout.separator()
layout.operator("action.select_border").axis_range = False
diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index 0a6077e6b57..eacfb364130 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -60,9 +60,7 @@ class GRAPH_HT_header(Header):
row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
layout.popover(
- space_type='GRAPH_EDITOR',
- region_type='HEADER',
- panel_type="GRAPH_PT_filters",
+ panel="GRAPH_PT_filters",
text="",
icon='FILTER',
)
@@ -165,11 +163,12 @@ class GRAPH_MT_select(Menu):
def draw(self, context):
layout = self.layout
- # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
- layout.operator("graph.select_all_toggle").invert = False
- layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
+ layout.operator("graph.select_all", text="All").action = 'SELECT'
+ layout.operator("graph.select_all", text="None").action = 'DESELECT'
+ layout.operator("graph.select_all", text="Invert").action = 'INVERT'
layout.separator()
+
props = layout.operator("graph.select_border")
props.axis_range = False
props.include_handles = False
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index ba63b2b216e..1303e46ab6c 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -139,14 +139,20 @@ class IMAGE_MT_select(Menu):
def draw(self, context):
layout = self.layout
+ layout.operator("uv.select_all", text="All").action = 'SELECT'
+ layout.operator("uv.select_all", text="None").action = 'DESELECT'
+ layout.operator("uv.select_all", text="Invert").action = 'INVERT'
+
+ layout.separator()
+
layout.operator("uv.select_border").pinned = False
layout.operator("uv.select_border", text="Border Select Pinned").pinned = True
layout.operator("uv.circle_select")
layout.separator()
- layout.operator("uv.select_all").action = 'TOGGLE'
- layout.operator("uv.select_all", text="Inverse").action = 'INVERT'
+ layout.operator("uv.select_less", text="Less")
+ layout.operator("uv.select_more", text="More")
layout.separator()
@@ -155,11 +161,6 @@ class IMAGE_MT_select(Menu):
layout.separator()
- layout.operator("uv.select_less", text="Less")
- layout.operator("uv.select_more", text="More")
-
- layout.separator()
-
layout.operator("uv.select_split")
@@ -190,30 +191,33 @@ class IMAGE_MT_image(Menu):
sima = context.space_data
ima = sima.image
-
- layout.operator("image.new")
- layout.operator("image.open")
-
show_render = sima.show_render
- layout.operator("image.read_viewlayers")
+ layout.operator("image.new", text="New")
+ layout.operator("image.open", text="Open...")
- layout.operator("image.save_dirty", text="Save All Images")
+ layout.operator("image.read_viewlayers")
if ima:
if not show_render:
- layout.operator("image.replace")
- layout.operator("image.reload")
+ layout.operator("image.replace", text="Replace...")
+ layout.operator("image.reload", text="Reload")
- layout.operator("image.save")
- layout.operator("image.save_as")
- layout.operator("image.save_as", text="Save a Copy").copy = True
+ layout.operator("image.external_edit", "Edit Externally")
- if ima.source == 'SEQUENCE':
- layout.operator("image.save_sequence")
+ layout.separator()
- layout.operator("image.external_edit", "Edit Externally")
+ if ima:
+ layout.operator("image.save", text="Save")
+ layout.operator("image.save_as", text="Save As...")
+ layout.operator("image.save_as", text="Save a Copy...").copy = True
+
+ if ima and ima.source == 'SEQUENCE':
+ layout.operator("image.save_sequence")
+ layout.operator("image.save_dirty", text="Save All Images")
+
+ if ima:
layout.separator()
layout.menu("IMAGE_MT_image_invert")
@@ -221,7 +225,7 @@ class IMAGE_MT_image(Menu):
if not show_render:
if not ima.packed_file:
layout.separator()
- layout.operator("image.pack")
+ layout.operator("image.pack", text="Pack")
# only for dirty && specific image types, perhaps
# this could be done in operator poll too
diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py
index 304fc799fea..4e20001b133 100644
--- a/release/scripts/startup/bl_ui/space_nla.py
+++ b/release/scripts/startup/bl_ui/space_nla.py
@@ -44,9 +44,7 @@ class NLA_HT_header(Header):
dopesheet_filter(layout, context)
layout.popover(
- space_type='NLA_EDITOR',
- region_type='HEADER',
- panel_type="NLA_PT_filters",
+ panel="NLA_PT_filters",
text="",
icon='FILTER',
)
@@ -126,9 +124,9 @@ class NLA_MT_select(Menu):
def draw(self, context):
layout = self.layout
- # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
- layout.operator("nla.select_all_toggle").invert = False
- layout.operator("nla.select_all_toggle", text="Invert Selection").invert = True
+ layout.operator("nla.select_all", text="All").action = 'SELECT'
+ layout.operator("nla.select_all", text="None").action = 'DESELECT'
+ layout.operator("nla.select_all", text="Invert").action = 'INVERT'
layout.separator()
layout.operator("nla.select_border").axis_range = False
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 3960f336cd0..9d8c14ba9c3 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -61,7 +61,7 @@ class NODE_HT_header(Header):
NODE_MT_editor_menus.draw_collapsible(context, layout)
# No shader nodes for Eevee lamps
- if snode_id and not (context.engine == 'BLENDER_EEVEE' and ob.type == 'LAMP'):
+ if snode_id and not (context.engine == 'BLENDER_EEVEE' and ob.type == 'LIGHT'):
row = layout.row()
row.prop(snode_id, "use_nodes")
@@ -73,12 +73,11 @@ class NODE_HT_header(Header):
# Show material.new when no active ID/slot exists
if not id_from and ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'METABALL'}:
row.template_ID(ob, "active_material", new="material.new")
- # Material ID, but not for Lamps
- if id_from and ob.type != 'LAMP':
+ # Material ID, but not for Lights
+ if id_from and ob.type != 'LIGHT':
row.template_ID(id_from, "active_material", new="material.new")
if snode.shader_type == 'WORLD':
-
NODE_MT_editor_menus.draw_collapsible(context, layout)
if snode_id:
diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 19f3bcd3b1f..8f722c4d3ce 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -49,11 +49,11 @@ class OUTLINER_HT_header(Header):
row = layout.row(align=True)
if display_mode in {'VIEW_LAYER'}:
- row.popover(space_type='OUTLINER',
- region_type='HEADER',
- panel_type="OUTLINER_PT_filter",
- text="",
- icon='FILTER')
+ row.popover(
+ panel="OUTLINER_PT_filter",
+ text="",
+ icon='FILTER',
+ )
elif display_mode in {'LIBRARIES', 'ORPHAN_DATA'}:
row.prop(space, "use_filter_id_type", text="", icon='FILTER')
sub = row.row(align=True)
@@ -134,7 +134,6 @@ class OUTLINER_MT_edit_datablocks(Menu):
layout.operator("outliner.drivers_delete_selected")
-
class OUTLINER_MT_collection_view_layer(Menu):
bl_label = "View Layer"
@@ -221,8 +220,8 @@ class OUTLINER_MT_object(Menu):
if object_mode in {'EDIT', 'POSE'}:
name = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode].name
- layout.operator("outliner.object_operation", text=f"{name} Set").type = 'OBJECT_MODE_ENTER'
- layout.operator("outliner.object_operation", text=f"{name} Clear").type = 'OBJECT_MODE_EXIT'
+ layout.operator("outliner.object_operation", text=f"{name:s} Set").type = 'OBJECT_MODE_ENTER'
+ layout.operator("outliner.object_operation", text=f"{name:s} Clear").type = 'OBJECT_MODE_EXIT'
del name
layout.separator()
@@ -261,28 +260,31 @@ class OUTLINER_PT_filter(Panel):
col = layout.column(align=True)
- col.prop(space, "use_filter_collection", text="Collections", icon="GROUP")
- col.prop(space, "use_filter_object", text="Objects", icon="OBJECT_DATAMODE")
+ col.prop(space, "use_filter_collection", text="Collections", icon='GROUP')
+ col.prop(space, "use_filter_object", text="Objects", icon='OBJECT_DATAMODE')
sub = col.column(align=True)
sub.active = space.use_filter_object
if bpy.data.meshes:
- sub.prop(space, "use_filter_object_mesh", text="Meshes", icon="MESH_DATA")
+ sub.prop(space, "use_filter_object_mesh", text="Meshes", icon='MESH_DATA')
if bpy.data.armatures:
- sub.prop(space, "use_filter_object_armature", text="Armatures", icon="ARMATURE_DATA")
- if bpy.data.lamps:
- sub.prop(space, "use_filter_object_lamp", text="Lamps", icon="LAMP_DATA")
+ sub.prop(space, "use_filter_object_armature", text="Armatures", icon='ARMATURE_DATA')
+ if bpy.data.lights:
+ sub.prop(space, "use_filter_object_light", text="Lights", icon='LIGHT_DATA')
if bpy.data.cameras:
- sub.prop(space, "use_filter_object_camera", text="Cameras", icon="CAMERA_DATA")
-
- sub.prop(space, "use_filter_object_empty", text="Empties", icon="EMPTY_DATA")
-
- if bpy.data.curves or \
- bpy.data.metaballs or \
- bpy.data.lightprobes or \
- bpy.data.lattices or \
- bpy.data.fonts or bpy.data.speakers:
+ sub.prop(space, "use_filter_object_camera", text="Cameras", icon='CAMERA_DATA')
+
+ sub.prop(space, "use_filter_object_empty", text="Empties", icon='EMPTY_DATA')
+
+ if (
+ bpy.data.curves or
+ bpy.data.metaballs or
+ bpy.data.lightprobes or
+ bpy.data.lattices or
+ bpy.data.fonts or
+ bpy.data.speakers
+ ):
sub.prop(space, "use_filter_object_others", text="Others")
subsub = sub.column(align=False)
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index dc966850b69..5fc9be2aa5b 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -249,6 +249,12 @@ class SEQUENCER_MT_select(Menu):
def draw(self, context):
layout = self.layout
+ layout.operator("sequencer.select_all", text="All").action = 'SELECT'
+ layout.operator("sequencer.select_all", text="None").action = 'DESELECT'
+ layout.operator("sequencer.select_all", text="Invert").action = 'INVERT'
+
+ layout.separator()
+
layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT'
layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT'
props = layout.operator("sequencer.select", text="All Strips to the Left")
@@ -267,8 +273,6 @@ class SEQUENCER_MT_select(Menu):
layout.operator("sequencer.select_linked")
layout.operator("sequencer.select_less")
layout.operator("sequencer.select_more")
- layout.operator("sequencer.select_all").action = 'TOGGLE'
- layout.operator("sequencer.select_all", text="Inverse").action = 'INVERT'
class SEQUENCER_MT_marker(Menu):
@@ -1285,7 +1289,7 @@ class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, SequencerButtonsP
class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
_context_path = "scene.sequence_editor.active_strip"
_property_type = (bpy.types.Sequence,)
bl_category = "Strip"
diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py
index 95124d2be83..8e370326d8c 100644
--- a/release/scripts/startup/bl_ui/space_text.py
+++ b/release/scripts/startup/bl_ui/space_text.py
@@ -60,12 +60,12 @@ class TEXT_HT_header(Header):
if text.filepath:
if text.is_dirty:
row.label(
- iface_(f"File: *{text.filepath} (unsaved)"),
+ iface_(f"File: *{text.filepath:s} (unsaved)"),
translate=False,
)
else:
row.label(
- iface_(f"File: {text.filepath}"),
+ iface_(f"File: {text.filepath:s}"),
translate=False,
)
else:
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index 179f1c90d2e..99e5f6b08e5 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -91,20 +91,20 @@ class TIME_MT_editor_menus(Menu):
@staticmethod
def draw_menus(layout, context):
- layout.popover(
- space_type='DOPESHEET_EDITOR',
- region_type='HEADER',
- panel_type="TIME_PT_playback",
+ row = layout.row()
+ sub = row.row(align=True)
+ sub.popover(
+ panel="TIME_PT_playback",
text="Playback",
)
- layout.popover(
- space_type='DOPESHEET_EDITOR',
- region_type='HEADER',
- panel_type="TIME_PT_keyframing_settings",
+ sub.popover(
+ panel="TIME_PT_keyframing_settings",
text="Keying",
)
- layout.menu("TIME_MT_view")
- layout.menu("TIME_MT_marker")
+
+ sub = row.row(align=True)
+ sub.menu("TIME_MT_view")
+ sub.menu("TIME_MT_marker")
class TIME_MT_marker(Menu):
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 20db56af416..4f6e42d4a98 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -74,7 +74,7 @@ ToolDef = namedtuple(
"icon",
# An optional cursor to use when this tool is active.
"cursor",
- # An optional manipulator group to activate when the tool is set or None for no widget.
+ # An optional gizmo group to activate when the tool is set or None for no gizmo.
"widget",
# Optional keymap for tool, either:
# - A function that populates a keymaps passed in as an argument.
@@ -88,6 +88,8 @@ ToolDef = namedtuple(
# Optional data-block assosiated with this tool.
# (Typically brush name, usage depends on mode, we could use for non-brush ID's in other modes).
"data_block",
+ # Optional primary operator (for introspection only).
+ "operator",
# Optional draw settings (operator options, toolsettings).
"draw_settings",
)
@@ -107,6 +109,7 @@ def from_dict(kw_args):
"widget": None,
"keymap": None,
"data_block": None,
+ "operator": None,
"draw_settings": None,
}
kw.update(kw_args)
@@ -290,7 +293,7 @@ class ToolSelectPanelHelper:
def _km_action_simple(cls, kc, context_mode, text, keymap_fn):
if context_mode is None:
context_mode = "All"
- km_idname = f"{cls.keymap_prefix} {context_mode}, {text}"
+ km_idname = f"{cls.keymap_prefix:s} {context_mode:s}, {text:s}"
km = kc.keymaps.get(km_idname)
if km is None:
km = kc.keymaps.new(km_idname, space_type=cls.bl_space_type, region_type='WINDOW')
@@ -566,8 +569,9 @@ def _activate_by_item(context, space_type, item, index):
name=item.text,
keymap=item.keymap[0].name if item.keymap is not None else "",
cursor=item.cursor or 'DEFAULT',
- manipulator_group=item.widget or "",
+ gizmo_group=item.widget or "",
data_block=item.data_block or "",
+ operator=item.operator or "",
index=index,
)
@@ -620,7 +624,20 @@ def keymap_from_context(context, space_type):
"""
Keymap for popup toolbar, currently generated each time.
"""
+
+ def modifier_keywords_from_item(kmi):
+ return {
+ "any": kmi.any,
+ "shift": kmi.shift,
+ "ctrl": kmi.ctrl,
+ "alt": kmi.alt,
+ "oskey": kmi.oskey,
+ "key_modifier": kmi.key_modifier,
+ }
+
+ use_search = False # allows double tap
use_simple_keymap = False
+
km_name = "Toolbar Popup"
wm = context.window_manager
keyconf = wm.keyconfigs.active
@@ -630,6 +647,10 @@ def keymap_from_context(context, space_type):
for kmi in keymap.keymap_items:
keymap.keymap_items.remove(kmi)
+ if use_search:
+ kmi_search = wm.keyconfigs.find_item_from_operator(idname="wm.toolbar")[1]
+ kmi_search_type = None if not kmi_search else kmi_search.type
+
items = []
cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
for i, item in enumerate(
@@ -643,15 +664,21 @@ def keymap_from_context(context, space_type):
kmi.properties.name = item.text
continue
- if not item.keymap:
- continue
-
# Only check the first item in the tools key-map (a little arbitrary).
- kmi_first = item.keymap[0].keymap_items[0]
- kmi_found = wm.keyconfigs.find_item_from_operator(
- idname=kmi_first.idname,
- # properties=kmi_first.properties, # prevents matches, don't use.
- )[1]
+ if item.operator is not None:
+ kmi_found = wm.keyconfigs.find_item_from_operator(
+ idname=item.operator,
+ )[1]
+ elif item.keymap is not None:
+ kmi_first = item.keymap[0].keymap_items[0]
+ kmi_found = wm.keyconfigs.find_item_from_operator(
+ idname=kmi_first.idname,
+ # properties=kmi_first.properties, # prevents matches, don't use.
+ )[1]
+ del kmi_first
+ else:
+ kmi_found = None
+
if kmi_found is not None:
kmi_found_type = kmi_found.type
# Only for single keys.
@@ -660,15 +687,30 @@ def keymap_from_context(context, space_type):
idname="wm.tool_set_by_name",
type=kmi_found_type,
value='PRESS',
- any=kmi_found.any,
- shift=kmi_found.shift,
- ctrl=kmi_found.ctrl,
- alt=kmi_found.alt,
- oskey=kmi_found.oskey,
- key_modifier=kmi_found.key_modifier,
+ **modifier_keywords_from_item(kmi_found),
)
kmi.properties.name = item.text
+ if use_search:
+ # Disallow overlap
+ if kmi_search_type == kmi_found_type:
+ kmi_search_type = None
+
+ if use_search:
+ # Support double-tap for search.
+ if kmi_search_type:
+ keymap.keymap_items.new("wm.search_menu", type=kmi_search_type, value='PRESS')
+ else:
+ # The shortcut will show, so we better support running it.
+ kmi_search = wm.keyconfigs.find_item_from_operator(idname="wm.search_menu")[1]
+ if kmi_search:
+ keymap.keymap_items.new(
+ "wm.search_menu",
+ type=kmi_search.type,
+ value='PRESS',
+ **modifier_keywords_from_item(kmi_search),
+ )
+
wm.keyconfigs.update()
return keymap
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 110611cf7ab..eeb47595213 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -118,7 +118,7 @@ class _defs_view3d_generic:
return dict(
text="Ruler",
icon="ops.view3d.ruler",
- widget="VIEW3D_WGT_ruler",
+ widget="VIEW3D_GGT_ruler",
keymap=(
("view3d.ruler_add", dict(), dict(type='EVT_TWEAK_A', value='ANY')),
),
@@ -130,11 +130,12 @@ class _defs_transform:
@ToolDef.from_fn
def translate():
return dict(
- text="Move",
+ text="Grab",
# cursor='SCROLL_XY',
icon="ops.transform.translate",
- widget="TRANSFORM_WGT_manipulator",
- # TODO, implement as optional fallback manipulator
+ widget="TRANSFORM_GGT_gizmo",
+ operator="transform.translate",
+ # TODO, implement as optional fallback gizmo
# keymap=(
# ("transform.translate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
# ),
@@ -146,8 +147,9 @@ class _defs_transform:
text="Rotate",
# cursor='SCROLL_XY',
icon="ops.transform.rotate",
- widget="TRANSFORM_WGT_manipulator",
- # TODO, implement as optional fallback manipulator
+ widget="TRANSFORM_GGT_gizmo",
+ operator="transform.rotate",
+ # TODO, implement as optional fallback gizmo
# keymap=(
# ("transform.rotate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
# ),
@@ -159,8 +161,9 @@ class _defs_transform:
text="Scale",
# cursor='SCROLL_XY',
icon="ops.transform.resize",
- widget="TRANSFORM_WGT_manipulator",
- # TODO, implement as optional fallback manipulator
+ widget="TRANSFORM_GGT_gizmo",
+ operator="transform.resize",
+ # TODO, implement as optional fallback gizmo
# keymap=(
# ("transform.resize", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
# ),
@@ -171,20 +174,21 @@ class _defs_transform:
return dict(
text="Scale Cage",
icon="ops.transform.resize.cage",
- widget="VIEW3D_WGT_xform_cage",
+ widget="VIEW3D_GGT_xform_cage",
+ operator="transform.resize",
)
@ToolDef.from_fn
def transform():
def draw_settings(context, layout, tool):
tool_settings = context.tool_settings
- layout.prop(tool_settings, "use_manipulator_mode")
+ layout.prop(tool_settings, "use_gizmo")
return dict(
text="Transform",
icon="ops.transform.transform",
- widget="TRANSFORM_WGT_manipulator",
- # No keymap default action, only for manipulators!
+ widget="TRANSFORM_GGT_gizmo",
+ # No keymap default action, only for gizmo!
draw_settings=draw_settings,
)
@@ -316,7 +320,7 @@ class _defs_edit_mesh:
widget=None,
keymap=(
("view3d.cursor3d", dict(), dict(type='ACTIONMOUSE', value='CLICK')),
- ("mesh.primitive_cube_add_manipulator", dict(), dict(type='EVT_TWEAK_A', value='ANY')),
+ ("mesh.primitive_cube_add_gizmo", dict(), dict(type='EVT_TWEAK_A', value='ANY')),
),
)
@@ -458,7 +462,8 @@ class _defs_edit_mesh:
return dict(
text="Extrude Region",
icon="ops.mesh.extrude_region_move",
- widget="MESH_WGT_extrude",
+ widget="MESH_GGT_extrude",
+ operator="view3d.edit_mesh_extrude_move_normal",
keymap=(
("mesh.extrude_context_move", dict(TRANSFORM_OT_translate=dict(release_confirm=True)),
dict(type='EVT_TWEAK_A', value='ANY')),
@@ -869,7 +874,7 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
bl_options = {'HIDE_HEADER'}
# Satisfy the 'ToolSelectPanelHelper' API.
- keymap_prefix = "Image Editor Tool: "
+ keymap_prefix = "Image Editor Tool:"
@classmethod
def tools_from_context(cls, context, mode=None):
@@ -920,7 +925,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
bl_options = {'HIDE_HEADER'}
# Satisfy the 'ToolSelectPanelHelper' API.
- keymap_prefix = "3D View Tool: "
+ keymap_prefix = "3D View Tool:"
@classmethod
def tools_from_context(cls, context, mode=None):
@@ -939,10 +944,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
# for reuse
_tools_transform = (
- (
- _defs_transform.translate,
- _defs_transform.transform,
- ),
+ _defs_transform.transform,
+ _defs_transform.translate,
_defs_transform.rotate,
(
_defs_transform.scale,
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 52d180c36b0..96ef2e51e60 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -147,8 +147,14 @@ class TOPBAR_HT_lower_bar(Header):
layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".weightpaint", category="")
elif mode == 'PAINT_TEXTURE':
layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".imagepaint", category="")
+ elif mode == 'EDIT_TEXT':
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".text_edit", category="")
elif mode == 'EDIT_ARMATURE':
layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".armature_edit", category="")
+ elif mode == 'EDIT_METABALL':
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".mball_edit", category="")
+ elif mode == 'EDIT_LATTICE':
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".lattice_edit", category="")
elif mode == 'EDIT_CURVE':
layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".curve_edit", category="")
elif mode == 'EDIT_MESH':
@@ -157,6 +163,8 @@ class TOPBAR_HT_lower_bar(Header):
layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".posemode", category="")
elif mode == 'PARTICLE':
layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".particlemode", category="")
+ elif mode == 'OBJECT':
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".objectmode", category="")
class _draw_left_context_mode:
@@ -206,98 +214,6 @@ class _draw_left_context_mode:
UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength")
-class TOPBAR_PT_pivot_point(Panel):
- bl_space_type = 'TOPBAR'
- bl_region_type = 'HEADER'
- bl_label = "Pivot Point"
-
- def draw(self, context):
- toolsettings = context.tool_settings
- obj = context.active_object
- mode = context.mode
-
- layout = self.layout
- col = layout.column()
- col.label("Pivot Point")
- col.prop(toolsettings, "transform_pivot_point", expand=True)
-
- col.separator()
-
- if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
- col.prop(
- toolsettings,
- "use_transform_pivot_point_align",
- text="Center Points Only",
- )
-
-
-class TOPBAR_PT_snapping(Panel):
- bl_space_type = 'TOPBAR'
- bl_region_type = 'HEADER'
- bl_label = "Snapping"
-
- def draw(self, context):
- toolsettings = context.tool_settings
- snap_elements = toolsettings.snap_elements
- obj = context.active_object
- mode = context.mode
- object_mode = 'OBJECT' if obj is None else obj.mode
-
- layout = self.layout
- col = layout.column()
- col.label("Snapping")
- col.prop(toolsettings, "snap_elements", expand=True)
-
- col.separator()
- if 'INCREMENT' in snap_elements:
- col.prop(toolsettings, "use_snap_grid_absolute")
-
- if snap_elements != {'INCREMENT'}:
- col.label("Target")
- row = col.row(align=True)
- row.prop(toolsettings, "snap_target", expand=True)
-
- if obj:
- if object_mode == 'EDIT':
- col.prop(toolsettings, "use_snap_self")
- if object_mode in {'OBJECT', 'POSE', 'EDIT'}:
- col.prop(toolsettings, "use_snap_align_rotation", text="Align Rotation")
-
- if 'FACE' in snap_elements:
- col.prop(toolsettings, "use_snap_project", text="Project Elements")
-
- if 'VOLUME' in snap_elements:
- col.prop(toolsettings, "use_snap_peel_object")
-
-
-class TOPBAR_PT_transform_orientations(Panel):
- bl_space_type = 'TOPBAR'
- bl_region_type = 'HEADER'
- bl_label = "Transform Orientations"
- bl_options = {'DEFAULT_CLOSED'}
-
- @classmethod
- def poll(cls, context):
- view = context.space_data
- return (view)
-
- def draw(self, context):
- layout = self.layout
- layout.label("Tranform Orientations")
-
- scene = context.scene
- orientation = scene.current_orientation
-
- col = layout.split(percentage=0.9)
- col.prop(scene, "transform_orientation", expand=True)
- col.operator("transform.create_orientation", text="", icon='ZOOMIN', emboss=False)
-
- if orientation:
- row = layout.row(align=False)
- row.prop(orientation, "name", text="")
- row.operator("transform.delete_orientation", text="", icon='X', emboss=False)
-
-
class INFO_MT_editor_menus(Menu):
bl_idname = "INFO_MT_editor_menus"
bl_label = ""
@@ -549,6 +465,10 @@ class INFO_MT_window(Menu):
layout = self.layout
layout.operator("wm.window_new")
+ layout.operator("wm.window_new_main")
+
+ layout.separator()
+
layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
layout.separator()
@@ -637,11 +557,14 @@ class TOPBAR_MT_window_specials(Menu):
layout.operator_context = 'EXEC_AREA'
layout.operator("wm.window_new")
+ layout.operator("wm.window_new_main")
layout.operator_context = 'INVOKE_AREA'
layout.operator("screen.area_dupli")
+ layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
+
layout.separator()
layout.operator("screen.area_split", text="Horizontal Split").direction = 'HORIZONTAL'
@@ -655,9 +578,6 @@ class TOPBAR_MT_window_specials(Menu):
classes = (
TOPBAR_HT_upper_bar,
TOPBAR_HT_lower_bar,
- TOPBAR_PT_pivot_point,
- TOPBAR_PT_snapping,
- TOPBAR_PT_transform_orientations,
TOPBAR_MT_file_specials,
TOPBAR_MT_window_specials,
INFO_MT_editor_menus,
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 4ce14f5ac89..ed0389942ad 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -28,25 +28,6 @@ from bpy.app.translations import pgettext_iface as iface_
from bpy.app.translations import contexts as i18n_contexts
-def opengl_lamp_buttons(column, lamp):
- split = column.row()
-
- split.prop(lamp, "use", text="", icon='OUTLINER_OB_LAMP' if lamp.use else 'LAMP_DATA')
-
- col = split.column()
- col.active = lamp.use
- row = col.row()
- row.label(text="Diffuse:")
- row.prop(lamp, "diffuse_color", text="")
- row = col.row()
- row.label(text="Specular:")
- row.prop(lamp, "specular_color", text="")
-
- col = split.column()
- col.active = lamp.use
- col.prop(lamp, "direction", text="")
-
-
class USERPREF_HT_header(Header):
bl_space_type = 'USER_PREFERENCES'
@@ -238,15 +219,15 @@ class USERPREF_PT_interface(Panel):
col.separator()
- col.prop(view, "show_manipulator_navigate")
+ # col.prop(view, "show_gizmo_navigate")
sub = col.column(align=True)
- sub.prop(view, "show_mini_axis", text="Display Mini Axis")
- sub.active = not view.show_manipulator_navigate
+ sub.label("3D Viewport Axis:")
+ sub.row().prop(view, "mini_axis_type", expand=True)
sub = col.column(align=True)
- sub.active = view.show_mini_axis
+ sub.active = view.mini_axis_type == 'MINIMAL'
sub.prop(view, "mini_axis_size", text="Size")
sub.prop(view, "mini_axis_brightness", text="Brightness")
@@ -258,16 +239,14 @@ class USERPREF_PT_interface(Panel):
#col.label(text="Open Toolbox Delay:")
#col.prop(view, "open_left_mouse_delay", text="Hold LMB")
#col.prop(view, "open_right_mouse_delay", text="Hold RMB")
- col.prop(view, "show_manipulator", text="Transform Manipulator")
- # Currently not working
- # col.prop(view, "show_manipulator_shaded")
+ col.prop(view, "show_gizmo", text="Gizmos")
sub = col.column()
- sub.active = view.show_manipulator
- sub.prop(view, "manipulator_size", text="Size")
+ sub.active = view.show_gizmo
+ sub.prop(view, "gizmo_size", text="Size")
col.separator()
- col.label("Development")
+ col.label("Development:")
col.prop(view, "show_tooltips_python")
col.prop(view, "show_developer_ui")
@@ -275,7 +254,7 @@ class USERPREF_PT_interface(Panel):
row.separator()
col = row.column()
- col.label(text="View Manipulation:")
+ col.label(text="View Gizmos:")
col.prop(view, "use_mouse_depth_cursor")
col.prop(view, "use_cursor_lock_adjust")
col.prop(view, "use_mouse_depth_navigate")
@@ -326,7 +305,7 @@ class USERPREF_PT_interface(Panel):
col.prop(view, "show_splash")
- col.label("Warnings")
+ col.label("Warnings:")
col.prop(view, "use_quit_dialog")
col.separator()
@@ -436,6 +415,7 @@ class USERPREF_PT_edit(Panel):
col.label(text="Transform:")
col.prop(edit, "use_drag_immediately")
+ col.prop(edit, "use_numeric_input_advanced")
row.separator()
row.separator()
@@ -454,7 +434,7 @@ class USERPREF_PT_edit(Panel):
col.prop(edit, "use_duplicate_text", text="Text")
col.prop(edit, "use_duplicate_metaball", text="Metaball")
col.prop(edit, "use_duplicate_armature", text="Armature")
- col.prop(edit, "use_duplicate_lamp", text="Lamp")
+ col.prop(edit, "use_duplicate_light", text="Light")
col.prop(edit, "use_duplicate_material", text="Material")
col.prop(edit, "use_duplicate_texture", text="Texture")
#col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
@@ -526,13 +506,13 @@ class USERPREF_PT_system(Panel):
col.prop(system, "use_16bit_textures")
col.separator()
- col.label(text="Selection")
+ col.label(text="Selection:")
col.prop(system, "select_method", text="")
col.prop(system, "use_select_pick_depth")
col.separator()
- col.label(text="Anisotropic Filtering")
+ col.label(text="Anisotropic Filtering:")
col.prop(system, "anisotropic_filter", text="")
col.separator()
@@ -551,43 +531,25 @@ class USERPREF_PT_system(Panel):
col.label(text="Text Draw Options:")
col.prop(system, "use_text_antialiasing")
- col.separator()
-
- col.label(text="Textures:")
- col.prop(system, "gl_texture_limit", text="Limit Size")
- col.prop(system, "texture_time_out", text="Time Out")
- col.prop(system, "texture_collection_rate", text="Collection Rate")
-
- col.separator()
-
- col.label(text="Images Draw Method:")
- col.prop(system, "image_draw_method", text="")
-
- col.separator()
-
- col.label(text="Sequencer/Clip Editor:")
- # currently disabled in the code
- # col.prop(system, "prefetch_frames")
- col.prop(system, "memory_cache_limit")
-
# 3. Column
column = split.column()
- column.label(text="Solid OpenGL Lights:")
+ column.label(text="Textures:")
+ column.prop(system, "gl_texture_limit", text="Limit Size")
+ column.prop(system, "texture_time_out", text="Time Out")
+ column.prop(system, "texture_collection_rate", text="Collection Rate")
- split = column.split(percentage=0.1)
- split.label()
- split.label(text="Colors:")
- split.label(text="Direction:")
+ column.separator()
- lamp = system.solid_lights[0]
- opengl_lamp_buttons(column, lamp)
+ column.label(text="Images Draw Method:")
+ column.prop(system, "image_draw_method", text="")
- lamp = system.solid_lights[1]
- opengl_lamp_buttons(column, lamp)
+ column.separator()
- lamp = system.solid_lights[2]
- opengl_lamp_buttons(column, lamp)
+ column.label(text="Sequencer/Clip Editor:")
+ # currently disabled in the code
+ # column.prop(system, "prefetch_frames")
+ column.prop(system, "memory_cache_limit")
column.separator()
@@ -917,7 +879,7 @@ class USERPREF_PT_theme(Panel):
col.separator()
col.separator()
- col.label("Axis & Manipulator Colors:")
+ col.label("Axis & Gizmo Colors:")
row = col.row()
@@ -935,10 +897,10 @@ class USERPREF_PT_theme(Panel):
padding = subsplit.split(percentage=0.15)
colsub = padding.column()
colsub = padding.column()
- colsub.row().prop(ui, "manipulator_primary")
- colsub.row().prop(ui, "manipulator_secondary")
- colsub.row().prop(ui, "manipulator_a")
- colsub.row().prop(ui, "manipulator_b")
+ colsub.row().prop(ui, "gizmo_primary")
+ colsub.row().prop(ui, "gizmo_secondary")
+ colsub.row().prop(ui, "gizmo_a")
+ colsub.row().prop(ui, "gizmo_b")
col.separator()
col.separator()
@@ -1473,7 +1435,14 @@ class USERPREF_PT_addons(Panel):
sub = row.row()
sub.active = is_enabled
sub.label(text="%s: %s" % (info["category"], info["name"]))
- if info["warning"]:
+
+ # WARNING: 2.8x exception, may be removed
+ # use disabled state for old add-ons, chances are they are broken.
+ if info.get("blender", (0,)) < (2, 80):
+ sub.label(text="upgrade to 2.8x required")
+ sub.label(icon='ERROR')
+ # Remove code above after 2.8x migration is complete.
+ elif info["warning"]:
sub.label(icon='ERROR')
# icon showing support level.
@@ -1590,13 +1559,6 @@ class StudioLightPanelMixin():
def _get_lights(self, userpref):
return [light for light in userpref.studio_lights if light.is_user_defined and light.orientation == self.sl_orientation]
- def draw_header(self, context):
- layout = self.layout
- row = layout.row()
- userpref = context.user_preferences
- lights = self._get_lights(userpref)
- row.label("({})".format(len(lights)))
-
def draw(self, context):
layout = self.layout
userpref = context.user_preferences
@@ -1634,6 +1596,48 @@ class USERPREF_PT_studiolight_camera(Panel, StudioLightPanelMixin):
sl_orientation = 'CAMERA'
+class USERPREF_PT_studiolight_specular(Panel, StudioLightPanelMixin):
+ bl_label = "Specular Lights"
+ sl_orientation = 'CAMERA'
+
+ @classmethod
+ def poll(cls, context):
+ userpref = context.user_preferences
+ return (userpref.active_section == 'LIGHTS')
+
+ def opengl_light_buttons(self, column, light):
+ split = column.split()
+
+ col = split.column()
+ col.prop(light, "use", text="Use", icon='OUTLINER_OB_LIGHT' if light.use else 'LIGHT_DATA')
+
+ sub = col.column()
+ sub.active = light.use
+ sub.prop(light, "specular_color")
+
+ col = split.column()
+ col.active = light.use
+ col.prop(light, "direction", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ column = layout.split()
+
+ userpref = context.user_preferences
+ system = userpref.system
+
+ light = system.solid_lights[0]
+ colsplit = column.split(percentage=0.85)
+ self.opengl_light_buttons(colsplit, light)
+
+ light = system.solid_lights[1]
+ colsplit = column.split(percentage=0.85)
+ self.opengl_light_buttons(colsplit, light)
+
+ light = system.solid_lights[2]
+ self.opengl_light_buttons(column, light)
+
+
classes = (
USERPREF_HT_header,
USERPREF_PT_tabs,
@@ -1657,6 +1661,7 @@ classes = (
USERPREF_PT_studiolight_matcaps,
USERPREF_PT_studiolight_world,
USERPREF_PT_studiolight_camera,
+ USERPREF_PT_studiolight_specular,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index e0a509fb44b..0b4032c8aaa 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -51,7 +51,7 @@ class VIEW3D_HT_header(Header):
layout.template_header_3D_mode()
- # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
+ # Contains buttons like Mode, Pivot, Layer, Mesh Select Mode...
shading_type = view.shading.type
shading_item = bpy.types.View3DShading.bl_rna.properties["type"].enum_items[shading_type]
@@ -97,23 +97,6 @@ class VIEW3D_HT_header(Header):
layout.separator_spacer()
- # Viewport Settings
- row = layout.row(align=True)
- row.prop(shading, "type", text="", expand=True)
-
- sub = row.row(align=True)
- sub.enabled = shading.type != 'RENDERED'
- sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading")
-
- row = layout.row(align=True)
- row.prop(overlay, "show_overlays", icon='WIRE', text="")
-
- sub = row.row(align=True)
- sub.active = overlay.show_overlays
- sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay")
-
- layout.separator_spacer()
-
# Mode & Transform Settings
scene = context.scene
@@ -128,14 +111,12 @@ class VIEW3D_HT_header(Header):
trans_icon = getattr(trans_orientation, "icon", "BLANK1")
trans_name = getattr(trans_orientation, "name", "Orientation")
else:
- trans_icon = "VISIBLE_IPO_OFF"
+ trans_icon = 'VISIBLE_IPO_OFF'
trans_name = getattr(current_orientation, "name", "Orientation")
row = layout.row(align=True)
row.popover(
- space_type='TOPBAR',
- region_type='HEADER',
- panel_type="TOPBAR_PT_transform_orientations",
+ panel="VIEW3D_PT_transform_orientations",
text=trans_name,
icon=trans_icon,
)
@@ -172,11 +153,9 @@ class VIEW3D_HT_header(Header):
sub = row.row(align=True)
sub.popover(
- space_type='TOPBAR',
- region_type='HEADER',
- panel_type="TOPBAR_PT_snapping",
+ panel="VIEW3D_PT_snapping",
icon=icon,
- text=""
+ text="",
)
# Proportional editing
@@ -216,13 +195,32 @@ class VIEW3D_HT_header(Header):
act_pivot_point = bpy.types.ToolSettings.bl_rna.properties["transform_pivot_point"].enum_items[pivot_point]
row = layout.row(align=True)
row.popover(
- space_type='TOPBAR',
- region_type='HEADER',
- panel_type="TOPBAR_PT_pivot_point",
+ panel="VIEW3D_PT_pivot_point",
icon=act_pivot_point.icon,
text="",
)
+ layout.separator_spacer()
+
+ # Viewport Settings
+ layout.popover(
+ panel="VIEW3D_PT_object_type_visibility",
+ icon_value=view.icon_from_show_object_viewport,
+ text="",
+ )
+
+ row = layout.row(align=True)
+ row.prop(overlay, "show_overlays", icon='WIRE', text="")
+ sub = row.row(align=True)
+ sub.active = overlay.show_overlays
+ sub.popover(panel="VIEW3D_PT_overlay")
+
+ row = layout.row(align=True)
+ row.prop(shading, "type", text="", expand=True)
+ sub = row.row(align=True)
+ sub.enabled = shading.type != 'RENDERED'
+ sub.popover(panel="VIEW3D_PT_shading")
+
class VIEW3D_MT_editor_menus(Menu):
bl_space_type = 'VIEW3D_MT_editor_menus'
@@ -573,7 +571,7 @@ class VIEW3D_MT_view_cameras(Menu):
layout = self.layout
layout.operator("view3d.object_as_camera")
- layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
+ layout.operator("view3d.view_camera", text="Active Camera")
class VIEW3D_MT_view_viewpoint(Menu):
@@ -582,22 +580,22 @@ class VIEW3D_MT_view_viewpoint(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
+ layout.operator("view3d.view_camera", text="Camera")
layout.separator()
- layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
- layout.operator("view3d.viewnumpad", text="Bottom").type = 'BOTTOM'
+ layout.operator("view3d.view_axis", text="Top").type = 'TOP'
+ layout.operator("view3d.view_axis", text="Bottom").type = 'BOTTOM'
layout.separator()
- layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
- layout.operator("view3d.viewnumpad", text="Back").type = 'BACK'
+ layout.operator("view3d.view_axis", text="Front").type = 'FRONT'
+ layout.operator("view3d.view_axis", text="Back").type = 'BACK'
layout.separator()
- layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
- layout.operator("view3d.viewnumpad", text="Left").type = 'LEFT'
+ layout.operator("view3d.view_axis", text="Right").type = 'RIGHT'
+ layout.operator("view3d.view_axis", text="Left").type = 'LEFT'
class VIEW3D_MT_view_navigation(Menu):
@@ -644,9 +642,12 @@ class VIEW3D_MT_view_align(Menu):
layout.separator()
- layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected")
+
+ layout.separator()
+
+ layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
layout.operator("view3d.view_center_cursor")
layout.separator()
@@ -661,27 +662,31 @@ class VIEW3D_MT_view_align_selected(Menu):
def draw(self, context):
layout = self.layout
- props = layout.operator("view3d.viewnumpad", text="Top")
+ props = layout.operator("view3d.view_axis", text="Top")
props.align_active = True
props.type = 'TOP'
- props = layout.operator("view3d.viewnumpad", text="Bottom")
+ props = layout.operator("view3d.view_axis", text="Bottom")
props.align_active = True
props.type = 'BOTTOM'
- props = layout.operator("view3d.viewnumpad", text="Front")
+ layout.separator()
+
+ props = layout.operator("view3d.view_axis", text="Front")
props.align_active = True
props.type = 'FRONT'
- props = layout.operator("view3d.viewnumpad", text="Back")
+ props = layout.operator("view3d.view_axis", text="Back")
props.align_active = True
props.type = 'BACK'
- props = layout.operator("view3d.viewnumpad", text="Right")
+ layout.separator()
+
+ props = layout.operator("view3d.view_axis", text="Right")
props.align_active = True
props.type = 'RIGHT'
- props = layout.operator("view3d.viewnumpad", text="Left")
+ props = layout.operator("view3d.view_axis", text="Left")
props.align_active = True
props.type = 'LEFT'
@@ -692,7 +697,7 @@ class VIEW3D_MT_view_borders(Menu):
def draw(self, context):
layout = self.layout
layout.operator("view3d.clip_border", text="Clipping Border...")
- layout.operator("view3d.render_border", text="Render Border...").camera_only = False
+ layout.operator("view3d.render_border", text="Render Border...")
layout.separator()
@@ -739,15 +744,19 @@ class VIEW3D_MT_select_object(Menu):
def draw(self, context):
layout = self.layout
+ layout.operator("object.select_all", text="All").action = 'SELECT'
+ layout.operator("object.select_all", text="None").action = 'DESELECT'
+ layout.operator("object.select_all", text="Invert").action = 'INVERT'
+
+ layout.separator()
+
layout.operator("view3d.select_border")
layout.operator("view3d.select_circle")
layout.separator()
- layout.operator("object.select_all", text="Select/Deselect All").action = 'TOGGLE'
layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
layout.operator("object.select_camera", text="Select Active Camera")
- layout.operator("object.select_all", text="Inverse Selection").action = 'INVERT'
layout.operator("object.select_mirror", text="Mirror Selection")
layout.operator("object.select_random", text="Select Random")
@@ -795,13 +804,17 @@ class VIEW3D_MT_select_pose(Menu):
def draw(self, context):
layout = self.layout
+ layout.operator("pose.select_all", text="All").action = 'SELECT'
+ layout.operator("pose.select_all", text="None").action = 'DESELECT'
+ layout.operator("pose.select_all", text="Invert").action = 'INVERT'
+
+ layout.separator()
+
layout.operator("view3d.select_border")
layout.operator("view3d.select_circle")
layout.separator()
- layout.operator("pose.select_all").action = 'TOGGLE'
- layout.operator("pose.select_all", text="Inverse").action = 'INVERT'
layout.operator("pose.select_mirror", text="Flip Active")
layout.separator()
@@ -825,14 +838,18 @@ class VIEW3D_MT_select_particle(Menu):
def draw(self, context):
layout = self.layout
+ layout.operator("particle.select_all", text="All").action = 'SELECT'
+ layout.operator("particle.select_all", text="None").action = 'DESELECT'
+ layout.operator("particle.select_all", text="Invert").action = 'INVERT'
+
+ layout.separator()
+
layout.operator("view3d.select_border")
layout.operator("view3d.select_circle")
layout.separator()
- layout.operator("particle.select_all").action = 'TOGGLE'
layout.operator("particle.select_linked")
- layout.operator("particle.select_all", text="Inverse").action = 'INVERT'
layout.separator()
@@ -926,14 +943,15 @@ class VIEW3D_MT_select_edit_mesh(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("view3d.select_border")
- layout.operator("view3d.select_circle")
+ # primitive
+ layout.operator("mesh.select_all", text="All").action = 'SELECT'
+ layout.operator("mesh.select_all", text="None").action = 'DESELECT'
+ layout.operator("mesh.select_all", text="Invert").action = 'INVERT'
layout.separator()
- # primitive
- layout.operator("mesh.select_all", text="Select/Deselect All").action = 'TOGGLE'
- layout.operator("mesh.select_all", text="Inverse Selection").action = 'INVERT'
+ layout.operator("view3d.select_border")
+ layout.operator("view3d.select_circle")
layout.separator()
@@ -979,13 +997,14 @@ class VIEW3D_MT_select_edit_curve(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("view3d.select_border")
- layout.operator("view3d.select_circle")
+ layout.operator("curve.select_all", text="All").action = 'SELECT'
+ layout.operator("curve.select_all", text="None").action = 'DESELECT'
+ layout.operator("curve.select_all", text="Invert").action = 'INVERT'
layout.separator()
- layout.operator("curve.select_all").action = 'TOGGLE'
- layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
+ layout.operator("view3d.select_border")
+ layout.operator("view3d.select_circle")
layout.separator()
@@ -1013,13 +1032,14 @@ class VIEW3D_MT_select_edit_surface(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("view3d.select_border")
- layout.operator("view3d.select_circle")
+ layout.operator("curve.select_all", text="All").action = 'SELECT'
+ layout.operator("curve.select_all", text="None").action = 'DESELECT'
+ layout.operator("curve.select_all", text="Invert").action = 'INVERT'
layout.separator()
- layout.operator("curve.select_all").action = 'TOGGLE'
- layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
+ layout.operator("view3d.select_border")
+ layout.operator("view3d.select_circle")
layout.separator()
@@ -1065,13 +1085,14 @@ class VIEW3D_MT_select_edit_metaball(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("view3d.select_border")
- layout.operator("view3d.select_circle")
+ layout.operator("mball.select_all", text="All").action = 'SELECT'
+ layout.operator("mball.select_all", text="None").action = 'DESELECT'
+ layout.operator("mball.select_all", text="Invert").action = 'INVERT'
layout.separator()
- layout.operator("mball.select_all").action = 'TOGGLE'
- layout.operator("mball.select_all", text="Inverse").action = 'INVERT'
+ layout.operator("view3d.select_border")
+ layout.operator("view3d.select_circle")
layout.separator()
@@ -1088,13 +1109,14 @@ class VIEW3D_MT_select_edit_lattice(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("view3d.select_border")
- layout.operator("view3d.select_circle")
+ layout.operator("lattice.select_all", text="All").action = 'SELECT'
+ layout.operator("lattice.select_all", text="None").action = 'DESELECT'
+ layout.operator("lattice.select_all", text="Invert").action = 'INVERT'
layout.separator()
- layout.operator("lattice.select_all").action = 'TOGGLE'
- layout.operator("lattice.select_all", text="Inverse").action = 'INVERT'
+ layout.operator("view3d.select_border")
+ layout.operator("view3d.select_circle")
layout.separator()
@@ -1112,13 +1134,17 @@ class VIEW3D_MT_select_edit_armature(Menu):
def draw(self, context):
layout = self.layout
+ layout.operator("armature.select_all", text="All").action = 'SELECT'
+ layout.operator("armature.select_all", text="None").action = 'DESELECT'
+ layout.operator("armature.select_all", text="Invert").action = 'INVERT'
+
+ layout.separator()
+
layout.operator("view3d.select_border")
layout.operator("view3d.select_circle")
layout.separator()
- layout.operator("armature.select_all").action = 'TOGGLE'
- layout.operator("armature.select_all", text="Inverse").action = 'INVERT'
layout.operator("armature.select_mirror", text="Mirror").extend = False
layout.separator()
@@ -1156,13 +1182,14 @@ class VIEW3D_MT_select_gpencil(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("gpencil.select_border")
- layout.operator("gpencil.select_circle")
+ layout.operator("gpencil.select_all", text="All").action = 'SELECT'
+ layout.operator("gpencil.select_all", text="None").action = 'DESELECT'
+ layout.operator("gpencil.select_all", text="Invert").action = 'INVERT'
layout.separator()
- layout.operator("gpencil.select_all", text="(De)select All").action = 'TOGGLE'
- layout.operator("gpencil.select_all", text="Inverse").action = 'INVERT'
+ layout.operator("gpencil.select_border")
+ layout.operator("gpencil.select_circle")
layout.separator()
@@ -1186,13 +1213,14 @@ class VIEW3D_MT_select_paint_mask(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("view3d.select_border")
- layout.operator("view3d.select_circle")
+ layout.operator("paint.face_select_all", text="All").action = 'SELECT'
+ layout.operator("paint.face_select_all", text="None").action = 'DESELECT'
+ layout.operator("paint.face_select_all", text="Invert").action = 'INVERT'
layout.separator()
- layout.operator("paint.face_select_all").action = 'TOGGLE'
- layout.operator("paint.face_select_all", text="Inverse").action = 'INVERT'
+ layout.operator("view3d.select_border")
+ layout.operator("view3d.select_circle")
layout.separator()
@@ -1205,13 +1233,14 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("view3d.select_border")
- layout.operator("view3d.select_circle")
+ layout.operator("paint.vert_select_all", text="All").action = 'SELECT'
+ layout.operator("paint.vert_select_all", text="None").action = 'DESELECT'
+ layout.operator("paint.vert_select_all", text="Invert").action = 'INVERT'
layout.separator()
- layout.operator("paint.vert_select_all").action = 'TOGGLE'
- layout.operator("paint.vert_select_all", text="Inverse").action = 'INVERT'
+ layout.operator("view3d.select_border")
+ layout.operator("view3d.select_circle")
layout.separator()
@@ -1367,15 +1396,15 @@ class INFO_MT_armature_add(Menu):
layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
-class INFO_MT_lamp_add(Menu):
- bl_idname = "INFO_MT_lamp_add"
- bl_label = "Lamp"
+class INFO_MT_light_add(Menu):
+ bl_idname = "INFO_MT_light_add"
+ bl_label = "Light"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator_enum("object.lamp_add", "type")
+ layout.operator_enum("object.light_add", "type")
class INFO_MT_lightprobe_add(Menu):
@@ -1435,7 +1464,7 @@ class INFO_MT_add(Menu):
else:
INFO_MT_camera_add.draw(self, context)
- layout.menu("INFO_MT_lamp_add", icon='OUTLINER_OB_LAMP')
+ layout.menu("INFO_MT_light_add", icon='OUTLINER_OB_LIGHT')
layout.separator()
layout.menu("INFO_MT_lightprobe_add", icon='OUTLINER_OB_LIGHTPROBE')
layout.separator()
@@ -1519,8 +1548,8 @@ class VIEW3D_MT_object(Menu):
layout.separator()
- layout.operator("object.shade_smooth", text="Smooth Shading")
- layout.operator("object.shade_flat", text="Flat Shading")
+ layout.operator("object.shade_smooth")
+ layout.operator("object.shade_flat")
layout.separator()
@@ -1707,14 +1736,14 @@ class VIEW3D_MT_object_specials(Menu):
props.input_scale = 0.01
props.header_text = "Empty Draw Size: %.3f"
- if obj.type == 'LAMP':
- lamp = obj.data
+ if obj.type == 'LIGHT':
+ light = obj.data
layout.operator_context = 'INVOKE_REGION_WIN'
emission_node = None
- if lamp.node_tree:
- for node in lamp.node_tree.nodes:
+ if light.node_tree:
+ for node in light.node_tree.nodes:
if getattr(node, "type", None) == 'EMISSION':
emission_node = node
break
@@ -1725,28 +1754,28 @@ class VIEW3D_MT_object_specials(Menu):
props.data_path_item = "data.node_tree" \
".nodes[\"" + emission_node.name + "\"]" \
".inputs[\"Strength\"].default_value"
- props.header_text = "Lamp Strength: %.3f"
+ props.header_text = "Light Strength: %.3f"
props.input_scale = 0.1
- if lamp.type == 'AREA':
+ if light.type == 'AREA':
props = layout.operator("wm.context_modal_mouse", text="Size X")
props.data_path_iter = "selected_editable_objects"
props.data_path_item = "data.size"
- props.header_text = "Lamp Size X: %.3f"
+ props.header_text = "Light Size X: %.3f"
- if lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
+ if light.shape in {'RECTANGLE', 'ELLIPSE'}:
props = layout.operator("wm.context_modal_mouse", text="Size Y")
props.data_path_iter = "selected_editable_objects"
props.data_path_item = "data.size_y"
- props.header_text = "Lamp Size Y: %.3f"
+ props.header_text = "Light Size Y: %.3f"
- elif lamp.type in {'SPOT', 'POINT', 'SUN'}:
+ elif light.type in {'SPOT', 'POINT', 'SUN'}:
props = layout.operator("wm.context_modal_mouse", text="Size")
props.data_path_iter = "selected_editable_objects"
props.data_path_item = "data.shadow_soft_size"
- props.header_text = "Lamp Size: %.3f"
+ props.header_text = "Light Size: %.3f"
- if lamp.type == 'SPOT':
+ if light.type == 'SPOT':
layout.separator()
props = layout.operator("wm.context_modal_mouse", text="Spot Size")
props.data_path_iter = "selected_editable_objects"
@@ -2278,6 +2307,13 @@ class VIEW3D_MT_particle_specials(Menu):
if particle_edit.select_mode == 'POINT':
layout.separator()
+
+ layout.operator("particle.select_all", text="All").action = 'SELECT'
+ layout.operator("particle.select_all", text="None").action = 'DESELECT'
+ layout.operator("particle.select_all", text="Invert").action = 'INVERT'
+
+ layout.separator()
+
layout.operator("particle.select_roots")
layout.operator("particle.select_tips")
@@ -2292,9 +2328,7 @@ class VIEW3D_MT_particle_specials(Menu):
layout.separator()
- layout.operator("particle.select_all").action = 'TOGGLE'
layout.operator("particle.select_linked")
- layout.operator("particle.select_all", text="Inverse").action = 'INVERT'
class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
@@ -2628,6 +2662,9 @@ class VIEW3D_MT_edit_mesh(Menu):
layout.menu("VIEW3D_MT_edit_mesh_showhide")
layout.operator_menu_enum("mesh.separate", "type")
layout.menu("VIEW3D_MT_edit_mesh_clean")
+
+ layout.separator()
+
layout.menu("VIEW3D_MT_edit_mesh_delete")
@@ -2852,14 +2889,11 @@ class VIEW3D_MT_edit_mesh_edges_data(Menu):
props.use_verts = True
props.clear = True
- layout.separator()
-
- layout.separator()
-
if with_freestyle:
+ layout.separator()
+
layout.operator("mesh.mark_freestyle_edge").clear = False
layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
- layout.separator()
class VIEW3D_MT_edit_mesh_edges(Menu):
@@ -3577,7 +3611,8 @@ class VIEW3D_MT_view_pie(Menu):
layout = self.layout
pie = layout.menu_pie()
- pie.operator_enum("VIEW3D_OT_viewnumpad", "type")
+ pie.operator_enum("VIEW3D_OT_view_axis", "type")
+ pie.operator("view3d.view_camera", text="View Camera", icon='CAMERA_DATA')
pie.operator("view3d.view_selected", text="View Selected", icon='ZOOM_SELECTED')
@@ -3603,74 +3638,148 @@ class VIEW3D_PT_view3d_properties(Panel):
bl_region_type = 'UI'
bl_label = "View"
- @classmethod
- def poll(cls, context):
+ def draw(self, context):
+ layout = self.layout
+
view = context.space_data
- return (view)
+
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
+ col = flow.column()
+
+ subcol = col.column()
+ subcol.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews)
+ subcol.prop(view, "lens", text="Focal Length")
+
+ subcol = col.column(align=True)
+ subcol.prop(view, "clip_start", text="Clip Start")
+ subcol.prop(view, "clip_end", text="End")
+
+ subcol.separator()
+
+ col = flow.column()
+
+ subcol = col.column()
+ subcol.enabled = not view.lock_camera_and_layers
+ subcol.prop(view, "camera", text="Local Camera")
+
+ subcol = col.column(align=True)
+ subcol.prop(view, "use_render_border")
+ subcol.active = view.region_3d.view_perspective != 'CAMERA'
+
+
+class VIEW3D_PT_view3d_camera_lock(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'UI'
+ bl_label = "Camera Lock"
+ bl_parent_id = "VIEW3D_PT_view3d_properties"
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
view = context.space_data
- col = layout.column()
- col.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews)
- col.prop(view, "lens")
- col.label(text="Lock to Object:")
- col.prop(view, "lock_object", text="")
+ col = layout.column(align=True)
+ subcol = col.column()
+ subcol.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews)
+
+ subcol.prop(view, "lock_object")
lock_object = view.lock_object
if lock_object:
if lock_object.type == 'ARMATURE':
- col.prop_search(view, "lock_bone", lock_object.data,
- "edit_bones" if lock_object.mode == 'EDIT'
- else "bones",
- text="")
+ subcol.prop_search(
+ view, "lock_bone", lock_object.data,
+ "edit_bones" if lock_object.mode == 'EDIT'
+ else "bones",
+ text=""
+ )
else:
- col.prop(view, "lock_cursor", text="Lock to Cursor")
+ subcol.prop(view, "lock_cursor", text="Lock to 3D Cursor")
- col = layout.column()
col.prop(view, "lock_camera")
- col = layout.column(align=True)
- col.label(text="Clip:")
- col.prop(view, "clip_start", text="Start")
- col.prop(view, "clip_end", text="End")
-
- subcol = col.column(align=True)
- subcol.enabled = not view.lock_camera_and_layers
- subcol.label(text="Local Camera:")
- subcol.prop(view, "camera", text="")
-
- col = layout.column(align=True)
- col.prop(view, "use_render_border")
- col.active = view.region_3d.view_perspective != 'CAMERA'
-
class VIEW3D_PT_view3d_cursor(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "3D Cursor"
- @classmethod
- def poll(cls, context):
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
view = context.space_data
- return (view is not None)
+
+ layout.column().prop(view, "cursor_location", text="Location")
+
+
+class VIEW3D_PT_object_type_visibility(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "View Object Types"
+ bl_ui_units_x = 6
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
view = context.space_data
- layout.column().prop(view, "cursor_location", text="Location")
+
+ col = layout.column()
+
+ attr_object_types = (
+ # Geometry
+ "mesh",
+ "curve",
+ "surf",
+ "meta",
+ "font",
+ None,
+ # Other
+ "armature",
+ "lattice",
+ "empty",
+ "camera",
+ "light",
+ "light_probe",
+ "speaker",
+ )
+
+ for attr in attr_object_types:
+ if attr is None:
+ col.separator()
+ continue
+
+ attr_v = "show_object_viewport_" f"{attr:s}"
+ attr_s = "show_object_select_" f"{attr:s}"
+
+ icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON'
+
+ row = col.row(align=True)
+ row.prop(view, attr_v)
+ row.active = getattr(view, attr_v)
+ row.prop(view, attr_s, text="", icon=icon_s, emboss=False)
class VIEW3D_PT_shading(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_label = "Shading"
+ bl_ui_units_x = 11
@classmethod
- def poll(cls, context):
- return True
+ def get_shading(cls, context):
+ # Get settings from 3D viewport or OpenGL render engine
+ view = context.space_data
+ if view.type == 'VIEW_3D':
+ return view.shading
+ else:
+ return context.scene.display.shading
def draw(self, context):
pass
@@ -3682,42 +3791,60 @@ class VIEW3D_PT_shading_lighting(Panel):
bl_label = "Lighting"
bl_parent_id = 'VIEW3D_PT_shading'
- @classmethod
- def poll(cls, context):
- return True
-
def draw(self, context):
layout = self.layout
+ shading = VIEW3D_PT_shading.get_shading(context)
- view = context.space_data
- shading = view.shading
+ col = layout.column()
+ split = col.split(0.9)
if shading.type == 'SOLID':
- layout.row().prop(shading, "light", expand=True)
+ split.row().prop(shading, "light", expand=True)
+ col = split.column()
+
+ split = layout.split(0.9)
+ col = split.column()
+ sub = col.row()
+ sub.scale_y = 0.6 # smaller matcap/hdri preview
+
if shading.light == 'STUDIO':
- row = layout.row()
- row.template_icon_view(shading, "studio_light", show_labels=True)
- sub = row.column()
- sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
+ sub.template_icon_view(shading, "studio_light", show_labels=True, scale=3)
+
if shading.selected_studio_light.orientation == 'WORLD':
- layout.row().prop(shading, "studiolight_rotate_z")
+ col.prop(shading, "studiolight_rotate_z", text="Rotation")
+
+ col = split.column()
+ col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
elif shading.light == 'MATCAP':
- row = layout.row()
- row.template_icon_view(shading, "studio_light", show_labels=True)
- sub = row.column()
- sub.operator('VIEW3D_OT_toggle_matcap_flip', emboss=False, text="", icon='ARROW_LEFTRIGHT')
- sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
+ sub.template_icon_view(shading, "studio_light", show_labels=True, scale=3)
+
+ col = split.column()
+ col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
+ col.operator('VIEW3D_OT_toggle_matcap_flip', emboss=False, text="", icon='ARROW_LEFTRIGHT')
elif shading.type == 'MATERIAL':
- row = layout.row()
- row.template_icon_view(shading, "studio_light", show_labels=True)
- sub = row.column()
- sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
- if shading.selected_studio_light.orientation == 'WORLD':
- layout.row().prop(shading, "studiolight_rotate_z")
- layout.row().prop(shading, "studiolight_background_alpha")
- layout.prop(shading, "use_scene_light")
+ col.prop(shading, "use_scene_lights")
+ col.prop(shading, "use_scene_world")
+
+ if not shading.use_scene_world:
+ col = layout.column()
+ split = col.split(0.9)
+
+ col = split.column()
+ sub = col.row()
+ sub.scale_y = 0.6
+ sub.template_icon_view(shading, "studio_light", show_labels=True, scale=3)
+
+ col = split.column()
+ col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
+
+ if shading.selected_studio_light.orientation == 'WORLD':
+ split = layout.split(0.9)
+ col = split.column()
+ col.prop(shading, "studiolight_rotate_z", text="Rotation")
+ col.prop(shading, "studiolight_background_alpha")
+ col = split.column() # to align properly with above
class VIEW3D_PT_shading_color(Panel):
@@ -3728,15 +3855,13 @@ class VIEW3D_PT_shading_color(Panel):
@classmethod
def poll(cls, context):
- view = context.space_data
- shading = view.shading
- return shading.type in ['SOLID']
+ shading = VIEW3D_PT_shading.get_shading(context)
+ return shading.type == 'SOLID'
def draw(self, context):
layout = self.layout
- view = context.space_data
- shading = view.shading
+ shading = VIEW3D_PT_shading.get_shading(context)
layout.row().prop(shading, "color_type", expand=True)
@@ -3752,54 +3877,74 @@ class VIEW3D_PT_shading_options(Panel):
@classmethod
def poll(cls, context):
- view = context.space_data
- shading = view.shading
+ shading = VIEW3D_PT_shading.get_shading(context)
return shading.type == 'SOLID'
def draw(self, context):
layout = self.layout
- view = context.space_data
- shading = view.shading
+ shading = VIEW3D_PT_shading.get_shading(context)
- if not shading.light == 'MATCAP':
- row = layout.row()
- row.prop(shading, "show_specular_highlight")
+ col = layout.column()
- row = layout.split(0.4)
- row.prop(shading, "show_xray")
- sub = row.row()
- sub.active = shading.show_xray
- sub.prop(shading, "xray_alpha", text="")
+ is_xray = shading.show_xray
+ is_shadows = shading.show_shadows
- row = layout.split(0.4)
- row.active = not shading.show_xray
- row.prop(shading, "show_shadows")
+ icon_x = 'CHECKBOX_HLT' if is_xray else 'CHECKBOX_DEHLT'
+ row = col.row()
+ row.prop(shading, "show_xray", text="")
sub = row.row()
- sub.active = shading.show_shadows and not shading.show_xray
- sub.prop(shading, "shadow_intensity", text="")
+ sub.active = is_xray
+ sub.prop(shading, "xray_alpha", text="X-Ray")
+
+ icon_s = 'CHECKBOX_HLT' if is_shadows else 'CHECKBOX_DEHLT'
+ row = col.row()
+ row.prop(shading, "show_shadows", text="")
+ row.active = not is_xray
+ sub = row.row(align=True)
+ sub.active = is_shadows
+ sub.prop(shading, "shadow_intensity", text="Shadow")
+ sub.popover(
+ panel="VIEW3D_PT_shading_options_shadow",
+ icon='SCRIPTWIN',
+ text=""
+ )
- row = layout.split(0.4)
- row.active = not shading.show_xray
+ col = layout.column()
+ row = col.row()
+ row.active = not is_xray
row.prop(shading, "show_cavity")
- sub = row.column(align=True)
- sub.active = not shading.show_xray and shading.show_cavity
- sub.prop(shading, "cavity_ridge_factor")
- sub.prop(shading, "cavity_valley_factor")
- row = layout.split(0.4)
+ if shading.show_cavity:
+ sub = col.row(align=True)
+ sub.active = not shading.show_xray and shading.show_cavity
+ sub.prop(shading, "cavity_ridge_factor")
+ sub.prop(shading, "cavity_valley_factor")
+ sub.popover(
+ panel="VIEW3D_PT_shading_options_ssao",
+ icon='SCRIPTWIN',
+ text=""
+ )
+
+ row = layout.split()
row.prop(shading, "show_object_outline")
sub = row.row()
sub.active = shading.show_object_outline
sub.prop(shading, "object_outline_color", text="")
- layout.prop(view, "show_world")
+ col = layout.column()
+ if not shading.light == 'MATCAP':
+ col.prop(shading, "show_specular_highlight")
+ view = context.space_data
+ if view.type == 'VIEW_3D':
+ col.prop(view, "show_world")
-class VIEW3D_PT_overlay(Panel):
+
+class VIEW3D_PT_shading_options_shadow(Panel):
+ bl_label = "Shadow Settings"
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = "Overlays"
@classmethod
def poll(cls, context):
@@ -3807,74 +3952,225 @@ class VIEW3D_PT_overlay(Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+ scene = context.scene
+
+ col = layout.column()
+ col.prop(scene.display, "light_direction")
+ col.prop(scene.display, "shadow_shift")
+
+
+class VIEW3D_PT_shading_options_ssao(Panel):
+ bl_label = "SSAO Settings"
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+
+ @classmethod
+ def poll(cls, context):
+ return True
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ scene = context.scene
+
+ col = layout.column(align=True)
+ col.prop(scene.display, "matcap_ssao_samples")
+ col.prop(scene.display, "matcap_ssao_distance")
+ col.prop(scene.display, "matcap_ssao_attenuation")
+
+
+class VIEW3D_PT_overlay(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Overlays"
+ bl_ui_units_x = 13
+
+ def draw(self, context):
+ pass
+
+
+class VIEW3D_PT_overlay_gizmo(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Gizmo"
+
+ def draw_header(self, context):
+ view = context.space_data
+ self.layout.prop(view, "show_gizmo", text="")
+
+ def draw(self, context):
+ layout = self.layout
view = context.space_data
- shading = view.shading
overlay = view.overlay
display_all = overlay.show_overlays
col = layout.column()
col.active = display_all
+ row = col.row(align=True)
+ row.active = view.show_gizmo
+ row.prop(view, "show_gizmo_navigate", text="Navigate", toggle=True)
+ row.prop(view, "show_gizmo_context", text="Active Object", toggle=True)
+ row.prop(view, "show_gizmo_tool", text="Active Tools", toggle=True)
+
+
+class VIEW3D_PT_overlay_guides(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Guides"
+
+ def draw(self, context):
+ layout = self.layout
+
+ view = context.space_data
+ overlay = view.overlay
+ shading = view.shading
+ display_all = overlay.show_overlays
+
+ col = layout.column()
+ col.active = display_all
+
split = col.split()
+ sub = split.column()
+ sub.prop(overlay, "show_floor", text="Grid")
+
+ if overlay.show_floor:
+ sub = col.column(align=True)
+ sub.active = bool(overlay.show_floor or view.region_quadviews or not view.region_3d.is_perspective)
+ subsub = sub.row(align=True)
+ subsub.active = overlay.show_floor
+ subsub.prop(overlay, "grid_scale", text="Scale")
+ subsub.prop(overlay, "grid_subdivisions", text="Subdivisions")
sub = split.column()
- sub.prop(view, "show_manipulator", text="Manipulators")
- sub.prop(overlay, "show_text", text="Text")
- sub.prop(overlay, "show_cursor", text="3D Cursor")
- sub.prop(overlay, "show_outline_selected")
- sub.prop(overlay, "show_all_objects_origin")
+ row = sub.row()
+ row.label(text="Axes")
+
+ subrow = row.row(align=True)
+ subrow.prop(overlay, "show_axis_x", text="X", toggle=True)
+ subrow.prop(overlay, "show_axis_y", text="Y", toggle=True)
+ subrow.prop(overlay, "show_axis_z", text="Z", toggle=True)
+ split = col.split()
+ sub = split.column()
+ sub.prop(overlay, "show_text", text="Text Info")
sub = split.column()
+ sub.prop(overlay, "show_cursor", text="3D Cursor")
+
+ if shading.type == 'MATERIAL':
+ col.prop(overlay, "show_look_dev")
+
+
+class VIEW3D_PT_overlay_object(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Objects"
+
+ def draw(self, context):
+ layout = self.layout
+ view = context.space_data
+ overlay = view.overlay
+ shading = view.shading
+ display_all = overlay.show_overlays
+
+ col = layout.column(align=True)
+ col.active = display_all
+
+ split = col.split()
+
+ sub = split.column(align=True)
+ sub.prop(overlay, "show_ornaments", text="Ornaments")
sub.prop(overlay, "show_relationship_lines")
+ sub.prop(overlay, "show_outline_selected")
+
+ sub = split.column(align=True)
+ sub.prop(overlay, "show_bones", text="Bones")
sub.prop(overlay, "show_motion_paths")
- #sub.prop(overlay, "show_onion_skins")
- sub.prop(overlay, "show_face_orientation")
- sub.prop(overlay, "show_backface_culling")
- if shading.type == 'MATERIAL':
- sub.prop(overlay, "show_look_dev")
+ sub.prop(overlay, "show_object_origins", text="Origins")
+ subsub = sub.column()
+ subsub.active = overlay.show_object_origins
+ subsub.prop(overlay, "show_object_origins_all", text="Origins (All)")
+
+
+class VIEW3D_PT_overlay_geometry(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Geometry"
+
+ def draw(self, context):
+ layout = self.layout
+ view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
+
+ col = layout.column()
+ col.active = display_all
row = col.row()
- row.prop(overlay, "show_wireframes")
+ row.prop(overlay, "show_wireframes", text="")
sub = row.row()
sub.active = overlay.show_wireframes
- sub.prop(overlay, "wireframe_threshold", text="")
+ sub.prop(overlay, "wireframe_threshold", text="Wireframe")
- col = layout.column()
+ col = layout.column(align=True)
col.active = display_all
- split = col.split(percentage=0.55)
- split.prop(overlay, "show_floor", text="Grid Floor")
- row = split.row(align=True)
- row.prop(overlay, "show_axis_x", text="X", toggle=True)
- row.prop(overlay, "show_axis_y", text="Y", toggle=True)
- row.prop(overlay, "show_axis_z", text="Z", toggle=True)
+ split = col.split()
+ sub = split.column(align=True)
+ sub.prop(overlay, "show_backface_culling")
- if overlay.show_floor:
- sub = col.column(align=True)
- sub.active = bool(overlay.show_floor or view.region_quadviews or not view.region_3d.is_perspective)
- subsub = sub.column(align=True)
- subsub.active = overlay.show_floor
- subsub.prop(overlay, "grid_scale", text="Scale")
- subsub.prop(overlay, "grid_subdivisions", text="Subdivisions")
+ sub = split.column(align=True)
+ #sub.prop(overlay, "show_onion_skins")
+ sub.prop(overlay, "show_face_orientation")
+
+
+class VIEW3D_PT_overlay_motion_tracking(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Motion Tracking"
+
+ def draw_header(self, context):
+ view = context.space_data
+ self.layout.prop(view, "show_reconstruction", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
+
+ col = layout.column()
+ col.active = display_all
- col.prop(view, "show_reconstruction", text="Motion Tracking")
if view.show_reconstruction:
- sub = col.column(align=True)
+ split = col.split()
+
+ sub = split.column(align=True)
sub.active = view.show_reconstruction
sub.prop(view, "show_camera_path", text="Camera Path")
- sub.prop(view, "show_bundle_names", text="3D Marker Names")
- sub.label(text="Track Type and Size:")
- row = sub.row(align=True)
+
+ sub = split.column()
+ sub.prop(view, "show_bundle_names", text="Marker Names")
+
+ col = layout.column()
+ col.label(text="Tracks:")
+ row = col.row(align=True)
row.prop(view, "tracks_draw_type", text="")
- row.prop(view, "tracks_draw_size", text="")
+ row.prop(view, "tracks_draw_size", text="Size")
class VIEW3D_PT_overlay_edit_mesh(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
- bl_label = "Edit Mesh"
+ bl_label = "Mesh Edit Mode"
@classmethod
def poll(cls, context):
@@ -3884,14 +4180,10 @@ class VIEW3D_PT_overlay_edit_mesh(Panel):
layout = self.layout
view = context.space_data
- shading = view.shading
overlay = view.overlay
- tool_settings = context.tool_settings
display_all = overlay.show_overlays
data = context.active_object.data
- statvis = tool_settings.statvis
with_freestyle = bpy.app.build_options.freestyle
- show_developer_ui = context.user_preferences.view.show_developer_ui
col = layout.column()
col.active = display_all
@@ -3899,73 +4191,193 @@ class VIEW3D_PT_overlay_edit_mesh(Panel):
split = col.split()
sub = split.column()
- sub.prop(data, "show_faces", text="Faces")
sub.prop(data, "show_edges", text="Edges")
- sub.prop(data, "show_edge_crease", text="Creases")
- sub.prop(data, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
- sub.prop(data, "show_edge_bevel_weight", text="Bevel")
+ sub = split.column()
+ sub.prop(data, "show_faces", text="Faces")
+
+ row = col.row(align=True)
+ row.prop(data, "show_edge_crease", text="Creases", toggle=True)
+ row.prop(data, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural, toggle=True)
+ row.prop(data, "show_edge_bevel_weight", text="Bevel", toggle=True)
+
if not with_freestyle:
- sub.prop(data, "show_edge_seams", text="Seams")
+ row.prop(data, "show_edge_seams", text="Seams", toggle=True)
- sub = split.column()
- sub.prop(overlay, "show_occlude_wire")
- sub.prop(data, "show_extra_edge_length", text="Edge Length")
- sub.prop(data, "show_extra_edge_angle", text="Edge Angle")
- sub.prop(data, "show_extra_face_area", text="Face Area")
- sub.prop(data, "show_extra_face_angle", text="Face Angle")
- if show_developer_ui:
- sub.prop(data, "show_extra_indices", text="Indices")
+class VIEW3D_PT_overlay_edit_mesh_shading(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh'
+ bl_label = "Shading"
+
+ @classmethod
+ def poll(cls, context):
+ return context.mode == 'EDIT_MESH'
- if with_freestyle:
- col.label(text="Freestyle:")
- row = col.row()
- row.prop(data, "show_freestyle_edge_marks", text="Edge Marks")
- row.prop(data, "show_freestyle_face_marks", text="Face Marks")
- row.prop(data, "show_edge_seams", text="Seams")
+ def draw(self, context):
+ layout = self.layout
- col.label(text="Normals:")
- row = col.row(align=True)
+ view = context.space_data
+ overlay = view.overlay
+ tool_settings = context.tool_settings
+ display_all = overlay.show_overlays
+ data = context.active_object.data
+ statvis = tool_settings.statvis
- row.prop(overlay, "show_vertex_normals", text="", icon='VERTEXSEL')
- row.prop(overlay, "show_split_normals", text="", icon='LOOPSEL')
- row.prop(overlay, "show_face_normals", text="", icon='FACESEL')
+ col = layout.column()
+ col.active = display_all
- sub = row.row(align=True)
- sub.active = overlay.show_vertex_normals or overlay.show_face_normals or overlay.show_split_normals
- sub.prop(overlay, "normals_length", text="Size")
+ col.prop(overlay, "show_occlude_wire")
- col.prop(overlay, "show_weight")
+ col.prop(overlay, "show_weight", text="Vertex Group Weights")
if overlay.show_weight:
- col.label("Show Zero Weights:")
- col.row().prop(tool_settings, "vertex_group_user", expand=True)
+ row = col.split()
+ row.label(text="Zero Weights")
+ row.prop(tool_settings, "vertex_group_user", text="")
col.prop(data, "show_statvis", text="Mesh Analysis")
if data.show_statvis:
- sub = col.column()
+ col = col.column()
+
+ sub = col.split()
sub.active = data.show_statvis
- sub.prop(statvis, "type")
+ sub.label(text="Type")
+ sub.prop(statvis, "type", text="")
+
statvis_type = statvis.type
if statvis_type == 'OVERHANG':
- row = sub.row(align=True)
- row.prop(statvis, "overhang_min", text="")
- row.prop(statvis, "overhang_max", text="")
- sub.row().prop(statvis, "overhang_axis", expand=True)
+ row = col.row(align=True)
+ row.prop(statvis, "overhang_min", text="Minimum")
+ row.prop(statvis, "overhang_max", text="Maximum")
+ col.row().prop(statvis, "overhang_axis", expand=True)
elif statvis_type == 'THICKNESS':
- row = sub.row(align=True)
- row.prop(statvis, "thickness_min", text="")
- row.prop(statvis, "thickness_max", text="")
- sub.prop(statvis, "thickness_samples")
+ row = col.row(align=True)
+ row.prop(statvis, "thickness_min", text="Minimum")
+ row.prop(statvis, "thickness_max", text="Maximum")
+ col.prop(statvis, "thickness_samples")
elif statvis_type == 'INTERSECT':
pass
elif statvis_type == 'DISTORT':
- row = sub.row(align=True)
- row.prop(statvis, "distort_min", text="")
- row.prop(statvis, "distort_max", text="")
+ row = col.row(align=True)
+ row.prop(statvis, "distort_min", text="Minimum")
+ row.prop(statvis, "distort_max", text="Maximum")
elif statvis_type == 'SHARP':
- row = sub.row(align=True)
- row.prop(statvis, "sharp_min", text="")
- row.prop(statvis, "sharp_max", text="")
+ row = col.row(align=True)
+ row.prop(statvis, "sharp_min", text="Minimum")
+ row.prop(statvis, "sharp_max", text="Maximum")
+
+
+class VIEW3D_PT_overlay_edit_mesh_measurement(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh'
+ bl_label = "Measurement"
+
+ @classmethod
+ def poll(cls, context):
+ return context.mode == 'EDIT_MESH'
+
+ def draw(self, context):
+ layout = self.layout
+
+ view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
+ data = context.active_object.data
+
+ col = layout.column()
+ col.active = display_all
+
+ split = col.split()
+
+ sub = split.column()
+ sub.prop(data, "show_extra_edge_length", text="Edge Length")
+ sub.prop(data, "show_extra_edge_angle", text="Edge Angle")
+
+ sub = split.column()
+ sub.prop(data, "show_extra_face_area", text="Face Area")
+ sub.prop(data, "show_extra_face_angle", text="Face Angle")
+
+
+class VIEW3D_PT_overlay_edit_mesh_normals(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh'
+ bl_label = "Normals"
+
+ @classmethod
+ def poll(cls, context):
+ return context.mode == 'EDIT_MESH'
+
+ def draw(self, context):
+ layout = self.layout
+
+ view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
+
+ col = layout.column()
+ col.active = display_all
+
+ row = col.row(align=True)
+ row.prop(overlay, "show_vertex_normals", text="", icon='VERTEXSEL')
+ row.prop(overlay, "show_split_normals", text="", icon='LOOPSEL')
+ row.prop(overlay, "show_face_normals", text="", icon='FACESEL')
+
+ sub = row.row(align=True)
+ sub.active = overlay.show_vertex_normals or overlay.show_face_normals or overlay.show_split_normals
+ sub.prop(overlay, "normals_length", text="Size")
+
+
+class VIEW3D_PT_overlay_edit_mesh_freestyle(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Freestyle"
+
+ @classmethod
+ def poll(cls, context):
+ return context.mode == 'EDIT_MESH' and bpy.app.build_options.freestyle
+
+ def draw(self, context):
+ layout = self.layout
+
+ view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
+ data = context.active_object.data
+
+ col = layout.column()
+ col.active = display_all
+
+ row = col.row()
+ row.prop(data, "show_freestyle_edge_marks", text="Edge Marks")
+ row.prop(data, "show_freestyle_face_marks", text="Face Marks")
+ row.prop(data, "show_edge_seams", text="Seams")
+
+
+class VIEW3D_PT_overlay_edit_mesh_developer(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh'
+ bl_label = "Developer"
+
+ @classmethod
+ def poll(cls, context):
+ return context.mode == 'EDIT_MESH' and context.user_preferences.view.show_developer_ui
+
+ def draw(self, context):
+ layout = self.layout
+
+ view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
+ data = context.active_object.data
+
+ col = layout.column()
+ col.active = display_all
+
+ col.prop(data, "show_extra_indices", text="Indices")
class VIEW3D_PT_overlay_edit_curve(Panel):
@@ -4035,11 +4447,12 @@ class VIEW3D_PT_overlay_pose(Panel):
col = layout.column()
col.active = display_all
col.prop(overlay, "show_transparent_bones")
- row = col.split(0.65)
- row.prop(overlay, "show_bone_selection")
- sub = row.column()
- sub.active = display_all and overlay.show_bone_selection
- sub.prop(overlay, "bone_selection_alpha", text="")
+
+ row = col.row()
+ row.prop(overlay, "show_bone_select", text="")
+ sub = row.row()
+ sub.active = display_all and overlay.show_bone_select
+ sub.prop(overlay, "bone_select_alpha", text="Fade Geometry")
class VIEW3D_PT_overlay_edit_armature(Panel):
@@ -4100,6 +4513,95 @@ class VIEW3D_PT_overlay_paint(Panel):
col.prop(overlay, "show_paint_wire")
+class VIEW3D_PT_pivot_point(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Pivot Point"
+ bl_ui_units_x = 8
+
+ def draw(self, context):
+ toolsettings = context.tool_settings
+ obj = context.active_object
+ mode = context.mode
+
+ layout = self.layout
+ col = layout.column()
+ col.label("Pivot Point")
+ col.prop(toolsettings, "transform_pivot_point", expand=True)
+
+ if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
+ col.separator()
+
+ col.prop(
+ toolsettings,
+ "use_transform_pivot_point_align",
+ text="Center Points Only",
+ )
+
+
+class VIEW3D_PT_snapping(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Snapping"
+
+ def draw(self, context):
+ toolsettings = context.tool_settings
+ snap_elements = toolsettings.snap_elements
+ obj = context.active_object
+ mode = context.mode
+ object_mode = 'OBJECT' if obj is None else obj.mode
+
+ layout = self.layout
+ col = layout.column()
+ col.label("Snapping")
+ col.prop(toolsettings, "snap_elements", expand=True)
+
+ col.separator()
+ if 'INCREMENT' in snap_elements:
+ col.prop(toolsettings, "use_snap_grid_absolute")
+
+ if snap_elements != {'INCREMENT'}:
+ col.label("Target")
+ row = col.row(align=True)
+ row.prop(toolsettings, "snap_target", expand=True)
+
+ if obj:
+ if object_mode == 'EDIT':
+ col.prop(toolsettings, "use_snap_self")
+ if object_mode in {'OBJECT', 'POSE', 'EDIT'}:
+ col.prop(toolsettings, "use_snap_align_rotation", text="Align Rotation")
+
+ if 'FACE' in snap_elements:
+ col.prop(toolsettings, "use_snap_project", text="Project Elements")
+
+ if 'VOLUME' in snap_elements:
+ col.prop(toolsettings, "use_snap_peel_object")
+
+
+class VIEW3D_PT_transform_orientations(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Transform Orientations"
+ bl_ui_units_x = 8
+
+ def draw(self, context):
+ layout = self.layout
+ layout.label("Transform Orientations")
+
+ scene = context.scene
+ orientation = scene.current_orientation
+
+ row = layout.row()
+ col = row.column()
+ col.prop(scene, "transform_orientation", expand=True)
+ row.operator("transform.create_orientation", text="", icon='ZOOMIN', emboss=False).use = True
+
+ if orientation:
+ row = layout.row(align=False)
+ row.prop(orientation, "name", text="")
+ row.operator("transform.delete_orientation", text="", icon='X', emboss=False)
+
+
class VIEW3D_PT_quad_view(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
@@ -4138,7 +4640,7 @@ class VIEW3D_PT_view3d_stereo(Panel):
scene = context.scene
multiview = scene.render.use_multiview
- return context.space_data and multiview
+ return multiview
def draw(self, context):
layout = self.layout
@@ -4251,7 +4753,7 @@ classes = (
INFO_MT_edit_curve_add,
INFO_MT_edit_armature_add,
INFO_MT_armature_add,
- INFO_MT_lamp_add,
+ INFO_MT_light_add,
INFO_MT_lightprobe_add,
INFO_MT_camera_add,
INFO_MT_add,
@@ -4340,20 +4842,37 @@ classes = (
VIEW3D_PT_grease_pencil,
VIEW3D_PT_grease_pencil_palettecolor,
VIEW3D_PT_view3d_properties,
+ VIEW3D_PT_view3d_camera_lock,
VIEW3D_PT_view3d_cursor,
+ VIEW3D_PT_object_type_visibility,
VIEW3D_PT_quad_view,
VIEW3D_PT_view3d_stereo,
VIEW3D_PT_shading,
VIEW3D_PT_shading_lighting,
VIEW3D_PT_shading_color,
VIEW3D_PT_shading_options,
+ VIEW3D_PT_shading_options_shadow,
+ VIEW3D_PT_shading_options_ssao,
VIEW3D_PT_overlay,
+ VIEW3D_PT_overlay_gizmo,
+ VIEW3D_PT_overlay_guides,
+ VIEW3D_PT_overlay_object,
+ VIEW3D_PT_overlay_geometry,
+ VIEW3D_PT_overlay_motion_tracking,
VIEW3D_PT_overlay_edit_mesh,
+ VIEW3D_PT_overlay_edit_mesh_shading,
+ VIEW3D_PT_overlay_edit_mesh_measurement,
+ VIEW3D_PT_overlay_edit_mesh_normals,
+ VIEW3D_PT_overlay_edit_mesh_freestyle,
+ VIEW3D_PT_overlay_edit_mesh_developer,
VIEW3D_PT_overlay_edit_curve,
VIEW3D_PT_overlay_edit_armature,
VIEW3D_PT_overlay_pose,
VIEW3D_PT_overlay_paint,
VIEW3D_PT_overlay_sculpt,
+ VIEW3D_PT_pivot_point,
+ VIEW3D_PT_snapping,
+ VIEW3D_PT_transform_orientations,
VIEW3D_PT_context_properties,
)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index a81dfdcfb09..3b68057c26d 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -247,18 +247,14 @@ class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel):
col.label("Missing Canvas", icon='INFO')
col.label("Add or assign a canvas image below")
col.label("Canvas Image:")
- # todo this should be combinded into a single row
- col.template_ID(toolsettings, "canvas", open="image.open")
- col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
+ col.template_ID(toolsettings, "canvas", new="image.new", open="image.open")
if toolsettings.missing_stencil:
col.separator()
col.label("Missing Stencil", icon='INFO')
col.label("Add or assign a stencil image below")
col.label("Stencil Image:")
- # todo this should be combinded into a single row
- col.template_ID(toolsettings, "stencil_image", open="image.open")
- col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
+ col.template_ID(toolsettings, "stencil_image", new="image.new", open="image.open")
# TODO, move to space_view3d.py
@@ -585,9 +581,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
mesh = ob.data
uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else ""
col.label("Canvas Image:")
- # todo this should be combinded into a single row
- col.template_ID(settings, "canvas", open="image.open")
- col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
+ col.template_ID(settings, "canvas", new="image.new", open="image.open")
col.label("UV Map:")
col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False)
@@ -635,8 +629,7 @@ class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
colsub.alignment = 'RIGHT'
colsub.label("Stencil Image")
colsub = split.column()
- colsub.template_ID(ipaint, "stencil_image", open="image.open")
- colsub.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
+ colsub.template_ID(ipaint, "stencil_image", new="image.new", open="image.open")
row = col.row(align=True)
row.prop(ipaint, "stencil_color", text="Display Color")
@@ -895,6 +888,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
bl_label = "Dyntopo"
bl_options = {'DEFAULT_CLOSED'}
+ bl_ui_units_x = 12
@classmethod
def poll(cls, context):
@@ -913,6 +907,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
+ layout.use_property_decorate = False
toolsettings = context.tool_settings
sculpt = toolsettings.sculpt
@@ -924,7 +919,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
sub = col.column()
sub.active = (brush and brush.sculpt_tool != 'MASK')
- if (sculpt.detail_type_method == 'CONSTANT'):
+ if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}:
row = sub.row(align=True)
row.prop(sculpt, "constant_detail_resolution")
row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
@@ -942,7 +937,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
col.prop(sculpt, "symmetrize_direction")
col.operator("sculpt.symmetrize")
col.operator("sculpt.optimize")
- if (sculpt.detail_type_method == 'CONSTANT'):
+ if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}:
col.operator("sculpt.detail_flood_fill")
diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py
index 390c043bb31..0d904de1d27 100644
--- a/release/scripts/startup/keyingsets_builtins.py
+++ b/release/scripts/startup/keyingsets_builtins.py
@@ -527,6 +527,8 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
ksi.addProp(ks, bone, prop)
# All properties that are likely to get animated in a character rig, only selected bones.
+
+
class BUILTIN_KSI_WholeCharacterSelected(KeyingSetInfo):
"""Insert a keyframe for all properties that are likely to get animated in a character rig """
"""(only selected bones)"""
@@ -557,6 +559,8 @@ class BUILTIN_KSI_WholeCharacterSelected(KeyingSetInfo):
###############################
# Delta Location
+
+
class BUILTIN_KSI_DeltaLocation(KeyingSetInfo):
"""Insert keyframes for additional location offset"""
bl_label = "Delta Location"
@@ -643,6 +647,7 @@ class BUILTIN_KSI_DeltaScale(KeyingSetInfo):
###############################
+
# Note that this controls order of options in 'insert keyframe' menu.
# Better try to keep some logical order here beyond mere alphabetical one, also because of menu entries shortcut.
# See also T51867.
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 713dbdafcc5..a70d78c16c6 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -61,12 +61,13 @@ def group_tools_draw(self, layout, context):
layout.operator("node.group_ungroup")
layout.separator()
+
# maps node tree type to group node type
node_tree_group_type = {
'CompositorNodeTree': 'CompositorNodeGroup',
'ShaderNodeTree': 'ShaderNodeGroup',
'TextureNodeTree': 'TextureNodeGroup',
- }
+}
# generic node group items generator for shader, compositor and texture node groups
@@ -185,14 +186,14 @@ shader_node_categories = [
NodeItem("ShaderNodeUVMap"),
NodeItem("ShaderNodeUVAlongStroke", poll=line_style_shader_nodes_poll),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
- ]),
+ ]),
ShaderNodeCategory("SH_NEW_OUTPUT", "Output", items=[
NodeItem("ShaderNodeOutputMaterial", poll=object_eevee_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeOutputLamp", poll=object_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeOutputLight", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeOutputWorld", poll=world_shader_nodes_poll),
NodeItem("ShaderNodeOutputLineStyle", poll=line_style_shader_nodes_poll),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
- ]),
+ ]),
ShaderNodeCategory("SH_NEW_SHADER", "Shader", items=[
NodeItem("ShaderNodeMixShader", poll=eevee_cycles_shader_nodes_poll),
NodeItem("ShaderNodeAddShader", poll=eevee_cycles_shader_nodes_poll),
@@ -215,7 +216,8 @@ shader_node_categories = [
NodeItem("ShaderNodeVolumeScatter", poll=eevee_cycles_shader_nodes_poll),
NodeItem("ShaderNodeVolumePrincipled"),
NodeItem("ShaderNodeEeveeSpecular", poll=object_eevee_shader_nodes_poll),
- ]),
+ NodeItem("ShaderNodeBsdfHairPrincipled", poll=object_shader_nodes_poll)
+ ]),
ShaderNodeCategory("SH_NEW_TEXTURE", "Texture", items=[
NodeItem("ShaderNodeTexImage"),
NodeItem("ShaderNodeTexEnvironment"),
@@ -230,7 +232,7 @@ shader_node_categories = [
NodeItem("ShaderNodeTexBrick"),
NodeItem("ShaderNodeTexPointDensity"),
NodeItem("ShaderNodeTexIES"),
- ]),
+ ]),
ShaderNodeCategory("SH_NEW_OP_COLOR", "Color", items=[
NodeItem("ShaderNodeMixRGB"),
NodeItem("ShaderNodeRGBCurve"),
@@ -239,7 +241,7 @@ shader_node_categories = [
NodeItem("ShaderNodeHueSaturation"),
NodeItem("ShaderNodeGamma"),
NodeItem("ShaderNodeBrightContrast"),
- ]),
+ ]),
ShaderNodeCategory("SH_NEW_OP_VECTOR", "Vector", items=[
NodeItem("ShaderNodeMapping"),
NodeItem("ShaderNodeBump"),
@@ -249,7 +251,7 @@ shader_node_categories = [
NodeItem("ShaderNodeNormal"),
NodeItem("ShaderNodeVectorCurve"),
NodeItem("ShaderNodeVectorTransform"),
- ]),
+ ]),
ShaderNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[
NodeItem("ShaderNodeMath"),
NodeItem("ShaderNodeValToRGB"),
@@ -264,16 +266,16 @@ shader_node_categories = [
NodeItem("ShaderNodeCombineHSV"),
NodeItem("ShaderNodeWavelength"),
NodeItem("ShaderNodeBlackbody"),
- ]),
+ ]),
ShaderNodeCategory("SH_NEW_SCRIPT", "Script", items=[
NodeItem("ShaderNodeScript"),
- ]),
+ ]),
ShaderNodeCategory("SH_NEW_GROUP", "Group", items=node_group_items),
ShaderNodeCategory("SH_NEW_LAYOUT", "Layout", items=[
NodeItem("NodeFrame"),
NodeItem("NodeReroute"),
- ]),
- ]
+ ]),
+]
compositor_node_categories = [
# Compositor Nodes
@@ -289,7 +291,7 @@ compositor_node_categories = [
NodeItem("CompositorNodeTime"),
NodeItem("CompositorNodeTrackPos"),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
- ]),
+ ]),
CompositorNodeCategory("CMP_OUTPUT", "Output", items=[
NodeItem("CompositorNodeComposite"),
NodeItem("CompositorNodeViewer"),
@@ -297,7 +299,7 @@ compositor_node_categories = [
NodeItem("CompositorNodeOutputFile"),
NodeItem("CompositorNodeLevels"),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
- ]),
+ ]),
CompositorNodeCategory("CMP_OP_COLOR", "Color", items=[
NodeItem("CompositorNodeMixRGB"),
NodeItem("CompositorNodeAlphaOver"),
@@ -311,7 +313,7 @@ compositor_node_categories = [
NodeItem("CompositorNodeColorCorrection"),
NodeItem("CompositorNodeTonemap"),
NodeItem("CompositorNodeZcombine"),
- ]),
+ ]),
CompositorNodeCategory("CMP_CONVERTOR", "Converter", items=[
NodeItem("CompositorNodeMath"),
NodeItem("CompositorNodeValToRGB"),
@@ -328,7 +330,7 @@ compositor_node_categories = [
NodeItem("CompositorNodeSepYCCA"),
NodeItem("CompositorNodeCombYCCA"),
NodeItem("CompositorNodeSwitchView"),
- ]),
+ ]),
CompositorNodeCategory("CMP_OP_FILTER", "Filter", items=[
NodeItem("CompositorNodeBlur"),
NodeItem("CompositorNodeBilateralblur"),
@@ -343,14 +345,14 @@ compositor_node_categories = [
NodeItem("CompositorNodeDBlur"),
NodeItem("CompositorNodePixelate"),
NodeItem("CompositorNodeSunBeams"),
- ]),
+ ]),
CompositorNodeCategory("CMP_OP_VECTOR", "Vector", items=[
NodeItem("CompositorNodeNormal"),
NodeItem("CompositorNodeMapValue"),
NodeItem("CompositorNodeMapRange"),
NodeItem("CompositorNodeNormalize"),
NodeItem("CompositorNodeCurveVec"),
- ]),
+ ]),
CompositorNodeCategory("CMP_MATTE", "Matte", items=[
NodeItem("CompositorNodeKeying"),
NodeItem("CompositorNodeKeyingScreen"),
@@ -364,7 +366,8 @@ compositor_node_categories = [
NodeItem("CompositorNodeChromaMatte"),
NodeItem("CompositorNodeColorMatte"),
NodeItem("CompositorNodeDoubleEdgeMask"),
- ]),
+ NodeItem("CompositorNodeCryptomatte"),
+ ]),
CompositorNodeCategory("CMP_DISTORT", "Distort", items=[
NodeItem("CompositorNodeScale"),
NodeItem("CompositorNodeLensdist"),
@@ -379,14 +382,14 @@ compositor_node_categories = [
NodeItem("CompositorNodeStabilize"),
NodeItem("CompositorNodePlaneTrackDeform"),
NodeItem("CompositorNodeCornerPin"),
- ]),
+ ]),
CompositorNodeCategory("CMP_GROUP", "Group", items=node_group_items),
CompositorNodeCategory("CMP_LAYOUT", "Layout", items=[
NodeItem("NodeFrame"),
NodeItem("NodeReroute"),
NodeItem("CompositorNodeSwitch"),
- ]),
- ]
+ ]),
+]
texture_node_categories = [
# Texture Nodes
@@ -396,12 +399,12 @@ texture_node_categories = [
NodeItem("TextureNodeTexture"),
NodeItem("TextureNodeImage"),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
- ]),
+ ]),
TextureNodeCategory("TEX_OUTPUT", "Output", items=[
NodeItem("TextureNodeOutput"),
NodeItem("TextureNodeViewer"),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
- ]),
+ ]),
TextureNodeCategory("TEX_OP_COLOR", "Color", items=[
NodeItem("TextureNodeMixRGB"),
NodeItem("TextureNodeCurveRGB"),
@@ -409,11 +412,11 @@ texture_node_categories = [
NodeItem("TextureNodeHueSaturation"),
NodeItem("TextureNodeCompose"),
NodeItem("TextureNodeDecompose"),
- ]),
+ ]),
TextureNodeCategory("TEX_PATTERN", "Pattern", items=[
NodeItem("TextureNodeChecker"),
NodeItem("TextureNodeBricks"),
- ]),
+ ]),
TextureNodeCategory("TEX_TEXTURE", "Textures", items=[
NodeItem("TextureNodeTexNoise"),
NodeItem("TextureNodeTexDistNoise"),
@@ -425,26 +428,26 @@ texture_node_categories = [
NodeItem("TextureNodeTexWood"),
NodeItem("TextureNodeTexMusgrave"),
NodeItem("TextureNodeTexStucci"),
- ]),
+ ]),
TextureNodeCategory("TEX_CONVERTOR", "Converter", items=[
NodeItem("TextureNodeMath"),
NodeItem("TextureNodeValToRGB"),
NodeItem("TextureNodeRGBToBW"),
NodeItem("TextureNodeValToNor"),
NodeItem("TextureNodeDistance"),
- ]),
+ ]),
TextureNodeCategory("TEX_DISTORT", "Distort", items=[
NodeItem("TextureNodeScale"),
NodeItem("TextureNodeTranslate"),
NodeItem("TextureNodeRotate"),
NodeItem("TextureNodeAt"),
- ]),
+ ]),
TextureNodeCategory("TEX_GROUP", "Group", items=node_group_items),
TextureNodeCategory("TEX_LAYOUT", "Layout", items=[
NodeItem("NodeFrame"),
NodeItem("NodeReroute"),
- ]),
- ]
+ ]),
+]
def register():
diff --git a/release/scripts/templates_py/addon_add_object.py b/release/scripts/templates_py/addon_add_object.py
index b74c0f8ee25..d26f3d351bf 100644
--- a/release/scripts/templates_py/addon_add_object.py
+++ b/release/scripts/templates_py/addon_add_object.py
@@ -45,7 +45,7 @@ class OBJECT_OT_add_object(Operator, AddObjectHelper):
bl_label = "Add Mesh Object"
bl_options = {'REGISTER', 'UNDO'}
- scale = FloatVectorProperty(
+ scale: FloatVectorProperty(
name="scale",
default=(1.0, 1.0, 1.0),
subtype='TRANSLATION',
diff --git a/release/scripts/templates_py/background_job.py b/release/scripts/templates_py/background_job.py
index 2f444641a51..020dabeb258 100644
--- a/release/scripts/templates_py/background_job.py
+++ b/release/scripts/templates_py/background_job.py
@@ -42,11 +42,11 @@ def example_function(text, save_path, render_path):
scene.camera = cam_ob # set the active camera
cam_ob.location = 0.0, 0.0, 10.0
- # Lamp
- lamp_data = bpy.data.lamps.new("MyLamp", 'POINT')
- lamp_ob = bpy.data.objects.new(name="MyCam", object_data=lamp_data)
- scene.objects.link(lamp_ob)
- lamp_ob.location = 2.0, 2.0, 5.0
+ # Light
+ light_data = bpy.data.lights.new("MyLight", 'POINT')
+ light_ob = bpy.data.objects.new(name="MyCam", object_data=light_data)
+ scene.objects.link(light_ob)
+ light_ob.location = 2.0, 2.0, 5.0
if save_path:
bpy.ops.wm.save_as_mainfile(filepath=save_path)
diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py
index 23d8ee55e72..7e4e89dafeb 100644
--- a/release/scripts/templates_py/custom_nodes.py
+++ b/release/scripts/templates_py/custom_nodes.py
@@ -30,10 +30,15 @@ class MyCustomSocket(NodeSocket):
('DOWN', "Down", "Where your feet are"),
('UP', "Up", "Where your head should be"),
('LEFT', "Left", "Not right"),
- ('RIGHT', "Right", "Not left")
+ ('RIGHT', "Right", "Not left"),
)
- my_enum_prop = bpy.props.EnumProperty(name="Direction", description="Just an example", items=my_items, default='UP')
+ my_enum_prop: bpy.props.EnumProperty(
+ name="Direction",
+ description="Just an example",
+ items=my_items,
+ default='UP',
+ )
# Optional function for drawing the socket input value
def draw(self, context, layout, node, text):
@@ -71,8 +76,8 @@ class MyCustomNode(Node, MyCustomTreeNode):
# These work just like custom properties in ID data blocks
# Extensive information can be found under
# http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Properties
- my_string_prop = bpy.props.StringProperty()
- my_float_prop = bpy.props.FloatProperty(default=3.1415926)
+ my_string_prop: bpy.props.StringProperty()
+ my_float_prop: bpy.props.FloatProperty(default=3.1415926)
# === Optional Functions ===
# Initialization function, called when a new node is created.
diff --git a/release/scripts/templates_py/manipulator_custom_geometry.py b/release/scripts/templates_py/gizmo_custom_geometry.py
index 48bb6956f85..8125498fa85 100644
--- a/release/scripts/templates_py/manipulator_custom_geometry.py
+++ b/release/scripts/templates_py/gizmo_custom_geometry.py
@@ -1,12 +1,12 @@
# Example of a custom widget that defines it's own geometry.
#
-# Usage: Select a lamp in the 3D view and drag the arrow at it's rear
+# Usage: Select a light in the 3D view and drag the arrow at it's rear
# to change it's energy value.
#
import bpy
from bpy.types import (
- Manipulator,
- ManipulatorGroup,
+ Gizmo,
+ GizmoGroup,
)
# Coordinates (each one is a triangle).
@@ -62,8 +62,8 @@ custom_shape_verts = (
)
-class MyCustomShapeWidget(Manipulator):
- bl_idname = "VIEW3D_WT_auto_facemap"
+class MyCustomShapeWidget(Gizmo):
+ bl_idname = "VIEW3D_GT_auto_facemap"
bl_target_properties = (
{"id": "offset", "type": 'FLOAT', "array_length": 1},
)
@@ -75,7 +75,7 @@ class MyCustomShapeWidget(Manipulator):
)
def _update_offset_matrix(self):
- # offset behind the lamp
+ # offset behind the light
self.matrix_offset.col[3][2] = self.target_get_value("offset") / -10.0
def draw(self, context):
@@ -108,13 +108,13 @@ class MyCustomShapeWidget(Manipulator):
delta /= 10.0
value = self.init_value + delta
self.target_set_value("offset", value)
- context.area.header_text_set("My Manipulator: %.4f" % value)
+ context.area.header_text_set("My Gizmo: %.4f" % value)
return {'RUNNING_MODAL'}
-class MyCustomShapeWidgetGroup(ManipulatorGroup):
- bl_idname = "OBJECT_WGT_lamp_test"
- bl_label = "Test Lamp Widget"
+class MyCustomShapeWidgetGroup(GizmoGroup):
+ bl_idname = "OBJECT_GGT_light_test"
+ bl_label = "Test Light Widget"
bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW'
bl_options = {'3D', 'PERSISTENT'}
@@ -122,12 +122,12 @@ class MyCustomShapeWidgetGroup(ManipulatorGroup):
@classmethod
def poll(cls, context):
ob = context.object
- return (ob and ob.type == 'LAMP')
+ return (ob and ob.type == 'LIGHT')
def setup(self, context):
- # Assign the 'offset' target property to the lamp energy.
+ # Assign the 'offset' target property to the light energy.
ob = context.object
- mpr = self.manipulators.new(MyCustomShapeWidget.bl_idname)
+ mpr = self.gizmos.new(MyCustomShapeWidget.bl_idname)
mpr.target_set_prop("offset", ob.data, "energy")
mpr.matrix_basis = ob.matrix_world.normalized()
diff --git a/release/scripts/templates_py/manipulator_operator.py b/release/scripts/templates_py/gizmo_operator.py
index 35e1c5b4fd1..bdc1bc9893c 100644
--- a/release/scripts/templates_py/manipulator_operator.py
+++ b/release/scripts/templates_py/gizmo_operator.py
@@ -1,15 +1,15 @@
-# Example of an operator which uses manipulators to control its properties.
+# Example of an operator which uses gizmos to control its properties.
#
# Usage: Run this script, then in mesh edit-mode press Spacebar
# to activate the operator "Select Side of Plane"
-# The manipulators can then be used to adjust the plane in the 3D view.
+# The gizmos can then be used to adjust the plane in the 3D view.
#
import bpy
import bmesh
from bpy.types import (
Operator,
- ManipulatorGroup,
+ GizmoGroup,
)
from bpy.props import (
@@ -39,11 +39,11 @@ class SelectSideOfPlane(Operator):
bl_label = "Select Side of Plane"
bl_options = {'REGISTER', 'UNDO'}
- plane_co = FloatVectorProperty(
+ plane_co: FloatVectorProperty(
size=3,
default=(0, 0, 0),
)
- plane_no = FloatVectorProperty(
+ plane_no: FloatVectorProperty(
size=3,
default=(0, 0, 1),
)
@@ -68,7 +68,7 @@ class SelectSideOfPlane(Operator):
if context.space_data.type == 'VIEW_3D':
wm = context.window_manager
- wm.manipulator_group_type_add(SelectSideOfPlaneManipulatorGroup.bl_idname)
+ wm.gizmo_group_type_add(SelectSideOfPlaneGizmoGroup.bl_idname)
return {'FINISHED'}
@@ -78,10 +78,10 @@ class SelectSideOfPlane(Operator):
return {'FINISHED'}
-# Manipulators for plane_co, plane_no
-class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
- bl_idname = "MESH_WGT_select_side_of_plane"
- bl_label = "Side of Plane Manipulator"
+# Gizmos for plane_co, plane_no
+class SelectSideOfPlaneGizmoGroup(GizmoGroup):
+ bl_idname = "MESH_GGT_select_side_of_plane"
+ bl_label = "Side of Plane Gizmo"
bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW'
bl_options = {'3D'}
@@ -106,7 +106,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
op = cls.my_target_operator(context)
if op is None:
wm = context.window_manager
- wm.manipulator_group_type_remove(SelectSideOfPlaneManipulatorGroup.bl_idname)
+ wm.gizmo_group_type_remove(SelectSideOfPlaneGizmoGroup.bl_idname)
return False
return True
@@ -117,16 +117,16 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
# Grab
def grab_get_cb():
- op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
+ op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
return op.plane_co
def grab_set_cb(value):
- op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
+ op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
op.plane_co = value
# XXX, this may change!
op.execute(context)
- mpr = self.manipulators.new("MANIPULATOR_WT_grab_3d")
+ mpr = self.gizmos.new("GIZMO_GT_grab_3d")
mpr.target_set_handler("offset", get=grab_get_cb, set=grab_set_cb)
mpr.use_draw_value = True
@@ -145,7 +145,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
# Dial
def direction_get_cb():
- op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
+ op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
no_a = self.widget_dial.matrix_basis.col[1].xyz
no_b = Vector(op.plane_no)
@@ -155,13 +155,13 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
return no_a.angle_signed(no_b)
def direction_set_cb(value):
- op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
+ op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
matrix_rotate = Matrix.Rotation(-value, 3, self.rotate_axis)
no = matrix_rotate * self.widget_dial.matrix_basis.col[1].xyz
op.plane_no = no
op.execute(context)
- mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d")
+ mpr = self.gizmos.new("GIZMO_GT_dial_3d")
mpr.target_set_handler("offset", get=direction_get_cb, set=direction_set_cb)
mpr.draw_options = {'ANGLE_START_Y'}
@@ -216,7 +216,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
classes = (
SelectSideOfPlane,
- SelectSideOfPlaneManipulatorGroup,
+ SelectSideOfPlaneGizmoGroup,
)
diff --git a/release/scripts/templates_py/manipulator_operator_target.py b/release/scripts/templates_py/gizmo_operator_target.py
index ba53b5e10ff..606aa6749d0 100644
--- a/release/scripts/templates_py/manipulator_operator_target.py
+++ b/release/scripts/templates_py/gizmo_operator_target.py
@@ -1,16 +1,16 @@
-# Example of a manipulator that activates an operator
-# using the predefined dial manipulator to change the camera roll.
+# Example of a gizmo that activates an operator
+# using the predefined dial gizmo to change the camera roll.
#
# Usage: Run this script and select a camera in the 3D view.
#
import bpy
from bpy.types import (
- ManipulatorGroup,
+ GizmoGroup,
)
-class MyCameraWidgetGroup(ManipulatorGroup):
- bl_idname = "OBJECT_WGT_test_camera"
+class MyCameraWidgetGroup(GizmoGroup):
+ bl_idname = "OBJECT_GGT_test_camera"
bl_label = "Object Camera Test Widget"
bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW'
@@ -22,9 +22,9 @@ class MyCameraWidgetGroup(ManipulatorGroup):
return (ob and ob.type == 'CAMERA')
def setup(self, context):
- # Run an operator using the dial manipulator
+ # Run an operator using the dial gizmo
ob = context.object
- mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d")
+ mpr = self.gizmos.new("GIZMO_GT_dial_3d")
props = mpr.target_set_operator("transform.rotate")
props.constraint_axis = False, False, True
props.constraint_orientation = 'LOCAL'
diff --git a/release/scripts/templates_py/manipulator_simple.py b/release/scripts/templates_py/gizmo_simple.py
index 8ddb870cd13..396378da04c 100644
--- a/release/scripts/templates_py/manipulator_simple.py
+++ b/release/scripts/templates_py/gizmo_simple.py
@@ -1,18 +1,18 @@
# Example of a group that edits a single property
-# using the predefined manipulator arrow.
+# using the predefined gizmo arrow.
#
-# Usage: Select a lamp in the 3D view and drag the arrow at it's rear
+# Usage: Select a light in the 3D view and drag the arrow at it's rear
# to change it's energy value.
#
import bpy
from bpy.types import (
- ManipulatorGroup,
+ GizmoGroup,
)
-class MyLampWidgetGroup(ManipulatorGroup):
- bl_idname = "OBJECT_WGT_lamp_test"
- bl_label = "Test Lamp Widget"
+class MyLightWidgetGroup(GizmoGroup):
+ bl_idname = "OBJECT_GGT_light_test"
+ bl_label = "Test Light Widget"
bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW'
bl_options = {'3D', 'PERSISTENT'}
@@ -20,12 +20,12 @@ class MyLampWidgetGroup(ManipulatorGroup):
@classmethod
def poll(cls, context):
ob = context.object
- return (ob and ob.type == 'LAMP')
+ return (ob and ob.type == 'LIGHT')
def setup(self, context):
- # Arrow manipulator has one 'offset' property we can assign to the lamp energy.
+ # Arrow gizmo has one 'offset' property we can assign to the light energy.
ob = context.object
- mpr = self.manipulators.new("MANIPULATOR_WT_arrow_3d")
+ mpr = self.gizmos.new("GIZMO_GT_arrow_3d")
mpr.target_set_prop("offset", ob.data, "energy")
mpr.matrix_basis = ob.matrix_world.normalized()
mpr.draw_style = 'BOX'
@@ -44,4 +44,4 @@ class MyLampWidgetGroup(ManipulatorGroup):
mpr.matrix_basis = ob.matrix_world.normalized()
-bpy.utils.register_class(MyLampWidgetGroup)
+bpy.utils.register_class(MyLightWidgetGroup)
diff --git a/release/scripts/templates_py/operator_file_export.py b/release/scripts/templates_py/operator_file_export.py
index 8a1eb4ae54c..4ea817d3507 100644
--- a/release/scripts/templates_py/operator_file_export.py
+++ b/release/scripts/templates_py/operator_file_export.py
@@ -25,7 +25,7 @@ class ExportSomeData(Operator, ExportHelper):
# ExportHelper mixin class uses this
filename_ext = ".txt"
- filter_glob = StringProperty(
+ filter_glob: StringProperty(
default="*.txt",
options={'HIDDEN'},
maxlen=255, # Max internal buffer length, longer would be clamped.
@@ -33,13 +33,13 @@ class ExportSomeData(Operator, ExportHelper):
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
- use_setting = BoolProperty(
+ use_setting: BoolProperty(
name="Example Boolean",
description="Example Tooltip",
default=True,
)
- type = EnumProperty(
+ type: EnumProperty(
name="Example Enum",
description="Choose between two items",
items=(
diff --git a/release/scripts/templates_py/operator_file_import.py b/release/scripts/templates_py/operator_file_import.py
index 9856b6a9040..b932b008c49 100644
--- a/release/scripts/templates_py/operator_file_import.py
+++ b/release/scripts/templates_py/operator_file_import.py
@@ -28,7 +28,7 @@ class ImportSomeData(Operator, ImportHelper):
# ImportHelper mixin class uses this
filename_ext = ".txt"
- filter_glob = StringProperty(
+ filter_glob: StringProperty(
default="*.txt",
options={'HIDDEN'},
maxlen=255, # Max internal buffer length, longer would be clamped.
@@ -36,13 +36,13 @@ class ImportSomeData(Operator, ImportHelper):
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
- use_setting = BoolProperty(
+ use_setting: BoolProperty(
name="Example Boolean",
description="Example Tooltip",
default=True,
)
- type = EnumProperty(
+ type: EnumProperty(
name="Example Enum",
description="Choose between two items",
items=(
diff --git a/release/scripts/templates_py/operator_mesh_add.py b/release/scripts/templates_py/operator_mesh_add.py
index 407956a0fda..6b39ef7bbba 100644
--- a/release/scripts/templates_py/operator_mesh_add.py
+++ b/release/scripts/templates_py/operator_mesh_add.py
@@ -49,25 +49,25 @@ class AddBox(bpy.types.Operator):
bl_label = "Add Box"
bl_options = {'REGISTER', 'UNDO'}
- width = FloatProperty(
+ width: FloatProperty(
name="Width",
description="Box Width",
min=0.01, max=100.0,
default=1.0,
)
- height = FloatProperty(
+ height: FloatProperty(
name="Height",
description="Box Height",
min=0.01, max=100.0,
default=1.0,
)
- depth = FloatProperty(
+ depth: FloatProperty(
name="Depth",
description="Box Depth",
min=0.01, max=100.0,
default=1.0,
)
- layers = BoolVectorProperty(
+ layers: BoolVectorProperty(
name="Layers",
description="Object Layers",
size=20,
@@ -75,15 +75,15 @@ class AddBox(bpy.types.Operator):
)
# generic transform props
- view_align = BoolProperty(
+ view_align: BoolProperty(
name="Align to View",
default=False,
)
- location = FloatVectorProperty(
+ location: FloatVectorProperty(
name="Location",
subtype='TRANSLATION',
)
- rotation = FloatVectorProperty(
+ rotation: FloatVectorProperty(
name="Rotation",
subtype='EULER',
)
diff --git a/release/scripts/templates_py/operator_modal.py b/release/scripts/templates_py/operator_modal.py
index 88e5ee80590..c242e3b67b9 100644
--- a/release/scripts/templates_py/operator_modal.py
+++ b/release/scripts/templates_py/operator_modal.py
@@ -7,8 +7,8 @@ class ModalOperator(bpy.types.Operator):
bl_idname = "object.modal_operator"
bl_label = "Simple Modal Operator"
- first_mouse_x = IntProperty()
- first_value = FloatProperty()
+ first_mouse_x: IntProperty()
+ first_value: FloatProperty()
def modal(self, context, event):
if event.type == 'MOUSEMOVE':
diff --git a/release/scripts/templates_py/operator_modal_view3d.py b/release/scripts/templates_py/operator_modal_view3d.py
index 65bab3489b4..9d371446829 100644
--- a/release/scripts/templates_py/operator_modal_view3d.py
+++ b/release/scripts/templates_py/operator_modal_view3d.py
@@ -8,7 +8,7 @@ class ViewOperator(bpy.types.Operator):
bl_idname = "view3d.modal_operator"
bl_label = "Simple View Operator"
- offset = FloatVectorProperty(
+ offset: FloatVectorProperty(
name="Offset",
size=3,
)
diff --git a/release/scripts/templates_py/ui_list.py b/release/scripts/templates_py/ui_list.py
index 92e1b29d2ae..f6b82356a78 100644
--- a/release/scripts/templates_py/ui_list.py
+++ b/release/scripts/templates_py/ui_list.py
@@ -7,8 +7,10 @@ class MESH_UL_mylist(bpy.types.UIList):
# E.g. VGROUP_EMPTY = 1 << 0
# Custom properties, saved with .blend file. E.g.
- # use_filter_empty = bpy.props.BoolProperty(name="Filter Empty", default=False, options=set(),
- # description="Whether to filter empty vertex groups")
+ # use_filter_empty: bpy.props.BoolProperty(
+ # name="Filter Empty", default=False, options=set(),
+ # description="Whether to filter empty vertex groups",
+ # )
# Called for each drawn item.
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag):
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 5dd692d3855..b0e0cdac407 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -594,24 +594,24 @@ static void blf_draw_gl__start(FontBLF *font)
if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) == 0)
return; /* glyphs will be translated individually and batched. */
- gpuPushMatrix();
+ GPU_matrix_push();
if (font->flags & BLF_MATRIX)
- gpuMultMatrix(font->m);
+ GPU_matrix_mul(font->m);
- gpuTranslate3fv(font->pos);
+ GPU_matrix_translate_3fv(font->pos);
if (font->flags & BLF_ASPECT)
- gpuScale3fv(font->aspect);
+ GPU_matrix_scale_3fv(font->aspect);
if (font->flags & BLF_ROTATION)
- gpuRotate2D(RAD2DEG(font->angle));
+ GPU_matrix_rotate_2d(RAD2DEG(font->angle));
}
static void blf_draw_gl__end(FontBLF *font)
{
if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) != 0)
- gpuPopMatrix();
+ GPU_matrix_pop();
}
void BLF_draw_ex(
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index b3ab36f7bcc..ea81106e60f 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -91,31 +91,31 @@ static SpinLock ft_lib_mutex;
**/
static void blf_batch_draw_init(void)
{
- Gwn_VertFormat format = {0};
- g_batch.pos_loc = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
- g_batch.tex_loc = GWN_vertformat_attr_add(&format, "tex", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
- g_batch.col_loc = GWN_vertformat_attr_add(&format, "col", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat format = {0};
+ g_batch.pos_loc = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ g_batch.tex_loc = GPU_vertformat_attr_add(&format, "tex", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ g_batch.col_loc = GPU_vertformat_attr_add(&format, "col", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- g_batch.verts = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STREAM);
- GWN_vertbuf_data_alloc(g_batch.verts, BLF_BATCH_DRAW_LEN_MAX);
+ g_batch.verts = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STREAM);
+ GPU_vertbuf_data_alloc(g_batch.verts, BLF_BATCH_DRAW_LEN_MAX);
- GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step);
- GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step);
- GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step);
g_batch.glyph_len = 0;
- g_batch.batch = GWN_batch_create_ex(GWN_PRIM_POINTS, g_batch.verts, NULL, GWN_BATCH_OWNS_VBO);
+ g_batch.batch = GPU_batch_create_ex(GPU_PRIM_POINTS, g_batch.verts, NULL, GPU_BATCH_OWNS_VBO);
}
static void blf_batch_draw_exit(void)
{
- GWN_BATCH_DISCARD_SAFE(g_batch.batch);
+ GPU_BATCH_DISCARD_SAFE(g_batch.batch);
}
void blf_batch_draw_vao_clear(void)
{
if (g_batch.batch) {
- gwn_batch_vao_cache_clear(g_batch.batch);
+ GPU_batch_vao_cache_clear(g_batch.batch);
}
}
@@ -142,15 +142,15 @@ void blf_batch_draw_begin(FontBLF *font)
if (g_batch.active) {
float gpumat[4][4];
- gpuGetModelViewMatrix(gpumat);
+ GPU_matrix_model_view_get(gpumat);
bool mat_changed = (memcmp(gpumat, g_batch.mat, sizeof(g_batch.mat)) != 0);
if (mat_changed) {
/* Modelviewmat is no longer the same.
* Flush cache but with the previous mat. */
- gpuPushMatrix();
- gpuLoadMatrix(g_batch.mat);
+ GPU_matrix_push();
+ GPU_matrix_set(g_batch.mat);
}
/* flush cache if config is not the same. */
@@ -165,7 +165,7 @@ void blf_batch_draw_begin(FontBLF *font)
}
if (mat_changed) {
- gpuPopMatrix();
+ GPU_matrix_pop();
/* Save for next memcmp. */
memcpy(g_batch.mat, gpumat, sizeof(g_batch.mat));
}
@@ -190,20 +190,20 @@ void blf_batch_draw(void)
UI_widgetbase_draw_cache_flush();
GPU_texture_bind(g_batch.tex_bind_state, 0);
- GWN_vertbuf_vertex_count_set(g_batch.verts, g_batch.glyph_len);
- GWN_vertbuf_use(g_batch.verts); /* send data */
+ GPU_vertbuf_vertex_count_set(g_batch.verts, g_batch.glyph_len);
+ GPU_vertbuf_use(g_batch.verts); /* send data */
GPUBuiltinShader shader = (g_batch.simple_shader) ? GPU_SHADER_TEXT_SIMPLE : GPU_SHADER_TEXT;
- GWN_batch_program_set_builtin(g_batch.batch, shader);
- GWN_batch_uniform_1i(g_batch.batch, "glyph", 0);
- GWN_batch_draw(g_batch.batch);
+ GPU_batch_program_set_builtin(g_batch.batch, shader);
+ GPU_batch_uniform_1i(g_batch.batch, "glyph", 0);
+ GPU_batch_draw(g_batch.batch);
GPU_blend(false);
/* restart to 1st vertex data pointers */
- GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step);
- GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step);
- GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step);
g_batch.glyph_len = 0;
}
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 84388bedb7b..99be8539d24 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -239,12 +239,12 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
}
unsigned char *pixels = MEM_callocN((size_t)gc->p2_width * (size_t)gc->p2_height, "BLF texture init");
- GPUTexture *tex = GPU_texture_create_2D(gc->p2_width, gc->p2_height, GPU_R8, (const float *)pixels, error);
+ GPUTexture *tex = GPU_texture_create_nD(gc->p2_width, gc->p2_height, 0, 2, pixels, GPU_R8, GPU_DATA_UNSIGNED_BYTE, 0, false, error);
MEM_freeN(pixels);
gc->textures[gc->texture_current] = tex;
GPU_texture_bind(tex, 0);
GPU_texture_wrap_mode(tex, false);
- GPU_texture_filters(tex, GPU_NEAREST, GPU_LINEAR);
+ GPU_texture_filters(tex, GPU_NEAREST, GPU_NEAREST);
GPU_texture_unbind(tex);
}
@@ -382,10 +382,10 @@ static void blf_texture_draw(const unsigned char color[4], const float uv[2][2],
{
/* Only one vertex per glyph, geometry shader expand it into a quad. */
/* TODO Get rid of Geom Shader because it's not optimal AT ALL for the GPU */
- copy_v4_fl4(GWN_vertbuf_raw_step(&g_batch.pos_step), x1 + g_batch.ofs[0], y1 + g_batch.ofs[1],
+ copy_v4_fl4(GPU_vertbuf_raw_step(&g_batch.pos_step), x1 + g_batch.ofs[0], y1 + g_batch.ofs[1],
x2 + g_batch.ofs[0], y2 + g_batch.ofs[1]);
- copy_v4_v4(GWN_vertbuf_raw_step(&g_batch.tex_step), (float *)uv);
- copy_v4_v4_uchar(GWN_vertbuf_raw_step(&g_batch.col_step), color);
+ copy_v4_v4(GPU_vertbuf_raw_step(&g_batch.tex_step), (float *)uv);
+ copy_v4_v4_uchar(GPU_vertbuf_raw_step(&g_batch.col_step), color);
g_batch.glyph_len++;
/* Flush cache if it's full. */
if (g_batch.glyph_len == BLF_BATCH_DRAW_LEN_MAX) {
@@ -476,7 +476,7 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
BLI_assert(g->height > 0);
}
- GPU_texture_update_sub(g->tex, g->bitmap, g->offset_x, g->offset_y, 0, g->width, g->height, 0);
+ GPU_texture_update_sub(g->tex, GPU_DATA_UNSIGNED_BYTE, g->bitmap, g->offset_x, g->offset_y, 0, g->width, g->height, 0);
g->uv[0][0] = ((float)g->offset_x) / ((float)gc->p2_width);
g->uv[0][1] = ((float)g->offset_y) / ((float)gc->p2_height);
diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h
index 999773d0212..265835f4c75 100644
--- a/source/blender/blenfont/intern/blf_internal_types.h
+++ b/source/blender/blenfont/intern/blf_internal_types.h
@@ -31,16 +31,16 @@
#ifndef __BLF_INTERNAL_TYPES_H__
#define __BLF_INTERNAL_TYPES_H__
-#include "../../../intern/gawain/gawain/gwn_vertex_buffer.h"
+#include "GPU_vertex_buffer.h"
#include "GPU_texture.h"
#define BLF_BATCH_DRAW_LEN_MAX 2048 /* in glyph */
typedef struct BatchBLF {
struct FontBLF *font; /* can only batch glyph from the same font */
- struct Gwn_Batch *batch;
- struct Gwn_VertBuf *verts;
- struct Gwn_VertBufRaw pos_step, tex_step, col_step;
+ struct GPUBatch *batch;
+ struct GPUVertBuf *verts;
+ struct GPUVertBufRaw pos_step, tex_step, col_step;
unsigned int pos_loc, tex_loc, col_loc;
unsigned int glyph_len;
float ofs[2]; /* copy of font->pos */
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 3099875c145..cdf0d683779 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -530,15 +530,8 @@ DerivedMesh *getEditDerivedBMesh(
struct BMEditMesh *em, struct Object *ob, CustomDataMask data_mask,
float (*vertexCos)[3]);
-DerivedMesh *mesh_create_derived_index_render(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask, int index);
-
/* same as above but wont use render settings */
DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
-DerivedMesh *mesh_create_derived_view(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_no_deform(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, float (*vertCos)[3],
diff --git a/source/blender/blenkernel/BKE_addon.h b/source/blender/blenkernel/BKE_addon.h
index 3af6d3b61bf..a463525d644 100644
--- a/source/blender/blenkernel/BKE_addon.h
+++ b/source/blender/blenkernel/BKE_addon.h
@@ -53,6 +53,7 @@ void BKE_addon_pref_type_free(void);
struct bAddon *BKE_addon_new(void);
struct bAddon *BKE_addon_find(struct ListBase *addon_list, const char *module);
struct bAddon *BKE_addon_ensure(struct ListBase *addon_list, const char *module);
+bool BKE_addon_remove_safe(struct ListBase *addon_list, const char *module);
void BKE_addon_free(struct bAddon *addon);
#endif /* __BKE_ADDON_H__ */
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index b16e8c17a12..9e8e7f7b724 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -153,7 +153,7 @@ char *BKE_animdata_driver_path_hack(struct bContext *C, struct PointerRNA *ptr,
char *base_path);
/* ************************************* */
-/* Gwn_Batch AnimData API */
+/* GPUBatch AnimData API */
/* Define for callback looper used in BKE_animdata_main_cb */
typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data);
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index e1bfb05fb59..21d880cf2a7 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -100,7 +100,7 @@ void BKE_armature_where_is(struct bArmature *arm);
void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion);
void BKE_pose_clear_pointers(struct bPose *pose);
void BKE_pose_remap_bone_pointers(struct bArmature *armature, struct bPose *pose);
-void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm);
+void BKE_pose_rebuild(struct Main *bmain, struct Object *ob, struct bArmature *arm);
void BKE_pose_where_is(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_pose_where_is_bone(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 9fa00e7f63f..9f57859d318 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -157,7 +157,7 @@ struct SpaceLink *CTX_wm_space_data(const bContext *C);
struct ARegion *CTX_wm_region(const bContext *C);
void *CTX_wm_region_data(const bContext *C);
struct ARegion *CTX_wm_menu(const bContext *C);
-struct wmManipulatorGroup *CTX_wm_manipulator_group(const bContext *C);
+struct wmGizmoGroup *CTX_wm_gizmo_group(const bContext *C);
struct wmMsgBus *CTX_wm_message_bus(const bContext *C);
struct ReportList *CTX_wm_reports(const bContext *C);
@@ -185,7 +185,7 @@ void CTX_wm_screen_set(bContext *C, struct bScreen *screen); /* to be removed */
void CTX_wm_area_set(bContext *C, struct ScrArea *sa);
void CTX_wm_region_set(bContext *C, struct ARegion *region);
void CTX_wm_menu_set(bContext *C, struct ARegion *menu);
-void CTX_wm_manipulator_group_set(bContext *C, struct wmManipulatorGroup *mgroup);
+void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup);
const char *CTX_wm_operator_poll_msg_get(struct bContext *C);
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg);
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 82afbdefeab..7497a9f04e3 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -179,12 +179,12 @@ enum {
/* On write, make backup `.blend1`, `.blend2` ... files, when the users preference is enabled */
#define G_FILE_HISTORY (1 << 25)
/* BMesh option to save as older mesh format */
-#define G_FILE_MESH_COMPAT (1 << 26)
+// #define G_FILE_MESH_COMPAT (1 << 26)
/* On write, restore paths after editing them (G_FILE_RELATIVE_REMAP) */
#define G_FILE_SAVE_COPY (1 << 27)
#define G_FILE_GLSL_NO_ENV_LIGHTING (1 << 28)
-#define G_FILE_FLAGS_RUNTIME (G_FILE_NO_UI | G_FILE_RELATIVE_REMAP | G_FILE_MESH_COMPAT | G_FILE_SAVE_COPY)
+#define G_FILE_FLAGS_RUNTIME (G_FILE_NO_UI | G_FILE_RELATIVE_REMAP | G_FILE_SAVE_COPY)
/* ENDIAN_ORDER: indicates what endianness the platform where the file was
* written had. */
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 060ed4536a4..a41d9582add 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -114,8 +114,6 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struc
struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]);
struct anim *openanim_noload(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]);
-void BKE_image_de_interlace(struct Image *ima, int odd);
-
void BKE_image_make_local(struct Main *bmain, struct Image *ima, const bool lib_local);
void BKE_image_tag_time(struct Image *ima);
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 9e89033894d..db0e5f21284 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -58,7 +58,7 @@ struct WorkSpace;
struct ViewLayer *BKE_view_layer_default_view(const struct Scene *scene);
struct ViewLayer *BKE_view_layer_default_render(const struct Scene *scene);
-struct ViewLayer *BKE_view_layer_from_workspace_get(const struct Scene *scene, const struct WorkSpace *workspace);
+struct ViewLayer *BKE_view_layer_find(const struct Scene *scene, const char *layer_name);
struct ViewLayer *BKE_view_layer_add(struct Scene *scene, const char *name);
/* DEPRECATED */
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index a577b5e4ae3..66b0b550744 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -204,6 +204,7 @@ int BKE_mesh_mselect_active_get(struct Mesh *me, int type);
void BKE_mesh_mselect_active_set(struct Mesh *me, int index, int type);
void BKE_mesh_apply_vert_coords(struct Mesh *mesh, float (*vertCoords)[3]);
+void BKE_mesh_apply_vert_normals(struct Mesh *mesh, short (*vertNormals)[3]);
/* *** mesh_evaluate.c *** */
@@ -395,9 +396,6 @@ void BKE_mesh_recalc_looptri(
const struct MVert *mvert,
int totloop, int totpoly,
struct MLoopTri *mlooptri);
-int BKE_mesh_mpoly_to_mface(
- struct CustomData *fdata, struct CustomData *ldata,
- struct CustomData *pdata, int totface, int totloop, int totpoly);
void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh);
void BKE_mesh_do_versions_convert_mfaces_to_mpolys(struct Mesh *mesh);
void BKE_mesh_convert_mfaces_to_mpolys_ex(
diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h
index b5b5443574c..1005a50a214 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -50,8 +50,12 @@ typedef struct UvVertMap {
typedef struct UvMapVert {
struct UvMapVert *next;
- unsigned int f;
- unsigned char tfindex, separate, flag;
+ unsigned int poly_index;
+ unsigned short loop_of_poly_index;
+ bool separate;
+ /* Zero-ed by map creation, left for use by specific areas. Is not
+ * initialized to anything. */
+ unsigned char flag;
} UvMapVert;
/* UvElement stores per uv information so that we can quickly access information for a uv.
@@ -63,9 +67,9 @@ typedef struct UvElement {
/* Face the element belongs to */
struct BMLoop *l;
/* index in loop. */
- unsigned short tfindex;
+ unsigned short loop_of_poly_index;
/* Whether this element is the first of coincident elements */
- unsigned char separate;
+ bool separate;
/* general use flag */
unsigned char flag;
/* If generating element map with island sorting, this stores the island index */
@@ -100,9 +104,9 @@ typedef struct MeshElemMap {
/* mapping */
UvVertMap *BKE_mesh_uv_vert_map_create(
- struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv,
- unsigned int totpoly, unsigned int totvert,
- const float limit[2], const bool selected, const bool use_winding);
+ const struct MPoly *mpoly, const struct MLoop *mloop, const struct MLoopUV *mloopuv,
+ unsigned int totpoly, unsigned int totvert, const float limit[2],
+ const bool selected, const bool use_winding);
UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v);
void BKE_mesh_uv_vert_map_free(UvVertMap *vmap);
diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h
index f894f72e648..e673a30c0b3 100644
--- a/source/blender/blenkernel/BKE_mesh_runtime.h
+++ b/source/blender/blenkernel/BKE_mesh_runtime.h
@@ -85,6 +85,24 @@ struct Mesh *mesh_get_eval_deform(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, CustomDataMask dataMask);
+#ifdef USE_DERIVEDMESH
+struct DerivedMesh *mesh_create_derived_index_render(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask, int index);
+#endif
+struct Mesh *mesh_create_eval_final_index_render(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask, int index);
+
+#ifdef USE_DERIVEDMESH
+struct DerivedMesh *mesh_create_derived_view(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
+#endif
+struct Mesh *mesh_create_eval_final_view(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
+
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb);
/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index c9f724a9bc4..d0b9d2adc5b 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -162,8 +162,10 @@ typedef struct ModifierTypeInfo {
/* Copy instance data for this modifier type. Should copy all user
* level settings to the target modifier.
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
*/
- void (*copyData)(const struct ModifierData *md, struct ModifierData *target);
+ void (*copyData)(const struct ModifierData *md, struct ModifierData *target, const int flag);
/********************* Deform modifier functions *********************/ /* DEPRECATED */
@@ -315,7 +317,7 @@ typedef struct ModifierTypeInfo {
*
* This function is optional (assumes never disabled if not present).
*/
- bool (*isDisabled)(const struct Scene *scene, struct ModifierData *md, int userRenderParams);
+ bool (*isDisabled)(const struct Scene *scene, struct ModifierData *md, bool userRenderParams);
/* Add the appropriate relations to the dependency graph.
*
@@ -387,7 +389,7 @@ void modifier_free(struct ModifierData *md);
bool modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md);
-void modifier_copyData_generic(const struct ModifierData *md, struct ModifierData *target);
+void modifier_copyData_generic(const struct ModifierData *md, struct ModifierData *target, const int flag);
void modifier_copyData(struct ModifierData *md, struct ModifierData *target);
void modifier_copyData_ex(struct ModifierData *md, struct ModifierData *target, const int flag);
bool modifier_dependsOnTime(struct ModifierData *md);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 1578176d465..cf55885a5ef 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -152,7 +152,7 @@ typedef struct bNodeType {
float width, minwidth, maxwidth;
float height, minheight, maxheight;
- short nclass, flag, compatibility;
+ short nclass, flag;
/* templates for static sockets */
bNodeSocketTemplate *inputs, *outputs;
@@ -251,11 +251,6 @@ typedef struct bNodeType {
#define NODE_CLASS_SHADER 40
#define NODE_CLASS_LAYOUT 100
-/* nodetype->compatibility */
-#define NODE_OLD_SHADING (1 << 0)
-#define NODE_NEW_SHADING (1 << 1)
-#define NODE_NEWER_SHADING (1 << 2)
-
/* node resize directions */
#define NODE_RESIZE_TOP 1
#define NODE_RESIZE_BOTTOM 2
@@ -601,7 +596,6 @@ void node_type_update(struct bNodeType *ntype,
void node_type_exec(struct bNodeType *ntype, NodeInitExecFunction initexecfunc, NodeFreeExecFunction freeexecfunc, NodeExecFunction execfunc);
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpufunc);
void node_type_internal_links(struct bNodeType *ntype, void (*update_internal_links)(struct bNodeTree *, struct bNode *));
-void node_type_compatibility(struct bNodeType *ntype, short compatibility);
/** \} */
@@ -734,7 +728,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, c
#define SH_NODE_OUTPUT_MATERIAL 124
#define SH_NODE_OUTPUT_WORLD 125
-#define SH_NODE_OUTPUT_LAMP 126
+#define SH_NODE_OUTPUT_LIGHT 126
#define SH_NODE_FRESNEL 127
#define SH_NODE_MIX_SHADER 128
#define SH_NODE_ATTRIBUTE 129
@@ -802,6 +796,8 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, c
#define SH_NODE_DISPLACEMENT 198
#define SH_NODE_VECTOR_DISPLACEMENT 199
#define SH_NODE_VOLUME_PRINCIPLED 200
+/* 201..700 occupied by other node types, continue from 701 */
+#define SH_NODE_BSDF_HAIR_PRINCIPLED 701
/* custom defines options for Material node */
#define SH_NODE_MAT_DIFF 1
@@ -813,9 +809,10 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, c
struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree);
void ntreeShaderEndExecTree(struct bNodeTreeExec *exec);
bool ntreeShaderExecTree(struct bNodeTree *ntree, int thread);
+struct bNode *ntreeShaderOutputNode(struct bNodeTree *ntree, int target);
-void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat, short compatibility);
-void ntreeGPUMaterialDomain(struct bNodeTree *ntree, bool *has_surface_output, bool *has_volume_output);
+void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat,
+ bool *has_surface_output, bool *has_volume_output);
/** \} */
@@ -949,6 +946,7 @@ void ntreeGPUMaterialDomain(struct bNodeTree *ntree, bool *has_surfac
#define CMP_NODE_PLANETRACKDEFORM 320
#define CMP_NODE_CORNERPIN 321
#define CMP_NODE_SWITCH_VIEW 322
+#define CMP_NODE_CRYPTOMATTE 323
/* channel toggles */
#define CMP_CHAN_RGB 1
@@ -1001,6 +999,11 @@ void ntreeCompositOutputFileUniqueLayer(struct ListBase *list, struct bNodeSocke
void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *ntree, bNode *node);
void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *ntree, bNode *node);
+void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *ntree, bNode *node);
+void ntreeCompositCryptomatteSyncFromRemove(bNodeTree *ntree, bNode *node);
+struct bNodeSocket *ntreeCompositCryptomatteAddSocket(struct bNodeTree *ntree, struct bNode *node);
+int ntreeCompositCryptomatteRemoveSocket(struct bNodeTree *ntree, struct bNode *node);
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index a54b244f5fd..79e4f1d448a 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -56,10 +56,9 @@ void BKE_object_workob_clear(struct Object *workob);
void BKE_object_workob_calc_parent(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct Object *workob);
void BKE_object_transform_copy(struct Object *ob_tar, const struct Object *ob_src);
-struct SoftBody *copy_softbody(const struct SoftBody *sb, const int flag);
+void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src, const int flag);
struct ParticleSystem *BKE_object_copy_particlesystem(struct ParticleSystem *psys, const int flag);
void BKE_object_copy_particlesystems(struct Object *ob_dst, const struct Object *ob_src, const int flag);
-void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src);
void BKE_object_free_particlesystems(struct Object *ob);
void BKE_object_free_softbody(struct Object *ob);
void BKE_object_free_curve_cache(struct Object *ob);
@@ -76,7 +75,7 @@ bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifie
void BKE_object_link_modifiers(struct Scene *scene, struct Object *ob_dst, const struct Object *ob_src);
void BKE_object_free_modifiers(struct Object *ob, const int flag);
-void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
+void BKE_object_make_proxy(struct Main *bmain, struct Object *ob, struct Object *target, struct Object *gob);
void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
bool BKE_object_exists_check(struct Main *bmain, const struct Object *obtest);
diff --git a/source/blender/blenkernel/BKE_ocean.h b/source/blender/blenkernel/BKE_ocean.h
index 3ea104e656a..e18a063ff52 100644
--- a/source/blender/blenkernel/BKE_ocean.h
+++ b/source/blender/blenkernel/BKE_ocean.h
@@ -31,6 +31,8 @@
extern "C" {
#endif
+struct OceanModifierData;
+
typedef struct OceanResult {
float disp[3];
float normal[3];
@@ -72,6 +74,8 @@ typedef struct OceanCache {
struct Ocean *BKE_ocean_add(void);
void BKE_ocean_free_data(struct Ocean *oc);
void BKE_ocean_free(struct Ocean *oc);
+bool BKE_ocean_ensure(struct OceanModifierData *omd);
+void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd);
void BKE_ocean_init(
struct Ocean *o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp,
@@ -99,6 +103,8 @@ void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, in
void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j);
void BKE_ocean_free_cache(struct OceanCache *och);
+void BKE_ocean_free_modifier_cache(struct OceanModifierData *omd);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 78c766f6115..095f442ca50 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -30,7 +30,7 @@
#include "BLI_ghash.h"
#include "BLI_utildefines.h"
-struct Gwn_Batch;
+struct GPUBatch;
struct CCGElem;
struct CCGKey;
struct CCGDerivedMesh;
@@ -131,7 +131,7 @@ bool BKE_pbvh_node_find_nearest_to_ray(
void BKE_pbvh_draw_cb(
PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast,
- void (*draw_fn)(void *user_data, struct Gwn_Batch *batch), void *user_data);
+ void (*draw_fn)(void *user_data, struct GPUBatch *batch), void *user_data);
/* PBVH Access */
typedef enum {
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 270ab60c02b..adccfda8e25 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -156,6 +156,7 @@ bool BKE_scene_use_shading_nodes_custom(struct Scene *scene);
bool BKE_scene_use_spherical_stereo(struct Scene *scene);
bool BKE_scene_uses_blender_eevee(const struct Scene *scene);
+bool BKE_scene_uses_blender_opengl(const struct Scene *scene);
bool BKE_scene_uses_cycles(const struct Scene *scene);
void BKE_scene_disable_color_management(struct Scene *scene);
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 861b47aebc6..c74170becb4 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -45,13 +45,14 @@ struct ScrVert;
struct SpaceType;
struct TransformOrientation;
struct View3D;
+struct View3DShading;
struct bContext;
struct bContextDataResult;
struct bScreen;
struct uiLayout;
struct uiList;
struct wmKeyConfig;
-struct wmManipulatorMap;
+struct wmGizmoMap;
struct wmNotifier;
struct wmWindow;
struct wmWindowManager;
@@ -88,9 +89,8 @@ typedef struct SpaceType {
/* exit is called when the area is hidden or removed */
void (*exit)(struct wmWindowManager *wm, struct ScrArea *sa);
/* Listeners can react to bContext changes */
- void (*listener)(struct bScreen *sc, struct ScrArea *sa,
- struct wmNotifier *wmn, struct Scene *scene,
- struct WorkSpace *workspace);
+ void (*listener)(struct wmWindow *win, struct ScrArea *sa,
+ struct wmNotifier *wmn, struct Scene *scene);
/* refresh context, called after filereads, ED_area_tag_refresh() */
void (*refresh)(const struct bContext *C, struct ScrArea *sa);
@@ -105,8 +105,8 @@ typedef struct SpaceType {
/* on startup, define dropboxes for spacetype+regions */
void (*dropboxes)(void);
- /* initialize manipulator-map-types and manipulator-group-types with the region */
- void (*manipulators)(void);
+ /* initialize gizmo-map-types and gizmo-group-types with the region */
+ void (*gizmos)(void);
/* return context data */
int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result);
@@ -146,7 +146,7 @@ typedef struct ARegionType {
/* snap the size of the region (can be NULL for no snapping). */
int (*snap_size)(const struct ARegion *ar, int size, int axis);
/* contextual changes should be handled here */
- void (*listener)(struct bScreen *sc, struct ScrArea *sa, struct ARegion *ar,
+ void (*listener)(struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar,
struct wmNotifier *wmn, const struct Scene *scene);
/* Optional callback to generate subscriptions. */
void (*message_subscribe)(
@@ -204,8 +204,10 @@ typedef struct PanelType {
char category[BKE_ST_MAXNAME]; /* for category tabs */
char owner_id[BKE_ST_MAXNAME]; /* for work-spaces to selectively show. */
char parent_id[BKE_ST_MAXNAME]; /* parent idname for subpanels */
- int space_type;
- int region_type;
+ short space_type;
+ short region_type;
+ /* For popovers, 0 for default. */
+ int ui_units_x;
int flag;
@@ -324,9 +326,9 @@ void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID
struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
void BKE_screen_area_free(struct ScrArea *sa);
-/* Manipulator-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */
-void BKE_region_callback_free_manipulatormap_set(void (*callback)(struct wmManipulatorMap *));
-void BKE_region_callback_refresh_tag_manipulatormap_set(void (*callback)(struct wmManipulatorMap *));
+/* Gizmo-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */
+void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *));
+void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *));
struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
@@ -343,7 +345,7 @@ unsigned int BKE_screen_view3d_layer_active(
unsigned int BKE_screen_view3d_layer_all(const struct bScreen *sc) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-void BKE_screen_manipulator_tag_refresh(struct bScreen *sc);
+void BKE_screen_gizmo_tag_refresh(struct bScreen *sc);
void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
void BKE_screen_view3d_scene_sync(struct bScreen *sc, struct Scene *scene);
@@ -354,6 +356,8 @@ bool BKE_screen_is_used(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT AT
float BKE_screen_view3d_zoom_to_fac(float camzoom);
float BKE_screen_view3d_zoom_from_fac(float zoomfac);
+void BKE_screen_view3d_shading_init(struct View3DShading *shading);
+
/* screen */
void BKE_screen_free(struct bScreen *sc);
void BKE_screen_area_map_free(struct ScrAreaMap *area_map) ATTR_NONNULL();
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index ff9d079c8e1..b173c995727 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -54,7 +54,7 @@ typedef struct BodyPoint {
extern struct SoftBody *sbNew(struct Scene *scene);
/* frees internal data and softbody itself */
-extern void sbFree(struct SoftBody *sb);
+extern void sbFree(struct Object *ob);
/* frees simulation data to reset simulation */
extern void sbFreeSimulation(struct SoftBody *sb);
diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h
index f8a9498724e..fee01fa8abb 100644
--- a/source/blender/blenkernel/BKE_studiolight.h
+++ b/source/blender/blenkernel/BKE_studiolight.h
@@ -103,7 +103,7 @@ enum StudioLightFlag {
#define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE)
#define STUDIOLIGHT_FLAG_ORIENTATIONS (STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_VIEWNORMAL)
-#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_WORLD)
+#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_ORIENTATION_WORLD)
#define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD)
typedef void StudioLightFreeFunction(struct StudioLight *, void *data);
diff --git a/source/blender/blenkernel/BKE_subdiv.h b/source/blender/blenkernel/BKE_subdiv.h
new file mode 100644
index 00000000000..a1792866255
--- /dev/null
+++ b/source/blender/blenkernel/BKE_subdiv.h
@@ -0,0 +1,230 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BKE_SUBDIV_H__
+#define __BKE_SUBDIV_H__
+
+#include "BLI_sys_types.h"
+
+struct Mesh;
+struct OpenSubdiv_Converter;
+struct OpenSubdiv_Evaluator;
+struct OpenSubdiv_TopologyRefiner;
+
+/** \file BKE_subdiv.h
+ * \ingroup bke
+ * \since July 2018
+ * \author Sergey Sharybin
+ */
+
+typedef enum {
+ SUBDIV_FVAR_LINEAR_INTERPOLATION_NONE,
+ SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY,
+ SUBDIV_FVAR_LINEAR_INTERPOLATION_BOUNDARIES,
+ SUBDIV_FVAR_LINEAR_INTERPOLATION_ALL,
+} eSubdivFVarLinearInterpolation;
+
+typedef struct SubdivSettings {
+ bool is_simple;
+ bool is_adaptive;
+ int level;
+ eSubdivFVarLinearInterpolation fvar_linear_interpolation;
+} SubdivSettings;
+
+/* NOTE: Order of enumerators MUST match order of values in SubdivStats. */
+typedef enum eSubdivStatsValue {
+ SUBDIV_STATS_TOPOLOGY_REFINER_CREATION_TIME = 0,
+ SUBDIV_STATS_SUBDIV_TO_MESH,
+ SUBDIV_STATS_EVALUATOR_CREATE,
+ SUBDIV_STATS_EVALUATOR_REFINE,
+
+ NUM_SUBDIV_STATS_VALUES,
+} eSubdivStatsValue;
+
+typedef struct SubdivStats {
+ union {
+ struct {
+ /* Time spend on creating topology refiner, which includes time
+ * spend on conversion from Blender data to OpenSubdiv data, and
+ * time spend on topology orientation on OpenSubdiv C-API side.
+ */
+ double topology_refiner_creation_time;
+ /* Total time spent in BKE_subdiv_to_mesh(). */
+ double subdiv_to_mesh_time;
+ /* Time spent on evaluator creation from topology refiner. */
+ double evaluator_creation_time;
+ /* Time spent on evaluator->refine(). */
+ double evaluator_refine_time;
+ };
+ double values_[NUM_SUBDIV_STATS_VALUES];
+ };
+
+ /* Per-value timestamp on when corresponding BKE_subdiv_stats_begin() was
+ * called.
+ */
+ double begin_timestamp_[NUM_SUBDIV_STATS_VALUES];
+} SubdivStats;
+
+typedef struct Subdiv {
+ /* Settings this subdivision surface is created for.
+ *
+ * It is read-only after assignment in BKE_subdiv_new_from_FOO().
+ */
+ SubdivSettings settings;
+
+ /* Total number of ptex faces on subdivision level 0.
+ *
+ * Ptex face is what is internally used by OpenSubdiv for evaluator. It is
+ * a quad face, which corresponds to Blender's legacy Catmull Clark grids.
+ *
+ * Basically, here is a correspondence between polygons and ptex faces:
+ * - Triangle consists of 3 PTex faces.
+ * - Quad is a single PTex face.
+ * - N-gon is N PTex faces.
+ *
+ * This value is initialized in BKE_subdiv_new_from_FOO() and is read-only
+ * after this.
+ */
+ int num_ptex_faces;
+
+ /* Indexed by base face index, element indicates total number of ptex faces
+ * created for preceding base faces.
+ */
+ int *face_ptex_offset;
+
+ /* Topology refiner includes all the glue logic to feed Blender side
+ * topology to OpenSubdiv. It can be shared by both evaluator and GL mesh
+ * drawer.
+ */
+ struct OpenSubdiv_TopologyRefiner *topology_refiner;
+
+ /* CPU side evaluator. */
+ struct OpenSubdiv_Evaluator *evaluator;
+
+ SubdivStats stats;
+} Subdiv;
+
+/* =============================== STATISTICS =============================== */
+
+void BKE_subdiv_stats_init(SubdivStats *stats);
+
+void BKE_subdiv_stats_begin(SubdivStats *stats, eSubdivStatsValue value);
+void BKE_subdiv_stats_end(SubdivStats *stats, eSubdivStatsValue value);
+
+void BKE_subdiv_stats_print(const SubdivStats *stats);
+
+/* ============================== CONSTRUCTION ============================== */
+
+Subdiv *BKE_subdiv_new_from_converter(const SubdivSettings *settings,
+ struct OpenSubdiv_Converter *converter);
+
+Subdiv *BKE_subdiv_new_from_mesh(const SubdivSettings *settings,
+ struct Mesh *mesh);
+
+void BKE_subdiv_free(Subdiv *subdiv);
+
+/* ============================= EVALUATION API ============================= */
+
+void BKE_subdiv_eval_begin(Subdiv *subdiv);
+void BKE_subdiv_eval_update_from_mesh(Subdiv *subdiv, const struct Mesh *mesh);
+
+/* Single point queries. */
+
+void BKE_subdiv_eval_limit_point(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float P[3]);
+void BKE_subdiv_eval_limit_point_and_derivatives(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float P[3], float dPdu[3], float dPdv[3]);
+void BKE_subdiv_eval_limit_point_and_normal(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float P[3], float N[3]);
+void BKE_subdiv_eval_limit_point_and_short_normal(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float P[3], short N[3]);
+
+void BKE_subdiv_eval_face_varying(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float varying[2]);
+
+/* Patch queries at given resolution.
+ *
+ * Will evaluate patch at uniformly distributed (u, v) coordinates on a grid
+ * of given resolution, producing resolution^2 evaluation points. The order
+ * goes as u in rows, v in columns.
+ */
+
+void BKE_subdiv_eval_limit_patch_resolution_point(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const int resolution,
+ void *buffer, const int offset, const int stride);
+void BKE_subdiv_eval_limit_patch_resolution_point_and_derivatives(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const int resolution,
+ void *point_buffer, const int point_offset, const int point_stride,
+ void *du_buffer, const int du_offset, const int du_stride,
+ void *dv_buffer, const int dv_offset, const int dv_stride);
+void BKE_subdiv_eval_limit_patch_resolution_point_and_normal(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const int resolution,
+ void *point_buffer, const int point_offset, const int point_stride,
+ void *normal_buffer, const int normal_offset, const int normal_stride);
+void BKE_subdiv_eval_limit_patch_resolution_point_and_short_normal(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const int resolution,
+ void *point_buffer, const int point_offset, const int point_stride,
+ void *normal_buffer, const int normal_offset, const int normal_stride);
+
+/* =========================== SUBDIV TO MESH API =========================== */
+
+typedef struct SubdivToMeshSettings {
+ /* Resolution at which ptex are being evaluated.
+ * This defines how many vertices final mesh will have: every ptex has
+ * resolution^2 vertices.
+ */
+ int resolution;
+} SubdivToMeshSettings;
+
+/* Create real hi-res mesh from subdivision, all geometry is "real". */
+struct Mesh *BKE_subdiv_to_mesh(
+ Subdiv *subdiv,
+ const SubdivToMeshSettings *settings,
+ const struct Mesh *coarse_mesh);
+
+#endif /* __BKE_SUBDIV_H__ */
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 03d24ac53d1..4f4ae9f375b 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -54,23 +54,11 @@ void BKE_workspace_layout_remove(
void BKE_workspace_relations_free(
ListBase *relation_list);
-void BKE_workspace_scene_relations_free_invalid(
- struct WorkSpace *workspace);
/* -------------------------------------------------------------------- */
/* General Utils */
-void BKE_workspace_view_layer_rename(
- const struct Main *bmain,
- const struct Scene *scene,
- const char *old_name,
- const char *new_name) ATTR_NONNULL();
-
-void BKE_workspace_view_layer_remove(
- const struct Main *bmain,
- const struct ViewLayer *view_layer) ATTR_NONNULL();
-
struct WorkSpaceLayout *BKE_workspace_layout_find(
const struct WorkSpace *workspace, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
struct WorkSpaceLayout *BKE_workspace_layout_find_global(
@@ -97,17 +85,6 @@ struct bScreen *BKE_workspace_active_screen_get(const struct WorkSpaceInstanceHo
void BKE_workspace_active_screen_set(
struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct bScreen *screen) SETTER_ATTRS;
-struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace, const struct Scene *scene);
-struct ViewLayer *BKE_workspace_view_layer_get(
- const struct WorkSpace *workspace,
- const struct Scene *scene) GETTER_ATTRS;
-struct ViewLayer *BKE_workspace_view_layer_exists(
- const struct WorkSpace *workspace,
- const struct Scene *scene) GETTER_ATTRS;
-void BKE_workspace_view_layer_set(
- struct WorkSpace *workspace,
- struct ViewLayer *layer,
- struct Scene *scene) SETTER_ATTRS;
struct ListBase *BKE_workspace_layouts_get(struct WorkSpace *workspace) GETTER_ATTRS;
const char *BKE_workspace_layout_name_get(const struct WorkSpaceLayout *layout) GETTER_ATTRS;
@@ -121,11 +98,6 @@ struct WorkSpaceLayout *BKE_workspace_hook_layout_for_workspace_get(
void BKE_workspace_hook_layout_for_workspace_set(
struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL();
-/* Update / evaluate */
-void BKE_workspace_update_tagged(struct Main *bmain,
- struct WorkSpace *workspace,
- struct Scene *scene);
-
bool BKE_workspace_owner_id_check(
const struct WorkSpace *workspace, const char *owner_id) ATTR_NONNULL();
diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h
index f703fefec97..6a9a75828e5 100644
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@ -44,10 +44,4 @@ struct World *BKE_world_copy(struct Main *bmain, const struct World *wrld);
struct World *BKE_world_localize(struct World *wrld);
void BKE_world_make_local(struct Main *bmain, struct World *wrld, const bool lib_local);
-/* Evaluation. */
-
-struct Depsgraph;
-
-void BKE_world_eval(struct Depsgraph *depsgraph, struct World *world);
-
#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index d2654e32fa7..01910bffdb0 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -186,6 +186,12 @@ set(SRC
intern/sound.c
intern/speaker.c
intern/studiolight.c
+ intern/subdiv.c
+ intern/subdiv_converter.c
+ intern/subdiv_converter_mesh.c
+ intern/subdiv_eval.c
+ intern/subdiv_mesh.c
+ intern/subdiv_stats.c
intern/subsurf_ccg.c
intern/suggestions.c
intern/text.c
@@ -276,6 +282,7 @@ set(SRC
BKE_mesh_iterators.h
BKE_mesh_mapping.h
BKE_mesh_remap.h
+ BKE_mesh_runtime.h
BKE_mesh_tangent.h
BKE_modifier.h
BKE_movieclip.h
@@ -305,6 +312,7 @@ set(SRC
BKE_sound.h
BKE_speaker.h
BKE_studiolight.h
+ BKE_subdiv.h
BKE_subsurf.h
BKE_suggestions.h
BKE_text.h
@@ -322,8 +330,9 @@ set(SRC
intern/CCGSubSurf.h
intern/CCGSubSurf_inline.h
intern/CCGSubSurf_intern.h
- intern/pbvh_intern.h
intern/data_transfer_intern.h
+ intern/pbvh_intern.h
+ intern/subdiv_converter.h
)
if(WITH_BINRELOC)
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 81b1afa3621..dd5a87a445d 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -40,6 +40,8 @@
#ifdef WITH_OPENSUBDIV
# include "opensubdiv_capi.h"
# include "opensubdiv_converter_capi.h"
+# include "opensubdiv_evaluator_capi.h"
+# include "opensubdiv_topology_refiner_capi.h"
#endif
#include "GPU_glew.h"
@@ -329,7 +331,7 @@ void ccgSubSurf_free(CCGSubSurf *ss)
CCGAllocatorHDL allocator = ss->allocator;
#ifdef WITH_OPENSUBDIV
if (ss->osd_evaluator != NULL) {
- openSubdiv_deleteEvaluatorDescr(ss->osd_evaluator);
+ openSubdiv_deleteEvaluator(ss->osd_evaluator);
}
if (ss->osd_mesh != NULL) {
ccgSubSurf__delete_osdGLMesh(ss->osd_mesh);
@@ -341,7 +343,7 @@ void ccgSubSurf_free(CCGSubSurf *ss)
MEM_freeN(ss->osd_coarse_coords);
}
if (ss->osd_topology_refiner != NULL) {
- openSubdiv_deleteTopologyRefinerDescr(ss->osd_topology_refiner);
+ openSubdiv_deleteTopologyRefiner(ss->osd_topology_refiner);
}
#endif
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_intern.h b/source/blender/blenkernel/intern/CCGSubSurf_intern.h
index 9df1c9021ef..29e327d8973 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_intern.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf_intern.h
@@ -236,7 +236,7 @@ struct CCGSubSurf {
* Refiner is created from the modifier stack and used later from the main
* thread to construct GL mesh to avoid threaded access to GL.
*/
- struct OpenSubdiv_TopologyRefinerDescr *osd_topology_refiner; /* Only used at synchronization stage. */
+ struct OpenSubdiv_TopologyRefiner *osd_topology_refiner; /* Only used at synchronization stage. */
/* Denotes whether osd_mesh is invalid now due to topology changes and needs
* to be reconstructed.
*
@@ -249,7 +249,7 @@ struct CCGSubSurf {
/* ** CPU backend. ** */
/* Limit evaluator, used to evaluate CCG. */
- struct OpenSubdiv_EvaluatorDescr *osd_evaluator;
+ struct OpenSubdiv_Evaluator *osd_evaluator;
/* Next PTex face index, used while CCG synchronization
* to fill in PTex index of CCGFace.
*/
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
index fc4220277eb..98a17ad8009 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
@@ -42,6 +42,9 @@
#include "opensubdiv_capi.h"
#include "opensubdiv_converter_capi.h"
+#include "opensubdiv_evaluator_capi.h"
+#include "opensubdiv_gl_mesh_capi.h"
+#include "opensubdiv_topology_refiner_capi.h"
#include "GPU_glew.h"
#include "GPU_extensions.h"
@@ -131,7 +134,6 @@ static bool compare_ccg_derivedmesh_topology(CCGSubSurf *ss, DerivedMesh *dm)
static bool compare_osd_derivedmesh_topology(CCGSubSurf *ss, DerivedMesh *dm)
{
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner;
OpenSubdiv_Converter converter;
bool result;
if (ss->osd_mesh == NULL && ss->osd_topology_refiner == NULL) {
@@ -140,15 +142,10 @@ static bool compare_osd_derivedmesh_topology(CCGSubSurf *ss, DerivedMesh *dm)
/* TODO(sergey): De-duplicate with topology counter at the bottom of
* the file.
*/
- if (ss->osd_topology_refiner != NULL) {
- topology_refiner = ss->osd_topology_refiner;
- }
- else {
- topology_refiner = openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh);
- }
ccgSubSurf_converter_setup_from_derivedmesh(ss, dm, &converter);
- result = openSubdiv_topologyRefnerCompareConverter(topology_refiner,
- &converter);
+ result = openSubdiv_topologyRefinerCompareWithConverter(
+ ss->osd_topology_refiner,
+ &converter);
ccgSubSurf_converter_free(&converter);
return result;
}
@@ -159,22 +156,13 @@ static bool opensubdiv_is_topology_changed(CCGSubSurf *ss, DerivedMesh *dm)
return true;
}
if (ss->osd_topology_refiner != NULL) {
- int levels = openSubdiv_topologyRefinerGetSubdivLevel(
+ const int levels = ss->osd_topology_refiner->getSubdivisionLevel(
ss->osd_topology_refiner);
BLI_assert(ss->osd_mesh_invalid == true);
if (levels != ss->subdivLevels) {
return true;
}
}
- if (ss->osd_mesh != NULL && ss->osd_mesh_invalid == false) {
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner =
- openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh);
- int levels = openSubdiv_topologyRefinerGetSubdivLevel(topology_refiner);
- BLI_assert(ss->osd_topology_refiner == NULL);
- if (levels != ss->subdivLevels) {
- return true;
- }
- }
if (ss->skip_grids == false) {
return compare_ccg_derivedmesh_topology(ss, dm) == false;
}
@@ -194,13 +182,13 @@ void ccgSubSurf_checkTopologyChanged(CCGSubSurf *ss, DerivedMesh *dm)
/* Reset GPU part. */
ss->osd_mesh_invalid = true;
if (ss->osd_topology_refiner != NULL) {
- openSubdiv_deleteTopologyRefinerDescr(ss->osd_topology_refiner);
+ openSubdiv_deleteTopologyRefiner(ss->osd_topology_refiner);
ss->osd_topology_refiner = NULL;
}
- /* Reste CPU side. */
+ /* Reset CPU side. */
if (ss->osd_evaluator != NULL) {
- openSubdiv_deleteEvaluatorDescr(ss->osd_evaluator);
+ openSubdiv_deleteEvaluator(ss->osd_evaluator);
ss->osd_evaluator = NULL;
}
}
@@ -209,10 +197,10 @@ void ccgSubSurf_checkTopologyChanged(CCGSubSurf *ss, DerivedMesh *dm)
static void ccgSubSurf__updateGLMeshCoords(CCGSubSurf *ss)
{
BLI_assert(ss->meshIFC.numLayers == 3);
- openSubdiv_osdGLMeshUpdateVertexBuffer(ss->osd_mesh,
- (float *) ss->osd_coarse_coords,
- 0,
- ss->osd_num_coarse_coords);
+ ss->osd_mesh->setCoarsePositions(ss->osd_mesh,
+ (float *) ss->osd_coarse_coords,
+ 0,
+ ss->osd_num_coarse_coords);
}
bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss,
@@ -259,9 +247,7 @@ bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss,
ss->osd_mesh = openSubdiv_createOsdGLMeshFromTopologyRefiner(
ss->osd_topology_refiner,
- compute_type,
- ss->subdivLevels);
- ss->osd_topology_refiner = NULL;
+ compute_type);
if (UNLIKELY(ss->osd_mesh == NULL)) {
/* Most likely compute device is not available. */
@@ -269,13 +255,12 @@ bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss,
}
ccgSubSurf__updateGLMeshCoords(ss);
- openSubdiv_osdGLMeshRefine(ss->osd_mesh);
- openSubdiv_osdGLMeshSynchronize(ss->osd_mesh);
+ ss->osd_mesh->refine(ss->osd_mesh);
+ ss->osd_mesh->synchronize(ss->osd_mesh);
ss->osd_coarse_coords_invalid = false;
glBindVertexArray(ss->osd_vao);
- glBindBuffer(GL_ARRAY_BUFFER,
- openSubdiv_getOsdGLMeshVertexBuffer(ss->osd_mesh));
+ ss->osd_mesh->bindVertexBuffer(ss->osd_mesh);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
@@ -289,12 +274,12 @@ bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss,
}
else if (ss->osd_coarse_coords_invalid) {
ccgSubSurf__updateGLMeshCoords(ss);
- openSubdiv_osdGLMeshRefine(ss->osd_mesh);
- openSubdiv_osdGLMeshSynchronize(ss->osd_mesh);
+ ss->osd_mesh->refine(ss->osd_mesh);
+ ss->osd_mesh->synchronize(ss->osd_mesh);
ss->osd_coarse_coords_invalid = false;
}
- openSubdiv_osdGLMeshDisplayPrepare(use_osd_glsl, active_uv_index);
+ ss->osd_mesh->prepareDraw(ss->osd_mesh, use_osd_glsl, active_uv_index);
return true;
}
@@ -305,12 +290,12 @@ void ccgSubSurf_drawGLMesh(CCGSubSurf *ss, bool fill_quads,
if (LIKELY(ss->osd_mesh != NULL)) {
glBindVertexArray(ss->osd_vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
- openSubdiv_getOsdGLMeshPatchIndexBuffer(ss->osd_mesh));
+ ss->osd_mesh->getPatchIndexBuffer(ss->osd_mesh));
- openSubdiv_osdGLMeshBindVertexBuffer(ss->osd_mesh);
+ ss->osd_mesh->bindVertexBuffer(ss->osd_mesh);
glBindVertexArray(ss->osd_vao);
- openSubdiv_osdGLMeshDisplay(ss->osd_mesh, fill_quads,
- start_partition, num_partitions);
+ ss->osd_mesh->drawPatches(ss->osd_mesh, fill_quads,
+ start_partition, num_partitions);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
@@ -319,33 +304,21 @@ void ccgSubSurf_drawGLMesh(CCGSubSurf *ss, bool fill_quads,
int ccgSubSurf_getNumGLMeshBaseFaces(CCGSubSurf *ss)
{
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner;
if (ss->osd_topology_refiner != NULL) {
- topology_refiner = ss->osd_topology_refiner;
- }
- else if (ss->osd_mesh != NULL) {
- topology_refiner = openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh);
- }
- else {
- return 0;
+ return ss->osd_topology_refiner->getNumFaces(
+ ss->osd_topology_refiner);
}
- return openSubdiv_topologyRefinerGetNumFaces(topology_refiner);
+ return 0;
}
/* Get number of vertices in base faces in a particular GL mesh. */
int ccgSubSurf_getNumGLMeshBaseFaceVerts(CCGSubSurf *ss, int face)
{
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner;
if (ss->osd_topology_refiner != NULL) {
- topology_refiner = ss->osd_topology_refiner;
- }
- else if (ss->osd_mesh != NULL) {
- topology_refiner = openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh);
- }
- else {
- return 0;
+ return ss->osd_topology_refiner->getNumFaceVertices(
+ ss->osd_topology_refiner, face);
}
- return openSubdiv_topologyRefinerGetNumFaceVerts(topology_refiner, face);
+ return 0;
}
void ccgSubSurf_setSkipGrids(CCGSubSurf *ss, bool skip_grids)
@@ -453,17 +426,21 @@ void ccgSubSurf_evaluatorFVarUV(CCGSubSurf *ss,
static bool opensubdiv_createEvaluator(CCGSubSurf *ss)
{
OpenSubdiv_Converter converter;
- OpenSubdiv_TopologyRefinerDescr *topology_refiner;
+ OpenSubdiv_TopologyRefiner *topology_refiner;
if (ss->fMap->numEntries == 0) {
/* OpenSubdiv doesn't support meshes without faces. */
return false;
}
ccgSubSurf_converter_setup_from_ccg(ss, &converter);
- topology_refiner = openSubdiv_createTopologyRefinerDescr(&converter);
+ OpenSubdiv_TopologyRefinerSettings settings;
+ settings.level = ss->subdivLevels;
+ settings.is_adaptive = false;
+ topology_refiner =
+ openSubdiv_createTopologyRefinerFromConverter(
+ &converter, &settings);
ccgSubSurf_converter_free(&converter);
ss->osd_evaluator =
- openSubdiv_createEvaluatorDescr(topology_refiner,
- ss->subdivLevels);
+ openSubdiv_createEvaluatorFromTopologyRefiner(topology_refiner);
if (ss->osd_evaluator == NULL) {
BLI_assert(!"OpenSubdiv initialization failed, should not happen.");
return false;
@@ -519,10 +496,11 @@ static void opensubdiv_updateEvaluatorCoarsePositions(CCGSubSurf *ss)
}
}
- openSubdiv_setEvaluatorCoarsePositions(ss->osd_evaluator,
- (float *)positions,
- 0,
- num_basis_verts);
+ ss->osd_evaluator->setCoarsePositions(ss->osd_evaluator,
+ (float *)positions,
+ 0,
+ num_basis_verts);
+ ss->osd_evaluator->refine(ss->osd_evaluator);
MEM_freeN(positions);
}
@@ -557,11 +535,12 @@ static void opensubdiv_evaluateQuadFaceGrids(CCGSubSurf *ss,
ccgSubSurf__mapGridToFace(S, grid_u, grid_v, &face_u, &face_v);
/* TODO(sergey): Need proper port. */
- openSubdiv_evaluateLimit(ss->osd_evaluator, osd_face_index,
- face_u, face_v,
- P,
- do_normals ? dPdu : NULL,
- do_normals ? dPdv : NULL);
+ ss->osd_evaluator->evaluateLimit(
+ ss->osd_evaluator, osd_face_index,
+ face_u, face_v,
+ P,
+ do_normals ? dPdu : NULL,
+ do_normals ? dPdv : NULL);
OSD_LOG("face=%d, corner=%d, grid_u=%f, grid_v=%f, face_u=%f, face_v=%f, P=(%f, %f, %f)\n",
osd_face_index, S, grid_u, grid_v, face_u, face_v, P[0], P[1], P[2]);
@@ -635,7 +614,11 @@ static void opensubdiv_evaluateQuadFaceGrids(CCGSubSurf *ss,
* let's just re-evaluate for simplicity.
*/
/* TODO(sergey): Need proper port. */
- openSubdiv_evaluateLimit(ss->osd_evaluator, osd_face_index, u, v, P, dPdu, dPdv);
+ ss->osd_evaluator->evaluateLimit(
+ ss->osd_evaluator,
+ osd_face_index,
+ u, v,
+ P, dPdu, dPdv);
VertDataCopy(co, P, ss);
if (do_normals) {
cross_v3_v3v3(no, dPdu, dPdv);
@@ -699,7 +682,11 @@ static void opensubdiv_evaluateNGonFaceGrids(CCGSubSurf *ss,
float P[3], dPdu[3], dPdv[3];
/* TODO(sergey): Need proper port. */
- openSubdiv_evaluateLimit(ss->osd_evaluator, osd_face_index + S, u, v, P, dPdu, dPdv);
+ ss->osd_evaluator->evaluateLimit(
+ ss->osd_evaluator,
+ osd_face_index + S,
+ u, v,
+ P, dPdu, dPdv);
OSD_LOG("face=%d, corner=%d, u=%f, v=%f, P=(%f, %f, %f)\n",
osd_face_index + S, S, u, v, P[0], P[1], P[2]);
@@ -837,7 +824,12 @@ void ccgSubSurf_prepareTopologyRefiner(CCGSubSurf *ss, DerivedMesh *dm)
OpenSubdiv_Converter converter;
ccgSubSurf_converter_setup_from_derivedmesh(ss, dm, &converter);
/* TODO(sergey): Remove possibly previously allocated refiner. */
- ss->osd_topology_refiner = openSubdiv_createTopologyRefinerDescr(&converter);
+ OpenSubdiv_TopologyRefinerSettings settings;
+ settings.level = ss->subdivLevels;
+ settings.is_adaptive = false;
+ ss->osd_topology_refiner =
+ openSubdiv_createTopologyRefinerFromConverter(
+ &converter, &settings);
ccgSubSurf_converter_free(&converter);
}
}
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c
index f1f82f458aa..649b7c7fa4c 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c
@@ -84,11 +84,14 @@ static OpenSubdiv_SchemeType conv_dm_get_type(
return OSD_SCHEME_CATMARK;
}
-static bool conv_dm_get_subdiv_uvs(
+static OpenSubdiv_FVarLinearInterpolation conv_dm_get_fvar_linear_interpolation(
const OpenSubdiv_Converter *converter)
{
ConvDMStorage *storage = converter->user_data;
- return (storage->ss->osd_subdiv_uvs);
+ if (storage->ss->osd_subdiv_uvs) {
+ return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY;
+ }
+ return OSD_FVAR_LINEAR_INTERPOLATION_ALL;
}
static int conv_dm_get_num_faces(const OpenSubdiv_Converter *converter)
@@ -386,12 +389,6 @@ static int conv_dm_get_num_uvs(const OpenSubdiv_Converter *converter)
return storage->num_uvs;
}
-static void conv_dm_get_uvs(const OpenSubdiv_Converter *converter, float *uvs)
-{
- ConvDMStorage *storage = converter->user_data;
- memcpy(uvs, storage->uvs, sizeof(float) * 2 * storage->num_uvs);
-}
-
static int conv_dm_get_face_corner_uv_index(const OpenSubdiv_Converter *converter,
int face,
int corner)
@@ -429,34 +426,34 @@ void ccgSubSurf_converter_setup_from_derivedmesh(
{
ConvDMStorage *user_data;
- converter->get_type = conv_dm_get_type;
+ converter->getSchemeType = conv_dm_get_type;
- converter->get_subdiv_uvs = conv_dm_get_subdiv_uvs;
+ converter->getFVarLinearInterpolation =
+ conv_dm_get_fvar_linear_interpolation;
- converter->get_num_faces = conv_dm_get_num_faces;
- converter->get_num_edges = conv_dm_get_num_edges;
- converter->get_num_verts = conv_dm_get_num_verts;
+ converter->getNumFaces = conv_dm_get_num_faces;
+ converter->getNumEdges = conv_dm_get_num_edges;
+ converter->getNumVertices = conv_dm_get_num_verts;
- converter->get_num_face_verts = conv_dm_get_num_face_verts;
- converter->get_face_verts = conv_dm_get_face_verts;
- converter->get_face_edges = conv_dm_get_face_edges;
+ converter->getNumFaceVertices = conv_dm_get_num_face_verts;
+ converter->getFaceVertices = conv_dm_get_face_verts;
+ converter->getFaceEdges = conv_dm_get_face_edges;
- converter->get_edge_verts = conv_dm_get_edge_verts;
- converter->get_num_edge_faces = conv_dm_get_num_edge_faces;
- converter->get_edge_faces = conv_dm_get_edge_faces;
- converter->get_edge_sharpness = conv_dm_get_edge_sharpness;
+ converter->getEdgeVertices = conv_dm_get_edge_verts;
+ converter->getNumEdgeFaces = conv_dm_get_num_edge_faces;
+ converter->getEdgeFaces = conv_dm_get_edge_faces;
+ converter->getEdgeSharpness = conv_dm_get_edge_sharpness;
- converter->get_num_vert_edges = conv_dm_get_num_vert_edges;
- converter->get_vert_edges = conv_dm_get_vert_edges;
- converter->get_num_vert_faces = conv_dm_get_num_vert_faces;
- converter->get_vert_faces = conv_dm_get_vert_faces;
+ converter->getNumVertexEdges = conv_dm_get_num_vert_edges;
+ converter->getVertexEdges = conv_dm_get_vert_edges;
+ converter->getNumVertexFaces = conv_dm_get_num_vert_faces;
+ converter->getVertexFaces = conv_dm_get_vert_faces;
- converter->get_num_uv_layers = conv_dm_get_num_uv_layers;
- converter->precalc_uv_layer = conv_dm_precalc_uv_layer;
- converter->finish_uv_layer = conv_dm_finish_uv_layer;
- converter->get_num_uvs = conv_dm_get_num_uvs;
- converter->get_uvs = conv_dm_get_uvs;
- converter->get_face_corner_uv_index = conv_dm_get_face_corner_uv_index;
+ converter->getNumUVLayers = conv_dm_get_num_uv_layers;
+ converter->precalcUVLayer = conv_dm_precalc_uv_layer;
+ converter->finishUVLayer = conv_dm_finish_uv_layer;
+ converter->getNumUVCoordinates = conv_dm_get_num_uvs;
+ converter->getFaceCornerUVIndex = conv_dm_get_face_corner_uv_index;
user_data = MEM_mallocN(sizeof(ConvDMStorage), __func__);
user_data->ss = ss;
@@ -472,7 +469,7 @@ void ccgSubSurf_converter_setup_from_derivedmesh(
user_data->uvs = NULL;
user_data->face_uvs = NULL;
- converter->free_user_data = conv_dm_free_user_data;
+ converter->freeUserData = conv_dm_free_user_data;
converter->user_data = user_data;
#ifdef USE_MESH_ELEMENT_MAPPING
@@ -526,11 +523,14 @@ static OpenSubdiv_SchemeType conv_ccg_get_bilinear_type(
}
}
-static bool conv_ccg_get_subdiv_uvs(
- const OpenSubdiv_Converter *converter)
+static OpenSubdiv_FVarLinearInterpolation
+conv_ccg_get_fvar_linear_interpolation(const OpenSubdiv_Converter *converter)
{
CCGSubSurf *ss = converter->user_data;
- return (ss->osd_subdiv_uvs);
+ if (ss->osd_subdiv_uvs) {
+ return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY;
+ }
+ return OSD_FVAR_LINEAR_INTERPOLATION_ALL;
}
static int conv_ccg_get_num_faces(const OpenSubdiv_Converter *converter)
@@ -695,11 +695,6 @@ static int conv_ccg_get_num_uvs(const OpenSubdiv_Converter *UNUSED(converter))
return 0;
}
-static void conv_ccg_get_uvs(const OpenSubdiv_Converter * UNUSED(converter),
- float *UNUSED(uvs))
-{
-}
-
static int conv_ccg_get_face_corner_uv_index(const OpenSubdiv_Converter *UNUSED(converter),
int UNUSED(face),
int UNUSED(corner_))
@@ -710,44 +705,44 @@ static int conv_ccg_get_face_corner_uv_index(const OpenSubdiv_Converter *UNUSED(
void ccgSubSurf_converter_setup_from_ccg(CCGSubSurf *ss,
OpenSubdiv_Converter *converter)
{
- converter->get_type = conv_ccg_get_bilinear_type;
+ converter->getSchemeType = conv_ccg_get_bilinear_type;
- converter->get_subdiv_uvs = conv_ccg_get_subdiv_uvs;
+ converter->getFVarLinearInterpolation =
+ conv_ccg_get_fvar_linear_interpolation;
- converter->get_num_faces = conv_ccg_get_num_faces;
- converter->get_num_edges = conv_ccg_get_num_edges;
- converter->get_num_verts = conv_ccg_get_num_verts;
+ converter->getNumFaces = conv_ccg_get_num_faces;
+ converter->getNumEdges = conv_ccg_get_num_edges;
+ converter->getNumVertices = conv_ccg_get_num_verts;
- converter->get_num_face_verts = conv_ccg_get_num_face_verts;
- converter->get_face_verts = conv_ccg_get_face_verts;
- converter->get_face_edges = conv_ccg_get_face_edges;
+ converter->getNumFaceVertices = conv_ccg_get_num_face_verts;
+ converter->getFaceVertices = conv_ccg_get_face_verts;
+ converter->getFaceEdges = conv_ccg_get_face_edges;
- converter->get_edge_verts = conv_ccg_get_edge_verts;
- converter->get_num_edge_faces = conv_ccg_get_num_edge_faces;
- converter->get_edge_faces = conv_ccg_get_edge_faces;
- converter->get_edge_sharpness = conv_ccg_get_edge_sharpness;
+ converter->getEdgeVertices = conv_ccg_get_edge_verts;
+ converter->getNumEdgeFaces = conv_ccg_get_num_edge_faces;
+ converter->getEdgeFaces = conv_ccg_get_edge_faces;
+ converter->getEdgeSharpness = conv_ccg_get_edge_sharpness;
- converter->get_num_vert_edges = conv_ccg_get_num_vert_edges;
- converter->get_vert_edges = conv_ccg_get_vert_edges;
- converter->get_num_vert_faces = conv_ccg_get_num_vert_faces;
- converter->get_vert_faces = conv_ccg_get_vert_faces;
+ converter->getNumVertexEdges = conv_ccg_get_num_vert_edges;
+ converter->getVertexEdges = conv_ccg_get_vert_edges;
+ converter->getNumVertexFaces = conv_ccg_get_num_vert_faces;
+ converter->getVertexFaces = conv_ccg_get_vert_faces;
- converter->get_num_uv_layers = conv_ccg_get_num_uv_layers;
- converter->precalc_uv_layer = conv_ccg_precalc_uv_layer;
- converter->finish_uv_layer = conv_ccg_finish_uv_layer;
- converter->get_num_uvs = conv_ccg_get_num_uvs;
- converter->get_uvs = conv_ccg_get_uvs;
- converter->get_face_corner_uv_index = conv_ccg_get_face_corner_uv_index;
+ converter->getNumUVLayers = conv_ccg_get_num_uv_layers;
+ converter->precalcUVLayer = conv_ccg_precalc_uv_layer;
+ converter->finishUVLayer = conv_ccg_finish_uv_layer;
+ converter->getNumUVCoordinates = conv_ccg_get_num_uvs;
+ converter->getFaceCornerUVIndex = conv_ccg_get_face_corner_uv_index;
- converter->free_user_data = NULL;
+ converter->freeUserData = NULL;
converter->user_data = ss;
}
void ccgSubSurf_converter_free(
struct OpenSubdiv_Converter *converter)
{
- if (converter->free_user_data) {
- converter->free_user_data(converter);
+ if (converter->freeUserData) {
+ converter->freeUserData(converter);
}
}
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 4aee616580e..9c4aae7cda5 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -3156,6 +3156,8 @@ DerivedMesh *mesh_create_derived_render(struct Depsgraph *depsgraph, Scene *scen
return final;
}
+#ifdef USE_DERIVEDMESH
+/* Deprecated, use `mesh_create_eval_final_index_render` instead. */
DerivedMesh *mesh_create_derived_index_render(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask, int index)
{
DerivedMesh *final;
@@ -3166,7 +3168,22 @@ DerivedMesh *mesh_create_derived_index_render(struct Depsgraph *depsgraph, Scene
return final;
}
+#endif
+struct Mesh *mesh_create_eval_final_index_render(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask, int index)
+{
+ Mesh *final;
+
+ mesh_calc_modifiers(
+ depsgraph, scene, ob, NULL, 1, false, dataMask, index, false, false, false,
+ NULL, &final);
+
+ return final;
+}
+#ifdef USE_DERIVEDMESH
+/* Deprecated, use `mesh_create_eval_final_view` instead. */
DerivedMesh *mesh_create_derived_view(
struct Depsgraph *depsgraph, Scene *scene,
Object *ob, CustomDataMask dataMask)
@@ -3187,6 +3204,28 @@ DerivedMesh *mesh_create_derived_view(
return final;
}
+#endif
+
+Mesh *mesh_create_eval_final_view(
+ struct Depsgraph *depsgraph, Scene *scene,
+ Object *ob, CustomDataMask dataMask)
+{
+ Mesh *final;
+
+ /* XXX hack
+ * psys modifier updates particle state when called during dupli-list generation,
+ * which can lead to wrong transforms. This disables particle system modifier execution.
+ */
+ ob->transflag |= OB_NO_PSYS_UPDATE;
+
+ mesh_calc_modifiers(
+ depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false, false,
+ NULL, &final);
+
+ ob->transflag &= ~OB_NO_PSYS_UPDATE;
+
+ return final;
+}
DerivedMesh *mesh_create_derived_no_deform(
struct Depsgraph *depsgraph, Scene *scene, Object *ob,
diff --git a/source/blender/blenkernel/intern/addon.c b/source/blender/blenkernel/intern/addon.c
index a9bb193a7a1..854bf62c061 100644
--- a/source/blender/blenkernel/intern/addon.c
+++ b/source/blender/blenkernel/intern/addon.c
@@ -69,6 +69,17 @@ bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module)
return addon;
}
+bool BKE_addon_remove_safe(ListBase *addon_list, const char *module)
+{
+ bAddon *addon = BLI_findstring(addon_list, module, offsetof(bAddon, module));
+ if (addon) {
+ BLI_remlink(addon_list, addon);
+ BKE_addon_free(addon);
+ return true;
+ }
+ return false;
+}
+
void BKE_addon_free(bAddon *addon)
{
if (addon->prop) {
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 07b8b69bc70..eed8943cd5b 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -114,9 +114,9 @@ void animviz_free_motionpath_cache(bMotionPath *mpath)
if (mpath->points)
MEM_freeN(mpath->points);
- GWN_VERTBUF_DISCARD_SAFE(mpath->points_vbo);
- GWN_BATCH_DISCARD_SAFE(mpath->batch_line);
- GWN_BATCH_DISCARD_SAFE(mpath->batch_points);
+ GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo);
+ GPU_BATCH_DISCARD_SAFE(mpath->batch_line);
+ GPU_BATCH_DISCARD_SAFE(mpath->batch_points);
/* reset the relevant parameters */
mpath->points = NULL;
@@ -495,9 +495,9 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
BLI_dlrbTree_free(&mpt->keys);
/* Free previous batches to force update. */
- GWN_VERTBUF_DISCARD_SAFE(mpath->points_vbo);
- GWN_BATCH_DISCARD_SAFE(mpath->batch_line);
- GWN_BATCH_DISCARD_SAFE(mpath->batch_points);
+ GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo);
+ GPU_BATCH_DISCARD_SAFE(mpath->batch_line);
+ GPU_BATCH_DISCARD_SAFE(mpath->batch_points);
}
}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index bd9ee7c9e5f..6be4574a62e 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -71,6 +71,8 @@
#include "BKE_object.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph_build.h"
+
#include "BIK_api.h"
/* **************** Generic Functions, data level *************** */
@@ -1951,9 +1953,14 @@ void BKE_pose_remap_bone_pointers(bArmature *armature, bPose *pose)
BLI_ghash_free(bone_hash, NULL, NULL);
}
-/* only after leave editmode, duplicating, validating older files, library syncing */
-/* NOTE: pose->flag is set for it */
-void BKE_pose_rebuild(Object *ob, bArmature *arm)
+/**
+ * Only after leave editmode, duplicating, validating older files, library syncing.
+ *
+ * \note pose->flag is set for it.
+ *
+ * \param bmain May be NULL, only used to tag depsgraph as being dirty...
+ */
+void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm)
{
Bone *bone;
bPose *pose;
@@ -1998,12 +2005,17 @@ void BKE_pose_rebuild(Object *ob, bArmature *arm)
pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected);
}
- BKE_pose_update_constraint_flags(ob->pose); /* for IK detection for example */
+ BKE_pose_update_constraint_flags(pose); /* for IK detection for example */
+
+ pose->flag &= ~POSE_RECALC;
+ pose->flag |= POSE_WAS_REBUILT;
- ob->pose->flag &= ~POSE_RECALC;
- ob->pose->flag |= POSE_WAS_REBUILT;
+ BKE_pose_channels_hash_make(pose);
- BKE_pose_channels_hash_make(ob->pose);
+ /* Rebuilding poses forces us to also rebuild the dependency graph, since there is one node per pose/bone... */
+ if (bmain != NULL) {
+ DEG_relations_tag_update(bmain);
+ }
}
/* ********************** THE POSE SOLVER ******************* */
@@ -2277,8 +2289,10 @@ void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
if (ELEM(NULL, arm, scene))
return;
- if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC))
- BKE_pose_rebuild(ob, arm);
+ if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) {
+ /* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty - hopefully this is OK. */
+ BKE_pose_rebuild(NULL, ob, arm);
+ }
ctime = BKE_scene_frame_get(scene); /* not accurate... */
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 23c2147ff7e..66020679bf7 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -300,7 +300,7 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use
DATA_SWAP(font_path_ui_mono);
DATA_SWAP(keyconfigstr);
- DATA_SWAP(manipulator_flag);
+ DATA_SWAP(gizmo_flag);
DATA_SWAP(app_flag);
/* We could add others. */
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 27b5089b092..b16648fd73f 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -226,7 +226,7 @@ static void setup_app_data(
* only the current screen is important because we wont have to handle
* events from multiple screens at once.*/
{
- BKE_screen_manipulator_tag_refresh(curscreen);
+ BKE_screen_gizmo_tag_refresh(curscreen);
}
}
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 7c9e57b039e..34f54704f75 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -513,7 +513,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
}
if (ob->soft) {
- BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches);
+ BPATH_TRAVERSE_POINTCACHE(ob->soft->shared->ptcaches);
}
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 778eb17f822..4203e0455f8 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -977,7 +977,6 @@ CameraBGImage *BKE_camera_background_image_new(Camera *cam)
bgpic->scale = 1.0f;
bgpic->alpha = 0.5f;
- bgpic->iuser.fie_ima = 2;
bgpic->iuser.ok = 1;
bgpic->iuser.flag |= IMA_ANIM_ALWAYS;
bgpic->flag |= CAM_BGIMG_FLAG_EXPANDED;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index ccef747a31c..caf5b94b30e 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -924,7 +924,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, Mesh *mesh )
}
/***************************************************************************************
- * SPRING NETWORK GWN_BATCH_BUILDING IMPLEMENTATION BEGIN
+ * SPRING NETWORK GPU_BATCH_BUILDING IMPLEMENTATION BEGIN
***************************************************************************************/
BLI_INLINE void spring_verts_ordered_set(ClothSpring *spring, int v0, int v1)
@@ -1506,5 +1506,5 @@ static int cloth_build_springs ( ClothModifierData *clmd, Mesh *mesh )
} /* cloth_build_springs */
/***************************************************************************************
- * SPRING NETWORK GWN_BATCH_BUILDING IMPLEMENTATION END
+ * SPRING NETWORK GPU_BATCH_BUILDING IMPLEMENTATION END
***************************************************************************************/
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 1d9cc9bb8d0..0c93f304218 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -473,7 +473,7 @@ static bool collection_object_add(Main *bmain, Collection *collection, Object *o
{
if (ob->dup_group) {
/* Cyclic dependency check. */
- if (collection_find_child_recursive(collection, ob->dup_group)) {
+ if (collection_find_child_recursive(ob->dup_group, collection)) {
return false;
}
}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 0cbd77b67d2..5aa192d527a 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -463,8 +463,8 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
}
/* derive the rotation from the average normal:
- * - code taken from transform_manipulator.c,
- * calc_manipulator_stats, V3D_MANIP_NORMAL case
+ * - code taken from transform_gizmo.c,
+ * calc_gizmo_stats, V3D_MANIP_NORMAL case
*/
/* we need the transpose of the inverse for a normal... */
copy_m3_m4(imat, ob->obmat);
@@ -3641,7 +3641,7 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
* - the min/max wrappers around (obvec . tarvec) result (stored temporarily in rangle)
* are used to ensure that the smallest angle is chosen
*/
- cross_v3_v3v3(raxis, obvec, tarvec);
+ cross_v3_v3v3_hi_prec(raxis, obvec, tarvec);
rangle = dot_v3v3(obvec, tarvec);
rangle = acosf(max_ff(-1.0f, min_ff(1.0f, rangle)));
@@ -3649,7 +3649,35 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* construct rotation matrix from the axis-angle rotation found above
* - this call takes care to make sure that the axis provided is a unit vector first
*/
- axis_angle_to_mat3(rmat, raxis, rangle);
+ float norm = normalize_v3(raxis);
+
+ if (norm < FLT_EPSILON) {
+ /* if dot product is nonzero, while cross is zero, we have two opposite vectors!
+ * - this is an ambiguity in the math that needs to be resolved arbitrarily,
+ * or there will be a case where damped track strangely does nothing
+ * - to do that, rotate around a different local axis
+ */
+ float tmpvec[3];
+
+ if (fabsf(rangle) < M_PI - 0.01f) {
+ return;
+ }
+
+ rangle = M_PI;
+ copy_v3_v3(tmpvec, track_dir_vecs[(data->trackflag + 1) % 6]);
+ mul_mat3_m4_v3(cob->matrix, tmpvec);
+ cross_v3_v3v3(raxis, obvec, tmpvec);
+
+ if (normalize_v3(raxis) == 0.0f) {
+ return;
+ }
+ }
+ else if (norm < 0.1f) {
+ /* near 0 and Pi arcsin has way better precision than arccos */
+ rangle = (rangle > M_PI_2) ? M_PI - asinf(norm) : asinf(norm);
+ }
+
+ axis_angle_normalized_to_mat3(rmat, raxis, rangle);
/* rotate the owner in the way defined by this rotation matrix, then reapply the location since
* we may have destroyed that in the process of multiplying the matrix
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index ee907fa496f..3dfe9732062 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -80,7 +80,7 @@ struct bContext {
struct ScrArea *area;
struct ARegion *region;
struct ARegion *menu;
- struct wmManipulatorGroup *manipulator_group;
+ struct wmGizmoGroup *gizmo_group;
struct bContextStore *store;
const char *operator_poll_msg; /* reason for poll failing */
} wm;
@@ -675,9 +675,9 @@ struct ARegion *CTX_wm_menu(const bContext *C)
return C->wm.menu;
}
-struct wmManipulatorGroup *CTX_wm_manipulator_group(const bContext *C)
+struct wmGizmoGroup *CTX_wm_gizmo_group(const bContext *C)
{
- return C->wm.manipulator_group;
+ return C->wm.gizmo_group;
}
struct wmMsgBus *CTX_wm_message_bus(const bContext *C)
@@ -876,9 +876,9 @@ void CTX_wm_menu_set(bContext *C, ARegion *menu)
C->wm.menu = menu;
}
-void CTX_wm_manipulator_group_set(bContext *C, struct wmManipulatorGroup *mgroup)
+void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup)
{
- C->wm.manipulator_group = mgroup;
+ C->wm.gizmo_group = gzgroup;
}
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
@@ -926,9 +926,17 @@ ViewLayer *CTX_data_view_layer(const bContext *C)
if (ctx_data_pointer_verify(C, "view_layer", (void *)&view_layer)) {
return view_layer;
}
- else {
- return BKE_view_layer_from_workspace_get(CTX_data_scene(C), CTX_wm_workspace(C));
+
+ wmWindow *win = CTX_wm_window(C);
+ Scene *scene = CTX_data_scene(C);
+ if (win) {
+ view_layer = BKE_view_layer_find(scene, win->view_layer_name);
+ if (view_layer) {
+ return view_layer;
+ }
}
+
+ return BKE_view_layer_default_view(scene);
}
RenderEngineType *CTX_data_engine_type(const bContext *C)
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index 87bc819c34f..bf1532bab42 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -30,36 +30,21 @@
*/
-// headers for fluidsim bobj meshes
-#include <stdlib.h>
-#include <zlib.h>
-#include <string.h>
-#include <stdio.h>
-
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_object_fluidsim_types.h"
-#include "DNA_object_force_types.h" // for pointcache
#include "DNA_object_types.h"
-#include "DNA_particle_types.h"
-#include "DNA_scene_types.h"
#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-#include "BKE_cdderivedmesh.h"
#include "BKE_customdata.h"
-#include "BKE_DerivedMesh.h"
#include "BKE_fluidsim.h"
-#include "BKE_modifier.h"
-#include "BKE_mesh.h"
+#include "BKE_library.h"
+#include "BKE_mesh_runtime.h"
/* ************************* fluidsim bobj file handling **************************** */
-
//-------------------------------------------------------------------------------
// file handling
//-------------------------------------------------------------------------------
@@ -69,7 +54,7 @@ void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Obj
int *numTriangles, int **triangles,
int useGlobalCoords, int modifierIndex)
{
- DerivedMesh *dm;
+ Mesh *mesh;
const MVert *mvert;
const MLoop *mloop;
const MLoopTri *looptri, *lt;
@@ -77,13 +62,13 @@ void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Obj
float *verts;
int *tris;
- dm = mesh_create_derived_index_render(depsgraph, scene, ob, CD_MASK_BAREMESH, modifierIndex);
+ mesh = mesh_create_eval_final_index_render(depsgraph, scene, ob, CD_MASK_BAREMESH, modifierIndex);
- mvert = dm->getVertArray(dm);
- mloop = dm->getLoopArray(dm);
- looptri = dm->getLoopTriArray(dm);
- mvert_num = dm->getNumVerts(dm);
- looptri_num = dm->getNumLoopTri(dm);
+ mvert = mesh->mvert;
+ mloop = mesh->mloop;
+ looptri = BKE_mesh_runtime_looptri_ensure(mesh);
+ mvert_num = mesh->totvert;
+ looptri_num = mesh->runtime.looptris.len;
*numVertices = mvert_num;
verts = MEM_mallocN(mvert_num * sizeof(float[3]), "elbeemmesh_vertices");
@@ -102,5 +87,5 @@ void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Obj
}
*triangles = tris;
- dm->release(dm);
+ BKE_id_free(NULL, mesh);
}
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 0edeaab8900..8328d71128a 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -67,7 +67,7 @@ static IDType idtypes[] = {
{ ID_IM, "Image", "images", BLT_I18NCONTEXT_ID_IMAGE, IDTYPE_FLAGS_ISLINKABLE },
{ ID_IP, "Ipo", "ipos", "", IDTYPE_FLAGS_ISLINKABLE }, /* deprecated */
{ ID_KE, "Key", "shape_keys", BLT_I18NCONTEXT_ID_SHAPEKEY, 0 },
- { ID_LA, "Lamp", "lamps", BLT_I18NCONTEXT_ID_LAMP, IDTYPE_FLAGS_ISLINKABLE },
+ { ID_LA, "Light", "lights", BLT_I18NCONTEXT_ID_LAMP, IDTYPE_FLAGS_ISLINKABLE },
{ ID_LI, "Library", "libraries", BLT_I18NCONTEXT_ID_LIBRARY, 0 },
{ ID_LS, "FreestyleLineStyle", "linestyles", BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, IDTYPE_FLAGS_ISLINKABLE },
{ ID_LT, "Lattice", "lattices", BLT_I18NCONTEXT_ID_LATTICE, IDTYPE_FLAGS_ISLINKABLE },
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index e164e1862d5..8cc40d4e74c 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -913,7 +913,6 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is
case IDP_ID:
return (IDP_Id(prop1) == IDP_Id(prop2));
default:
- /* should never get here */
BLI_assert(0);
break;
}
@@ -1015,7 +1014,8 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
prop->data.pointer = MEM_mallocN(DEFAULT_ALLOC_FOR_NULL_STRINGS, "id property string 1");
*IDP_String(prop) = '\0';
prop->totallen = DEFAULT_ALLOC_FOR_NULL_STRINGS;
- prop->len = 1; /*NULL string, has len of 1 to account for null byte.*/
+ /* NULL string, has len of 1 to account for null byte. */
+ prop->len = 1;
}
else {
BLI_assert((int)val->string.len <= (int)strlen(st) + 1);
@@ -1030,8 +1030,8 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
}
case IDP_GROUP:
{
+ /* Values are set properly by calloc. */
prop = MEM_callocN(sizeof(IDProperty), "IDProperty group");
- /* heh I think all needed values are set properly by calloc anyway :) */
break;
}
case IDP_ID:
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index b5abdcae2d4..aedbd0673c2 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -186,76 +186,6 @@ void BKE_images_exit(void)
BLI_spin_end(&image_spin);
}
-/* ******** IMAGE PROCESSING ************* */
-
-static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */
-{
- struct ImBuf *tbuf1, *tbuf2;
-
- if (ibuf == NULL) return;
- if (ibuf->flags & IB_fields) return;
- ibuf->flags |= IB_fields;
-
- if (ibuf->rect) {
- /* make copies */
- tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect);
- tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect);
-
- ibuf->x *= 2;
-
- IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
- IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
-
- ibuf->x /= 2;
- IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y);
- IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y);
-
- IMB_freeImBuf(tbuf1);
- IMB_freeImBuf(tbuf2);
- }
- ibuf->y /= 2;
-}
-
-static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */
-{
- struct ImBuf *tbuf1, *tbuf2;
-
- if (ibuf == NULL) return;
- if (ibuf->flags & IB_fields) return;
- ibuf->flags |= IB_fields;
-
- if (ibuf->rect) {
- /* make copies */
- tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect);
- tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect);
-
- ibuf->x *= 2;
-
- IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
- IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
-
- ibuf->x /= 2;
- IMB_rectcpy(ibuf, tbuf2, 0, 0, 0, 0, tbuf2->x, tbuf2->y);
- IMB_rectcpy(ibuf, tbuf1, 0, tbuf2->y, 0, 0, tbuf1->x, tbuf1->y);
-
- IMB_freeImBuf(tbuf1);
- IMB_freeImBuf(tbuf2);
- }
- ibuf->y /= 2;
-}
-
-void BKE_image_de_interlace(Image *ima, int odd)
-{
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- if (ibuf) {
- if (odd)
- de_interlace_st(ibuf);
- else
- de_interlace_ng(ibuf);
- }
- BKE_image_release_ibuf(ima, ibuf, NULL);
-}
-
/* ***************** ALLOC & FREE, DATA MANAGING *************** */
static void image_free_cached_frames(Image *image)
@@ -3129,7 +3059,7 @@ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
#endif /* WITH_OPENEXR */
/* common stuff to do with images after loading */
-static void image_initialize_after_load(Image *ima, ImBuf *ibuf)
+static void image_initialize_after_load(Image *ima, ImBuf *UNUSED(ibuf))
{
/* Preview is NULL when it has never been used as an icon before.
* Never handle previews/icons outside of main thread. */
@@ -3137,11 +3067,6 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf)
BKE_icon_changed(BKE_icon_id_ensure(&ima->id));
}
- /* fields */
- if (ima->flag & IMA_FIELDS) {
- if (ima->flag & IMA_STD_FIELD) de_interlace_st(ibuf);
- else de_interlace_ng(ibuf);
- }
/* timer */
BKE_image_tag_time(ima);
@@ -4093,12 +4018,12 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
{
- if (lock) {
+ if (lock != NULL) {
/* for getting image during threaded render / compositing, need to release */
if (lock == ima) {
BLI_thread_unlock(LOCK_VIEWER); /* viewer image */
}
- else if (lock) {
+ else {
RE_ReleaseResultImage(lock); /* render result */
BLI_thread_unlock(LOCK_VIEWER); /* view image imbuf */
}
@@ -4249,7 +4174,7 @@ void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool)
int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, bool *r_is_in_range)
{
- const int len = (iuser->fie_ima * iuser->frames) / 2;
+ const int len = iuser->frames;
if (r_is_in_range) {
*r_is_in_range = false;
@@ -4290,7 +4215,7 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, bool
if (fieldnr) cfra++;
/* transform to images space */
- framenr = (cfra + iuser->fie_ima - 2) / iuser->fie_ima;
+ framenr = cfra;
if (framenr > iuser->frames) framenr = iuser->frames;
if (iuser->cycl) {
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index f8040f0cf24..3be40b414a6 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1717,8 +1717,7 @@ void do_versions_ipos_to_animato(Main *bmain)
/* IPO first to take into any non-NLA'd Object Animation */
if (ob->ipo) {
ipo_to_animdata(bmain, id, ob->ipo, NULL, NULL, NULL);
-
- id_us_min(&ob->ipo->id);
+ /* No need to id_us_min ipo ID here, ipo_to_animdata already does it. */
ob->ipo = NULL;
}
@@ -1751,7 +1750,7 @@ void do_versions_ipos_to_animato(Main *bmain)
/* IPO second... */
if (ob->ipo) {
ipo_to_animdata(bmain, id, ob->ipo, NULL, NULL, NULL);
- id_us_min(&ob->ipo->id);
+ /* No need to id_us_min ipo ID here, ipo_to_animdata already does it. */
ob->ipo = NULL;
}
}
@@ -1999,7 +1998,7 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->lamp.first; id; id = id->next) {
Lamp *la = (Lamp *)id;
- if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name + 2);
+ if (G.debug & G_DEBUG) printf("\tconverting light %s\n", id->name + 2);
/* we're only interested in the IPO */
if (la->ipo) {
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 1d5b6de22f4..2c1b36d3496 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -84,10 +84,10 @@ void BKE_lamp_init(Lamp *la)
la->cascade_count = 4;
la->cascade_exponent = 0.8f;
la->cascade_fade = 0.1f;
- la->contact_dist = 1.0f;
+ la->contact_dist = 0.2f;
la->contact_bias = 0.03f;
la->contact_spread = 0.2f;
- la->contact_thickness = 0.5f;
+ la->contact_thickness = 0.2f;
la->spec_fac = 1.0f;
curvemapping_initialize(la->curfalloff);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 22188d25df5..2f5c8e7817e 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -42,7 +42,6 @@
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_node.h"
-#include "BKE_workspace.h"
#include "BKE_object.h"
#include "DNA_group_types.h"
@@ -130,17 +129,22 @@ ViewLayer *BKE_view_layer_default_render(const Scene *scene)
return scene->view_layers.first;
}
-/**
- * Returns the ViewLayer to be used for drawing, outliner, and other context related areas.
- */
-ViewLayer *BKE_view_layer_from_workspace_get(const struct Scene *scene, const struct WorkSpace *workspace)
+/* Returns view layer with matching name, or NULL if not found. */
+ViewLayer *BKE_view_layer_find(const Scene *scene, const char *layer_name)
{
- return BKE_workspace_view_layer_get(workspace, scene);
+ for (ViewLayer *view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
+ if (STREQ(view_layer->name, layer_name)) {
+ return view_layer;
+ }
+ }
+
+ return NULL;
}
/**
- * This is a placeholder to know which areas of the code need to be addressed for the Workspace changes.
- * Never use this, you should either use BKE_view_layer_from_workspace_get or get ViewLayer explicitly.
+ * This is a placeholder to know which areas of the code need to be addressed
+ * for the Workspace changes. Never use this, you should typically get the
+ * active layer from the context or window.
*/
ViewLayer *BKE_view_layer_context_active_PLACEHOLDER(const Scene *scene)
{
@@ -342,7 +346,9 @@ void BKE_view_layer_base_select(struct ViewLayer *view_layer, Base *selbase)
/**************************** Copy View Layer and Layer Collections ***********************/
-static void layer_collections_copy_data(ListBase *layer_collections_dst, const ListBase *layer_collections_src)
+static void layer_collections_copy_data(
+ ViewLayer *view_layer_dst, const ViewLayer *view_layer_src,
+ ListBase *layer_collections_dst, const ListBase *layer_collections_src)
{
BLI_duplicatelist(layer_collections_dst, layer_collections_src);
@@ -351,9 +357,15 @@ static void layer_collections_copy_data(ListBase *layer_collections_dst, const L
while (layer_collection_dst != NULL) {
layer_collections_copy_data(
+ view_layer_dst,
+ view_layer_src,
&layer_collection_dst->layer_collections,
&layer_collection_src->layer_collections);
+ if (layer_collection_src == view_layer_src->active_collection) {
+ view_layer_dst->active_collection = layer_collection_dst;
+ }
+
layer_collection_dst = layer_collection_dst->next;
layer_collection_src = layer_collection_src->next;
}
@@ -365,7 +377,7 @@ static void layer_collections_copy_data(ListBase *layer_collections_dst, const L
* \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
*/
void BKE_view_layer_copy_data(
- Scene *UNUSED(scene_dst), const Scene *UNUSED(scene_src),
+ Scene *scene_dst, const Scene *UNUSED(scene_src),
ViewLayer *view_layer_dst, const ViewLayer *view_layer_src,
const int flag)
{
@@ -392,9 +404,15 @@ void BKE_view_layer_copy_data(
}
}
- layer_collections_copy_data(&view_layer_dst->layer_collections, &view_layer_src->layer_collections);
+ view_layer_dst->active_collection = NULL;
+ layer_collections_copy_data(
+ view_layer_dst,
+ view_layer_src,
+ &view_layer_dst->layer_collections,
+ &view_layer_src->layer_collections);
- // TODO: not always safe to free BKE_layer_collection_sync(scene_dst, view_layer_dst);
+ LayerCollection *lc_scene_dst = view_layer_dst->layer_collections.first;
+ lc_scene_dst->collection = scene_dst->master_collection;
}
void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, const char *newname)
@@ -418,9 +436,15 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
}
}
- /* fix all the animation data and workspace which may link to this */
+ /* fix all the animation data and windows which may link to this */
BKE_animdata_fix_paths_rename_all(NULL, "view_layers", oldname, view_layer->name);
- BKE_workspace_view_layer_rename(bmain, scene, oldname, view_layer->name);
+
+ wmWindowManager *wm = bmain->wm.first;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ if (win->scene == scene && STREQ(win->view_layer_name, oldname)) {
+ STRNCPY(win->view_layer_name, view_layer->name);
+ }
+ }
/* Dependency graph uses view layer name based lookups. */
DEG_id_tag_update(&scene->id, 0);
@@ -588,6 +612,10 @@ static int layer_collection_sync(
BLI_findptr(lb_scene, lc->collection, offsetof(CollectionChild, collection)) : NULL;
if (!collection) {
+ if (lc == view_layer->active_collection) {
+ view_layer->active_collection = NULL;
+ }
+
/* Free recursively. */
layer_collection_free(view_layer, lc);
BLI_freelinkN(lb_layer, lc);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index c2cdc8df1e6..351214ed72b 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -2464,7 +2464,7 @@ void BKE_library_make_local(
* Try "make all local" in 04_01_H.lighting.blend from Agent327 without this, e.g. */
for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->data != NULL && ob->type == OB_ARMATURE && ob->pose != NULL && ob->pose->flag & POSE_RECALC) {
- BKE_pose_rebuild(ob, ob->data);
+ BKE_pose_rebuild(bmain, ob, ob->data);
}
}
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 54b73dad982..93fdd3349bf 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -936,10 +936,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
/* allow callback to set a different screen */
BKE_workspace_layout_screen_set(layout, screen);
}
-
- for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first; relation; relation = relation->next) {
- CALLBACK_INVOKE(relation->scene, IDWALK_CB_NOP);
- }
break;
}
case ID_GD:
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index 057b6aaaf65..baf0cdbe62f 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -53,7 +53,6 @@ void BKE_lightprobe_init(LightProbe *probe)
probe->vis_bias = 1.0f;
probe->vis_blur = 0.2f;
probe->intensity = 1.0f;
- probe->data_draw_size = 1.0f;
probe->flag = LIGHTPROBE_FLAG_SHOW_INFLUENCE | LIGHTPROBE_FLAG_SHOW_DATA;
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index b13f45499f1..df20d5a2b5d 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -349,8 +349,9 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me)
/* Mark an arbitrary vertex as root */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- vs = CustomData_bmesh_get(&bm->vdata, v->head.data,
- CD_MVERT_SKIN);
+ vs = CustomData_bmesh_get(
+ &bm->vdata, v->head.data,
+ CD_MVERT_SKIN);
vs->flag |= MVERT_SKIN_ROOT;
break;
}
@@ -358,11 +359,12 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me)
}
else {
if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
- vs = CustomData_add_layer(&me->vdata,
- CD_MVERT_SKIN,
- CD_DEFAULT,
- NULL,
- me->totvert);
+ vs = CustomData_add_layer(
+ &me->vdata,
+ CD_MVERT_SKIN,
+ CD_DEFAULT,
+ NULL,
+ me->totvert);
/* Mark an arbitrary vertex as root */
if (vs) {
@@ -384,11 +386,12 @@ bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me)
}
else {
if (!CustomData_has_layer(&me->pdata, CD_FACEMAP)) {
- CustomData_add_layer(&me->pdata,
- CD_FACEMAP,
- CD_DEFAULT,
- NULL,
- me->totpoly);
+ CustomData_add_layer(
+ &me->pdata,
+ CD_FACEMAP,
+ CD_DEFAULT,
+ NULL,
+ me->totpoly);
changed = true;
}
}
@@ -1200,9 +1203,10 @@ int poly_get_adj_loops_from_vert(
const MLoop *mloop, unsigned int vert,
unsigned int r_adj[2])
{
- int corner = poly_find_loop_from_vert(poly,
- &mloop[poly->loopstart],
- vert);
+ int corner = poly_find_loop_from_vert(
+ poly,
+ &mloop[poly->loopstart],
+ vert);
if (corner != -1) {
#if 0 /* unused - this loop */
@@ -1310,11 +1314,12 @@ void BKE_mesh_ensure_navmesh(Mesh *me)
void BKE_mesh_tessface_calc(Mesh *mesh)
{
- mesh->totface = BKE_mesh_recalc_tessellation(&mesh->fdata, &mesh->ldata, &mesh->pdata,
- mesh->mvert,
- mesh->totface, mesh->totloop, mesh->totpoly,
- /* calc normals right after, don't copy from polys here */
- false);
+ mesh->totface = BKE_mesh_recalc_tessellation(
+ &mesh->fdata, &mesh->ldata, &mesh->pdata,
+ mesh->mvert,
+ mesh->totface, mesh->totloop, mesh->totpoly,
+ /* calc normals right after, don't copy from polys here */
+ false);
BKE_mesh_update_customdata_pointers(mesh, true);
}
@@ -1511,6 +1516,21 @@ void BKE_mesh_apply_vert_coords(Mesh *mesh, float (*vertCoords)[3])
mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
}
+void BKE_mesh_apply_vert_normals(Mesh *mesh, short (*vertNormals)[3])
+{
+ MVert *vert;
+ int i;
+
+ /* this will just return the pointer if it wasn't a referenced layer */
+ vert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert);
+ mesh->mvert = vert;
+
+ for (i = 0; i < mesh->totvert; ++i, ++vert)
+ copy_v3_v3_short(vert->no, vertNormals[i]);
+
+ mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
+}
+
/**
* Compute 'split' (aka loop, or per face corner's) normals.
*
@@ -1549,8 +1569,8 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
else {
polynors = MEM_malloc_arrayN(mesh->totpoly, sizeof(float[3]), __func__);
BKE_mesh_calc_normals_poly(
- mesh->mvert, NULL, mesh->totvert,
- mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, polynors, false);
+ mesh->mvert, NULL, mesh->totvert,
+ mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, polynors, false);
free_polynors = true;
}
@@ -1830,8 +1850,9 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
/* **** Depsgraph evaluation **** */
-void BKE_mesh_eval_geometry(Depsgraph *depsgraph,
- Mesh *mesh)
+void BKE_mesh_eval_geometry(
+ Depsgraph *depsgraph,
+ Mesh *mesh)
{
DEG_debug_print_eval(depsgraph, __func__, mesh->id.name, mesh);
if (mesh->bb == NULL || (mesh->bb->flag & BOUNDBOX_DIRTY)) {
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 3fc5d1ca51c..738f116310b 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -134,9 +134,10 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
/**
* Specialized function to use when we _know_ existing edges don't overlap with poly edges.
*/
-static void make_edges_mdata_extend(MEdge **r_alledge, int *r_totedge,
- const MPoly *mpoly, MLoop *mloop,
- const int totpoly)
+static void make_edges_mdata_extend(
+ MEdge **r_alledge, int *r_totedge,
+ const MPoly *mpoly, MLoop *mloop,
+ const int totpoly)
{
int totedge = *r_totedge;
int totedge_new;
@@ -561,10 +562,11 @@ void BKE_mesh_from_nurbs_displist(
cu = ob->data;
if (dm == NULL) {
- if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert,
- &alledge, &totedge, &allloop,
- &allpoly, (use_orco_uv) ? &alluv : NULL,
- &totloop, &totpoly) != 0)
+ if (BKE_mesh_nurbs_displist_to_mdata(
+ ob, dispbase, &allvert, &totvert,
+ &alledge, &totedge, &allloop,
+ &allpoly, (use_orco_uv) ? &alluv : NULL,
+ &totloop, &totpoly) != 0)
{
/* Error initializing */
return;
@@ -1143,12 +1145,13 @@ Mesh *BKE_mesh_create_derived_for_modifier(
float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
modifier_deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
- BKE_id_copy_ex(NULL, &me->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(
+ NULL, &me->id, (ID **)&result,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_NO_PREVIEW,
+ false);
BKE_mesh_apply_vert_coords(result, deformedVerts);
if (build_shapekey_layers)
@@ -1158,12 +1161,13 @@ Mesh *BKE_mesh_create_derived_for_modifier(
}
else {
Mesh *mesh_temp;
- BKE_id_copy_ex(NULL, &me->id, (ID **)&mesh_temp,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(
+ NULL, &me->id, (ID **)&mesh_temp,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_NO_PREVIEW,
+ false);
if (build_shapekey_layers)
add_shapekey_layers(mesh_temp, me);
@@ -1314,14 +1318,16 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomD
/* TODO(Sybren): we could probably replace CD_ASSIGN with alloctype and always directly pass mesh_src->mxxx,
* instead of using a ternary operator. */
if (!CustomData_has_layer(&tmp.vdata, CD_MVERT)) {
- CustomData_add_layer(&tmp.vdata, CD_MVERT, CD_ASSIGN,
- (alloctype == CD_ASSIGN) ? mesh_src->mvert : MEM_dupallocN(mesh_src->mvert),
- totvert);
+ CustomData_add_layer(
+ &tmp.vdata, CD_MVERT, CD_ASSIGN,
+ (alloctype == CD_ASSIGN) ? mesh_src->mvert : MEM_dupallocN(mesh_src->mvert),
+ totvert);
}
if (!CustomData_has_layer(&tmp.edata, CD_MEDGE)) {
- CustomData_add_layer(&tmp.edata, CD_MEDGE, CD_ASSIGN,
- (alloctype == CD_ASSIGN) ? mesh_src->medge : MEM_dupallocN(mesh_src->medge),
- totedge);
+ CustomData_add_layer(
+ &tmp.edata, CD_MEDGE, CD_ASSIGN,
+ (alloctype == CD_ASSIGN) ? mesh_src->medge : MEM_dupallocN(mesh_src->medge),
+ totedge);
}
if (!CustomData_has_layer(&tmp.pdata, CD_MPOLY)) {
/* TODO(Sybren): assigment to tmp.mxxx is probably not necessary due to the
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 3062cd13f5f..66419b03e01 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -96,10 +96,10 @@ void BKE_mesh_calc_normals_mapping_simple(struct Mesh *mesh)
const bool only_face_normals = CustomData_is_referenced_layer(&mesh->vdata, CD_MVERT);
BKE_mesh_calc_normals_mapping_ex(
- mesh->mvert, mesh->totvert,
- mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL,
- mesh->mface, mesh->totface, NULL, NULL,
- only_face_normals);
+ mesh->mvert, mesh->totvert,
+ mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL,
+ mesh->mface, mesh->totface, NULL, NULL,
+ only_face_normals);
}
/* Calculate vertex and face normals, face normals are returned in *r_faceNors if non-NULL
@@ -360,9 +360,10 @@ void BKE_mesh_calc_normals(Mesh *mesh)
#ifdef DEBUG_TIME
TIMEIT_START_AVERAGED(BKE_mesh_calc_normals);
#endif
- BKE_mesh_calc_normals_poly(mesh->mvert, NULL, mesh->totvert,
- mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
- NULL, false);
+ BKE_mesh_calc_normals_poly(
+ mesh->mvert, NULL, mesh->totvert,
+ mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
+ NULL, false);
#ifdef DEBUG_TIME
TIMEIT_END_AVERAGED(BKE_mesh_calc_normals);
#endif
@@ -516,8 +517,9 @@ MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr)
* Beware, this modifies ref_vec and other_vec in place!
* In case no valid space can be generated, ref_alpha and ref_beta are set to zero (which means 'use auto lnors').
*/
-void BKE_lnor_space_define(MLoopNorSpace *lnor_space, const float lnor[3],
- float vec_ref[3], float vec_other[3], BLI_Stack *edge_vectors)
+void BKE_lnor_space_define(
+ MLoopNorSpace *lnor_space, const float lnor[3],
+ float vec_ref[3], float vec_other[3], BLI_Stack *edge_vectors)
{
const float pi2 = (float)M_PI * 2.0f;
float tvec[3], dtp;
@@ -799,8 +801,9 @@ static void mesh_edges_sharp_tag(
e2l[1] = (mp->flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID;
}
else if (e2l[1] == INDEX_UNSET) {
- const bool is_angle_sharp = (check_angle &&
- dot_v3v3(polynors[loop_to_poly[e2l[0]]], polynors[mp_index]) < split_angle_cos);
+ const bool is_angle_sharp = (
+ check_angle &&
+ dot_v3v3(polynors[loop_to_poly[e2l[0]]], polynors[mp_index]) < split_angle_cos);
/* Second loop using this edge, time to test its sharpness.
* An edge is sharp if it is tagged as such, or its face is not smooth,
@@ -1133,8 +1136,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
/* Find next loop of the smooth fan. */
BKE_mesh_loop_manifold_fan_around_vert_next(
- mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index,
- &mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index);
+ mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index,
+ &mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index);
e2lfan_curr = edge_to_loops[mlfan_curr->e];
}
@@ -1270,8 +1273,8 @@ static bool loop_split_generator_check_cyclic_smooth_fan(
while (true) {
/* Find next loop of the smooth fan. */
BKE_mesh_loop_manifold_fan_around_vert_next(
- mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index,
- &mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index);
+ mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index,
+ &mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index);
e2lfan_curr = edge_to_loops[mlfan_curr->e];
@@ -1620,9 +1623,10 @@ static void mesh_normals_loop_custom_set(
BLI_SMALLSTACK_DECLARE(clnors_data, short *);
/* Compute current lnor spacearr. */
- BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
- mpolys, polynors, numPolys, use_split_normals, split_angle,
- &lnors_spacearr, NULL, loop_to_poly);
+ BKE_mesh_normals_loop_split(
+ mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
+ mpolys, polynors, numPolys, use_split_normals, split_angle,
+ &lnors_spacearr, NULL, loop_to_poly);
/* Set all given zero vectors to their default value. */
if (use_vertices) {
@@ -1730,9 +1734,10 @@ static void mesh_normals_loop_custom_set(
/* And now, recompute our new auto lnors and lnor spacearr! */
BKE_lnor_spacearr_clear(&lnors_spacearr);
- BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
- mpolys, polynors, numPolys, use_split_normals, split_angle,
- &lnors_spacearr, NULL, loop_to_poly);
+ BKE_mesh_normals_loop_split(
+ mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
+ mpolys, polynors, numPolys, use_split_normals, split_angle,
+ &lnors_spacearr, NULL, loop_to_poly);
}
else {
BLI_BITMAP_SET_ALL(done_loops, true, (size_t)numLoops);
@@ -1804,8 +1809,9 @@ void BKE_mesh_normals_loop_custom_set(
MPoly *mpolys, const float (*polynors)[3], const int numPolys,
short (*r_clnors_data)[2])
{
- mesh_normals_loop_custom_set(mverts, numVerts, medges, numEdges, mloops, r_custom_loopnors, numLoops,
- mpolys, polynors, numPolys, r_clnors_data, false);
+ mesh_normals_loop_custom_set(
+ mverts, numVerts, medges, numEdges, mloops, r_custom_loopnors, numLoops,
+ mpolys, polynors, numPolys, r_clnors_data, false);
}
void BKE_mesh_normals_loop_custom_from_vertices_set(
@@ -1814,8 +1820,9 @@ void BKE_mesh_normals_loop_custom_from_vertices_set(
MPoly *mpolys, const float (*polynors)[3], const int numPolys,
short (*r_clnors_data)[2])
{
- mesh_normals_loop_custom_set(mverts, numVerts, medges, numEdges, mloops, r_custom_vertnors, numLoops,
- mpolys, polynors, numPolys, r_clnors_data, true);
+ mesh_normals_loop_custom_set(
+ mverts, numVerts, medges, numEdges, mloops, r_custom_vertnors, numLoops,
+ mpolys, polynors, numPolys, r_clnors_data, true);
}
/**
@@ -1899,19 +1906,19 @@ void BKE_mesh_calc_poly_normal(
mesh_calc_ngon_normal(mpoly, loopstart, mvarray, r_no);
}
else if (mpoly->totloop == 3) {
- normal_tri_v3(r_no,
- mvarray[loopstart[0].v].co,
- mvarray[loopstart[1].v].co,
- mvarray[loopstart[2].v].co
- );
+ normal_tri_v3(
+ r_no,
+ mvarray[loopstart[0].v].co,
+ mvarray[loopstart[1].v].co,
+ mvarray[loopstart[2].v].co);
}
else if (mpoly->totloop == 4) {
- normal_quad_v3(r_no,
- mvarray[loopstart[0].v].co,
- mvarray[loopstart[1].v].co,
- mvarray[loopstart[2].v].co,
- mvarray[loopstart[3].v].co
- );
+ normal_quad_v3(
+ r_no,
+ mvarray[loopstart[0].v].co,
+ mvarray[loopstart[1].v].co,
+ mvarray[loopstart[2].v].co,
+ mvarray[loopstart[3].v].co);
}
else { /* horrible, two sided face! */
r_no[0] = 0.0;
@@ -1951,19 +1958,19 @@ void BKE_mesh_calc_poly_normal_coords(
mesh_calc_ngon_normal_coords(mpoly, loopstart, vertex_coords, r_no);
}
else if (mpoly->totloop == 3) {
- normal_tri_v3(r_no,
- vertex_coords[loopstart[0].v],
- vertex_coords[loopstart[1].v],
- vertex_coords[loopstart[2].v]
- );
+ normal_tri_v3(
+ r_no,
+ vertex_coords[loopstart[0].v],
+ vertex_coords[loopstart[1].v],
+ vertex_coords[loopstart[2].v]);
}
else if (mpoly->totloop == 4) {
- normal_quad_v3(r_no,
- vertex_coords[loopstart[0].v],
- vertex_coords[loopstart[1].v],
- vertex_coords[loopstart[2].v],
- vertex_coords[loopstart[3].v]
- );
+ normal_quad_v3(
+ r_no,
+ vertex_coords[loopstart[0].v],
+ vertex_coords[loopstart[1].v],
+ vertex_coords[loopstart[2].v],
+ vertex_coords[loopstart[3].v]);
}
else { /* horrible, two sided face! */
r_no[0] = 0.0;
@@ -1991,19 +1998,19 @@ void BKE_mesh_calc_poly_center(
const MVert *mvarray, float r_cent[3])
{
if (mpoly->totloop == 3) {
- mid_v3_v3v3v3(r_cent,
- mvarray[loopstart[0].v].co,
- mvarray[loopstart[1].v].co,
- mvarray[loopstart[2].v].co
- );
+ mid_v3_v3v3v3(
+ r_cent,
+ mvarray[loopstart[0].v].co,
+ mvarray[loopstart[1].v].co,
+ mvarray[loopstart[2].v].co);
}
else if (mpoly->totloop == 4) {
- mid_v3_v3v3v3v3(r_cent,
- mvarray[loopstart[0].v].co,
- mvarray[loopstart[1].v].co,
- mvarray[loopstart[2].v].co,
- mvarray[loopstart[3].v].co
- );
+ mid_v3_v3v3v3v3(
+ r_cent,
+ mvarray[loopstart[0].v].co,
+ mvarray[loopstart[1].v].co,
+ mvarray[loopstart[2].v].co,
+ mvarray[loopstart[3].v].co);
}
else {
mesh_calc_ngon_center(mpoly, loopstart, mvarray, r_cent);
@@ -2016,10 +2023,10 @@ float BKE_mesh_calc_poly_area(
const MVert *mvarray)
{
if (mpoly->totloop == 3) {
- return area_tri_v3(mvarray[loopstart[0].v].co,
- mvarray[loopstart[1].v].co,
- mvarray[loopstart[2].v].co
- );
+ return area_tri_v3(
+ mvarray[loopstart[0].v].co,
+ mvarray[loopstart[1].v].co,
+ mvarray[loopstart[2].v].co);
}
else {
int i;
@@ -2130,8 +2137,9 @@ static float mesh_calc_poly_area_centroid(
}
#if 0 /* slow version of the function below */
-void BKE_mesh_calc_poly_angles(MPoly *mpoly, MLoop *loopstart,
- MVert *mvarray, float angles[])
+void BKE_mesh_calc_poly_angles(
+ MPoly *mpoly, MLoop *loopstart,
+ MVert *mvarray, float angles[])
{
MLoop *ml;
MLoop *mloop = &loopstart[-mpoly->loopstart];
@@ -2499,8 +2507,9 @@ void BKE_mesh_loops_to_mface_corners(
*
* \note when mface is not NULL, mface[face_index].v4 is used to test quads, else, loopindices[face_index][3] is used.
*/
-void BKE_mesh_loops_to_tessdata(CustomData *fdata, CustomData *ldata, MFace *mface,
- int *polyindices, unsigned int (*loopindices)[4], const int num_faces)
+void BKE_mesh_loops_to_tessdata(
+ CustomData *fdata, CustomData *ldata, MFace *mface,
+ int *polyindices, unsigned int (*loopindices)[4], const int num_faces)
{
/* Note: performances are sub-optimal when we get a NULL mface, we could be ~25% quicker with dedicated code...
* Issue is, unless having two different functions with nearly the same code, there's not much ways to solve
@@ -3036,130 +3045,6 @@ void BKE_mesh_recalc_looptri(
#undef ML_TO_MLT
}
-/* -------------------------------------------------------------------- */
-
-
-#ifdef USE_BMESH_SAVE_AS_COMPAT
-
-/**
- * This function recreates a tessellation.
- * returns number of tessellation faces.
- *
- * for forwards compat only quad->tri polys to mface, skip ngons.
- */
-int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
- struct CustomData *pdata, int totface, int UNUSED(totloop), int totpoly)
-{
- MLoop *mloop;
-
- unsigned int lindex[4];
- int i;
- int k;
-
- MPoly *mp, *mpoly;
- MFace *mface, *mf;
-
- const int numUV = CustomData_number_of_layers(ldata, CD_MLOOPUV);
- 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_malloc_arrayN((size_t)totpoly, sizeof(*mface), __func__);
-
- mpoly = CustomData_get_layer(pdata, CD_MPOLY);
- mloop = CustomData_get_layer(ldata, CD_MLOOP);
-
- mp = mpoly;
- k = 0;
- for (i = 0; i < totpoly; i++, mp++) {
- if (ELEM(mp->totloop, 3, 4)) {
- const unsigned int mp_loopstart = (unsigned int)mp->loopstart;
- mf = &mface[k];
-
- mf->mat_nr = mp->mat_nr;
- mf->flag = mp->flag;
-
- mf->v1 = mp_loopstart + 0;
- mf->v2 = mp_loopstart + 1;
- mf->v3 = mp_loopstart + 2;
- mf->v4 = (mp->totloop == 4) ? (mp_loopstart + 3) : 0;
-
- /* abuse edcode for temp storage and clear next loop */
- mf->edcode = (char)mp->totloop; /* only ever 3 or 4 */
-
- k++;
- }
- }
-
- CustomData_free(fdata, totface);
-
- totface = k;
-
- CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface);
-
- CustomData_from_bmeshpoly(fdata, ldata, totface);
-
- mp = mpoly;
- k = 0;
- for (i = 0; i < totpoly; i++, mp++) {
- if (ELEM(mp->totloop, 3, 4)) {
- mf = &mface[k];
-
- if (mf->edcode == 3) {
- /* sort loop indices to ensure winding is correct */
- /* NO SORT - looks like we can skip this */
-
- lindex[0] = mf->v1;
- lindex[1] = mf->v2;
- lindex[2] = mf->v3;
- lindex[3] = 0; /* unused */
-
- /* transform loop indices to vert indices */
- mf->v1 = mloop[mf->v1].v;
- mf->v2 = mloop[mf->v2].v;
- mf->v3 = mloop[mf->v3].v;
-
- BKE_mesh_loops_to_mface_corners(
- fdata, ldata, pdata,
- lindex, k, i, 3,
- numUV, numCol, hasPCol, hasOrigSpace, hasLNor);
- test_index_face(mf, fdata, k, 3);
- }
- else {
- /* sort loop indices to ensure winding is correct */
- /* NO SORT - looks like we can skip this */
-
- lindex[0] = mf->v1;
- lindex[1] = mf->v2;
- lindex[2] = mf->v3;
- lindex[3] = mf->v4;
-
- /* transform loop indices to vert indices */
- mf->v1 = mloop[mf->v1].v;
- mf->v2 = mloop[mf->v2].v;
- mf->v3 = mloop[mf->v3].v;
- mf->v4 = mloop[mf->v4].v;
-
- BKE_mesh_loops_to_mface_corners(
- fdata, ldata, pdata,
- lindex, k, i, 4,
- numUV, numCol, hasPCol, hasOrigSpace, hasLNor);
- test_index_face(mf, fdata, k, 4);
- }
-
- mf->edcode = 0;
-
- k++;
- }
- }
-
- return k;
-}
-#endif /* USE_BMESH_SAVE_AS_COMPAT */
-
-
static void bm_corners_to_loops_ex(
ID *id, CustomData *fdata, CustomData *ldata,
MFace *mface, int totloop, int findex, int loopstart, int numTex, int numCol)
@@ -3217,8 +3102,9 @@ static void bm_corners_to_loops_ex(
if (CustomData_external_test(fdata, CD_MDISPS)) {
if (id && fdata->external) {
- CustomData_external_add(ldata, id, CD_MDISPS,
- totloop, fdata->external->filename);
+ CustomData_external_add(
+ ldata, id, CD_MDISPS,
+ totloop, fdata->external->filename);
}
}
@@ -3256,10 +3142,11 @@ static void bm_corners_to_loops_ex(
void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
{
- BKE_mesh_convert_mfaces_to_mpolys_ex(&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata,
- mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly,
- mesh->medge, mesh->mface,
- &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly);
+ BKE_mesh_convert_mfaces_to_mpolys_ex(
+ &mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata,
+ mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly,
+ mesh->medge, mesh->mface,
+ &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly);
BKE_mesh_update_customdata_pointers(mesh, true);
}
@@ -3276,21 +3163,23 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
*/
void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
{
- BKE_mesh_convert_mfaces_to_mpolys_ex(&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata,
- mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly,
- mesh->medge, mesh->mface,
- &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly);
+ BKE_mesh_convert_mfaces_to_mpolys_ex(
+ &mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata,
+ mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly,
+ mesh->medge, mesh->mface,
+ &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly);
CustomData_bmesh_do_versions_update_active_layers(&mesh->fdata, &mesh->ldata);
BKE_mesh_update_customdata_pointers(mesh, true);
}
-void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata,
- int totedge_i, int totface_i, int totloop_i, int totpoly_i,
- MEdge *medge, MFace *mface,
- int *r_totloop, int *r_totpoly,
- MLoop **r_mloop, MPoly **r_mpoly)
+void BKE_mesh_convert_mfaces_to_mpolys_ex(
+ ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata,
+ int totedge_i, int totface_i, int totloop_i, int totpoly_i,
+ MEdge *medge, MFace *mface,
+ int *r_totloop, int *r_totpoly,
+ MLoop **r_mloop, MPoly **r_mpoly)
{
MFace *mf;
MLoop *ml, *mloop;
@@ -3514,10 +3403,11 @@ void BKE_mesh_polygons_flip(
/* update the hide flag for edges and faces from the corresponding
* flag in verts */
-void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert,
- const MLoop *mloop,
- MEdge *medge, const int totedge,
- MPoly *mpoly, const int totpoly)
+void BKE_mesh_flush_hidden_from_verts_ex(
+ const MVert *mvert,
+ const MLoop *mloop,
+ MEdge *medge, const int totedge,
+ MPoly *mpoly, const int totpoly)
{
int i, j;
@@ -3543,15 +3433,17 @@ void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert,
}
void BKE_mesh_flush_hidden_from_verts(Mesh *me)
{
- BKE_mesh_flush_hidden_from_verts_ex(me->mvert, me->mloop,
- me->medge, me->totedge,
- me->mpoly, me->totpoly);
+ BKE_mesh_flush_hidden_from_verts_ex(
+ me->mvert, me->mloop,
+ me->medge, me->totedge,
+ me->mpoly, me->totpoly);
}
-void BKE_mesh_flush_hidden_from_polys_ex(MVert *mvert,
- const MLoop *mloop,
- MEdge *medge, const int UNUSED(totedge),
- const MPoly *mpoly, const int totpoly)
+void BKE_mesh_flush_hidden_from_polys_ex(
+ MVert *mvert,
+ const MLoop *mloop,
+ MEdge *medge, const int UNUSED(totedge),
+ const MPoly *mpoly, const int totpoly)
{
const MPoly *mp;
int i;
@@ -3584,18 +3476,20 @@ void BKE_mesh_flush_hidden_from_polys_ex(MVert *mvert,
}
void BKE_mesh_flush_hidden_from_polys(Mesh *me)
{
- BKE_mesh_flush_hidden_from_polys_ex(me->mvert, me->mloop,
- me->medge, me->totedge,
- me->mpoly, me->totpoly);
+ BKE_mesh_flush_hidden_from_polys_ex(
+ me->mvert, me->mloop,
+ me->medge, me->totedge,
+ me->mpoly, me->totpoly);
}
/**
* simple poly -> vert/edge selection.
*/
-void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert,
- const MLoop *mloop,
- MEdge *medge, const int totedge,
- const MPoly *mpoly, const int totpoly)
+void BKE_mesh_flush_select_from_polys_ex(
+ MVert *mvert, const int totvert,
+ const MLoop *mloop,
+ MEdge *medge, const int totedge,
+ const MPoly *mpoly, const int totpoly)
{
MVert *mv;
MEdge *med;
@@ -3629,16 +3523,18 @@ void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert,
}
void BKE_mesh_flush_select_from_polys(Mesh *me)
{
- BKE_mesh_flush_select_from_polys_ex(me->mvert, me->totvert,
- me->mloop,
- me->medge, me->totedge,
- me->mpoly, me->totpoly);
+ BKE_mesh_flush_select_from_polys_ex(
+ me->mvert, me->totvert,
+ me->mloop,
+ me->medge, me->totedge,
+ me->mpoly, me->totpoly);
}
-void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(totvert),
- const MLoop *mloop,
- MEdge *medge, const int totedge,
- MPoly *mpoly, const int totpoly)
+void BKE_mesh_flush_select_from_verts_ex(
+ const MVert *mvert, const int UNUSED(totvert),
+ const MLoop *mloop,
+ MEdge *medge, const int totedge,
+ MPoly *mpoly, const int totpoly)
{
MEdge *med;
MPoly *mp;
@@ -3683,10 +3579,11 @@ void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(to
}
void BKE_mesh_flush_select_from_verts(Mesh *me)
{
- BKE_mesh_flush_select_from_verts_ex(me->mvert, me->totvert,
- me->mloop,
- me->medge, me->totedge,
- me->mpoly, me->totpoly);
+ BKE_mesh_flush_select_from_verts_ex(
+ me->mvert, me->totvert,
+ me->mloop,
+ me->medge, me->totedge,
+ me->mpoly, me->totpoly);
}
/** \} */
@@ -3714,7 +3611,7 @@ void BKE_mesh_calc_relative_deform(
const float (*vert_cos_dst)[3],
const float (*vert_cos_org)[3],
- float (*vert_cos_new)[3])
+ float (*vert_cos_new)[3])
{
const MPoly *mp;
int i;
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 0143125490e..5c9849f6b74 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -55,13 +55,13 @@
* but for now this replaces it because its unused. */
UvVertMap *BKE_mesh_uv_vert_map_create(
- struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv,
+ const MPoly *mpoly, const MLoop *mloop, const MLoopUV *mloopuv,
unsigned int totpoly, unsigned int totvert,
const float limit[2], const bool selected, const bool use_winding)
{
UvVertMap *vmap;
UvMapVert *buf;
- MPoly *mp;
+ const MPoly *mp;
unsigned int a;
int i, totuv, nverts;
@@ -103,8 +103,8 @@ UvVertMap *BKE_mesh_uv_vert_map_create(
nverts = mp->totloop;
for (i = 0; i < nverts; i++) {
- buf->tfindex = (unsigned char)i;
- buf->f = a;
+ buf->loop_of_poly_index = (unsigned short)i;
+ buf->poly_index = a;
buf->separate = 0;
buf->next = vmap->vert[mloop[mp->loopstart + i].v];
vmap->vert[mloop[mp->loopstart + i].v] = buf;
@@ -126,7 +126,8 @@ UvVertMap *BKE_mesh_uv_vert_map_create(
for (a = 0; a < totvert; a++) {
UvMapVert *newvlist = NULL, *vlist = vmap->vert[a];
UvMapVert *iterv, *v, *lastv, *next;
- float *uv, *uv2, uvdiff[2];
+ const float *uv, *uv2;
+ float uvdiff[2];
while (vlist) {
v = vlist;
@@ -134,19 +135,19 @@ UvVertMap *BKE_mesh_uv_vert_map_create(
v->next = newvlist;
newvlist = v;
- uv = mloopuv[mpoly[v->f].loopstart + v->tfindex].uv;
+ uv = mloopuv[mpoly[v->poly_index].loopstart + v->loop_of_poly_index].uv;
lastv = NULL;
iterv = vlist;
while (iterv) {
next = iterv->next;
- uv2 = mloopuv[mpoly[iterv->f].loopstart + iterv->tfindex].uv;
+ uv2 = mloopuv[mpoly[iterv->poly_index].loopstart + iterv->loop_of_poly_index].uv;
sub_v2_v2v2(uvdiff, uv2, uv);
if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1] &&
- (!use_winding || winding[iterv->f] == winding[v->f]))
+ (!use_winding || winding[iterv->poly_index] == winding[v->poly_index]))
{
if (lastv) lastv->next = next;
else vlist = next;
@@ -243,9 +244,10 @@ static void mesh_vert_poly_or_loop_map_create(
* Generates a map where the key is the vertex and the value is a list of polys that use that vertex as a corner.
* The lists are allocated from one memory pool.
*/
-void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
- const MPoly *mpoly, const MLoop *mloop,
- int totvert, int totpoly, int totloop)
+void BKE_mesh_vert_poly_map_create(
+ MeshElemMap **r_map, int **r_mem,
+ const MPoly *mpoly, const MLoop *mloop,
+ int totvert, int totpoly, int totloop)
{
mesh_vert_poly_or_loop_map_create(r_map, r_mem, mpoly, mloop, totvert, totpoly, totloop, false);
}
@@ -254,9 +256,10 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
* Generates a map where the key is the vertex and the value is a list of loops that use that vertex as a corner.
* The lists are allocated from one memory pool.
*/
-void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map, int **r_mem,
- const MPoly *mpoly, const MLoop *mloop,
- int totvert, int totpoly, int totloop)
+void BKE_mesh_vert_loop_map_create(
+ MeshElemMap **r_map, int **r_mem,
+ const MPoly *mpoly, const MLoop *mloop,
+ int totvert, int totpoly, int totloop)
{
mesh_vert_poly_or_loop_map_create(r_map, r_mem, mpoly, mloop, totvert, totpoly, totloop, true);
}
@@ -310,8 +313,9 @@ void BKE_mesh_vert_looptri_map_create(
* Generates a map where the key is the vertex and the value is a list of edges that use that vertex as an endpoint.
* The lists are allocated from one memory pool.
*/
-void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
- const MEdge *medge, int totvert, int totedge)
+void BKE_mesh_vert_edge_map_create(
+ MeshElemMap **r_map, int **r_mem,
+ const MEdge *medge, int totvert, int totedge)
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, "vert-edge map");
int *indices = MEM_mallocN(sizeof(int[2]) * (size_t)totedge, "vert-edge map mem");
@@ -397,10 +401,11 @@ void BKE_mesh_vert_edge_vert_map_create(
* Loops indices of a same poly are contiguous and in winding order.
* The lists are allocated from one memory pool.
*/
-void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, int **r_mem,
- const MEdge *UNUSED(medge), const int totedge,
- const MPoly *mpoly, const int totpoly,
- const MLoop *mloop, const int totloop)
+void BKE_mesh_edge_loop_map_create(
+ MeshElemMap **r_map, int **r_mem,
+ const MEdge *UNUSED(medge), const int totedge,
+ const MPoly *mpoly, const int totpoly,
+ const MLoop *mloop, const int totloop)
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totedge, "edge-poly map");
int *indices = MEM_mallocN(sizeof(int) * (size_t)totloop * 2, "edge-poly map mem");
@@ -450,10 +455,11 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, int **r_mem,
* Generates a map where the key is the edge and the value is a list of polygons that use that edge.
* The lists are allocated from one memory pool.
*/
-void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem,
- const MEdge *UNUSED(medge), const int totedge,
- const MPoly *mpoly, const int totpoly,
- const MLoop *mloop, const int totloop)
+void BKE_mesh_edge_poly_map_create(
+ MeshElemMap **r_map, int **r_mem,
+ const MEdge *UNUSED(medge), const int totedge,
+ const MPoly *mpoly, const int totpoly,
+ const MLoop *mloop, const int totloop)
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totedge, "edge-poly map");
int *indices = MEM_mallocN(sizeof(int) * (size_t)totloop, "edge-poly map mem");
@@ -509,9 +515,10 @@ void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem,
* ``totfinal`` could be ``tottessface`` and ``final_origindex`` its ORIGINDEX customdata.
* This would allow an MPoly to loop over its tessfaces.
*/
-void BKE_mesh_origindex_map_create(MeshElemMap **r_map, int **r_mem,
- const int totsource,
- const int *final_origindex, const int totfinal)
+void BKE_mesh_origindex_map_create(
+ MeshElemMap **r_map, int **r_mem,
+ const int totsource,
+ const int *final_origindex, const int totfinal)
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totsource, "poly-tessface map");
int *indices = MEM_mallocN(sizeof(int) * (size_t)totfinal, "poly-tessface map mem");
@@ -632,8 +639,9 @@ static void poly_edge_loop_islands_calc(
}
if (!edge_poly_map) {
- BKE_mesh_edge_poly_map_create(&edge_poly_map, &edge_poly_mem,
- medge, totedge, mpoly, totpoly, mloop, totloop);
+ BKE_mesh_edge_poly_map_create(
+ &edge_poly_map, &edge_poly_mem,
+ medge, totedge, mpoly, totpoly, mloop, totloop);
}
poly_groups = MEM_callocN(sizeof(int) * (size_t)totpoly, __func__);
@@ -786,10 +794,11 @@ static bool poly_is_island_boundary_smooth_cb(
* (0 being used as 'invalid' flag).
* Note it's callers's responsibility to MEM_freeN returned array.
*/
-int *BKE_mesh_calc_smoothgroups(const MEdge *medge, const int totedge,
- const MPoly *mpoly, const int totpoly,
- const MLoop *mloop, const int totloop,
- int *r_totgroup, const bool use_bitflags)
+int *BKE_mesh_calc_smoothgroups(
+ const MEdge *medge, const int totedge,
+ const MPoly *mpoly, const int totpoly,
+ const MLoop *mloop, const int totloop,
+ int *r_totgroup, const bool use_bitflags)
{
int *poly_groups = NULL;
@@ -987,21 +996,23 @@ static bool mesh_calc_islands_loop_poly_uv(
BKE_mesh_loop_islands_clear(r_island_store);
BKE_mesh_loop_islands_init(r_island_store, MISLAND_TYPE_LOOP, totloop, MISLAND_TYPE_POLY, MISLAND_TYPE_EDGE);
- BKE_mesh_edge_poly_map_create(&edge_poly_map, &edge_poly_mem,
- edges, totedge, polys, totpoly, loops, totloop);
+ BKE_mesh_edge_poly_map_create(
+ &edge_poly_map, &edge_poly_mem,
+ edges, totedge, polys, totpoly, loops, totloop);
if (luvs) {
- BKE_mesh_edge_loop_map_create(&edge_loop_map, &edge_loop_mem,
- edges, totedge, polys, totpoly, loops, totloop);
+ BKE_mesh_edge_loop_map_create(
+ &edge_loop_map, &edge_loop_mem,
+ edges, totedge, polys, totpoly, loops, totloop);
edge_boundary_check_data.loops = loops;
edge_boundary_check_data.luvs = luvs;
edge_boundary_check_data.edge_loop_map = edge_loop_map;
}
poly_edge_loop_islands_calc(
- edges, totedge, polys, totpoly, loops, totloop, edge_poly_map, false,
- mesh_check_island_boundary_uv, luvs ? &edge_boundary_check_data : NULL,
- &poly_groups, &num_poly_groups, &edge_borders, &num_edge_borders);
+ edges, totedge, polys, totpoly, loops, totloop, edge_poly_map, false,
+ mesh_check_island_boundary_uv, luvs ? &edge_boundary_check_data : NULL,
+ &poly_groups, &num_poly_groups, &edge_borders, &num_edge_borders);
if (!num_poly_groups) {
/* Should never happen... */
@@ -1051,8 +1062,9 @@ static bool mesh_calc_islands_loop_poly_uv(
}
}
- BKE_mesh_loop_islands_add(r_island_store, num_lidx, loop_indices, num_pidx, poly_indices,
- num_einnercuts, edge_innercut_indices);
+ BKE_mesh_loop_islands_add(
+ r_island_store, num_lidx, loop_indices, num_pidx, poly_indices,
+ num_einnercuts, edge_innercut_indices);
}
MEM_freeN(edge_poly_map);
@@ -1089,7 +1101,7 @@ bool BKE_mesh_calc_islands_loop_poly_edgeseam(
MeshIslandStore *r_island_store)
{
return mesh_calc_islands_loop_poly_uv(
- verts, totvert, edges, totedge, polys, totpoly, loops, totloop, NULL, r_island_store);
+ verts, totvert, edges, totedge, polys, totpoly, loops, totloop, NULL, r_island_store);
}
/**
@@ -1113,7 +1125,7 @@ bool BKE_mesh_calc_islands_loop_poly_uvmap(
{
BLI_assert(luvs != NULL);
return mesh_calc_islands_loop_poly_uv(
- verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store);
+ verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store);
}
/** \} */
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index 27ba7e76fa3..d49ca507e02 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -383,9 +383,10 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, const int *vtargetmap, const int tot_vtar
/* Can we optimise by reusing an old pmap ? How do we know an old pmap is stale ? */
/* When called by MOD_array.c, the cddm has just been created, so it has no valid pmap. */
- BKE_mesh_vert_poly_map_create(&poly_map, &poly_map_mem,
- mesh->mpoly, mesh->mloop,
- totvert, totpoly, totloop);
+ BKE_mesh_vert_poly_map_create(
+ &poly_map, &poly_map_mem,
+ mesh->mpoly, mesh->mloop,
+ totvert, totpoly, totloop);
} /* done preparing for fast poly compare */
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index c882cc0a7fa..bf98b8040e3 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -666,8 +666,9 @@ void BKE_mesh_remap_calc_edges_from_mesh(
v_dst_to_src_map[i].hit_dist = -1.0f;
}
- BKE_mesh_vert_edge_map_create(&vert_to_edge_src_map, &vert_to_edge_src_map_mem,
- edges_src, num_verts_src, num_edges_src);
+ BKE_mesh_vert_edge_map_create(
+ &vert_to_edge_src_map, &vert_to_edge_src_map_mem,
+ edges_src, num_verts_src, num_edges_src);
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_VERTS, 2);
nearest.index = -1;
@@ -926,8 +927,9 @@ void BKE_mesh_remap_calc_edges_from_mesh(
indices[sources_num] = j;
sources_num++;
}
- mesh_remap_item_define(r_map, i, hit_dist_accum / totweights, 0,
- sources_num, indices, weights);
+ mesh_remap_item_define(
+ r_map, i, hit_dist_accum / totweights, 0,
+ sources_num, indices, weights);
}
else {
/* No source for this dest edge! */
@@ -1141,8 +1143,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
BLI_AStarGraph *as_graphdata = NULL;
BLI_AStarSolution as_solution = {0};
- const int isld_steps_src = islands_precision_src ?
- max_ii((int)(ASTAR_STEPS_MAX * islands_precision_src + 0.499f), 1) : 0;
+ const int isld_steps_src = (
+ islands_precision_src ?
+ max_ii((int)(ASTAR_STEPS_MAX * islands_precision_src + 0.499f), 1) : 0);
float (*poly_nors_src)[3] = NULL;
float (*loop_nors_src)[3] = NULL;
@@ -1210,8 +1213,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
}
if (dirty_nors_dst || do_poly_nors_dst) {
- BKE_mesh_calc_normals_poly(verts_dst, NULL, numverts_dst, loops_dst, polys_dst,
- numloops_dst, numpolys_dst, poly_nors_dst, true);
+ BKE_mesh_calc_normals_poly(
+ verts_dst, NULL, numverts_dst, loops_dst, polys_dst,
+ numloops_dst, numpolys_dst, poly_nors_dst, true);
}
}
if (need_lnors_dst) {
@@ -1225,10 +1229,11 @@ void BKE_mesh_remap_calc_loops_from_mesh(
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
}
if (dirty_nors_dst || do_loop_nors_dst) {
- BKE_mesh_normals_loop_split(verts_dst, numverts_dst, edges_dst, numedges_dst,
- loops_dst, loop_nors_dst, numloops_dst,
- polys_dst, (const float (*)[3])poly_nors_dst, numpolys_dst,
- use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL);
+ BKE_mesh_normals_loop_split(
+ verts_dst, numverts_dst, edges_dst, numedges_dst,
+ loops_dst, loop_nors_dst, numloops_dst,
+ polys_dst, (const float (*)[3])poly_nors_dst, numpolys_dst,
+ use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL);
}
}
if (need_pnors_src || need_lnors_src) {
@@ -1249,17 +1254,20 @@ void BKE_mesh_remap_calc_loops_from_mesh(
}
if (use_from_vert) {
- BKE_mesh_vert_loop_map_create(&vert_to_loop_map_src, &vert_to_loop_map_src_buff,
- polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src);
+ BKE_mesh_vert_loop_map_create(
+ &vert_to_loop_map_src, &vert_to_loop_map_src_buff,
+ polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src);
if (mode & MREMAP_USE_POLY) {
- BKE_mesh_vert_poly_map_create(&vert_to_poly_map_src, &vert_to_poly_map_src_buff,
- polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src);
+ BKE_mesh_vert_poly_map_create(
+ &vert_to_poly_map_src, &vert_to_poly_map_src_buff,
+ polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src);
}
}
/* Needed for islands (or plain mesh) to AStar graph conversion. */
- BKE_mesh_edge_poly_map_create(&edge_to_poly_map_src, &edge_to_poly_map_src_buff,
- edges_src, num_edges_src, polys_src, num_polys_src, loops_src, num_loops_src);
+ BKE_mesh_edge_poly_map_create(
+ &edge_to_poly_map_src, &edge_to_poly_map_src_buff,
+ edges_src, num_edges_src, polys_src, num_polys_src, loops_src, num_loops_src);
if (use_from_vert) {
loop_to_poly_map_src = MEM_mallocN(sizeof(*loop_to_poly_map_src) * (size_t)num_loops_src, __func__);
poly_cents_src = MEM_mallocN(sizeof(*poly_cents_src) * (size_t)num_polys_src, __func__);
@@ -1339,8 +1347,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
}
}
}
- bvhtree_from_mesh_verts_ex(&treedata[tindex], verts_src, num_verts_src, false,
- verts_active, num_verts_active, 0.0, 2, 6);
+ bvhtree_from_mesh_verts_ex(
+ &treedata[tindex], verts_src, num_verts_src, false,
+ verts_active, num_verts_active, 0.0, 2, 6);
}
MEM_freeN(verts_active);
@@ -1456,13 +1465,15 @@ void BKE_mesh_remap_calc_loops_from_mesh(
BLI_assert(index_src != -1);
const float dot = dot_v3v3(nors_src[index_src], *nor_dst);
- pidx_src = (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
- loop_to_poly_map_src[index_src] : index_src;
+ pidx_src = (
+ (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
+ loop_to_poly_map_src[index_src] : index_src);
/* WARNING! This is not the *real* lidx_src in case of POLYNOR, we only use it
* to check we stay on current island (all loops from a given poly are
* on same island!). */
- lidx_src = (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
- index_src : polys_src[pidx_src].loopstart;
+ lidx_src = (
+ (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
+ index_src : polys_src[pidx_src].loopstart);
/* A same vert may be at the boundary of several islands! Hence, we have to ensure
* poly/loop we are currently considering *belongs* to current island! */
@@ -1481,7 +1492,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(
if (!pcent_dst_valid) {
BKE_mesh_calc_poly_center(
- mp_dst, &loops_dst[mp_dst->loopstart], verts_dst, pcent_dst);
+ mp_dst, &loops_dst[mp_dst->loopstart], verts_dst, pcent_dst);
pcent_dst_valid = true;
}
pcent_src = poly_cents_src[pidx_src];
@@ -1712,8 +1723,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
BLI_space_transform_apply(space_transform, tmp_co);
}
- pidx_src = use_islands ? best_island->indices[last_valid_pidx_isld_src] :
- last_valid_pidx_isld_src;
+ pidx_src = (
+ use_islands ? best_island->indices[last_valid_pidx_isld_src] :
+ last_valid_pidx_isld_src);
mp_src = &polys_src[pidx_src];
ml_src = &loops_src[mp_src->loopstart];
for (j = 0; j < mp_src->totloop; j++, ml_src++) {
@@ -1797,8 +1809,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
BLI_space_transform_apply(space_transform, tmp_co);
}
- pidx_src = use_islands ? best_island->indices[last_valid_pidx_isld_src] :
- last_valid_pidx_isld_src;
+ pidx_src = (
+ use_islands ? best_island->indices[last_valid_pidx_isld_src] :
+ last_valid_pidx_isld_src);
mp_src = &polys_src[pidx_src];
/* Create that one on demand. */
@@ -1947,8 +1960,9 @@ void BKE_mesh_remap_calc_polys_from_mesh(
CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
}
if (dirty_nors_dst) {
- BKE_mesh_calc_normals_poly(verts_dst, NULL, numverts_dst, loops_dst, polys_dst, numloops_dst, numpolys_dst,
- poly_nors_dst, true);
+ BKE_mesh_calc_normals_poly(
+ verts_dst, NULL, numverts_dst, loops_dst, polys_dst, numloops_dst, numpolys_dst,
+ poly_nors_dst, true);
}
}
@@ -2131,8 +2145,9 @@ void BKE_mesh_remap_calc_polys_from_mesh(
tri_vidx_2d[1][2] = 3;
}
else {
- BLI_polyfill_calc(poly_vcos_2d, (unsigned int)mp->totloop, -1,
- (unsigned int (*)[3])tri_vidx_2d);
+ BLI_polyfill_calc(
+ poly_vcos_2d, (unsigned int)mp->totloop, -1,
+ (unsigned int (*)[3])tri_vidx_2d);
}
for (j = 0; j < tris_num; j++) {
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index 07c354559b8..a3fc422ade7 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -246,9 +246,10 @@ static void mesh_runtime_debug_info_layers(
const char *structname;
int structnum;
CustomData_file_write_info(type, &structname, &structnum);
- BLI_dynstr_appendf(dynstr,
- " dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
- name, structname, type, (const void *)pt, size, pt_size);
+ BLI_dynstr_appendf(
+ dynstr,
+ " dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
+ name, structname, type, (const void *)pt, size, pt_size);
}
}
}
@@ -346,21 +347,21 @@ bool BKE_mesh_runtime_is_valid(Mesh *me_eval)
}
is_valid &= BKE_mesh_validate_all_customdata(
- &me_eval->vdata, &me_eval->edata, &me_eval->ldata, &me_eval->pdata,
- false, /* setting mask here isn't useful, gives false positives */
- do_verbose, do_fixes,
- &changed);
+ &me_eval->vdata, &me_eval->edata, &me_eval->ldata, &me_eval->pdata,
+ false, /* setting mask here isn't useful, gives false positives */
+ do_verbose, do_fixes,
+ &changed);
is_valid &= BKE_mesh_validate_arrays(
- me_eval,
- me_eval->mvert, me_eval->totvert,
- me_eval->medge, me_eval->totedge,
- me_eval->mface, me_eval->totface,
- me_eval->mloop, me_eval->totloop,
- me_eval->mpoly, me_eval->totpoly,
- me_eval->dvert,
- do_verbose, do_fixes,
- &changed);
+ me_eval,
+ me_eval->mvert, me_eval->totvert,
+ me_eval->medge, me_eval->totedge,
+ me_eval->mface, me_eval->totface,
+ me_eval->mloop, me_eval->totloop,
+ me_eval->mpoly, me_eval->totpoly,
+ me_eval->dvert,
+ do_verbose, do_fixes,
+ &changed);
BLI_assert(changed == false);
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index 05a5a5e8703..9d6d0b90959 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -91,8 +91,9 @@ static void get_position(const SMikkTSpaceContext *pContext, float r_co[3], cons
copy_v3_v3(r_co, p_mesh->mverts[p_mesh->mloops[loop_idx].v].co);
}
-static void get_texture_coordinate(const SMikkTSpaceContext *pContext, float r_uv[2], const int face_idx,
- const int vert_idx)
+static void get_texture_coordinate(
+ const SMikkTSpaceContext *pContext, float r_uv[2], const int face_idx,
+ const int vert_idx)
{
BKEMeshToTangent *p_mesh = (BKEMeshToTangent *)pContext->m_pUserData;
copy_v2_v2(r_uv, p_mesh->luvs[p_mesh->mpolys[face_idx].loopstart + vert_idx].uv);
@@ -104,8 +105,9 @@ static void get_normal(const SMikkTSpaceContext *pContext, float r_no[3], const
copy_v3_v3(r_no, p_mesh->lnors[p_mesh->mpolys[face_idx].loopstart + vert_idx]);
}
-static void set_tspace(const SMikkTSpaceContext *pContext, const float fv_tangent[3], const float face_sign,
- const int face_idx, const int vert_idx)
+static void set_tspace(
+ const SMikkTSpaceContext *pContext, const float fv_tangent[3], const float face_sign,
+ const int face_idx, const int vert_idx)
{
BKEMeshToTangent *p_mesh = (BKEMeshToTangent *)pContext->m_pUserData;
float *p_res = p_mesh->tangents[p_mesh->mpolys[face_idx].loopstart + vert_idx];
@@ -192,8 +194,9 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh, const char *uvmap, float (*r_
return;
}
- BKE_mesh_calc_loop_tangent_single_ex(mesh->mvert, mesh->totvert, mesh->mloop, r_looptangents,
- loopnors, loopuvs, mesh->totloop, mesh->mpoly, mesh->totpoly, reports);
+ BKE_mesh_calc_loop_tangent_single_ex(
+ mesh->mvert, mesh->totvert, mesh->mloop, r_looptangents,
+ loopnors, loopuvs, mesh->totloop, mesh->mpoly, mesh->totpoly, reports);
}
/** \} */
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 0dca41e60e6..f974362e4be 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -212,15 +212,16 @@ static int search_polyloop_cmp(const void *v1, const void *v2)
*
* \return false if no changes needed to be made.
*/
-bool BKE_mesh_validate_arrays(Mesh *mesh,
- MVert *mverts, unsigned int totvert,
- MEdge *medges, unsigned int totedge,
- MFace *mfaces, unsigned int totface,
- MLoop *mloops, unsigned int totloop,
- MPoly *mpolys, unsigned int totpoly,
- MDeformVert *dverts, /* assume totvert length */
- const bool do_verbose, const bool do_fixes,
- bool *r_changed)
+bool BKE_mesh_validate_arrays(
+ Mesh *mesh,
+ MVert *mverts, unsigned int totvert,
+ MEdge *medges, unsigned int totedge,
+ MFace *mfaces, unsigned int totface,
+ MLoop *mloops, unsigned int totloop,
+ MPoly *mpolys, unsigned int totpoly,
+ MDeformVert *dverts, /* assume totvert length */
+ const bool do_verbose, const bool do_fixes,
+ bool *r_changed)
{
# define REMOVE_EDGE_TAG(_me) { _me->v2 = _me->v1; free_flag.edges = do_fixes; } (void)0
# define IS_REMOVED_EDGE(_me) (_me->v2 == _me->v1)
@@ -875,9 +876,10 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
return is_valid;
}
-static bool mesh_validate_customdata(CustomData *data, CustomDataMask mask,
- const bool do_verbose, const bool do_fixes,
- bool *r_change)
+static bool mesh_validate_customdata(
+ CustomData *data, CustomDataMask mask,
+ const bool do_verbose, const bool do_fixes,
+ bool *r_change)
{
bool is_valid = true;
bool has_fixes = false;
@@ -928,11 +930,12 @@ static bool mesh_validate_customdata(CustomData *data, CustomDataMask mask,
/**
* \returns is_valid.
*/
-bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata,
- CustomData *ldata, CustomData *pdata,
- const bool check_meshmask,
- const bool do_verbose, const bool do_fixes,
- bool *r_change)
+bool BKE_mesh_validate_all_customdata(
+ CustomData *vdata, CustomData *edata,
+ CustomData *ldata, CustomData *pdata,
+ const bool check_meshmask,
+ const bool do_verbose, const bool do_fixes,
+ bool *r_change)
{
bool is_valid = true;
bool is_change_v, is_change_e, is_change_l, is_change_p;
@@ -1229,9 +1232,10 @@ struct EdgeSort {
};
/* edges have to be added with lowest index first for sorting */
-static void to_edgesort(struct EdgeSort *ed,
- unsigned int v1, unsigned int v2,
- char is_loose, short is_draw)
+static void to_edgesort(
+ struct EdgeSort *ed,
+ unsigned int v1, unsigned int v2,
+ char is_loose, short is_draw)
{
if (v1 < v2) {
ed->v1 = v1; ed->v2 = v2;
@@ -1380,9 +1384,10 @@ void BKE_mesh_calc_edges_legacy(Mesh *me, const bool use_old)
MEdge *medge;
int totedge = 0;
- mesh_calc_edges_mdata(me->mvert, me->mface, me->mloop, me->mpoly,
- me->totvert, me->totface, me->totloop, me->totpoly,
- use_old, &medge, &totedge);
+ mesh_calc_edges_mdata(
+ me->mvert, me->mface, me->mloop, me->mpoly,
+ me->totvert, me->totface, me->totloop, me->totpoly,
+ use_old, &medge, &totedge);
if (totedge == 0) {
/* flag that mesh has edges */
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 4c2a58e7126..b877a08b6cf 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -293,7 +293,7 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData)
/* callback's can use this
* to avoid copying every member.
*/
-void modifier_copyData_generic(const ModifierData *md_src, ModifierData *md_dst)
+void modifier_copyData_generic(const ModifierData *md_src, ModifierData *md_dst, const int UNUSED(flag))
{
const ModifierTypeInfo *mti = modifierType_getInfo(md_src->type);
@@ -326,7 +326,7 @@ void modifier_copyData_ex(ModifierData *md, ModifierData *target, const int flag
target->flag = md->flag;
if (mti->copyData) {
- mti->copyData(md, target);
+ mti->copyData(md, target, flag);
}
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index f7cd2bd52dc..c81f5f425d8 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -3333,11 +3333,6 @@ void node_type_internal_links(bNodeType *ntype, void (*update_internal_links)(bN
ntype->update_internal_links = update_internal_links;
}
-void node_type_compatibility(struct bNodeType *ntype, short compatibility)
-{
- ntype->compatibility = compatibility;
-}
-
/* callbacks for undefined types */
static bool node_undefined_poll(bNodeType *UNUSED(ntype), bNodeTree *UNUSED(nodetree))
@@ -3437,6 +3432,7 @@ static void registerCompositNodes(void)
register_node_type_cmp_doubleedgemask();
register_node_type_cmp_keyingscreen();
register_node_type_cmp_keying();
+ register_node_type_cmp_cryptomatte();
register_node_type_cmp_translate();
register_node_type_cmp_rotate();
@@ -3525,6 +3521,7 @@ static void registerShaderNodes(void)
register_node_type_sh_bsdf_velvet();
register_node_type_sh_bsdf_toon();
register_node_type_sh_bsdf_hair();
+ register_node_type_sh_bsdf_hair_principled();
register_node_type_sh_emission();
register_node_type_sh_holdout();
register_node_type_sh_volume_absorption();
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8295fccc810..33ea13c9a38 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -165,10 +165,7 @@ void BKE_object_free_particlesystems(Object *ob)
void BKE_object_free_softbody(Object *ob)
{
- if (ob->soft) {
- sbFree(ob->soft);
- ob->soft = NULL;
- }
+ sbFree(ob);
}
void BKE_object_free_curve_cache(Object *ob)
@@ -275,7 +272,7 @@ void BKE_object_link_modifiers(Scene *scene, struct Object *ob_dst, const struct
switch (md->type) {
case eModifierType_Softbody:
- BKE_object_copy_softbody(ob_dst, ob_src);
+ BKE_object_copy_softbody(ob_dst, ob_src, 0);
break;
case eModifierType_Skin:
/* ensure skin-node customdata exists */
@@ -427,6 +424,8 @@ void BKE_object_free(Object *ob)
{
BKE_animdata_free((ID *)ob, false);
+ DRW_drawdata_free((ID *)ob);
+
/* BKE_<id>_free shall never touch to ID->us. Never ever. */
BKE_object_free_modifiers(ob, LIB_ID_CREATE_NO_USER_REFCOUNT);
@@ -452,17 +451,7 @@ void BKE_object_free(Object *ob)
BKE_rigidbody_free_object(ob, NULL);
BKE_rigidbody_free_constraint(ob);
- if (ob->soft) {
- sbFree(ob->soft);
- ob->soft = NULL;
- }
-
- for (ObjectEngineData *oed = ob->drawdata.first; oed; oed = oed->next) {
- if (oed->free != NULL) {
- oed->free(oed);
- }
- }
- BLI_freelistN(&ob->drawdata);
+ sbFree(ob);
BKE_sculptsession_free(ob);
@@ -659,7 +648,7 @@ static const char *get_obdata_defname(int type)
case OB_FONT: return DATA_("Text");
case OB_MBALL: return DATA_("Mball");
case OB_CAMERA: return DATA_("Camera");
- case OB_LAMP: return DATA_("Lamp");
+ case OB_LAMP: return DATA_("Light");
case OB_LATTICE: return DATA_("Lattice");
case OB_ARMATURE: return DATA_("Armature");
case OB_SPEAKER: return DATA_("Speaker");
@@ -725,6 +714,9 @@ void BKE_object_init(Object *ob)
ob->dt = OB_TEXTURE;
ob->empty_drawtype = OB_PLAINAXES;
ob->empty_drawsize = 1.0;
+ if (ob->type == OB_EMPTY) {
+ copy_v2_fl(ob->ima_ofs, -0.5f);
+ }
if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
ob->trackflag = OB_NEGZ;
@@ -836,11 +828,17 @@ Object *BKE_object_add_from(
return ob;
}
-SoftBody *copy_softbody(const SoftBody *sb, const int flag)
+void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src, const int flag)
{
+ SoftBody *sb = ob_src->soft;
SoftBody *sbn;
+ bool tagged_no_main = ob_dst->id.tag & LIB_TAG_NO_MAIN;
- if (sb == NULL) return(NULL);
+ ob_dst->softflag = ob_src->softflag;
+ if (sb == NULL) {
+ ob_dst->soft = NULL;
+ return;
+ }
sbn = MEM_dupallocN(sb);
@@ -873,12 +871,15 @@ SoftBody *copy_softbody(const SoftBody *sb, const int flag)
sbn->scratch = NULL;
- sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches, flag);
+ if (tagged_no_main == 0) {
+ sbn->shared = MEM_dupallocN(sb->shared);
+ sbn->shared->pointcache = BKE_ptcache_copy_list(&sbn->shared->ptcaches, &sb->shared->ptcaches, flag);
+ }
if (sb->effector_weights)
sbn->effector_weights = MEM_dupallocN(sb->effector_weights);
- return sbn;
+ ob_dst->soft = sbn;
}
ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys, const int flag)
@@ -967,14 +968,6 @@ void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src, const
}
}
-void BKE_object_copy_softbody(Object *ob_dst, const Object *ob_src)
-{
- if (ob_src->soft) {
- ob_dst->softflag = ob_src->softflag;
- ob_dst->soft = copy_softbody(ob_src->soft, 0);
- }
-}
-
static void copy_object_pose(Object *obn, const Object *ob, const int flag)
{
bPoseChannel *chan;
@@ -1157,7 +1150,7 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
*
* \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
*/
-void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_src, const int flag)
+void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, const int flag)
{
ModifierData *md;
@@ -1187,7 +1180,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
copy_object_pose(ob_dst, ob_src, flag_subdata);
/* backwards compat... non-armatures can get poses in older files? */
if (ob_src->type == OB_ARMATURE)
- BKE_pose_rebuild(ob_dst, ob_dst->data);
+ BKE_pose_rebuild(bmain, ob_dst, ob_dst->data);
}
defgroup_copy_list(&ob_dst->defbase, &ob_src->defbase);
BKE_object_facemap_copy_list(&ob_dst->fmaps, &ob_src->fmaps);
@@ -1202,7 +1195,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
ob_dst->pd->rng = MEM_dupallocN(ob_src->pd->rng);
}
}
- ob_dst->soft = copy_softbody(ob_src->soft, flag_subdata);
+ BKE_object_copy_softbody(ob_dst, ob_src, flag_subdata);
ob_dst->rigidbody_object = BKE_rigidbody_copy_object(ob_src, flag_subdata);
ob_dst->rigidbody_constraint = BKE_rigidbody_copy_constraint(ob_src, flag_subdata);
@@ -1212,7 +1205,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
ob_dst->derivedFinal = NULL;
BLI_listbase_clear(&ob_dst->gpulamp);
- BLI_listbase_clear(&ob_dst->drawdata);
+ BLI_listbase_clear((ListBase *)&ob_dst->drawdata);
BLI_listbase_clear(&ob_dst->pc_ids);
ob_dst->avs = ob_src->avs;
@@ -1366,7 +1359,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
/* local_object->proxy == pointer to library object, saved in files and read */
/* local_object->proxy_group == pointer to collection dupli-object, saved in files and read */
-void BKE_object_make_proxy(Object *ob, Object *target, Object *cob)
+void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob)
{
/* paranoia checks */
if (ID_IS_LINKED(ob) || !ID_IS_LINKED(target)) {
@@ -1441,7 +1434,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *cob)
if (target->type == OB_ARMATURE) {
copy_object_pose(ob, target, 0); /* data copy, object pointers in constraints */
BKE_pose_rest(ob->pose); /* clear all transforms in channels */
- BKE_pose_rebuild(ob, ob->data); /* set all internal links */
+ BKE_pose_rebuild(bmain, ob, ob->data); /* set all internal links */
armature_set_id_extern(ob);
}
@@ -2487,7 +2480,6 @@ void BKE_object_empty_draw_type_set(Object *ob, const int value)
ob->iuser->flag |= IMA_ANIM_ALWAYS;
ob->iuser->frames = 100;
ob->iuser->sfra = 1;
- ob->iuser->fie_ima = 2;
}
}
else {
@@ -2706,8 +2698,10 @@ void BKE_object_handle_update_ex(Depsgraph *depsgraph,
* with poses we do it ahead of BKE_object_where_is_calc to ensure animation
* is evaluated on the rebuilt pose, otherwise we get incorrect poses
* on file load */
- if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC))
- BKE_pose_rebuild(ob, ob->data);
+ if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) {
+ /* No need to pass bmain here, we assume we do not need to rebuild DEG from here... */
+ BKE_pose_rebuild(NULL, ob, ob->data);
+ }
}
}
/* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers,
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 7f3f916964a..ab0130019b8 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -36,6 +36,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
@@ -835,6 +836,35 @@ struct Ocean *BKE_ocean_add(void)
return oc;
}
+bool BKE_ocean_ensure(struct OceanModifierData *omd)
+{
+ if (omd->ocean) {
+ return false;
+ }
+
+ omd->ocean = BKE_ocean_add();
+ BKE_ocean_init_from_modifier(omd->ocean, omd);
+ return true;
+}
+
+void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd)
+{
+ short do_heightfield, do_chop, do_normals, do_jacobian;
+
+ do_heightfield = true;
+ do_chop = (omd->chop_amount > 0);
+ do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS);
+ do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
+
+ BKE_ocean_free_data(ocean);
+ BKE_ocean_init(ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution,
+ omd->spatial_size, omd->spatial_size,
+ omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
+ omd->depth, omd->time,
+ do_heightfield, do_chop, do_normals, do_jacobian,
+ omd->seed);
+}
+
void BKE_ocean_init(struct Ocean *o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp,
float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals,
short do_jacobian, int seed)
@@ -1511,4 +1541,16 @@ void BKE_ocean_bake(struct Ocean *UNUSED(o), struct OceanCache *UNUSED(och),
/* unused */
(void)update_cb;
}
+
+void BKE_ocean_init_from_modifier(struct Ocean *UNUSED(ocean), struct OceanModifierData const *UNUSED(omd))
+{
+}
+
#endif /* WITH_OCEANSIM */
+
+void BKE_ocean_free_modifier_cache(struct OceanModifierData *omd)
+{
+ BKE_ocean_free_cache(omd->oceancache);
+ omd->oceancache = NULL;
+ omd->cached = false;
+}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 404a1a656d9..07aa21f44ff 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -68,6 +68,7 @@
#include "BKE_subsurf.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "bmesh.h"
@@ -857,21 +858,12 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
}
/**
- * \param need_mask So taht the evaluated mesh that is returned has mask data.
+ * \param need_mask So that the evaluated mesh that is returned has mask data.
*/
void BKE_sculpt_update_mesh_elements(
Depsgraph *depsgraph, Scene *scene, Sculpt *sd, Object *ob,
bool need_pmap, bool need_mask)
{
- if (depsgraph == NULL) {
- /* Happens on file load.
- *
- * We do nothing in this case, it will be taken care about on depsgraph
- * evaluation.
- */
- return;
- }
-
SculptSession *ss = ob->sculpt;
Mesh *me = BKE_object_get_original_mesh(ob);
MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
@@ -947,13 +939,14 @@ void BKE_sculpt_update_mesh_elements(
if (ss->modifiers_active) {
if (!ss->orig_cos) {
+ Object *object_orig = DEG_get_original_object(ob);
int a;
BKE_sculptsession_free_deformMats(ss);
ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL);
- BKE_crazyspace_build_sculpt(depsgraph, scene, ob, &ss->deform_imats, &ss->deform_cos);
+ BKE_crazyspace_build_sculpt(depsgraph, scene, object_orig, &ss->deform_imats, &ss->deform_cos);
BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos, me->totvert);
for (a = 0; a < me->totvert; ++a) {
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 0a4cd3ec3c1..3e7a9b7ce24 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2077,7 +2077,7 @@ static void pbvh_node_check_mask_changed(PBVH *bvh, PBVHNode *node)
struct PBVHNodeDrawCallbackData {
- void (*draw_fn)(void *user_data, Gwn_Batch *batch);
+ void (*draw_fn)(void *user_data, GPUBatch *batch);
void *user_data;
bool fast;
};
@@ -2087,7 +2087,7 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v)
struct PBVHNodeDrawCallbackData *data = data_v;
if (!(node->flag & PBVH_FullyHidden)) {
- Gwn_Batch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast);
+ GPUBatch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast);
if (triangles != NULL) {
data->draw_fn(data->user_data, triangles);
}
@@ -2099,7 +2099,7 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v)
*/
void BKE_pbvh_draw_cb(
PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast,
- void (*draw_fn)(void *user_data, Gwn_Batch *batch), void *user_data)
+ void (*draw_fn)(void *user_data, GPUBatch *batch), void *user_data)
{
struct PBVHNodeDrawCallbackData draw_data = {
.fast = fast,
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index a8c6091124a..17e90d688a2 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1389,9 +1389,9 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
pid->ob= ob;
pid->calldata= sb;
pid->type= PTCACHE_TYPE_SOFTBODY;
- pid->cache= sb->pointcache;
- pid->cache_ptr= &sb->pointcache;
- pid->ptcaches= &sb->ptcaches;
+ pid->cache= sb->shared->pointcache;
+ pid->cache_ptr= &sb->shared->pointcache;
+ pid->ptcaches= &sb->shared->ptcaches;
pid->totpoint= pid->totwrite= ptcache_softbody_totpoint;
pid->error = ptcache_softbody_error;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index a38384f8f2b..3650fa21c1c 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -103,6 +103,8 @@
#include "RE_engine.h"
+#include "engines/eevee/eevee_lightcache.h"
+
#include "PIL_time.h"
#include "IMB_colormanagement.h"
@@ -111,7 +113,7 @@
#include "bmesh.h"
const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
-const char *RE_engine_id_BLENDER_WORKBENCH = "BLENDER_WORKBENCH";
+const char *RE_engine_id_BLENDER_OPENGL = "BLENDER_OPENGL";
const char *RE_engine_id_CYCLES = "CYCLES";
void free_avicodecdata(AviCodecData *acd)
@@ -316,6 +318,9 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
else {
sce_dst->preview = NULL;
}
+
+ sce_dst->eevee.light_cache = NULL;
+ /* TODO Copy the cache. */
}
Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
@@ -356,6 +361,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
curvemapping_copy_data(&sce_copy->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve);
+ /* viewport display settings */
+ sce_copy->display = sce->display;
+
/* tool settings */
sce_copy->toolsettings = BKE_toolsettings_copy(sce->toolsettings, 0);
@@ -511,6 +519,11 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
sce->master_collection = NULL;
}
+ if (sce->eevee.light_cache) {
+ EEVEE_lightcache_free(sce->eevee.light_cache);
+ sce->eevee.light_cache = NULL;
+ }
+
/* These are freed on doversion. */
BLI_assert(sce->layer_properties == NULL);
}
@@ -635,7 +648,7 @@ void BKE_scene_init(Scene *sce)
sce->toolsettings->uvcalc_flag = UVCALC_TRANSFORM_CORRECT;
sce->toolsettings->unwrapper = 1;
sce->toolsettings->select_thresh = 0.01f;
- sce->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE;
+ sce->toolsettings->gizmo_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE;
sce->toolsettings->selectmode = SCE_SELECT_VERTEX;
sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX;
@@ -810,10 +823,15 @@ void BKE_scene_init(Scene *sce)
sce->display.matcap_ssao_attenuation = 1.0f;
sce->display.matcap_ssao_samples = 16;
+ /* OpenGL Render. */
+ BKE_screen_view3d_shading_init(&sce->display.shading);
+
/* SceneEEVEE */
sce->eevee.gi_diffuse_bounces = 3;
sce->eevee.gi_cubemap_resolution = 512;
sce->eevee.gi_visibility_resolution = 32;
+ sce->eevee.gi_cubemap_draw_size = 0.3f;
+ sce->eevee.gi_irradiance_draw_size = 0.1f;
sce->eevee.taa_samples = 16;
sce->eevee.taa_render_samples = 64;
@@ -856,6 +874,8 @@ void BKE_scene_init(Scene *sce)
sce->eevee.shadow_cube_size = 512;
sce->eevee.shadow_cascade_size = 1024;
+ sce->eevee.light_cache = NULL;
+
sce->eevee.flag =
SCE_EEVEE_VOLUMETRIC_LIGHTS |
SCE_EEVEE_VOLUMETRIC_COLORED |
@@ -906,7 +926,7 @@ Object *BKE_scene_object_find_by_name(Scene *scene, const char *name)
/**
* Sets the active scene, mainly used when running in background mode (``--scene`` command line argument).
* This is also called to set the scene directly, bypassing windowing code.
- * Otherwise #WM_window_change_active_scene is used when changing scenes by the user.
+ * Otherwise #WM_window_set_active_scene is used when changing scenes by the user.
*/
void BKE_scene_set_background(Main *bmain, Scene *scene)
{
@@ -1268,7 +1288,7 @@ static void scene_armature_depsgraph_workaround(Main *bmain, Depsgraph *depsgrap
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->type == OB_ARMATURE && ob->adt && ob->adt->recalc & ADT_RECALC_ANIM) {
if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) {
- BKE_pose_rebuild(ob, ob->data);
+ BKE_pose_rebuild(bmain, ob, ob->data);
}
}
}
@@ -1293,7 +1313,7 @@ static bool check_rendered_viewport_visible(Main *bmain)
if (area->spacetype != SPACE_VIEW3D) {
continue;
}
- if (v3d->drawtype == OB_RENDER) {
+ if (v3d->shading.type == OB_RENDER) {
return true;
}
}
@@ -1527,6 +1547,11 @@ bool BKE_scene_uses_blender_eevee(const Scene *scene)
return STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE);
}
+bool BKE_scene_uses_blender_opengl(const Scene *scene)
+{
+ return STREQ(scene->r.engine, RE_engine_id_BLENDER_OPENGL);
+}
+
bool BKE_scene_uses_cycles(const Scene *scene)
{
return STREQ(scene->r.engine, RE_engine_id_CYCLES);
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 1c8a93981c7..f8d926a13ed 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -45,9 +45,10 @@
#include "DNA_view3d_types.h"
#include "DNA_workspace_types.h"
+#include "BLI_math_vector.h"
#include "BLI_listbase.h"
-#include "BLI_utildefines.h"
#include "BLI_rect.h"
+#include "BLI_utildefines.h"
#include "BKE_icons.h"
#include "BKE_idprop.h"
@@ -222,7 +223,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
BLI_listbase_clear(&newar->panels_category_active);
BLI_listbase_clear(&newar->ui_lists);
newar->visible = 0;
- newar->manipulator_map = NULL;
+ newar->gizmo_map = NULL;
newar->regiontimer = NULL;
newar->headerstr = NULL;
newar->draw_buffer = NULL;
@@ -324,18 +325,18 @@ void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID
}
/**
- * Avoid bad-level calls to #WM_manipulatormap_tag_refresh.
+ * Avoid bad-level calls to #WM_gizmomap_tag_refresh.
*/
-static void (*region_refresh_tag_manipulatormap_callback)(struct wmManipulatorMap *) = NULL;
+static void (*region_refresh_tag_gizmomap_callback)(struct wmGizmoMap *) = NULL;
-void BKE_region_callback_refresh_tag_manipulatormap_set(void (*callback)(struct wmManipulatorMap *))
+void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *))
{
- region_refresh_tag_manipulatormap_callback = callback;
+ region_refresh_tag_gizmomap_callback = callback;
}
-void BKE_screen_manipulator_tag_refresh(struct bScreen *sc)
+void BKE_screen_gizmo_tag_refresh(struct bScreen *sc)
{
- if (region_refresh_tag_manipulatormap_callback == NULL) {
+ if (region_refresh_tag_gizmomap_callback == NULL) {
return;
}
@@ -343,21 +344,21 @@ void BKE_screen_manipulator_tag_refresh(struct bScreen *sc)
ARegion *ar;
for (sa = sc->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->manipulator_map != NULL) {
- region_refresh_tag_manipulatormap_callback(ar->manipulator_map);
+ if (ar->gizmo_map != NULL) {
+ region_refresh_tag_gizmomap_callback(ar->gizmo_map);
}
}
}
}
/**
- * Avoid bad-level calls to #WM_manipulatormap_delete.
+ * Avoid bad-level calls to #WM_gizmomap_delete.
*/
-static void (*region_free_manipulatormap_callback)(struct wmManipulatorMap *) = NULL;
+static void (*region_free_gizmomap_callback)(struct wmGizmoMap *) = NULL;
-void BKE_region_callback_free_manipulatormap_set(void (*callback)(struct wmManipulatorMap *))
+void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *))
{
- region_free_manipulatormap_callback = callback;
+ region_free_gizmomap_callback = callback;
}
static void panel_list_free(ListBase *lb)
@@ -414,8 +415,8 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
}
}
- if (ar->manipulator_map != NULL) {
- region_free_manipulatormap_callback(ar->manipulator_map);
+ if (ar->gizmo_map != NULL) {
+ region_free_gizmomap_callback(ar->gizmo_map);
}
BLI_freelistN(&ar->ui_lists);
@@ -855,6 +856,21 @@ void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene)
}
}
+void BKE_screen_view3d_shading_init(View3DShading *shading)
+{
+ memset(shading, 0, sizeof(*shading));
+
+ shading->type = OB_SOLID;
+ shading->prev_type = OB_SOLID;
+ shading->flag = V3D_SHADING_SPECULAR_HIGHLIGHT;
+ shading->light = V3D_LIGHTING_STUDIO;
+ shading->shadow_intensity = 0.5f;
+ shading->xray_alpha = 0.5f;
+ shading->cavity_valley_factor = 1.0f;
+ shading->cavity_ridge_factor = 1.0f;
+ copy_v3_fl(shading->single_color, 0.8f);
+}
+
/* magic zoom calculation, no idea what
* it signifies, if you find out, tell me! -zr
*/
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index a61b71f50eb..d3429622573 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -3276,7 +3276,8 @@ SoftBody *sbNew(Scene *scene)
sb->shearstiff = 1.0f;
sb->solverflags |= SBSO_OLDERR;
- sb->pointcache = BKE_ptcache_add(&sb->ptcaches);
+ sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared");
+ sb->shared->pointcache = BKE_ptcache_add(&sb->shared->ptcaches);
if (!sb->effector_weights)
sb->effector_weights = BKE_add_effector_weights(NULL);
@@ -3287,14 +3288,26 @@ SoftBody *sbNew(Scene *scene)
}
/* frees all */
-void sbFree(SoftBody *sb)
+void sbFree(Object *ob)
{
+ SoftBody *sb = ob->soft;
+ if (sb == NULL) {
+ return;
+ }
+
free_softbody_intern(sb);
- BKE_ptcache_free_list(&sb->ptcaches);
- sb->pointcache = NULL;
+
+ if ((ob->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0) {
+ /* Only free shared data on non-CoW copies */
+ BKE_ptcache_free_list(&sb->shared->ptcaches);
+ sb->shared->pointcache = NULL;
+ MEM_freeN(sb->shared);
+ }
if (sb->effector_weights)
MEM_freeN(sb->effector_weights);
MEM_freeN(sb);
+
+ ob->soft = NULL;
}
void sbFreeSimulation(SoftBody *sb)
@@ -3601,7 +3614,7 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c
float dtime, timescale;
int framedelta, framenr, startframe, endframe;
int cache_result;
- cache= sb->pointcache;
+ cache= sb->shared->pointcache;
framenr= (int)cfra;
framedelta= framenr - cache->simframe;
@@ -3669,7 +3682,8 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c
}
/* try to read from cache */
- bool can_simulate = (framenr == sb->last_frame + 1) && !(cache->flag & PTCACHE_BAKED);
+ bool can_write_cache = DEG_is_active(depsgraph);
+ bool can_simulate = (framenr == sb->last_frame + 1) && !(cache->flag & PTCACHE_BAKED) && can_write_cache;
cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, can_simulate);
@@ -3680,7 +3694,7 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c
BKE_ptcache_validate(cache, framenr);
- if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
+ if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED && can_write_cache)
BKE_ptcache_write(&pid, framenr);
sb->last_frame = framenr;
@@ -3692,7 +3706,9 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c
}
else if (/*ob->id.lib || */(cache->flag & PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */
/* if baked and nothing in cache, do nothing */
- BKE_ptcache_invalidate(cache);
+ if (can_write_cache) {
+ BKE_ptcache_invalidate(cache);
+ }
return;
}
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index ebb23f8d5c6..5135362bd69 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -756,15 +756,19 @@ int BKE_sound_scene_playing(struct Scene *scene)
void BKE_sound_free_waveform(bSound *sound)
{
- SoundWaveform *waveform = sound->waveform;
- if (waveform) {
- if (waveform->data) {
- MEM_freeN(waveform->data);
+ if ((sound->tags & SOUND_TAGS_WAVEFORM_NO_RELOAD) == 0) {
+ SoundWaveform *waveform = sound->waveform;
+ if (waveform) {
+ if (waveform->data) {
+ MEM_freeN(waveform->data);
+ }
+ MEM_freeN(waveform);
}
- MEM_freeN(waveform);
- }
- sound->waveform = NULL;
+ sound->waveform = NULL;
+ }
+ /* This tag is only valid once. */
+ sound->tags &= ~SOUND_TAGS_WAVEFORM_NO_RELOAD;
}
void BKE_sound_read_waveform(bSound *sound, short *stop)
@@ -793,7 +797,7 @@ void BKE_sound_read_waveform(bSound *sound, short *stop)
}
MEM_freeN(waveform);
BLI_spin_lock(sound->spinlock);
- sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+ sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
BLI_spin_unlock(sound->spinlock);
return;
}
@@ -802,7 +806,7 @@ void BKE_sound_read_waveform(bSound *sound, short *stop)
BLI_spin_lock(sound->spinlock);
sound->waveform = waveform;
- sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+ sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
BLI_spin_unlock(sound->spinlock);
}
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 468a961627e..df5cc7551aa 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -120,7 +120,7 @@ static void studiolight_free(struct StudioLight *sl)
STUDIOLIGHT_DELETE_ICON(sl->icon_id_matcap_flipped);
#undef STUDIOLIGHT_DELETE_ICON
- for (int index = 0 ; index < 6 ; index ++) {
+ for (int index = 0; index < 6; index++) {
IMB_SAFE_FREE(sl->radiance_cubemap_buffers[index]);
}
GPU_TEXTURE_SAFE_FREE(sl->equirectangular_radiance_gputexture);
@@ -152,7 +152,7 @@ static struct StudioLight *studiolight_create(int flag)
sl->icon_id_irradiance = BKE_icon_ensure_studio_light(sl, STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE);
}
- for (int index = 0 ; index < 6 ; index ++) {
+ for (int index = 0; index < 6; index++) {
sl->radiance_cubemap_buffers[index] = NULL;
}
@@ -193,9 +193,9 @@ static void studiolight_calculate_radiance_buffer(
float xf;
float *color = colbuf;
- for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++, yf += add_y) {
+ for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y++, yf += add_y) {
xf = start_x;
- for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++, xf += add_x) {
+ for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x++, xf += add_x) {
direction[index_x] = xf;
direction[index_y] = yf;
direction[index_z] = z;
@@ -234,13 +234,13 @@ static void studiolight_create_equirectangular_radiance_gputexture(StudioLight *
float *offset4 = ibuf->rect_float;
float *offset3 = sl->gpu_matcap_3components;
- for (int i = 0 ; i < ibuf->x * ibuf->y; i++) {
+ for (int i = 0; i < ibuf->x * ibuf->y; i++) {
copy_v3_v3(offset3, offset4);
offset3 += 3;
offset4 += 4;
}
- sl->equirectangular_radiance_gputexture = GPU_texture_create_2D(
- ibuf->x, ibuf->y, GPU_R11F_G11F_B10F, sl->gpu_matcap_3components, error);
+ sl->equirectangular_radiance_gputexture = GPU_texture_create_nD(
+ ibuf->x, ibuf->y, 0, 2, sl->gpu_matcap_3components, GPU_R11F_G11F_B10F, GPU_DATA_FLOAT, 0, false, error);
}
else {
sl->equirectangular_radiance_gputexture = GPU_texture_create_2D(
@@ -336,8 +336,8 @@ BLI_INLINE void studiolight_evaluate_radiance_buffer(
float angle;
float *radiance_color = radiance_buffer->rect_float;
float direction[3];
- for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
- for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
+ for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y++) {
+ for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x++) {
// calculate light direction;
direction[zoffset] = zvalue;
direction[xoffset] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
@@ -345,7 +345,7 @@ BLI_INLINE void studiolight_evaluate_radiance_buffer(
normalize_v3(direction);
angle = fmax(0.0f, dot_v3v3(direction, normal));
madd_v3_v3fl(color, radiance_color, angle);
- (*hits) ++;
+ (*hits)++;
radiance_color += 4;
}
}
@@ -442,106 +442,64 @@ static void studiolight_calculate_spherical_harmonics_coefficient(StudioLight *s
switch (sh_component) {
/* L0 */
case 0:
- {
coef = 0.2822095f;
break;
- }
-
/* L1 */
case 1:
- {
coef = -0.488603f * nz * 2.0f / 3.0f;
break;
- }
case 2:
- {
coef = 0.488603f * ny * 2.0f / 3.0f;
break;
- }
case 3:
- {
coef = -0.488603f * nx * 2.0f / 3.0f;
break;
- }
-
/* L2 */
case 4:
- {
coef = 1.092548f * nx * nz * 1.0f / 4.0f;
break;
- }
case 5:
- {
coef = -1.092548f * nz * ny * 1.0f / 4.0f;
break;
- }
case 6:
- {
coef = 0.315392f * (3.0f * ny2 - 1.0f) * 1.0f / 4.0f;
break;
- }
case 7:
- {
coef = 1.092548f * nx * ny * 1.0f / 4.0f;
break;
- }
case 8:
- {
coef = 0.546274f * (nx2 - nz2) * 1.0f / 4.0f;
break;
- }
-
/* L4 */
case 9:
- {
coef = (2.5033429417967046f * nx * nz * (nx2 - nz2)) / -24.0f;
break;
- }
case 10:
- {
coef = (-1.7701307697799304f * nz * ny * (3.0f * nx2 - nz2)) / -24.0f;
break;
- }
case 11:
- {
- coef = (0.9461746957575601f * nz * nx * (-1.0f +7.0f*ny2)) / -24.0f;
+ coef = (0.9461746957575601f * nz * nx * (-1.0f + 7.0f * ny2)) / -24.0f;
break;
- }
case 12:
- {
coef = (-0.6690465435572892f * nz * ny * (-3.0f + 7.0f * ny2)) / -24.0f;
break;
- }
case 13:
- {
- coef = ((105.0f*ny4-90.0f*ny2+9.0f)/28.359261614f) / -24.0f;
+ coef = ((105.0f * ny4 - 90.0f * ny2 + 9.0f) / 28.359261614f) / -24.0f;
break;
- }
case 14:
- {
coef = (-0.6690465435572892f * nx * ny * (-3.0f + 7.0f * ny2)) / -24.0f;
break;
- }
case 15:
- {
coef = (0.9461746957575601f * (nx2 - nz2) * (-1.0f + 7.0f * ny2)) / -24.0f;
break;
- }
case 16:
- {
coef = (-1.7701307697799304f * nx * ny * (nx2 - 3.0f * nz2)) / -24.0f;
break;
- }
case 17:
- {
coef = (0.6258357354491761f * (nx4 - 6.0f * nz2 * nx2 + nz4)) / -24.0f;
break;
- }
-
default:
- {
coef = 0.0f;
- }
}
madd_v3_v3fl(sh, color, coef * weight);
@@ -621,7 +579,7 @@ static void studiolight_apply_spherical_harmonics_windowing(StudioLight *sl, flo
/* Apply windowing lambda */
index = 0;
- for (int level = 0; level <= STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL; level ++) {
+ for (int level = 0; level <= STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL; level++) {
float s = 1.0f / (1.0f + lambda * SQUARE(level) * SQUARE(level + 1.0f));
for (int m = -1; m <= level; m++) {
@@ -666,9 +624,9 @@ BLI_INLINE void studiolight_sample_spherical_harmonics(StudioLight *sl, float co
const float nz4 = SQUARE(nz2);
madd_v3_v3fl(color, sl->spherical_harmonics_coefs[9], 2.5033429417967046f * nx * nz * (nx2 - nz2));
madd_v3_v3fl(color, sl->spherical_harmonics_coefs[10], -1.7701307697799304f * nz * ny * (3.0f * nx2 - nz2));
- madd_v3_v3fl(color, sl->spherical_harmonics_coefs[11], 0.9461746957575601f * nz * nx * (-1.0f + 7.0f*ny2));
+ madd_v3_v3fl(color, sl->spherical_harmonics_coefs[11], 0.9461746957575601f * nz * nx * (-1.0f + 7.0f * ny2));
madd_v3_v3fl(color, sl->spherical_harmonics_coefs[12], -0.6690465435572892f * nz * ny * (-3.0f + 7.0f * ny2));
- madd_v3_v3fl(color, sl->spherical_harmonics_coefs[13], (105.0f*ny4-90.0f*ny2+9.0f)/28.359261614f);
+ madd_v3_v3fl(color, sl->spherical_harmonics_coefs[13], (105.0f * ny4 - 90.0f * ny2 + 9.0f) / 28.359261614f);
madd_v3_v3fl(color, sl->spherical_harmonics_coefs[14], -0.6690465435572892f * nx * ny * (-3.0f + 7.0f * ny2));
madd_v3_v3fl(color, sl->spherical_harmonics_coefs[15], 0.9461746957575601f * (nx2 - nz2) * (-1.0f + 7.0f * ny2));
madd_v3_v3fl(color, sl->spherical_harmonics_coefs[16], -1.7701307697799304f * nx * ny * (nx2 - 3.0f * nz2));
@@ -683,7 +641,7 @@ static void studiolight_calculate_diffuse_light(StudioLight *sl)
if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED);
- for (int comp = 0; comp < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; comp ++) {
+ for (int comp = 0; comp < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; comp++) {
studiolight_calculate_spherical_harmonics_coefficient(sl, comp);
}
@@ -705,8 +663,8 @@ static void studiolight_calculate_diffuse_light(StudioLight *sl)
static float texel_coord_solid_angle(float a_U, float a_V, int a_Size)
{
//scale up to [-1, 1] range (inclusive), offset by 0.5 to point to texel center.
- float u = (2.0f * ((float)a_U + 0.5f) / (float)a_Size ) - 1.0f;
- float v = (2.0f * ((float)a_V + 0.5f) / (float)a_Size ) - 1.0f;
+ float u = (2.0f * ((float)a_U + 0.5f) / (float)a_Size) - 1.0f;
+ float v = (2.0f * ((float)a_V + 0.5f) / (float)a_Size) - 1.0f;
float resolution_inv = 1.0f / a_Size;
@@ -729,8 +687,8 @@ BLI_INLINE void studiolight_evaluate_specular_radiance_buffer(
float angle;
float *radiance_color = radiance_buffer->rect_float;
float direction[3];
- for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
- for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
+ for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y++) {
+ for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x++) {
// calculate light direction;
float u = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
float v = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
@@ -823,10 +781,10 @@ static void studiolight_calculate_irradiance_equirectangular_image(StudioLight *
float *colbuf = MEM_mallocN(STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH * STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT * sizeof(float[4]), __func__);
float *color = colbuf;
- for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT ; y ++) {
+ for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT; y++) {
float yf = y / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT;
- for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH ; x ++) {
+ for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; x++) {
float xf = x / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH;
float dir[3];
equirectangular_to_direction(dir, xf, yf);
@@ -875,8 +833,8 @@ static void studiolight_calculate_light_direction(StudioLight *sl)
/* go over every pixel, determine light, if higher calc direction off the light */
float new_light;
float *color = ibuf->rect_float;
- for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT; y ++) {
- for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; x ++) {
+ for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT; y++) {
+ for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; x++) {
new_light = color[0] + color[1] + color[2];
if (new_light > best_light) {
float u = x / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH;
@@ -1037,7 +995,7 @@ static void studiolight_matcap_preview(uint *icon_buffer, StudioLight *sl, bool
if (flipped) {
fx = 1.0f - fx;
}
- nearest_interpolation_color(ibuf, NULL, color, fx * ibuf->x, fy * ibuf->y);
+ nearest_interpolation_color(ibuf, NULL, color, fx * ibuf->x - 1.0f, fy * ibuf->y - 1.0f);
uint alphamask = alpha_circle_mask(fx, fy, 0.5f - pixel_size, 0.5f);
diff --git a/source/blender/blenkernel/intern/subdiv.c b/source/blender/blenkernel/intern/subdiv.c
new file mode 100644
index 00000000000..794da2d3477
--- /dev/null
+++ b/source/blender/blenkernel/intern/subdiv.c
@@ -0,0 +1,119 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/subdiv.c
+ * \ingroup bke
+ */
+
+#include "BKE_subdiv.h"
+
+#include "BLI_utildefines.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "subdiv_converter.h"
+
+#ifdef WITH_OPENSUBDIV
+# include "opensubdiv_capi.h"
+# include "opensubdiv_converter_capi.h"
+# include "opensubdiv_evaluator_capi.h"
+# include "opensubdiv_topology_refiner_capi.h"
+#endif
+
+#ifdef WITH_OPENSUBDIV
+static void update_subdiv_after_topology_change(Subdiv *subdiv)
+{
+ /* Count ptex faces. */
+ subdiv->num_ptex_faces = subdiv->topology_refiner->getNumPtexFaces(
+ subdiv->topology_refiner);
+ /* Initialize offset of base faces in ptex indices. */
+ MEM_SAFE_FREE(subdiv->face_ptex_offset);
+ subdiv->face_ptex_offset = MEM_malloc_arrayN(subdiv->num_ptex_faces,
+ sizeof(int),
+ "subdiv ptex offset");
+ subdiv->topology_refiner->fillFacePtexIndexOffset(
+ subdiv->topology_refiner,
+ subdiv->face_ptex_offset);
+}
+#endif
+
+Subdiv *BKE_subdiv_new_from_converter(const SubdivSettings *settings,
+ struct OpenSubdiv_Converter *converter)
+{
+#ifdef WITH_OPENSUBDIV
+ SubdivStats stats;
+ BKE_subdiv_stats_init(&stats);
+ BKE_subdiv_stats_begin(&stats, SUBDIV_STATS_TOPOLOGY_REFINER_CREATION_TIME);
+ OpenSubdiv_TopologyRefinerSettings topology_refiner_settings;
+ topology_refiner_settings.level = settings->level;
+ topology_refiner_settings.is_adaptive = settings->is_adaptive;
+ struct OpenSubdiv_TopologyRefiner *osd_topology_refiner =
+ openSubdiv_createTopologyRefinerFromConverter(
+ converter, &topology_refiner_settings);
+ if (osd_topology_refiner == NULL) {
+ return NULL;
+ }
+ Subdiv *subdiv = MEM_callocN(sizeof(Subdiv), "subdiv from converetr");
+ subdiv->settings = *settings;
+ subdiv->topology_refiner = osd_topology_refiner;
+ subdiv->evaluator = NULL;
+ update_subdiv_after_topology_change(subdiv);
+ BKE_subdiv_stats_end(&stats, SUBDIV_STATS_TOPOLOGY_REFINER_CREATION_TIME);
+ subdiv->stats = stats;
+ return subdiv;
+#else
+ UNUSED_VARS(settings, converter);
+ return NULL;
+#endif
+}
+
+Subdiv *BKE_subdiv_new_from_mesh(const SubdivSettings *settings,
+ struct Mesh *mesh)
+{
+#ifdef WITH_OPENSUBDIV
+ OpenSubdiv_Converter converter;
+ BKE_subdiv_converter_init_for_mesh(&converter, settings, mesh);
+ Subdiv *subdiv = BKE_subdiv_new_from_converter(settings, &converter);
+ BKE_subdiv_converter_free(&converter);
+ return subdiv;
+#else
+ UNUSED_VARS(settings, mesh);
+ return NULL;
+#endif
+}
+
+void BKE_subdiv_free(Subdiv *subdiv)
+{
+#ifdef WITH_OPENSUBDIV
+ if (subdiv->evaluator != NULL) {
+ openSubdiv_deleteEvaluator(subdiv->evaluator);
+ }
+ if (subdiv->topology_refiner != NULL) {
+ openSubdiv_deleteTopologyRefiner(subdiv->topology_refiner);
+ }
+ MEM_SAFE_FREE(subdiv->face_ptex_offset);
+ MEM_freeN(subdiv);
+#endif
+}
diff --git a/source/blender/blenkernel/intern/subdiv_converter.c b/source/blender/blenkernel/intern/subdiv_converter.c
new file mode 100644
index 00000000000..f6dabfa1c80
--- /dev/null
+++ b/source/blender/blenkernel/intern/subdiv_converter.c
@@ -0,0 +1,65 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "subdiv_converter.h"
+
+#include "BLI_utildefines.h"
+
+#ifdef WITH_OPENSUBDIV
+# include "opensubdiv_converter_capi.h"
+#endif
+
+void BKE_subdiv_converter_free(struct OpenSubdiv_Converter *converter)
+{
+#ifdef WITH_OPENSUBDIV
+ if (converter->freeUserData) {
+ converter->freeUserData(converter);
+ }
+#else
+ UNUSED_VARS(converter);
+#endif
+}
+
+/*OpenSubdiv_FVarLinearInterpolation*/ int
+BKE_subdiv_converter_fvar_linear_from_settings(const SubdivSettings *settings)
+{
+#ifdef WITH_OPENSUBDIV
+ switch (settings->fvar_linear_interpolation) {
+ case SUBDIV_FVAR_LINEAR_INTERPOLATION_NONE:
+ return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
+ case SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY:
+ return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY;
+ case SUBDIV_FVAR_LINEAR_INTERPOLATION_BOUNDARIES:
+ return OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES;
+ case SUBDIV_FVAR_LINEAR_INTERPOLATION_ALL:
+ return OSD_FVAR_LINEAR_INTERPOLATION_ALL;
+ }
+ BLI_assert(!"Unknown fvar linear interpolation");
+ return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
+#else
+ UNUSED_VARS(settings);
+ return 0;
+#endif
+}
diff --git a/source/blender/blenkernel/intern/subdiv_converter.h b/source/blender/blenkernel/intern/subdiv_converter.h
new file mode 100644
index 00000000000..4c552a9164e
--- /dev/null
+++ b/source/blender/blenkernel/intern/subdiv_converter.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.
+ *
+ * The Original Code is Copyright (C) 2018 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __SUBDIV_CONVERTER_H__
+#define __SUBDIV_CONVERTER_H__
+
+#include "BKE_subdiv.h"
+
+/* NOTE: Was initially used to get proper enumerator types, but this makes
+ * it tricky to compile without OpenSubdiv.
+ */
+/* #include "opensubdiv_converter_capi.h" */
+
+struct Mesh;
+struct OpenSubdiv_Converter;
+struct SubdivSettings;
+
+void BKE_subdiv_converter_init_for_mesh(struct OpenSubdiv_Converter *converter,
+ const struct SubdivSettings *settings,
+ const struct Mesh *mesh);
+
+/* NOTE: Frees converter data, but not converter itself. This means, that if
+ * converter was allocated on heap, it is up to the user to free that memory.
+ */
+void BKE_subdiv_converter_free(struct OpenSubdiv_Converter *converter);
+
+/* ============================ INTERNAL HELPERS ============================ */
+
+/* TODO(sergey): Find a way to make it OpenSubdiv_FVarLinearInterpolation,
+ * without breaking compilation without OpenSubdiv.
+ */
+int BKE_subdiv_converter_fvar_linear_from_settings(
+ const SubdivSettings *settings);
+
+#endif /* __SUBDIV_CONVERTER_H__ */
diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
new file mode 100644
index 00000000000..1a2c26b3564
--- /dev/null
+++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
@@ -0,0 +1,471 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "subdiv_converter.h"
+
+#include <string.h>
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
+
+#include "BKE_customdata.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_subdiv.h"
+
+#include "MEM_guardedalloc.h"
+
+#ifdef WITH_OPENSUBDIV
+# include "opensubdiv_capi.h"
+# include "opensubdiv_converter_capi.h"
+#endif
+
+/* Use mesh element mapping structures during conversion.
+ * Uses more memory but is much faster than naive algorithm.
+ */
+#define USE_MESH_ELEMENT_MAPPING
+
+#ifdef WITH_OPENSUBDIV
+typedef struct ConverterStorage {
+ SubdivSettings settings;
+ const Mesh *mesh;
+
+#ifdef USE_MESH_ELEMENT_MAPPING
+ MeshElemMap *vert_edge_map;
+ MeshElemMap *vert_poly_map;
+ MeshElemMap *edge_poly_map;
+ int *vert_edge_mem;
+ int *vert_poly_mem;
+ int *edge_poly_mem;
+#endif
+
+ /* Indexed by loop index, value denotes index of face-varying vertex
+ * which corresponds to the UV coordinate.
+ */
+ int *loop_uv_indices;
+ int num_uv_coordinates;
+} ConverterStorage;
+
+static OpenSubdiv_SchemeType get_scheme_type(
+ const OpenSubdiv_Converter *converter)
+{
+ ConverterStorage *storage = converter->user_data;
+ if (storage->settings.is_simple) {
+ return OSD_SCHEME_BILINEAR;
+ }
+ else {
+ return OSD_SCHEME_CATMARK;
+ }
+}
+
+static OpenSubdiv_FVarLinearInterpolation get_fvar_linear_interpolation(
+ const OpenSubdiv_Converter *converter)
+{
+ ConverterStorage *storage = converter->user_data;
+ return BKE_subdiv_converter_fvar_linear_from_settings(&storage->settings);
+}
+
+static int get_num_faces(const OpenSubdiv_Converter *converter)
+{
+ ConverterStorage *storage = converter->user_data;
+ return storage->mesh->totpoly;
+}
+
+static int get_num_edges(const OpenSubdiv_Converter *converter)
+{
+ ConverterStorage *storage = converter->user_data;
+ return storage->mesh->totedge;
+}
+
+static int get_num_verts(const OpenSubdiv_Converter *converter)
+{
+ ConverterStorage *storage = converter->user_data;
+ return storage->mesh->totvert;
+}
+
+static int get_num_face_verts(const OpenSubdiv_Converter *converter, int face)
+{
+ ConverterStorage *storage = converter->user_data;
+ return storage->mesh->mpoly[face].totloop;
+}
+
+static void get_face_verts(const OpenSubdiv_Converter *converter,
+ int face,
+ int *face_verts)
+{
+ ConverterStorage *storage = converter->user_data;
+ const MPoly *mp = &storage->mesh->mpoly[face];
+ const MLoop *mloop = storage->mesh->mloop;
+ for (int loop = 0; loop < mp->totloop; loop++) {
+ face_verts[loop] = mloop[mp->loopstart + loop].v;
+ }
+}
+
+static void get_face_edges(const OpenSubdiv_Converter *converter,
+ int face,
+ int *face_edges)
+{
+ ConverterStorage *storage = converter->user_data;
+ const MPoly *mp = &storage->mesh->mpoly[face];
+ const MLoop *mloop = storage->mesh->mloop;
+ for (int loop = 0; loop < mp->totloop; loop++) {
+ face_edges[loop] = mloop[mp->loopstart + loop].e;
+ }
+}
+
+static void get_edge_verts(const OpenSubdiv_Converter *converter,
+ int edge,
+ int *edge_verts)
+{
+ ConverterStorage *storage = converter->user_data;
+ const MEdge *me = &storage->mesh->medge[edge];
+ edge_verts[0] = me->v1;
+ edge_verts[1] = me->v2;
+}
+
+static int get_num_edge_faces(const OpenSubdiv_Converter *converter, int edge)
+{
+ ConverterStorage *storage = converter->user_data;
+#ifdef USE_MESH_ELEMENT_MAPPING
+ return storage->edge_poly_map[edge].count;
+#else
+ const Mesh *mesh = storage->mesh;
+ const MPoly *mpoly = mesh->mpoly;
+ const MLoop *mloop = mesh->mloop;
+ int num = 0;
+ for (int poly = 0; poly < mesh->totpoly; poly++) {
+ const MPoly *mp = &mpoly[poly];
+ for (int loop = 0; loop < mp->totloop; loop++) {
+ const MLoop *ml = &mloop[mp->loopstart + loop];
+ if (ml->e == edge) {
+ ++num;
+ break;
+ }
+ }
+ }
+ return num;
+#endif
+}
+
+static void get_edge_faces(const OpenSubdiv_Converter *converter,
+ int edge,
+ int *edge_faces)
+{
+ ConverterStorage *storage = converter->user_data;
+#ifdef USE_MESH_ELEMENT_MAPPING
+ memcpy(edge_faces,
+ storage->edge_poly_map[edge].indices,
+ sizeof(int) * storage->edge_poly_map[edge].count);
+#else
+ const Mesh *mesh = storage->mesh;
+ const MPoly *mpoly = mesh->mpoly;
+ const MLoop *mloop = mesh->mloop;
+ int num = 0;
+ for (int poly = 0; poly < mesh->totpoly; poly++) {
+ const MPoly *mp = &mpoly[poly];
+ for (int loop = 0; loop < mpoly->totloop; loop++) {
+ const MLoop *ml = &mloop[mp->loopstart + loop];
+ if (ml->e == edge) {
+ edge_faces[num++] = poly;
+ break;
+ }
+ }
+ }
+#endif
+}
+
+static float get_edge_sharpness(const OpenSubdiv_Converter *converter, int edge)
+{
+ ConverterStorage *storage = converter->user_data;
+ const MEdge *medge = storage->mesh->medge;
+ const float edge_crease = (float)medge[edge].crease / 255.0f;
+ return edge_crease * storage->settings.level;
+}
+
+static int get_num_vert_edges(const OpenSubdiv_Converter *converter, int vert)
+{
+ ConverterStorage *storage = converter->user_data;
+#ifdef USE_MESH_ELEMENT_MAPPING
+ return storage->vert_edge_map[vert].count;
+#else
+ const Mesh *mesh = storage->mesh;
+ const MEdge *medge = mesh->medge;
+ int num = 0;
+ for (int edge = 0; edge < mesh->totedge; edge++) {
+ const MEdge *me = &medge[edge];
+ if (me->v1 == vert || me->v2 == vert) {
+ ++num;
+ }
+ }
+ return num;
+#endif
+}
+
+static void get_vert_edges(const OpenSubdiv_Converter *converter,
+ int vert,
+ int *vert_edges)
+{
+ ConverterStorage *storage = converter->user_data;
+#ifdef USE_MESH_ELEMENT_MAPPING
+ memcpy(vert_edges,
+ storage->vert_edge_map[vert].indices,
+ sizeof(int) * storage->vert_edge_map[vert].count);
+#else
+ const Mesh *mesh = storage->mesh;
+ const MEdge *medge = mesh->medge;
+ int num = 0;
+ for (int edge = 0; edge < mesh->totedge; edge++) {
+ const MEdge *me = &medge[edge];
+ if (me->v1 == vert || me->v2 == vert) {
+ vert_edges[num++] = edge;
+ }
+ }
+#endif
+}
+
+static int get_num_vert_faces(const OpenSubdiv_Converter *converter, int vert)
+{
+ ConverterStorage *storage = converter->user_data;
+#ifdef USE_MESH_ELEMENT_MAPPING
+ return storage->vert_poly_map[vert].count;
+#else
+ const Mesh *mesh = storage->mesh;
+ const MPoly *mpoly = mesh->mpoly;
+ const MLoop *mloop = mesh->mloop;
+ int num = 0;
+ for (int poly = 0; poly < mesh->totpoly; poly++) {
+ const MPoly *mp = &mpoly[poly];
+ for (int loop = 0; loop < mpoly->totloop; loop++) {
+ const MLoop *ml = &mloop[mp->loopstart + loop];
+ if (ml->v == vert) {
+ ++num;
+ break;
+ }
+ }
+ }
+ return num;
+#endif
+}
+
+static void get_vert_faces(const OpenSubdiv_Converter *converter,
+ int vert,
+ int *vert_faces)
+{
+ ConverterStorage *storage = converter->user_data;
+#ifdef USE_MESH_ELEMENT_MAPPING
+ memcpy(vert_faces,
+ storage->vert_poly_map[vert].indices,
+ sizeof(int) * storage->vert_poly_map[vert].count);
+#else
+ const Mesh *mesh = storage->mesh;
+ const MPoly *mpoly = mesh->mpoly;
+ const MLoop *mloop = mesh->mloop;
+ int num = 0;
+ for (int poly = 0; poly < mesh->totpoly; poly++) {
+ const MPoly *mp = &mpoly[poly];
+ for (int loop = 0; loop < mpoly->totloop; loop++) {
+ const MLoop *ml = &mloop[mp->loopstart + loop];
+ if (ml->v == vert) {
+ vert_faces[num++] = poly;
+ break;
+ }
+ }
+ }
+#endif
+}
+
+static int get_num_uv_layers(const OpenSubdiv_Converter *converter)
+{
+ ConverterStorage *storage = converter->user_data;
+ const Mesh *mesh = storage->mesh;
+ return CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV);
+}
+
+static void precalc_uv_layer(const OpenSubdiv_Converter *converter,
+ const int layer_index)
+{
+ ConverterStorage *storage = converter->user_data;
+ const Mesh *mesh = storage->mesh;
+ const MPoly *mpoly = mesh->mpoly;
+ const MLoop *mloop = mesh->mloop;
+ const MLoopUV *mloopuv = CustomData_get_layer_n(
+ &mesh->ldata, CD_MLOOPUV, layer_index);
+ const int num_poly = mesh->totpoly;
+ const int num_vert = mesh->totvert;
+ const float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT};
+ /* Initialize memory required for the operations. */
+ if (storage->loop_uv_indices == NULL) {
+ storage->loop_uv_indices = MEM_malloc_arrayN(
+ mesh->totloop, sizeof(int), "loop uv vertex index");
+ }
+ UvVertMap *uv_vert_map = BKE_mesh_uv_vert_map_create(
+ mpoly, mloop, mloopuv,
+ num_poly, num_vert,
+ limit,
+ false, true);
+ /* NOTE: First UV vertex is supposed to be always marked as separate. */
+ storage->num_uv_coordinates = -1;
+ for (int vertex_index = 0; vertex_index < num_vert; ++vertex_index) {
+ const UvMapVert *uv_vert = BKE_mesh_uv_vert_map_get_vert(uv_vert_map,
+ vertex_index);
+ while (uv_vert != NULL) {
+ if (uv_vert->separate) {
+ storage->num_uv_coordinates++;
+ }
+ const MPoly *mp = &mpoly[uv_vert->poly_index];
+ const int global_loop_index = mp->loopstart +
+ uv_vert->loop_of_poly_index;
+ storage->loop_uv_indices[global_loop_index] =
+ storage->num_uv_coordinates;
+ uv_vert = uv_vert->next;
+ }
+ }
+ /* So far this value was used as a 0-based index, actual number of UV
+ * vertices is 1 more.
+ */
+ storage->num_uv_coordinates += 1;
+ BKE_mesh_uv_vert_map_free(uv_vert_map);
+}
+
+static void finish_uv_layer(const OpenSubdiv_Converter *UNUSED(converter))
+{
+}
+
+static int get_num_uvs(const OpenSubdiv_Converter *converter)
+{
+ ConverterStorage *storage = converter->user_data;
+ return storage->num_uv_coordinates;
+}
+
+static int get_face_corner_uv_index(const OpenSubdiv_Converter *converter,
+ const int face_index,
+ const int corner)
+{
+ ConverterStorage *storage = converter->user_data;
+ const MPoly *mp = &storage->mesh->mpoly[face_index];
+ return storage->loop_uv_indices[mp->loopstart + corner];
+}
+
+static void free_user_data(const OpenSubdiv_Converter *converter)
+{
+ ConverterStorage *user_data = converter->user_data;
+ MEM_SAFE_FREE(user_data->loop_uv_indices);
+#ifdef USE_MESH_ELEMENT_MAPPING
+ MEM_freeN(user_data->vert_edge_map);
+ MEM_freeN(user_data->vert_edge_mem);
+ MEM_freeN(user_data->vert_poly_map);
+ MEM_freeN(user_data->vert_poly_mem);
+ MEM_freeN(user_data->edge_poly_map);
+ MEM_freeN(user_data->edge_poly_mem);
+#endif
+ MEM_freeN(user_data);
+}
+
+static void init_functions(OpenSubdiv_Converter *converter)
+{
+ converter->getSchemeType = get_scheme_type;
+
+ converter->getFVarLinearInterpolation = get_fvar_linear_interpolation;
+
+ converter->getNumFaces = get_num_faces;
+ converter->getNumEdges = get_num_edges;
+ converter->getNumVertices = get_num_verts;
+
+ converter->getNumFaceVertices = get_num_face_verts;
+ converter->getFaceVertices = get_face_verts;
+ converter->getFaceEdges = get_face_edges;
+
+ converter->getEdgeVertices = get_edge_verts;
+ converter->getNumEdgeFaces = get_num_edge_faces;
+ converter->getEdgeFaces = get_edge_faces;
+ converter->getEdgeSharpness = get_edge_sharpness;
+
+ converter->getNumVertexEdges = get_num_vert_edges;
+ converter->getVertexEdges = get_vert_edges;
+ converter->getNumVertexFaces = get_num_vert_faces;
+ converter->getVertexFaces = get_vert_faces;
+
+ converter->getNumUVLayers = get_num_uv_layers;
+ converter->precalcUVLayer = precalc_uv_layer;
+ converter->finishUVLayer = finish_uv_layer;
+ converter->getNumUVCoordinates = get_num_uvs;
+ converter->getFaceCornerUVIndex = get_face_corner_uv_index;
+
+ converter->freeUserData = free_user_data;
+}
+
+static void create_element_maps_if_needed(ConverterStorage *storage)
+{
+#ifdef USE_MESH_ELEMENT_MAPPING
+ const Mesh *mesh = storage->mesh;
+ BKE_mesh_vert_edge_map_create(&storage->vert_edge_map,
+ &storage->vert_edge_mem,
+ mesh->medge,
+ mesh->totvert,
+ mesh->totedge);
+ BKE_mesh_vert_poly_map_create(&storage->vert_poly_map,
+ &storage->vert_poly_mem,
+ mesh->mpoly,
+ mesh->mloop,
+ mesh->totvert,
+ mesh->totpoly,
+ mesh->totloop);
+ BKE_mesh_edge_poly_map_create(&storage->edge_poly_map,
+ &storage->edge_poly_mem,
+ mesh->medge, mesh->totedge,
+ mesh->mpoly, mesh->totpoly,
+ mesh->mloop, mesh->totloop);
+#else
+ (void) storage; /* Ignored. */
+#endif
+}
+
+static void init_user_data(OpenSubdiv_Converter *converter,
+ const SubdivSettings *settings,
+ const Mesh *mesh)
+{
+ ConverterStorage *user_data =
+ MEM_mallocN(sizeof(ConverterStorage), __func__);
+ user_data->settings = *settings;
+ user_data->mesh = mesh;
+ user_data->loop_uv_indices = NULL;
+ create_element_maps_if_needed(user_data);
+ converter->user_data = user_data;
+}
+#endif
+
+void BKE_subdiv_converter_init_for_mesh(struct OpenSubdiv_Converter *converter,
+ const SubdivSettings *settings,
+ const Mesh *mesh)
+{
+#ifdef WITH_OPENSUBDIV
+ init_functions(converter);
+ init_user_data(converter, settings, mesh);
+#else
+ UNUSED_VARS(converter, settings, mesh);
+#endif
+}
diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c
new file mode 100644
index 00000000000..4c2ed07cdfa
--- /dev/null
+++ b/source/blender/blenkernel/intern/subdiv_eval.c
@@ -0,0 +1,323 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/subdiv_eval.c
+ * \ingroup bke
+ */
+
+#include "BKE_subdiv.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
+
+#include "BKE_customdata.h"
+
+#ifdef WITH_OPENSUBDIV
+# include "opensubdiv_evaluator_capi.h"
+# include "opensubdiv_topology_refiner_capi.h"
+#endif
+
+void BKE_subdiv_eval_begin(Subdiv *subdiv)
+{
+#ifdef WITH_OPENSUBDIV
+ if (subdiv->evaluator == NULL) {
+ BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_EVALUATOR_CREATE);
+ subdiv->evaluator = openSubdiv_createEvaluatorFromTopologyRefiner(
+ subdiv->topology_refiner);
+ BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_EVALUATOR_CREATE);
+ }
+ else {
+ /* TODO(sergey): Check for topology change. */
+ }
+#else
+ UNUSED_VARS(subdiv);
+#endif
+}
+
+#ifdef WITH_OPENSUBDIV
+static void set_face_varying_data_from_uv(Subdiv *subdiv,
+ const MLoopUV *mloopuv,
+ const int layer_index)
+{
+ OpenSubdiv_TopologyRefiner *topology_refiner = subdiv->topology_refiner;
+ OpenSubdiv_Evaluator *evaluator = subdiv->evaluator;
+ const int num_faces = topology_refiner->getNumFaces(topology_refiner);
+ const MLoopUV *mluv = mloopuv;
+ /* TODO(sergey): OpenSubdiv's C-API converter can change winding of
+ * loops of a face, need to watch for that, to prevent wrong UVs assigned.
+ */
+ for (int face_index = 0; face_index < num_faces; ++face_index) {
+ const int num_face_vertices = topology_refiner->getNumFaceVertices(
+ topology_refiner, face_index);
+ const int *uv_indicies = topology_refiner->getFaceFVarValueIndices(
+ topology_refiner, face_index, layer_index);
+ for (int vertex_index = 0;
+ vertex_index < num_face_vertices;
+ vertex_index++, mluv++)
+ {
+ evaluator->setFaceVaryingData(evaluator,
+ mluv->uv,
+ uv_indicies[vertex_index],
+ 1);
+ }
+ }
+}
+#endif
+
+void BKE_subdiv_eval_update_from_mesh(Subdiv *subdiv, const Mesh *mesh)
+{
+#ifdef WITH_OPENSUBDIV
+ BKE_subdiv_eval_begin(subdiv);
+ /* Set coordinates of base mesh vertices. */
+ subdiv->evaluator->setCoarsePositionsFromBuffer(
+ subdiv->evaluator,
+ mesh->mvert,
+ offsetof(MVert, co),
+ sizeof(MVert),
+ 0, mesh->totvert);
+ /* Set face-varyign data to UV maps. */
+ const int num_uv_layers =
+ CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV);
+ for (int layer_index = 0; layer_index < num_uv_layers; layer_index++) {
+ const MLoopUV *mloopuv = CustomData_get_layer_n(
+ &mesh->ldata, CD_MLOOPUV, layer_index);
+ set_face_varying_data_from_uv(subdiv, mloopuv, layer_index);
+ /* NOTE: Currently evaluator can only handle single face varying layer.
+ * This is a limitation of C-API and some underlying helper classes from
+ * our side which will get fixed.
+ */
+ break;
+ }
+ /* Update evaluator to the new coarse geometry. */
+ BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_EVALUATOR_REFINE);
+ subdiv->evaluator->refine(subdiv->evaluator);
+ BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_EVALUATOR_REFINE);
+#else
+ UNUSED_VARS(subdiv, mesh);
+#endif
+}
+
+/* ========================== Single point queries ========================== */
+
+void BKE_subdiv_eval_limit_point(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float P[3])
+{
+ BKE_subdiv_eval_limit_point_and_derivatives(subdiv,
+ ptex_face_index,
+ u, v,
+ P, NULL, NULL);
+}
+
+void BKE_subdiv_eval_limit_point_and_derivatives(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float P[3], float dPdu[3], float dPdv[3])
+{
+#ifdef WITH_OPENSUBDIV
+ subdiv->evaluator->evaluateLimit(subdiv->evaluator,
+ ptex_face_index,
+ u, v,
+ P, dPdu, dPdv);
+#else
+ UNUSED_VARS(subdiv, ptex_face_index, u, v, P, dPdu, dPdv);
+#endif
+}
+
+void BKE_subdiv_eval_limit_point_and_normal(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float P[3], float N[3])
+{
+ float dPdu[3], dPdv[3];
+ BKE_subdiv_eval_limit_point_and_derivatives(subdiv,
+ ptex_face_index,
+ u, v,
+ P, dPdu, dPdv);
+ cross_v3_v3v3(N, dPdu, dPdv);
+ normalize_v3(N);
+}
+
+void BKE_subdiv_eval_limit_point_and_short_normal(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float P[3], short N[3])
+{
+ float N_float[3];
+ BKE_subdiv_eval_limit_point_and_normal(subdiv,
+ ptex_face_index,
+ u, v,
+ P, N_float);
+ normal_float_to_short_v3(N, N_float);
+}
+
+void BKE_subdiv_eval_face_varying(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float face_varying[2])
+{
+#ifdef WITH_OPENSUBDIV
+ subdiv->evaluator->evaluateFaceVarying(subdiv->evaluator,
+ ptex_face_index,
+ u, v,
+ face_varying);
+#else
+ UNUSED_VARS(subdiv, ptex_face_index, u, v, face_varying);
+#endif
+}
+
+/* =================== Patch queries at given resolution =================== */
+
+/* Move buffer forward by a given number of bytes. */
+static void buffer_apply_offset(void **buffer, const int offset)
+{
+ *buffer = ((unsigned char *)*buffer) + offset;
+}
+
+/* Write given number of floats to the beginning of given buffer. */
+static void buffer_write_float_value(void **buffer,
+ const float *values_buffer, int num_values)
+{
+ memcpy(*buffer, values_buffer, sizeof(float) * num_values);
+}
+
+/* Similar to above, just operates with short values. */
+static void buffer_write_short_value(void **buffer,
+ const short *values_buffer, int num_values)
+{
+ memcpy(*buffer, values_buffer, sizeof(short) * num_values);
+}
+
+void BKE_subdiv_eval_limit_patch_resolution_point(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const int resolution,
+ void *buffer, const int offset, const int stride)
+{
+ buffer_apply_offset(&buffer, offset);
+ const float inv_resolution_1 = 1.0f / (float)(resolution - 1);
+ for (int y = 0; y < resolution; y++) {
+ const float v = y * inv_resolution_1;
+ for (int x = 0; x < resolution; x++) {
+ const float u = x * inv_resolution_1;
+ BKE_subdiv_eval_limit_point(subdiv,
+ ptex_face_index,
+ u, v,
+ buffer);
+ buffer_apply_offset(&buffer, stride);
+ }
+ }
+}
+
+void BKE_subdiv_eval_limit_patch_resolution_point_and_derivatives(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const int resolution,
+ void *point_buffer, const int point_offset, const int point_stride,
+ void *du_buffer, const int du_offset, const int du_stride,
+ void *dv_buffer, const int dv_offset, const int dv_stride)
+{
+ buffer_apply_offset(&point_buffer, point_offset);
+ buffer_apply_offset(&du_buffer, du_offset);
+ buffer_apply_offset(&dv_buffer, dv_offset);
+ const float inv_resolution_1 = 1.0f / (float)(resolution - 1);
+ for (int y = 0; y < resolution; y++) {
+ const float v = y * inv_resolution_1;
+ for (int x = 0; x < resolution; x++) {
+ const float u = x * inv_resolution_1;
+ BKE_subdiv_eval_limit_point_and_derivatives(
+ subdiv,
+ ptex_face_index,
+ u, v,
+ point_buffer, du_buffer, dv_buffer);
+ buffer_apply_offset(&point_buffer, point_stride);
+ buffer_apply_offset(&du_buffer, du_stride);
+ buffer_apply_offset(&dv_buffer, dv_stride);
+ }
+ }
+}
+
+void BKE_subdiv_eval_limit_patch_resolution_point_and_normal(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const int resolution,
+ void *point_buffer, const int point_offset, const int point_stride,
+ void *normal_buffer, const int normal_offset, const int normal_stride)
+{
+ buffer_apply_offset(&point_buffer, point_offset);
+ buffer_apply_offset(&normal_buffer, normal_offset);
+ const float inv_resolution_1 = 1.0f / (float)(resolution - 1);
+ for (int y = 0; y < resolution; y++) {
+ const float v = y * inv_resolution_1;
+ for (int x = 0; x < resolution; x++) {
+ const float u = x * inv_resolution_1;
+ float normal[3];
+ BKE_subdiv_eval_limit_point_and_normal(
+ subdiv,
+ ptex_face_index,
+ u, v,
+ point_buffer, normal);
+ buffer_write_float_value(&normal_buffer, normal, 3);
+ buffer_apply_offset(&point_buffer, point_stride);
+ buffer_apply_offset(&normal_buffer, normal_stride);
+ }
+ }
+}
+
+void BKE_subdiv_eval_limit_patch_resolution_point_and_short_normal(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const int resolution,
+ void *point_buffer, const int point_offset, const int point_stride,
+ void *normal_buffer, const int normal_offset, const int normal_stride)
+{
+ buffer_apply_offset(&point_buffer, point_offset);
+ buffer_apply_offset(&normal_buffer, normal_offset);
+ const float inv_resolution_1 = 1.0f / (float)(resolution - 1);
+ for (int y = 0; y < resolution; y++) {
+ const float v = y * inv_resolution_1;
+ for (int x = 0; x < resolution; x++) {
+ const float u = x * inv_resolution_1;
+ short normal[3];
+ BKE_subdiv_eval_limit_point_and_short_normal(
+ subdiv,
+ ptex_face_index,
+ u, v,
+ point_buffer, normal);
+ buffer_write_short_value(&normal_buffer, normal, 3);
+ buffer_apply_offset(&point_buffer, point_stride);
+ buffer_apply_offset(&normal_buffer, normal_stride);
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
new file mode 100644
index 00000000000..83f2069ea0f
--- /dev/null
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -0,0 +1,952 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/subdiv_mesh.c
+ * \ingroup bke
+ */
+
+#include "BKE_subdiv.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLI_alloca.h"
+#include "BLI_math_vector.h"
+#include "BLI_task.h"
+
+#include "BKE_mesh.h"
+
+/* TODO(sergey): Somehow move this to subdiv code? */
+static int mpoly_ptex_faces_count_get(const MPoly *mp)
+{
+ if (mp->totloop == 4) {
+ return 1;
+ }
+ else {
+ return mp->totloop;
+ }
+}
+
+static int num_edges_per_ptex_get(const int resolution)
+{
+ return 2 * (resolution - 1) * resolution;
+}
+
+static int num_polys_per_ptex_get(const int resolution)
+{
+ return (resolution - 1) * (resolution - 1);
+}
+
+typedef struct SubdivMeshContext {
+ const Mesh *coarse_mesh;
+ Subdiv *subdiv;
+ Mesh *subdiv_mesh;
+ const SubdivToMeshSettings *settings;
+ /* Cached custom data arrays for fastter access. */
+ int *vert_origindex;
+ int *edge_origindex;
+ int *loop_origindex;
+ int *poly_origindex;
+ /* UV layers interpolation. */
+ int num_uv_layers;
+ MLoopUV *uv_layers[MAX_MTFACE];
+} SubdivMeshContext;
+
+typedef struct LoopsOfPtex {
+ /* First loop of the ptex, starts at ptex (0, 0) and goes in u direction. */
+ const MLoop *first_loop;
+ /* Last loop of the ptex, starts at ptex (0, 0) and goes in v direction. */
+ const MLoop *last_loop;
+ /* For quad coarse faces only. */
+ const MLoop *second_loop;
+ const MLoop *third_loop;
+} LoopsOfPtex;
+
+static void loops_of_ptex_get(
+ const SubdivMeshContext *ctx,
+ LoopsOfPtex *loops_of_ptex,
+ const MPoly *coarse_poly,
+ const int ptex_face_index)
+{
+ const MLoop *coarse_mloop = ctx->coarse_mesh->mloop;
+ const int first_ptex_loop_index = coarse_poly->loopstart + ptex_face_index;
+ /* Loop which look in the (opposite) V direction of the current
+ * ptex face.
+ *
+ * TOOD(sergey): Get rid of using module on every iteration.
+ */
+ const int last_ptex_loop_index =
+ coarse_poly->loopstart +
+ (ptex_face_index + coarse_poly->totloop - 1) % coarse_poly->totloop;
+ loops_of_ptex->first_loop = &coarse_mloop[first_ptex_loop_index];
+ loops_of_ptex->last_loop = &coarse_mloop[last_ptex_loop_index];
+ if (coarse_poly->totloop == 4) {
+ loops_of_ptex->second_loop = loops_of_ptex->first_loop + 1;
+ loops_of_ptex->third_loop = loops_of_ptex->first_loop + 2;
+ }
+ else {
+ loops_of_ptex->second_loop = NULL;
+ loops_of_ptex->third_loop = NULL;
+ }
+}
+
+typedef struct EdgesOfPtex {
+ /* First edge of the ptex, starts at ptex (0, 0) and goes in u direction. */
+ const MEdge *first_edge;
+ /* Last edge of the ptex, starts at ptex (0, 0) and goes in v direction. */
+ const MEdge *last_edge;
+ /* For quad coarse faces only. */
+ const MEdge *second_edge;
+ const MEdge *third_edge;
+} EdgesOfPtex;
+
+static void edges_of_ptex_get(
+ const SubdivMeshContext *ctx,
+ EdgesOfPtex *edges_of_ptex,
+ const MPoly *coarse_poly,
+ const int ptex_face_index)
+{
+ const MEdge *coarse_medge = ctx->coarse_mesh->medge;
+ LoopsOfPtex loops_of_ptex;
+ loops_of_ptex_get(ctx, &loops_of_ptex, coarse_poly, ptex_face_index);
+ edges_of_ptex->first_edge = &coarse_medge[loops_of_ptex.first_loop->e];
+ edges_of_ptex->last_edge = &coarse_medge[loops_of_ptex.last_loop->e];
+ if (coarse_poly->totloop == 4) {
+ edges_of_ptex->second_edge =
+ &coarse_medge[loops_of_ptex.second_loop->e];
+ edges_of_ptex->third_edge =
+ &coarse_medge[loops_of_ptex.third_loop->e];
+ }
+ else {
+ edges_of_ptex->second_edge = NULL;
+ edges_of_ptex->third_edge = NULL;
+ }
+}
+
+/* TODO(sergey): Somehow de-duplicate with loops storage, without too much
+ * exception cases all over the code.
+ */
+
+typedef struct VerticesForInterpolation {
+ /* This field points to a vertex data which is to be used for interpolation.
+ * The idea is to avoid unnecessary allocations for regular faces, where
+ * we can simply
+ */
+ const CustomData *vertex_data;
+ /* Vertices data calculated for ptex corners. There are always 4 elements
+ * in this custom data, aligned the following way:
+ *
+ * index 0 -> uv (0, 0)
+ * index 1 -> uv (0, 1)
+ * index 2 -> uv (1, 1)
+ * index 3 -> uv (1, 0)
+ *
+ * Is allocated for non-regular faces (triangles and n-gons).
+ */
+ CustomData vertex_data_storage;
+ bool vertex_data_storage_allocated;
+ /* Infices within vertex_data to interpolate for. The indices are aligned
+ * with uv coordinates in a similar way as indices in loop_data_storage.
+ */
+ int vertex_indices[4];
+} VerticesForInterpolation;
+
+static void vertex_interpolation_init(
+ const SubdivMeshContext *ctx,
+ VerticesForInterpolation *vertex_interpolation,
+ const MPoly *coarse_poly)
+{
+ const Mesh *coarse_mesh = ctx->coarse_mesh;
+ const MLoop *coarse_mloop = coarse_mesh->mloop;
+ if (coarse_poly->totloop == 4) {
+ vertex_interpolation->vertex_data = &coarse_mesh->vdata;
+ vertex_interpolation->vertex_indices[0] =
+ coarse_mloop[coarse_poly->loopstart + 0].v;
+ vertex_interpolation->vertex_indices[1] =
+ coarse_mloop[coarse_poly->loopstart + 1].v;
+ vertex_interpolation->vertex_indices[2] =
+ coarse_mloop[coarse_poly->loopstart + 2].v;
+ vertex_interpolation->vertex_indices[3] =
+ coarse_mloop[coarse_poly->loopstart + 3].v;
+ vertex_interpolation->vertex_data_storage_allocated = false;
+ }
+ else {
+ vertex_interpolation->vertex_data =
+ &vertex_interpolation->vertex_data_storage;
+ /* Allocate storage for loops corresponding to ptex corners. */
+ CustomData_copy(&ctx->coarse_mesh->vdata,
+ &vertex_interpolation->vertex_data_storage,
+ CD_MASK_EVERYTHING,
+ CD_CALLOC,
+ 4);
+ /* Initialize indices. */
+ vertex_interpolation->vertex_indices[0] = 0;
+ vertex_interpolation->vertex_indices[1] = 1;
+ vertex_interpolation->vertex_indices[2] = 2;
+ vertex_interpolation->vertex_indices[3] = 3;
+ vertex_interpolation->vertex_data_storage_allocated = true;
+ /* Interpolate center of poly right away, it stays unchanged for all
+ * ptex faces.
+ */
+ const float weight = 1.0f / (float)coarse_poly->totloop;
+ float *weights = BLI_array_alloca(weights, coarse_poly->totloop);
+ int *indices = BLI_array_alloca(indices, coarse_poly->totloop);
+ for (int i = 0; i < coarse_poly->totloop; ++i) {
+ weights[i] = weight;
+ indices[i] = coarse_poly->loopstart + i;
+ }
+ CustomData_interp(&coarse_mesh->vdata,
+ &vertex_interpolation->vertex_data_storage,
+ indices,
+ weights, NULL,
+ coarse_poly->totloop,
+ 2);
+ }
+}
+
+static void vertex_interpolation_from_ptex(
+ const SubdivMeshContext *ctx,
+ VerticesForInterpolation *vertex_interpolation,
+ const MPoly *coarse_poly,
+ const int ptex_face_index)
+{
+ if (coarse_poly->totloop == 4) {
+ /* Nothing to do, all indices and data is already assigned. */
+ }
+ else {
+ const CustomData *vertex_data = &ctx->coarse_mesh->vdata;
+ const Mesh *coarse_mesh = ctx->coarse_mesh;
+ const MLoop *coarse_mloop = coarse_mesh->mloop;
+ LoopsOfPtex loops_of_ptex;
+ loops_of_ptex_get(ctx, &loops_of_ptex, coarse_poly, ptex_face_index);
+ /* Ptex face corner corresponds to a poly loop with same index. */
+ CustomData_copy_data(
+ vertex_data,
+ &vertex_interpolation->vertex_data_storage,
+ coarse_mloop[coarse_poly->loopstart + ptex_face_index].v,
+ 0,
+ 1);
+ /* Interpolate remaining ptex face corners, which hits loops
+ * middle points.
+ *
+ * TODO(sergey): Re-use one of interpolation results from previous
+ * iteration.
+ */
+ const float weights[2] = {0.5f, 0.5f};
+ const int first_indices[2] = {
+ coarse_mloop[loops_of_ptex.first_loop - coarse_mloop].v,
+ coarse_mloop[(loops_of_ptex.first_loop + 1 - coarse_mloop) %
+ coarse_poly->totloop].v};
+ const int last_indices[2] = {
+ coarse_mloop[loops_of_ptex.last_loop - coarse_mloop].v,
+ coarse_mloop[loops_of_ptex.first_loop - coarse_mloop].v};
+ CustomData_interp(vertex_data,
+ &vertex_interpolation->vertex_data_storage,
+ first_indices,
+ weights, NULL,
+ 2,
+ 1);
+ CustomData_interp(vertex_data,
+ &vertex_interpolation->vertex_data_storage,
+ last_indices,
+ weights, NULL,
+ 2,
+ 3);
+ }
+}
+
+static void vertex_interpolation_end(
+ VerticesForInterpolation *vertex_interpolation)
+{
+ if (vertex_interpolation->vertex_data_storage_allocated) {
+ CustomData_free(&vertex_interpolation->vertex_data_storage, 4);
+ }
+}
+
+typedef struct LoopsForInterpolation {
+ /* This field points to a loop data which is to be used for interpolation.
+ * The idea is to avoid unnecessary allocations for regular faces, where
+ * we can simply
+ */
+ const CustomData *loop_data;
+ /* Loops data calculated for ptex corners. There are always 4 elements
+ * in this custom data, aligned the following way:
+ *
+ * index 0 -> uv (0, 0)
+ * index 1 -> uv (0, 1)
+ * index 2 -> uv (1, 1)
+ * index 3 -> uv (1, 0)
+ *
+ * Is allocated for non-regular faces (triangles and n-gons).
+ */
+ CustomData loop_data_storage;
+ bool loop_data_storage_allocated;
+ /* Infices within loop_data to interpolate for. The indices are aligned with
+ * uv coordinates in a similar way as indices in loop_data_storage.
+ */
+ int loop_indices[4];
+} LoopsForInterpolation;
+
+static void loop_interpolation_init(
+ const SubdivMeshContext *ctx,
+ LoopsForInterpolation *loop_interpolation,
+ const MPoly *coarse_poly)
+{
+ const Mesh *coarse_mesh = ctx->coarse_mesh;
+ if (coarse_poly->totloop == 4) {
+ loop_interpolation->loop_data = &coarse_mesh->ldata;
+ loop_interpolation->loop_indices[0] = coarse_poly->loopstart + 0;
+ loop_interpolation->loop_indices[1] = coarse_poly->loopstart + 1;
+ loop_interpolation->loop_indices[2] = coarse_poly->loopstart + 2;
+ loop_interpolation->loop_indices[3] = coarse_poly->loopstart + 3;
+ loop_interpolation->loop_data_storage_allocated = false;
+ }
+ else {
+ loop_interpolation->loop_data = &loop_interpolation->loop_data_storage;
+ /* Allocate storage for loops corresponding to ptex corners. */
+ CustomData_copy(&ctx->coarse_mesh->ldata,
+ &loop_interpolation->loop_data_storage,
+ CD_MASK_EVERYTHING,
+ CD_CALLOC,
+ 4);
+ /* Initialize indices. */
+ loop_interpolation->loop_indices[0] = 0;
+ loop_interpolation->loop_indices[1] = 1;
+ loop_interpolation->loop_indices[2] = 2;
+ loop_interpolation->loop_indices[3] = 3;
+ loop_interpolation->loop_data_storage_allocated = true;
+ /* Interpolate center of poly right away, it stays unchanged for all
+ * ptex faces.
+ */
+ const float weight = 1.0f / (float)coarse_poly->totloop;
+ float *weights = BLI_array_alloca(weights, coarse_poly->totloop);
+ int *indices = BLI_array_alloca(indices, coarse_poly->totloop);
+ for (int i = 0; i < coarse_poly->totloop; ++i) {
+ weights[i] = weight;
+ indices[i] = coarse_poly->loopstart + i;
+ }
+ CustomData_interp(&coarse_mesh->ldata,
+ &loop_interpolation->loop_data_storage,
+ indices,
+ weights, NULL,
+ coarse_poly->totloop,
+ 2);
+ }
+}
+
+static void loop_interpolation_from_ptex(
+ const SubdivMeshContext *ctx,
+ LoopsForInterpolation *loop_interpolation,
+ const MPoly *coarse_poly,
+ const int ptex_face_index)
+{
+ if (coarse_poly->totloop == 4) {
+ /* Nothing to do, all indices and data is already assigned. */
+ }
+ else {
+ const CustomData *loop_data = &ctx->coarse_mesh->ldata;
+ const Mesh *coarse_mesh = ctx->coarse_mesh;
+ const MLoop *coarse_mloop = coarse_mesh->mloop;
+ LoopsOfPtex loops_of_ptex;
+ loops_of_ptex_get(ctx, &loops_of_ptex, coarse_poly, ptex_face_index);
+ /* Ptex face corner corresponds to a poly loop with same index. */
+ CustomData_copy_data(loop_data,
+ &loop_interpolation->loop_data_storage,
+ coarse_poly->loopstart + ptex_face_index,
+ 0,
+ 1);
+ /* Interpolate remaining ptex face corners, which hits loops
+ * middle points.
+ *
+ * TODO(sergey): Re-use one of interpolation results from previous
+ * iteration.
+ */
+ const float weights[2] = {0.5f, 0.5f};
+ const int first_indices[2] = {
+ loops_of_ptex.first_loop - coarse_mloop,
+ (loops_of_ptex.first_loop + 1 - coarse_mloop) %
+ coarse_poly->totloop};
+ const int last_indices[2] = {
+ loops_of_ptex.last_loop - coarse_mloop,
+ loops_of_ptex.first_loop - coarse_mloop};
+ CustomData_interp(loop_data,
+ &loop_interpolation->loop_data_storage,
+ first_indices,
+ weights, NULL,
+ 2,
+ 1);
+ CustomData_interp(loop_data,
+ &loop_interpolation->loop_data_storage,
+ last_indices,
+ weights, NULL,
+ 2,
+ 3);
+ }
+}
+
+static void loop_interpolation_end(LoopsForInterpolation *loop_interpolation)
+{
+ if (loop_interpolation->loop_data_storage_allocated) {
+ CustomData_free(&loop_interpolation->loop_data_storage, 4);
+ }
+}
+
+static void subdiv_copy_vertex_data(
+ const SubdivMeshContext *ctx,
+ MVert *subdiv_vertex,
+ const Mesh *coarse_mesh,
+ const MPoly *coarse_poly,
+ const VerticesForInterpolation *vertex_interpolation,
+ const int ptex_of_poly_index,
+ const float u, const float v)
+{
+ const int subdiv_vertex_index = subdiv_vertex - ctx->subdiv_mesh->mvert;
+ const float weights[4] = {(1.0f - u) * (1.0f - v),
+ u * (1.0f - v),
+ u * v,
+ (1.0f - u) * v};
+ CustomData_interp(vertex_interpolation->vertex_data,
+ &ctx->subdiv_mesh->vdata,
+ vertex_interpolation->vertex_indices,
+ weights, NULL,
+ 4,
+ subdiv_vertex_index);
+ if (ctx->vert_origindex != NULL) {
+ ctx->vert_origindex[subdiv_vertex_index] = ORIGINDEX_NONE;
+ if (coarse_poly->totloop == 4) {
+ if (u == 0.0f && v == 0.0f) {
+ ctx->vert_origindex[subdiv_vertex_index] =
+ vertex_interpolation->vertex_indices[0];
+ }
+ else if (u == 1.0f && v == 0.0f) {
+ ctx->vert_origindex[subdiv_vertex_index] =
+ vertex_interpolation->vertex_indices[1];
+ }
+ else if (u == 1.0f && v == 1.0f) {
+ ctx->vert_origindex[subdiv_vertex_index] =
+ vertex_interpolation->vertex_indices[2];
+ }
+ else if (u == 0.0f && v == 1.0f) {
+ ctx->vert_origindex[subdiv_vertex_index] =
+ vertex_interpolation->vertex_indices[3];
+ }
+ } else {
+ if (u == 0.0f && v == 0.0f) {
+ const MLoop *coarse_mloop = coarse_mesh->mloop;
+ ctx->vert_origindex[subdiv_vertex_index] =
+ coarse_mloop[coarse_poly->loopstart +
+ ptex_of_poly_index].v;
+ }
+ }
+ }
+}
+
+static void subdiv_evaluate_vertices(SubdivMeshContext *ctx,
+ const int poly_index)
+{
+ Subdiv *subdiv = ctx->subdiv;
+ const int resolution = ctx->settings->resolution;
+ const int resolution2 = resolution * resolution;
+ const float inv_resolution_1 = 1.0f / (float)(resolution - 1);
+ /* Base/coarse mesh information. */
+ const Mesh *coarse_mesh = ctx->coarse_mesh;
+ const MPoly *coarse_polyoly = coarse_mesh->mpoly;
+ const MPoly *coarse_poly = &coarse_polyoly[poly_index];
+ const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly);
+ /* Hi-poly subdivided mesh. */
+ Mesh *subdiv_mesh = ctx->subdiv_mesh;
+ MVert *subdiv_vertex = subdiv_mesh->mvert;
+ const int ptex_face_index = subdiv->face_ptex_offset[poly_index];
+ /* Actual evaluation. */
+ VerticesForInterpolation vertex_interpolation;
+ vertex_interpolation_init(ctx, &vertex_interpolation, coarse_poly);
+ MVert *subdiv_vert = &subdiv_vertex[ptex_face_index * resolution2];
+ for (int ptex_of_poly_index = 0;
+ ptex_of_poly_index < num_poly_ptex_faces;
+ ptex_of_poly_index++)
+ {
+ vertex_interpolation_from_ptex(ctx,
+ &vertex_interpolation,
+ coarse_poly,
+ ptex_of_poly_index);
+ const int current_ptex_face_index =
+ ptex_face_index + ptex_of_poly_index;
+ BKE_subdiv_eval_limit_patch_resolution_point_and_short_normal(
+ subdiv,
+ current_ptex_face_index,
+ resolution,
+ subdiv_vert, offsetof(MVert, co), sizeof(MVert),
+ subdiv_vert, offsetof(MVert, no), sizeof(MVert));
+ for (int y = 0; y < resolution; y++) {
+ const float v = y * inv_resolution_1;
+ for (int x = 0; x < resolution; x++, subdiv_vert++) {
+ const float u = x * inv_resolution_1;
+ subdiv_copy_vertex_data(ctx,
+ subdiv_vert,
+ coarse_mesh,
+ coarse_poly,
+ &vertex_interpolation,
+ ptex_of_poly_index,
+ u, v);
+ }
+ }
+ }
+ vertex_interpolation_end(&vertex_interpolation);
+}
+
+static void subdiv_copy_edge_data(
+ SubdivMeshContext *ctx,
+ MEdge *subdiv_edge,
+ const MEdge *coarse_edge)
+{
+ const int subdiv_edge_index = subdiv_edge - ctx->subdiv_mesh->medge;
+ if (coarse_edge == NULL) {
+ subdiv_edge->crease = 0;
+ subdiv_edge->bweight = 0;
+ subdiv_edge->flag = 0;
+ if (ctx->edge_origindex != NULL) {
+ ctx->edge_origindex[subdiv_edge_index] = ORIGINDEX_NONE;
+ }
+ return;
+ }
+ const int coarse_edge_index = coarse_edge - ctx->coarse_mesh->medge;
+ CustomData_copy_data(&ctx->coarse_mesh->edata,
+ &ctx->subdiv_mesh->edata,
+ coarse_edge_index,
+ subdiv_edge_index,
+ 1);
+ if (ctx->edge_origindex != NULL) {
+ ctx->edge_origindex[subdiv_edge_index] = coarse_edge_index;
+ }
+}
+
+static MEdge *subdiv_create_edges_row(SubdivMeshContext *ctx,
+ MEdge *subdiv_edge,
+ const MEdge *coarse_edge,
+ const int start_vertex_index,
+ const int resolution)
+{
+ int vertex_index = start_vertex_index;
+ for (int edge_index = 0;
+ edge_index < resolution - 1;
+ edge_index++, subdiv_edge++)
+ {
+ subdiv_copy_edge_data(ctx, subdiv_edge, coarse_edge);
+ subdiv_edge->v1 = vertex_index;
+ subdiv_edge->v2 = vertex_index + 1;
+ vertex_index += 1;
+ }
+ return subdiv_edge;
+}
+
+static MEdge *subdiv_create_edges_column(SubdivMeshContext *ctx,
+ MEdge *subdiv_edge,
+ const MEdge *coarse_start_edge,
+ const MEdge *coarse_end_edge,
+ const int start_vertex_index,
+ const int resolution)
+{
+ int vertex_index = start_vertex_index;
+ for (int edge_index = 0;
+ edge_index < resolution;
+ edge_index++, subdiv_edge++)
+ {
+ const MEdge *coarse_edge = NULL;
+ if (edge_index == 0) {
+ coarse_edge = coarse_start_edge;
+ }
+ else if (edge_index == resolution - 1) {
+ coarse_edge = coarse_end_edge;
+ }
+ subdiv_copy_edge_data(ctx, subdiv_edge, coarse_edge);
+ subdiv_edge->v1 = vertex_index;
+ subdiv_edge->v2 = vertex_index + resolution;
+ vertex_index += 1;
+ }
+ return subdiv_edge;
+}
+
+static void subdiv_create_edges(SubdivMeshContext *ctx, int poly_index)
+{
+ Subdiv *subdiv = ctx->subdiv;
+ const int resolution = ctx->settings->resolution;
+ const int resolution2 = resolution * resolution;
+ const int ptex_face_index = subdiv->face_ptex_offset[poly_index];
+ const int num_edges_per_ptex = num_edges_per_ptex_get(resolution);
+ const int start_edge_index = ptex_face_index * num_edges_per_ptex;
+ /* Base/coarse mesh information. */
+ const Mesh *coarse_mesh = ctx->coarse_mesh;
+ const MPoly *coarse_polyoly = coarse_mesh->mpoly;
+ const MPoly *coarse_poly = &coarse_polyoly[poly_index];
+ const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly);
+ /* Hi-poly subdivided mesh. */
+ Mesh *subdiv_mesh = ctx->subdiv_mesh;
+ MEdge *subdiv_medge = subdiv_mesh->medge;
+ MEdge *subdiv_edge = &subdiv_medge[start_edge_index];
+ const int start_poly_vertex_index = ptex_face_index * resolution2;
+ /* Consider a subdivision of base face at level 1:
+ *
+ * y
+ * ^
+ * | (6) ---- (7) ---- (8)
+ * | | | |
+ * | (3) ---- (4) ---- (5)
+ * | | | |
+ * | (0) ---- (1) ---- (2)
+ * o---------------------------> x
+ *
+ * This is illustrate which parts of geometry is created by code below.
+ */
+ for (int i = 0; i < num_poly_ptex_faces; i++) {
+ const int start_ptex_face_vertex_index =
+ start_poly_vertex_index + i * resolution2;
+ EdgesOfPtex edges_of_ptex;
+ edges_of_ptex_get(ctx, &edges_of_ptex, coarse_poly, i);
+ /* Create bottom row of edges (0-1, 1-2). */
+ subdiv_edge = subdiv_create_edges_row(
+ ctx,
+ subdiv_edge,
+ edges_of_ptex.first_edge,
+ start_ptex_face_vertex_index,
+ resolution);
+ /* Create remaining edges. */
+ for (int row = 0; row < resolution - 1; row++) {
+ const int start_row_vertex_index =
+ start_ptex_face_vertex_index + row * resolution;
+ /* Create vertical columns.
+ *
+ * At first iteration it will be edges (0-3. 1-4, 2-5), then it
+ * will be (3-6, 4-7, 5-8) and so on.
+ */
+ subdiv_edge = subdiv_create_edges_column(
+ ctx,
+ subdiv_edge,
+ edges_of_ptex.last_edge,
+ edges_of_ptex.second_edge,
+ start_row_vertex_index,
+ resolution);
+ /* Create horizontal edge row.
+ *
+ * At first iteration it will be edges (3-4, 4-5), then it will be
+ * (6-7, 7-8) and so on.
+ */
+ subdiv_edge = subdiv_create_edges_row(
+ ctx,
+ subdiv_edge,
+ (row == resolution - 2) ? edges_of_ptex.third_edge
+ : NULL,
+ start_row_vertex_index + resolution,
+ resolution);
+ }
+ }
+}
+
+static void subdiv_copy_loop_data(
+ const SubdivMeshContext *ctx,
+ MLoop *subdiv_loop,
+ const LoopsForInterpolation *loop_interpolation,
+ const float u, const float v)
+{
+ const int subdiv_loop_index = subdiv_loop - ctx->subdiv_mesh->mloop;
+ const float weights[4] = {(1.0f - u) * (1.0f - v),
+ u * (1.0f - v),
+ u * v,
+ (1.0f - u) * v};
+ CustomData_interp(loop_interpolation->loop_data,
+ &ctx->subdiv_mesh->ldata,
+ loop_interpolation->loop_indices,
+ weights, NULL,
+ 4,
+ subdiv_loop_index);
+ /* TODO(sergey): Set ORIGINDEX. */
+}
+
+static void subdiv_eval_uv_layer(SubdivMeshContext *ctx,
+ MLoop *subdiv_loop,
+ const int ptex_face_index,
+ const float u, const float v,
+ const float inv_resolution_1)
+{
+ if (ctx->num_uv_layers == 0) {
+ return;
+ }
+ Subdiv *subdiv = ctx->subdiv;
+ const int mloop_index = subdiv_loop - ctx->subdiv_mesh->mloop;
+ const float du = inv_resolution_1;
+ const float dv = inv_resolution_1;
+ for (int layer_index = 0; layer_index < ctx->num_uv_layers; layer_index++) {
+ MLoopUV *subdiv_loopuv = &ctx->uv_layers[layer_index][mloop_index];
+ BKE_subdiv_eval_face_varying(subdiv,
+ ptex_face_index,
+ u, v,
+ subdiv_loopuv[0].uv);
+ BKE_subdiv_eval_face_varying(subdiv,
+ ptex_face_index,
+ u + du, v,
+ subdiv_loopuv[1].uv);
+ BKE_subdiv_eval_face_varying(subdiv,
+ ptex_face_index,
+ u + du, v + dv,
+ subdiv_loopuv[2].uv);
+ BKE_subdiv_eval_face_varying(subdiv,
+ ptex_face_index,
+ u, v + dv,
+ subdiv_loopuv[3].uv);
+ /* TODO(sergey): Currently evaluator only has single UV layer, so can
+ * not evaluate more than that. Need to be solved.
+ */
+ break;
+ }
+}
+
+static void subdiv_create_loops(SubdivMeshContext *ctx, int poly_index)
+{
+ Subdiv *subdiv = ctx->subdiv;
+ const int resolution = ctx->settings->resolution;
+ const int resolution2 = resolution * resolution;
+ const float inv_resolution_1 = 1.0f / (float)(resolution - 1);
+ const int ptex_face_index = subdiv->face_ptex_offset[poly_index];
+ const int num_edges_per_ptex = num_edges_per_ptex_get(resolution);
+ const int start_edge_index = ptex_face_index * num_edges_per_ptex;
+ const int num_polys_per_ptex = num_polys_per_ptex_get(resolution);
+ const int start_poly_index = ptex_face_index * num_polys_per_ptex;
+ const int start_loop_index = 4 * start_poly_index;
+ const int start_vert_index = ptex_face_index * resolution2;
+ const float du = inv_resolution_1;
+ const float dv = inv_resolution_1;
+ /* Base/coarse mesh information. */
+ const Mesh *coarse_mesh = ctx->coarse_mesh;
+ const MPoly *coarse_polyoly = coarse_mesh->mpoly;
+ const MPoly *coarse_poly = &coarse_polyoly[poly_index];
+ const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly);
+ /* Hi-poly subdivided mesh. */
+ Mesh *subdiv_mesh = ctx->subdiv_mesh;
+ MLoop *subdiv_loopoop = subdiv_mesh->mloop;
+ MLoop *subdiv_loop = &subdiv_loopoop[start_loop_index];
+ LoopsForInterpolation loop_interpolation;
+ loop_interpolation_init(ctx, &loop_interpolation, coarse_poly);
+ for (int ptex_of_poly_index = 0;
+ ptex_of_poly_index < num_poly_ptex_faces;
+ ptex_of_poly_index++)
+ {
+ loop_interpolation_from_ptex(ctx,
+ &loop_interpolation,
+ coarse_poly,
+ ptex_of_poly_index);
+ const int current_ptex_face_index =
+ ptex_face_index + ptex_of_poly_index;
+ for (int y = 0; y < resolution - 1; y++) {
+ const float v = y * inv_resolution_1;
+ for (int x = 0; x < resolution - 1; x++, subdiv_loop += 4) {
+ const float u = x * inv_resolution_1;
+ /* Vertex indicies ordered counter-clockwise. */
+ const int v0 = start_vert_index +
+ (ptex_of_poly_index * resolution2) +
+ (y * resolution + x);
+ const int v1 = v0 + 1;
+ const int v2 = v0 + resolution + 1;
+ const int v3 = v0 + resolution;
+ /* Edge indicies ordered counter-clockwise. */
+ const int e0 = start_edge_index +
+ (ptex_of_poly_index * num_edges_per_ptex) +
+ (y * (2 * resolution - 1) + x);
+ const int e1 = e0 + resolution;
+ const int e2 = e0 + (2 * resolution - 1);
+ const int e3 = e0 + resolution - 1;
+ /* Initialize 4 loops of corresponding hi-poly poly. */
+ /* TODO(sergey): For ptex boundaries we should use loops from
+ * coarse mesh.
+ */
+ subdiv_copy_loop_data(ctx,
+ &subdiv_loop[0],
+ &loop_interpolation,
+ u, v);
+ subdiv_loop[0].v = v0;
+ subdiv_loop[0].e = e0;
+ subdiv_copy_loop_data(ctx,
+ &subdiv_loop[1],
+ &loop_interpolation,
+ u + du, v);
+ subdiv_loop[1].v = v1;
+ subdiv_loop[1].e = e1;
+ subdiv_copy_loop_data(ctx,
+ &subdiv_loop[2],
+ &loop_interpolation,
+ u + du, v + dv);
+ subdiv_loop[2].v = v2;
+ subdiv_loop[2].e = e2;
+ subdiv_copy_loop_data(ctx,
+ &subdiv_loop[3],
+ &loop_interpolation,
+ u, v + dv);
+ subdiv_loop[3].v = v3;
+ subdiv_loop[3].e = e3;
+ /* Interpolate UV layers using OpenSubdiv. */
+ subdiv_eval_uv_layer(ctx,
+ subdiv_loop,
+ current_ptex_face_index,
+ u, v,
+ inv_resolution_1);
+ }
+ }
+ }
+ loop_interpolation_end(&loop_interpolation);
+}
+
+static void subdiv_copy_poly_data(const SubdivMeshContext *ctx,
+ MPoly *subdiv_poly,
+ const MPoly *coarse_poly)
+{
+ const int coarse_poly_index = coarse_poly - ctx->coarse_mesh->mpoly;
+ const int subdiv_poly_index = subdiv_poly - ctx->subdiv_mesh->mpoly;
+ CustomData_copy_data(&ctx->coarse_mesh->pdata,
+ &ctx->subdiv_mesh->pdata,
+ coarse_poly_index,
+ subdiv_poly_index,
+ 1);
+ if (ctx->poly_origindex != NULL) {
+ ctx->poly_origindex[subdiv_poly_index] = coarse_poly_index;
+ }
+}
+
+static void subdiv_create_polys(SubdivMeshContext *ctx, int poly_index)
+{
+ Subdiv *subdiv = ctx->subdiv;
+ const int resolution = ctx->settings->resolution;
+ const int ptex_face_index = subdiv->face_ptex_offset[poly_index];
+ const int num_polys_per_ptex = num_polys_per_ptex_get(resolution);
+ const int num_loops_per_ptex = 4 * num_polys_per_ptex;
+ const int start_poly_index = ptex_face_index * num_polys_per_ptex;
+ const int start_loop_index = 4 * start_poly_index;
+ /* Base/coarse mesh information. */
+ const Mesh *coarse_mesh = ctx->coarse_mesh;
+ const MPoly *coarse_polyoly = coarse_mesh->mpoly;
+ const MPoly *coarse_poly = &coarse_polyoly[poly_index];
+ const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly);
+ /* Hi-poly subdivided mesh. */
+ Mesh *subdiv_mesh = ctx->subdiv_mesh;
+ MPoly *subdiv_mpoly = subdiv_mesh->mpoly;
+ MPoly *subdiv_mp = &subdiv_mpoly[start_poly_index];
+ for (int ptex_of_poly_index = 0;
+ ptex_of_poly_index < num_poly_ptex_faces;
+ ptex_of_poly_index++)
+ {
+ for (int subdiv_poly_index = 0;
+ subdiv_poly_index < num_polys_per_ptex;
+ subdiv_poly_index++, subdiv_mp++)
+ {
+ subdiv_copy_poly_data(ctx, subdiv_mp, coarse_poly);
+ subdiv_mp->loopstart = start_loop_index +
+ (ptex_of_poly_index * num_loops_per_ptex) +
+ (subdiv_poly_index * 4);
+ subdiv_mp->totloop = 4;
+ }
+ }
+}
+
+static void subdiv_eval_task(
+ void *__restrict userdata,
+ const int poly_index,
+ const ParallelRangeTLS *__restrict UNUSED(tls))
+{
+ SubdivMeshContext *data = userdata;
+ /* Evaluate hi-poly vertex coordinates and normals. */
+ subdiv_evaluate_vertices(data, poly_index);
+ /* Create mesh geometry for the given base poly index. */
+ subdiv_create_edges(data, poly_index);
+ subdiv_create_loops(data, poly_index);
+ subdiv_create_polys(data, poly_index);
+}
+
+static void cache_uv_layers(SubdivMeshContext *ctx)
+{
+ Mesh *subdiv_mesh = ctx->subdiv_mesh;
+ ctx->num_uv_layers =
+ CustomData_number_of_layers(&subdiv_mesh->ldata, CD_MLOOPUV);
+ for (int layer_index = 0; layer_index < ctx->num_uv_layers; ++layer_index) {
+ ctx->uv_layers[layer_index] = CustomData_get_layer_n(
+ &subdiv_mesh->ldata, CD_MLOOPUV, layer_index);
+ }
+}
+
+static void cache_custom_data_layers(SubdivMeshContext *ctx)
+{
+ Mesh *subdiv_mesh = ctx->subdiv_mesh;
+ /* Pointers to original indices layers. */
+ ctx->vert_origindex = CustomData_get_layer(
+ &subdiv_mesh->vdata, CD_ORIGINDEX);
+ ctx->edge_origindex = CustomData_get_layer(
+ &subdiv_mesh->edata, CD_ORIGINDEX);
+ ctx->loop_origindex = CustomData_get_layer(
+ &subdiv_mesh->ldata, CD_ORIGINDEX);
+ ctx->poly_origindex = CustomData_get_layer(
+ &subdiv_mesh->pdata, CD_ORIGINDEX);
+ /* UV layers interpolation. */
+ cache_uv_layers(ctx);
+}
+
+Mesh *BKE_subdiv_to_mesh(
+ Subdiv *subdiv,
+ const SubdivToMeshSettings *settings,
+ const Mesh *coarse_mesh)
+{
+ BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH);
+ /* Make sure evaluator is up to date with possible new topology, and that
+ * is is refined for the new positions of coarse vertices.
+ */
+ BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh);
+ const int resolution = settings->resolution;
+ const int resolution2 = resolution * resolution;
+ const int num_result_verts = subdiv->num_ptex_faces * resolution2;
+ const int num_result_edges =
+ subdiv->num_ptex_faces * num_edges_per_ptex_get(resolution);
+ const int num_result_polys =
+ subdiv->num_ptex_faces * num_polys_per_ptex_get(resolution);
+ const int num_result_loops = 4 * num_result_polys;
+ /* Create mesh and its arrays. */
+ Mesh *result = BKE_mesh_new_nomain_from_template(
+ coarse_mesh,
+ num_result_verts,
+ num_result_edges,
+ 0,
+ num_result_loops,
+ num_result_polys);
+ /* Evaluate subdivisions of base faces in threads. */
+ SubdivMeshContext ctx;
+ ctx.coarse_mesh = coarse_mesh;
+ ctx.subdiv = subdiv;
+ ctx.subdiv_mesh = result;
+ ctx.settings = settings;
+ cache_custom_data_layers(&ctx);
+ /* Multi-threaded evaluation. */
+ ParallelRangeSettings parallel_range_settings;
+ BLI_parallel_range_settings_defaults(&parallel_range_settings);
+ BLI_task_parallel_range(0, coarse_mesh->totpoly,
+ &ctx,
+ subdiv_eval_task,
+ &parallel_range_settings);
+ BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH);
+ return result;
+}
diff --git a/source/blender/blenkernel/intern/subdiv_stats.c b/source/blender/blenkernel/intern/subdiv_stats.c
new file mode 100644
index 00000000000..5da63fdbacb
--- /dev/null
+++ b/source/blender/blenkernel/intern/subdiv_stats.c
@@ -0,0 +1,80 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/subdiv_stats.c
+ * \ingroup bke
+ */
+
+#include "BKE_subdiv.h"
+
+#include <stdio.h>
+
+#include "PIL_time.h"
+
+void BKE_subdiv_stats_init(SubdivStats *stats)
+{
+ stats->topology_refiner_creation_time = 0.0;
+ stats->subdiv_to_mesh_time = 0.0;
+ stats->evaluator_creation_time = 0.0;
+ stats->evaluator_refine_time = 0.0;
+}
+
+void BKE_subdiv_stats_begin(SubdivStats *stats, eSubdivStatsValue value)
+{
+ stats->begin_timestamp_[value] = PIL_check_seconds_timer();
+}
+
+void BKE_subdiv_stats_end(SubdivStats *stats, eSubdivStatsValue value)
+{
+ stats->values_[value] =
+ PIL_check_seconds_timer() - stats->begin_timestamp_[value];
+}
+
+void BKE_subdiv_stats_print(const SubdivStats *stats)
+{
+#define STATS_PRINT_TIME(stats, value, description) \
+ do { \
+ if ((stats)->value > 0.0) { \
+ printf(" %s: %f (sec)\n", description, (stats)->value); \
+ } \
+ } while (false)
+
+ printf("Subdivision surface statistics:\n");
+
+ STATS_PRINT_TIME(stats,
+ topology_refiner_creation_time,
+ "Topology refiner creation time");
+ STATS_PRINT_TIME(stats,
+ subdiv_to_mesh_time,
+ "Subdivision to mesh time");
+ STATS_PRINT_TIME(stats,
+ evaluator_creation_time,
+ "Evaluator creation time");
+ STATS_PRINT_TIME(stats,
+ evaluator_refine_time,
+ "Evaluator refine time");
+
+#undef STATS_PRINT_TIME
+}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 9ea6ef62e4e..cead75ae659 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -280,11 +280,11 @@ static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct ML
for (nv = v = BKE_mesh_uv_vert_map_get_vert(vmap, ml[j].v); v; v = v->next) {
if (v->separate)
nv = v;
- if (v->f == fi)
+ if (v->poly_index == fi)
break;
}
- fverts[j] = SET_UINT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex);
+ fverts[j] = SET_UINT_IN_POINTER(mpoly[nv->poly_index].loopstart + nv->loop_of_poly_index);
}
}
@@ -292,7 +292,6 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
{
MPoly *mpoly = dm->getPolyArray(dm);
MLoop *mloop = dm->getLoopArray(dm);
- MVert *mvert = dm->getVertArray(dm);
int totvert = dm->getNumVerts(dm);
int totface = dm->getNumPolys(dm);
int i, seam;
@@ -304,13 +303,12 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
BLI_array_declare(fverts);
#endif
EdgeSet *eset;
- float creaseFactor = (float)ccgSubSurf_getSubdivisionLevels(ss);
float uv[3] = {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */
limit[0] = limit[1] = STD_UV_CONNECT_LIMIT;
/* previous behavior here is without accounting for winding, however this causes stretching in
* UV map in really simple cases with mirror + subsurf, see second part of T44530. Also, initially
- * intention is to treat merged vertices from mirror modifier as seams, see code below with ME_VERT_MERGED
+ * intention is to treat merged vertices from mirror modifier as seams.
* This fixes a very old regression (2.49 was correct here) */
vmap = BKE_mesh_uv_vert_map_create(mpoly, mloop, mloopuv, totface, totvert, limit, false, true);
if (!vmap)
@@ -327,12 +325,12 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
if (v->separate)
break;
- seam = (v != NULL) || ((mvert + i)->flag & ME_VERT_MERGED);
+ seam = (v != NULL);
for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i); v; v = v->next) {
if (v->separate) {
CCGVert *ssv;
- int loopid = mpoly[v->f].loopstart + v->tfindex;
+ int loopid = mpoly[v->poly_index].loopstart + v->loop_of_poly_index;
CCGVertHDL vhdl = SET_INT_IN_POINTER(loopid);
copy_v2_v2(uv, mloopuv[loopid].uv);
@@ -365,18 +363,11 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
for (j = 0, j_next = nverts - 1; j < nverts; j_next = j++) {
unsigned int v0 = GET_UINT_FROM_POINTER(fverts[j_next]);
unsigned int v1 = GET_UINT_FROM_POINTER(fverts[j]);
- MVert *mv0 = mvert + (ml[j_next].v);
- MVert *mv1 = mvert + (ml[j].v);
if (BLI_edgeset_add(eset, v0, v1)) {
CCGEdge *e, *orige = ccgSubSurf_getFaceEdge(origf, j_next);
CCGEdgeHDL ehdl = SET_INT_IN_POINTER(mp->loopstart + j_next);
- float crease;
-
- if ((mv0->flag & mv1->flag) & ME_VERT_MERGED)
- crease = creaseFactor;
- else
- crease = ccgSubSurf_getEdgeCrease(orige);
+ float crease = ccgSubSurf_getEdgeCrease(orige);
ccgSubSurf_syncEdge(ss, ehdl, fverts[j_next], fverts[j], crease, &e);
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index ad60e81fe19..c5a208e3aca 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -233,7 +233,6 @@ void BKE_texture_default(Tex *tex)
tex->texfilter = TXF_EWA;
tex->afmax = 8;
tex->xrepeat = tex->yrepeat = 1;
- tex->fie_ima = 2;
tex->sfra = 1;
tex->frames = 0;
tex->offset = 0;
@@ -267,7 +266,6 @@ void BKE_texture_default(Tex *tex)
tex->vn_distm = 0;
tex->vn_coltype = 0;
- tex->iuser.fie_ima = 2;
tex->iuser.ok = 1;
tex->iuser.frames = 100;
tex->iuser.sfra = 1;
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index f0f57e8e56c..a5e93c8d765 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -157,7 +157,6 @@ WorkSpace *BKE_workspace_add(Main *bmain, const char *name)
void BKE_workspace_free(WorkSpace *workspace)
{
BKE_workspace_relations_free(&workspace->hook_layout_relations);
- BLI_freelistN(&workspace->scene_layer_relations);
BLI_freelistN(&workspace->owner_ids);
BLI_freelistN(&workspace->layouts);
@@ -166,10 +165,10 @@ void BKE_workspace_free(WorkSpace *workspace)
tref_next = tref->next;
if (tref->runtime) {
MEM_freeN(tref->runtime);
- if (tref->properties) {
- IDP_FreeProperty(tref->properties);
- MEM_freeN(tref->properties);
- }
+ }
+ if (tref->properties) {
+ IDP_FreeProperty(tref->properties);
+ MEM_freeN(tref->properties);
}
}
BLI_freelistN(&workspace->tools);
@@ -267,48 +266,9 @@ void BKE_workspace_relations_free(
}
}
-void BKE_workspace_scene_relations_free_invalid(
- WorkSpace *workspace)
-{
- for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first, *relation_next; relation; relation = relation_next) {
- relation_next = relation->next;
-
- if (relation->scene == NULL) {
- BLI_freelinkN(&workspace->scene_layer_relations, relation);
- }
- else if (!BLI_findstring(&relation->scene->view_layers, relation->view_layer, offsetof(ViewLayer, name))) {
- BLI_freelinkN(&workspace->scene_layer_relations, relation);
- }
- }
-}
-
/* -------------------------------------------------------------------- */
/* General Utils */
-void BKE_workspace_view_layer_rename(
- const Main *bmain,
- const Scene *scene,
- const char *old_name,
- const char *new_name)
-{
- for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
- for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first; relation; relation = relation->next) {
- if (relation->scene == scene && STREQ(relation->view_layer, old_name)) {
- STRNCPY(relation->view_layer, new_name);
- }
- }
- }
-}
-
-void BKE_workspace_view_layer_remove(
- const Main *bmain,
- const ViewLayer *UNUSED(view_layer))
-{
- for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
- BKE_workspace_scene_relations_free_invalid(workspace);
- }
-}
-
WorkSpaceLayout *BKE_workspace_layout_find(
const WorkSpace *workspace, const bScreen *screen)
{
@@ -429,46 +389,6 @@ void BKE_workspace_active_screen_set(WorkSpaceInstanceHook *hook, WorkSpace *wor
BKE_workspace_hook_layout_for_workspace_set(hook, workspace, layout);
}
-Base *BKE_workspace_active_base_get(const WorkSpace *workspace, const Scene *scene)
-{
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
- return view_layer->basact;
-}
-
-ViewLayer *BKE_workspace_view_layer_exists(const WorkSpace *workspace, const Scene *scene)
-{
- WorkSpaceSceneRelation *relation = BLI_findptr(&workspace->scene_layer_relations, scene, offsetof(WorkSpaceSceneRelation, scene));
- return (relation) ? BLI_findstring(&scene->view_layers, relation->view_layer, offsetof(ViewLayer, name)) : NULL;
-}
-
-ViewLayer *BKE_workspace_view_layer_get(const WorkSpace *workspace, const Scene *scene)
-{
- ViewLayer *layer = BKE_workspace_view_layer_exists(workspace, scene);
-
- if (layer == NULL) {
- BKE_workspace_view_layer_set((WorkSpace *)workspace, scene->view_layers.first, (Scene *)scene);
- layer = scene->view_layers.first;
- }
-
- return layer;
-}
-
-void BKE_workspace_view_layer_set(WorkSpace *workspace, ViewLayer *layer, Scene *scene)
-{
- WorkSpaceSceneRelation *relation = BLI_findptr(&workspace->scene_layer_relations, scene, offsetof(WorkSpaceSceneRelation, scene));
- if (relation == NULL) {
- relation = MEM_callocN(sizeof(*relation), __func__);
- }
- else {
- BLI_remlink(&workspace->scene_layer_relations, relation);
- }
-
- /* (Re)insert at the head of the list, for faster lookups. */
- relation->scene = scene;
- STRNCPY(relation->view_layer, layer->name);
- BLI_addhead(&workspace->scene_layer_relations, relation);
-}
-
ListBase *BKE_workspace_layouts_get(WorkSpace *workspace)
{
return &workspace->layouts;
@@ -504,27 +424,6 @@ void BKE_workspace_hook_layout_for_workspace_set(
workspace_relation_ensure_updated(&workspace->hook_layout_relations, hook, layout);
}
-/* Update / evaluate */
-
-void BKE_workspace_update_tagged(Main *bmain,
- WorkSpace *workspace,
- Scene *scene)
-{
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
- struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene,
- view_layer,
- true);
- /* TODO(sergey): For now all dependency graphs which are evaluated from
- * workspace are considered active. This will work all fine with "locked"
- * view layer and time across windows. This is to be granted separately,
- * and for until then we have to accept ambiguities when object is shared
- * across visible view layers and has overrides on it.
- */
- DEG_make_active(depsgraph);
- BKE_scene_graph_update_tagged(depsgraph, bmain);
-}
-
-
bool BKE_workspace_owner_id_check(
const WorkSpace *workspace, const char *owner_id)
{
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 69096ad7a08..3e1a9a4f57b 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -53,6 +53,8 @@
#include "BKE_node.h"
#include "BKE_world.h"
+#include "DRW_engine.h"
+
#include "DEG_depsgraph.h"
#include "GPU_material.h"
@@ -62,6 +64,8 @@ void BKE_world_free(World *wrld)
{
BKE_animdata_free((ID *)wrld, false);
+ DRW_drawdata_free((ID *)wrld);
+
/* is no lib link block, but world extension */
if (wrld->nodetree) {
ntreeFreeTree(wrld->nodetree);
@@ -119,6 +123,7 @@ void BKE_world_copy_data(Main *bmain, World *wrld_dst, const World *wrld_src, co
}
BLI_listbase_clear(&wrld_dst->gpumaterial);
+ BLI_listbase_clear((ListBase *)&wrld_dst->drawdata);
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
BKE_previewimg_id_copy(&wrld_dst->id, &wrld_src->id);
@@ -154,6 +159,7 @@ World *BKE_world_localize(World *wrld)
wrldn->preview = NULL;
BLI_listbase_clear(&wrldn->gpumaterial);
+ BLI_listbase_clear((ListBase *)&wrldn->drawdata);
return wrldn;
}
@@ -163,10 +169,3 @@ void BKE_world_make_local(Main *bmain, World *wrld, const bool lib_local)
BKE_id_make_local_generic(bmain, &wrld->id, true, lib_local);
}
-void BKE_world_eval(struct Depsgraph *depsgraph, World *world)
-{
- DEG_debug_print_eval(depsgraph, __func__, world->id.name, world);
- if (!BLI_listbase_is_empty(&world->gpumaterial)) {
- world->update_flag = 1;
- }
-}
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index 994592ec307..1db239b3c6f 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -197,8 +197,6 @@ static int start_avi(void *context_v, Scene *UNUSED(scene), RenderData *rd, int
avi->interlace = 0;
avi->odd_fields = 0;
-/* avi->interlace = rd->mode & R_FIELDS; */
-/* avi->odd_fields = (rd->mode & R_ODDFIELD) ? 1 : 0; */
printf("Created avi: %s\n", name);
return 1;
diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h
index c913510bda3..f53a4b385b4 100644
--- a/source/blender/blenlib/BLI_callbacks.h
+++ b/source/blender/blenlib/BLI_callbacks.h
@@ -49,6 +49,10 @@ typedef enum {
BLI_CB_EVT_LOAD_POST,
BLI_CB_EVT_SAVE_PRE,
BLI_CB_EVT_SAVE_POST,
+ BLI_CB_EVT_UNDO_PRE,
+ BLI_CB_EVT_UNDO_POST,
+ BLI_CB_EVT_REDO_PRE,
+ BLI_CB_EVT_REDO_POST,
BLI_CB_EVT_VERSION_UPDATE,
BLI_CB_EVT_TOT
} eCbEvent;
diff --git a/source/blender/blenlib/BLI_hash_mm3.h b/source/blender/blenlib/BLI_hash_mm3.h
new file mode 100644
index 00000000000..93bf963c9a4
--- /dev/null
+++ b/source/blender/blenlib/BLI_hash_mm3.h
@@ -0,0 +1,40 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_HASH_MM3_H__
+#define __BLI_HASH_MM3_H__
+
+/** \file BLI_hash_mm3.h
+ * \ingroup bli
+ */
+
+#include "BLI_sys_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+uint32_t BLI_hash_mm3(const unsigned char *data, size_t len, uint32_t seed);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BLI_HASH_MM2A_H__ */
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 20852f8fc82..ec16a6854c4 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -169,6 +169,7 @@ MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) ATTR_WARN_UNUS
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
+MINLINE void cross_v3_v3v3_hi_prec(float r[3], const float a[3], const float b[3]);
MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3]);
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 61f53f938e2..9621a759f3c 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -74,6 +74,7 @@ set(SRC
intern/gsqueue.c
intern/hash_md5.c
intern/hash_mm2a.c
+ intern/hash_mm3.c
intern/jitter_2d.c
intern/lasso_2d.c
intern/list_sort_impl.h
@@ -158,6 +159,7 @@ set(SRC
BLI_hash.h
BLI_hash_md5.h
BLI_hash_mm2a.h
+ BLI_hash_mm3.h
BLI_heap.h
BLI_iterator.h
BLI_jitter_2d.h
diff --git a/source/blender/blenlib/intern/hash_mm3.c b/source/blender/blenlib/intern/hash_mm3.c
new file mode 100644
index 00000000000..105c1f46832
--- /dev/null
+++ b/source/blender/blenlib/intern/hash_mm3.c
@@ -0,0 +1,147 @@
+/*
+ * ***** 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 *****
+ *
+ * Copyright (C) 2018 Blender Foundation.
+ *
+ */
+
+/** \file blender/blenlib/intern/hash_mm3.c
+ * \ingroup bli
+ *
+ * Functions to compute Murmur3 hash key.
+ *
+ * This Code is based on alShaders/Cryptomatte/MurmurHash3.h:
+ *
+ * MurmurHash3 was written by Austin Appleby, and is placed in the public
+ * domain. The author hereby disclaims copyright to this source code.
+ *
+ */
+
+#include "BLI_compiler_compat.h"
+#include "BLI_compiler_attrs.h"
+#include "BLI_hash_mm3.h" /* own include */
+
+#if defined(_MSC_VER)
+# include <stdlib.h>
+# define ROTL32(x,y) _rotl(x,y)
+# define BIG_CONSTANT(x) (x)
+
+/* Other compilers */
+#else /* defined(_MSC_VER) */
+static inline uint32_t rotl32(uint32_t x, int8_t r)
+{
+ return (x << r) | (x >> (32 - r));
+}
+# define ROTL32(x,y) rotl32(x,y)
+# define BIG_CONSTANT(x) (x##LLU)
+#endif /* !defined(_MSC_VER) */
+
+/* Block read - if your platform needs to do endian-swapping or can only
+ * handle aligned reads, do the conversion here
+ */
+
+BLI_INLINE uint32_t getblock32(const uint32_t * p, int i)
+{
+ return p[i];
+}
+
+BLI_INLINE uint64_t getblock64(const uint64_t * p, int i)
+{
+ return p[i];
+}
+
+/* Finalization mix - force all bits of a hash block to avalanche */
+
+BLI_INLINE uint32_t fmix32(uint32_t h)
+{
+ h ^= h >> 16;
+ h *= 0x85ebca6b;
+ h ^= h >> 13;
+ h *= 0xc2b2ae35;
+ h ^= h >> 16;
+
+ return h;
+}
+
+BLI_INLINE uint64_t fmix64(uint64_t k)
+{
+ k ^= k >> 33;
+ k *= BIG_CONSTANT(0xff51afd7ed558ccd);
+ k ^= k >> 33;
+ k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
+ k ^= k >> 33;
+
+ return k;
+}
+
+uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
+{
+ const uint8_t *data = (const uint8_t *)in;
+ const int nblocks = len / 4;
+
+ uint32_t h1 = seed;
+
+ const uint32_t c1 = 0xcc9e2d51;
+ const uint32_t c2 = 0x1b873593;
+
+ /* body */
+
+ const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
+
+ for (int i = -nblocks; i; i++) {
+ uint32_t k1 = getblock32(blocks, i);
+
+ k1 *= c1;
+ k1 = ROTL32(k1, 15);
+ k1 *= c2;
+
+ h1 ^= k1;
+ h1 = ROTL32(h1, 13);
+ h1 = h1 * 5 + 0xe6546b64;
+ }
+
+ /* tail */
+
+ const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
+
+ uint32_t k1 = 0;
+
+ switch (len & 3) {
+ case 3:
+ k1 ^= tail[2] << 16;
+ ATTR_FALLTHROUGH;
+ case 2:
+ k1 ^= tail[1] << 8;
+ ATTR_FALLTHROUGH;
+ case 1:
+ k1 ^= tail[0];
+ k1 *= c1;
+ k1 = ROTL32(k1, 15);
+ k1 *= c2;
+ h1 ^= k1;
+ }
+
+ /* finalization */
+
+ h1 ^= len;
+
+ h1 = fmix32(h1);
+
+ return h1;
+}
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 4c40921edb6..189b94a6f13 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -753,6 +753,16 @@ MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
r[2] = a[0] * b[1] - a[1] * b[0];
}
+/* cross product suffers from severe precision loss when vectors are
+ * nearly parallel or opposite; doing the computation in double helps a lot */
+MINLINE void cross_v3_v3v3_hi_prec(float r[3], const float a[3], const float b[3])
+{
+ BLI_assert(r != a && r != b);
+ r[0] = (float)((double)a[1] * (double)b[2] - (double)a[2] * (double)b[1]);
+ r[1] = (float)((double)a[2] * (double)b[0] - (double)a[0] * (double)b[2]);
+ r[2] = (float)((double)a[0] * (double)b[1] - (double)a[1] * (double)b[0]);
+}
+
/* Newell's Method */
/* excuse this fairly specific function,
* its used for polygon normals all over the place
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index b340aa28324..72fa155553d 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -30,6 +30,7 @@ set(INC
../blenlib
../blentranslation
../depsgraph
+ ../draw
../imbuf
../makesdna
../makesrna
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 7488d62bb3c..6fd77c34977 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -393,6 +393,9 @@ BlendFileData *BLO_read_from_memfile(
/* makes lookup of existing images in old main */
blo_make_image_pointer_map(fd, oldmain);
+ /* makes lookup of existing light caches in old main */
+ blo_make_scene_pointer_map(fd, oldmain);
+
/* makes lookup of existing video clips in old main */
blo_make_movieclip_pointer_map(fd, oldmain);
@@ -403,6 +406,9 @@ BlendFileData *BLO_read_from_memfile(
bfd = blo_read_file_internal(fd, filename);
+ /* ensures relinked light caches are not freed */
+ blo_end_scene_pointer_map(fd, oldmain);
+
/* ensures relinked images are not freed */
blo_end_image_pointer_map(fd, oldmain);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 79a552a5b86..d76a2fc2cd0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -145,6 +145,7 @@
#include "BKE_multires.h"
#include "BKE_node.h" // for tree type defines
#include "BKE_object.h"
+#include "BKE_ocean.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
@@ -157,6 +158,8 @@
#include "BKE_colortools.h"
#include "BKE_workspace.h"
+#include "DRW_engine.h"
+
#include "DEG_depsgraph.h"
#include "NOD_common.h"
@@ -1338,6 +1341,8 @@ void blo_freefiledata(FileData *fd)
oldnewmap_free(fd->imamap);
if (fd->movieclipmap)
oldnewmap_free(fd->movieclipmap);
+ if (fd->scenemap)
+ oldnewmap_free(fd->scenemap);
if (fd->soundmap)
oldnewmap_free(fd->soundmap);
if (fd->packedmap)
@@ -1525,6 +1530,13 @@ static void *newimaadr(FileData *fd, const void *adr) /* used to restore im
return NULL;
}
+static void *newsceadr(FileData *fd, const void *adr) /* used to restore scene data after undo */
+{
+ if (fd->scenemap && adr)
+ return oldnewmap_lookup_and_inc(fd->scenemap, adr, true);
+ return NULL;
+}
+
static void *newmclipadr(FileData *fd, const void *adr) /* used to restore movie clip data after undo */
{
if (fd->movieclipmap && adr)
@@ -1630,6 +1642,37 @@ void blo_clear_proxy_pointers_from_lib(Main *oldmain)
}
}
+void blo_make_scene_pointer_map(FileData *fd, Main *oldmain)
+{
+ Scene *sce = oldmain->scene.first;
+
+ fd->scenemap = oldnewmap_new();
+
+ for (; sce; sce = sce->id.next) {
+ if (sce->eevee.light_cache) {
+ struct LightCache *light_cache = sce->eevee.light_cache;
+ oldnewmap_insert(fd->scenemap, light_cache, light_cache, 0);
+ }
+ }
+}
+
+void blo_end_scene_pointer_map(FileData *fd, Main *oldmain)
+{
+ OldNew *entry = fd->scenemap->entries;
+ Scene *sce = oldmain->scene.first;
+ int i;
+
+ /* used entries were restored, so we put them to zero */
+ for (i = 0; i < fd->scenemap->nentries; i++, entry++) {
+ if (entry->nr > 0)
+ entry->newp = NULL;
+ }
+
+ for (; sce; sce = sce->id.next) {
+ sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache);
+ }
+}
+
void blo_make_image_pointer_map(FileData *fd, Main *oldmain)
{
Image *ima = oldmain->image.first;
@@ -2300,6 +2343,11 @@ static void direct_link_id(FileData *fd, ID *id)
id->override_static = newdataadr(fd, id->override_static);
link_list_ex(fd, &id->override_static->properties, direct_link_id_override_property_cb);
}
+
+ DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
+ if (drawdata) {
+ BLI_listbase_clear((ListBase *)drawdata);
+ }
}
/* ************ READ CurveMapping *************** */
@@ -2866,19 +2914,6 @@ static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
/* ************ READ WORKSPACES *************** */
-static void lib_link_workspace_scene_data(FileData *fd, WorkSpace *workspace)
-{
- for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first;
- relation != NULL;
- relation = relation->next)
- {
- relation->scene = newlibadr(fd, workspace->id.lib, relation->scene);
- }
-
- /* Free any relations that got lost due to missing datablocks. */
- BKE_workspace_scene_relations_free_invalid(workspace);
-}
-
static void lib_link_workspaces(FileData *fd, Main *bmain)
{
for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
@@ -2891,8 +2926,6 @@ static void lib_link_workspaces(FileData *fd, Main *bmain)
IDP_LibLinkProperty(id->properties, fd);
id_us_ensure_real(id);
- lib_link_workspace_scene_data(fd, workspace);
-
for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) {
bScreen *screen = newlibadr(fd, id->lib, BKE_workspace_layout_screen_get(layout));
@@ -2918,7 +2951,6 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
{
link_list(fd, BKE_workspace_layouts_get(workspace));
link_list(fd, &workspace->hook_layout_relations);
- link_list(fd, &workspace->scene_layer_relations);
link_list(fd, &workspace->owner_ids);
link_list(fd, &workspace->tools);
@@ -3311,6 +3343,10 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
direct_link_curvemapping(fd, node->storage);
else if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
((ImageUser *)node->storage)->ok = 1;
+ else if (node->type==CMP_NODE_CRYPTOMATTE) {
+ NodeCryptomatte *nc = (NodeCryptomatte *) node->storage;
+ nc->matte_id = newdataadr(fd, nc->matte_id);
+ }
}
else if ( ntree->type==NTREE_TEXTURE) {
if (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME)
@@ -5068,6 +5104,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->domain->tex = NULL;
smd->domain->tex_shadow = NULL;
smd->domain->tex_flame = NULL;
+ smd->domain->tex_velocity_x = NULL;
+ smd->domain->tex_velocity_y = NULL;
+ smd->domain->tex_velocity_z = NULL;
smd->domain->tex_wt = NULL;
smd->domain->coba = newdataadr(fd, smd->domain->coba);
@@ -5241,7 +5280,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
OceanModifierData *omd = (OceanModifierData *)md;
omd->oceancache = NULL;
omd->ocean = NULL;
- omd->refresh = (MOD_OCEAN_REFRESH_ADD|MOD_OCEAN_REFRESH_RESET|MOD_OCEAN_REFRESH_SIM);
}
else if (md->type == eModifierType_Warp) {
WarpModifierData *tmd = (WarpModifierData *)md;
@@ -5437,7 +5475,18 @@ static void direct_link_object(FileData *fd, Object *ob)
if (!sb->effector_weights)
sb->effector_weights = BKE_add_effector_weights(NULL);
- direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, 0);
+ sb->shared = newdataadr(fd, sb->shared);
+ if (sb->shared == NULL) {
+ /* Link deprecated caches if they exist, so we can use them for versioning.
+ * We should only do this when sb->shared == NULL, because those pointers
+ * are always set (for compatibility with older Blenders). We mustn't link
+ * the same pointcache twice. */
+ direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, false);
+ }
+ else {
+ /* link caches */
+ direct_link_pointcache_list(fd, &sb->shared->ptcaches, &sb->shared->pointcache, false);
+ }
}
ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
@@ -5497,7 +5546,6 @@ static void direct_link_object(FileData *fd, Object *ob)
ob->derivedFinal = NULL;
BKE_object_runtime_reset(ob);
BLI_listbase_clear(&ob->gpulamp);
- BLI_listbase_clear(&ob->drawdata);
link_list(fd, &ob->pc_ids);
/* Runtime curve data */
@@ -5744,6 +5792,41 @@ static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb
}
}
+static void direct_link_lightcache_texture(FileData *fd, LightCacheTexture *lctex)
+{
+ lctex->tex = NULL;
+
+ if (lctex->data) {
+ lctex->data = newdataadr(fd, lctex->data);
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] * lctex->tex_size[2];
+
+ if (lctex->data_type == LIGHTCACHETEX_FLOAT) {
+ BLI_endian_switch_float_array((float *)lctex->data, data_size * sizeof(float));
+ }
+ else if (lctex->data_type == LIGHTCACHETEX_UINT) {
+ BLI_endian_switch_uint32_array((unsigned int *)lctex->data, data_size * sizeof(unsigned int));
+ }
+ }
+ }
+}
+
+static void direct_link_lightcache(FileData *fd, LightCache *cache)
+{
+ direct_link_lightcache_texture(fd, &cache->cube_tx);
+ direct_link_lightcache_texture(fd, &cache->grid_tx);
+
+ if (cache->cube_mips) {
+ cache->cube_mips = newdataadr(fd, cache->cube_mips);
+ for (int i = 0; i < cache->mips_len; ++i) {
+ direct_link_lightcache_texture(fd, &cache->cube_mips[i]);
+ }
+ }
+
+ cache->cube_data = newdataadr(fd, cache->cube_data);
+ cache->grid_data = newdataadr(fd, cache->grid_data);
+}
+
/* check for cyclic set-scene,
* libs can cause this case which is normally prevented, see (T#####) */
#define USE_SETSCENE_CHECK
@@ -6304,6 +6387,19 @@ static void direct_link_scene(FileData *fd, Scene *sce)
direct_link_view_layer(fd, view_layer);
}
+ if (fd->memfile) {
+ /* If it's undo try to recover the cache. */
+ if (fd->scenemap) sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache);
+ else sce->eevee.light_cache = NULL;
+ }
+ else {
+ /* else read the cache from file. */
+ if (sce->eevee.light_cache) {
+ sce->eevee.light_cache = newdataadr(fd, sce->eevee.light_cache);
+ direct_link_lightcache(fd, sce->eevee.light_cache);
+ }
+ }
+
sce->layer_properties = newdataadr(fd, sce->layer_properties);
IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
@@ -6439,7 +6535,6 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
ar->v2d.tab_cur = 0;
ar->v2d.sms = NULL;
ar->v2d.alpha_hor = ar->v2d.alpha_vert = 255; /* visible by default */
- ar->v2d.size_hor = ar->v2d.size_vert = 0;
BLI_listbase_clear(&ar->panels_category);
BLI_listbase_clear(&ar->handlers);
BLI_listbase_clear(&ar->uiblocks);
@@ -6447,7 +6542,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
ar->visible = 0;
ar->type = NULL;
ar->do_draw = 0;
- ar->manipulator_map = NULL;
+ ar->gizmo_map = NULL;
ar->regiontimer = NULL;
ar->draw_buffer = NULL;
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
@@ -6515,9 +6610,10 @@ static void direct_link_area(FileData *fd, ScrArea *area)
v3d->properties_storage = NULL;
/* render can be quite heavy, set to solid on load */
- if (v3d->drawtype == OB_RENDER)
- v3d->drawtype = OB_SOLID;
- v3d->prev_drawtype = OB_SOLID;
+ if (v3d->shading.type == OB_RENDER) {
+ v3d->shading.type = OB_SOLID;
+ }
+ v3d->shading.prev_type = OB_SOLID;
if (v3d->fx_settings.dof)
v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof);
@@ -6915,16 +7011,18 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
link_list(fd, &wm->windows);
for (win = wm->windows.first; win; win = win->next) {
- WorkSpaceInstanceHook *hook = win->workspace_hook;
+ win->parent = newdataadr(fd, win->parent);
+ WorkSpaceInstanceHook *hook = win->workspace_hook;
win->workspace_hook = newdataadr(fd, hook);
+
/* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */
oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0);
direct_link_area_map(fd, &win->global_areas);
win->ghostwin = NULL;
- win->gwnctx = NULL;
+ win->gpuctx = NULL;
win->eventstate = NULL;
win->cursor_keymap_status = NULL;
win->tweak = NULL;
@@ -7127,19 +7225,6 @@ static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map)
BKE_sequencer_base_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map);
}
-static void lib_link_workspace_scene_data_restore(struct IDNameLib_Map *id_map, WorkSpace *workspace)
-{
- for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first;
- relation != NULL;
- relation = relation->next)
- {
- relation->scene = restore_pointer_by_name(id_map, &relation->scene->id, USER_IGNORE);
- }
-
- /* Free any relations that got lost due to missing datablocks or view layers. */
- BKE_workspace_scene_relations_free_invalid(workspace);
-}
-
static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene)
{
bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
@@ -7402,9 +7487,6 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene
struct IDNameLib_Map *id_map = BKE_main_idmap_create(newmain);
for (WorkSpace *workspace = newmain->workspaces.first; workspace; workspace = workspace->id.next) {
- lib_link_workspace_scene_data_restore(id_map, workspace);
- BKE_workspace_view_layer_set(workspace, cur_view_layer, curscene);
-
ListBase *layouts = BKE_workspace_layouts_get(workspace);
for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
@@ -7423,6 +7505,9 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene
if (win->scene == NULL) {
win->scene = curscene;
}
+ if (BKE_view_layer_find(win->scene, win->view_layer_name) == NULL) {
+ STRNCPY(win->view_layer_name, cur_view_layer->name);
+ }
BKE_workspace_active_set(win->workspace_hook, workspace);
/* keep cursor location through undo */
@@ -7622,6 +7707,7 @@ static void direct_link_speaker(FileData *fd, Speaker *spk)
static void direct_link_sound(FileData *fd, bSound *sound)
{
+ sound->tags = 0;
sound->handle = NULL;
sound->playback_handle = NULL;
@@ -7633,6 +7719,7 @@ static void direct_link_sound(FileData *fd, bSound *sound)
if (fd->soundmap) {
sound->waveform = newsoundadr(fd, sound->waveform);
+ sound->tags |= SOUND_TAGS_WAVEFORM_NO_RELOAD;
}
else {
sound->waveform = NULL;
@@ -7643,7 +7730,7 @@ static void direct_link_sound(FileData *fd, bSound *sound)
BLI_spin_init(sound->spinlock);
}
/* clear waveform loading flag */
- sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+ sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 9c699db5583..10f0c7a2942 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -90,6 +90,7 @@ typedef struct FileData {
struct OldNewMap *libmap;
struct OldNewMap *imamap;
struct OldNewMap *movieclipmap;
+ struct OldNewMap *scenemap;
struct OldNewMap *soundmap;
struct OldNewMap *packedmap;
@@ -140,6 +141,8 @@ FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *rep
void blo_clear_proxy_pointers_from_lib(Main *oldmain);
void blo_make_image_pointer_map(FileData *fd, Main *oldmain);
void blo_end_image_pointer_map(FileData *fd, Main *oldmain);
+void blo_make_scene_pointer_map(FileData *fd, Main *oldmain);
+void blo_end_scene_pointer_map(FileData *fd, Main *oldmain);
void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain);
void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain);
void blo_make_sound_pointer_map(FileData *fd, Main *oldmain);
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index c405e385e9f..7a032dc3c90 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -1254,7 +1254,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
tex->iuser.frames = 1;
tex->iuser.sfra = 1;
- tex->iuser.fie_ima = 2;
tex->iuser.ok = 1;
}
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 3fa059989a3..09a940436ef 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -97,15 +97,10 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
{
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
const bScreen *screen_parent = screen_parent_find(screen);
- Scene *scene = screen->scene;
WorkSpace *workspace;
- ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay);
if (screen->temp) {
continue;
}
- if (!layer) {
- layer = BKE_view_layer_default_view(scene);
- }
if (screen_parent) {
/* fullscreen with "Back to Previous" option, don't create
@@ -117,7 +112,6 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
workspace = BKE_workspace_add(bmain, screen->id.name + 2);
}
BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2);
- BKE_workspace_view_layer_set(workspace, layer, scene);
}
}
@@ -170,7 +164,18 @@ static void do_version_workspaces_after_lib_link(Main *bmain)
for (wmWindow *win = wm->windows.first; win; win = win->next) {
bScreen *screen_parent = screen_parent_find(win->screen);
bScreen *screen = screen_parent ? screen_parent : win->screen;
+
+ if (screen->temp) {
+ /* We do not generate a new workspace for those screens... still need to set some data in win. */
+ win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
+ win->scene = screen->scene;
+ /* Deprecated from now on! */
+ win->screen = NULL;
+ continue;
+ }
+
WorkSpace *workspace = BLI_findstring(&bmain->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
+ BLI_assert(workspace != NULL);
ListBase *layouts = BKE_workspace_layouts_get(workspace);
win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
@@ -178,7 +183,16 @@ static void do_version_workspaces_after_lib_link(Main *bmain)
BKE_workspace_active_set(win->workspace_hook, workspace);
BKE_workspace_active_layout_set(win->workspace_hook, layouts->first);
- win->scene = screen->scene;
+ /* Move scene and view layer to window. */
+ Scene *scene = screen->scene;
+ ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay);
+ if (!layer) {
+ layer = BKE_view_layer_default_view(scene);
+ }
+
+ win->scene = scene;
+ STRNCPY(win->view_layer_name, layer->name);
+
/* Deprecated from now on! */
win->screen = NULL;
}
@@ -594,7 +608,7 @@ void do_versions_after_linking_280(Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
/* same render-layer as do_version_workspaces_after_lib_link will activate,
- * so same layer as BKE_view_layer_from_workspace_get would return */
+ * so same layer as BKE_view_layer_default_view would return */
ViewLayer *layer = screen->scene->view_layers.first;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
@@ -790,10 +804,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "contact_dist")) {
for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
- la->contact_dist = 1.0f;
+ la->contact_dist = 0.2f;
la->contact_bias = 0.03f;
la->contact_spread = 0.2f;
- la->contact_thickness = 0.5f;
+ la->contact_thickness = 0.2f;
}
}
@@ -1086,7 +1100,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
v3d->overlay.backwire_opacity = 0.5f;
v3d->overlay.normals_length = 0.1f;
- v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV;
+ v3d->overlay.flag = 0;
}
}
}
@@ -1451,13 +1465,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "bone_selection_alpha")) {
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "bone_select_alpha")) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- v3d->overlay.bone_selection_alpha = 0.5f;
+ v3d->overlay.bone_select_alpha = 0.5f;
}
}
}
@@ -1527,9 +1541,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_cubemap_draw_size")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ scene->eevee.gi_irradiance_draw_size = 0.1f;
+ scene->eevee.gi_cubemap_draw_size = 0.3f;
+ }
+ }
+
for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
- if (scene->toolsettings->manipulator_flag == 0) {
- scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE;
+ if (scene->toolsettings->gizmo_flag == 0) {
+ scene->toolsettings->gizmo_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE;
}
}
@@ -1559,5 +1580,46 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "SoftBody", "SoftBody_Shared", "*shared")) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
+ SoftBody *sb = ob->soft;
+ if (sb == NULL) {
+ continue;
+ }
+ if (sb->shared == NULL) {
+ sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared");
+ }
+
+ /* Move shared pointers from deprecated location to current location */
+ sb->shared->pointcache = sb->pointcache;
+ sb->shared->ptcaches = sb->ptcaches;
+
+ sb->pointcache = NULL;
+ BLI_listbase_clear(&sb->ptcaches);
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->drawtype == OB_RENDER) {
+ v3d->drawtype = OB_SOLID;
+ }
+ v3d->shading.type = v3d->drawtype;
+ v3d->shading.prev_type = OB_SOLID;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ BKE_screen_view3d_shading_init(&scene->display.shading);
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 860d1432370..bd7334516ca 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -52,7 +52,6 @@
#include "BLO_readfile.h"
-
/**
* Override values in in-memory startup.blend, avoids resaving for small changes.
*/
@@ -72,7 +71,6 @@ void BLO_update_defaults_userpref_blend(void)
/* Defaults from T54943 (phase 1). */
U.flag &= ~USER_TOOLTIPS_PYTHON;
U.uiflag |= USER_AUTOPERSP;
- U.manipulator_flag |= USER_MANIPULATOR_DRAW_NAVIGATE;
U.uiflag2 |= USER_REGION_OVERLAP;
U.versions = 1;
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index bc69b1d99fc..30bbec1f482 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -380,7 +380,6 @@ static void do_version_ntree_242_2(bNodeTree *ntree)
iuser->sfra = nia->sfra;
iuser->offset = nia->nr-1;
iuser->cycl = nia->cyclic;
- iuser->fie_ima = 2;
iuser->ok = 1;
node->storage = iuser;
@@ -389,7 +388,6 @@ static void do_version_ntree_242_2(bNodeTree *ntree)
else {
ImageUser *iuser = node->storage = MEM_callocN(sizeof(ImageUser), "node image user");
iuser->sfra = 1;
- iuser->fie_ima = 2;
iuser->ok = 1;
}
}
@@ -1033,7 +1031,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SpaceButs *sbuts = (SpaceButs *) sl;
sbuts->v2d.maxzoom = 1.2f;
- sbuts->align = 1; /* horizontal default */
if (sbuts->mainb == BUTS_LAMP) {
sbuts->mainb = CONTEXT_SHADING;
@@ -1111,33 +1108,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
if (bmain->versionfile <= 231) {
- /* new bit flags for showing/hiding grid floor and axes */
- bScreen *sc = bmain->screen.first;
-
- while (sc) {
- ScrArea *sa = sc->areabase.first;
- while (sa) {
- SpaceLink *sl = sa->spacedata.first;
- while (sl) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D*) sl;
-
- if (v3d->gridflag == 0) {
- v3d->gridflag |= V3D_SHOW_X;
- v3d->gridflag |= V3D_SHOW_Y;
- v3d->gridflag |= V3D_SHOW_FLOOR;
- v3d->gridflag &= ~V3D_SHOW_Z;
- }
- }
- sl = sl->next;
- }
- sa = sa->next;
- }
- sc = sc->id.next;
- }
- }
-
- if (bmain->versionfile <= 231) {
bScreen *sc = bmain->screen.first;
/* new bit flags for showing/hiding grid floor and axes */
@@ -1845,13 +1815,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ima = blo_do_versions_newlibadr(fd, lib, tex->ima);
if (tex->imaflag & TEX_ANIM5_)
ima->source = IMA_SRC_MOVIE;
- if (tex->imaflag & TEX_FIELDS_)
- ima->flag |= IMA_FIELDS;
- if (tex->imaflag & TEX_STD_FIELD_)
- ima->flag |= IMA_STD_FIELD;
}
tex->iuser.frames = tex->frames;
- tex->iuser.fie_ima = (char)tex->fie_ima;
tex->iuser.offset = tex->offset;
tex->iuser.sfra = tex->sfra;
tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC_)!=0;
@@ -1865,18 +1830,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (ma = bmain->mat.first; ma; ma = ma->id.next)
if (ma->nodetree)
do_version_ntree_242_2(ma->nodetree);
-
- for (sc = bmain->screen.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMAGE) {
- ((SpaceImage *)sl)->iuser.fie_ima = 2;
- }
- }
- }
- }
}
if (bmain->subversionfile < 4) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index e7bca4c7e5b..552f5420e8d 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -166,6 +166,7 @@
#include "BKE_constraint.h"
#include "BKE_global.h" // for G
#include "BKE_idcode.h"
+#include "BKE_layer.h"
#include "BKE_library.h" // for set_listbasepointers
#include "BKE_library_override.h"
#include "BKE_main.h"
@@ -347,10 +348,6 @@ typedef struct {
* Will be NULL for UNDO.
*/
WriteWrap *ww;
-
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- bool use_mesh_compat; /* option to save with older mesh format */
-#endif
} WriteData;
static WriteData *writedata_new(WriteWrap *ww)
@@ -1106,6 +1103,13 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
}
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
}
+ else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_CRYPTOMATTE)) {
+ NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
+ if (nc->matte_id) {
+ writedata(wd, DATA, strlen(nc->matte_id) + 1, nc->matte_id);
+ }
+ writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ }
else {
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
}
@@ -1147,7 +1151,6 @@ static void current_screen_compat(
{
wmWindowManager *wm;
wmWindow *window = NULL;
- WorkSpace *workspace;
/* find a global current screen in the first open window, to have
* a reasonable default for reading in older versions */
@@ -1171,11 +1174,10 @@ static void current_screen_compat(
window = wm->windows.first;
}
}
- workspace = (window) ? BKE_workspace_active_get(window->workspace_hook) : NULL;
*r_screen = (window) ? BKE_workspace_active_screen_get(window->workspace_hook) : NULL;
*r_scene = (window) ? window->scene : NULL;
- *r_render_layer = (window) ? BKE_workspace_view_layer_get(workspace, *r_scene) : NULL;
+ *r_render_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) : NULL;
}
typedef struct RenderInfo {
@@ -1816,9 +1818,13 @@ static void write_object(WriteData *wd, Object *ob)
write_motionpath(wd, ob->mpath);
writestruct(wd, DATA, PartDeflect, 1, ob->pd);
- writestruct(wd, DATA, SoftBody, 1, ob->soft);
if (ob->soft) {
- write_pointcaches(wd, &ob->soft->ptcaches);
+ /* Set deprecated pointers to prevent crashes of older Blenders */
+ ob->soft->pointcache = ob->soft->shared->pointcache;
+ ob->soft->ptcaches = ob->soft->shared->ptcaches;
+ writestruct(wd, DATA, SoftBody, 1, ob->soft);
+ writestruct(wd, DATA, SoftBody_Shared, 1, ob->soft->shared);
+ write_pointcaches(wd, &(ob->soft->shared->ptcaches));
writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights);
}
@@ -2080,12 +2086,6 @@ static void write_customdata(
static void write_mesh(WriteData *wd, Mesh *mesh)
{
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- const bool save_for_old_blender = wd->use_mesh_compat; /* option to save with older mesh format */
-#else
- const bool save_for_old_blender = false;
-#endif
-
CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE];
CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE];
CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE];
@@ -2094,19 +2094,17 @@ static void write_mesh(WriteData *wd, Mesh *mesh)
if (mesh->id.us > 0 || wd->use_memfile) {
/* write LibData */
- if (!save_for_old_blender) {
+ {
/* write a copy of the mesh, don't modify in place because it is
* not thread safe for threaded renders that are reading this */
Mesh *old_mesh = mesh;
Mesh copy_mesh = *mesh;
mesh = &copy_mesh;
-#ifdef USE_BMESH_SAVE_WITHOUT_MFACE
/* cache only - don't write */
mesh->mface = NULL;
mesh->totface = 0;
memset(&mesh->fdata, 0, sizeof(mesh->fdata));
-#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */
/**
* Those calls:
@@ -2117,11 +2115,7 @@ static void write_mesh(WriteData *wd, Mesh *mesh)
*/
CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
-#ifndef USE_BMESH_SAVE_WITHOUT_MFACE /* Do not copy org fdata in this case!!! */
- CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff));
-#else
flayers = flayers_buff;
-#endif
CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
@@ -2146,73 +2140,6 @@ static void write_mesh(WriteData *wd, Mesh *mesh)
/* restore pointer */
mesh = old_mesh;
}
- else {
-
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- /* write a copy of the mesh, don't modify in place because it is
- * not thread safe for threaded renders that are reading this */
- Mesh *old_mesh = mesh;
- Mesh copy_mesh = *mesh;
- mesh = &copy_mesh;
-
- mesh->mpoly = NULL;
- mesh->mface = NULL;
- mesh->totface = 0;
- mesh->totpoly = 0;
- mesh->totloop = 0;
- CustomData_reset(&mesh->fdata);
- CustomData_reset(&mesh->pdata);
- CustomData_reset(&mesh->ldata);
- mesh->edit_btmesh = NULL;
-
- /* now fill in polys to mfaces */
- /* XXX This breaks writing design, by using temp allocated memory, which will likely generate
- * duplicates in stored 'old' addresses.
- * This is very bad, but do not see easy way to avoid this, aside from generating those data
- * outside of save process itself.
- * Maybe we can live with this, though?
- */
- mesh->totface = BKE_mesh_mpoly_to_mface(
- &mesh->fdata, &old_mesh->ldata, &old_mesh->pdata,
- mesh->totface, old_mesh->totloop, old_mesh->totpoly);
-
- BKE_mesh_update_customdata_pointers(mesh, false);
-
- CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
- CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
- CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff));
-#if 0
- CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
- CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
-#endif
-
- writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh);
- write_iddata(wd, &mesh->id);
-
- /* direct data */
- if (mesh->adt) {
- write_animdata(wd, mesh->adt);
- }
-
- writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat);
- /* writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); */ /* pre-bmesh NULL's */
-
- write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0);
- /* harmless for older blender versioins but _not_ writing these keeps file size down */
-#if 0
- write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0);
-#endif
-
- CustomData_free(&mesh->fdata, mesh->totface);
- flayers = NULL;
-
- /* restore pointer */
- mesh = old_mesh;
-#endif /* USE_BMESH_SAVE_AS_COMPAT */
- }
}
if (vlayers && vlayers != vlayers_buff) {
@@ -2476,6 +2403,36 @@ static void write_view_layer(WriteData *wd, ViewLayer *view_layer)
write_layer_collections(wd, &view_layer->layer_collections);
}
+static void write_lightcache_texture(WriteData *wd, LightCacheTexture *tex)
+{
+ if (tex->data) {
+ size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2];
+ if (tex->data_type == LIGHTCACHETEX_FLOAT) {
+ data_size *= sizeof(float);
+ }
+ else if (tex->data_type == LIGHTCACHETEX_UINT) {
+ data_size *= sizeof(unsigned int);
+ }
+ writedata(wd, DATA, data_size, tex->data);
+ }
+}
+
+static void write_lightcache(WriteData *wd, LightCache *cache)
+{
+ write_lightcache_texture(wd, &cache->grid_tx);
+ write_lightcache_texture(wd, &cache->cube_tx);
+
+ if (cache->cube_mips) {
+ writestruct(wd, DATA, LightCacheTexture, cache->mips_len, cache->cube_mips);
+ for (int i = 0; i < cache->mips_len; ++i) {
+ write_lightcache_texture(wd, &cache->cube_mips[i]);
+ }
+ }
+
+ writestruct(wd, DATA, LightGridCache, cache->grid_len, cache->grid_data);
+ writestruct(wd, DATA, LightProbeCache, cache->cube_len, cache->cube_data);
+}
+
static void write_scene(WriteData *wd, Scene *sce)
{
/* write LibData */
@@ -2676,6 +2633,12 @@ static void write_scene(WriteData *wd, Scene *sce)
write_collection_nolib(wd, sce->master_collection);
}
+ /* Eevee Lightcache */
+ if (sce->eevee.light_cache && !wd->use_memfile) {
+ writestruct(wd, DATA, LightCache, 1, sce->eevee.light_cache);
+ write_lightcache(wd, sce->eevee.light_cache);
+ }
+
/* Freed on doversion. */
BLI_assert(sce->layer_properties == NULL);
}
@@ -3642,7 +3605,6 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace)
writestruct(wd, ID_WS, WorkSpace, 1, workspace);
writelist(wd, DATA, WorkSpaceLayout, layouts);
writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations);
- writelist(wd, DATA, WorkSpaceSceneRelation, &workspace->scene_layer_relations);
writelist(wd, DATA, wmOwnerID, &workspace->owner_ids);
writelist(wd, DATA, bToolRef, &workspace->tools);
for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
@@ -3799,10 +3761,6 @@ static bool write_file_handle(
wd = mywrite_begin(ww, compare, current);
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- wd->use_mesh_compat = (write_flags & G_FILE_MESH_COMPAT) != 0;
-#endif
-
#ifdef USE_NODE_COMPAT_CUSTOMNODES
/* don't write compatibility data on undo */
if (!current) {
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index 10a03050d4b..1e53180396e 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -863,7 +863,7 @@ void BM_editselection_normal(BMEditSelection *ese, float r_normal[3])
/* Calculate a plane that is rightangles to the edge/vert/faces normal
* also make the plane run along an axis that is related to the geometry,
- * because this is used for the manipulators Y axis. */
+ * because this is used for the gizmos Y axis. */
void BM_editselection_plane(BMEditSelection *ese, float r_plane[3])
{
if (ese->htype == BM_VERT) {
@@ -895,7 +895,7 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3])
else {
/* the plane is simple, it runs along the edge
* however selecting different edges can swap the direction of the y axis.
- * this makes it less likely for the y axis of the manipulator
+ * this makes it less likely for the y axis of the gizmo
* (running along the edge).. to flip less often.
* at least its more predictable */
if (eed->v2->co[1] > eed->v1->co[1]) { /* check which to do first */
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 7cbc6461667..421b2adc3a7 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -487,7 +487,7 @@ void BM_face_calc_tangent_vert_diagonal(const BMFace *f, float r_tangent[3])
}
/**
- * Compute a meaningful direction along the face (use for manipulator axis).
+ * Compute a meaningful direction along the face (use for gizmo axis).
*
* \note Callers shouldn't depend on the *exact* method used here.
*/
diff --git a/source/blender/bmesh/intern/bmesh_query.h b/source/blender/bmesh/intern/bmesh_query.h
index cb3af88c316..51956761d8f 100644
--- a/source/blender/bmesh/intern/bmesh_query.h
+++ b/source/blender/bmesh/intern/bmesh_query.h
@@ -20,8 +20,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __BMESH_QUERIES_H__
-#define __BMESH_QUERIES_H__
+#ifndef __BMESH_QUERY_H__
+#define __BMESH_QUERY_H__
/** \file blender/bmesh/intern/bmesh_query.h
* \ingroup bmesh
@@ -198,4 +198,4 @@ float bmesh_subd_falloff_calc(const int falloff, float val) ATTR_WARN_UNUSED_RES
#include "bmesh_query_inline.h"
-#endif /* __BMESH_QUERIES_H__ */
+#endif /* __BMESH_QUERY_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_query_inline.h b/source/blender/bmesh/intern/bmesh_query_inline.h
index 1bd77d23ded..92be3639dce 100644
--- a/source/blender/bmesh/intern/bmesh_query_inline.h
+++ b/source/blender/bmesh/intern/bmesh_query_inline.h
@@ -23,8 +23,8 @@
*/
-#ifndef __BMESH_QUERIES_INLINE_H__
-#define __BMESH_QUERIES_INLINE_H__
+#ifndef __BMESH_QUERY_INLINE_H__
+#define __BMESH_QUERY_INLINE_H__
/**
* Returns whether or not a given vertex is
@@ -166,4 +166,4 @@ BLI_INLINE bool BM_vert_is_wire_endpoint(const BMVert *v)
return false;
}
-#endif /* __BMESH_QUERIES_INLINE_H__ */
+#endif /* __BMESH_QUERY_INLINE_H__ */
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index a382b7cca9c..ced6e967acf 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -389,7 +389,7 @@ Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce
{
const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId();
if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) {
- fprintf(stderr, "Couldn't find lamp by UID.\n");
+ fprintf(stderr, "Couldn't find light by UID.\n");
return NULL;
}
@@ -1122,7 +1122,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
else lamp = (Lamp *)BKE_lamp_add(bmain, (char *)la_id.c_str());
if (!lamp) {
- fprintf(stderr, "Cannot create lamp.\n");
+ fprintf(stderr, "Cannot create light.\n");
return true;
}
@@ -1234,7 +1234,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
break;
case COLLADAFW::Light::UNDEFINED:
{
- fprintf(stderr, "Current lamp type is not supported.\n");
+ fprintf(stderr, "Current light type is not supported.\n");
lamp->type = LA_LOCAL;
}
break;
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index a141495e5ae..261a1218d2d 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -183,6 +183,11 @@ set(SRC
operations/COM_SunBeamsOperation.cpp
operations/COM_SunBeamsOperation.h
+ nodes/COM_CryptomatteNode.cpp
+ nodes/COM_CryptomatteNode.h
+ operations/COM_CryptomatteOperation.cpp
+ operations/COM_CryptomatteOperation.h
+
nodes/COM_CornerPinNode.cpp
nodes/COM_CornerPinNode.h
nodes/COM_PlaneTrackDeformNode.cpp
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 58e0da04e5e..c9181905908 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -55,6 +55,7 @@ extern "C" {
#include "COM_Converter.h"
#include "COM_CornerPinNode.h"
#include "COM_CropNode.h"
+#include "COM_CryptomatteNode.h"
#include "COM_DefocusNode.h"
#include "COM_DespeckleNode.h"
#include "COM_DifferenceMatteNode.h"
@@ -406,6 +407,9 @@ Node *Converter::convert(bNode *b_node)
case CMP_NODE_SUNBEAMS:
node = new SunBeamsNode(b_node);
break;
+ case CMP_NODE_CRYPTOMATTE:
+ node = new CryptomatteNode(b_node);
+ break;
}
return node;
}
diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp
index 4599832b433..ae9defa786e 100644
--- a/source/blender/compositor/intern/COM_compositor.cpp
+++ b/source/blender/compositor/intern/COM_compositor.cpp
@@ -88,7 +88,7 @@ void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rende
editingtree->progress(editingtree->prh, 0.0);
editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing"));
- bool twopass = (editingtree->flag & NTREE_TWO_PASS) > 0 && !rendering;
+ bool twopass = (editingtree->flag & NTREE_TWO_PASS) && !rendering;
/* initialize execution system */
if (twopass) {
ExecutionSystem *system = new ExecutionSystem(rd, scene, editingtree, rendering, twopass, viewSettings, displaySettings, viewName);
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
new file mode 100644
index 00000000000..648ea4556ad
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2018, 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 Stockner
+ * Stefan Werner
+ */
+
+#include "COM_CryptomatteNode.h"
+#include "COM_CryptomatteOperation.h"
+#include "COM_SetAlphaOperation.h"
+#include "COM_ConvertOperation.h"
+#include "BLI_string.h"
+#include "BLI_hash_mm3.h"
+#include "BLI_assert.h"
+#include <iterator>
+
+CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
+
+/* This is taken from the Cryptomatte specification 1.0. */
+static inline float hash_to_float(uint32_t hash)
+{
+ uint32_t mantissa = hash & (( 1 << 23) - 1);
+ uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
+ exponent = max(exponent, (uint32_t) 1);
+ exponent = min(exponent, (uint32_t) 254);
+ exponent = exponent << 23;
+ uint32_t sign = (hash >> 31);
+ sign = sign << 31;
+ uint32_t float_bits = sign | exponent | mantissa;
+ float f;
+ /* Bit casting relies on equal size for both types. */
+ BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "float and uint32_t are not the same size")
+ ::memcpy(&f, &float_bits, sizeof(float));
+ return f;
+}
+
+void CryptomatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+{
+ NodeInput *inputSocketImage = this->getInputSocket(0);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ NodeOutput *outputSocketMatte = this->getOutputSocket(1);
+ NodeOutput *outputSocketPick = this->getOutputSocket(2);
+
+ bNode *node = this->getbNode();
+ NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage;
+
+ CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1);
+ if (cryptoMatteSettings) {
+ if (cryptoMatteSettings->matte_id) {
+ /* Split the string by commas, ignoring white space. */
+ std::string input = cryptoMatteSettings->matte_id;
+ std::istringstream ss(input);
+ while (ss.good()) {
+ std::string token;
+ getline(ss, token, ',');
+ /* Ignore empty tokens. */
+ if (token.length() > 0) {
+ size_t first = token.find_first_not_of(' ');
+ size_t last = token.find_last_not_of(' ');
+ if (first == std::string::npos || last == std::string::npos) {
+ break;
+ }
+ token = token.substr(first, (last - first + 1));
+ if (*token.begin() == '<' && *(--token.end()) == '>') {
+ operation->addObjectIndex(atof(token.substr(1, token.length() - 2).c_str()));
+ }
+ else {
+ uint32_t hash = BLI_hash_mm3((const unsigned char *)token.c_str(), token.length(), 0);
+ operation->addObjectIndex(hash_to_float(hash));
+ }
+ }
+ }
+ }
+ }
+
+ converter.addOperation(operation);
+
+ for (int i = 0; i < getNumberOfInputSockets() - 1; ++i) {
+ converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i));
+ }
+
+ SeparateChannelOperation *separateOperation = new SeparateChannelOperation;
+ separateOperation->setChannel(3);
+ converter.addOperation(separateOperation);
+
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ converter.addOperation(operationAlpha);
+
+ converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0));
+ converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1));
+
+ SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation();
+ converter.addOperation(clearAlphaOperation);
+ converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f);
+
+ converter.addLink(operation->getOutputSocket(0), clearAlphaOperation->getInputSocket(0));
+
+ converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
+ converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0));
+ converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0));
+ converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0));
+
+}
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.h b/source/blender/compositor/nodes/COM_CryptomatteNode.h
new file mode 100644
index 00000000000..5251b57d8af
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2018, 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 Stockner
+ */
+
+#ifndef _COM_CryptomatteNode_h_
+#define _COM_CryptomatteNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief CryptomatteNode
+ * @ingroup Node
+ */
+class CryptomatteNode : public Node {
+public:
+ CryptomatteNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+};
+
+#endif
+
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp
index d16300ebff4..25c617a3487 100644
--- a/source/blender/compositor/nodes/COM_MathNode.cpp
+++ b/source/blender/compositor/nodes/COM_MathNode.cpp
@@ -89,6 +89,18 @@ void MathNode::convertToOperations(NodeConverter &converter, const CompositorCon
case NODE_MATH_ATAN2:
operation = new MathArcTan2Operation();
break;
+ case NODE_MATH_FLOOR:
+ operation = new MathFloorOperation();
+ break;
+ case NODE_MATH_CEIL:
+ operation = new MathCeilOperation();
+ break;
+ case NODE_MATH_FRACT:
+ operation = new MathFractOperation();
+ break;
+ case NODE_MATH_SQRT:
+ operation = new MathSqrtOperation();
+ break;
}
if (operation) {
diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
new file mode 100644
index 00000000000..f3fa81075c6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2018, 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 Stockner, Stefan Werner
+ */
+
+#include "COM_CryptomatteOperation.h"
+
+CryptomatteOperation::CryptomatteOperation(size_t num_inputs) : NodeOperation()
+{
+ for(size_t i = 0; i < num_inputs; i++) {
+ this->addInputSocket(COM_DT_COLOR);
+ }
+ inputs.resize(num_inputs);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+}
+
+void CryptomatteOperation::initExecution()
+{
+ for (size_t i = 0; i < inputs.size(); i++) {
+ inputs[i] = this->getInputSocketReader(i);
+ }
+}
+
+void CryptomatteOperation::addObjectIndex(float objectIndex)
+{
+ if (objectIndex != 0.0f) {
+ m_objectIndex.push_back(objectIndex);
+ }
+}
+
+void CryptomatteOperation::executePixel(float output[4],
+ int x,
+ int y,
+ void *data)
+{
+ float input[4];
+ output[0] = output[1] = output[2] = output[3] = 0.0f;
+ for (size_t i = 0; i < inputs.size(); i++) {
+ inputs[i]->read(input, x, y, data);
+ if (i == 0) {
+ /* Write the frontmost object as false color for picking. */
+ output[0] = input[0];
+ uint32_t m3hash;
+ ::memcpy(&m3hash, &input[0], sizeof(uint32_t));
+ /* Since the red channel is likely to be out of display range,
+ * setting green and blue gives more meaningful images. */
+ output[1] = ((float) ((m3hash << 8)) / (float) UINT32_MAX);
+ output[2] = ((float) ((m3hash << 16)) / (float) UINT32_MAX);
+ }
+ for (size_t i = 0; i < m_objectIndex.size(); i++) {
+ if (m_objectIndex[i] == input[0]) {
+ output[3] += input[1];
+ }
+ if (m_objectIndex[i] == input[2]) {
+ output[3] += input[3];
+ }
+ }
+ }
+}
diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.h b/source/blender/compositor/operations/COM_CryptomatteOperation.h
new file mode 100644
index 00000000000..9ce02c048b3
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2018, 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 Stockner, Stefan Werner
+ */
+
+#ifndef _COM_CryptomatteOperation_h
+#define _COM_CryptomatteOperation_h
+#include "COM_NodeOperation.h"
+
+
+class CryptomatteOperation : public NodeOperation {
+private:
+ std::vector<float> m_objectIndex;
+public:
+ std::vector<SocketReader *> inputs;
+
+ CryptomatteOperation(size_t num_inputs = 6);
+
+ void initExecution();
+ void executePixel(float output[4], int x, int y, void *data);
+
+ void addObjectIndex(float objectIndex);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index 0a515da1877..99385a5073a 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -356,3 +356,50 @@ void MathArcTan2Operation::executePixelSampled(float output[4], float x, float y
clampIfNeeded(output);
}
+
+void MathFloorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+{
+ float inputValue1[4];
+
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+
+ output[0] = floor(inputValue1[0]);
+
+ clampIfNeeded(output);
+}
+
+void MathCeilOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+{
+ float inputValue1[4];
+
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+
+ output[0] = ceil(inputValue1[0]);
+
+ clampIfNeeded(output);
+}
+
+void MathFractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+{
+ float inputValue1[4];
+
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+
+ output[0] = inputValue1[0] - floor(inputValue1[0]);
+
+ clampIfNeeded(output);
+}
+
+void MathSqrtOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+{
+ float inputValue1[4];
+
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+
+ if (inputValue1[0] > 0)
+ output[0] = sqrt(inputValue1[0]);
+ else
+ output[0] = 0.0f;
+
+ clampIfNeeded(output);
+}
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index c636117451f..5435cc82ba7 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -175,4 +175,28 @@ public:
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
+class MathFloorOperation : public MathBaseOperation {
+public:
+ MathFloorOperation() : MathBaseOperation() {}
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+};
+
+class MathCeilOperation : public MathBaseOperation {
+public:
+ MathCeilOperation() : MathBaseOperation() {}
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+};
+
+class MathFractOperation : public MathBaseOperation {
+public:
+ MathFractOperation() : MathBaseOperation() {}
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+};
+
+class MathSqrtOperation : public MathBaseOperation {
+public:
+ MathSqrtOperation() : MathBaseOperation() {}
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+};
+
#endif
diff --git a/source/blender/datatoc/datatoc_icon_split.py b/source/blender/datatoc/datatoc_icon_split.py
index aae907ec340..e7cc3a71446 100755
--- a/source/blender/datatoc/datatoc_icon_split.py
+++ b/source/blender/datatoc/datatoc_icon_split.py
@@ -68,7 +68,7 @@ def image_from_file(filepath):
if bpy is not None:
pixels, pixel_w, pixel_h = image_from_file__bpy(filepath)
- #else:
+ # else:
# pixels, pixel_w, pixel_h = image_from_file__py(filepath)
return pixels, pixel_w, pixel_h
@@ -95,12 +95,14 @@ def write_subimage(sub_x, sub_y, sub_w, sub_h,
with open(filepath, 'wb') as f:
- f.write(struct.pack('<6I',
+ f.write(
+ struct.pack(
+ '<6I',
sub_w, sub_h,
sub_x, sub_y,
# redundant but including to maintain consistency
pixel_w, pixel_h,
- ))
+ ))
for y in range(sub_h):
for x in range(sub_w):
@@ -113,8 +115,9 @@ def write_subimage(sub_x, sub_y, sub_w, sub_h,
_dice_icon_name_cache = {}
-def dice_icon_name(x, y, parts_x, parts_y,
- name_style=None, prefix=""):
+def dice_icon_name(
+ x, y, parts_x, parts_y,
+ name_style=None, prefix=""):
"""
How to name icons, this is mainly for what name we get in git,
the actual names don't really matter, its just nice to have the
@@ -143,7 +146,7 @@ def dice_icon_name(x, y, parts_x, parts_y,
icon_name = _dice_icon_name_cache[index]
# for debugging its handy to sort by number
- #~ id_str = "%03d_%s%s.dat" % (index, prefix, icon_name)
+ # ~ id_str = "%03d_%s%s.dat" % (index, prefix, icon_name)
id_str = "%s%s.dat" % (prefix, icon_name)
@@ -158,16 +161,18 @@ def dice_icon_name(x, y, parts_x, parts_y,
return id_str
-def dice(filepath, output, output_prefix, name_style,
- parts_x, parts_y,
- minx, miny, maxx, maxy,
- minx_icon, miny_icon, maxx_icon, maxy_icon,
- spacex_icon, spacey_icon,
- ):
+def dice(
+ filepath, output, output_prefix, name_style,
+ parts_x, parts_y,
+ minx, miny, maxx, maxy,
+ minx_icon, miny_icon, maxx_icon, maxy_icon,
+ spacex_icon, spacey_icon,
+):
- is_simple = (max(minx, miny, maxx, maxy,
- minx_icon, miny_icon, maxx_icon, maxy_icon,
- spacex_icon, spacey_icon) == 0)
+ is_simple = (max(
+ minx, miny, maxx, maxy,
+ minx_icon, miny_icon, maxx_icon, maxy_icon,
+ spacex_icon, spacey_icon) == 0)
pixels, pixel_w, pixel_h = image_from_file(filepath)
@@ -199,9 +204,11 @@ def dice(filepath, output, output_prefix, name_style,
for x in range(parts_x):
for y in range(parts_y):
- id_str = dice_icon_name(x, y,
- parts_x, parts_y,
- name_style=name_style, prefix=output_prefix)
+ id_str = dice_icon_name(
+ x, y,
+ parts_x, parts_y,
+ name_style=name_style, prefix=output_prefix
+ )
filepath = os.path.join(output, id_str)
if VERBOSE:
print(" writing:", filepath)
@@ -235,25 +242,35 @@ def main():
parser = argparse.ArgumentParser(description=__doc__, epilog=epilog)
# File path options
- parser.add_argument("--image", dest="image", metavar='FILE',
- help="Image file")
-
- parser.add_argument("--output", dest="output", metavar='DIR',
- help="Output directory")
-
- parser.add_argument("--output_prefix", dest="output_prefix", metavar='STRING',
- help="Output prefix")
+ parser.add_argument(
+ "--image", dest="image", metavar='FILE',
+ help="Image file",
+ )
+ parser.add_argument(
+ "--output", dest="output", metavar='DIR',
+ help="Output directory",
+ )
+ parser.add_argument(
+ "--output_prefix", dest="output_prefix", metavar='STRING',
+ help="Output prefix",
+ )
# Icon naming option
- parser.add_argument("--name_style", dest="name_style", metavar='ENUM', type=str,
- choices=('', 'UI_ICONS'),
- help="The metod used for naming output data")
+ parser.add_argument(
+ "--name_style", dest="name_style", metavar='ENUM', type=str,
+ choices=('', 'UI_ICONS'),
+ help="The metod used for naming output data",
+ )
# Options for dicing up the image
- parser.add_argument("--parts_x", dest="parts_x", metavar='INT', type=int,
- help="Grid X parts")
- parser.add_argument("--parts_y", dest="parts_y", metavar='INT', type=int,
- help="Grid Y parts")
+ parser.add_argument(
+ "--parts_x", dest="parts_x", metavar='INT', type=int,
+ help="Grid X parts",
+ )
+ parser.add_argument(
+ "--parts_y", dest="parts_y", metavar='INT', type=int,
+ help="Grid Y parts",
+ )
_help = "Inset from the outer edge (in pixels)"
parser.add_argument("--minx", dest="minx", metavar='INT', type=int, help=_help)
@@ -287,5 +304,6 @@ def main():
args.spacex_icon, args.spacey_icon,
)
+
if __name__ == "__main__":
main()
diff --git a/source/blender/datatoc/datatoc_icon_split_to_png.py b/source/blender/datatoc/datatoc_icon_split_to_png.py
index 39bbf1110fb..b583b10b9ff 100755
--- a/source/blender/datatoc/datatoc_icon_split_to_png.py
+++ b/source/blender/datatoc/datatoc_icon_split_to_png.py
@@ -67,5 +67,6 @@ def main():
icondata_to_png(file_src, file_dst)
+
if __name__ == "__main__":
main()
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 0673a3177b7..185a98f2a2b 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
../blenkernel
../blenlib
../bmesh
+ ../draw
../makesdna
../makesrna
../modifiers
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 0174b002292..2e566752a6f 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -130,7 +130,7 @@ typedef enum eDepsgraph_Tag {
DEG_TAG_GEOMETRY = (1 << 1),
/* Time changed and animation is to be re-evaluated, OB_RECALC_TIME. */
DEG_TAG_TIME = (1 << 2),
- /* Particle system changed. */
+ /* Particle system changed; values are aligned with PSYS_RECALC_xxx. */
DEG_TAG_PSYS_REDO = (1 << 3),
DEG_TAG_PSYS_RESET = (1 << 4),
DEG_TAG_PSYS_TYPE = (1 << 5),
@@ -269,9 +269,9 @@ void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph,
const void *parent_address);
void DEG_debug_print_eval_time(struct Depsgraph *depsgraph,
- const char* function_name,
- const char* object_name,
- const void* object_address,
+ const char *function_name,
+ const char *object_name,
+ const void *object_address,
float time);
#ifdef __cplusplus
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index b6256e9ceb0..4cbc7700947 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -69,7 +69,10 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
flag |= DEG_TAG_COPY_ON_WRITE;
}
if (flag != 0) {
- DEG_id_tag_update_ex(bmain, id_node->id_orig, flag);
+ DEG_graph_id_tag_update(bmain,
+ (::Depsgraph *)graph,
+ id_node->id_orig,
+ flag);
}
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_map.cc b/source/blender/depsgraph/intern/builder/deg_builder_map.cc
index 218483d1dc5..cde7b9721b7 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_map.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_map.cc
@@ -37,24 +37,29 @@
namespace DEG {
-BuilderMap::BuilderMap() {
+BuilderMap::BuilderMap()
+{
set = BLI_gset_ptr_new("deg builder gset");
}
-BuilderMap::~BuilderMap() {
+BuilderMap::~BuilderMap()
+{
BLI_gset_free(set, NULL);
}
-bool BuilderMap::checkIsBuilt(ID *id) {
+bool BuilderMap::checkIsBuilt(ID *id)
+{
return BLI_gset_haskey(set, id);
}
-void BuilderMap::tagBuild(ID *id) {
+void BuilderMap::tagBuild(ID *id)
+{
BLI_gset_insert(set, id);
}
-bool BuilderMap::checkIsBuiltAndTag(ID *id) {
+bool BuilderMap::checkIsBuiltAndTag(ID *id)
+{
void **key_p;
if (!BLI_gset_ensure_p_ex(set, id, &key_p)) {
*key_p = id;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index cb455130d4c..1b68a73bbd7 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -829,8 +829,19 @@ void DepsgraphNodeBuilder::build_driver_variables(ID * id, FCurve *fcurve)
LISTBASE_FOREACH (DriverVar *, dvar, &fcurve->driver->variables) {
DRIVER_TARGETS_USED_LOOPER(dvar)
{
+ if (dtar->id == NULL) {
+ continue;
+ }
build_id(dtar->id);
build_driver_id_property(dtar->id, dtar->rna_path);
+ /* Corresponds to dtar_id_ensure_proxy_from(). */
+ if ((GS(dtar->id->name) == ID_OB) &&
+ (((Object *)dtar->id)->proxy_from != NULL))
+ {
+ Object *proxy_from = ((Object *)dtar->id)->proxy_from;
+ build_id(&proxy_from->id);
+ build_driver_id_property(&proxy_from->id, dtar->rna_path);
+ }
}
DRIVER_TARGETS_LOOPER_END
}
@@ -873,9 +884,7 @@ void DepsgraphNodeBuilder::build_world(World *world)
/* world itself */
add_operation_node(&world->id,
DEG_NODE_TYPE_SHADING,
- function_bind(BKE_world_eval,
- _1,
- get_cow_datablock(world)),
+ NULL,
DEG_OPCODE_WORLD_UPDATE);
/* world's nodetree */
if (world->nodetree != NULL) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 6899a86b3e9..66293a91e85 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -158,7 +158,7 @@ struct DepsgraphNodeBuilder {
const char *name = "",
int name_tag = -1);
- void build_id(ID* id);
+ void build_id(ID *id);
void build_layer_collections(ListBase *lb);
void build_view_layer(Scene *scene,
ViewLayer *view_layer,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
index 00d7a5da455..043148a0f70 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
@@ -161,7 +161,8 @@ void DepsgraphNodeBuilder::build_rig(Object *object)
build_armature(armature);
/* Rebuild pose if not up to date. */
if (object->pose == NULL || (object->pose->flag & POSE_RECALC)) {
- BKE_pose_rebuild(object, armature);
+ /* By definition, no need to tag depsgraph as dirty from here, so we can pass NULL bmain. */
+ BKE_pose_rebuild(NULL, object, armature);
/* XXX: Without this animation gets lost in certain circumstances
* after loading file. Need to investigate further since it does
* not happen with simple scenes..
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index f64c4f5aff0..1a0c621ab43 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -679,7 +679,7 @@ void DepsgraphRelationBuilder::build_object_data_lamp(Object *object)
build_lamp(lamp);
ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS);
ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS);
- add_relation(lamp_parameters_key, object_parameters_key, "Lamp -> Object");
+ add_relation(lamp_parameters_key, object_parameters_key, "Light -> Object");
}
void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object)
@@ -1351,6 +1351,14 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
continue;
}
build_id(dtar->id);
+ /* Initialize relations coming to proxy_from. */
+ Object *proxy_from = NULL;
+ if ((GS(dtar->id->name) == ID_OB) &&
+ (((Object *)dtar->id)->proxy_from != NULL))
+ {
+ proxy_from = ((Object *)dtar->id)->proxy_from;
+ build_id(&proxy_from->id);
+ }
/* Special handling for directly-named bones. */
if ((dtar->flag & DTAR_FLAG_STRUCT_REF) &&
(((Object *)dtar->id)->type == OB_ARMATURE) &&
@@ -1398,6 +1406,13 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
continue;
}
add_relation(variable_key, driver_key, "RNA Target -> Driver");
+ if (proxy_from != NULL) {
+ RNAPathKey proxy_from_variable_key(&proxy_from->id,
+ dtar->rna_path);
+ add_relation(proxy_from_variable_key,
+ variable_key,
+ "Proxy From -> Variable");
+ }
}
else {
if (dtar->id == id) {
@@ -1968,7 +1983,7 @@ void DepsgraphRelationBuilder::build_lamp(Lamp *lamp)
build_nodetree(lamp->nodetree);
ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS);
ComponentKey nodetree_key(&lamp->nodetree->id, DEG_NODE_TYPE_SHADING);
- add_relation(nodetree_key, lamp_parameters_key, "NTree->Lamp Parameters");
+ add_relation(nodetree_key, lamp_parameters_key, "NTree->Light Parameters");
build_nested_nodetree(&lamp->id, lamp->nodetree);
}
}
@@ -2186,7 +2201,7 @@ void DepsgraphRelationBuilder::build_nested_shapekey(ID *owner, Key *key)
void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node)
{
ID *id_orig = id_node->id_orig;
-
+ const ID_Type id_type = GS(id_orig->name);
TimeSourceKey time_source_key;
OperationKey copy_on_write_key(id_orig,
DEG_NODE_TYPE_COPY_ON_WRITE,
@@ -2209,9 +2224,28 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node
/* Component explicitly requests to not add relation. */
continue;
}
- int rel_flag = 0;
- if (comp_node->type == DEG_NODE_TYPE_ANIMATION) {
- rel_flag |= DEPSREL_FLAG_NO_FLUSH;
+ int rel_flag = DEPSREL_FLAG_NO_FLUSH;
+ if (id_type == ID_ME && comp_node->type == DEG_NODE_TYPE_GEOMETRY) {
+ rel_flag &= ~DEPSREL_FLAG_NO_FLUSH;
+ }
+ /* Notes on exceptions:
+ * - Parameters component is where drivers are living. Changing any
+ * of the (custom) properties in the original datablock (even the
+ * ones which do not imply other component update) need to make
+ * sure drivers are properly updated.
+ * This way, for example, changing ID property will properly poke
+ * all drivers to be updated.
+ *
+ * - View layers have cached array of bases in them, which is not
+ * copied by copy-on-write, and not preserved. PROBABLY it is better
+ * to preserve that cache in copy-on-write, but for the time being
+ * we allow flush to layer collections component which will ensure
+ * that cached array fo bases exists and is up-to-date.
+ */
+ if (comp_node->type == DEG_NODE_TYPE_PARAMETERS ||
+ comp_node->type == DEG_NODE_TYPE_LAYER_COLLECTIONS)
+ {
+ rel_flag &= ~DEPSREL_FLAG_NO_FLUSH;
}
/* All entry operations of each component should wait for a proper
* copy of ID.
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index ddc6e44ee1b..2a24d72eb67 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -140,9 +140,9 @@ static bool pointer_to_component_node_criteria(
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
if (prop != NULL && RNA_property_is_idprop(prop)) {
*type = DEG_NODE_TYPE_PARAMETERS;
- *subdata = "";
- *operation_code = DEG_OPCODE_PARAMETERS_EVAL;
- *operation_name = pchan->name;
+ *operation_code = DEG_OPCODE_ID_PROPERTY;
+ *operation_name = RNA_property_identifier((PropertyRNA *)prop);
+ *operation_name_tag = -1;
}
else {
/* Bone - generally, we just want the bone component. */
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 9128571155f..4229f8bf9a2 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -299,6 +299,7 @@ void depsgraph_tag_component(Depsgraph *graph,
* explicitly, but not all areas are aware of this yet.
*/
void deg_graph_id_tag_legacy_compat(Main *bmain,
+ Depsgraph *depsgraph,
ID *id,
eDepsgraph_Tag tag)
{
@@ -309,7 +310,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain,
Object *object = (Object *)id;
ID *data_id = (ID *)object->data;
if (data_id != NULL) {
- DEG_id_tag_update_ex(bmain, data_id, 0);
+ deg_graph_id_tag_update(bmain, depsgraph, data_id, 0);
}
break;
}
@@ -322,7 +323,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain,
Mesh *mesh = (Mesh *)id;
ID *key_id = &mesh->key->id;
if (key_id != NULL) {
- DEG_id_tag_update_ex(bmain, key_id, 0);
+ deg_graph_id_tag_update(bmain, depsgraph, key_id, 0);
}
break;
}
@@ -331,7 +332,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain,
Lattice *lattice = (Lattice *)id;
ID *key_id = &lattice->key->id;
if (key_id != NULL) {
- DEG_id_tag_update_ex(bmain, key_id, 0);
+ deg_graph_id_tag_update(bmain, depsgraph, key_id, 0);
}
break;
}
@@ -340,7 +341,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain,
Curve *curve = (Curve *)id;
ID *key_id = &curve->key->id;
if (key_id != NULL) {
- DEG_id_tag_update_ex(bmain, key_id, 0);
+ deg_graph_id_tag_update(bmain, depsgraph, key_id, 0);
}
break;
}
@@ -396,7 +397,7 @@ static void deg_graph_id_tag_update_single_flag(Main *bmain,
/* TODO(sergey): Get rid of this once all areas are using proper data ID
* for tagging.
*/
- deg_graph_id_tag_legacy_compat(bmain, id, tag);
+ deg_graph_id_tag_legacy_compat(bmain, graph, id, tag);
}
@@ -454,7 +455,7 @@ void deg_graph_node_tag_zero(Main *bmain, Depsgraph *graph, IDDepsNode *id_node)
comp_node->tag_update(graph);
}
GHASH_FOREACH_END();
- deg_graph_id_tag_legacy_compat(bmain, id, (eDepsgraph_Tag)0);
+ deg_graph_id_tag_legacy_compat(bmain, graph, id, (eDepsgraph_Tag)0);
}
void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 0f49d57a826..20aec0ba5ed 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -70,6 +70,8 @@ extern "C" {
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
+#include "DRW_engine.h"
+
#ifdef NESTED_ID_NASTY_WORKAROUND
# include "DNA_curve_types.h"
# include "DNA_key_types.h"
@@ -553,6 +555,13 @@ void update_special_pointers(const Depsgraph *depsgraph,
update_particle_system_orig_pointers(object_orig, object_cow);
break;
}
+ case ID_SCE:
+ {
+ Scene *scene_cow = (Scene *)id_cow;
+ const Scene *scene_orig = (const Scene *)id_orig;
+ scene_cow->eevee.light_cache = scene_orig->eevee.light_cache;
+ break;
+ }
default:
break;
}
@@ -806,6 +815,8 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
*/
ListBase gpumaterial_backup;
ListBase *gpumaterial_ptr = NULL;
+ DrawDataList drawdata_backup;
+ DrawDataList *drawdata_ptr = NULL;
ObjectRuntimeBackup object_runtime_backup = {NULL};
if (check_datablock_expanded(id_cow)) {
switch (id_type) {
@@ -841,9 +852,11 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
break;
}
case ID_OB:
- deg_backup_object_runtime((Object *)id_cow,
- &object_runtime_backup);
+ {
+ Object *ob = (Object *)id_cow;
+ deg_backup_object_runtime(ob, &object_runtime_backup);
break;
+ }
default:
break;
}
@@ -851,6 +864,11 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
gpumaterial_backup = *gpumaterial_ptr;
gpumaterial_ptr->first = gpumaterial_ptr->last = NULL;
}
+ drawdata_ptr = DRW_drawdatalist_from_id(id_cow);
+ if (drawdata_ptr != NULL) {
+ drawdata_backup = *drawdata_ptr;
+ drawdata_ptr->first = drawdata_ptr->last = NULL;
+ }
}
deg_free_copy_on_write_datablock(id_cow);
deg_expand_copy_on_write_datablock(depsgraph, id_node);
@@ -858,6 +876,10 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
if (gpumaterial_ptr != NULL) {
*gpumaterial_ptr = gpumaterial_backup;
}
+ /* Restore DrawData. */
+ if (drawdata_ptr != NULL) {
+ *drawdata_ptr = drawdata_backup;
+ }
if (id_type == ID_OB) {
deg_restore_object_runtime((Object *)id_cow, &object_runtime_backup);
}
@@ -911,6 +933,12 @@ void discard_mesh_edit_mode_pointers(ID *id_cow)
mesh_cow->edit_btmesh = NULL;
}
+void discard_scene_pointers(ID *id_cow)
+{
+ Scene *scene_cow = (Scene *)id_cow;
+ scene_cow->eevee.light_cache = NULL;
+}
+
/* NULL-ify all edit mode pointers which points to data from
* original object.
*/
@@ -933,6 +961,11 @@ void discard_edit_mode_pointers(ID *id_cow)
case ID_LT:
discard_lattice_edit_mode_pointers(id_cow);
break;
+ case ID_SCE:
+ /* Not really edit mode but still needs to run before
+ * BKE_libblock_free_datablock() */
+ discard_scene_pointers(id_cow);
+ break;
default:
break;
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
index 8fca90e9f5b..40b1f94c7bc 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
@@ -34,7 +34,7 @@
struct ID;
-/* Unkomment this to have verbose log about original and CoW pointers
+/* Uncomment this to have verbose log about original and CoW pointers
* logged, with detailed information when they are allocated, expanded
* and remapped.
*/
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index e9f11f8e089..16cb1b394f6 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -46,6 +46,8 @@
extern "C" {
#include "DNA_object_types.h"
+
+#include "DRW_engine.h"
} /* extern "C" */
#include "DEG_depsgraph.h"
@@ -140,6 +142,9 @@ BLI_INLINE void flush_schedule_entrypoints(Depsgraph *graph, FlushQueue *queue)
{
queue->push_back(op_node);
op_node->scheduled = true;
+ DEG_DEBUG_PRINTF((::Depsgraph *)graph,
+ EVAL, "Operation is entry point for update: %s\n",
+ op_node->identifier().c_str());
}
GSET_FOREACH_END();
}
@@ -216,12 +221,12 @@ BLI_INLINE OperationDepsNode *flush_schedule_children(
void flush_engine_data_update(ID *id)
{
- if (GS(id->name) != ID_OB) {
+ DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
+ if (drawdata == NULL) {
return;
}
- Object *object = (Object *)id;
- LISTBASE_FOREACH(ObjectEngineData *, engine_data, &object->drawdata) {
- engine_data->recalc |= id->recalc;
+ LISTBASE_FOREACH(DrawData *, dd, drawdata) {
+ dd->recalc |= id->recalc;
}
}
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index 5e79dc1c685..e4a77f2e72b 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -189,7 +189,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Proxy);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Pose);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Sequencer);
-DEG_COMPONENT_NODE_DECLARE_GENERIC(Shading);
+DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(Shading);
DEG_COMPONENT_NODE_DECLARE_GENERIC(ShadingParameters);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform);
DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer);
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index d7b7129114e..6ec7b03501b 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -96,6 +96,7 @@ set(SRC
engines/eevee/eevee_depth_of_field.c
engines/eevee/eevee_effects.c
engines/eevee/eevee_engine.c
+ engines/eevee/eevee_lightcache.c
engines/eevee/eevee_lightprobes.c
engines/eevee/eevee_lights.c
engines/eevee/eevee_lookdev.c
@@ -116,7 +117,9 @@ set(SRC
engines/workbench/workbench_effect_taa.c
engines/workbench/workbench_forward.c
engines/workbench/workbench_materials.c
+ engines/workbench/workbench_render.c
engines/workbench/workbench_studiolight.c
+ engines/workbench/workbench_volume.c
engines/workbench/solid_mode.c
engines/workbench/transparent_mode.c
engines/external/external_engine.c
@@ -137,6 +140,7 @@ set(SRC
modes/edit_mesh_mode_intern.h
engines/basic/basic_engine.h
engines/eevee/eevee_engine.h
+ engines/eevee/eevee_lightcache.h
engines/eevee/eevee_lut.h
engines/eevee/eevee_private.h
engines/external/external_engine.h
@@ -223,6 +227,8 @@ data_to_c_simple(engines/workbench/shaders/workbench_shadow_vert.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_shadow_geom.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_shadow_caps_geom.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_shadow_debug_frag.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_volume_vert.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_volume_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_world_light_lib.glsl SRC)
data_to_c_simple(modes/shaders/common_globals_lib.glsl SRC)
@@ -295,6 +301,7 @@ data_to_c_simple(modes/shaders/paint_wire_vert.glsl SRC)
data_to_c_simple(modes/shaders/paint_vert_frag.glsl SRC)
data_to_c_simple(modes/shaders/particle_strand_frag.glsl SRC)
data_to_c_simple(modes/shaders/particle_strand_vert.glsl SRC)
+data_to_c_simple(modes/shaders/volume_velocity_vert.glsl SRC)
list(APPEND INC
)
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index d126dcb71aa..4d4b486d247 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -136,6 +136,18 @@ void DRW_opengl_context_destroy(void);
void DRW_opengl_context_enable(void);
void DRW_opengl_context_disable(void);
+/* Never use this. Only for closing blender. */
+void DRW_opengl_context_enable_ex(bool restore);
+void DRW_opengl_context_disable_ex(bool restore);
+
+void DRW_opengl_render_context_enable(void *re_gl_context);
+void DRW_opengl_render_context_disable(void *re_gl_context);
+void DRW_gawain_render_context_enable(void *re_gpu_context);
+void DRW_gawain_render_context_disable(void *re_gpu_context);
+
void DRW_deferred_shader_remove(struct GPUMaterial *mat);
+struct DrawDataList *DRW_drawdatalist_from_id(struct ID *id);
+void DRW_drawdata_free(struct ID *id);
+
#endif /* __DRW_ENGINE_H__ */
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index 2c771578514..57553d98d5d 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -42,9 +42,6 @@
#define BASIC_ENGINE "BLENDER_BASIC"
-/* we may want this later? */
-#define USE_DEPTH
-
/* *********** LISTS *********** */
/* GPUViewport.storage
@@ -54,11 +51,8 @@ typedef struct BASIC_StorageList {
} BASIC_StorageList;
typedef struct BASIC_PassList {
-#ifdef USE_DEPTH
struct DRWPass *depth_pass;
struct DRWPass *depth_pass_cull;
-#endif
- struct DRWPass *color_pass;
} BASIC_PassList;
typedef struct BASIC_Data {
@@ -72,38 +66,24 @@ typedef struct BASIC_Data {
/* *********** STATIC *********** */
static struct {
-#ifdef USE_DEPTH
/* Depth Pre Pass */
struct GPUShader *depth_sh;
-#endif
- /* Shading Pass */
- struct GPUShader *color_sh;
} e_data = {NULL}; /* Engine data */
typedef struct BASIC_PrivateData {
-#ifdef USE_DEPTH
DRWShadingGroup *depth_shgrp;
DRWShadingGroup *depth_shgrp_cull;
DRWShadingGroup *depth_shgrp_hair;
-#endif
- DRWShadingGroup *color_shgrp;
} BASIC_PrivateData; /* Transient data */
/* Functions */
static void basic_engine_init(void *UNUSED(vedata))
{
-#ifdef USE_DEPTH
/* Depth prepass */
if (!e_data.depth_sh) {
e_data.depth_sh = DRW_shader_create_3D_depth_only();
}
-#endif
-
- /* Shading pass */
- if (!e_data.color_sh) {
- e_data.color_sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
- }
}
static void basic_cache_init(void *vedata)
@@ -116,8 +96,6 @@ static void basic_cache_init(void *vedata)
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
}
-#ifdef USE_DEPTH
- /* Depth Pass */
{
psl->depth_pass = DRW_pass_create(
"Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WIRE);
@@ -128,13 +106,6 @@ static void basic_cache_init(void *vedata)
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK);
stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
}
-#endif
-
- /* Color Pass */
- {
- psl->color_pass = DRW_pass_create("Color Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
- stl->g_data->color_shgrp = DRW_shgroup_create(e_data.color_sh, psl->color_pass);
- }
}
static void basic_cache_populate(void *vedata, Object *ob)
@@ -146,34 +117,31 @@ static void basic_cache_populate(void *vedata, Object *ob)
}
const DRWContextState *draw_ctx = DRW_context_state_get();
- if (ob == draw_ctx->object_edit) {
- return;
- }
-
- for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
- if (!psys_check_enabled(ob, psys, false)) {
- continue;
- }
- if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
- continue;
- }
- ParticleSettings *part = psys->part;
- const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
- if (draw_as == PART_DRAW_PATH) {
- struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL);
- DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL);
+ if (ob != draw_ctx->object_edit) {
+ for (ParticleSystem *psys = ob->particlesystem.first;
+ psys != NULL;
+ psys = psys->next)
+ {
+ if (!psys_check_enabled(ob, psys, false)) {
+ continue;
+ }
+ if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
+ continue;
+ }
+ ParticleSettings *part = psys->part;
+ const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
+ if (draw_as == PART_DRAW_PATH) {
+ struct GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL);
+ DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL);
+ }
}
}
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
- bool do_cull = false; /* TODO (we probably wan't to take this from the viewport?) */
-#ifdef USE_DEPTH
+ const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING));
/* Depth Prepass */
DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
-#endif
- /* Shading */
- DRW_shgroup_call_add(stl->g_data->color_shgrp, geom, ob->obmat);
}
}
@@ -186,36 +154,10 @@ static void basic_cache_finish(void *vedata)
static void basic_draw_scene(void *vedata)
{
-
BASIC_PassList *psl = ((BASIC_Data *)vedata)->psl;
- const bool is_select = DRW_state_is_select();
-
- bool use_color = true;
- bool use_depth = true;
- bool use_depth_cull = true;
-
- if (is_select) {
- /* Needed for depth-picking,
- * for other selection types there are no need for extra passes either. */
- use_color = false;
- use_depth_cull = false;
- }
-#ifdef USE_DEPTH
- /* Pass 1 : Depth pre-pass */
- if (use_depth) {
- DRW_draw_pass(psl->depth_pass);
- }
-
- if (use_depth_cull) {
- DRW_draw_pass(psl->depth_pass_cull);
- }
-#endif
-
- /* Pass 3 : Shading */
- if (use_color) {
- DRW_draw_pass(psl->color_pass);
- }
+ DRW_draw_pass(psl->depth_pass);
+ DRW_draw_pass(psl->depth_pass_cull);
}
static void basic_engine_free(void)
diff --git a/source/blender/draw/engines/eevee/eevee_bloom.c b/source/blender/draw/engines/eevee/eevee_bloom.c
index 8be9c637fbc..d111c28b256 100644
--- a/source/blender/draw/engines/eevee/eevee_bloom.c
+++ b/source/blender/draw/engines/eevee/eevee_bloom.c
@@ -132,9 +132,9 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
/* determine the iteration count */
const float minDim = (float)MIN2(blitsize[0], blitsize[1]);
const float maxIter = (radius - 8.0f) + log(minDim) / log(2);
- const int maxIterInt = effects->bloom_iteration_ct = (int)maxIter;
+ const int maxIterInt = effects->bloom_iteration_len = (int)maxIter;
- CLAMP(effects->bloom_iteration_ct, 1, MAX_BLOOM_STEP);
+ CLAMP(effects->bloom_iteration_len, 1, MAX_BLOOM_STEP);
effects->bloom_sample_scale = 0.5f + maxIter - (float)maxIterInt;
effects->bloom_curve_threshold[0] = threshold - knee;
@@ -146,7 +146,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
/* Downsample buffers */
copy_v2_v2_int(texsize, blitsize);
- for (int i = 0; i < effects->bloom_iteration_ct; ++i) {
+ for (int i = 0; i < effects->bloom_iteration_len; ++i) {
texsize[0] /= 2; texsize[1] /= 2;
texsize[0] = MAX2(texsize[0], 2);
@@ -165,7 +165,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
/* Upsample buffers */
copy_v2_v2_int(texsize, blitsize);
- for (int i = 0; i < effects->bloom_iteration_ct - 1; ++i) {
+ for (int i = 0; i < effects->bloom_iteration_len - 1; ++i) {
texsize[0] /= 2; texsize[1] /= 2;
texsize[0] = MAX2(texsize[0], 2);
@@ -196,7 +196,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
static DRWShadingGroup *eevee_create_bloom_pass(
const char *name, EEVEE_EffectsInfo *effects, struct GPUShader *sh, DRWPass **pass, bool upsample)
{
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
*pass = DRW_pass_create(name, DRW_STATE_WRITE_COLOR);
@@ -291,7 +291,7 @@ void EEVEE_bloom_draw(EEVEE_Data *vedata)
last = effects->bloom_downsample[0];
- for (int i = 1; i < effects->bloom_iteration_ct; ++i) {
+ for (int i = 1; i < effects->bloom_iteration_len; ++i) {
copy_v2_v2(effects->unf_source_texel_size, effects->downsamp_texel_size[i - 1]);
effects->unf_source_buffer = last;
@@ -303,7 +303,7 @@ void EEVEE_bloom_draw(EEVEE_Data *vedata)
}
/* Upsample and accumulate */
- for (int i = effects->bloom_iteration_ct - 2; i >= 0; --i) {
+ for (int i = effects->bloom_iteration_len - 2; i >= 0; --i) {
copy_v2_v2(effects->unf_source_texel_size, effects->downsamp_texel_size[i]);
effects->unf_source_buffer = effects->bloom_downsample[i];
effects->unf_base_buffer = last;
diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c
index e9883cc3054..96e784b524c 100644
--- a/source/blender/draw/engines/eevee/eevee_data.c
+++ b/source/blender/draw/engines/eevee/eevee_data.c
@@ -28,6 +28,7 @@
#include "DRW_render.h"
#include "eevee_private.h"
+#include "eevee_lightcache.h"
static void eevee_view_layer_data_free(void *storage)
{
@@ -53,6 +54,11 @@ static void eevee_view_layer_data_free(void *storage)
MEM_SAFE_FREE(sldata->shcasters_buffers[1].shadow_casters);
MEM_SAFE_FREE(sldata->shcasters_buffers[1].flags);
+ if (sldata->fallback_lightcache) {
+ EEVEE_lightcache_free(sldata->fallback_lightcache);
+ sldata->fallback_lightcache = NULL;
+ }
+
/* Probes */
MEM_SAFE_FREE(sldata->probes);
DRW_UBO_FREE_SAFE(sldata->probe_ubo);
@@ -60,15 +66,6 @@ static void eevee_view_layer_data_free(void *storage)
DRW_UBO_FREE_SAFE(sldata->planar_ubo);
DRW_UBO_FREE_SAFE(sldata->common_ubo);
DRW_UBO_FREE_SAFE(sldata->clip_ubo);
- GPU_FRAMEBUFFER_FREE_SAFE(sldata->probe_filter_fb);
- for (int i = 0; i < 6; ++i) {
- GPU_FRAMEBUFFER_FREE_SAFE(sldata->probe_face_fb[i]);
- }
- DRW_TEXTURE_FREE_SAFE(sldata->probe_rt);
- DRW_TEXTURE_FREE_SAFE(sldata->probe_depth_rt);
- DRW_TEXTURE_FREE_SAFE(sldata->probe_pool);
- DRW_TEXTURE_FREE_SAFE(sldata->irradiance_pool);
- DRW_TEXTURE_FREE_SAFE(sldata->irradiance_rt);
}
EEVEE_ViewLayerData *EEVEE_view_layer_data_get(void)
@@ -77,6 +74,18 @@ EEVEE_ViewLayerData *EEVEE_view_layer_data_get(void)
&draw_engine_eevee_type);
}
+EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure_ex(struct ViewLayer *view_layer)
+{
+ EEVEE_ViewLayerData **sldata = (EEVEE_ViewLayerData **)DRW_view_layer_engine_data_ensure_ex(
+ view_layer, &draw_engine_eevee_type, &eevee_view_layer_data_free);
+
+ if (*sldata == NULL) {
+ *sldata = MEM_callocN(sizeof(**sldata), "EEVEE_ViewLayerData");
+ }
+
+ return *sldata;
+}
+
EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure(void)
{
EEVEE_ViewLayerData **sldata = (EEVEE_ViewLayerData **)DRW_view_layer_engine_data_ensure(
@@ -91,9 +100,9 @@ EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure(void)
/* Object data. */
-static void eevee_object_data_init(ObjectEngineData *engine_data)
+static void eevee_object_data_init(DrawData *dd)
{
- EEVEE_ObjectEngineData *eevee_data = (EEVEE_ObjectEngineData *)engine_data;
+ EEVEE_ObjectEngineData *eevee_data = (EEVEE_ObjectEngineData *)dd;
eevee_data->shadow_caster_id = -1;
}
@@ -102,15 +111,15 @@ EEVEE_ObjectEngineData *EEVEE_object_data_get(Object *ob)
if (ELEM(ob->type, OB_LIGHTPROBE, OB_LAMP)) {
return NULL;
}
- return (EEVEE_ObjectEngineData *)DRW_object_engine_data_get(
- ob, &draw_engine_eevee_type);
+ return (EEVEE_ObjectEngineData *)DRW_drawdata_get(
+ &ob->id, &draw_engine_eevee_type);
}
EEVEE_ObjectEngineData *EEVEE_object_data_ensure(Object *ob)
{
BLI_assert(!ELEM(ob->type, OB_LIGHTPROBE, OB_LAMP));
- return (EEVEE_ObjectEngineData *)DRW_object_engine_data_ensure(
- ob,
+ return (EEVEE_ObjectEngineData *)DRW_drawdata_ensure(
+ &ob->id,
&draw_engine_eevee_type,
sizeof(EEVEE_ObjectEngineData),
eevee_object_data_init,
@@ -119,18 +128,10 @@ EEVEE_ObjectEngineData *EEVEE_object_data_ensure(Object *ob)
/* Light probe data. */
-static void eevee_lightprobe_data_init(ObjectEngineData *engine_data)
+static void eevee_lightprobe_data_init(DrawData *dd)
{
- EEVEE_LightProbeEngineData *ped = (EEVEE_LightProbeEngineData *)engine_data;
- ped->need_full_update = true;
- ped->need_update = true;
-}
-
-static void eevee_lightprobe_data_free(ObjectEngineData *engine_data)
-{
- EEVEE_LightProbeEngineData *ped = (EEVEE_LightProbeEngineData *)engine_data;
-
- BLI_freelistN(&ped->captured_object_list);
+ EEVEE_LightProbeEngineData *ped = (EEVEE_LightProbeEngineData *)dd;
+ ped->need_update = false;
}
EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob)
@@ -138,26 +139,26 @@ EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob)
if (ob->type != OB_LIGHTPROBE) {
return NULL;
}
- return (EEVEE_LightProbeEngineData *)DRW_object_engine_data_get(
- ob, &draw_engine_eevee_type);
+ return (EEVEE_LightProbeEngineData *)DRW_drawdata_get(
+ &ob->id, &draw_engine_eevee_type);
}
EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_ensure(Object *ob)
{
BLI_assert(ob->type == OB_LIGHTPROBE);
- return (EEVEE_LightProbeEngineData *)DRW_object_engine_data_ensure(
- ob,
+ return (EEVEE_LightProbeEngineData *)DRW_drawdata_ensure(
+ &ob->id,
&draw_engine_eevee_type,
sizeof(EEVEE_LightProbeEngineData),
eevee_lightprobe_data_init,
- eevee_lightprobe_data_free);
+ NULL);
}
/* Lamp data. */
-static void eevee_lamp_data_init(ObjectEngineData *engine_data)
+static void eevee_lamp_data_init(DrawData *dd)
{
- EEVEE_LampEngineData *led = (EEVEE_LampEngineData *)engine_data;
+ EEVEE_LampEngineData *led = (EEVEE_LampEngineData *)dd;
led->need_update = true;
led->prev_cube_shadow_id = -1;
}
@@ -167,17 +168,41 @@ EEVEE_LampEngineData *EEVEE_lamp_data_get(Object *ob)
if (ob->type != OB_LAMP) {
return NULL;
}
- return (EEVEE_LampEngineData *)DRW_object_engine_data_get(
- ob, &draw_engine_eevee_type);
+ return (EEVEE_LampEngineData *)DRW_drawdata_get(
+ &ob->id, &draw_engine_eevee_type);
}
EEVEE_LampEngineData *EEVEE_lamp_data_ensure(Object *ob)
{
BLI_assert(ob->type == OB_LAMP);
- return (EEVEE_LampEngineData *)DRW_object_engine_data_ensure(
- ob,
+ return (EEVEE_LampEngineData *)DRW_drawdata_ensure(
+ &ob->id,
&draw_engine_eevee_type,
sizeof(EEVEE_LampEngineData),
eevee_lamp_data_init,
NULL);
}
+
+/* World data. */
+
+static void eevee_world_data_init(DrawData *dd)
+{
+ EEVEE_WorldEngineData *wed = (EEVEE_WorldEngineData *)dd;
+ wed->dd.recalc |= 1;
+}
+
+EEVEE_WorldEngineData *EEVEE_world_data_get(World *wo)
+{
+ return (EEVEE_WorldEngineData *)DRW_drawdata_get(
+ &wo->id, &draw_engine_eevee_type);
+}
+
+EEVEE_WorldEngineData *EEVEE_world_data_ensure(World *wo)
+{
+ return (EEVEE_WorldEngineData *)DRW_drawdata_ensure(
+ &wo->id,
+ &draw_engine_eevee_type,
+ sizeof(EEVEE_WorldEngineData),
+ eevee_world_data_init,
+ NULL);
+}
diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index 60c6175f4fa..cb54ad3a164 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -192,7 +192,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
* - Finally composite the 2 blurred buffers with the original render.
**/
DRWShadingGroup *grp;
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
psl->dof_down = DRW_pass_create("DoF Downsample", DRW_STATE_WRITE_COLOR);
@@ -208,8 +208,8 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
/* This create an empty batch of N triangles to be positioned
* by the vertex shader 0.4ms against 6ms with instancing */
const float *viewport_size = DRW_viewport_size_get();
- const int sprite_ct = ((int)viewport_size[0] / 2) * ((int)viewport_size[1] / 2); /* brackets matters */
- grp = DRW_shgroup_empty_tri_batch_create(e_data.dof_scatter_sh, psl->dof_scatter, sprite_ct);
+ const int sprite_len = ((int)viewport_size[0] / 2) * ((int)viewport_size[1] / 2); /* brackets matters */
+ grp = DRW_shgroup_empty_tri_batch_create(e_data.dof_scatter_sh, psl->dof_scatter, sprite_len);
DRW_shgroup_uniform_texture_ref(grp, "nearBuffer", &effects->dof_down_near);
DRW_shgroup_uniform_texture_ref(grp, "farBuffer", &effects->dof_down_far);
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index d7a978066d5..28658d5126c 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -302,7 +302,7 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
downsample_write = DRW_STATE_WRITE_COLOR;
}
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
{
psl->color_downsample_ps = DRW_pass_create(
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index d2400b8b651..adbe165354a 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -123,7 +123,7 @@ static void eevee_cache_init(void *vedata)
EEVEE_volumes_cache_init(sldata, vedata);
}
-static void eevee_cache_populate(void *vedata, Object *ob)
+void EEVEE_cache_populate(void *vedata, Object *ob)
{
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
@@ -146,7 +146,7 @@ static void eevee_cache_populate(void *vedata, Object *ob)
/* TODO: Special case for dupli objects because we cannot save the object pointer. */
}
else {
- EEVEE_lightprobes_cache_add(sldata, ob);
+ EEVEE_lightprobes_cache_add(sldata, vedata, ob);
}
}
else if (ob->type == OB_LAMP) {
@@ -191,10 +191,10 @@ static void eevee_draw_background(void *vedata)
/* Number of iteration: needed for all temporal effect (SSR, volumetrics)
* when using opengl render. */
- int loop_ct = (DRW_state_is_image_render() &&
+ int loop_len = (DRW_state_is_image_render() &&
(stl->effects->enabled_effects & (EFFECT_VOLUMETRIC | EFFECT_SSR)) != 0) ? 4 : 1;
- while (loop_ct--) {
+ while (loop_len--) {
float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float clear_depth = 1.0f;
uint clear_stencil = 0xFF;
@@ -282,7 +282,9 @@ static void eevee_draw_background(void *vedata)
EEVEE_subsurface_compute(sldata, vedata);
EEVEE_reflection_compute(sldata, vedata);
EEVEE_occlusion_draw_debug(sldata, vedata);
- DRW_draw_pass(psl->probe_display);
+ if (psl->probe_display) {
+ DRW_draw_pass(psl->probe_display);
+ }
EEVEE_refraction_compute(sldata, vedata);
/* Opaque refraction */
@@ -365,21 +367,35 @@ static void eevee_view_update(void *vedata)
static void eevee_id_object_update(void *UNUSED(vedata), Object *object)
{
- /* This is a bit mask of components which update is to be ignored. */
EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(object);
- if (ped != NULL && ped->engine_data.recalc != 0) {
- ped->need_full_update = true;
- ped->engine_data.recalc = 0;
+ if (ped != NULL && ped->dd.recalc != 0) {
+ ped->need_update = (ped->dd.recalc & (ID_RECALC_TRANSFORM | ID_RECALC_COPY_ON_WRITE)) != 0;
+ ped->dd.recalc = 0;
}
EEVEE_LampEngineData *led = EEVEE_lamp_data_get(object);
- if (led != NULL && led->engine_data.recalc != 0) {
+ if (led != NULL && led->dd.recalc != 0) {
led->need_update = true;
- led->engine_data.recalc = 0;
+ led->dd.recalc = 0;
}
EEVEE_ObjectEngineData *oedata = EEVEE_object_data_get(object);
- if (oedata != NULL && oedata->engine_data.recalc != 0) {
+ if (oedata != NULL && oedata->dd.recalc != 0) {
oedata->need_update = true;
- oedata->engine_data.recalc = 0;
+ oedata->dd.recalc = 0;
+ }
+}
+
+static void eevee_id_world_update(void *vedata, World *wo)
+{
+ EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ LightCache *lcache = stl->g_data->light_cache;
+
+ EEVEE_WorldEngineData *wedata = EEVEE_world_data_ensure(wo);
+
+ if (wedata != NULL && wedata->dd.recalc != 0) {
+ if ((lcache->flag & (LIGHTCACHE_BAKED | LIGHTCACHE_BAKING)) == 0) {
+ lcache->flag |= LIGHTCACHE_UPDATE_WORLD;
+ }
+ wedata->dd.recalc = 0;
}
}
@@ -387,6 +403,9 @@ static void eevee_id_update(void *vedata, ID *id)
{
/* Handle updates based on ID type. */
switch (GS(id->name)) {
+ case ID_WO:
+ eevee_id_world_update(vedata, (World *)id);
+ break;
case ID_OB:
eevee_id_object_update(vedata, (Object *)id);
break;
@@ -433,7 +452,7 @@ DrawEngineType draw_engine_eevee_type = {
&eevee_engine_init,
&eevee_engine_free,
&eevee_cache_init,
- &eevee_cache_populate,
+ &EEVEE_cache_populate,
&eevee_cache_finish,
&eevee_draw_background,
NULL, /* Everything is drawn in the background pass (see comment on function) */
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
new file mode 100644
index 00000000000..4f5ad5159cf
--- /dev/null
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -0,0 +1,1141 @@
+/*
+ * Copyright 2016, 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(s): Blender Institute
+ *
+ */
+
+/** \file eevee_lightcache.c
+ * \ingroup draw_engine
+ *
+ * Eevee's indirect lighting cache.
+ */
+
+#include "DRW_render.h"
+
+#include "BKE_global.h"
+#include "BKE_blender.h"
+
+#include "BLI_threads.h"
+
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
+#include "BKE_object.h"
+
+#include "DNA_lightprobe_types.h"
+#include "DNA_group_types.h"
+
+#include "PIL_time.h"
+
+#include "eevee_lightcache.h"
+#include "eevee_private.h"
+
+#include "GPU_context.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "wm_window.h"
+
+/* Rounded to nearest PowerOfTwo */
+#if defined(IRRADIANCE_SH_L2)
+#define IRRADIANCE_SAMPLE_SIZE_X 4 /* 3 in reality */
+#define IRRADIANCE_SAMPLE_SIZE_Y 4 /* 3 in reality */
+#elif defined(IRRADIANCE_CUBEMAP)
+#define IRRADIANCE_SAMPLE_SIZE_X 8
+#define IRRADIANCE_SAMPLE_SIZE_Y 8
+#elif defined(IRRADIANCE_HL2)
+#define IRRADIANCE_SAMPLE_SIZE_X 4 /* 3 in reality */
+#define IRRADIANCE_SAMPLE_SIZE_Y 2
+#endif
+
+#ifdef IRRADIANCE_SH_L2
+/* we need a signed format for Spherical Harmonics */
+# define IRRADIANCE_FORMAT GPU_RGBA16F
+#else
+# define IRRADIANCE_FORMAT GPU_RGBA8
+#endif
+
+#define IRRADIANCE_MAX_POOL_LAYER 256 /* OpenGL 3.3 core requirement, can be extended but it's already very big */
+#define IRRADIANCE_MAX_POOL_SIZE 1024
+#define MAX_IRRADIANCE_SAMPLES \
+ (IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_X) * \
+ (IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_Y)
+
+/* TODO should be replace by a more elegant alternative. */
+extern void DRW_opengl_context_enable(void);
+extern void DRW_opengl_context_disable(void);
+
+extern void DRW_opengl_render_context_enable(void *re_gl_context);
+extern void DRW_opengl_render_context_disable(void *re_gl_context);
+extern void DRW_gawain_render_context_enable(void *re_gpu_context);
+extern void DRW_gawain_render_context_disable(void *re_gpu_context);
+
+typedef struct EEVEE_LightBake {
+ Depsgraph *depsgraph;
+ ViewLayer *view_layer;
+ ViewLayer *view_layer_input;
+ LightCache *lcache;
+ Scene *scene;
+ struct Main *bmain;
+
+ LightProbe **probe; /* Current probe being rendered. */
+ GPUTexture *rt_color; /* Target cube color texture. */
+ GPUTexture *rt_depth; /* Target cube depth texture. */
+ GPUFrameBuffer *rt_fb[6]; /* Target cube framebuffers. */
+ GPUFrameBuffer *store_fb; /* Storage framebuffer. */
+ int rt_res; /* Cube render target resolution. */
+
+ /* Shared */
+ int layer; /* Target layer to store the data to. */
+ float samples_ct, invsamples_ct; /* Sample count for the convolution. */
+ float lod_factor; /* Sampling bias during convolution step. */
+ float lod_max; /* Max cubemap LOD to sample when convolving. */
+ int cube_len, grid_len; /* Number of probes to render + world probe. */
+
+ /* Irradiance grid */
+ EEVEE_LightGrid *grid; /* Current probe being rendered (UBO data). */
+ int irr_cube_res; /* Target cubemap at MIP 0. */
+ int irr_size[3]; /* Size of the irradiance texture. */
+ int total_irr_samples; /* Total for all grids */
+ int grid_sample; /* Nth sample of the current grid being rendered. */
+ int grid_sample_len; /* Total number of samples for the current grid. */
+ int grid_curr; /* Nth grid in the cache being rendered. */
+ int bounce_curr, bounce_len; /* The current light bounce being evaluated. */
+ float vis_range, vis_blur; /* Sample Visibility compression and bluring. */
+ float vis_res; /* Resolution of the Visibility shadowmap. */
+ GPUTexture *grid_prev; /* Result of previous light bounce. */
+ LightProbe **grid_prb; /* Pointer to the id.data of the probe object. */
+
+ /* Reflection probe */
+ EEVEE_LightProbe *cube; /* Current probe being rendered (UBO data). */
+ int ref_cube_res; /* Target cubemap at MIP 0. */
+ int cube_offset; /* Index of the current cube. */
+ float probemat[6][4][4]; /* ViewProjection matrix for each cube face. */
+ float texel_size, padding_size; /* Texel and padding size for the final octahedral map. */
+ float roughness; /* Roughness level of the current mipmap. */
+ LightProbe **cube_prb; /* Pointer to the id.data of the probe object. */
+
+ /* Dummy Textures */
+ struct GPUTexture *dummy_color, *dummy_depth;
+ struct GPUTexture *dummy_layer_color;
+
+ int total, done; /* to compute progress */
+ short *stop, *do_update;
+ float *progress;
+
+ bool resource_only; /* For only handling the resources. */
+ bool own_resources;
+ bool own_light_cache; /* If the lightcache was created for baking, it's first owned by the baker. */
+ int delay; /* ms. delay the start of the baking to not slowdown interactions (TODO remove) */
+
+ void *gl_context, *gpu_context; /* If running in parallel (in a separate thread), use this context. */
+} EEVEE_LightBake;
+
+/* -------------------------------------------------------------------- */
+
+/** \name Light Cache
+ * \{ */
+
+/* Return memory footprint in bytes. */
+static unsigned int eevee_lightcache_memsize_get(LightCache *lcache)
+{
+ unsigned int size = 0;
+ if (lcache->grid_tx.data) {
+ size += MEM_allocN_len(lcache->grid_tx.data);
+ }
+ if (lcache->cube_tx.data) {
+ size += MEM_allocN_len(lcache->cube_tx.data);
+ for (int mip = 0; mip < lcache->mips_len; ++mip) {
+ size += MEM_allocN_len(lcache->cube_mips[mip].data);
+ }
+ }
+ return size;
+}
+
+static int eevee_lightcache_irradiance_sample_count(LightCache *lcache)
+{
+ int total_irr_samples = 0;
+
+ for (int i = 1; i < lcache->grid_len; ++i) {
+ EEVEE_LightGrid *egrid = lcache->grid_data + i;
+ total_irr_samples += egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2];
+ }
+ return total_irr_samples;
+}
+
+void EEVEE_lightcache_info_update(SceneEEVEE *eevee)
+{
+ LightCache *lcache = eevee->light_cache;
+
+ if (lcache != NULL) {
+ char formatted_mem[15];
+ BLI_str_format_byte_unit(formatted_mem, eevee_lightcache_memsize_get(lcache), true);
+
+ int irr_samples = eevee_lightcache_irradiance_sample_count(lcache);
+
+ BLI_snprintf(eevee->light_cache_info, sizeof(eevee->light_cache_info), IFACE_("%d Ref. Cubemaps, %d Irr. Samples (%s in memory)"), lcache->cube_len - 1, irr_samples, formatted_mem);
+ }
+ else {
+ BLI_strncpy(eevee->light_cache_info, IFACE_("No light cache in this scene."), sizeof(eevee->light_cache_info));
+ }
+}
+
+static void irradiance_pool_size_get(int visibility_size, int total_samples, int r_size[3])
+{
+ /* Compute how many irradiance samples we can store per visibility sample. */
+ int irr_per_vis = (visibility_size / IRRADIANCE_SAMPLE_SIZE_X) *
+ (visibility_size / IRRADIANCE_SAMPLE_SIZE_Y);
+
+ /* The irradiance itself take one layer, hence the +1 */
+ int layer_ct = MIN2(irr_per_vis + 1, IRRADIANCE_MAX_POOL_LAYER);
+
+ int texel_ct = (int)ceilf((float)total_samples / (float)(layer_ct - 1));
+ r_size[0] = visibility_size * max_ii(1, min_ii(texel_ct, (IRRADIANCE_MAX_POOL_SIZE / visibility_size)));
+ r_size[1] = visibility_size * max_ii(1, (texel_ct / (IRRADIANCE_MAX_POOL_SIZE / visibility_size)));
+ r_size[2] = layer_ct;
+}
+
+static bool EEVEE_lightcache_validate(
+ const LightCache *light_cache,
+ const int cube_len,
+ const int cube_res,
+ const int grid_len,
+ const int irr_size[3])
+{
+ if (light_cache) {
+ /* See if we need the same amount of texture space. */
+ if ((irr_size[0] == light_cache->grid_tx.tex_size[0]) &&
+ (irr_size[1] == light_cache->grid_tx.tex_size[1]) &&
+ (irr_size[2] == light_cache->grid_tx.tex_size[2]) &&
+ (grid_len != light_cache->grid_len))
+ {
+ int mip_len = (int)(floorf(log2f(cube_res)) - MIN_CUBE_LOD_LEVEL);
+ if ((cube_res == light_cache->cube_tx.tex_size[0]) &&
+ (cube_len == light_cache->cube_tx.tex_size[2]) &&
+ (mip_len == light_cache->mips_len))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+LightCache *EEVEE_lightcache_create(
+ const int grid_len,
+ const int cube_len,
+ const int cube_size,
+ const int vis_size,
+ const int irr_size[3])
+{
+ LightCache *light_cache = MEM_callocN(sizeof(LightCache), "LightCache");
+
+ light_cache->cube_data = MEM_callocN(sizeof(EEVEE_LightProbe) * cube_len, "EEVEE_LightProbe");
+ light_cache->grid_data = MEM_callocN(sizeof(EEVEE_LightGrid) * grid_len, "EEVEE_LightGrid");
+
+ light_cache->grid_tx.tex = DRW_texture_create_2D_array(irr_size[0], irr_size[1], irr_size[2], IRRADIANCE_FORMAT, DRW_TEX_FILTER, NULL);
+ light_cache->grid_tx.tex_size[0] = irr_size[0];
+ light_cache->grid_tx.tex_size[1] = irr_size[1];
+ light_cache->grid_tx.tex_size[2] = irr_size[2];
+
+ light_cache->cube_tx.tex = DRW_texture_create_2D_array(cube_size, cube_size, cube_len, GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+ light_cache->cube_tx.tex_size[0] = cube_size;
+ light_cache->cube_tx.tex_size[1] = cube_size;
+ light_cache->cube_tx.tex_size[2] = cube_len;
+
+ light_cache->mips_len = (int)(floorf(log2f(cube_size)) - MIN_CUBE_LOD_LEVEL);
+ light_cache->vis_res = vis_size;
+ light_cache->ref_res = cube_size;
+
+ light_cache->cube_mips = MEM_callocN(sizeof(LightCacheTexture) * light_cache->mips_len, "LightCacheTexture");
+
+ for (int mip = 0; mip < light_cache->mips_len; ++mip) {
+ GPU_texture_get_mipmap_size(light_cache->cube_tx.tex, mip + 1, light_cache->cube_mips[mip].tex_size);
+ }
+
+ light_cache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | LIGHTCACHE_UPDATE_GRID;
+
+ return light_cache;
+}
+
+void EEVEE_lightcache_load(LightCache *lcache)
+{
+ if (lcache->grid_tx.tex == NULL && lcache->grid_tx.data) {
+ lcache->grid_tx.tex = GPU_texture_create_nD(lcache->grid_tx.tex_size[0],
+ lcache->grid_tx.tex_size[1],
+ lcache->grid_tx.tex_size[2],
+ 2,
+ lcache->grid_tx.data,
+ IRRADIANCE_FORMAT,
+ GPU_DATA_UNSIGNED_BYTE,
+ 0,
+ false,
+ NULL);
+ GPU_texture_bind(lcache->grid_tx.tex, 0);
+ GPU_texture_filter_mode(lcache->grid_tx.tex, true);
+ GPU_texture_unbind(lcache->grid_tx.tex);
+ }
+
+ if (lcache->cube_tx.tex == NULL && lcache->cube_tx.data) {
+ lcache->cube_tx.tex = GPU_texture_create_nD(lcache->cube_tx.tex_size[0],
+ lcache->cube_tx.tex_size[1],
+ lcache->cube_tx.tex_size[2],
+ 2,
+ lcache->cube_tx.data,
+ GPU_R11F_G11F_B10F,
+ GPU_DATA_10_11_11_REV,
+ 0,
+ false,
+ NULL);
+ GPU_texture_bind(lcache->cube_tx.tex, 0);
+ GPU_texture_mipmap_mode(lcache->cube_tx.tex, true, true);
+ for (int mip = 0; mip < lcache->mips_len; ++mip) {
+ GPU_texture_add_mipmap(lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, mip + 1, lcache->cube_mips[mip].data);
+ }
+ GPU_texture_unbind(lcache->cube_tx.tex);
+ }
+}
+
+static void eevee_lightbake_readback_irradiance(LightCache *lcache)
+{
+ MEM_SAFE_FREE(lcache->grid_tx.data);
+ lcache->grid_tx.data = GPU_texture_read(lcache->grid_tx.tex, GPU_DATA_UNSIGNED_BYTE, 0);
+ lcache->grid_tx.data_type = LIGHTCACHETEX_BYTE;
+ lcache->grid_tx.components = 4;
+}
+
+static void eevee_lightbake_readback_reflections(LightCache *lcache)
+{
+ MEM_SAFE_FREE(lcache->cube_tx.data);
+ lcache->cube_tx.data = GPU_texture_read(lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, 0);
+ lcache->cube_tx.data_type = LIGHTCACHETEX_UINT;
+ lcache->cube_tx.components = 1;
+
+ for (int mip = 0; mip < lcache->mips_len; ++mip) {
+ LightCacheTexture *cube_mip = lcache->cube_mips + mip;
+ MEM_SAFE_FREE(cube_mip->data);
+ GPU_texture_get_mipmap_size(lcache->cube_tx.tex, mip + 1, cube_mip->tex_size);
+
+ cube_mip->data = GPU_texture_read(lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, mip + 1);
+ cube_mip->data_type = LIGHTCACHETEX_UINT;
+ cube_mip->components = 1;
+ }
+}
+
+void EEVEE_lightcache_free(LightCache *lcache)
+{
+ DRW_TEXTURE_FREE_SAFE(lcache->cube_tx.tex);
+ MEM_SAFE_FREE(lcache->cube_tx.data);
+ DRW_TEXTURE_FREE_SAFE(lcache->grid_tx.tex);
+ MEM_SAFE_FREE(lcache->grid_tx.data);
+
+ if (lcache->cube_mips) {
+ for (int i = 0; i < lcache->mips_len; ++i) {
+ MEM_SAFE_FREE(lcache->cube_mips[i].data);
+ }
+ MEM_SAFE_FREE(lcache->cube_mips);
+ }
+
+ MEM_SAFE_FREE(lcache->cube_data);
+ MEM_SAFE_FREE(lcache->grid_data);
+ MEM_freeN(lcache);
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Light Bake Context
+ * \{ */
+
+static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake)
+{
+ if (lbake->gl_context) {
+ DRW_opengl_render_context_enable(lbake->gl_context);
+ if (lbake->gpu_context == NULL) {
+ lbake->gpu_context = GPU_context_create();
+ }
+ DRW_gawain_render_context_enable(lbake->gpu_context);
+ }
+ else {
+ DRW_opengl_context_enable();
+ }
+}
+
+static void eevee_lightbake_context_disable(EEVEE_LightBake *lbake)
+{
+ if (lbake->gl_context) {
+ DRW_gawain_render_context_disable(lbake->gpu_context);
+ DRW_opengl_render_context_disable(lbake->gl_context);
+ }
+ else {
+ DRW_opengl_context_disable();
+ }
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Light Bake Job
+ * \{ */
+
+static void eevee_lightbake_count_probes(EEVEE_LightBake *lbake)
+{
+ Depsgraph *depsgraph = lbake->depsgraph;
+
+ /* At least one of each for the world */
+ lbake->grid_len = lbake->cube_len = lbake->total_irr_samples = 1;
+
+ DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
+ {
+ if (!BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_FOR_RENDER)) {
+ continue;
+ }
+
+ if (ob->type == OB_LIGHTPROBE) {
+ LightProbe *prb = (LightProbe *)ob->data;
+
+ if (prb->type == LIGHTPROBE_TYPE_GRID) {
+ lbake->total_irr_samples += prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z;
+ lbake->grid_len++;
+ }
+ else if (prb->type == LIGHTPROBE_TYPE_CUBE) {
+ lbake->cube_len++;
+ }
+ }
+ }
+ DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
+}
+
+static void eevee_lightbake_create_render_target(EEVEE_LightBake *lbake, int rt_res)
+{
+ lbake->rt_depth = DRW_texture_create_cube(rt_res, GPU_DEPTH_COMPONENT24, 0, NULL);
+ lbake->rt_color = DRW_texture_create_cube(rt_res, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+
+ for (int i = 0; i < 6; ++i) {
+ GPU_framebuffer_ensure_config(&lbake->rt_fb[i], {
+ GPU_ATTACHMENT_TEXTURE_CUBEFACE(lbake->rt_depth, i),
+ GPU_ATTACHMENT_TEXTURE_CUBEFACE(lbake->rt_color, i)
+ });
+ }
+
+ GPU_framebuffer_ensure_config(&lbake->store_fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_NONE
+ });
+}
+
+static void eevee_lightbake_create_resources(EEVEE_LightBake *lbake)
+{
+ Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph);
+ SceneEEVEE *eevee = &scene_eval->eevee;
+
+ lbake->bounce_len = eevee->gi_diffuse_bounces;
+ lbake->vis_res = eevee->gi_visibility_resolution;
+ lbake->rt_res = eevee->gi_cubemap_resolution;
+
+ irradiance_pool_size_get(lbake->vis_res, lbake->total_irr_samples, lbake->irr_size);
+
+ lbake->ref_cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(lbake->rt_res);
+
+ lbake->cube_prb = MEM_callocN(sizeof(LightProbe *) * lbake->cube_len, "EEVEE Cube visgroup ptr");
+ lbake->grid_prb = MEM_callocN(sizeof(LightProbe *) * lbake->grid_len, "EEVEE Grid visgroup ptr");
+
+ lbake->grid_prev = DRW_texture_create_2D_array(lbake->irr_size[0], lbake->irr_size[1], lbake->irr_size[2],
+ IRRADIANCE_FORMAT, DRW_TEX_FILTER, NULL);
+
+ /* Ensure Light Cache is ready to accept new data. If not recreate one.
+ * WARNING: All the following must be threadsafe. It's currently protected
+ * by the DRW mutex. */
+ lbake->lcache = eevee->light_cache;
+
+ /* TODO validate irradiance and reflection cache independantly... */
+ if (lbake->lcache != NULL &&
+ !EEVEE_lightcache_validate(lbake->lcache, lbake->cube_len, lbake->ref_cube_res, lbake->grid_len, lbake->irr_size))
+ {
+ eevee->light_cache = lbake->lcache = NULL;
+ }
+
+ if (lbake->lcache == NULL) {
+ lbake->lcache = EEVEE_lightcache_create(lbake->grid_len,
+ lbake->cube_len,
+ lbake->ref_cube_res,
+ lbake->vis_res,
+ lbake->irr_size);
+ lbake->lcache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | LIGHTCACHE_UPDATE_GRID;
+ lbake->lcache->vis_res = lbake->vis_res;
+ lbake->own_light_cache = true;
+
+ eevee->light_cache = lbake->lcache;
+ }
+
+ EEVEE_lightcache_load(eevee->light_cache);
+
+ lbake->lcache->flag |= LIGHTCACHE_BAKING;
+ lbake->lcache->cube_len = 1;
+}
+
+wmJob *EEVEE_lightbake_job_create(
+ struct wmWindowManager *wm, struct wmWindow *win, struct Main *bmain,
+ struct ViewLayer *view_layer, struct Scene *scene, int delay)
+{
+ EEVEE_LightBake *lbake = NULL;
+
+ /* only one render job at a time */
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER))
+ return NULL;
+
+ wmJob *wm_job = WM_jobs_get(wm, win, scene, "Bake Lighting",
+ WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_LIGHT_BAKE);
+
+ /* If job exists do not recreate context and depsgraph. */
+ EEVEE_LightBake *old_lbake = (EEVEE_LightBake *)WM_jobs_customdata_get(wm_job);
+
+ if (old_lbake && (old_lbake->view_layer_input == view_layer) && (old_lbake->bmain == bmain)) {
+ lbake = MEM_callocN(sizeof(EEVEE_LightBake), "EEVEE_LightBake");
+ /* Cannot reuse depsgraph for now because we cannot get the update from the
+ * main database directly. TODO reuse depsgraph and only update positions. */
+ /* lbake->depsgraph = old_lbake->depsgraph; */
+ lbake->depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
+
+ lbake->scene = scene;
+ lbake->bmain = bmain;
+ lbake->view_layer_input = view_layer;
+ lbake->gl_context = old_lbake->gl_context;
+ lbake->own_resources = true;
+ lbake->delay = delay;
+
+ old_lbake->own_resources = false;
+
+ if (old_lbake->stop != NULL) {
+ *old_lbake->stop = 1;
+ }
+ }
+ else {
+ lbake = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, true);
+ lbake->delay = delay;
+ }
+
+ WM_jobs_customdata_set(wm_job, lbake, EEVEE_lightbake_job_data_free);
+ WM_jobs_timer(wm_job, 0.4, NC_SCENE | NA_EDITED, 0);
+ WM_jobs_callbacks(wm_job, EEVEE_lightbake_job, NULL, EEVEE_lightbake_update, EEVEE_lightbake_update);
+
+ G.is_break = false;
+
+ return wm_job;
+}
+
+/* MUST run on the main thread. */
+void *EEVEE_lightbake_job_data_alloc(
+ struct Main *bmain, struct ViewLayer *view_layer, struct Scene *scene, bool run_as_job)
+{
+ BLI_assert(BLI_thread_is_main());
+
+ EEVEE_LightBake *lbake = MEM_callocN(sizeof(EEVEE_LightBake), "EEVEE_LightBake");
+
+ lbake->depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
+ lbake->scene = scene;
+ lbake->bmain = bmain;
+ lbake->view_layer_input = view_layer;
+ lbake->own_resources = true;
+ lbake->own_light_cache = false;
+
+ if (run_as_job) {
+ lbake->gl_context = WM_opengl_context_create();
+ wm_window_reset_drawable();
+ }
+
+ return lbake;
+}
+
+void EEVEE_lightbake_job_data_free(void *custom_data)
+{
+ EEVEE_LightBake *lbake = (EEVEE_LightBake *)custom_data;
+
+ /* TODO reuse depsgraph. */
+ /* if (lbake->own_resources) { */
+ DEG_graph_free(lbake->depsgraph);
+ /* } */
+
+ MEM_SAFE_FREE(lbake->cube_prb);
+ MEM_SAFE_FREE(lbake->grid_prb);
+
+ MEM_freeN(lbake);
+}
+
+static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake)
+{
+ if (lbake->gl_context) {
+ DRW_opengl_render_context_enable(lbake->gl_context);
+ DRW_gawain_render_context_enable(lbake->gpu_context);
+ }
+ else if (!lbake->resource_only) {
+ DRW_opengl_context_enable();
+ }
+
+ if (lbake->own_light_cache) {
+ EEVEE_lightcache_free(lbake->lcache);
+ lbake->lcache = NULL;
+ }
+
+ DRW_TEXTURE_FREE_SAFE(lbake->rt_depth);
+ DRW_TEXTURE_FREE_SAFE(lbake->rt_color);
+ DRW_TEXTURE_FREE_SAFE(lbake->grid_prev);
+ GPU_FRAMEBUFFER_FREE_SAFE(lbake->store_fb);
+ for (int i = 0; i < 6; ++i) {
+ GPU_FRAMEBUFFER_FREE_SAFE(lbake->rt_fb[i]);
+ }
+
+ if (lbake->gpu_context) {
+ DRW_gawain_render_context_disable(lbake->gpu_context);
+ DRW_gawain_render_context_enable(lbake->gpu_context);
+ GPU_context_discard(lbake->gpu_context);
+ }
+
+ if (lbake->gl_context && lbake->own_resources) {
+ /* Delete the baking context. */
+ DRW_opengl_render_context_disable(lbake->gl_context);
+ WM_opengl_context_dispose(lbake->gl_context);
+ lbake->gpu_context = NULL;
+ lbake->gl_context = NULL;
+ }
+ else if (lbake->gl_context) {
+ DRW_opengl_render_context_disable(lbake->gl_context);
+ }
+ else if (!lbake->resource_only) {
+ DRW_opengl_context_disable();
+ }
+}
+
+/* Cache as in draw cache not light cache. */
+static void eevee_lightbake_cache_create(EEVEE_Data *vedata, EEVEE_LightBake *lbake)
+{
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
+ EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
+ Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph);
+ /* Disable all effects BUT high bitdepth shadows. */
+ scene_eval->eevee.flag &= SCE_EEVEE_SHADOW_HIGH_BITDEPTH;
+ scene_eval->eevee.taa_samples = 1;
+
+ stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__);
+ stl->g_data->background_alpha = 1.0f;
+
+ /* XXX TODO remove this. This is in order to make the init functions work. */
+ DRWMatrixState dummy_mats = {{{{{0}}}}};
+ DRW_viewport_matrix_override_set_all(&dummy_mats);
+
+ if (sldata->common_ubo == NULL) {
+ sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data), &sldata->common_data);
+ }
+ if (sldata->clip_ubo == NULL) {
+ sldata->clip_ubo = DRW_uniformbuffer_create(sizeof(sldata->clip_data), &sldata->clip_data);
+ }
+
+ EEVEE_effects_init(sldata, vedata, NULL);
+ EEVEE_materials_init(sldata, stl, fbl);
+ EEVEE_lights_init(sldata);
+ EEVEE_lightprobes_init(sldata, vedata);
+
+ EEVEE_effects_cache_init(sldata, vedata);
+ EEVEE_materials_cache_init(sldata, vedata);
+ EEVEE_lights_cache_init(sldata, vedata);
+ EEVEE_lightprobes_cache_init(sldata, vedata);
+
+ EEVEE_lightbake_cache_init(sldata, vedata, lbake->rt_color, lbake->rt_depth);
+
+ if (lbake->probe) {
+ EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ LightProbe *prb = *lbake->probe;
+ pinfo->vis_data.collection = prb->visibility_grp;
+ pinfo->vis_data.invert = prb->flag & LIGHTPROBE_FLAG_INVERT_GROUP;
+ pinfo->vis_data.cached = false;
+ }
+ DRW_render_object_iter(vedata, NULL, lbake->depsgraph, EEVEE_render_cache);
+
+ EEVEE_materials_cache_finish(vedata);
+ EEVEE_lights_cache_finish(sldata);
+ EEVEE_lightprobes_cache_finish(sldata, vedata);
+
+ DRW_render_instance_buffer_finish();
+ DRW_hair_update();
+}
+
+static void eevee_lightbake_copy_irradiance(EEVEE_LightBake *lbake, LightCache *lcache)
+{
+ DRW_TEXTURE_FREE_SAFE(lbake->grid_prev);
+
+ /* Copy texture by reading back and reuploading it. */
+ float *tex = GPU_texture_read(lcache->grid_tx.tex, GPU_DATA_FLOAT, 0);
+ lbake->grid_prev = DRW_texture_create_2D_array(lbake->irr_size[0], lbake->irr_size[1], lbake->irr_size[2],
+ IRRADIANCE_FORMAT, DRW_TEX_FILTER, tex);
+
+ MEM_freeN(tex);
+}
+
+static void eevee_lightbake_render_world_sample(void *ved, void *user_data)
+{
+ EEVEE_Data *vedata = (EEVEE_Data *)ved;
+ EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
+ EEVEE_LightBake *lbake = (EEVEE_LightBake *)user_data;
+ Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph);
+ LightCache *lcache = scene_eval->eevee.light_cache;
+
+ /* TODO do this once for the whole bake when we have independant DRWManagers. */
+ eevee_lightbake_cache_create(vedata, lbake);
+
+ EEVEE_lightbake_render_world(sldata, vedata, lbake->rt_fb);
+ EEVEE_lightbake_filter_glossy(sldata, vedata, lbake->rt_color, lbake->store_fb, 0, 1.0f, lcache->mips_len);
+ EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake->rt_color, lbake->store_fb, 0, 1.0f);
+
+ /* Clear the cache to avoid white values in the grid. */
+ GPU_framebuffer_texture_attach(lbake->store_fb, lbake->grid_prev, 0, 0);
+ GPU_framebuffer_bind(lbake->store_fb);
+ /* Clear to 1.0f for visibility. */
+ GPU_framebuffer_clear_color(lbake->store_fb, ((float[4]){1.0f, 1.0f, 1.0f, 1.0f}));
+ DRW_draw_pass(vedata->psl->probe_grid_fill);
+
+ SWAP(GPUTexture *, lbake->grid_prev, lcache->grid_tx.tex);
+
+ /* Make a copy for later. */
+ eevee_lightbake_copy_irradiance(lbake, lcache);
+
+ lcache->cube_len = 1;
+ lcache->grid_len = lbake->grid_len;
+
+ lcache->flag |= LIGHTCACHE_CUBE_READY | LIGHTCACHE_GRID_READY;
+ lcache->flag &= ~LIGHTCACHE_UPDATE_WORLD;
+}
+
+static void cell_id_to_grid_loc(EEVEE_LightGrid *egrid, int cell_idx, int r_local_cell[3])
+{
+ /* Keep in sync with lightprobe_grid_display_vert */
+ r_local_cell[2] = cell_idx % egrid->resolution[2];
+ r_local_cell[1] = (cell_idx / egrid->resolution[2]) % egrid->resolution[1];
+ r_local_cell[0] = cell_idx / (egrid->resolution[2] * egrid->resolution[1]);
+}
+
+static void compute_cell_id(
+ EEVEE_LightGrid *egrid, LightProbe *probe,
+ int cell_idx, int *r_final_idx, int r_local_cell[3], int *r_stride)
+{
+ const int cell_count = probe->grid_resolution_x * probe->grid_resolution_y * probe->grid_resolution_z;
+
+ /* Add one for level 0 */
+ int max_lvl = (int)floorf(log2f((float)MAX3(probe->grid_resolution_x,
+ probe->grid_resolution_y,
+ probe->grid_resolution_z)));
+
+ int visited_cells = 0;
+ for (int lvl = max_lvl; lvl >= 0; --lvl) {
+ *r_stride = 1 << lvl;
+ int prev_stride = *r_stride << 1;
+ for (int i = 0; i < cell_count; ++i) {
+ *r_final_idx = i;
+ cell_id_to_grid_loc(egrid, *r_final_idx, r_local_cell);
+ if (((r_local_cell[0] % *r_stride) == 0) &&
+ ((r_local_cell[1] % *r_stride) == 0) &&
+ ((r_local_cell[2] % *r_stride) == 0))
+ {
+ if (!(((r_local_cell[0] % prev_stride) == 0) &&
+ ((r_local_cell[1] % prev_stride) == 0) &&
+ ((r_local_cell[2] % prev_stride) == 0)) ||
+ ((i == 0) && (lvl == max_lvl)))
+ {
+ if (visited_cells == cell_idx) {
+ return;
+ }
+ else {
+ visited_cells++;
+ }
+ }
+ }
+ }
+ }
+
+ BLI_assert(0);
+}
+
+static void grid_loc_to_world_loc(EEVEE_LightGrid *egrid, int local_cell[3], float r_pos[3])
+{
+ copy_v3_v3(r_pos, egrid->corner);
+ madd_v3_v3fl(r_pos, egrid->increment_x, local_cell[0]);
+ madd_v3_v3fl(r_pos, egrid->increment_y, local_cell[1]);
+ madd_v3_v3fl(r_pos, egrid->increment_z, local_cell[2]);
+}
+
+static void eevee_lightbake_render_grid_sample(void *ved, void *user_data)
+{
+ EEVEE_Data *vedata = (EEVEE_Data *)ved;
+ EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
+ EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
+ EEVEE_LightBake *lbake = (EEVEE_LightBake *)user_data;
+ EEVEE_LightGrid *egrid = lbake->grid;
+ LightProbe *prb = *lbake->probe;
+ Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph);
+ LightCache *lcache = scene_eval->eevee.light_cache;
+ int grid_loc[3], sample_id, sample_offset, stride;
+ float pos[3];
+ const bool is_last_bounce_sample = ((egrid->offset + lbake->grid_sample) == (lbake->total_irr_samples - 1));
+
+ /* No bias for rendering the probe. */
+ egrid->level_bias = 1.0f;
+
+ /* Use the previous bounce for rendering this bounce. */
+ SWAP(GPUTexture *, lbake->grid_prev, lcache->grid_tx.tex);
+
+ /* TODO do this once for the whole bake when we have independant DRWManagers.
+ * Warning: Some of the things above require this. */
+ eevee_lightbake_cache_create(vedata, lbake);
+
+ /* Compute sample position */
+ compute_cell_id(egrid, prb, lbake->grid_sample, &sample_id, grid_loc, &stride);
+ sample_offset = egrid->offset + sample_id;
+
+ grid_loc_to_world_loc(egrid, grid_loc, pos);
+
+ /* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */
+ common_data->spec_toggle = false;
+ common_data->prb_num_planar = 0;
+ common_data->prb_num_render_cube = 0;
+ if (lbake->bounce_curr == 0) {
+ common_data->prb_num_render_grid = 0;
+ }
+ DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+
+ EEVEE_lightbake_render_scene(sldata, vedata, lbake->rt_fb, pos, prb->clipsta, prb->clipend);
+
+ /* Restore before filtering. */
+ SWAP(GPUTexture *, lbake->grid_prev, lcache->grid_tx.tex);
+
+ EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake->rt_color, lbake->store_fb, sample_offset, prb->intensity);
+
+ if (lbake->bounce_curr == 0) {
+ /* We only need to filter the visibility for the first bounce. */
+ EEVEE_lightbake_filter_visibility(sldata, vedata, lbake->rt_depth, lbake->store_fb, sample_offset,
+ prb->clipsta, prb->clipend, egrid->visibility_range,
+ prb->vis_blur, lbake->vis_res);
+ }
+
+ /* Update level for progressive update. */
+ if (is_last_bounce_sample) {
+ egrid->level_bias = 1.0f;
+ }
+ else if (lbake->bounce_curr == 0) {
+ egrid->level_bias = (float)(stride << 1);
+ }
+
+ /* Only run this for the last sample of a bounce. */
+ if (is_last_bounce_sample) {
+ eevee_lightbake_copy_irradiance(lbake, lcache);
+ }
+
+ /* If it is the last sample grid sample (and last bounce). */
+ if ((lbake->bounce_curr == lbake->bounce_len - 1) &&
+ (lbake->grid_curr == lbake->grid_len - 1) &&
+ (lbake->grid_sample == lbake->grid_sample_len - 1))
+ {
+ lcache->flag &= ~LIGHTCACHE_UPDATE_GRID;
+ }
+}
+
+static void eevee_lightbake_render_probe_sample(void *ved, void *user_data)
+{
+ EEVEE_Data *vedata = (EEVEE_Data *)ved;
+ EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
+ EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
+ EEVEE_LightBake *lbake = (EEVEE_LightBake *)user_data;
+ Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph);
+ LightCache *lcache = scene_eval->eevee.light_cache;
+ EEVEE_LightProbe *eprobe = lbake->cube;
+ LightProbe *prb = *lbake->probe;
+
+ /* TODO do this once for the whole bake when we have independant DRWManagers. */
+ eevee_lightbake_cache_create(vedata, lbake);
+
+ /* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */
+ common_data->spec_toggle = false;
+ common_data->prb_num_planar = 0;
+ common_data->prb_num_render_cube = 0;
+ DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+
+ EEVEE_lightbake_render_scene(sldata, vedata, lbake->rt_fb, eprobe->position, prb->clipsta, prb->clipend);
+ EEVEE_lightbake_filter_glossy(sldata, vedata, lbake->rt_color, lbake->store_fb, lbake->cube_offset, prb->intensity, lcache->mips_len);
+
+ lcache->cube_len += 1;
+
+ /* If it's the last probe. */
+ if (lbake->cube_offset == lbake->cube_len - 1) {
+ lcache->flag &= ~LIGHTCACHE_UPDATE_CUBE;
+ }
+}
+
+static float eevee_lightbake_grid_influence_volume(EEVEE_LightGrid *grid)
+{
+ return mat4_to_scale(grid->mat);
+}
+
+static float eevee_lightbake_cube_influence_volume(EEVEE_LightProbe *eprb)
+{
+ return mat4_to_scale(eprb->attenuationmat);
+}
+
+static bool eevee_lightbake_grid_comp(EEVEE_LightGrid *grid_a, EEVEE_LightGrid *grid_b)
+{
+ float vol_a = eevee_lightbake_grid_influence_volume(grid_a);
+ float vol_b = eevee_lightbake_grid_influence_volume(grid_b);
+ return (vol_a < vol_b);
+}
+
+static bool eevee_lightbake_cube_comp(EEVEE_LightProbe *prb_a, EEVEE_LightProbe *prb_b)
+{
+ float vol_a = eevee_lightbake_cube_influence_volume(prb_a);
+ float vol_b = eevee_lightbake_cube_influence_volume(prb_b);
+ return (vol_a < vol_b);
+}
+
+#define SORT_PROBE(elems_type, prbs, elems, elems_len, comp_fn) \
+{ \
+ bool sorted = false; \
+ while (!sorted) { \
+ sorted = true; \
+ for (int i = 0; i < (elems_len) - 1; ++i) { \
+ if ((comp_fn)((elems) + i, (elems) + i+1)) { \
+ SWAP(elems_type, (elems)[i], (elems)[i+1]); \
+ SWAP(LightProbe *, (prbs)[i], (prbs)[i+1]); \
+ sorted = false; \
+ } \
+ } \
+ } \
+}
+
+static void eevee_lightbake_gather_probes(EEVEE_LightBake *lbake)
+{
+ Depsgraph *depsgraph = lbake->depsgraph;
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ LightCache *lcache = scene_eval->eevee.light_cache;
+
+ /* At least one for the world */
+ int grid_len = 1;
+ int cube_len = 1;
+ int total_irr_samples = 1;
+
+ /* Convert all lightprobes to tight UBO data from all lightprobes in the scene.
+ * This allows a large number of probe to be precomputed (even dupli ones). */
+ DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
+ {
+ if (!BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_FOR_RENDER)) {
+ continue;
+ }
+
+ if (ob->type == OB_LIGHTPROBE) {
+ LightProbe *prb = (LightProbe *)ob->data;
+
+ if (prb->type == LIGHTPROBE_TYPE_GRID) {
+ lbake->grid_prb[grid_len] = prb;
+ EEVEE_LightGrid *egrid = &lcache->grid_data[grid_len++];
+ EEVEE_lightprobes_grid_data_from_object(ob, egrid, &total_irr_samples);
+ }
+ else if (prb->type == LIGHTPROBE_TYPE_CUBE) {
+ lbake->cube_prb[cube_len] = prb;
+ EEVEE_LightProbe *eprobe = &lcache->cube_data[cube_len++];
+ EEVEE_lightprobes_cube_data_from_object(ob, eprobe);
+ }
+ }
+ }
+ DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
+
+ SORT_PROBE(EEVEE_LightGrid, lbake->grid_prb + 1, lcache->grid_data + 1, lbake->grid_len - 1, eevee_lightbake_grid_comp);
+ SORT_PROBE(EEVEE_LightProbe, lbake->cube_prb + 1, lcache->cube_data + 1, lbake->cube_len - 1, eevee_lightbake_cube_comp);
+
+ lbake->total = lbake->total_irr_samples * lbake->bounce_len + lbake->cube_len;
+ lbake->done = 0;
+}
+
+void EEVEE_lightbake_update(void *custom_data)
+{
+ EEVEE_LightBake *lbake = (EEVEE_LightBake *)custom_data;
+ Scene *scene_orig = lbake->scene;
+
+ /* If a new lightcache was created, free the old one and reference the new. */
+ if (lbake->lcache && scene_orig->eevee.light_cache != lbake->lcache) {
+ if (scene_orig->eevee.light_cache != NULL) {
+ EEVEE_lightcache_free(scene_orig->eevee.light_cache);
+ }
+ scene_orig->eevee.light_cache = lbake->lcache;
+ lbake->own_light_cache = false;
+ }
+
+ EEVEE_lightcache_info_update(&lbake->scene->eevee);
+
+ DEG_id_tag_update(&scene_orig->id, DEG_TAG_COPY_ON_WRITE);
+}
+
+static bool lightbake_do_sample(EEVEE_LightBake *lbake, void (*render_callback)(void *ved, void *user_data))
+{
+ if (G.is_break == true || *lbake->stop) {
+ return false;
+ }
+
+ Depsgraph *depsgraph = lbake->depsgraph;
+
+ /* TODO: make DRW manager instanciable (and only lock on drawing) */
+ eevee_lightbake_context_enable(lbake);
+ DRW_custom_pipeline(&draw_engine_eevee_type, depsgraph, render_callback, lbake);
+ lbake->done += 1;
+ *lbake->progress = lbake->done / (float)lbake->total;
+ *lbake->do_update = 1;
+ eevee_lightbake_context_disable(lbake);
+
+ return true;
+}
+
+void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float *progress)
+{
+ EEVEE_LightBake *lbake = (EEVEE_LightBake *)custom_data;
+ Depsgraph *depsgraph = lbake->depsgraph;
+ int frame = 0; /* TODO make it user param. */
+
+ DEG_graph_relations_update(depsgraph, lbake->bmain, lbake->scene, lbake->view_layer_input);
+ DEG_evaluate_on_framechange(lbake->bmain, depsgraph, frame);
+
+ lbake->view_layer = DEG_get_evaluated_view_layer(depsgraph);
+ lbake->stop = stop;
+ lbake->do_update = do_update;
+ lbake->progress = progress;
+
+ /* Count lightprobes */
+ eevee_lightbake_count_probes(lbake);
+
+ /* We need to create the FBOs in the right context.
+ * We cannot do it in the main thread. */
+ eevee_lightbake_context_enable(lbake);
+ eevee_lightbake_create_resources(lbake);
+ eevee_lightbake_create_render_target(lbake, lbake->rt_res);
+ eevee_lightbake_context_disable(lbake);
+
+ /* Gather all probes data */
+ eevee_lightbake_gather_probes(lbake);
+
+ LightCache *lcache = lbake->lcache;
+
+ /* HACK: Sleep to delay the first rendering operation
+ * that causes a small freeze (caused by VBO generation)
+ * because this step is locking at this moment. */
+ /* TODO remove this. */
+ if (lbake->delay) {
+ PIL_sleep_ms(lbake->delay);
+ }
+
+ /* Render world irradiance and reflection first */
+ if (lcache->flag & LIGHTCACHE_UPDATE_WORLD) {
+ lbake->probe = NULL;
+ lightbake_do_sample(lbake, eevee_lightbake_render_world_sample);
+ }
+
+ /* Render irradiance grids */
+ if (lcache->flag & LIGHTCACHE_UPDATE_GRID) {
+ for (lbake->bounce_curr = 0; lbake->bounce_curr < lbake->bounce_len; ++lbake->bounce_curr) {
+ /* Bypass world, start at 1. */
+ lbake->probe = lbake->grid_prb + 1;
+ lbake->grid = lcache->grid_data + 1;
+ for (lbake->grid_curr = 1;
+ lbake->grid_curr < lbake->grid_len;
+ ++lbake->grid_curr, ++lbake->probe, ++lbake->grid)
+ {
+ LightProbe *prb = *lbake->probe;
+ lbake->grid_sample_len = prb->grid_resolution_x *
+ prb->grid_resolution_y *
+ prb->grid_resolution_z;
+ for (lbake->grid_sample = 0;
+ lbake->grid_sample < lbake->grid_sample_len;
+ ++lbake->grid_sample)
+ {
+ lightbake_do_sample(lbake, eevee_lightbake_render_grid_sample);
+ }
+ }
+ }
+ }
+
+ /* Render reflections */
+ if (lcache->flag & LIGHTCACHE_UPDATE_CUBE) {
+ /* Bypass world, start at 1. */
+ lbake->probe = lbake->cube_prb + 1;
+ lbake->cube = lcache->cube_data + 1;
+ for (lbake->cube_offset = 1;
+ lbake->cube_offset < lbake->cube_len;
+ ++lbake->cube_offset, ++lbake->probe, ++lbake->cube)
+ {
+ lightbake_do_sample(lbake, eevee_lightbake_render_probe_sample);
+ }
+ }
+
+ /* Read the resulting lighting data to save it to file/disk. */
+ eevee_lightbake_context_enable(lbake);
+ eevee_lightbake_readback_irradiance(lcache);
+ eevee_lightbake_readback_reflections(lcache);
+ eevee_lightbake_context_disable(lbake);
+
+ lcache->flag |= LIGHTCACHE_BAKED;
+ lcache->flag &= ~LIGHTCACHE_BAKING;
+
+ /* Assume that if lbake->gl_context is NULL
+ * we are not running in this in a job, so update
+ * the scene lightcache pointer before deleting it. */
+ if (lbake->gl_context == NULL) {
+ BLI_assert(BLI_thread_is_main());
+ EEVEE_lightbake_update(lbake);
+ }
+
+ eevee_lightbake_delete_resources(lbake);
+}
+
+/* This is to update the world irradiance and reflection contribution from
+ * within the viewport drawing (does not have the overhead of a full light cache rebuild.) */
+void EEVEE_lightbake_update_world_quick(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, const Scene *scene)
+{
+ LightCache *lcache = vedata->stl->g_data->light_cache;
+
+ EEVEE_LightBake lbake = {
+ .resource_only = true
+ };
+
+ /* Create resources. */
+ eevee_lightbake_create_render_target(&lbake, scene->eevee.gi_cubemap_resolution);
+
+ EEVEE_lightbake_cache_init(sldata, vedata, lbake.rt_color, lbake.rt_depth);
+
+ EEVEE_lightbake_render_world(sldata, vedata, lbake.rt_fb);
+ EEVEE_lightbake_filter_glossy(sldata, vedata, lbake.rt_color, lbake.store_fb, 0, 1.0f, lcache->mips_len);
+ EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake.rt_color, lbake.store_fb, 0, 1.0f);
+
+ /* Don't hide grids if they are already rendered. */
+ lcache->grid_len = max_ii(1, lcache->grid_len);
+ lcache->cube_len = 1;
+
+ lcache->flag |= LIGHTCACHE_CUBE_READY | LIGHTCACHE_GRID_READY;
+ lcache->flag &= ~LIGHTCACHE_UPDATE_WORLD;
+
+ eevee_lightbake_delete_resources(&lbake);
+}
+
+/** \} */
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.h b/source/blender/draw/engines/eevee/eevee_lightcache.h
new file mode 100644
index 00000000000..b58a0544c59
--- /dev/null
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2018, 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(s): Blender Institute
+ *
+ */
+
+/** \file eevee_lightcache.h
+ * \ingroup eevee
+ */
+
+#ifndef __EEVEE_LIGHTCACHE_H__
+#define __EEVEE_LIGHTCACHE_H__
+
+#include "BLI_sys_types.h" /* for bool */
+
+struct ViewLayer;
+struct Scene;
+struct SceneEEVEE;
+struct LightCache;
+struct EEVEE_ViewLayerData;
+struct EEVEE_Data;
+struct EEVEE_LightBake;
+
+/* Light Bake */
+struct wmJob *EEVEE_lightbake_job_create(
+ struct wmWindowManager *wm, struct wmWindow *win, struct Main *bmain,
+ struct ViewLayer *view_layer, struct Scene *scene, int delay);
+void *EEVEE_lightbake_job_data_alloc(struct Main *bmain, struct ViewLayer *viewlayer, struct Scene *scene, bool run_as_job);
+void EEVEE_lightbake_job_data_free(void *custom_data);
+void EEVEE_lightbake_update(void *custom_data);
+void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float *progress);
+
+void EEVEE_lightbake_update_world_quick(struct EEVEE_ViewLayerData *sldata, struct EEVEE_Data *vedata, const Scene *scene);
+
+/* Light Cache */
+struct LightCache *EEVEE_lightcache_create(
+ const int grid_len, const int cube_len,
+ const int cube_size, const int vis_size,
+ const int irr_size[3]);
+void EEVEE_lightcache_free(struct LightCache *lcache);
+void EEVEE_lightcache_load(struct LightCache *lcache);
+void EEVEE_lightcache_info_update(struct SceneEEVEE *eevee);
+
+#endif /* __EEVEE_LIGHTCACHE_H__ */ \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index a45d69794f3..691d6ffe6eb 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -20,7 +20,7 @@
*/
/** \file eevee_lightprobes.c
- * \ingroup DNA
+ * \ingroup draw_engine
*/
#include "DRW_render.h"
@@ -46,27 +46,14 @@
#include "DEG_depsgraph_query.h"
#include "eevee_engine.h"
+#include "eevee_lightcache.h"
#include "eevee_private.h"
#include "ED_screen.h"
-/* Rounded to nearest PowerOfTwo */
-#if defined(IRRADIANCE_SH_L2)
-#define IRRADIANCE_SAMPLE_SIZE_X 4 /* 3 in reality */
-#define IRRADIANCE_SAMPLE_SIZE_Y 4 /* 3 in reality */
-#elif defined(IRRADIANCE_CUBEMAP)
-#define IRRADIANCE_SAMPLE_SIZE_X 8
-#define IRRADIANCE_SAMPLE_SIZE_Y 8
-#elif defined(IRRADIANCE_HL2)
-#define IRRADIANCE_SAMPLE_SIZE_X 4 /* 3 in reality */
-#define IRRADIANCE_SAMPLE_SIZE_Y 2
-#endif
+#include "WM_api.h"
+#include "WM_types.h"
-#define IRRADIANCE_MAX_POOL_LAYER 256 /* OpenGL 3.3 core requirement, can be extended but it's already very big */
-#define IRRADIANCE_MAX_POOL_SIZE 1024
-#define MAX_IRRADIANCE_SAMPLES \
- (IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_X) * \
- (IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_Y)
#define HAMMERSLEY_SIZE 1024
static struct {
@@ -87,8 +74,8 @@ static struct {
struct GPUTexture *depth_array_placeholder;
struct GPUTexture *cube_face_minmaxz;
- struct Gwn_VertFormat *format_probe_display_cube;
- struct Gwn_VertFormat *format_probe_display_planar;
+ struct GPUVertFormat *format_probe_display_cube;
+ struct GPUVertFormat *format_probe_display_planar;
} e_data = {NULL}; /* Engine data */
extern char datatoc_background_vert_glsl[];
@@ -120,19 +107,30 @@ extern GlobalsUboStorage ts;
/* *********** FUNCTIONS *********** */
-static void irradiance_pool_size_get(int visibility_size, int total_samples, int r_size[3])
+/* TODO find a better way than this. This does not support dupli objects if
+ * the original object is hidden. */
+bool EEVEE_lightprobes_obj_visibility_cb(bool vis_in, void *user_data)
{
- /* Compute how many irradiance samples we can store per visibility sample. */
- int irr_per_vis = (visibility_size / IRRADIANCE_SAMPLE_SIZE_X) *
- (visibility_size / IRRADIANCE_SAMPLE_SIZE_Y);
+ EEVEE_ObjectEngineData *oed = (EEVEE_ObjectEngineData *)user_data;
+
+ /* test disabled if group is NULL */
+ if (oed->test_data->collection == NULL)
+ return vis_in;
+
+ if (oed->test_data->cached == false)
+ oed->ob_vis_dirty = true;
+
+ /* early out, don't need to compute ob_vis yet. */
+ if (vis_in == false)
+ return vis_in;
- /* The irradiance itself take one layer, hence the +1 */
- int layer_ct = MIN2(irr_per_vis + 1, IRRADIANCE_MAX_POOL_LAYER);
+ if (oed->ob_vis_dirty) {
+ oed->ob_vis_dirty = false;
+ oed->ob_vis = BKE_collection_has_object_recursive(oed->test_data->collection, oed->ob);
+ oed->ob_vis = (oed->test_data->invert) ? !oed->ob_vis : oed->ob_vis;
+ }
- int texel_ct = (int)ceilf((float)total_samples / (float)(layer_ct - 1));
- r_size[0] = visibility_size * max_ii(1, min_ii(texel_ct, (IRRADIANCE_MAX_POOL_SIZE / visibility_size)));
- r_size[1] = visibility_size * max_ii(1, (texel_ct / (IRRADIANCE_MAX_POOL_SIZE / visibility_size)));
- r_size[2] = layer_ct;
+ return vis_in && oed->ob_vis;
}
static struct GPUTexture *create_hammersley_sample_texture(int samples)
@@ -156,11 +154,11 @@ static struct GPUTexture *create_hammersley_sample_texture(int samples)
static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref)
{
+ EEVEE_TextureList *txl = vedata->txl;
+
/* XXX TODO OPTIMISATION : This is a complete waist of texture memory.
* Instead of allocating each planar probe for each viewport,
* only alloc them once using the biggest viewport resolution. */
- EEVEE_TextureList *txl = vedata->txl;
-
const float *viewport_size = DRW_viewport_size_get();
/* TODO get screen percentage from layer setting */
@@ -275,7 +273,7 @@ static void lightprobe_shaders_init(void)
datatoc_common_view_lib_glsl,
datatoc_lightprobe_cube_display_vert_glsl);
- e_data.probe_cube_display_sh = DRW_shader_create(vert_str, NULL, shader_str, NULL);
+ e_data.probe_cube_display_sh = DRW_shader_create(vert_str, NULL, shader_str, SHADER_DEFINES);
MEM_freeN(vert_str);
MEM_freeN(shader_str);
@@ -302,86 +300,132 @@ static void lightprobe_shaders_init(void)
e_data.hammersley = create_hammersley_sample_texture(HAMMERSLEY_SIZE);
}
-void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *UNUSED(vedata))
+void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
- bool update_all = false;
+ EEVEE_StorageList *stl = vedata->stl;
+
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
- /* Shaders */
if (!e_data.probe_filter_glossy_sh) {
lightprobe_shaders_init();
}
+ if ((scene_eval->eevee.light_cache == NULL) &&
+ (sldata->fallback_lightcache == NULL))
+ {
+#if defined(IRRADIANCE_SH_L2)
+ int grid_res = 4;
+#elif defined(IRRADIANCE_CUBEMAP)
+ int grid_res = 8;
+#elif defined(IRRADIANCE_HL2)
+ int grid_res = 4;
+#endif
+ int cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(scene_eval->eevee.gi_cubemap_resolution);
+ int vis_res = scene_eval->eevee.gi_visibility_resolution;
+
+ sldata->fallback_lightcache = EEVEE_lightcache_create(1, 1, cube_res, vis_res, (int[3]){grid_res, grid_res, 1});
+ }
+
+ stl->g_data->light_cache = (scene_eval->eevee.light_cache) ? scene_eval->eevee.light_cache : sldata->fallback_lightcache;
+
+ EEVEE_lightcache_load(stl->g_data->light_cache);
+
if (!sldata->probes) {
sldata->probes = MEM_callocN(sizeof(EEVEE_LightProbesInfo), "EEVEE_LightProbesInfo");
- sldata->probes->grid_initialized = false;
sldata->probe_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightProbe) * MAX_PROBE, NULL);
sldata->grid_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightGrid) * MAX_GRID, NULL);
sldata->planar_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_PlanarReflection) * MAX_PLANAR, NULL);
}
- /* Only start doing probes if all materials have finished compiling. */
- sldata->probes->all_materials_updated = true;
+ common_data->prb_num_planar = 0;
+ common_data->prb_num_render_cube = 1;
+ common_data->prb_num_render_grid = 1;
common_data->spec_toggle = true;
common_data->ssr_toggle = true;
common_data->sss_toggle = true;
- int prop_bounce_num = scene_eval->eevee.gi_diffuse_bounces;
- if (sldata->probes->num_bounce != prop_bounce_num) {
- sldata->probes->num_bounce = prop_bounce_num;
- update_all = true;
+ /* Placeholder planar pool: used when rendering planar reflections (avoid dependency loop). */
+ if (!e_data.planar_pool_placeholder) {
+ e_data.planar_pool_placeholder = DRW_texture_create_2D_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER, NULL);
}
+}
- int prop_cubemap_res = scene_eval->eevee.gi_cubemap_resolution;
- if (sldata->probes->cubemap_res != prop_cubemap_res) {
- sldata->probes->cubemap_res = prop_cubemap_res;
- update_all = true;
+/* Only init the passes usefull for rendering the light cache. */
+void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, GPUTexture *rt_color, GPUTexture *rt_depth)
+{
+ EEVEE_PassList *psl = vedata->psl;
+ LightCache *light_cache = vedata->stl->g_data->light_cache;
+ EEVEE_LightProbesInfo *pinfo = sldata->probes;
- sldata->probes->target_size = prop_cubemap_res >> 1;
+ {
+ psl->probe_glossy_compute = DRW_pass_create("LightProbe Glossy Compute", DRW_STATE_WRITE_COLOR);
- DRW_TEXTURE_FREE_SAFE(sldata->probe_depth_rt);
- DRW_TEXTURE_FREE_SAFE(sldata->probe_rt);
- DRW_TEXTURE_FREE_SAFE(sldata->probe_pool);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_filter_glossy_sh, psl->probe_glossy_compute);
+ DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1);
+ DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_len, 1);
+ DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->samples_len_inv, 1);
+ DRW_shgroup_uniform_float(grp, "roughnessSquared", &pinfo->roughness, 1);
+ DRW_shgroup_uniform_float(grp, "lodFactor", &pinfo->lodfactor, 1);
+ DRW_shgroup_uniform_float(grp, "lodMax", &pinfo->lod_rt_max, 1);
+ DRW_shgroup_uniform_float(grp, "texelSize", &pinfo->texel_size, 1);
+ DRW_shgroup_uniform_float(grp, "paddingSize", &pinfo->padding_size, 1);
+ DRW_shgroup_uniform_int(grp, "Layer", &pinfo->layer, 1);
+ DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
+ // DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter);
+ DRW_shgroup_uniform_texture(grp, "probeHdr", rt_color);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
- const int visibility_res = scene_eval->eevee.gi_visibility_resolution;
- if (common_data->prb_irradiance_vis_size != visibility_res) {
- common_data->prb_irradiance_vis_size = visibility_res;
- update_all = true;
- }
+ {
+ psl->probe_diffuse_compute = DRW_pass_create("LightProbe Diffuse Compute", DRW_STATE_WRITE_COLOR);
- if (update_all) {
- sldata->probes->update_world |= PROBE_UPDATE_ALL;
- sldata->probes->updated_bounce = 0;
- sldata->probes->grid_initialized = false;
- }
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_filter_diffuse_sh, psl->probe_diffuse_compute);
+#ifdef IRRADIANCE_SH_L2
+ DRW_shgroup_uniform_int(grp, "probeSize", &pinfo->shres, 1);
+#else
+ DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_len, 1);
+ DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->samples_len_inv, 1);
+ DRW_shgroup_uniform_float(grp, "lodFactor", &pinfo->lodfactor, 1);
+ DRW_shgroup_uniform_float(grp, "lodMax", &pinfo->lod_rt_max, 1);
+ DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
+#endif
+ DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1);
+ DRW_shgroup_uniform_texture(grp, "probeHdr", rt_color);
- /* Setup Render Target Cubemap */
- if (!sldata->probe_rt) {
- sldata->probe_depth_rt = DRW_texture_create_cube(sldata->probes->target_size, GPU_DEPTH_COMPONENT24, 0, NULL);
- sldata->probe_rt = DRW_texture_create_cube(sldata->probes->target_size, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+ struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
+ DRW_shgroup_call_add(grp, geom, NULL);
}
- for (int i = 0; i < 6; ++i) {
- GPU_framebuffer_ensure_config(&sldata->probe_face_fb[i], {
- GPU_ATTACHMENT_TEXTURE_CUBEFACE(sldata->probe_depth_rt, i),
- GPU_ATTACHMENT_TEXTURE_CUBEFACE(sldata->probe_rt, i)
- });
- }
+ {
+ psl->probe_visibility_compute = DRW_pass_create("LightProbe Visibility Compute", DRW_STATE_WRITE_COLOR);
- /* Placeholder planar pool: used when rendering planar reflections (avoid dependency loop). */
- if (!e_data.planar_pool_placeholder) {
- e_data.planar_pool_placeholder = DRW_texture_create_2D_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER, NULL);
- }
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_filter_visibility_sh, psl->probe_visibility_compute);
+ DRW_shgroup_uniform_int(grp, "outputSize", &pinfo->shres, 1);
+ DRW_shgroup_uniform_float(grp, "visibilityRange", &pinfo->visibility_range, 1);
+ DRW_shgroup_uniform_float(grp, "visibilityBlur", &pinfo->visibility_blur, 1);
+ DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_len, 1);
+ DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->samples_len_inv, 1);
+ DRW_shgroup_uniform_float(grp, "storedTexelSize", &pinfo->texel_size, 1);
+ DRW_shgroup_uniform_float(grp, "nearClip", &pinfo->near_clip, 1);
+ DRW_shgroup_uniform_float(grp, "farClip", &pinfo->far_clip, 1);
+ DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
+ DRW_shgroup_uniform_texture(grp, "probeDepth", rt_depth);
- if (!e_data.depth_placeholder) {
- e_data.depth_placeholder = DRW_texture_create_2D(1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
+ struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
+ DRW_shgroup_call_add(grp, geom, NULL);
}
- if (!e_data.depth_array_placeholder) {
- e_data.depth_array_placeholder = DRW_texture_create_2D_array(1, 1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
+
+ {
+ psl->probe_grid_fill = DRW_pass_create("LightProbe Grid Floodfill", DRW_STATE_WRITE_COLOR);
+
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_grid_fill_sh, psl->probe_grid_fill);
+ DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &light_cache->grid_tx.tex);
+
+ struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
+ DRW_shgroup_call_add(grp, geom, NULL);
}
}
@@ -391,26 +435,21 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
EEVEE_PassList *psl = vedata->psl;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ LightCache *lcache = stl->g_data->light_cache;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
- /* Make sure no aditionnal visibility check runs by default. */
+ pinfo->num_planar = 0;
pinfo->vis_data.collection = NULL;
-
+ pinfo->do_grid_update = false;
pinfo->do_cube_update = false;
- pinfo->num_cube = 1; /* at least one for the world */
- pinfo->num_grid = 1;
- pinfo->num_planar = 0;
- pinfo->total_irradiance_samples = 1;
- memset(pinfo->probes_cube_ref, 0, sizeof(pinfo->probes_cube_ref));
- memset(pinfo->probes_grid_ref, 0, sizeof(pinfo->probes_grid_ref));
- memset(pinfo->probes_planar_ref, 0, sizeof(pinfo->probes_planar_ref));
{
psl->probe_background = DRW_pass_create("World Probe Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = NULL;
- const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
World *wo = scene->world;
@@ -421,11 +460,9 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
/* END */
if (!grp && wo) {
col = &wo->horr;
- bool wo_sh_compiled = true;
if (wo->use_nodes && wo->nodetree) {
static float error_col[3] = {1.0f, 0.0f, 1.0f};
- static float compile_col[3] = {0.5f, 0.5f, 0.5f};
struct GPUMaterial *gpumat = EEVEE_material_world_lightprobe_get(scene, wo);
GPUMaterialStatus status = GPU_material_status(gpumat);
@@ -435,35 +472,12 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
grp = DRW_shgroup_material_create(gpumat, psl->probe_background);
DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
DRW_shgroup_call_add(grp, geom, NULL);
- wo_sh_compiled = true;
break;
- case GPU_MAT_QUEUED:
- pinfo->all_materials_updated = false;
- wo_sh_compiled = false;
- /* TODO Bypass probe compilation. */
- col = compile_col;
- break;
- case GPU_MAT_FAILED:
default:
- wo_sh_compiled = true;
col = error_col;
break;
}
}
-
- if (wo->update_flag != 0 || pinfo->prev_world != wo || pinfo->prev_wo_sh_compiled != wo_sh_compiled) {
- pinfo->update_world |= PROBE_UPDATE_ALL;
- pinfo->studiolight_index = 0;
- pinfo->prev_wo_sh_compiled = wo_sh_compiled;
- pinfo->prev_world = wo;
- }
- wo->update_flag = 0;
- }
- else if (pinfo->prev_world) {
- pinfo->update_world |= PROBE_UPDATE_ALL;
- pinfo->studiolight_index = 0;
- pinfo->prev_wo_sh_compiled = false;
- pinfo->prev_world = NULL;
}
/* Fallback if shader fails or if not using nodetree. */
@@ -475,99 +489,48 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
}
}
- {
- psl->probe_glossy_compute = DRW_pass_create("LightProbe Glossy Compute", DRW_STATE_WRITE_COLOR);
-
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_filter_glossy_sh, psl->probe_glossy_compute);
- DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1);
- DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_ct, 1);
- DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->invsamples_ct, 1);
- DRW_shgroup_uniform_float(grp, "roughnessSquared", &pinfo->roughness, 1);
- DRW_shgroup_uniform_float(grp, "lodFactor", &pinfo->lodfactor, 1);
- DRW_shgroup_uniform_float(grp, "lodMax", &pinfo->lod_rt_max, 1);
- DRW_shgroup_uniform_float(grp, "texelSize", &pinfo->texel_size, 1);
- DRW_shgroup_uniform_float(grp, "paddingSize", &pinfo->padding_size, 1);
- DRW_shgroup_uniform_int(grp, "Layer", &pinfo->layer, 1);
- DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
- // DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter);
- DRW_shgroup_uniform_texture(grp, "probeHdr", sldata->probe_rt);
- DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
- }
-
- {
- psl->probe_diffuse_compute = DRW_pass_create("LightProbe Diffuse Compute", DRW_STATE_WRITE_COLOR);
-
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_filter_diffuse_sh, psl->probe_diffuse_compute);
-#ifdef IRRADIANCE_SH_L2
- DRW_shgroup_uniform_int(grp, "probeSize", &pinfo->shres, 1);
-#else
- DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_ct, 1);
- DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->invsamples_ct, 1);
- DRW_shgroup_uniform_float(grp, "lodFactor", &pinfo->lodfactor, 1);
- DRW_shgroup_uniform_float(grp, "lodMax", &pinfo->lod_rt_max, 1);
- DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
-#endif
- DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1);
- DRW_shgroup_uniform_texture(grp, "probeHdr", sldata->probe_rt);
-
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
- DRW_shgroup_call_add(grp, geom, NULL);
- }
-
- {
- psl->probe_visibility_compute = DRW_pass_create("LightProbe Visibility Compute", DRW_STATE_WRITE_COLOR);
-
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_filter_visibility_sh, psl->probe_visibility_compute);
- DRW_shgroup_uniform_int(grp, "outputSize", &pinfo->shres, 1);
- DRW_shgroup_uniform_float(grp, "visibilityRange", &pinfo->visibility_range, 1);
- DRW_shgroup_uniform_float(grp, "visibilityBlur", &pinfo->visibility_blur, 1);
- DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_ct, 1);
- DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->invsamples_ct, 1);
- DRW_shgroup_uniform_float(grp, "storedTexelSize", &pinfo->texel_size, 1);
- DRW_shgroup_uniform_float(grp, "nearClip", &pinfo->near_clip, 1);
- DRW_shgroup_uniform_float(grp, "farClip", &pinfo->far_clip, 1);
- DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
- DRW_shgroup_uniform_texture(grp, "probeDepth", sldata->probe_depth_rt);
-
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
- DRW_shgroup_call_add(grp, geom, NULL);
- }
-
- {
- psl->probe_grid_fill = DRW_pass_create("LightProbe Grid Floodfill", DRW_STATE_WRITE_COLOR);
-
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_grid_fill_sh, psl->probe_grid_fill);
- DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &sldata->irradiance_pool);
-
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
- DRW_shgroup_call_add(grp, geom, NULL);
- }
-
- {
+ if (DRW_state_draw_support()) {
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK;
psl->probe_display = DRW_pass_create("LightProbe Display", state);
- DRW_shgroup_instance_format(e_data.format_probe_display_cube, {
- {"probe_id", DRW_ATTRIB_INT, 1},
- {"probe_location", DRW_ATTRIB_FLOAT, 3},
- {"sphere_size", DRW_ATTRIB_FLOAT, 1},
- });
+ /* Cube Display */
+ if (scene_eval->eevee.flag & SCE_EEVEE_SHOW_CUBEMAPS && lcache->cube_len > 1) {
+ int cube_len = lcache->cube_len - 1; /* don't count the world. */
+ DRWShadingGroup *grp = DRW_shgroup_empty_tri_batch_create(e_data.probe_cube_display_sh,
+ psl->probe_display, cube_len * 2);
+ DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &lcache->cube_tx.tex);
+ DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
+ DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
+ DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
+ DRW_shgroup_uniform_float_copy(grp, "sphere_size", scene_eval->eevee.gi_cubemap_draw_size * 0.5f);
+ }
- DRWShadingGroup *grp = DRW_shgroup_instance_create(
- e_data.probe_cube_display_sh,
- psl->probe_display,
- DRW_cache_sphere_get(),
- e_data.format_probe_display_cube);
- stl->g_data->cube_display_shgrp = grp;
- DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &sldata->probe_pool);
- DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
+ /* Grid Display */
+ if (scene_eval->eevee.flag & SCE_EEVEE_SHOW_IRRADIANCE) {
+ EEVEE_LightGrid *egrid = lcache->grid_data + 1;
+ for (int p = 1; p < lcache->grid_len; ++p, egrid++) {
+ DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.probe_grid_display_sh, psl->probe_display);
+ DRW_shgroup_uniform_int(shgrp, "offset", &egrid->offset, 1);
+ DRW_shgroup_uniform_ivec3(shgrp, "grid_resolution", egrid->resolution, 1);
+ DRW_shgroup_uniform_vec3(shgrp, "corner", egrid->corner, 1);
+ DRW_shgroup_uniform_vec3(shgrp, "increment_x", egrid->increment_x, 1);
+ DRW_shgroup_uniform_vec3(shgrp, "increment_y", egrid->increment_y, 1);
+ DRW_shgroup_uniform_vec3(shgrp, "increment_z", egrid->increment_z, 1);
+ DRW_shgroup_uniform_vec3(shgrp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
+ DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &lcache->grid_tx.tex);
+ DRW_shgroup_uniform_float_copy(shgrp, "sphere_size", scene_eval->eevee.gi_irradiance_draw_size * 0.5f);
+ int tri_count = egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2] * 2;
+ DRW_shgroup_call_procedural_triangles_add(shgrp, tri_count, NULL);
+ }
+ }
+ /* Planar Display */
DRW_shgroup_instance_format(e_data.format_probe_display_planar, {
{"probe_id", DRW_ATTRIB_INT, 1},
{"probe_mat", DRW_ATTRIB_FLOAT, 16},
});
- grp = DRW_shgroup_instance_create(
+ DRWShadingGroup *grp = DRW_shgroup_instance_create(
e_data.probe_planar_display_sh,
psl->probe_display,
DRW_cache_quad_get(),
@@ -575,6 +538,9 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
stl->g_data->planar_display_shgrp = grp;
DRW_shgroup_uniform_texture_ref(grp, "probePlanars", &txl->planar_pool);
}
+ else {
+ stl->g_data->planar_display_shgrp = NULL;
+ }
{
psl->probe_planar_downsample_ps = DRW_pass_create("LightProbe Planar Downsample", DRW_STATE_WRITE_COLOR);
@@ -586,809 +552,484 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
}
}
-bool EEVEE_lightprobes_obj_visibility_cb(bool vis_in, void *user_data)
+static bool eevee_lightprobes_culling_test(Object *ob)
{
- EEVEE_ObjectEngineData *oed = (EEVEE_ObjectEngineData *)user_data;
-
- /* test disabled if group is NULL */
- if (oed->test_data->collection == NULL)
- return vis_in;
-
- if (oed->test_data->cached == false)
- oed->ob_vis_dirty = true;
-
- /* early out, don't need to compute ob_vis yet. */
- if (vis_in == false)
- return vis_in;
+ LightProbe *probe = (LightProbe *)ob->data;
- if (oed->ob_vis_dirty) {
- oed->ob_vis_dirty = false;
- oed->ob_vis = BKE_collection_has_object_recursive(oed->test_data->collection, oed->ob);
- oed->ob_vis = (oed->test_data->invert) ? !oed->ob_vis : oed->ob_vis;
+ switch (probe->type) {
+ case LIGHTPROBE_TYPE_PLANAR:
+ {
+ /* See if this planar probe is inside the view frustum. If not, no need to update it. */
+ /* NOTE: this could be bypassed if we want feedback loop mirrors for rendering. */
+ BoundBox bbox; float tmp[4][4];
+ const float min[3] = {-1.0f, -1.0f, -1.0f};
+ const float max[3] = { 1.0f, 1.0f, 1.0f};
+ BKE_boundbox_init_from_minmax(&bbox, min, max);
+
+ copy_m4_m4(tmp, ob->obmat);
+ normalize_v3(tmp[2]);
+ mul_v3_fl(tmp[2], probe->distinf);
+
+ for (int v = 0; v < 8; ++v) {
+ mul_m4_v3(tmp, bbox.vec[v]);
+ }
+ return DRW_culling_box_test(&bbox);
+ }
+ case LIGHTPROBE_TYPE_CUBE:
+ return true; /* TODO */
+ case LIGHTPROBE_TYPE_GRID:
+ return true; /* TODO */
}
-
- return vis_in && oed->ob_vis;
+ BLI_assert(0);
+ return true;
}
-void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, Object *ob)
+void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *ob)
{
EEVEE_LightProbesInfo *pinfo = sldata->probes;
LightProbe *probe = (LightProbe *)ob->data;
if ((probe->type == LIGHTPROBE_TYPE_CUBE && pinfo->num_cube >= MAX_PROBE) ||
(probe->type == LIGHTPROBE_TYPE_GRID && pinfo->num_grid >= MAX_PROBE) ||
- (probe->type == LIGHTPROBE_TYPE_PLANAR && pinfo->num_grid >= MAX_PLANAR))
+ (probe->type == LIGHTPROBE_TYPE_PLANAR && pinfo->num_planar >= MAX_PLANAR))
{
- printf("Too much probes in the scene !!!\n");
+ printf("Too many probes in the view !!!\n");
return;
}
if (probe->type == LIGHTPROBE_TYPE_PLANAR) {
- /* See if this planar probe is inside the view frustum. If not, no need to update it. */
- /* NOTE: this could be bypassed if we want feedback loop mirrors for rendering. */
- BoundBox bbox; float tmp[4][4];
- const float min[3] = {-1.0f, -1.0f, -1.0f};
- const float max[3] = { 1.0f, 1.0f, 1.0f};
- BKE_boundbox_init_from_minmax(&bbox, min, max);
-
- copy_m4_m4(tmp, ob->obmat);
- normalize_v3(tmp[2]);
- mul_v3_fl(tmp[2], probe->distinf);
-
- for (int v = 0; v < 8; ++v) {
- mul_m4_v3(tmp, bbox.vec[v]);
- }
- if (!DRW_culling_box_test(&bbox)) {
+ if (!eevee_lightprobes_culling_test(ob)) {
return; /* Culled */
}
- }
-
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
-
- ped->num_cell = probe->grid_resolution_x * probe->grid_resolution_y * probe->grid_resolution_z;
-
- if ((probe->type == LIGHTPROBE_TYPE_GRID) &&
- ((pinfo->total_irradiance_samples + ped->num_cell) >= MAX_IRRADIANCE_SAMPLES))
- {
- printf("Too much grid samples !!!\n");
- return;
- }
-
- if (ped->need_full_update) {
- ped->need_full_update = false;
-
- ped->need_update = true;
- ped->probe_id = 0;
- if (probe->type == LIGHTPROBE_TYPE_GRID) {
- ped->updated_cells = 0;
- ped->updated_lvl = 0;
- pinfo->updated_bounce = 0;
- pinfo->grid_initialized = false;
+ EEVEE_lightprobes_planar_data_from_object(ob,
+ &pinfo->planar_data[pinfo->num_planar],
+ &pinfo->planar_vis_tests[pinfo->num_planar]);
+ /* Debug Display */
+ DRWShadingGroup *grp = vedata->stl->g_data->planar_display_shgrp;
+ if (grp && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
+ DRW_shgroup_call_dynamic_add(grp, &pinfo->num_planar, ob->obmat);
}
- }
- if (pinfo->update_world) {
- ped->need_update = true;
- ped->updated_cells = 0;
- ped->updated_lvl = 0;
- ped->probe_id = 0;
+ pinfo->num_planar++;
}
-
- pinfo->do_cube_update |= ped->need_update;
-
- switch (probe->type) {
- case LIGHTPROBE_TYPE_CUBE:
- pinfo->probes_cube_ref[pinfo->num_cube] = ob;
- pinfo->num_cube++;
- break;
- case LIGHTPROBE_TYPE_PLANAR:
- pinfo->probes_planar_ref[pinfo->num_planar] = ob;
- pinfo->num_planar++;
- break;
- case LIGHTPROBE_TYPE_GRID:
- pinfo->probes_grid_ref[pinfo->num_grid] = ob;
- pinfo->num_grid++;
- pinfo->total_irradiance_samples += ped->num_cell;
- break;
- }
-}
-
-/* TODO find a nice name to push it to math_matrix.c */
-static void scale_m4_v3(float R[4][4], float v[3])
-{
- for (int i = 0; i < 4; ++i)
- mul_v3_v3(R[i], v);
-}
-
-static void EEVEE_planar_reflections_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl)
-{
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
- Object *ob;
-
- for (int i = 0; (ob = pinfo->probes_planar_ref[i]) && (i < MAX_PLANAR); i++) {
- LightProbe *probe = (LightProbe *)ob->data;
+ else {
EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
-
- ped->probe_id = i;
-
- /* Debug Display */
- if (DRW_state_draw_support() &&
- (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
- {
- DRW_shgroup_call_dynamic_add(stl->g_data->planar_display_shgrp, &ped->probe_id, ob->obmat);
+ if (ped->need_update) {
+ if (probe->type == LIGHTPROBE_TYPE_GRID) {
+ pinfo->do_grid_update = true;
+ }
+ else {
+ pinfo->do_cube_update = true;
+ }
+ ped->need_update = false;
}
}
}
-static void EEVEE_planar_reflections_updates(EEVEE_ViewLayerData *sldata)
+void EEVEE_lightprobes_grid_data_from_object(Object *ob, EEVEE_LightGrid *egrid, int *offset)
{
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
- Object *ob;
- float mtx[4][4], normat[4][4], imat[4][4], rangemat[4][4];
-
- float viewmat[4][4];
- DRW_viewport_matrix_get(viewmat, DRW_MAT_VIEW);
-
- zero_m4(rangemat);
- rangemat[0][0] = rangemat[1][1] = rangemat[2][2] = 0.5f;
- rangemat[3][0] = rangemat[3][1] = rangemat[3][2] = 0.5f;
- rangemat[3][3] = 1.0f;
+ LightProbe *probe = (LightProbe *)ob->data;
- /* PLANAR REFLECTION */
- for (int i = 0; (ob = pinfo->probes_planar_ref[i]) && (i < MAX_PLANAR); i++) {
- LightProbe *probe = (LightProbe *)ob->data;
- EEVEE_PlanarReflection *eplanar = &pinfo->planar_data[i];
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
- /* Computing mtx : matrix that mirror position around object's XY plane. */
- normalize_m4_m4(normat, ob->obmat); /* object > world */
- invert_m4_m4(imat, normat); /* world > object */
- float reflect[3] = {1.0f, 1.0f, -1.0f}; /* XY reflection plane */
- scale_m4_v3(imat, reflect); /* world > object > mirrored obj */
- mul_m4_m4m4(mtx, normat, imat); /* world > object > mirrored obj > world */
- /* Reflect Camera Matrix. */
- mul_m4_m4m4(ped->mats.mat[DRW_MAT_VIEW], viewmat, mtx);
- /* TODO FOV margin */
- /* Temporal sampling jitter should be already applied to the DRW_MAT_WIN. */
- DRW_viewport_matrix_get(ped->mats.mat[DRW_MAT_WIN], DRW_MAT_WIN);
- /* Apply Projection Matrix. */
- mul_m4_m4m4(ped->mats.mat[DRW_MAT_PERS], ped->mats.mat[DRW_MAT_WIN], ped->mats.mat[DRW_MAT_VIEW]);
- /* This is the matrix used to reconstruct texture coordinates.
- * We use the original view matrix because it does not create
- * visual artifacts if receiver is not perfectly aligned with
- * the planar reflection probe. */
- mul_m4_m4m4(eplanar->reflectionmat, ped->mats.mat[DRW_MAT_WIN], viewmat); /* TODO FOV margin */
- /* Convert from [-1, 1] to [0, 1] (NDC to Texture coord). */
- mul_m4_m4m4(eplanar->reflectionmat, rangemat, eplanar->reflectionmat);
-
- /* Compute clip plane equation / normal. */
- float refpoint[3];
- copy_v3_v3(eplanar->plane_equation, ob->obmat[2]);
- normalize_v3(eplanar->plane_equation); /* plane normal */
- eplanar->plane_equation[3] = -dot_v3v3(eplanar->plane_equation, ob->obmat[3]);
-
- /* Compute offset plane equation (fix missing texels near reflection plane). */
- copy_v3_v3(ped->planer_eq_offset, eplanar->plane_equation);
- mul_v3_v3fl(refpoint, eplanar->plane_equation, -probe->clipsta);
- add_v3_v3(refpoint, ob->obmat[3]);
- ped->planer_eq_offset[3] = -dot_v3v3(eplanar->plane_equation, refpoint);
-
- /* Compute XY clip planes. */
- normalize_v3_v3(eplanar->clip_vec_x, ob->obmat[0]);
- normalize_v3_v3(eplanar->clip_vec_y, ob->obmat[1]);
-
- float vec[3] = {0.0f, 0.0f, 0.0f};
- vec[0] = 1.0f; vec[1] = 0.0f; vec[2] = 0.0f;
- mul_m4_v3(ob->obmat, vec); /* Point on the edge */
- eplanar->clip_edge_x_pos = dot_v3v3(eplanar->clip_vec_x, vec);
-
- vec[0] = 0.0f; vec[1] = 1.0f; vec[2] = 0.0f;
- mul_m4_v3(ob->obmat, vec); /* Point on the edge */
- eplanar->clip_edge_y_pos = dot_v3v3(eplanar->clip_vec_y, vec);
-
- vec[0] = -1.0f; vec[1] = 0.0f; vec[2] = 0.0f;
- mul_m4_v3(ob->obmat, vec); /* Point on the edge */
- eplanar->clip_edge_x_neg = dot_v3v3(eplanar->clip_vec_x, vec);
-
- vec[0] = 0.0f; vec[1] = -1.0f; vec[2] = 0.0f;
- mul_m4_v3(ob->obmat, vec); /* Point on the edge */
- eplanar->clip_edge_y_neg = dot_v3v3(eplanar->clip_vec_y, vec);
-
- /* Facing factors */
- float max_angle = max_ff(1e-2f, probe->falloff) * M_PI * 0.5f;
- float min_angle = 0.0f;
- eplanar->facing_scale = 1.0f / max_ff(1e-8f, cosf(min_angle) - cosf(max_angle));
- eplanar->facing_bias = -min_ff(1.0f - 1e-8f, cosf(max_angle)) * eplanar->facing_scale;
-
- /* Distance factors */
- float max_dist = probe->distinf;
- float min_dist = min_ff(1.0f - 1e-8f, 1.0f - probe->falloff) * probe->distinf;
- eplanar->attenuation_scale = -1.0f / max_ff(1e-8f, max_dist - min_dist);
- eplanar->attenuation_bias = max_dist * -eplanar->attenuation_scale;
- }
+ copy_v3_v3_int(egrid->resolution, &probe->grid_resolution_x);
+
+ /* Save current offset and advance it for the next grid. */
+ egrid->offset = *offset;
+ *offset += egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2];
+
+ /* Add one for level 0 */
+ float fac = 1.0f / max_ff(1e-8f, probe->falloff);
+ egrid->attenuation_scale = fac / max_ff(1e-8f, probe->distinf);
+ egrid->attenuation_bias = fac;
+
+ /* Update transforms */
+ float cell_dim[3], half_cell_dim[3];
+ cell_dim[0] = 2.0f / egrid->resolution[0];
+ cell_dim[1] = 2.0f / egrid->resolution[1];
+ cell_dim[2] = 2.0f / egrid->resolution[2];
+
+ mul_v3_v3fl(half_cell_dim, cell_dim, 0.5f);
+
+ /* Matrix converting world space to cell ranges. */
+ invert_m4_m4(egrid->mat, ob->obmat);
+
+ /* First cell. */
+ copy_v3_fl(egrid->corner, -1.0f);
+ add_v3_v3(egrid->corner, half_cell_dim);
+ mul_m4_v3(ob->obmat, egrid->corner);
+
+ /* Opposite neighbor cell. */
+ copy_v3_fl3(egrid->increment_x, cell_dim[0], 0.0f, 0.0f);
+ add_v3_v3(egrid->increment_x, half_cell_dim);
+ add_v3_fl(egrid->increment_x, -1.0f);
+ mul_m4_v3(ob->obmat, egrid->increment_x);
+ sub_v3_v3(egrid->increment_x, egrid->corner);
+
+ copy_v3_fl3(egrid->increment_y, 0.0f, cell_dim[1], 0.0f);
+ add_v3_v3(egrid->increment_y, half_cell_dim);
+ add_v3_fl(egrid->increment_y, -1.0f);
+ mul_m4_v3(ob->obmat, egrid->increment_y);
+ sub_v3_v3(egrid->increment_y, egrid->corner);
+
+ copy_v3_fl3(egrid->increment_z, 0.0f, 0.0f, cell_dim[2]);
+ add_v3_v3(egrid->increment_z, half_cell_dim);
+ add_v3_fl(egrid->increment_z, -1.0f);
+ mul_m4_v3(ob->obmat, egrid->increment_z);
+ sub_v3_v3(egrid->increment_z, egrid->corner);
+
+ /* Visibility bias */
+ egrid->visibility_bias = 0.05f * probe->vis_bias;
+ egrid->visibility_bleed = probe->vis_bleedbias;
+ egrid->visibility_range = 1.0f + sqrtf(max_fff(len_squared_v3(egrid->increment_x),
+ len_squared_v3(egrid->increment_y),
+ len_squared_v3(egrid->increment_z)));
}
-static void EEVEE_lightprobes_updates(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl, EEVEE_StorageList *stl)
+void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *eprobe)
{
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
- Object *ob;
-
- /* CUBE REFLECTION */
- for (int i = 1; (ob = pinfo->probes_cube_ref[i]) && (i < MAX_PROBE); i++) {
- LightProbe *probe = (LightProbe *)ob->data;
- EEVEE_LightProbe *eprobe = &pinfo->probe_data[i];
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
+ LightProbe *probe = (LightProbe *)ob->data;
- /* Update transforms */
- copy_v3_v3(eprobe->position, ob->obmat[3]);
+ /* Update transforms */
+ copy_v3_v3(eprobe->position, ob->obmat[3]);
- /* Attenuation */
- eprobe->attenuation_type = probe->attenuation_type;
- eprobe->attenuation_fac = 1.0f / max_ff(1e-8f, probe->falloff);
+ /* Attenuation */
+ eprobe->attenuation_type = probe->attenuation_type;
+ eprobe->attenuation_fac = 1.0f / max_ff(1e-8f, probe->falloff);
- unit_m4(eprobe->attenuationmat);
- scale_m4_fl(eprobe->attenuationmat, probe->distinf);
- mul_m4_m4m4(eprobe->attenuationmat, ob->obmat, eprobe->attenuationmat);
- invert_m4(eprobe->attenuationmat);
+ unit_m4(eprobe->attenuationmat);
+ scale_m4_fl(eprobe->attenuationmat, probe->distinf);
+ mul_m4_m4m4(eprobe->attenuationmat, ob->obmat, eprobe->attenuationmat);
+ invert_m4(eprobe->attenuationmat);
- /* Parallax */
- float dist;
- if ((probe->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) {
- eprobe->parallax_type = probe->parallax_type;
- dist = probe->distpar;
- }
- else {
- eprobe->parallax_type = probe->attenuation_type;
- dist = probe->distinf;
- }
+ /* Parallax */
+ unit_m4(eprobe->parallaxmat);
- unit_m4(eprobe->parallaxmat);
- scale_m4_fl(eprobe->parallaxmat, dist);
- mul_m4_m4m4(eprobe->parallaxmat, ob->obmat, eprobe->parallaxmat);
- invert_m4(eprobe->parallaxmat);
-
- /* Debug Display */
- if (DRW_state_draw_support() &&
- (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
- {
- ped->probe_size = probe->data_draw_size * 0.1f;
- DRW_shgroup_call_dynamic_add(
- stl->g_data->cube_display_shgrp, &ped->probe_id, ob->obmat[3], &ped->probe_size);
- }
+ if ((probe->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) {
+ eprobe->parallax_type = probe->parallax_type;
+ scale_m4_fl(eprobe->parallaxmat, probe->distpar);
+ }
+ else {
+ eprobe->parallax_type = probe->attenuation_type;
+ scale_m4_fl(eprobe->parallaxmat, probe->distinf);
}
- /* IRRADIANCE GRID */
- int offset = 1; /* to account for the world probe */
- for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) {
- LightProbe *probe = (LightProbe *)ob->data;
- EEVEE_LightGrid *egrid = &pinfo->grid_data[i];
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
+ mul_m4_m4m4(eprobe->parallaxmat, ob->obmat, eprobe->parallaxmat);
+ invert_m4(eprobe->parallaxmat);
+}
- /* If one grid has move we need to recompute all the lighting. */
- if (!pinfo->grid_initialized) {
- ped->updated_cells = 0;
- ped->updated_lvl = 0;
- ped->need_update = true;
- }
+void EEVEE_lightprobes_planar_data_from_object(Object *ob, EEVEE_PlanarReflection *eplanar, EEVEE_LightProbeVisTest *vis_test)
+{
+ LightProbe *probe = (LightProbe *)ob->data;
+ float normat[4][4], imat[4][4];
+
+ vis_test->collection = probe->visibility_grp;
+ vis_test->invert = probe->flag & LIGHTPROBE_FLAG_INVERT_GROUP;
+ vis_test->cached = false;
+
+ /* Computing mtx : matrix that mirror position around object's XY plane. */
+ normalize_m4_m4(normat, ob->obmat); /* object > world */
+ invert_m4_m4(imat, normat); /* world > object */
+ /* XY reflection plane */
+ imat[0][2] = -imat[0][2];
+ imat[1][2] = -imat[1][2];
+ imat[2][2] = -imat[2][2];
+ imat[3][2] = -imat[3][2]; /* world > object > mirrored obj */
+ mul_m4_m4m4(eplanar->mtx, normat, imat); /* world > object > mirrored obj > world */
+
+ /* Compute clip plane equation / normal. */
+ copy_v3_v3(eplanar->plane_equation, ob->obmat[2]);
+ normalize_v3(eplanar->plane_equation); /* plane normal */
+ eplanar->plane_equation[3] = -dot_v3v3(eplanar->plane_equation, ob->obmat[3]);
+ eplanar->clipsta = probe->clipsta;
+
+ /* Compute XY clip planes. */
+ normalize_v3_v3(eplanar->clip_vec_x, ob->obmat[0]);
+ normalize_v3_v3(eplanar->clip_vec_y, ob->obmat[1]);
+
+ float vec[3] = {0.0f, 0.0f, 0.0f};
+ vec[0] = 1.0f; vec[1] = 0.0f; vec[2] = 0.0f;
+ mul_m4_v3(ob->obmat, vec); /* Point on the edge */
+ eplanar->clip_edge_x_pos = dot_v3v3(eplanar->clip_vec_x, vec);
+
+ vec[0] = 0.0f; vec[1] = 1.0f; vec[2] = 0.0f;
+ mul_m4_v3(ob->obmat, vec); /* Point on the edge */
+ eplanar->clip_edge_y_pos = dot_v3v3(eplanar->clip_vec_y, vec);
+
+ vec[0] = -1.0f; vec[1] = 0.0f; vec[2] = 0.0f;
+ mul_m4_v3(ob->obmat, vec); /* Point on the edge */
+ eplanar->clip_edge_x_neg = dot_v3v3(eplanar->clip_vec_x, vec);
+
+ vec[0] = 0.0f; vec[1] = -1.0f; vec[2] = 0.0f;
+ mul_m4_v3(ob->obmat, vec); /* Point on the edge */
+ eplanar->clip_edge_y_neg = dot_v3v3(eplanar->clip_vec_y, vec);
+
+ /* Facing factors */
+ float max_angle = max_ff(1e-2f, probe->falloff) * M_PI * 0.5f;
+ float min_angle = 0.0f;
+ eplanar->facing_scale = 1.0f / max_ff(1e-8f, cosf(min_angle) - cosf(max_angle));
+ eplanar->facing_bias = -min_ff(1.0f - 1e-8f, cosf(max_angle)) * eplanar->facing_scale;
+
+ /* Distance factors */
+ float max_dist = probe->distinf;
+ float min_dist = min_ff(1.0f - 1e-8f, 1.0f - probe->falloff) * probe->distinf;
+ eplanar->attenuation_scale = -1.0f / max_ff(1e-8f, max_dist - min_dist);
+ eplanar->attenuation_bias = max_dist * -eplanar->attenuation_scale;
+}
- /* Add one for level 0 */
- ped->max_lvl = 1.0f + floorf(log2f((float)MAX3(probe->grid_resolution_x,
- probe->grid_resolution_y,
- probe->grid_resolution_z)));
-
- egrid->offset = offset;
- float fac = 1.0f / max_ff(1e-8f, probe->falloff);
- egrid->attenuation_scale = fac / max_ff(1e-8f, probe->distinf);
- egrid->attenuation_bias = fac;
-
- /* Set offset for the next grid */
- offset += ped->num_cell;
-
- /* Update transforms */
- float cell_dim[3], half_cell_dim[3];
- cell_dim[0] = 2.0f / (float)(probe->grid_resolution_x);
- cell_dim[1] = 2.0f / (float)(probe->grid_resolution_y);
- cell_dim[2] = 2.0f / (float)(probe->grid_resolution_z);
-
- mul_v3_v3fl(half_cell_dim, cell_dim, 0.5f);
-
- /* Matrix converting world space to cell ranges. */
- invert_m4_m4(egrid->mat, ob->obmat);
-
- /* First cell. */
- copy_v3_fl(egrid->corner, -1.0f);
- add_v3_v3(egrid->corner, half_cell_dim);
- mul_m4_v3(ob->obmat, egrid->corner);
-
- /* Opposite neighbor cell. */
- copy_v3_fl3(egrid->increment_x, cell_dim[0], 0.0f, 0.0f);
- add_v3_v3(egrid->increment_x, half_cell_dim);
- add_v3_fl(egrid->increment_x, -1.0f);
- mul_m4_v3(ob->obmat, egrid->increment_x);
- sub_v3_v3(egrid->increment_x, egrid->corner);
-
- copy_v3_fl3(egrid->increment_y, 0.0f, cell_dim[1], 0.0f);
- add_v3_v3(egrid->increment_y, half_cell_dim);
- add_v3_fl(egrid->increment_y, -1.0f);
- mul_m4_v3(ob->obmat, egrid->increment_y);
- sub_v3_v3(egrid->increment_y, egrid->corner);
-
- copy_v3_fl3(egrid->increment_z, 0.0f, 0.0f, cell_dim[2]);
- add_v3_v3(egrid->increment_z, half_cell_dim);
- add_v3_fl(egrid->increment_z, -1.0f);
- mul_m4_v3(ob->obmat, egrid->increment_z);
- sub_v3_v3(egrid->increment_z, egrid->corner);
-
- copy_v3_v3_int(egrid->resolution, &probe->grid_resolution_x);
-
- /* Visibility bias */
- egrid->visibility_bias = 0.05f * probe->vis_bias;
- egrid->visibility_bleed = probe->vis_bleedbias;
- egrid->visibility_range = (
- sqrtf(max_fff(len_squared_v3(egrid->increment_x),
- len_squared_v3(egrid->increment_y),
- len_squared_v3(egrid->increment_z))) + 1.0f);
+static void lightbake_planar_compute_render_matrices(
+ EEVEE_PlanarReflection *eplanar, DRWMatrixState *r_matstate, const float viewmat[4][4])
+{
+ /* Reflect Camera Matrix. */
+ mul_m4_m4m4(r_matstate->viewmat, viewmat, eplanar->mtx);
+ /* TODO FOV margin */
+ /* Temporal sampling jitter should be already applied to the DRW_MAT_WIN. */
+ DRW_viewport_matrix_get(r_matstate->winmat, DRW_MAT_WIN);
+ /* Apply Projection Matrix. */
+ mul_m4_m4m4(r_matstate->persmat, r_matstate->winmat, r_matstate->viewmat);
+
+ /* This is the matrix used to reconstruct texture coordinates.
+ * We use the original view matrix because it does not create
+ * visual artifacts if receiver is not perfectly aligned with
+ * the planar reflection probe. */
+ mul_m4_m4m4(eplanar->reflectionmat, r_matstate->winmat, viewmat); /* TODO FOV margin */
+ /* Convert from [-1, 1] to [0, 1] (NDC to Texture coord). */
+ mul_m4_m4m4(eplanar->reflectionmat, texcomat, eplanar->reflectionmat);
+}
- /* Debug Display */
- if (DRW_state_draw_support() &&
- (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
- {
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_grid_display_sh, psl->probe_display);
- DRW_shgroup_uniform_int(grp, "offset", &egrid->offset, 1);
- DRW_shgroup_uniform_ivec3(grp, "grid_resolution", egrid->resolution, 1);
- DRW_shgroup_uniform_vec3(grp, "corner", egrid->corner, 1);
- DRW_shgroup_uniform_vec3(grp, "increment_x", egrid->increment_x, 1);
- DRW_shgroup_uniform_vec3(grp, "increment_y", egrid->increment_y, 1);
- DRW_shgroup_uniform_vec3(grp, "increment_z", egrid->increment_z, 1);
- DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &sldata->irradiance_pool);
- DRW_shgroup_uniform_float(grp, "sphere_size", &probe->data_draw_size, 1);
- DRW_shgroup_call_instances_add(grp, DRW_cache_sphere_get(), NULL, (uint *)&ped->num_cell);
- }
- }
+static void eevee_lightprobes_extract_from_cache(EEVEE_LightProbesInfo *pinfo, LightCache *lcache)
+{
+ /* copy the entire cache for now (up to MAX_PROBE) */
+ /* TODO Frutum cull to only add visible probes. */
+ memcpy(pinfo->probe_data, lcache->cube_data, sizeof(EEVEE_LightProbe) * max_ii(1, min_ii(lcache->cube_len, MAX_PROBE)));
+ /* TODO compute the max number of grid based on sample count. */
+ memcpy(pinfo->grid_data, lcache->grid_data, sizeof(EEVEE_LightGrid) * max_ii(1, min_ii(lcache->grid_len, MAX_GRID)));
}
void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
- EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
+ EEVEE_StorageList *stl = vedata->stl;
+ LightCache *light_cache = stl->g_data->light_cache;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
- Object *ob;
- /* Setup enough layers. */
- /* Free textures if number mismatch. */
- if (pinfo->num_cube != pinfo->cache_num_cube) {
- DRW_TEXTURE_FREE_SAFE(sldata->probe_pool);
- pinfo->cache_num_cube = pinfo->num_cube;
- }
+ eevee_lightprobes_extract_from_cache(sldata->probes, light_cache);
+
+ DRW_uniformbuffer_update(sldata->probe_ubo, &sldata->probes->probe_data);
+ DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
+
+ /* For shading, save max level of the octahedron map */
+ sldata->common_data.prb_lod_cube_max = (float)light_cache->mips_len - 1.0f;
+ sldata->common_data.prb_lod_planar_max = (float)MAX_PLANAR_LOD_LEVEL;
+ sldata->common_data.prb_irradiance_vis_size = light_cache->vis_res;
+ sldata->common_data.prb_num_render_cube = max_ii(1, light_cache->cube_len);
+ sldata->common_data.prb_num_render_grid = max_ii(1, light_cache->grid_len);
+ sldata->common_data.prb_num_planar = pinfo->num_planar;
if (pinfo->num_planar != pinfo->cache_num_planar) {
DRW_TEXTURE_FREE_SAFE(vedata->txl->planar_pool);
DRW_TEXTURE_FREE_SAFE(vedata->txl->planar_depth);
pinfo->cache_num_planar = pinfo->num_planar;
}
-
- int irr_size[3];
- irradiance_pool_size_get(common_data->prb_irradiance_vis_size, pinfo->total_irradiance_samples, irr_size);
-
- if ((irr_size[0] != pinfo->cache_irradiance_size[0]) ||
- (irr_size[1] != pinfo->cache_irradiance_size[1]) ||
- (irr_size[2] != pinfo->cache_irradiance_size[2]))
- {
- DRW_TEXTURE_FREE_SAFE(sldata->irradiance_pool);
- DRW_TEXTURE_FREE_SAFE(sldata->irradiance_rt);
- copy_v3_v3_int(pinfo->cache_irradiance_size, irr_size);
- }
-
- /* XXX this should be run each frame as it ensure planar_depth is set */
planar_pool_ensure_alloc(vedata, pinfo->num_planar);
- if (!sldata->probe_pool) {
- sldata->probe_pool = DRW_texture_create_2D_array(pinfo->cubemap_res, pinfo->cubemap_res, max_ff(1, pinfo->num_cube),
- GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
- if (sldata->probe_filter_fb) {
- GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0);
- }
- /* Tag probes to refresh */
- pinfo->update_world |= PROBE_UPDATE_CUBE;
- }
+ /* If lightcache auto-update is enable we tag the relevant part
+ * of the cache to update and fire up a baking job. */
+ if (!DRW_state_is_image_render() && !DRW_state_is_opengl_render() &&
+ (pinfo->do_grid_update || pinfo->do_cube_update))
+ {
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ BLI_assert(draw_ctx->evil_C);
- if ((pinfo->update_world & PROBE_UPDATE_CUBE) != 0) {
- common_data->prb_num_render_cube = 0;
- for (int i = 1; (ob = pinfo->probes_cube_ref[i]) && (i < MAX_PROBE); i++) {
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
- ped->need_update = true;
- ped->ready_to_shade = false;
- ped->probe_id = 0;
+ if (draw_ctx->scene->eevee.flag & SCE_EEVEE_GI_AUTOBAKE) {
+ Scene *scene_orig = DEG_get_input_scene(draw_ctx->depsgraph);
+ if (scene_orig->eevee.light_cache != NULL) {
+ if (pinfo->do_grid_update) {
+ scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_GRID;
+ }
+ /* If we update grid we need to update the cubemaps too.
+ * So always refresh cubemaps. */
+ scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_CUBE;
+ /* Tag the lightcache to auto update. */
+ scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_AUTO;
+ /* Use a notifier to trigger the operator after drawing. */
+ WM_event_add_notifier(draw_ctx->evil_C, NC_LIGHTPROBE, scene_orig);
+ }
}
}
+}
-#ifdef IRRADIANCE_SH_L2
- /* we need a signed format for Spherical Harmonics */
- int irradiance_format = GPU_RGBA16F;
-#else
- int irradiance_format = GPU_RGBA8;
-#endif
+/* -------------------------------------------------------------------- */
- if (!sldata->irradiance_pool || !sldata->irradiance_rt) {
- if (!sldata->irradiance_pool) {
- sldata->irradiance_pool = DRW_texture_create_2D_array(irr_size[0], irr_size[1], irr_size[2],
- irradiance_format, DRW_TEX_FILTER, NULL);
- }
- if (!sldata->irradiance_rt) {
- sldata->irradiance_rt = DRW_texture_create_2D_array(irr_size[0], irr_size[1], irr_size[2],
- irradiance_format, DRW_TEX_FILTER, NULL);
- }
- /* Tag probes to refresh */
- pinfo->update_world |= PROBE_UPDATE_GRID;
- pinfo->grid_initialized = false;
- }
+/** \name Rendering
+ * \{ */
- if ((pinfo->update_world & PROBE_UPDATE_GRID) != 0) {
- common_data->prb_num_render_grid = 0;
- pinfo->updated_bounce = 0;
- for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_PROBE); i++) {
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
- ped->need_update = true;
- ped->updated_cells = 0;
- }
- }
+typedef struct EEVEE_BakeRenderData {
+ EEVEE_Data *vedata;
+ EEVEE_ViewLayerData *sldata;
+ struct GPUFrameBuffer **face_fb; /* should contain 6 framebuffer */
+} EEVEE_BakeRenderData;
- if (common_data->prb_num_render_grid > pinfo->num_grid) {
- /* This can happen when deleting a probe. */
- common_data->prb_num_render_grid = pinfo->num_grid;
- }
+static void render_cubemap(
+ void (*callback)(int face, EEVEE_BakeRenderData *user_data), EEVEE_BakeRenderData *user_data,
+ const float pos[3], float clipsta, float clipend)
+{
+ DRWMatrixState matstate;
- EEVEE_planar_reflections_cache_finish(sldata, vedata->stl);
+ /* Move to capture position */
+ float posmat[4][4];
+ unit_m4(posmat);
+ negate_v3_v3(posmat[3], pos);
- EEVEE_lightprobes_updates(sldata, vedata->psl, vedata->stl);
+ perspective_m4(matstate.winmat, -clipsta, clipsta, -clipsta, clipsta, clipsta, clipend);
+ invert_m4_m4(matstate.wininv, matstate.winmat);
- DRW_uniformbuffer_update(sldata->probe_ubo, &sldata->probes->probe_data);
- DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
-}
+ /* 1 - Render to each cubeface individually.
+ * We do this instead of using geometry shader because a) it's faster,
+ * b) it's easier than fixing the nodetree shaders (for view dependant effects). */
+ for (int i = 0; i < 6; ++i) {
+ /* Setup custom matrices */
+ mul_m4_m4m4(matstate.viewmat, cubefacemat[i], posmat);
+ mul_m4_m4m4(matstate.persmat, matstate.winmat, matstate.viewmat);
+ invert_m4_m4(matstate.persinv, matstate.persmat);
+ invert_m4_m4(matstate.viewinv, matstate.viewmat);
+ invert_m4_m4(matstate.wininv, matstate.winmat);
-static void downsample_planar(void *vedata, int level)
-{
- EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
- EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ DRW_viewport_matrix_override_set_all(&matstate);
- const float *size = DRW_viewport_size_get();
- copy_v2_v2(stl->g_data->planar_texel_size, size);
- for (int i = 0; i < level - 1; ++i) {
- stl->g_data->planar_texel_size[0] /= 2.0f;
- stl->g_data->planar_texel_size[1] /= 2.0f;
- min_ff(floorf(stl->g_data->planar_texel_size[0]), 1.0f);
- min_ff(floorf(stl->g_data->planar_texel_size[1]), 1.0f);
+ callback(i, user_data);
}
- invert_v2(stl->g_data->planar_texel_size);
-
- DRW_draw_pass(psl->probe_planar_downsample_ps);
}
-/* Glossy filter probe_rt to probe_pool at index probe_idx */
-static void glossy_filter_probe(
- EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, EEVEE_PassList *psl, int probe_idx, float intensity)
+static void render_reflections(
+ void (*callback)(int face, EEVEE_BakeRenderData *user_data), EEVEE_BakeRenderData *user_data,
+ EEVEE_PlanarReflection *planar_data, int ref_count)
{
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
-
- pinfo->intensity_fac = intensity;
-
- /* Max lod used from the render target probe */
- pinfo->lod_rt_max = floorf(log2f(pinfo->target_size)) - 2.0f;
-
- /* Start fresh */
- GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_NONE
- });
-
- /* 2 - Let gpu create Mipmaps for Filtered Importance Sampling. */
- /* Bind next framebuffer to be able to gen. mips for probe_rt. */
- EEVEE_downsample_cube_buffer(vedata, sldata->probe_rt, (int)(pinfo->lod_rt_max));
-
- /* 3 - Render to probe array to the specified layer, do prefiltering. */
- float mipsize = pinfo->cubemap_res;
- const int maxlevel = (int)floorf(log2f(pinfo->cubemap_res));
- const int min_lod_level = 3;
- for (int i = 0; i < maxlevel - min_lod_level; i++) {
- float bias = (i == 0) ? -1.0f : 1.0f;
- pinfo->texel_size = 1.0f / mipsize;
- pinfo->padding_size = powf(2.0f, (float)(maxlevel - min_lod_level - 1 - i));
- /* XXX : WHY THE HECK DO WE NEED THIS ??? */
- /* padding is incorrect without this! float precision issue? */
- if (pinfo->padding_size > 32) {
- pinfo->padding_size += 5;
- }
- if (pinfo->padding_size > 16) {
- pinfo->padding_size += 4;
- }
- else if (pinfo->padding_size > 8) {
- pinfo->padding_size += 2;
- }
- else if (pinfo->padding_size > 4) {
- pinfo->padding_size += 1;
- }
- pinfo->layer = probe_idx;
- pinfo->roughness = (float)i / ((float)maxlevel - 4.0f);
- pinfo->roughness *= pinfo->roughness; /* Disney Roughness */
- pinfo->roughness *= pinfo->roughness; /* Distribute Roughness accros lod more evenly */
- CLAMP(pinfo->roughness, 1e-8f, 0.99999f); /* Avoid artifacts */
-
-#if 1 /* Variable Sample count (fast) */
- switch (i) {
- case 0: pinfo->samples_ct = 1.0f; break;
- case 1: pinfo->samples_ct = 16.0f; break;
- case 2: pinfo->samples_ct = 32.0f; break;
- case 3: pinfo->samples_ct = 64.0f; break;
- default: pinfo->samples_ct = 128.0f; break;
- }
-#else /* Constant Sample count (slow) */
- pinfo->samples_ct = 1024.0f;
-#endif
+ DRWMatrixState matstate;
- pinfo->invsamples_ct = 1.0f / pinfo->samples_ct;
- pinfo->lodfactor = bias + 0.5f * log((float)(pinfo->target_size * pinfo->target_size) * pinfo->invsamples_ct) / log(2);
+ float original_viewmat[4][4];
+ DRW_viewport_matrix_get(original_viewmat, DRW_MAT_VIEW);
- GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_TEXTURE_MIP(sldata->probe_pool, i)
- });
- GPU_framebuffer_bind(sldata->probe_filter_fb);
- GPU_framebuffer_viewport_set(sldata->probe_filter_fb, 0, 0, mipsize, mipsize);
- DRW_draw_pass(psl->probe_glossy_compute);
+ for (int i = 0; i < ref_count; ++i) {
+ /* Setup custom matrices */
+ lightbake_planar_compute_render_matrices(planar_data + i, &matstate, original_viewmat);
+ invert_m4_m4(matstate.persinv, matstate.persmat);
+ invert_m4_m4(matstate.viewinv, matstate.viewmat);
+ invert_m4_m4(matstate.wininv, matstate.winmat);
+ DRW_viewport_matrix_override_set_all(&matstate);
- mipsize /= 2;
- CLAMP_MIN(mipsize, 1);
+ callback(i, user_data);
}
- /* For shading, save max level of the octahedron map */
- sldata->common_data.prb_lod_cube_max = (float)(maxlevel - min_lod_level) - 1.0f;
}
-/* Diffuse filter probe_rt to irradiance_pool at index probe_idx */
-static void diffuse_filter_probe(
- EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, EEVEE_PassList *psl, int offset,
- float clipsta, float clipend, float vis_range, float vis_blur, float intensity)
+static void lightbake_render_world_face(int face, EEVEE_BakeRenderData *user_data)
{
- EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ EEVEE_PassList *psl = user_data->vedata->psl;
+ struct GPUFrameBuffer **face_fb = user_data->face_fb;
- pinfo->intensity_fac = intensity;
+ /* For world probe, we don't need to clear the color buffer
+ * since we render the background directly. */
+ GPU_framebuffer_bind(face_fb[face]);
+ GPU_framebuffer_clear_depth(face_fb[face], 1.0f);
+ DRW_draw_pass(psl->probe_background);
+}
- int pool_size[3];
- irradiance_pool_size_get(common_data->prb_irradiance_vis_size, pinfo->total_irradiance_samples, pool_size);
+void EEVEE_lightbake_render_world(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata, struct GPUFrameBuffer *face_fb[6])
+{
+ EEVEE_BakeRenderData brdata = {
+ .vedata = vedata,
+ .face_fb = face_fb
+ };
- /* find cell position on the virtual 3D texture */
- /* NOTE : Keep in sync with load_irradiance_cell() */
-#if defined(IRRADIANCE_SH_L2)
- int size[2] = {3, 3};
-#elif defined(IRRADIANCE_CUBEMAP)
- int size[2] = {8, 8};
- pinfo->samples_ct = 1024.0f;
-#elif defined(IRRADIANCE_HL2)
- int size[2] = {3, 2};
- pinfo->samples_ct = 1024.0f;
-#endif
+ render_cubemap(lightbake_render_world_face, &brdata, (float[3]){0.0f}, 1.0f, 10.0f);
+}
- int cell_per_row = pool_size[0] / size[0];
- int x = size[0] * (offset % cell_per_row);
- int y = size[1] * (offset / cell_per_row);
+static void lightbake_render_scene_face(int face, EEVEE_BakeRenderData *user_data)
+{
+ EEVEE_ViewLayerData *sldata = user_data->sldata;
+ EEVEE_PassList *psl = user_data->vedata->psl;
+ struct GPUFrameBuffer **face_fb = user_data->face_fb;
-#ifndef IRRADIANCE_SH_L2
- /* Tweaking parameters to balance perf. vs precision */
- const float bias = 0.0f;
- pinfo->invsamples_ct = 1.0f / pinfo->samples_ct;
- pinfo->lodfactor = bias + 0.5f * log((float)(pinfo->target_size * pinfo->target_size) * pinfo->invsamples_ct) / log(2);
- pinfo->lod_rt_max = floorf(log2f(pinfo->target_size)) - 2.0f;
-#else
- pinfo->shres = 32; /* Less texture fetches & reduce branches */
- pinfo->lod_rt_max = 2.0f; /* Improve cache reuse */
-#endif
+ /* Be sure that cascaded shadow maps are updated. */
+ EEVEE_draw_shadows(sldata, psl);
- /* Start fresh */
- GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_NONE
- });
+ GPU_framebuffer_bind(face_fb[face]);
+ GPU_framebuffer_clear_depth(face_fb[face], 1.0f);
- /* 4 - Compute spherical harmonics */
- EEVEE_downsample_cube_buffer(vedata, sldata->probe_rt, (int)(pinfo->lod_rt_max));
+ DRW_draw_pass(psl->depth_pass);
+ DRW_draw_pass(psl->depth_pass_cull);
+ DRW_draw_pass(psl->probe_background);
+ DRW_draw_pass(psl->material_pass);
+ DRW_draw_pass(psl->sss_pass); /* Only output standard pass */
+ EEVEE_draw_default_passes(psl);
+}
- GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_TEXTURE_LAYER(sldata->irradiance_rt, 0)
- });
- GPU_framebuffer_bind(sldata->probe_filter_fb);
- GPU_framebuffer_viewport_set(sldata->probe_filter_fb, x, y, size[0], size[1]);
- DRW_draw_pass(psl->probe_diffuse_compute);
+/* Render the scene to the probe_rt texture. */
+void EEVEE_lightbake_render_scene(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUFrameBuffer *face_fb[6],
+ const float pos[3], float near_clip, float far_clip)
+{
+ EEVEE_BakeRenderData brdata = {
+ .vedata = vedata,
+ .sldata = sldata,
+ .face_fb = face_fb
+ };
- /* World irradiance have no visibility */
- if (offset > 0) {
- /* Compute visibility */
- pinfo->samples_ct = 512.0f; /* TODO refine */
- pinfo->invsamples_ct = 1.0f / pinfo->samples_ct;
- pinfo->shres = common_data->prb_irradiance_vis_size;
- pinfo->visibility_range = vis_range;
- pinfo->visibility_blur = vis_blur;
- pinfo->near_clip = -clipsta;
- pinfo->far_clip = -clipend;
- pinfo->texel_size = 1.0f / (float)common_data->prb_irradiance_vis_size;
-
- int cell_per_col = pool_size[1] / common_data->prb_irradiance_vis_size;
- cell_per_row = pool_size[0] / common_data->prb_irradiance_vis_size;
- x = common_data->prb_irradiance_vis_size * (offset % cell_per_row);
- y = common_data->prb_irradiance_vis_size * ((offset / cell_per_row) % cell_per_col);
- int layer = 1 + ((offset / cell_per_row) / cell_per_col);
- const int vis_size = common_data->prb_irradiance_vis_size;
-
- GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_TEXTURE_LAYER(sldata->irradiance_rt, layer)
- });
- GPU_framebuffer_bind(sldata->probe_filter_fb);
- GPU_framebuffer_viewport_set(sldata->probe_filter_fb, x, y, vis_size, vis_size);
- DRW_draw_pass(psl->probe_visibility_compute);
- }
+ render_cubemap(lightbake_render_scene_face, &brdata, pos, near_clip, far_clip);
}
-/* Render the scene to the probe_rt texture. */
-static void render_scene_to_probe(
- EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
- const float pos[3], float clipsta, float clipend)
+static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *user_data)
{
- EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_Data *vedata = user_data->vedata;
+ EEVEE_ViewLayerData *sldata = user_data->sldata;
EEVEE_PassList *psl = vedata->psl;
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ EEVEE_PlanarReflection *eplanar = pinfo->planar_data + layer;
- DRWMatrixState matstate;
- float (*viewmat)[4] = matstate.mat[DRW_MAT_VIEW];
- float (*viewinv)[4] = matstate.mat[DRW_MAT_VIEWINV];
- float (*persmat)[4] = matstate.mat[DRW_MAT_PERS];
- float (*persinv)[4] = matstate.mat[DRW_MAT_PERSINV];
- float (*winmat)[4] = matstate.mat[DRW_MAT_WIN];
- float (*wininv)[4] = matstate.mat[DRW_MAT_WININV];
-
- float posmat[4][4];
- unit_m4(posmat);
-
- /* Move to capture position */
- negate_v3_v3(posmat[3], pos);
+ GPU_framebuffer_ensure_config(&fbl->planarref_fb, {
+ GPU_ATTACHMENT_TEXTURE_LAYER(txl->planar_depth, layer),
+ GPU_ATTACHMENT_TEXTURE_LAYER(txl->planar_pool, layer)
+ });
- /* 1 - Render to each cubeface individually.
- * We do this instead of using geometry shader because a) it's faster,
- * b) it's easier than fixing the nodetree shaders (for view dependant effects). */
- pinfo->layer = 0;
- perspective_m4(winmat, -clipsta, clipsta, -clipsta, clipsta, clipsta, clipend);
+ /* Use visibility info for this planar reflection. */
+ pinfo->vis_data = pinfo->planar_vis_tests[layer];
/* Avoid using the texture attached to framebuffer when rendering. */
/* XXX */
GPUTexture *tmp_planar_pool = txl->planar_pool;
- GPUTexture *tmp_maxz = txl->maxzbuffer;
+ GPUTexture *tmp_planar_depth = txl->planar_depth;
txl->planar_pool = e_data.planar_pool_placeholder;
- txl->maxzbuffer = e_data.depth_placeholder;
-
- DRW_stats_group_start("Cubemap Render");
-
- /* Update common uniforms */
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
-
- for (int i = 0; i < 6; ++i) {
- /* Recompute only on 1st drawloop. */
- pinfo->vis_data.cached = (i != 0);
-
- DRW_stats_group_start("Cubemap Face");
-
- /* Setup custom matrices */
- mul_m4_m4m4(viewmat, cubefacemat[i], posmat);
- mul_m4_m4m4(persmat, winmat, viewmat);
- invert_m4_m4(persinv, persmat);
- invert_m4_m4(viewinv, viewmat);
- invert_m4_m4(wininv, winmat);
-
- DRW_viewport_matrix_override_set_all(&matstate);
-
- /* Be sure that cascaded shadow maps are updated. */
- EEVEE_draw_shadows(sldata, psl);
-
- GPU_framebuffer_bind(sldata->probe_face_fb[i]);
- GPU_framebuffer_clear_depth(sldata->probe_face_fb[i], 1.0);
-
- /* Depth prepass */
- DRW_draw_pass(psl->depth_pass);
- DRW_draw_pass(psl->depth_pass_cull);
-
- DRW_draw_pass(psl->probe_background);
-
- // EEVEE_create_minmax_buffer(vedata, sldata->probe_depth_rt);
-
- /* Rebind Target FB */
- GPU_framebuffer_bind(sldata->probe_face_fb[i]);
-
- /* Shading pass */
- EEVEE_draw_default_passes(psl);
- DRW_draw_pass(psl->material_pass);
- DRW_draw_pass(psl->sss_pass); /* Only output standard pass */
-
- DRW_stats_group_end();
- }
-
- DRW_stats_group_end();
-
- /* Make sure no aditionnal visibility check runs after this. */
- pinfo->vis_data.collection = NULL;
-
- /* Restore */
- txl->planar_pool = tmp_planar_pool;
- txl->maxzbuffer = tmp_maxz;
-}
-
-static void render_scene_to_planar(
- EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, int layer,
- EEVEE_LightProbeEngineData *ped)
-{
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
- EEVEE_FramebufferList *fbl = vedata->fbl;
- EEVEE_TextureList *txl = vedata->txl;
- EEVEE_PassList *psl = vedata->psl;
-
- float (*viewmat)[4] = ped->mats.mat[DRW_MAT_VIEW];
- float (*viewinv)[4] = ped->mats.mat[DRW_MAT_VIEWINV];
- float (*persmat)[4] = ped->mats.mat[DRW_MAT_PERS];
- float (*persinv)[4] = ped->mats.mat[DRW_MAT_PERSINV];
- float (*winmat)[4] = ped->mats.mat[DRW_MAT_WIN];
- float (*wininv)[4] = ped->mats.mat[DRW_MAT_WININV];
-
- invert_m4_m4(viewinv, viewmat);
- invert_m4_m4(persinv, persmat);
- invert_m4_m4(wininv, winmat);
+ txl->planar_depth = e_data.depth_array_placeholder;
+ /* Be sure that cascaded shadow maps are updated. */
DRW_stats_group_start("Planar Reflection");
- DRW_viewport_matrix_override_set_all(&ped->mats);
-
- /* Don't reuse previous visibility. */
- pinfo->vis_data.cached = false;
-
/* Be sure that cascaded shadow maps are updated. */
EEVEE_draw_shadows(sldata, psl);
-
/* Since we are rendering with an inverted view matrix, we need
* to invert the facing for backface culling to be the same. */
DRW_state_invert_facing();
- /* Set clipping plan */
- copy_v4_v4(sldata->clip_data.clip_planes[0], ped->planer_eq_offset);
+ /* Compute offset plane equation (fix missing texels near reflection plane). */
+ copy_v4_v4(sldata->clip_data.clip_planes[0], eplanar->plane_equation);
+ sldata->clip_data.clip_planes[0][3] += eplanar->clipsta;
+ /* Set clipping plane */
DRW_uniformbuffer_update(sldata->clip_ubo, &sldata->clip_data);
DRW_state_clip_planes_count_set(1);
- GPU_framebuffer_ensure_config(&fbl->planarref_fb, {
- GPU_ATTACHMENT_TEXTURE_LAYER(txl->planar_depth, layer),
- GPU_ATTACHMENT_TEXTURE_LAYER(txl->planar_pool, layer)
- });
-
GPU_framebuffer_bind(fbl->planarref_fb);
GPU_framebuffer_clear_depth(fbl->planarref_fb, 1.0);
- /* Avoid using the texture attached to framebuffer when rendering. */
- /* XXX */
- GPUTexture *tmp_planar_pool = txl->planar_pool;
- GPUTexture *tmp_planar_depth = txl->planar_depth;
- txl->planar_pool = e_data.planar_pool_placeholder;
- txl->planar_depth = e_data.depth_array_placeholder;
-
/* Slight modification: we handle refraction as normal
* shading and don't do SSRefraction. */
- /* Depth prepass */
DRW_draw_pass(psl->depth_pass_clip);
DRW_draw_pass(psl->depth_pass_clip_cull);
DRW_draw_pass(psl->refract_depth_pass);
DRW_draw_pass(psl->refract_depth_pass_cull);
- /* Background */
DRW_draw_pass(psl->probe_background);
-
EEVEE_create_minmax_buffer(vedata, tmp_planar_depth, layer);
-
- /* Compute GTAO Horizons */
EEVEE_occlusion_compute(sldata, vedata, tmp_planar_depth, layer);
- /* Rebind Planar FB */
GPU_framebuffer_bind(fbl->planarref_fb);
/* Shading pass */
@@ -1409,134 +1050,229 @@ static void render_scene_to_planar(
DRW_stats_group_end();
- /* Make sure no aditionnal visibility check runs after this. */
- pinfo->vis_data.collection = NULL;
-
/* Restore */
txl->planar_pool = tmp_planar_pool;
txl->planar_depth = tmp_planar_depth;
}
-static void render_world_to_probe(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
+static void eevee_lightbake_render_scene_to_planars(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
+{
+ EEVEE_BakeRenderData brdata = {
+ .vedata = vedata,
+ .sldata = sldata,
+ };
+
+ render_reflections(lightbake_render_scene_reflected, &brdata, sldata->probes->planar_data, sldata->probes->num_planar);
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Filtering
+ * \{ */
+
+/* Glossy filter rt_color to light_cache->cube_tx.tex at index probe_idx */
+void EEVEE_lightbake_filter_glossy(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
+ struct GPUTexture *rt_color, struct GPUFrameBuffer *fb,
+ int probe_idx, float intensity, int maxlevel)
{
+ EEVEE_PassList *psl = vedata->psl;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
- DRWMatrixState matstate;
- float (*viewmat)[4] = matstate.mat[DRW_MAT_VIEW];
- float (*viewinv)[4] = matstate.mat[DRW_MAT_VIEWINV];
- float (*persmat)[4] = matstate.mat[DRW_MAT_PERS];
- float (*persinv)[4] = matstate.mat[DRW_MAT_PERSINV];
- float (*winmat)[4] = matstate.mat[DRW_MAT_WIN];
- float (*wininv)[4] = matstate.mat[DRW_MAT_WININV];
+ LightCache *light_cache = vedata->stl->g_data->light_cache;
- /* For world probe, we don't need to clear since we render the background directly. */
- pinfo->layer = 0;
+ float target_size = (float)GPU_texture_width(rt_color);
- perspective_m4(winmat, -0.1f, 0.1f, -0.1f, 0.1f, 0.1f, 1.0f);
- invert_m4_m4(wininv, winmat);
+ /* Max lod used from the render target probe */
+ pinfo->lod_rt_max = floorf(log2f(target_size)) - 2.0f;
+ pinfo->intensity_fac = intensity;
- for (int i = 0; i < 6; ++i) {
- /* Setup custom matrices */
- copy_m4_m4(viewmat, cubefacemat[i]);
- mul_m4_m4m4(persmat, winmat, viewmat);
- invert_m4_m4(persinv, persmat);
- invert_m4_m4(viewinv, viewmat);
- DRW_viewport_matrix_override_set_all(&matstate);
+ /* Start fresh */
+ GPU_framebuffer_ensure_config(&fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_NONE
+ });
- GPU_framebuffer_bind(sldata->probe_face_fb[i]);
- GPU_framebuffer_clear_depth(sldata->probe_face_fb[i], 1.0f);
- DRW_draw_pass(psl->probe_background);
- }
-}
+ /* 2 - Let gpu create Mipmaps for Filtered Importance Sampling. */
+ /* Bind next framebuffer to be able to gen. mips for probe_rt. */
+ EEVEE_downsample_cube_buffer(vedata, rt_color, (int)(pinfo->lod_rt_max));
-static void lightprobe_cell_grid_location_get(EEVEE_LightGrid *egrid, int cell_idx, float r_local_cell[3])
-{
- /* Keep in sync with lightprobe_grid_display_vert */
- r_local_cell[2] = (float)(cell_idx % egrid->resolution[2]);
- r_local_cell[1] = (float)((cell_idx / egrid->resolution[2]) % egrid->resolution[1]);
- r_local_cell[0] = (float)(cell_idx / (egrid->resolution[2] * egrid->resolution[1]));
-}
+ /* 3 - Render to probe array to the specified layer, do prefiltering. */
+ int mipsize = GPU_texture_width(light_cache->cube_tx.tex);
+ for (int i = 0; i < maxlevel + 1; i++) {
+ float bias = (i == 0) ? -1.0f : 1.0f;
+ pinfo->texel_size = 1.0f / (float)mipsize;
+ pinfo->padding_size = (float)(1 << (maxlevel - i - 1));
+ pinfo->padding_size *= pinfo->texel_size;
+ pinfo->layer = probe_idx;
+ pinfo->roughness = i / (float)maxlevel;
+ pinfo->roughness *= pinfo->roughness; /* Disney Roughness */
+ pinfo->roughness *= pinfo->roughness; /* Distribute Roughness accros lod more evenly */
+ CLAMP(pinfo->roughness, 1e-8f, 0.99999f); /* Avoid artifacts */
-static void lightprobe_cell_world_location_get(EEVEE_LightGrid *egrid, float local_cell[3], float r_pos[3])
-{
- float tmp[3];
-
- copy_v3_v3(r_pos, egrid->corner);
- mul_v3_v3fl(tmp, egrid->increment_x, local_cell[0]);
- add_v3_v3(r_pos, tmp);
- mul_v3_v3fl(tmp, egrid->increment_y, local_cell[1]);
- add_v3_v3(r_pos, tmp);
- mul_v3_v3fl(tmp, egrid->increment_z, local_cell[2]);
- add_v3_v3(r_pos, tmp);
+#if 1 /* Variable Sample count (fast) */
+ switch (i) {
+ case 0: pinfo->samples_len = 1.0f; break;
+ case 1: pinfo->samples_len = 16.0f; break;
+ case 2: pinfo->samples_len = 32.0f; break;
+ case 3: pinfo->samples_len = 64.0f; break;
+ default: pinfo->samples_len = 128.0f; break;
+ }
+#else /* Constant Sample count (slow) */
+ pinfo->samples_len = 1024.0f;
+#endif
+
+ pinfo->samples_len_inv = 1.0f / pinfo->samples_len;
+ pinfo->lodfactor = bias + 0.5f * log((float)(target_size * target_size) * pinfo->samples_len_inv) / log(2);
+
+ GPU_framebuffer_ensure_config(&fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE_MIP(light_cache->cube_tx.tex, i)
+ });
+ GPU_framebuffer_bind(fb);
+ GPU_framebuffer_viewport_set(fb, 0, 0, mipsize, mipsize);
+ DRW_draw_pass(psl->probe_glossy_compute);
+
+ mipsize /= 2;
+ CLAMP_MIN(mipsize, 1);
+ }
}
-static void lightprobes_refresh_world(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
+/* Diffuse filter rt_color to light_cache->grid_tx.tex at index grid_offset */
+void EEVEE_lightbake_filter_diffuse(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
+ struct GPUTexture *rt_color, struct GPUFrameBuffer *fb,
+ int grid_offset, float intensity)
{
- EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
EEVEE_PassList *psl = vedata->psl;
- EEVEE_StorageList *stl = vedata->stl;
- DRWMatrixState saved_mats;
+ EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ LightCache *light_cache = vedata->stl->g_data->light_cache;
- /* We need to save the Matrices before overidding them */
- DRW_viewport_matrix_get_all(&saved_mats);
+ float target_size = (float)GPU_texture_width(rt_color);
- render_world_to_probe(sldata, psl);
- if (pinfo->update_world & PROBE_UPDATE_CUBE) {
- glossy_filter_probe(sldata, vedata, psl, 0, 1.0);
- common_data->prb_num_render_cube = 1;
- }
- if (pinfo->update_world & PROBE_UPDATE_GRID) {
- diffuse_filter_probe(sldata, vedata, psl, 0, 0.0, 0.0, 0.0, 0.0, 1.0);
+ pinfo->intensity_fac = intensity;
- SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
+ /* find cell position on the virtual 3D texture */
+ /* NOTE : Keep in sync with load_irradiance_cell() */
+#if defined(IRRADIANCE_SH_L2)
+ int size[2] = {3, 3};
+#elif defined(IRRADIANCE_CUBEMAP)
+ int size[2] = {8, 8};
+ pinfo->samples_len = 1024.0f;
+#elif defined(IRRADIANCE_HL2)
+ int size[2] = {3, 2};
+ pinfo->samples_len = 1024.0f;
+#endif
- GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
- GPU_framebuffer_bind(sldata->probe_filter_fb);
- DRW_draw_pass(psl->probe_grid_fill);
+ int cell_per_row = GPU_texture_width(light_cache->grid_tx.tex) / size[0];
+ int x = size[0] * (grid_offset % cell_per_row);
+ int y = size[1] * (grid_offset / cell_per_row);
- common_data->prb_num_render_grid = 1;
- /* Reset volume history. */
- stl->effects->volume_current_sample = -1;
- common_data->vol_history_alpha = 0.0f;
- }
- pinfo->update_world = 0;
- DRW_viewport_request_redraw();
- /* Do not let this frame accumulate. */
- stl->effects->taa_current_sample = 1;
+#ifndef IRRADIANCE_SH_L2
+ /* Tweaking parameters to balance perf. vs precision */
+ const float bias = 0.0f;
+ pinfo->samples_len_inv = 1.0f / pinfo->samples_len;
+ pinfo->lodfactor = bias + 0.5f * log((float)(target_size * target_size) * pinfo->samples_len_inv) / log(2);
+ pinfo->lod_rt_max = floorf(log2f(target_size)) - 2.0f;
+#else
+ pinfo->shres = 32; /* Less texture fetches & reduce branches */
+ pinfo->lod_rt_max = 2.0f; /* Improve cache reuse */
+#endif
- DRW_viewport_matrix_override_set_all(&saved_mats);
+ /* Start fresh */
+ GPU_framebuffer_ensure_config(&fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_NONE
+ });
+
+ /* 4 - Compute diffuse irradiance */
+ EEVEE_downsample_cube_buffer(vedata, rt_color, (int)(pinfo->lod_rt_max));
+
+ GPU_framebuffer_ensure_config(&fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE_LAYER(light_cache->grid_tx.tex, 0)
+ });
+ GPU_framebuffer_bind(fb);
+ GPU_framebuffer_viewport_set(fb, x, y, size[0], size[1]);
+ DRW_draw_pass(psl->probe_diffuse_compute);
}
-static void lightprobes_refresh_initialize_grid(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
+/* Filter rt_depth to light_cache->grid_tx.tex at index grid_offset */
+void EEVEE_lightbake_filter_visibility(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
+ struct GPUTexture *UNUSED(rt_depth), struct GPUFrameBuffer *fb,
+ int grid_offset, float clipsta, float clipend,
+ float vis_range, float vis_blur, int vis_size)
{
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
EEVEE_PassList *psl = vedata->psl;
- if (pinfo->grid_initialized) {
- /* Grid is already initialized, nothing to do. */
- return;
+ EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ LightCache *light_cache = vedata->stl->g_data->light_cache;
+
+ pinfo->samples_len = 512.0f; /* TODO refine */
+ pinfo->samples_len_inv = 1.0f / pinfo->samples_len;
+ pinfo->shres = vis_size;
+ pinfo->visibility_range = vis_range;
+ pinfo->visibility_blur = vis_blur;
+ pinfo->near_clip = -clipsta;
+ pinfo->far_clip = -clipend;
+ pinfo->texel_size = 1.0f / (float)vis_size;
+
+ int cell_per_col = GPU_texture_height(light_cache->grid_tx.tex) / vis_size;
+ int cell_per_row = GPU_texture_width(light_cache->grid_tx.tex) / vis_size;
+ int x = vis_size * (grid_offset % cell_per_row);
+ int y = vis_size * ((grid_offset / cell_per_row) % cell_per_col);
+ int layer = 1 + ((grid_offset / cell_per_row) / cell_per_col);
+
+ GPU_framebuffer_ensure_config(&fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE_LAYER(light_cache->grid_tx.tex, layer)
+ });
+ GPU_framebuffer_bind(fb);
+ GPU_framebuffer_viewport_set(fb, x, y, vis_size, vis_size);
+ DRW_draw_pass(psl->probe_visibility_compute);
+}
+
+/* Actually a simple downsampling */
+static void downsample_planar(void *vedata, int level)
+{
+ EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+
+ const float *size = DRW_viewport_size_get();
+ copy_v2_v2(stl->g_data->planar_texel_size, size);
+ for (int i = 0; i < level - 1; ++i) {
+ stl->g_data->planar_texel_size[0] /= 2.0f;
+ stl->g_data->planar_texel_size[1] /= 2.0f;
+ min_ff(floorf(stl->g_data->planar_texel_size[0]), 1.0f);
+ min_ff(floorf(stl->g_data->planar_texel_size[1]), 1.0f);
}
- /* Flood fill with world irradiance. */
- GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
- GPU_framebuffer_bind(sldata->probe_filter_fb);
- DRW_draw_pass(psl->probe_grid_fill);
+ invert_v2(stl->g_data->planar_texel_size);
+
+ DRW_draw_pass(psl->probe_planar_downsample_ps);
+}
- SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
+static void EEVEE_lightbake_filter_planar(EEVEE_Data *vedata)
+{
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
- GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
- GPU_framebuffer_bind(sldata->probe_filter_fb);
- DRW_draw_pass(psl->probe_grid_fill);
+ DRW_stats_group_start("Planar Probe Downsample");
- SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
+ GPU_framebuffer_ensure_config(&fbl->planar_downsample_fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(txl->planar_pool)
+ });
- pinfo->grid_initialized = true;
+ GPU_framebuffer_recursive_downsample(fbl->planar_downsample_fb, MAX_PLANAR_LOD_LEVEL, &downsample_planar, vedata);
+ DRW_stats_group_end();
}
+/** \} */
+
void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
- EEVEE_FramebufferList *fbl = vedata->fbl;
- EEVEE_TextureList *txl = vedata->txl;
- Object *ob;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
DRWMatrixState saved_mats;
@@ -1547,9 +1283,6 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
return;
}
- EEVEE_planar_reflections_updates(sldata);
- DRW_uniformbuffer_update(sldata->planar_ubo, &sldata->probes->planar_data);
-
/* We need to save the Matrices before overidding them */
DRW_viewport_matrix_get_all(&saved_mats);
@@ -1561,13 +1294,13 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
- for (int i = 0; (ob = pinfo->probes_planar_ref[i]) && (i < MAX_PLANAR); i++) {
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
- LightProbe *prb = (LightProbe *)ob->data;
- pinfo->vis_data.collection = prb->visibility_grp;
- pinfo->vis_data.invert = prb->flag & LIGHTPROBE_FLAG_INVERT_GROUP;
- render_scene_to_planar(sldata, vedata, i, ped);
- }
+ /* Rendering happens here! */
+ eevee_lightbake_render_scene_to_planars(sldata, vedata);
+
+ /* Make sure no aditionnal visibility check runs after this. */
+ pinfo->vis_data.collection = NULL;
+
+ DRW_uniformbuffer_update(sldata->planar_ubo, &sldata->probes->planar_data);
/* Restore */
common_data->prb_num_planar = pinfo->num_planar;
@@ -1576,17 +1309,7 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
/* Prefilter for SSR */
if ((vedata->stl->effects->enabled_effects & EFFECT_SSR) != 0) {
- const int max_lod = 9;
- DRW_stats_group_start("Planar Probe Downsample");
-
- GPU_framebuffer_ensure_config(&fbl->planar_downsample_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_TEXTURE(txl->planar_pool)
- });
- GPU_framebuffer_recursive_downsample(fbl->planar_downsample_fb, max_lod, &downsample_planar, vedata);
- /* For shading, save max level of the planar map */
- common_data->prb_lod_planar_max = (float)(max_lod);
- DRW_stats_group_end();
+ EEVEE_lightbake_filter_planar(vedata);
}
DRW_viewport_matrix_override_set_all(&saved_mats);
@@ -1600,239 +1323,18 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
common_data->ssr_toggle = vedata->stl->g_data->valid_double_buffer;
}
-static void lightprobes_refresh_cube(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
-{
- EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
- EEVEE_PassList *psl = vedata->psl;
- EEVEE_StorageList *stl = vedata->stl;
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
- Object *ob;
- for (int i = 1; (ob = pinfo->probes_cube_ref[i]) && (i < MAX_PROBE); i++) {
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
- if (!ped->need_update) {
- continue;
- }
- LightProbe *prb = (LightProbe *)ob->data;
- pinfo->vis_data.collection = prb->visibility_grp;
- pinfo->vis_data.invert = prb->flag & LIGHTPROBE_FLAG_INVERT_GROUP;
- render_scene_to_probe(sldata, vedata, ob->obmat[3], prb->clipsta, prb->clipend);
- glossy_filter_probe(sldata, vedata, psl, i, prb->intensity);
- ped->need_update = false;
- ped->probe_id = i;
- if (!ped->ready_to_shade) {
- common_data->prb_num_render_cube++;
- ped->ready_to_shade = true;
- }
-#if 0
- printf("Update Cubemap %d\n", i);
-#endif
- DRW_viewport_request_redraw();
- /* Do not let this frame accumulate. */
- stl->effects->taa_current_sample = 1;
- /* Only do one probe per frame */
- return;
- }
-
- pinfo->do_cube_update = false;
-}
-
-static void lightprobes_refresh_all_no_world(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
-{
- EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
- EEVEE_PassList *psl = vedata->psl;
- EEVEE_StorageList *stl = vedata->stl;
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
- Object *ob;
- const DRWContextState *draw_ctx = DRW_context_state_get();
- RegionView3D *rv3d = draw_ctx->rv3d;
-
- if (draw_ctx->evil_C != NULL) {
- /* Only compute probes if not navigating or in playback */
- struct wmWindowManager *wm = CTX_wm_manager(draw_ctx->evil_C);
- if (((rv3d->rflag & RV3D_NAVIGATING) != 0) || ED_screen_animation_no_scrub(wm) != NULL) {
- return;
- }
- }
- /* We need to save the Matrices before overidding them */
- DRWMatrixState saved_mats;
- DRW_viewport_matrix_get_all(&saved_mats);
- /* Make sure grid is initialized. */
- lightprobes_refresh_initialize_grid(sldata, vedata);
- /* Reflection probes depend on diffuse lighting thus on irradiance grid,
- * so update them first. */
- while (pinfo->updated_bounce < pinfo->num_bounce) {
- common_data->prb_num_render_grid = pinfo->num_grid;
- /* TODO(sergey): This logic can be split into smaller functions. */
- for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) {
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
- if (!ped->need_update) {
- continue;
- }
- EEVEE_LightGrid *egrid = &pinfo->grid_data[i];
- LightProbe *prb = (LightProbe *)ob->data;
- /* Find the next cell corresponding to the current level. */
- bool valid_cell = false;
- int cell_id = ped->updated_cells;
- float pos[3], grid_loc[3];
- /* Other levels */
- int current_stride = 1 << max_ii(0, ped->max_lvl - ped->updated_lvl);
- int prev_stride = current_stride << 1;
- bool do_rendering = true;
- while (!valid_cell) {
- cell_id = ped->updated_cells;
- lightprobe_cell_grid_location_get(egrid, cell_id, grid_loc);
- if (ped->updated_lvl == 0 && cell_id == 0) {
- valid_cell = true;
- ped->updated_cells = ped->num_cell;
- continue;
- }
- else if (((((int)grid_loc[0] % current_stride) == 0) &&
- (((int)grid_loc[1] % current_stride) == 0) &&
- (((int)grid_loc[2] % current_stride) == 0)) &&
- !((((int)grid_loc[0] % prev_stride) == 0) &&
- (((int)grid_loc[1] % prev_stride) == 0) &&
- (((int)grid_loc[2] % prev_stride) == 0)))
- {
- valid_cell = true;
- }
- ped->updated_cells++;
- if (ped->updated_cells > ped->num_cell) {
- do_rendering = false;
- break;
- }
- }
- if (do_rendering) {
- lightprobe_cell_world_location_get(egrid, grid_loc, pos);
- SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
- /* Temporary Remove all probes. */
- int tmp_num_render_grid = common_data->prb_num_render_grid;
- int tmp_num_render_cube = common_data->prb_num_render_cube;
- int tmp_num_planar = common_data->prb_num_planar;
- float tmp_level_bias = egrid->level_bias;
- common_data->prb_num_render_cube = 0;
- common_data->prb_num_planar = 0;
- /* Use light from previous bounce when capturing radiance. */
- if (pinfo->updated_bounce == 0) {
- /* But not on first bounce. */
- common_data->prb_num_render_grid = 0;
- }
- else {
- /* Remove bias */
- egrid->level_bias = (float)(1 << 0);
- DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
- }
- pinfo->vis_data.collection = prb->visibility_grp;
- pinfo->vis_data.invert = prb->flag & LIGHTPROBE_FLAG_INVERT_GROUP;
- render_scene_to_probe(sldata, vedata, pos, prb->clipsta, prb->clipend);
- diffuse_filter_probe(sldata, vedata, psl, egrid->offset + cell_id,
- prb->clipsta, prb->clipend, egrid->visibility_range, prb->vis_blur,
- prb->intensity);
- /* To see what is going on. */
- SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
- /* Restore */
- common_data->prb_num_render_cube = tmp_num_render_cube;
- pinfo->num_planar = tmp_num_planar;
- if (pinfo->updated_bounce == 0) {
- common_data->prb_num_render_grid = tmp_num_render_grid;
- }
- else {
- egrid->level_bias = tmp_level_bias;
- DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
- }
-#if 0
- printf("Updated Grid %d : cell %d / %d, bounce %d / %d\n",
- i, cell_id + 1, ped->num_cell, pinfo->updated_bounce + 1, pinfo->num_bounce);
-#endif
- }
- if (ped->updated_cells >= ped->num_cell) {
- ped->updated_lvl++;
- ped->updated_cells = 0;
- if (ped->updated_lvl > ped->max_lvl) {
- ped->need_update = false;
- }
- egrid->level_bias = (float)(1 << max_ii(0, ped->max_lvl - ped->updated_lvl + 1));
- DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
- }
- /* Only do one probe per frame */
- DRW_viewport_request_redraw();
- /* Do not let this frame accumulate. */
- stl->effects->taa_current_sample = 1;
- /* Reset volume history. */
- stl->effects->volume_current_sample = -1;
- common_data->vol_history_alpha = 0.0f;
- /* Restore matrices */
- DRW_viewport_matrix_override_set_all(&saved_mats);
- return;
- }
-
- pinfo->updated_bounce++;
- common_data->prb_num_render_grid = pinfo->num_grid;
-
- if (pinfo->updated_bounce < pinfo->num_bounce) {
- /* Retag all grids to update for next bounce */
- for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) {
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob);
- ped->need_update = true;
- ped->updated_cells = 0;
- ped->updated_lvl = 0;
- }
- /* Reset the next buffer so we can see the progress. */
- /* irradiance_rt is already the next rt because of the previous SWAP */
- GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
- GPU_framebuffer_bind(sldata->probe_filter_fb);
- DRW_draw_pass(psl->probe_grid_fill);
-
- GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0);
- /* Swap AFTER */
- SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
- }
- }
- /* Refresh cube probe when needed. */
- lightprobes_refresh_cube(sldata, vedata);
- /* Restore matrices */
- DRW_viewport_matrix_override_set_all(&saved_mats);
-}
-
-bool EEVEE_lightprobes_all_probes_ready(EEVEE_ViewLayerData *sldata, EEVEE_Data *UNUSED(vedata))
-{
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
- EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
-
- return ((pinfo->do_cube_update == false) &&
- (pinfo->updated_bounce == pinfo->num_bounce) &&
- (common_data->prb_num_render_cube == pinfo->num_cube));
-}
-
void EEVEE_lightprobes_refresh(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
- EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
- EEVEE_LightProbesInfo *pinfo = sldata->probes;
-
- /* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */
- common_data->spec_toggle = false;
- common_data->ssr_toggle = false;
- common_data->sss_toggle = false;
-
- /* Disable AO until we find a way to hide really bad discontinuities between cubefaces. */
- float tmp_ao_dist = common_data->ao_dist;
- float tmp_ao_settings = common_data->ao_settings;
- common_data->ao_settings = 0.0f;
- common_data->ao_dist = 0.0f;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
+ LightCache *light_cache = vedata->stl->g_data->light_cache;
- /* Render world in priority */
- if (pinfo->update_world) {
- lightprobes_refresh_world(sldata, vedata);
- }
- else if (EEVEE_lightprobes_all_probes_ready(sldata, vedata) == false && pinfo->all_materials_updated) {
- lightprobes_refresh_all_no_world(sldata, vedata);
+ if (light_cache->flag & LIGHTCACHE_UPDATE_WORLD) {
+ DRWMatrixState saved_mats;
+ DRW_viewport_matrix_get_all(&saved_mats);
+ EEVEE_lightbake_update_world_quick(sldata, vedata, scene_eval);
+ DRW_viewport_matrix_override_set_all(&saved_mats);
}
-
- /* Restore */
- common_data->spec_toggle = true;
- common_data->ssr_toggle = true;
- common_data->sss_toggle = true;
- common_data->ao_dist = tmp_ao_dist;
- common_data->ao_settings = tmp_ao_settings;
}
void EEVEE_lightprobes_free(void)
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index f5673d1a616..2c970fa5285 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -37,6 +37,8 @@
#define SHADOW_CASTER_ALLOC_CHUNK 16
+// #define DEBUG_CSM
+
static struct {
struct GPUShader *shadow_sh;
struct GPUShader *shadow_store_cube_sh[SHADOW_METHOD_MAX];
@@ -148,7 +150,7 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata)
DRW_TEXTURE_FREE_SAFE(sldata->shadow_cube_blur);
/* Compute adequate size for the octahedral map. */
- linfo->shadow_cube_store_size = (int)ceil(sqrt((sh_cube_size * sh_cube_size) * 6.0f));
+ linfo->shadow_cube_store_size = OCTAHEDRAL_SIZE_FROM_CUBESIZE(sh_cube_size);
CLAMP(linfo->shadow_cube_store_size, 1, 4096);
CLAMP(sh_cube_size, 1, 4096);
@@ -235,9 +237,9 @@ static GPUShader *eevee_lights_get_store_sh(int shadow_method, bool high_blur, b
return *shader;
}
-static DRWPass *eevee_lights_cube_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_ct)
+static DRWPass *eevee_lights_cube_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_len)
{
- bool high_blur = shadow_samples_ct > 16;
+ bool high_blur = shadow_samples_len > 16;
DRWPass **pass = (high_blur) ? &psl->shadow_cube_store_pass : &psl->shadow_cube_store_high_pass;
if (*pass == NULL) {
EEVEE_LampsInfo *linfo = sldata->lamps;
@@ -252,9 +254,9 @@ static DRWPass *eevee_lights_cube_store_pass_get(EEVEE_PassList *psl, EEVEE_View
return *pass;
}
-static DRWPass *eevee_lights_cascade_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_ct)
+static DRWPass *eevee_lights_cascade_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_len)
{
- bool high_blur = shadow_samples_ct > 16;
+ bool high_blur = shadow_samples_len > 16;
DRWPass **pass = (high_blur) ? &psl->shadow_cascade_store_pass : &psl->shadow_cascade_store_high_pass;
if (*pass == NULL) {
EEVEE_LampsInfo *linfo = sldata->lamps;
@@ -280,8 +282,8 @@ void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
linfo->num_light = 0;
linfo->num_cube_layer = 0;
linfo->num_cascade_layer = 0;
- linfo->gpu_cube_ct = linfo->gpu_cascade_ct = linfo->gpu_shadow_ct = 0;
- linfo->cpu_cube_ct = linfo->cpu_cascade_ct = 0;
+ linfo->gpu_cube_len = linfo->gpu_cascade_len = linfo->gpu_shadow_len = 0;
+ linfo->cpu_cube_len = linfo->cpu_cascade_len = 0;
memset(linfo->light_ref, 0, sizeof(linfo->light_ref));
memset(linfo->shadow_cube_ref, 0, sizeof(linfo->shadow_cube_ref));
memset(linfo->shadow_cascade_ref, 0, sizeof(linfo->shadow_cascade_ref));
@@ -334,7 +336,7 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob)
/* Step 1 find all lamps in the scene and setup them */
if (linfo->num_light >= MAX_LIGHT) {
- printf("Too many lamps in the scene !!!\n");
+ printf("Too many lights in the scene !!!\n");
}
else {
Lamp *la = (Lamp *)ob->data;
@@ -361,56 +363,56 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob)
int sh_nbr = 1; /* TODO : MSM */
int cascade_nbr = la->cascade_count;
- if ((linfo->gpu_cascade_ct + sh_nbr) <= MAX_SHADOW_CASCADE) {
+ if ((linfo->gpu_cascade_len + sh_nbr) <= MAX_SHADOW_CASCADE) {
/* Save Light object. */
- linfo->shadow_cascade_ref[linfo->cpu_cascade_ct] = ob;
+ linfo->shadow_cascade_ref[linfo->cpu_cascade_len] = ob;
/* Store indices. */
EEVEE_ShadowCascadeData *data = &led->data.scad;
- data->shadow_id = linfo->gpu_shadow_ct;
- data->cascade_id = linfo->gpu_cascade_ct;
+ data->shadow_id = linfo->gpu_shadow_len;
+ data->cascade_id = linfo->gpu_cascade_len;
data->layer_id = linfo->num_cascade_layer;
/* Increment indices. */
- linfo->gpu_shadow_ct += 1;
- linfo->gpu_cascade_ct += sh_nbr;
+ linfo->gpu_shadow_len += 1;
+ linfo->gpu_cascade_len += sh_nbr;
linfo->num_cascade_layer += sh_nbr * cascade_nbr;
- linfo->cpu_cascade_ct += 1;
+ linfo->cpu_cascade_len += 1;
}
}
else if (la->type == LA_SPOT || la->type == LA_LOCAL || la->type == LA_AREA) {
int sh_nbr = 1; /* TODO : MSM */
- if ((linfo->gpu_cube_ct + sh_nbr) <= MAX_SHADOW_CUBE) {
+ if ((linfo->gpu_cube_len + sh_nbr) <= MAX_SHADOW_CUBE) {
/* Save Light object. */
- linfo->shadow_cube_ref[linfo->cpu_cube_ct] = ob;
+ linfo->shadow_cube_ref[linfo->cpu_cube_len] = ob;
/* For light update tracking. */
if ((prev_cube_sh_id >= 0) &&
(prev_cube_sh_id < linfo->shcaster_backbuffer->count))
{
- linfo->new_shadow_id[prev_cube_sh_id] = linfo->cpu_cube_ct;
+ linfo->new_shadow_id[prev_cube_sh_id] = linfo->cpu_cube_len;
}
- led->prev_cube_shadow_id = linfo->cpu_cube_ct;
+ led->prev_cube_shadow_id = linfo->cpu_cube_len;
/* Saving lamp bounds for later. */
- BLI_assert(linfo->cpu_cube_ct >= 0 && linfo->cpu_cube_ct < MAX_LIGHT);
- copy_v3_v3(linfo->shadow_bounds[linfo->cpu_cube_ct].center, ob->obmat[3]);
- linfo->shadow_bounds[linfo->cpu_cube_ct].radius = la->clipend;
+ BLI_assert(linfo->cpu_cube_len >= 0 && linfo->cpu_cube_len < MAX_LIGHT);
+ copy_v3_v3(linfo->shadow_bounds[linfo->cpu_cube_len].center, ob->obmat[3]);
+ linfo->shadow_bounds[linfo->cpu_cube_len].radius = la->clipend;
EEVEE_ShadowCubeData *data = &led->data.scd;
/* Store indices. */
- data->shadow_id = linfo->gpu_shadow_ct;
- data->cube_id = linfo->gpu_cube_ct;
+ data->shadow_id = linfo->gpu_shadow_len;
+ data->cube_id = linfo->gpu_cube_len;
data->layer_id = linfo->num_cube_layer;
/* Increment indices. */
- linfo->gpu_shadow_ct += 1;
- linfo->gpu_cube_ct += sh_nbr;
+ linfo->gpu_shadow_len += 1;
+ linfo->gpu_cube_len += sh_nbr;
linfo->num_cube_layer += sh_nbr;
- linfo->cpu_cube_ct += 1;
+ linfo->cpu_cube_len += 1;
}
}
}
@@ -423,7 +425,7 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob)
/* Add a shadow caster to the shadowpasses */
void EEVEE_lights_cache_shcaster_add(
- EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob)
+ EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl, struct GPUBatch *geom, Object *ob)
{
DRW_shgroup_call_object_add(
stl->g_data->shadow_shgrp,
@@ -432,7 +434,7 @@ void EEVEE_lights_cache_shcaster_add(
void EEVEE_lights_cache_shcaster_material_add(
EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_PassList *psl, struct GPUMaterial *gpumat,
- struct Gwn_Batch *geom, struct Object *ob, float *alpha_threshold)
+ struct GPUBatch *geom, struct Object *ob, float *alpha_threshold)
{
/* TODO / PERF : reuse the same shading group for objects with the same material */
DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, psl->shadow_pass);
@@ -871,13 +873,13 @@ static void eevee_shadow_cascade_setup(
/* Given 8 frustum corners */
float corners[8][3] = {
/* Near Cap */
- {-1.0f, -1.0f, splits_start_ndc[c]},
{ 1.0f, -1.0f, splits_start_ndc[c]},
+ {-1.0f, -1.0f, splits_start_ndc[c]},
{-1.0f, 1.0f, splits_start_ndc[c]},
{ 1.0f, 1.0f, splits_start_ndc[c]},
/* Far Cap */
- {-1.0f, -1.0f, splits_end_ndc[c]},
{ 1.0f, -1.0f, splits_end_ndc[c]},
+ {-1.0f, -1.0f, splits_end_ndc[c]},
{-1.0f, 1.0f, splits_end_ndc[c]},
{ 1.0f, 1.0f, splits_end_ndc[c]}
};
@@ -890,8 +892,17 @@ static void eevee_shadow_cascade_setup(
float center[3];
frustum_min_bounding_sphere(corners, center, &(sh_data->radius[c]));
+#ifdef DEBUG_CSM
+ float dbg_col[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ if (c < 3) {
+ dbg_col[c] = 1.0f;
+ }
+ DRW_debug_bbox((BoundBox *)&corners, dbg_col);
+ DRW_debug_sphere(center, sh_data->radius[c], dbg_col);
+#endif
+
/* Project into lightspace */
- mul_mat3_m4_v3(viewmat, center);
+ mul_m4_v3(viewmat, center);
/* Snap projection center to nearest texel to cancel shimmering. */
float shadow_origin[2], shadow_texco[2];
@@ -919,6 +930,10 @@ static void eevee_shadow_cascade_setup(
mul_m4_m4m4(sh_data->viewprojmat[c], projmat, viewmat);
mul_m4_m4m4(cascade_data->shadowmat[c], texcomat, sh_data->viewprojmat[c]);
+
+#ifdef DEBUG_CSM
+ DRW_debug_m4_as_bbox(sh_data->viewprojmat[c], dbg_col, true);
+#endif
}
ubo_data->bias = 0.05f * la->bias;
@@ -993,7 +1008,7 @@ void EEVEE_lights_update(EEVEE_ViewLayerData *sldata)
for (i = 0; i < frontbuffer->count; i++, flag++, shcaster++) {
/* Run intersection checks to fill the bitfields. */
bsphere = linfo->shadow_bounds;
- for (int j = 0; j < linfo->cpu_cube_ct; j++, bsphere++) {
+ for (int j = 0; j < linfo->cpu_cube_len; j++, bsphere++) {
bool iter = sphere_bbox_intersect(bsphere, &shcaster->bbox);
lightbits_set_single(&shcaster->bits, j, iter);
}
@@ -1086,7 +1101,7 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
DRW_uniformbuffer_update(sldata->shadow_render_ubo, srd);
/* Render shadow cube */
- /* Render 6 faces separatly: seems to be faster for the general case.
+ /* Render 6 faces separately: seems to be faster for the general case.
* The only time it's more beneficial is when the CPU culling overhead
* outweight the instancing overhead. which is rarelly the case. */
for (int j = 0; j < 6; j++) {
@@ -1139,19 +1154,19 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
filter_pixel_size = max_ff(0.0f, filter_pixel_size - 3.0f);
/* Compute number of concentric samples. Depends directly on filter size. */
float pix_size_sqr = filter_pixel_size * filter_pixel_size;
- srd->shadow_samples_ct = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr));
+ srd->shadow_samples_len = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr));
}
else {
linfo->filter_size = 0.0f;
- srd->shadow_samples_ct = 4;
+ srd->shadow_samples_len = 4;
}
- srd->shadow_inv_samples_ct = 1.0f / (float)srd->shadow_samples_ct;
+ srd->shadow_samples_len_inv = 1.0f / (float)srd->shadow_samples_len;
DRW_uniformbuffer_update(sldata->shadow_render_ubo, srd);
GPU_framebuffer_texture_layer_attach(sldata->shadow_cube_store_fb, sldata->shadow_cube_pool, 0, evscd->layer_id, 0);
GPU_framebuffer_bind(sldata->shadow_cube_store_fb);
- DRWPass *store_pass = eevee_lights_cube_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_ct);
+ DRWPass *store_pass = eevee_lights_cube_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_len);
DRW_draw_pass(store_pass);
led->need_update = false;
@@ -1193,7 +1208,7 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
invert_m4_m4(render_mats.mat[DRW_MAT_VIEWINV], viewmat);
/* Render shadow cascades */
- /* Render cascade separatly: seems to be faster for the general case.
+ /* Render cascade separately: seems to be faster for the general case.
* The only time it's more beneficial is when the CPU culling overhead
* outweight the instancing overhead. which is rarelly the case. */
for (int j = 0; j < la->cascade_count; j++) {
@@ -1240,20 +1255,20 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
filter_pixel_size = max_ff(0.0f, filter_pixel_size - 3.0f);
/* Compute number of concentric samples. Depends directly on filter size. */
float pix_size_sqr = filter_pixel_size * filter_pixel_size;
- srd->shadow_samples_ct = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr));
+ srd->shadow_samples_len = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr));
}
else {
linfo->filter_size = 0.0f;
- srd->shadow_samples_ct = 4;
+ srd->shadow_samples_len = 4;
}
- srd->shadow_inv_samples_ct = 1.0f / (float)srd->shadow_samples_ct;
+ srd->shadow_samples_len_inv = 1.0f / (float)srd->shadow_samples_len;
DRW_uniformbuffer_update(sldata->shadow_render_ubo, &linfo->shadow_render_data);
int layer = evscd->layer_id + linfo->current_shadow_cascade;
GPU_framebuffer_texture_layer_attach(sldata->shadow_cascade_store_fb, sldata->shadow_cascade_pool, 0, layer, 0);
GPU_framebuffer_bind(sldata->shadow_cascade_store_fb);
- DRWPass *store_pass = eevee_lights_cascade_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_ct);
+ DRWPass *store_pass = eevee_lights_cascade_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_len);
DRW_draw_pass(store_pass);
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index e083c9b5eb5..345a28590c6 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -30,23 +30,76 @@
#include "DNA_screen_types.h"
#include "DNA_world_types.h"
+#include "DEG_depsgraph_query.h"
+
#include "ED_screen.h"
#include "eevee_private.h"
+#include "eevee_lightcache.h"
+
+static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata)
+{
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_TextureList *txl = vedata->txl;
+
+ MEM_SAFE_FREE(stl->lookdev_lightcache);
+ MEM_SAFE_FREE(stl->lookdev_grid_data);
+ MEM_SAFE_FREE(stl->lookdev_cube_data);
+ DRW_TEXTURE_FREE_SAFE(txl->lookdev_grid_tx);
+ DRW_TEXTURE_FREE_SAFE(txl->lookdev_cube_tx);
+}
void EEVEE_lookdev_cache_init(
EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass,
World *world, EEVEE_LightProbesInfo *pinfo)
{
EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_TextureList *txl = vedata->txl;
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
- if (LOOK_DEV_MODE_ENABLED(v3d)) {
- StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_WORLD);
- if ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) {
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) {
+ StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
+ if (sl && (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) {
+ struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
GPUTexture *tex = NULL;
+ /* If one of the component is missing we start from scratch. */
+ if ((stl->lookdev_grid_data == NULL) ||
+ (stl->lookdev_cube_data == NULL) ||
+ (txl->lookdev_grid_tx == NULL) ||
+ (txl->lookdev_cube_tx == NULL))
+ {
+ eevee_lookdev_lightcache_delete(vedata);
+ }
+
+ if (stl->lookdev_lightcache == NULL) {
+ const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
+#if defined(IRRADIANCE_SH_L2)
+ int grid_res = 4;
+#elif defined(IRRADIANCE_CUBEMAP)
+ int grid_res = 8;
+#elif defined(IRRADIANCE_HL2)
+ int grid_res = 4;
+#endif
+ int cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(scene_eval->eevee.gi_cubemap_resolution);
+ int vis_res = scene_eval->eevee.gi_visibility_resolution;
+
+ stl->lookdev_lightcache = EEVEE_lightcache_create(1, 1, cube_res, vis_res, (int[3]){grid_res, grid_res, 1});
+
+ /* We do this to use a special light cache for lookdev.
+ * This lightcache needs to be per viewport. But we need to
+ * have correct freeing when the viewport is closed. So we
+ * need to reference all textures to the txl and the memblocks
+ * to the stl. */
+ stl->lookdev_grid_data = stl->lookdev_lightcache->grid_data;
+ stl->lookdev_cube_data = stl->lookdev_lightcache->cube_data;
+ stl->lookdev_cube_mips = stl->lookdev_lightcache->cube_mips;
+ txl->lookdev_grid_tx = stl->lookdev_lightcache->grid_tx.tex;
+ txl->lookdev_cube_tx = stl->lookdev_lightcache->cube_tx.tex;
+ }
+
+ stl->g_data->light_cache = stl->lookdev_lightcache;
+
*grp = DRW_shgroup_create(shader, pass);
axis_angle_to_mat3_single(stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z);
DRW_shgroup_uniform_mat3(*grp, "StudioLightMatrix", stl->g_data->studiolight_matrix);
@@ -77,11 +130,9 @@ void EEVEE_lookdev_cache_init(
((pinfo->studiolight_index != sl->index) ||
(pinfo->studiolight_rot_z != v3d->shading.studiolight_rot_z)))
{
- pinfo->update_world |= PROBE_UPDATE_ALL;
+ stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD;
pinfo->studiolight_index = sl->index;
pinfo->studiolight_rot_z = v3d->shading.studiolight_rot_z;
- pinfo->prev_wo_sh_compiled = false;
- pinfo->prev_world = NULL;
}
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 5cc20adf961..39f7443145f 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -115,8 +115,8 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
{
struct GPUTexture *tex;
struct GPUFrameBuffer *fb = NULL;
- static float samples_ct = 8192.0f;
- static float inv_samples_ct = 1.0f / 8192.0f;
+ static float samples_len = 8192.0f;
+ static float inv_samples_len = 1.0f / 8192.0f;
char *lib_str = BLI_string_joinN(
datatoc_bsdf_common_lib_glsl,
@@ -130,12 +130,12 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR);
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
- DRW_shgroup_uniform_float(grp, "sampleCount", &samples_ct, 1);
- DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_ct, 1);
+ DRW_shgroup_uniform_float(grp, "sampleCount", &samples_len, 1);
+ DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_len, 1);
DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter);
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
DRW_shgroup_call_add(grp, geom, NULL);
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
@@ -172,9 +172,9 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
struct GPUTexture *tex;
struct GPUTexture *hammersley = create_hammersley_sample_texture(8192);
struct GPUFrameBuffer *fb = NULL;
- static float samples_ct = 8192.0f;
+ static float samples_len = 8192.0f;
static float a2 = 0.0f;
- static float inv_samples_ct = 1.0f / 8192.0f;
+ static float inv_samples_len = 1.0f / 8192.0f;
char *frag_str = BLI_string_joinN(
datatoc_bsdf_common_lib_glsl,
@@ -192,12 +192,12 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR);
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
DRW_shgroup_uniform_float(grp, "a2", &a2, 1);
- DRW_shgroup_uniform_float(grp, "sampleCount", &samples_ct, 1);
- DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_ct, 1);
+ DRW_shgroup_uniform_float(grp, "sampleCount", &samples_len, 1);
+ DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_len, 1);
DRW_shgroup_uniform_texture(grp, "texHammersley", hammersley);
DRW_shgroup_uniform_texture(grp, "utilTex", e_data.util_tex);
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
DRW_shgroup_call_add(grp, geom, NULL);
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
@@ -362,6 +362,8 @@ static void add_standard_uniforms(
DRWShadingGroup *shgrp, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
int *ssr_id, float *refract_depth, bool use_ssrefraction, bool use_alpha_blend)
{
+ LightCache *lcache = vedata->stl->g_data->light_cache;
+
if (ssr_id == NULL) {
static int no_ssr = -1.0f;
ssr_id = &no_ssr;
@@ -393,12 +395,12 @@ static void add_standard_uniforms(
/* TODO if diffuse bsdf */
if (true) {
- DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &sldata->irradiance_pool);
+ DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &lcache->grid_tx.tex);
}
/* TODO if glossy bsdf */
if (true) {
- DRW_shgroup_uniform_texture_ref(shgrp, "probeCubes", &sldata->probe_pool);
+ DRW_shgroup_uniform_texture_ref(shgrp, "probeCubes", &lcache->cube_tx.tex);
DRW_shgroup_uniform_texture_ref(shgrp, "probePlanars", &vedata->txl->planar_pool);
DRW_shgroup_uniform_int(shgrp, "outputSsrId", ssr_id, 1);
}
@@ -654,14 +656,14 @@ struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, Wor
const void *engine = &DRW_engine_viewport_eevee_type;
const int options = VAR_WORLD_PROBE;
- GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options);
+ GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options, false);
if (mat != NULL) {
return mat;
}
return DRW_shader_create_from_world(
scene, wo, engine, options,
datatoc_background_vert_glsl, NULL, e_data.frag_shader_lib,
- SHADER_DEFINES "#define PROBE_CAPTURE\n");
+ SHADER_DEFINES "#define PROBE_CAPTURE\n", false);
}
struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, World *wo)
@@ -669,14 +671,14 @@ struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, Wor
const void *engine = &DRW_engine_viewport_eevee_type;
int options = VAR_WORLD_BACKGROUND;
- GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options);
+ GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options, true);
if (mat != NULL) {
return mat;
}
return DRW_shader_create_from_world(
scene, wo, engine, options,
datatoc_background_vert_glsl, NULL, e_data.frag_shader_lib,
- SHADER_DEFINES "#define WORLD_BACKGROUND\n");
+ SHADER_DEFINES "#define WORLD_BACKGROUND\n", true);
}
struct GPUMaterial *EEVEE_material_world_volume_get(struct Scene *scene, World *wo)
@@ -684,7 +686,7 @@ struct GPUMaterial *EEVEE_material_world_volume_get(struct Scene *scene, World *
const void *engine = &DRW_engine_viewport_eevee_type;
int options = VAR_WORLD_VOLUME;
- GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options);
+ GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options, true);
if (mat != NULL) {
return mat;
}
@@ -694,7 +696,7 @@ struct GPUMaterial *EEVEE_material_world_volume_get(struct Scene *scene, World *
mat = DRW_shader_create_from_world(
scene, wo, engine, options,
datatoc_volumetric_vert_glsl, datatoc_volumetric_geom_glsl, e_data.volume_shader_lib,
- defines);
+ defines, true);
MEM_freeN(defines);
@@ -719,7 +721,7 @@ struct GPUMaterial *EEVEE_material_mesh_get(
options |= eevee_material_shadow_option(shadow_method);
- GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options);
+ GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true);
if (mat) {
return mat;
}
@@ -729,7 +731,7 @@ struct GPUMaterial *EEVEE_material_mesh_get(
mat = DRW_shader_create_from_material(
scene, ma, engine, options,
e_data.vert_shader_str, NULL, e_data.frag_shader_lib,
- defines);
+ defines, true);
MEM_freeN(defines);
@@ -741,7 +743,7 @@ struct GPUMaterial *EEVEE_material_mesh_volume_get(struct Scene *scene, Material
const void *engine = &DRW_engine_viewport_eevee_type;
int options = VAR_MAT_VOLUME;
- GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options);
+ GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true);
if (mat != NULL) {
return mat;
}
@@ -751,7 +753,7 @@ struct GPUMaterial *EEVEE_material_mesh_volume_get(struct Scene *scene, Material
mat = DRW_shader_create_from_material(
scene, ma, engine, options,
datatoc_volumetric_vert_glsl, datatoc_volumetric_geom_glsl, e_data.volume_shader_lib,
- defines);
+ defines, true);
MEM_freeN(defines);
@@ -775,7 +777,7 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get(
if (is_shadow)
options |= VAR_MAT_SHADOW;
- GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options);
+ GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true);
if (mat) {
return mat;
}
@@ -791,7 +793,8 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get(
(is_shadow) ? datatoc_shadow_vert_glsl : e_data.vert_shader_str,
NULL,
frag_str,
- defines);
+ defines,
+ true);
MEM_freeN(frag_str);
MEM_freeN(defines);
@@ -807,7 +810,7 @@ struct GPUMaterial *EEVEE_material_hair_get(
options |= eevee_material_shadow_option(shadow_method);
- GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options);
+ GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true);
if (mat) {
return mat;
}
@@ -817,7 +820,7 @@ struct GPUMaterial *EEVEE_material_hair_get(
mat = DRW_shader_create_from_material(
scene, ma, engine, options,
e_data.vert_shader_str, NULL, e_data.frag_shader_lib,
- defines);
+ defines, true);
MEM_freeN(defines);
@@ -943,7 +946,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
psl->background_pass = DRW_pass_create("Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = NULL;
const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -971,7 +974,6 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_shgroup_call_add(grp, geom, NULL);
break;
case GPU_MAT_QUEUED:
- sldata->probes->all_materials_updated = false;
/* TODO Bypass probe compilation. */
col = compile_col;
break;
@@ -1228,7 +1230,6 @@ static void material_opaque(
}
case GPU_MAT_QUEUED:
{
- sldata->probes->all_materials_updated = false;
/* TODO Bypass probe compilation. */
color_p = compile_col;
metal_p = spec_p = rough_p = &half;
@@ -1315,7 +1316,6 @@ static void material_transparent(
}
case GPU_MAT_QUEUED:
{
- sldata->probes->all_materials_updated = false;
/* TODO Bypass probe compilation. */
color_p = compile_col;
metal_p = spec_p = rough_p = &half;
@@ -1477,7 +1477,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
char *auto_layer_names;
int *auto_layer_is_srgb;
int auto_layer_count;
- struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(
+ struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get(
ob, gpumat_array, materials_len,
&auto_layer_names,
&auto_layer_is_srgb,
@@ -1645,7 +1645,6 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata,
}
case GPU_MAT_QUEUED:
{
- sldata->probes->all_materials_updated = false;
color_p = compile_col;
metal_p = spec_p = rough_p = &half;
break;
@@ -1691,7 +1690,7 @@ void EEVEE_materials_cache_finish(EEVEE_Data *vedata)
if (LOOK_DEV_OVERLAY_ENABLED(v3d)) {
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
EEVEE_LampsInfo *linfo = sldata->lamps;
- struct Gwn_Batch *sphere = DRW_cache_sphere_get();
+ struct GPUBatch *sphere = DRW_cache_sphere_get();
static float mat1[4][4];
static float color[3] = {0.8f, 0.8f, 0.8f};
static float metallic_on = 1.0f;
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 6dabc8f91cb..08745850bd4 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -178,7 +178,7 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
EEVEE_EffectsInfo *effects = stl->effects;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
if ((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0) {
psl->motion_blur = DRW_pass_create("Motion Blur", DRW_STATE_WRITE_COLOR);
diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c
index f39fbe33a71..8ede22cda5a 100644
--- a/source/blender/draw/engines/eevee/eevee_occlusion.c
+++ b/source/blender/draw/engines/eevee/eevee_occlusion.c
@@ -183,7 +183,7 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
EEVEE_EffectsInfo *effects = stl->effects;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
if ((effects->enabled_effects & EFFECT_GTAO) != 0) {
/** Occlusion algorithm overview
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index fa9d2453934..5aa331a9b99 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -26,11 +26,14 @@
#ifndef __EEVEE_PRIVATE_H__
#define __EEVEE_PRIVATE_H__
+#include "DNA_lightprobe_types.h"
+
struct Object;
struct EEVEE_BoundSphere;
struct EEVEE_ShadowCasterBuffer;
struct RenderLayer;
struct RenderResult;
+struct GPUFrameBuffer;
extern struct DrawEngineType draw_engine_eevee_type;
@@ -93,9 +96,14 @@ extern struct DrawEngineType draw_engine_eevee_type;
} ((void)0)
#define OVERLAY_ENABLED(v3d) ((v3d) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
-#define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->drawtype == OB_MATERIAL))
-#define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && ((v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV) > 0))
-#define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHT))))
+#define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->shading.type == OB_MATERIAL))
+#define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && (v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV))
+#define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS))))
+#define LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && !(v3d->shading.flag & V3D_SHADING_SCENE_WORLD))
+
+#define OCTAHEDRAL_SIZE_FROM_CUBESIZE(cube_size) ((int)ceilf(sqrtf((cube_size * cube_size) * 6.0f)))
+#define MIN_CUBE_LOD_LEVEL 3
+#define MAX_PLANAR_LOD_LEVEL 9
/* World shader variations */
enum {
@@ -131,6 +139,27 @@ enum {
VAR_MAT_SSSALBED = (1 << 17),
};
+/* ************ PROBE UBO ************* */
+
+/* They are the same struct as their Cache siblings.
+ * typedef'ing just to keep the naming consistent with
+ * other eevee types. */
+typedef LightProbeCache EEVEE_LightProbe;
+typedef LightGridCache EEVEE_LightGrid;
+
+typedef struct EEVEE_PlanarReflection {
+ float plane_equation[4];
+ float clip_vec_x[3], attenuation_scale;
+ float clip_vec_y[3], attenuation_bias;
+ float clip_edge_x_pos, clip_edge_x_neg;
+ float clip_edge_y_pos, clip_edge_y_neg;
+ float facing_scale, facing_bias, clipsta, pad;
+ float reflectionmat[4][4]; /* Used for sampling the texture. */
+ float mtx[4][4]; /* Not used in shader. TODO move elsewhere. */
+} EEVEE_PlanarReflection;
+
+/* --------------------------------------- */
+
typedef struct EEVEE_BoundSphere {
float center[3], radius;
} EEVEE_BoundSphere;
@@ -271,6 +300,9 @@ typedef struct EEVEE_TextureList {
struct GPUTexture *volume_scatter_history;
struct GPUTexture *volume_transmittance_history;
+ struct GPUTexture *lookdev_grid_tx;
+ struct GPUTexture *lookdev_cube_tx;
+
struct GPUTexture *planar_pool;
struct GPUTexture *planar_depth;
@@ -287,6 +319,10 @@ typedef struct EEVEE_StorageList {
struct EEVEE_PrivateData *g_data;
+ struct LightCache *lookdev_lightcache;
+ EEVEE_LightProbe *lookdev_cube_data;
+ EEVEE_LightGrid *lookdev_grid_data;
+ LightCacheTexture *lookdev_cube_mips;
} EEVEE_StorageList;
/* ************ LIGHT UBO ************* */
@@ -324,14 +360,14 @@ typedef struct EEVEE_ShadowRender {
float stored_texel_size;
float clip_near;
float clip_far;
- int shadow_samples_ct;
- float shadow_inv_samples_ct;
+ int shadow_samples_len;
+ float shadow_samples_len_inv;
} EEVEE_ShadowRender;
/* This is just a really long bitflag with special function to access it. */
#define MAX_LIGHTBITS_FIELDS (MAX_LIGHT / 8)
typedef struct EEVEE_LightBits {
- unsigned char fields[MAX_LIGHTBITS_FIELDS];
+ uchar fields[MAX_LIGHTBITS_FIELDS];
} EEVEE_LightBits;
typedef struct EEVEE_ShadowCaster {
@@ -351,8 +387,8 @@ typedef struct EEVEE_LampsInfo {
int num_light, cache_num_light;
int num_cube_layer, cache_num_cube_layer;
int num_cascade_layer, cache_num_cascade_layer;
- int gpu_cube_ct, gpu_cascade_ct, gpu_shadow_ct;
- int cpu_cube_ct, cpu_cascade_ct;
+ int gpu_cube_len, gpu_cascade_len, gpu_shadow_len;
+ int cpu_cube_len, cpu_cascade_len;
int update_flag;
int shadow_cube_size, shadow_cascade_size, shadow_method;
bool shadow_high_bitdepth;
@@ -391,42 +427,11 @@ enum {
LIGHT_UPDATE_SHADOW_CUBE = (1 << 0),
};
-/* ************ PROBE UBO ************* */
-typedef struct EEVEE_LightProbe {
- float position[3], parallax_type;
- float attenuation_fac;
- float attenuation_type;
- float pad3[2];
- float attenuationmat[4][4];
- float parallaxmat[4][4];
-} EEVEE_LightProbe;
-
-typedef struct EEVEE_LightGrid {
- float mat[4][4];
- int resolution[3], offset;
- float corner[3], attenuation_scale;
- float increment_x[3], attenuation_bias; /* world space vector between 2 opposite cells */
- float increment_y[3], level_bias;
- float increment_z[3], pad4;
- float visibility_bias, visibility_bleed, visibility_range, pad5;
-} EEVEE_LightGrid;
-
-typedef struct EEVEE_PlanarReflection {
- float plane_equation[4];
- float clip_vec_x[3], attenuation_scale;
- float clip_vec_y[3], attenuation_bias;
- float clip_edge_x_pos, clip_edge_x_neg;
- float clip_edge_y_pos, clip_edge_y_neg;
- float facing_scale, facing_bias, pad[2];
- float reflectionmat[4][4];
-} EEVEE_PlanarReflection;
-
/* ************ PROBE DATA ************* */
-
typedef struct EEVEE_LightProbeVisTest {
+ struct Collection *collection; /* Skip test if NULL */
bool invert;
bool cached; /* Reuse last test results */
- struct Collection *collection; /* Skip test if NULL */
} EEVEE_LightProbeVisTest;
typedef struct EEVEE_LightProbesInfo {
@@ -439,20 +444,16 @@ typedef struct EEVEE_LightProbesInfo {
int updated_bounce;
int num_bounce;
int cubemap_res;
- int target_size;
- int grid_initialized;
- struct World *prev_world;
- int update_world;
- bool prev_wo_sh_compiled;
+ /* Update */
bool do_cube_update;
- bool all_materials_updated;
+ bool do_grid_update;
/* For rendering probes */
float probemat[6][4][4];
int layer;
float texel_size;
float padding_size;
- float samples_ct;
- float invsamples_ct;
+ float samples_len;
+ float samples_len_inv;
float near_clip;
float far_clip;
float roughness;
@@ -464,15 +465,11 @@ typedef struct EEVEE_LightProbesInfo {
int shres;
int studiolight_index;
float studiolight_rot_z;
- /* List of probes in the scene. */
- /* XXX This is fragile, can get out of sync quickly. */
- struct Object *probes_cube_ref[MAX_PROBE];
- struct Object *probes_grid_ref[MAX_GRID];
- struct Object *probes_planar_ref[MAX_PLANAR];
+ EEVEE_LightProbeVisTest planar_vis_tests[MAX_PLANAR];
/* UBO Storage : data used by UBO */
- struct EEVEE_LightProbe probe_data[MAX_PROBE];
- struct EEVEE_LightGrid grid_data[MAX_GRID];
- struct EEVEE_PlanarReflection planar_data[MAX_PLANAR];
+ EEVEE_LightProbe probe_data[MAX_PROBE];
+ EEVEE_LightGrid grid_data[MAX_GRID];
+ EEVEE_PlanarReflection planar_data[MAX_PLANAR];
/* Probe Visibility Collection */
EEVEE_LightProbeVisTest vis_data;
} EEVEE_LightProbesInfo;
@@ -518,6 +515,7 @@ typedef struct EEVEE_EffectsInfo {
int volume_current_sample;
/* SSR */
bool reflection_trace_full;
+ bool ssr_was_persp;
int ssr_neighbor_ofs;
int ssr_halfres_ofs[2];
struct GPUTexture *ssr_normal_input; /* Textures from pool */
@@ -562,7 +560,7 @@ typedef struct EEVEE_EffectsInfo {
/* Other */
float prev_persmat[4][4];
/* Bloom */
- int bloom_iteration_ct;
+ int bloom_iteration_len;
float source_texel_size[2];
float blit_texel_size[2];
float downsamp_texel_size[MAX_BLOOM_STEP][2];
@@ -587,7 +585,7 @@ typedef struct EEVEE_EffectsInfo {
/* Common uniform buffer containing all "constant" data over the whole drawing pipeline. */
/* !! CAUTION !!
- * - [i]vec3 need to be paded to [i]vec4 (even in ubo declaration).
+ * - [i]vec3 need to be padded to [i]vec4 (even in ubo declaration).
* - Make sure that [i]vec4 start at a multiple of 16 bytes.
* - Arrays of vec2/vec3 are padded as arrays of vec4.
* - sizeof(bool) == sizeof(int) in GLSL so use int in C */
@@ -672,24 +670,18 @@ typedef struct EEVEE_ViewLayerData {
struct GPUUniformBuffer *grid_ubo;
struct GPUUniformBuffer *planar_ubo;
- struct GPUFrameBuffer *probe_filter_fb;
- struct GPUFrameBuffer *probe_face_fb[6];
-
- struct GPUTexture *probe_rt;
- struct GPUTexture *probe_depth_rt;
- struct GPUTexture *probe_pool;
- struct GPUTexture *irradiance_pool;
- struct GPUTexture *irradiance_rt;
-
/* Common Uniform Buffer */
struct EEVEE_CommonUniformBuffer common_data;
struct GPUUniformBuffer *common_ubo;
struct EEVEE_ClipPlanesUniformBuffer clip_data;
struct GPUUniformBuffer *clip_ubo;
+
+ struct LightCache *fallback_lightcache;
} EEVEE_ViewLayerData;
/* ************ OBJECT DATA ************ */
+
typedef struct EEVEE_LightData {
short light_id, shadow_id;
} EEVEE_LightData;
@@ -710,7 +702,7 @@ typedef struct EEVEE_ShadowCascadeData {
* It works with even if the object is in multiple layers
* because we don't get the same "Object *" for each layer. */
typedef struct EEVEE_LampEngineData {
- ObjectEngineData engine_data;
+ DrawData dd;
bool need_update;
/* This needs to be out of the union to avoid undefined behaviour. */
@@ -723,35 +715,13 @@ typedef struct EEVEE_LampEngineData {
} EEVEE_LampEngineData;
typedef struct EEVEE_LightProbeEngineData {
- ObjectEngineData engine_data;
-
- /* NOTE: need_full_update is set by dependency graph when the probe or it's
- * object is updated. This triggers full probe update, including it's
- * "progressive" GI refresh.
- *
- * need_update is always set to truth when need_full_update is tagged, but
- * might also be forced to be kept truth during GI refresh stages.
- *
- * TODO(sergey): Is there a way to avoid two flags here, or at least make
- * it more clear what's going on here?
- */
- bool need_full_update;
- bool need_update;
+ DrawData dd;
- bool ready_to_shade;
- int updated_cells;
- int updated_lvl;
- int num_cell;
- int max_lvl;
- int probe_id; /* Only used for display data */
- float probe_size; /* Only used for display data */
- DRWMatrixState mats; /* For planar probes */
- float planer_eq_offset[4];
- struct ListBase captured_object_list;
+ bool need_update;
} EEVEE_LightProbeEngineData;
typedef struct EEVEE_ObjectEngineData {
- ObjectEngineData engine_data;
+ DrawData dd;
Object *ob; /* self reference */
EEVEE_LightProbeVisTest *test_data;
@@ -761,6 +731,10 @@ typedef struct EEVEE_ObjectEngineData {
uint shadow_caster_id;
} EEVEE_ObjectEngineData;
+typedef struct EEVEE_WorldEngineData {
+ DrawData dd;
+} EEVEE_WorldEngineData;
+
/* *********************************** */
typedef struct EEVEE_Data {
@@ -785,6 +759,8 @@ typedef struct EEVEE_PrivateData {
struct DRWShadingGroup *planar_display_shgrp;
struct GHash *material_hash;
float background_alpha; /* TODO find a better place for this. */
+ /* Chosen lightcache: can come from Lookdev or the viewlayer. */
+ struct LightCache *light_cache;
/* For planar probes */
float planar_texel_size[2];
/* For double buffering */
@@ -802,6 +778,7 @@ typedef struct EEVEE_PrivateData {
/* eevee_data.c */
EEVEE_ViewLayerData *EEVEE_view_layer_data_get(void);
+EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure_ex(struct ViewLayer *view_layer);
EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure(void);
EEVEE_ObjectEngineData *EEVEE_object_data_get(Object *ob);
EEVEE_ObjectEngineData *EEVEE_object_data_ensure(Object *ob);
@@ -809,6 +786,8 @@ EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob);
EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_ensure(Object *ob);
EEVEE_LampEngineData *EEVEE_lamp_data_get(Object *ob);
EEVEE_LampEngineData *EEVEE_lamp_data_ensure(Object *ob);
+EEVEE_WorldEngineData *EEVEE_world_data_get(World *wo);
+EEVEE_WorldEngineData *EEVEE_world_data_ensure(World *wo);
/* eevee_materials.c */
struct GPUTexture *EEVEE_materials_get_util_tex(void); /* XXX */
@@ -837,10 +816,10 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata);
void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, struct Object *ob);
void EEVEE_lights_cache_shcaster_add(
- EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob);
+ EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, struct GPUBatch *geom, Object *ob);
void EEVEE_lights_cache_shcaster_material_add(
EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl,
- struct GPUMaterial *gpumat, struct Gwn_Batch *geom, struct Object *ob,
+ struct GPUMaterial *gpumat, struct GPUBatch *geom, struct Object *ob,
float *alpha_threshold);
void EEVEE_lights_cache_shcaster_object_add(EEVEE_ViewLayerData *sldata, struct Object *ob);
void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata);
@@ -848,17 +827,37 @@ void EEVEE_lights_update(EEVEE_ViewLayerData *sldata);
void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl);
void EEVEE_lights_free(void);
+
/* eevee_lightprobes.c */
bool EEVEE_lightprobes_obj_visibility_cb(bool vis_in, void *user_data);
-bool EEVEE_lightprobes_all_probes_ready(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
-void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, Object *ob);
+void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *ob);
void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lightprobes_refresh(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lightprobes_free(void);
+void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, GPUTexture *rt_color, GPUTexture *rt_depth);
+void EEVEE_lightbake_render_world(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUFrameBuffer *face_fb[6]);
+void EEVEE_lightbake_render_scene(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUFrameBuffer *face_fb[6],
+ const float pos[3], float near_clip, float far_clip);
+void EEVEE_lightbake_filter_glossy(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUTexture *rt_color, struct GPUFrameBuffer *fb,
+ int probe_idx, float intensity, int maxlevel);
+void EEVEE_lightbake_filter_diffuse(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUTexture *rt_color, struct GPUFrameBuffer *fb,
+ int grid_offset, float intensity);
+void EEVEE_lightbake_filter_visibility(
+ EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUTexture *rt_depth, struct GPUFrameBuffer *fb,
+ int grid_offset, float clipsta, float clipend, float vis_range, float vis_blur, int vis_size);
+
+void EEVEE_lightprobes_grid_data_from_object(Object *ob, EEVEE_LightGrid *prb_data, int *offset);
+void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *prb_data);
+void EEVEE_lightprobes_planar_data_from_object(Object *ob, EEVEE_PlanarReflection *eplanar, EEVEE_LightProbeVisTest *vis_test);
+
/* eevee_depth_of_field.c */
int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *camera);
void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
@@ -910,6 +909,7 @@ void EEVEE_mist_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
void EEVEE_mist_free(void);
/* eevee_temporal_sampling.c */
+void EEVEE_temporal_sampling_reset(EEVEE_Data *vedata);
int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_temporal_sampling_matrices_calc(
EEVEE_EffectsInfo *effects, float viewmat[4][4], float persmat[4][4], const double ht_point[2]);
@@ -947,6 +947,9 @@ void EEVEE_render_update_passes(struct RenderEngine *engine, struct Scene *scene
void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass, struct World *world, EEVEE_LightProbesInfo *pinfo);
void EEVEE_lookdev_draw_background(EEVEE_Data *vedata);
+/** eevee_engine.c */
+void EEVEE_cache_populate(void *vedata, Object *ob);
+
/* Shadow Matrix */
static const float texcomat[4][4] = { /* From NDC to TexCo */
{0.5f, 0.0f, 0.0f, 0.0f},
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c
index c650a6945ac..bc1bd97bdde 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -134,17 +134,31 @@ void EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
EEVEE_volumes_cache_init(sldata, vedata);
}
+/* Used by light cache. in this case engine is NULL. */
void EEVEE_render_cache(
void *vedata, struct Object *ob,
struct RenderEngine *engine, struct Depsgraph *UNUSED(depsgraph))
{
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
-
- char info[42];
- BLI_snprintf(info, sizeof(info), "Syncing %s", ob->id.name + 2);
- RE_engine_update_stats(engine, NULL, info);
+ EEVEE_LightProbesInfo *pinfo = sldata->probes;
bool cast_shadow = false;
+ if (pinfo->vis_data.collection) {
+ /* Used for rendering probe with visibility groups. */
+ bool ob_vis = BKE_collection_has_object_recursive(pinfo->vis_data.collection, ob);
+ ob_vis = (pinfo->vis_data.invert) ? !ob_vis : ob_vis;
+
+ if (!ob_vis) {
+ return;
+ }
+ }
+
+ if (engine) {
+ char info[42];
+ BLI_snprintf(info, sizeof(info), "Syncing %s", ob->id.name + 2);
+ RE_engine_update_stats(engine, NULL, info);
+ }
+
if (ob->base_flag & BASE_VISIBLE) {
EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
}
@@ -154,7 +168,7 @@ void EEVEE_render_cache(
EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
}
else if (ob->type == OB_LIGHTPROBE) {
- EEVEE_lightprobes_cache_add(sldata, ob);
+ EEVEE_lightprobes_cache_add(sldata, vedata, ob);
}
else if (ob->type == OB_LAMP) {
EEVEE_lights_cache_add(sldata, ob);
@@ -477,14 +491,8 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
DRW_viewport_matrix_override_set(g_data->viewinv, DRW_MAT_VIEWINV);
/* Refresh Probes */
- while (EEVEE_lightprobes_all_probes_ready(sldata, vedata) == false) {
- RE_engine_update_stats(engine, NULL, "Updating Probes");
- EEVEE_lightprobes_refresh(sldata, vedata);
- /* Refreshing probes can take some times, allow exit. */
- if (RE_engine_test_break(engine)) {
- return;
- }
- }
+ RE_engine_update_stats(engine, NULL, "Updating Probes");
+ EEVEE_lightprobes_refresh(sldata, vedata);
EEVEE_lightprobes_refresh_planar(sldata, vedata);
DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
index 74760b9c828..b882db174b0 100644
--- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
+++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
@@ -132,6 +132,14 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
});
}
+ const bool is_persp = DRW_viewport_is_persp_get();
+ if (effects->ssr_was_persp != is_persp) {
+ effects->ssr_was_persp = is_persp;
+ DRW_viewport_request_redraw();
+ EEVEE_temporal_sampling_reset(vedata);
+ stl->g_data->valid_double_buffer = false;
+ }
+
effects->reflection_trace_full = (scene_eval->eevee.flag & SCE_EEVEE_SSR_HALF_RESOLUTION) == 0;
common_data->ssr_thickness = scene_eval->eevee.ssr_thickness;
common_data->ssr_border_fac = scene_eval->eevee.ssr_border_fade;
@@ -187,8 +195,9 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
EEVEE_StorageList *stl = vedata->stl;
EEVEE_TextureList *txl = vedata->txl;
EEVEE_EffectsInfo *effects = stl->effects;
+ LightCache *lcache = stl->g_data->light_cache;
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
if ((effects->enabled_effects & EFFECT_SSR) != 0) {
int options = (effects->reflection_trace_full) ? SSR_FULL_TRACE : 0;
@@ -230,7 +239,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data.depth_src);
DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &effects->ssr_normal_input);
DRW_shgroup_uniform_texture_ref(grp, "specroughBuffer", &effects->ssr_specrough_input);
- DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &sldata->probe_pool);
+ DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &lcache->cube_tx.tex);
DRW_shgroup_uniform_texture_ref(grp, "probePlanars", &vedata->txl->planar_pool);
DRW_shgroup_uniform_texture_ref(grp, "planarDepth", &vedata->txl->planar_depth);
DRW_shgroup_uniform_texture_ref(grp, "hitBuffer", &effects->ssr_hit_output);
diff --git a/source/blender/draw/engines/eevee/eevee_subsurface.c b/source/blender/draw/engines/eevee/eevee_subsurface.c
index 6ee3b9cc286..9667f2ac9d7 100644
--- a/source/blender/draw/engines/eevee/eevee_subsurface.c
+++ b/source/blender/draw/engines/eevee/eevee_subsurface.c
@@ -204,7 +204,7 @@ void EEVEE_subsurface_add_pass(
EEVEE_PassList *psl = vedata->psl;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[0], psl->sss_blur_ps);
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
index 7cd76669fe4..76e11e02d26 100644
--- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
@@ -174,6 +174,11 @@ void EEVEE_temporal_sampling_matrices_calc(
invert_m4_m4(effects->overide_wininv, effects->overide_winmat);
}
+void EEVEE_temporal_sampling_reset(EEVEE_Data *vedata)
+{
+ vedata->stl->effects->taa_render_sample = 1;
+}
+
int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
{
EEVEE_StorageList *stl = vedata->stl;
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index 560f898b275..d0cea65d05e 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -349,6 +349,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
EEVEE_StorageList *stl = vedata->stl;
EEVEE_TextureList *txl = vedata->txl;
EEVEE_EffectsInfo *effects = stl->effects;
+ LightCache *lcache = stl->g_data->light_cache;
EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
if ((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) {
@@ -417,7 +418,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
psl->volumetric_scatter_ps = DRW_pass_create("Volumetric Scattering", DRW_STATE_WRITE_COLOR);
grp = DRW_shgroup_empty_tri_batch_create(scatter_sh, psl->volumetric_scatter_ps,
common_data->vol_tex_size[2]);
- DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &sldata->irradiance_pool);
+ DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &lcache->grid_tx.tex);
DRW_shgroup_uniform_texture_ref(grp, "shadowCubeTexture", &sldata->shadow_cube_pool);
DRW_shgroup_uniform_texture_ref(grp, "shadowCascadeTexture", &sldata->shadow_cascade_pool);
DRW_shgroup_uniform_texture_ref(grp, "volumeScattering", &txl->volume_prop_scattering);
diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
index 9d27224b5c9..fae310be90b 100644
--- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
@@ -246,7 +246,7 @@ float gtao_multibounce(float visibility, vec3 albedo)
float occlusion_compute(vec3 N, vec3 vpos, float user_occlusion, vec4 rand, out vec3 bent_normal)
{
#ifndef USE_REFRACTION
- if ((int(aoSettings) & USE_AO) > 0) {
+ if ((int(aoSettings) & USE_AO) != 0) {
float visibility;
vec3 vnor = mat3(ViewMatrix) * N;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
index d10f4bc0d42..5a72244cfbe 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
@@ -1,15 +1,18 @@
flat in int pid;
-in vec3 worldNormal;
-in vec3 worldPosition;
+in vec2 quadCoord;
out vec4 FragColor;
void main()
{
- vec3 V = (ProjectionMatrix[3][3] == 0.0) /* if perspective */
- ? normalize(cameraPos - worldPosition)
- : cameraForward;
- vec3 N = normalize(worldNormal);
- FragColor = vec4(textureLod_octahedron(probeCubes, vec4(reflect(-V, N), pid), 0.0, prbLodCubeMax).rgb, 1.0);
+ float dist_sqr = dot(quadCoord, quadCoord);
+
+ /* Discard outside the circle. */
+ if (dist_sqr > 1.0)
+ discard;
+
+ vec3 view_nor = vec3(quadCoord, sqrt(max(0.0, 1.0 - dist_sqr)));
+ vec3 world_ref = mat3(ViewMatrixInverse) * reflect(vec3(0.0, 0.0, -1.0), view_nor);
+ FragColor = vec4(textureLod_octahedron(probeCubes, vec4(world_ref, pid), 0.0, prbLodCubeMax).rgb, 1.0);
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
index b0a6cbe1707..b327878b63d 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
@@ -1,26 +1,43 @@
-in vec3 pos;
+/* XXX TODO fix code duplication */
+struct CubeData {
+ vec4 position_type;
+ vec4 attenuation_fac_type;
+ mat4 influencemat;
+ mat4 parallaxmat;
+};
-/* Instance attrib */
-in int probe_id;
-in vec3 probe_location;
-in float sphere_size;
+layout(std140) uniform probe_block {
+ CubeData probes_data[MAX_PROBE];
+};
+
+uniform float sphere_size;
+uniform vec3 screen_vecs[2];
flat out int pid;
-out vec3 worldNormal;
-out vec3 worldPosition;
+out vec2 quadCoord;
+
+const vec2 pos[6] = vec2[6](
+ vec2(-1.0, -1.0),
+ vec2( 1.0, -1.0),
+ vec2(-1.0, 1.0),
+
+ vec2( 1.0, -1.0),
+ vec2( 1.0, 1.0),
+ vec2(-1.0, 1.0)
+);
void main()
{
- pid = probe_id;
+ pid = 1 + (gl_VertexID / 6); /* +1 for the world */
+ int vert_id = gl_VertexID % 6;
+
+ quadCoord = pos[vert_id];
- /* While this is not performant, we do this to
- * match the object mode engine instancing shader. */
- mat4 offsetmat = mat4(1.0); /* Identity */
- offsetmat[3].xyz = probe_location;
+ vec3 ws_location = probes_data[pid].position_type.xyz;
+ vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y;
+ ws_location += screen_pos * sphere_size;
- vec4 wpos = offsetmat * vec4(pos * sphere_size, 1.0);
- worldPosition = wpos.xyz;
- gl_Position = ViewProjectionMatrix * wpos;
- worldNormal = normalize(pos);
+ gl_Position = ViewProjectionMatrix * vec4(ws_location, 1.0);
+ gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
index 14fd6d3dff5..7cf4259a938 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
@@ -131,8 +131,7 @@ void main()
/* Add a N pixel border to ensure filtering is correct
* for N mipmap levels. */
- uvs += uvs * texelSize * paddingSize * 2.0;
- uvs -= texelSize * paddingSize;
+ uvs = (uvs - texelSize * paddingSize) / (1.0 - 2.0 * texelSize * paddingSize);
/* edge mirroring : only mirror if directly adjacent
* (not diagonally adjacent) */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
index e4199e6a5ed..bb23051b7e5 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
@@ -30,8 +30,7 @@ void main() {
/* Add a N pixel border to ensure filtering is correct
* for N mipmap levels. */
- uvs += uvs * texelSize * paddingSize * 2.0;
- uvs -= texelSize * paddingSize;
+ uvs = (uvs - paddingSize) / (1.0 - 2.0 * paddingSize);
/* edge mirroring : only mirror if directly adjacent
* (not diagonally adjacent) */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
index 211fa8f0ce8..083d2313337 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
@@ -49,8 +49,7 @@ void main()
cos.xy = (vec2(texel) + 0.5) * storedTexelSize;
/* add a 2 pixel border to ensure filtering is correct */
- cos.xy *= 1.0 + storedTexelSize * 2.0;
- cos.xy -= storedTexelSize;
+ cos.xy = (cos.xy - storedTexelSize) / (1.0 - 2.0 * storedTexelSize);
float pattern = 1.0;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl
index d333ad34bb0..fd8eb157aa5 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl
@@ -1,11 +1,19 @@
flat in int cellOffset;
-in vec3 worldNormal;
+in vec2 quadCoord;
out vec4 FragColor;
void main()
{
- IrradianceData ir_data = load_irradiance_cell(cellOffset, worldNormal);
- FragColor = vec4(compute_irradiance(worldNormal, ir_data), 1.0);
+ float dist_sqr = dot(quadCoord, quadCoord);
+
+ /* Discard outside the circle. */
+ if (dist_sqr > 1.0)
+ discard;
+
+ vec3 view_nor = vec3(quadCoord, sqrt(max(0.0, 1.0 - dist_sqr)));
+ vec3 world_nor = mat3(ViewMatrixInverse) * view_nor;
+ IrradianceData ir_data = load_irradiance_cell(cellOffset, world_nor);
+ FragColor = vec4(compute_irradiance(world_nor, ir_data), 1.0);
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
index a017a791e41..7a92b55e530 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
@@ -1,6 +1,4 @@
-in vec3 pos;
-
uniform float sphere_size;
uniform int offset;
uniform ivec3 grid_resolution;
@@ -8,25 +6,44 @@ uniform vec3 corner;
uniform vec3 increment_x;
uniform vec3 increment_y;
uniform vec3 increment_z;
+uniform vec3 screen_vecs[2];
flat out int cellOffset;
-out vec3 worldNormal;
+out vec2 quadCoord;
+
+const vec2 pos[6] = vec2[6](
+ vec2(-1.0, -1.0),
+ vec2( 1.0, -1.0),
+ vec2(-1.0, 1.0),
+
+ vec2( 1.0, -1.0),
+ vec2( 1.0, 1.0),
+ vec2(-1.0, 1.0)
+);
void main()
{
+ int cell_id = gl_VertexID / 6;
+ int vert_id = gl_VertexID % 6;
+
vec3 ls_cell_location;
/* Keep in sync with update_irradiance_probe */
- ls_cell_location.z = float(gl_InstanceID % grid_resolution.z);
- ls_cell_location.y = float((gl_InstanceID / grid_resolution.z) % grid_resolution.y);
- ls_cell_location.x = float(gl_InstanceID / (grid_resolution.z * grid_resolution.y));
+ ls_cell_location.z = float(cell_id % grid_resolution.z);
+ ls_cell_location.y = float((cell_id / grid_resolution.z) % grid_resolution.y);
+ ls_cell_location.x = float(cell_id / (grid_resolution.z * grid_resolution.y));
- cellOffset = offset + gl_InstanceID;
+ cellOffset = offset + cell_id;
vec3 ws_cell_location = corner +
(increment_x * ls_cell_location.x +
increment_y * ls_cell_location.y +
increment_z * ls_cell_location.z);
- gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0);
- worldNormal = normalize(pos);
+
+ quadCoord = pos[vert_id];
+ vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y;
+ ws_cell_location += screen_pos * sphere_size;
+
+ gl_Position = ViewProjectionMatrix * vec4(ws_cell_location , 1.0);
+ gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
index 0ffc0cc4b49..6ae13e0102d 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
@@ -27,6 +27,7 @@ struct PlanarData {
vec4 clip_edges;
vec4 facing_scale_bias;
mat4 reflectionmat; /* transform world space into reflection texture space */
+ mat4 unused;
};
#define pl_plane_eq plane_equation
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 644b449c03e..22194c22f39 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -256,7 +256,7 @@ void CLOSURE_NAME(
PlanarData pd = planars_data[i];
/* Fade on geometric normal. */
- float fade = probe_attenuation_planar(pd, worldPosition, worldNormal, roughness);
+ float fade = probe_attenuation_planar(pd, worldPosition, (gl_FrontFacing) ? worldNormal : -worldNormal, roughness);
if (fade > 0.0) {
if (!(ssrToggle && ssr_id == outputSsrId)) {
@@ -404,7 +404,7 @@ void CLOSURE_NAME(
spec_occlu = 1.0;
}
- out_spec += spec_accum.rgb * ssr_spec * spec_occlu * float(specToggle);
+ out_spec += spec_accum.rgb * ssr_spec * spec_occlu;
#endif
#ifdef CLOSURE_REFRACTION
@@ -419,7 +419,12 @@ void CLOSURE_NAME(
vec2 C_brdf_lut = texture(utilTex, vec3(C_uv, 1.0)).rg;
vec3 C_fresnel = F_ibl(vec3(0.04), brdf_lut) * specular_occlusion(NV, final_ao, C_roughness);
- out_spec += C_spec_accum.rgb * C_fresnel * float(specToggle) * C_intensity;
+ out_spec += C_spec_accum.rgb * C_fresnel * C_intensity;
+#endif
+
+#ifdef CLOSURE_GLOSSY
+ /* Global toggle for lightprobe baking. */
+ out_spec *= float(specToggle);
#endif
/* ---------------------------------------------------------------- */
diff --git a/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl b/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
index 631b325ae37..ec13c885bbb 100644
--- a/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
@@ -13,8 +13,7 @@ vec2 mapping_octahedron(vec3 cubevec, vec2 texel_size)
vec2 uvs = cubevec.xy * (0.5) + 0.5;
/* edge filtering fix */
- uvs *= 1.0 - 2.0 * texel_size;
- uvs += texel_size;
+ uvs = (1.0 - 2.0 * texel_size) * uvs + texel_size;
return uvs;
}
diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c
index 2917805d233..b2c30ba723c 100644
--- a/source/blender/draw/engines/external/external_engine.c
+++ b/source/blender/draw/engines/external/external_engine.c
@@ -128,7 +128,7 @@ static void external_cache_populate(void *vedata, Object *ob)
if (!DRW_object_is_renderable(ob))
return;
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
/* Depth Prepass */
DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
@@ -165,14 +165,14 @@ static void external_draw_scene_do(void *vedata)
}
/* Rendered draw. */
- gpuPushProjectionMatrix();
+ GPU_matrix_push_projection();
ED_region_pixelspace(ar);
/* Render result draw. */
type = rv3d->render_engine->type;
type->view_draw(rv3d->render_engine, draw_ctx->evil_C);
- gpuPopProjectionMatrix();
+ GPU_matrix_pop_projection();
/* Set render info. */
EXTERNAL_Data *data = vedata;
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
index 99bacea4b27..eadc5e4b0d0 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
@@ -8,7 +8,7 @@ struct WorldData {
vec4 background_color_low;
vec4 background_color_high;
vec4 object_outline_color;
- vec4 light_direction_vs;
+ vec4 shadow_direction_vs;
LightData lights[3];
int num_lights;
int matcap_orientation;
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
index c72df6b677d..bf856fbb212 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
@@ -106,12 +106,10 @@ void main()
#endif
#ifdef V3D_SHADING_SHADOW
- float light_factor = -dot(normal_viewport, world_data.lights[0].light_direction_vs.xyz);
+ float light_factor = -dot(normal_viewport, world_data.shadow_direction_vs.xyz);
/* The step function might be ok for meshes but it's
* clearly not the case for hairs. Do smoothstep in this case. */
- float shadow_mix = (diffuse_color.a == 1.0 || diffuse_color.a == 0.0)
- ? step(-shadowShift, -light_factor)
- : smoothstep(1.0, shadowShift, light_factor);
+ float shadow_mix = smoothstep(1.0, shadowShift, light_factor);
float light_multiplier = mix(lightMultiplier, shadowMultiplier, shadow_mix);
#else /* V3D_SHADING_SHADOW */
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl
index 948392bd8ee..d8c8f22ed1c 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl
@@ -6,24 +6,24 @@
#ifdef DOUBLE_MANIFOLD
# ifdef USE_INVOC_EXT
-# define invoc_ct 2
+# define invoc_len 2
# else
-# define vert_ct 6
+# define vert_len 6
# endif
#else
# ifdef USE_INVOC_EXT
-# define invoc_ct 2
+# define invoc_len 2
# else
-# define vert_ct 6
+# define vert_len 6
# endif
#endif
#ifdef USE_INVOC_EXT
-layout(triangles, invocations = invoc_ct) in;
+layout(triangles, invocations = invoc_len) in;
layout(triangle_strip, max_vertices = 3) out;
#else
layout(triangles) in;
-layout(triangle_strip, max_vertices = vert_ct) out;
+layout(triangle_strip, max_vertices = vert_len) out;
#endif
uniform vec3 lightDirection = vec3(0.57, 0.57, -0.57);
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl
index 5a31aa34932..7418f86a58e 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl
@@ -6,24 +6,24 @@
#ifdef DOUBLE_MANIFOLD
# ifdef USE_INVOC_EXT
-# define invoc_ct 2
+# define invoc_len 2
# else
-# define vert_ct 8
+# define vert_len 8
# endif
#else
# ifdef USE_INVOC_EXT
-# define invoc_ct 1
+# define invoc_len 1
# else
-# define vert_ct 4
+# define vert_len 4
# endif
#endif
#ifdef USE_INVOC_EXT
-layout(lines_adjacency, invocations = invoc_ct) in;
+layout(lines_adjacency, invocations = invoc_len) in;
layout(triangle_strip, max_vertices = 4) out;
#else
layout(lines_adjacency) in;
-layout(triangle_strip, max_vertices = vert_ct) out;
+layout(triangle_strip, max_vertices = vert_len) out;
#endif
uniform vec3 lightDirection = vec3(0.57, 0.57, -0.57);
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
new file mode 100644
index 00000000000..ba5b78f4ecf
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
@@ -0,0 +1,181 @@
+
+uniform mat4 ProjectionMatrix;
+uniform mat4 ModelMatrixInverse;
+uniform mat4 ModelViewMatrixInverse;
+uniform mat4 ModelMatrix;
+
+uniform sampler2D depthBuffer;
+uniform sampler3D densityTexture;
+
+uniform int samplesLen = 256;
+uniform float stepLength; /* Step length in local space. */
+uniform float densityScale; /* Simple Opacity multiplicator. */
+uniform vec4 viewvecs[3];
+
+uniform float slicePosition;
+uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */
+
+#ifdef VOLUME_SLICE
+in vec3 localPos;
+#endif
+
+out vec4 fragColor;
+
+#define M_PI 3.1415926535897932 /* pi */
+
+float phase_function_isotropic()
+{
+ return 1.0 / (4.0 * M_PI);
+}
+
+float get_view_z_from_depth(float depth)
+{
+ if (ProjectionMatrix[3][3] == 0.0) {
+ float d = 2.0 * depth - 1.0;
+ return -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]);
+ }
+ else {
+ return viewvecs[0].z + depth * viewvecs[1].z;
+ }
+}
+
+vec3 get_view_space_from_depth(vec2 uvcoords, float depth)
+{
+ if (ProjectionMatrix[3][3] == 0.0) {
+ return vec3(viewvecs[0].xy + uvcoords * viewvecs[1].xy, 1.0) * get_view_z_from_depth(depth);
+ }
+ else {
+ return viewvecs[0].xyz + vec3(uvcoords, depth) * viewvecs[1].xyz;
+ }
+}
+
+float max_v3(vec3 v) { return max(v.x, max(v.y, v.z)); }
+
+float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
+{
+ /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ */
+ vec3 firstplane = (vec3( 1.0) - lineorigin) / linedirection;
+ vec3 secondplane = (vec3(-1.0) - lineorigin) / linedirection;
+ vec3 furthestplane = min(firstplane, secondplane);
+ return max_v3(furthestplane);
+}
+
+void volume_properties(vec3 ls_pos, out vec3 scattering, out float extinction)
+{
+ scattering = vec3(0.0);
+ extinction = 1e-8;
+
+ vec4 density = texture(densityTexture, ls_pos * 0.5 + 0.5);
+ density.rgb /= density.a;
+ density *= densityScale;
+
+ scattering = density.rgb;
+ extinction = max(1e-8, density.a);
+}
+
+#define P(x) ((x + 0.5) * (1.0 / 16.0))
+const vec4 dither_mat[4] = vec4[4](
+ vec4( P(0.0), P(8.0), P(2.0), P(10.0)),
+ vec4(P(12.0), P(4.0), P(14.0), P(6.0)),
+ vec4( P(3.0), P(11.0), P(1.0), P(9.0)),
+ vec4(P(15.0), P(7.0), P(13.0), P(5.0))
+);
+
+vec4 volume_integration(
+ vec3 ray_ori, vec3 ray_dir, float ray_inc, float ray_max, float step_len)
+{
+ /* Start with full transmittance and no scattered light. */
+ vec3 final_scattering = vec3(0.0);
+ float final_transmittance = 1.0;
+
+ ivec2 tx = ivec2(gl_FragCoord.xy) % 4;
+ float noise = dither_mat[tx.x][tx.y];
+
+ float ray_len = noise * ray_inc;
+ for (int i = 0; i < samplesLen && ray_len < ray_max; ++i, ray_len += ray_inc) {
+ vec3 ls_pos = ray_ori + ray_dir * ray_len;
+
+ vec3 Lscat;
+ float s_extinction;
+ volume_properties(ls_pos, Lscat, s_extinction);
+ /* Evaluate Scattering */
+ float Tr = exp(-s_extinction * step_len);
+ /* integrate along the current step segment */
+ Lscat = (Lscat - Lscat * Tr) / s_extinction;
+ /* accumulate and also take into account the transmittance from previous steps */
+ final_scattering += final_transmittance * Lscat;
+ final_transmittance *= Tr;
+ }
+
+ return vec4(final_scattering, 1.0 - final_transmittance);
+}
+
+void main()
+{
+#ifdef VOLUME_SLICE
+ /* Manual depth test. TODO remove. */
+ float depth = texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r;
+ if (gl_FragCoord.z >= depth) {
+ discard;
+ }
+
+ ivec3 volume_size = textureSize(densityTexture, 0);
+ float step_len;
+ if (sliceAxis == 0) {
+ step_len = float(volume_size.x);
+ }
+ else if (sliceAxis == 1) {
+ step_len = float(volume_size.y);
+ }
+ else {
+ step_len = float(volume_size.z);
+ }
+ /* FIXME Should be in world space but is in local space. */
+ step_len = 1.0 / step_len;
+
+ vec3 Lscat;
+ float s_extinction;
+ volume_properties(localPos, Lscat, s_extinction);
+ /* Evaluate Scattering */
+ float Tr = exp(-s_extinction * step_len);
+ /* integrate along the current step segment */
+ Lscat = (Lscat - Lscat * Tr) / s_extinction;
+
+ fragColor = vec4(Lscat, 1.0 - Tr);
+
+#else
+ vec2 screen_uv = gl_FragCoord.xy / vec2(textureSize(depthBuffer, 0).xy);
+ bool is_persp = ProjectionMatrix[3][3] == 0.0;
+
+ vec3 volume_center = ModelMatrix[3].xyz;
+
+ float depth = texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r;
+ float depth_end = min(depth, gl_FragCoord.z);
+ vec3 vs_ray_end = get_view_space_from_depth(screen_uv, depth_end);
+ vec3 vs_ray_ori = get_view_space_from_depth(screen_uv, 0.0);
+ vec3 vs_ray_dir = (is_persp) ? (vs_ray_end - vs_ray_ori) : vec3(0.0, 0.0, -1.0);
+ vs_ray_dir /= abs(vs_ray_dir.z);
+
+ vec3 ls_ray_dir = mat3(ModelViewMatrixInverse) * vs_ray_dir;
+ vec3 ls_ray_ori = (ModelViewMatrixInverse * vec4(vs_ray_ori, 1.0)).xyz;
+ vec3 ls_ray_end = (ModelViewMatrixInverse * vec4(vs_ray_end, 1.0)).xyz;
+
+ /* TODO: Align rays to volume center so that it mimics old behaviour of slicing the volume. */
+
+ float dist = line_unit_box_intersect_dist(ls_ray_ori, ls_ray_dir);
+ if (dist > 0.0) {
+ ls_ray_ori = ls_ray_dir * dist + ls_ray_ori;
+ }
+
+ vec3 ls_vol_isect = ls_ray_end - ls_ray_ori;
+ if (dot(ls_ray_dir, ls_vol_isect) < 0.0) {
+ /* Start is further away than the end.
+ * That means no volume is intersected. */
+ discard;
+ }
+
+ fragColor = volume_integration(ls_ray_ori, ls_ray_dir, stepLength,
+ length(ls_vol_isect) / length(ls_ray_dir),
+ length(vs_ray_dir) * stepLength);
+#endif
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl
new file mode 100644
index 00000000000..90a22d9d02f
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl
@@ -0,0 +1,31 @@
+
+uniform mat4 ModelViewProjectionMatrix;
+uniform float slicePosition;
+uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */
+
+in vec3 pos;
+
+#ifdef VOLUME_SLICE
+in vec3 uvs;
+
+out vec3 localPos;
+#endif
+
+void main()
+{
+#ifdef VOLUME_SLICE
+ if (sliceAxis == 0) {
+ localPos = vec3(slicePosition * 2.0 - 1.0, pos.xy);
+ }
+ else if (sliceAxis == 1) {
+ localPos = vec3(pos.x, slicePosition * 2.0 - 1.0, pos.y);
+ }
+ else {
+ localPos = vec3(pos.xy, slicePosition * 2.0 - 1.0);
+ }
+
+ gl_Position = ModelViewProjectionMatrix * vec4(localPos, 1.0);
+#else
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+#endif
+}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl
index 3eda4455487..82d0d1fcd02 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl
@@ -89,7 +89,6 @@ vec3 get_world_specular_light(vec4 specular_data, LightData light_data, vec3 N,
vec3 get_world_specular_lights(WorldData world_data, vec4 specular_data, vec3 N, vec3 I)
{
vec3 specular_light = vec3(0.0);
- specular_light += get_world_specular_light(specular_data, world_data.lights[0], N, I);
for (int i = 0 ; i < world_data.num_lights ; i ++) {
specular_light += get_world_specular_light(specular_data, world_data.lights[i], N, I);
}
diff --git a/source/blender/draw/engines/workbench/solid_mode.c b/source/blender/draw/engines/workbench/solid_mode.c
index b28263d48cf..5c64cebd981 100644
--- a/source/blender/draw/engines/workbench/solid_mode.c
+++ b/source/blender/draw/engines/workbench/solid_mode.c
@@ -30,6 +30,8 @@
#include "GPU_shader.h"
+#include "RE_pipeline.h"
+
#include "workbench_private.h"
/* Functions */
@@ -69,6 +71,7 @@ static void workbench_solid_draw_scene(void *vedata)
{
WORKBENCH_Data *data = vedata;
workbench_deferred_draw_scene(data);
+ workbench_deferred_draw_finish(data);
}
static void workbench_solid_engine_free(void)
@@ -82,6 +85,11 @@ static void workbench_solid_view_update(void *vedata)
workbench_taa_view_updated(data);
}
+static void workbench_render_to_image(void *vedata, RenderEngine *engine, RenderLayer *render_layer, const rcti *rect)
+{
+ workbench_render(vedata, engine, render_layer, rect);
+}
+
static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
DrawEngineType draw_engine_workbench_solid = {
@@ -97,5 +105,5 @@ DrawEngineType draw_engine_workbench_solid = {
&workbench_solid_draw_scene,
&workbench_solid_view_update,
NULL,
- NULL,
+ &workbench_render_to_image,
};
diff --git a/source/blender/draw/engines/workbench/transparent_mode.c b/source/blender/draw/engines/workbench/transparent_mode.c
index 3c4f7796c2b..195b8371165 100644
--- a/source/blender/draw/engines/workbench/transparent_mode.c
+++ b/source/blender/draw/engines/workbench/transparent_mode.c
@@ -76,6 +76,12 @@ static void workbench_transparent_engine_free(void)
workbench_forward_engine_free();
}
+static void workbench_transparent_view_update(void *vedata)
+{
+ WORKBENCH_Data *data = vedata;
+ workbench_taa_view_updated(data);
+}
+
static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
DrawEngineType draw_engine_workbench_transparent = {
@@ -89,7 +95,7 @@ DrawEngineType draw_engine_workbench_transparent = {
&workbench_transparent_cache_finish,
&workbench_transparent_draw_background,
&workbench_transparent_draw_scene,
- NULL,
+ &workbench_transparent_view_update,
NULL,
NULL,
};
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index 0f0d879aae8..5c3ab5f6688 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -19,37 +19,37 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wpd->user_preferences = &U;
View3D *v3d = draw_ctx->v3d;
- if (v3d) {
+ if (!v3d) {
+ wpd->shading = scene->display.shading;
+ }
+ else if (v3d->shading.type == OB_RENDER &&
+ BKE_scene_uses_blender_opengl(scene))
+ {
+ wpd->shading = scene->display.shading;
+ }
+ else {
wpd->shading = v3d->shading;
- if (wpd->shading.light == V3D_LIGHTING_MATCAP) {
- wpd->studio_light = BKE_studiolight_find(
- wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
- }
- else {
- wpd->studio_light = BKE_studiolight_find(
- wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD);
- }
+ }
+
+ if (wpd->shading.light == V3D_LIGHTING_MATCAP) {
+ wpd->studio_light = BKE_studiolight_find(
+ wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
}
else {
- memset(&wpd->shading, 0, sizeof(wpd->shading));
- wpd->shading.light = V3D_LIGHTING_STUDIO;
- wpd->shading.shadow_intensity = 0.5;
- copy_v3_fl(wpd->shading.single_color, 0.8f);
- wpd->studio_light = BKE_studiolight_find_first(STUDIOLIGHT_INTERNAL);
+ wpd->studio_light = BKE_studiolight_find(
+ wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD);
}
wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity;
WORKBENCH_UBO_World *wd = &wpd->world_data;
- wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) > 0;
- wd->background_alpha = 1.0f;
+ wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0;
+ wd->background_alpha = (v3d || scene->r.alphamode == R_ADDSKY) ? 1.0f : 0.0f;
- if ((v3d->flag3 & V3D_SHOW_WORLD) &&
- (scene->world != NULL))
- {
+ if (!v3d || ((v3d->flag3 & V3D_SHOW_WORLD) && (scene->world != NULL))) {
copy_v3_v3(wd->background_color_low, &scene->world->horr);
copy_v3_v3(wd->background_color_high, &scene->world->horr);
}
- else {
+ else if (v3d) {
UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD : TH_HIGH_GRAD, wd->background_color_low);
UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
@@ -58,6 +58,10 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
srgb_to_linearrgb_v3_v3(wd->background_color_high, wd->background_color_high);
srgb_to_linearrgb_v3_v3(wd->background_color_low, wd->background_color_low);
}
+ else {
+ zero_v3(wd->background_color_low);
+ zero_v3(wd->background_color_high);
+ }
studiolight_update_world(wpd->studio_light, wd);
@@ -119,9 +123,12 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wpd->viewvecs[1][2] = vec_far[2] - wpd->viewvecs[0][2];
}
}
+
+ wpd->volumes_do = false;
+ BLI_listbase_clear(&wpd->smoke_domains);
}
-void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float light_direction[3])
+void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float r_light_direction[3])
{
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
@@ -129,13 +136,16 @@ void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, floa
float view_matrix[4][4];
DRW_viewport_matrix_get(view_matrix, DRW_MAT_VIEW);
+ copy_v3_v3(r_light_direction, scene->display.light_direction);
+ negate_v3(r_light_direction);
+
{
WORKBENCH_UBO_Light *light = &wd->lights[0];
- mul_v3_mat3_m4v3(light->light_direction_vs, view_matrix, light_direction);
+ mul_v3_mat3_m4v3(light->light_direction_vs, view_matrix, r_light_direction);
light->light_direction_vs[3] = 0.0f;
copy_v3_fl(light->specular_color, 1.0f);
light->energy = 1.0f;
- copy_v4_v4(wd->light_direction_vs, light->light_direction_vs);
+ copy_v4_v4(wd->shadow_direction_vs, light->light_direction_vs);
wd->num_lights = 1;
}
@@ -154,8 +164,6 @@ void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, floa
wd->num_lights = light_index;
}
- copy_v3_v3(light_direction, scene->display.light_direction);
- negate_v3(light_direction);
DRW_uniformbuffer_update(wpd->world_ubo, wd);
}
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 1307f1c4446..4e90a08a543 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -33,6 +33,7 @@
#include "BLI_rand.h"
#include "BKE_node.h"
+#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "DNA_image_types.h"
@@ -258,9 +259,9 @@ static struct GPUTexture *create_jitter_texture(int num_samples)
/* Functions */
-static void workbench_init_object_data(ObjectEngineData *engine_data)
+static void workbench_init_object_data(DrawData *dd)
{
- WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)engine_data;
+ WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)dd;
data->object_id = ((e_data.next_object_id++) & 0xff) + 1;
data->shadow_bbox_dirty = true;
}
@@ -271,6 +272,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PassList *psl = vedata->psl;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ const DRWContextState *draw_ctx = DRW_context_state_get();
if (!stl->g_data) {
/* Alloc transient pointers */
@@ -327,12 +329,11 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
char *cavity_frag = workbench_build_cavity_frag();
e_data.cavity_sh = DRW_shader_create_fullscreen(cavity_frag, NULL);
MEM_freeN(cavity_frag);
-
}
+ workbench_volume_engine_init();
workbench_fxaa_engine_init();
workbench_taa_engine_init(vedata);
-
WORKBENCH_PrivateData *wpd = stl->g_data;
workbench_private_data_init(wpd);
@@ -370,6 +371,10 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx),
});
+ GPU_framebuffer_ensure_config(&fbl->volume_fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx),
+ });
GPU_framebuffer_ensure_config(&fbl->effect_fb, {
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.color_buffer_tx),
@@ -377,7 +382,6 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
}
{
- const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
/* AO Samples Tex */
int num_iterations = workbench_taa_calculate_num_iterations(vedata);
@@ -401,8 +405,10 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
/* Prepass */
{
+ const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING));
+
int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
- psl->prepass_pass = DRW_pass_create("Prepass", state);
+ psl->prepass_pass = DRW_pass_create("Prepass", (do_cull) ? state | DRW_STATE_CULL_BACK : state);
psl->prepass_hair_pass = DRW_pass_create("Prepass", state);
}
@@ -446,6 +452,7 @@ void workbench_deferred_engine_free(void)
DRW_SHADER_FREE_SAFE(e_data.shadow_caps_sh);
DRW_SHADER_FREE_SAFE(e_data.shadow_caps_manifold_sh);
+ workbench_volume_engine_free();
workbench_fxaa_engine_free();
workbench_taa_engine_free();
}
@@ -485,7 +492,10 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
Scene *scene = draw_ctx->scene;
+ workbench_volume_cache_init(vedata);
+
select_deferred_shaders(wpd);
+
/* Deferred Mix Pass */
{
workbench_private_data_get_light_direction(wpd, e_data.display.light_direction);
@@ -561,8 +571,8 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
WORKBENCH_MaterialData *material;
- WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_object_engine_data_ensure(
- ob, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL);
+ WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_drawdata_ensure(
+ &ob->id, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL);
WORKBENCH_MaterialData material_template;
/* Solid */
@@ -636,6 +646,9 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+
if (!DRW_object_is_renderable(ob))
return;
@@ -643,13 +656,22 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
workbench_cache_populate_particles(vedata, ob);
}
+ ModifierData *md;
+ if (((ob->base_flag & BASE_FROMDUPLI) == 0) &&
+ (md = modifiers_findByType(ob, eModifierType_Smoke)) &&
+ (modifier_isEnabled(scene, md, eModifierMode_Realtime)) &&
+ (((SmokeModifierData *)md)->domain != NULL))
+ {
+ workbench_volume_cache_populate(vedata, scene, ob, md);
+ return; /* Do not draw solid in this case. */
+ }
+
if (!DRW_check_object_visible_within_active_context(ob)) {
return;
}
WORKBENCH_MaterialData *material;
if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
- const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
bool is_drawn = false;
@@ -658,7 +680,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (me->mloopuv) {
const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
- struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
+ struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
if (materials_len > 0 && geom_array) {
for (int i = 0; i < materials_len; i++) {
if (geom_array[i] == NULL) {
@@ -681,7 +703,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (!is_drawn) {
if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) {
/* No material split needed */
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type);
if (is_sculpt_mode) {
@@ -699,7 +721,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
gpumat_array[i] = NULL;
}
- struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(
+ struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get(
ob, gpumat_array, materials_len, NULL, NULL, NULL);
if (mat_geom) {
for (int i = 0; i < materials_len; ++i) {
@@ -720,9 +742,9 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
}
}
- if (SHADOW_ENABLED(wpd) && (ob->display.flag & OB_SHOW_SHADOW) > 0) {
+ if (SHADOW_ENABLED(wpd) && (ob->display.flag & OB_SHOW_SHADOW)) {
bool is_manifold;
- struct Gwn_Batch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold);
+ struct GPUBatch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold);
if (geom_shadow) {
if (is_sculpt_mode) {
/* Currently unsupported in sculpt mode. We could revert to the slow
@@ -731,8 +753,8 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
// DRW_shgroup_call_sculpt_add(wpd->shadow_shgrp, ob, ob->obmat);
}
else {
- WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_object_engine_data_ensure(
- ob, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL);
+ WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_drawdata_ensure(
+ &ob->id, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL);
if (studiolight_object_cast_visible_shadow(wpd, ob, engine_object_data)) {
@@ -860,6 +882,19 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata)
DRW_draw_pass(psl->composite_pass);
}
+ if (wpd->volumes_do) {
+ GPU_framebuffer_bind(fbl->volume_fb);
+ DRW_draw_pass(psl->volume_pass);
+ }
+
workbench_aa_draw_pass(vedata, e_data.composite_buffer_tx);
+}
+
+void workbench_deferred_draw_finish(WORKBENCH_Data *vedata)
+{
+ WORKBENCH_StorageList *stl = vedata->stl;
+ WORKBENCH_PrivateData *wpd = stl->g_data;
+
workbench_private_data_free(wpd);
+ workbench_volume_smoke_textures_free(wpd);
}
diff --git a/source/blender/draw/engines/workbench/workbench_effect_aa.c b/source/blender/draw/engines/workbench/workbench_effect_aa.c
index 95a81649522..66f1de7f9fc 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_aa.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_aa.c
@@ -45,6 +45,18 @@ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx)
}
}
+static void workspace_aa_draw_transform(GPUTexture *tx)
+{
+ if (DRW_state_is_image_render()) {
+ /* Linear result for render. */
+ DRW_transform_none(tx);
+ }
+ else {
+ /* Display space result for viewport. */
+ DRW_transform_to_display(tx);
+ }
+}
+
void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx)
{
WORKBENCH_StorageList *stl = vedata->stl;
@@ -56,7 +68,7 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
if (FXAA_ENABLED(wpd)) {
GPU_framebuffer_bind(fbl->effect_fb);
- DRW_transform_to_display(tx);
+ workspace_aa_draw_transform(tx);
GPU_framebuffer_bind(dfbl->color_only_fb);
DRW_draw_pass(psl->effect_aa_pass);
}
@@ -67,14 +79,13 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx)
* the workbench_taa_draw_screen_end will fill the history buffer
* for the other iterations.
*/
- if (effect_info->jitter_index == 1)
- {
+ if (effect_info->jitter_index == 1) {
GPU_framebuffer_bind(dfbl->color_only_fb);
- DRW_transform_to_display(tx);
+ workspace_aa_draw_transform(tx);
}
else {
GPU_framebuffer_bind(fbl->effect_fb);
- DRW_transform_to_display(tx);
+ workspace_aa_draw_transform(tx);
GPU_framebuffer_bind(dfbl->color_only_fb);
DRW_draw_pass(psl->effect_aa_pass);
}
@@ -82,6 +93,6 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx)
}
else {
GPU_framebuffer_bind(dfbl->color_only_fb);
- DRW_transform_to_display(tx);
+ workspace_aa_draw_transform(tx);
}
}
diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c
index 0b4cc0a4e5b..403338d55c4 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_taa.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c
@@ -93,20 +93,23 @@ int workbench_taa_calculate_num_iterations(WORKBENCH_Data *vedata)
WORKBENCH_PrivateData *wpd = stl->g_data;
int result = 1;
if (TAA_ENABLED(wpd)) {
- if (IN_RANGE_INCL(
+ if (DRW_state_is_image_render()) {
+ const Scene *scene = DRW_context_state_get()->scene;
+ result = (scene->r.mode & R_OSA) ? scene->r.osa : 1;
+ }
+ else if (IN_RANGE_INCL(
wpd->user_preferences->gpu_viewport_quality,
GPU_VIEWPORT_QUALITY_TAA8, GPU_VIEWPORT_QUALITY_TAA16))
{
result = 8;
}
else if (IN_RANGE_INCL(
- wpd->user_preferences->gpu_viewport_quality,
- GPU_VIEWPORT_QUALITY_TAA16, GPU_VIEWPORT_QUALITY_TAA32))
+ wpd->user_preferences->gpu_viewport_quality,
+ GPU_VIEWPORT_QUALITY_TAA16, GPU_VIEWPORT_QUALITY_TAA32))
{
result = 16;
}
- else
- {
+ else {
result = 32;
}
}
@@ -277,16 +280,23 @@ void workbench_taa_draw_scene_end(WORKBENCH_Data *vedata)
GPU_framebuffer_blit(dfbl->color_only_fb, 0, fbl->effect_taa_fb, 0, GPU_COLOR_BIT);
- DRW_viewport_matrix_override_unset_all();
+ if (!DRW_state_is_image_render()) {
+ DRW_viewport_matrix_override_unset_all();
+ }
copy_m4_m4(effect_info->last_mat, effect_info->curr_mat);
- if (effect_info->jitter_index != 0) {
+ if (effect_info->jitter_index != 0 && !DRW_state_is_image_render()) {
DRW_viewport_request_redraw();
}
}
void workbench_taa_view_updated(WORKBENCH_Data *vedata)
{
- WORKBENCH_EffectInfo *effect_info = vedata->stl->effects;
- effect_info->view_updated = true;
+ WORKBENCH_StorageList *stl = vedata->stl;
+ if (stl) {
+ WORKBENCH_EffectInfo *effect_info = stl->effects;
+ if (effect_info) {
+ effect_info->view_updated = true;
+ }
+ }
}
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
index 26ae1c289c8..642c5820895 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.c
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -29,16 +29,16 @@
#include "DRW_render.h"
#include "workbench_engine.h"
-/* Shaders */
-
-#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
+#include "workbench_private.h"
+#define OPENGL_ENGINE "BLENDER_OPENGL"
/* Note: currently unused, we may want to register so we can see this when debugging the view. */
-RenderEngineType DRW_engine_viewport_workbench_type = {
+RenderEngineType DRW_engine_viewport_opengl_type = {
NULL, NULL,
- WORKBENCH_ENGINE, N_("Workbench"), RE_INTERNAL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ OPENGL_ENGINE, N_("OpenGL"), RE_INTERNAL,
+ NULL, &DRW_render_to_image, NULL, NULL, NULL, NULL,
+ &workbench_render_update_passes,
&draw_engine_workbench_solid,
{NULL, NULL, NULL}
};
diff --git a/source/blender/draw/engines/workbench/workbench_engine.h b/source/blender/draw/engines/workbench/workbench_engine.h
index a7f168db093..24f68cacd21 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.h
+++ b/source/blender/draw/engines/workbench/workbench_engine.h
@@ -28,6 +28,6 @@
extern DrawEngineType draw_engine_workbench_solid;
extern DrawEngineType draw_engine_workbench_transparent;
-extern RenderEngineType DRW_engine_viewport_workbench_type;
+extern RenderEngineType DRW_engine_viewport_opengl_type;
#endif /* __WORKBENCH_ENGINE_H__ */
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index 76172443c2d..825b80ace52 100644
--- a/source/blender/draw/engines/workbench/workbench_forward.c
+++ b/source/blender/draw/engines/workbench/workbench_forward.c
@@ -33,6 +33,7 @@
#include "BKE_node.h"
#include "BKE_particle.h"
+#include "BKE_modifier.h"
#include "DNA_image_types.h"
#include "DNA_mesh_types.h"
@@ -126,9 +127,9 @@ static char *workbench_build_forward_composite_frag(void)
return str;
}
-static void workbench_init_object_data(ObjectEngineData *engine_data)
+static void workbench_init_object_data(DrawData *dd)
{
- WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)engine_data;
+ WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)dd;
data->object_id = ((e_data.next_object_id++) & 0xff) + 1;
}
@@ -139,8 +140,8 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
WORKBENCH_MaterialData *material;
- WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_object_engine_data_ensure(
- ob, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL);
+ WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_drawdata_ensure(
+ &ob->id, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL);
WORKBENCH_MaterialData material_template;
DRWShadingGroup *grp;
@@ -176,14 +177,15 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
material->shgrp = grp;
/* Depth */
- if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR)
- {
- material->shgrp_object_outline = DRW_shgroup_create(e_data.object_outline_texture_sh, psl->object_outline_pass);
+ if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR) {
+ material->shgrp_object_outline = DRW_shgroup_create(
+ e_data.object_outline_texture_sh, psl->object_outline_pass);
GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false, 0.0f);
DRW_shgroup_uniform_texture(material->shgrp_object_outline, "image", tex);
}
else {
- material->shgrp_object_outline = DRW_shgroup_create(e_data.object_outline_sh, psl->object_outline_pass);
+ material->shgrp_object_outline = DRW_shgroup_create(
+ e_data.object_outline_sh, psl->object_outline_pass);
}
material->object_id = engine_object_data->object_id;
DRW_shgroup_uniform_int(material->shgrp_object_outline, "object_id", &material->object_id, 1);
@@ -241,14 +243,15 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_StorageList *stl = vedata->stl;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ const DRWContextState *draw_ctx = DRW_context_state_get();
DRWShadingGroup *grp;
if (!stl->g_data) {
/* Alloc transient pointers */
- stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__);
}
if (!stl->effects) {
- stl->effects = MEM_mallocN(sizeof(*stl->effects), __func__);
+ stl->effects = MEM_callocN(sizeof(*stl->effects), __func__);
workbench_effect_info_init(stl->effects);
}
WORKBENCH_PrivateData *wpd = stl->g_data;
@@ -283,6 +286,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
MEM_freeN(defines_texture);
MEM_freeN(defines_hair);
}
+ workbench_volume_engine_init();
workbench_fxaa_engine_init();
workbench_taa_engine_init(vedata);
@@ -304,13 +308,11 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx),
});
-
GPU_framebuffer_ensure_config(&fbl->transparent_accum_fb, {
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.transparent_accum_tx),
GPU_ATTACHMENT_TEXTURE(e_data.transparent_revealage_tx),
});
-
GPU_framebuffer_ensure_config(&fbl->composite_fb, {
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx),
@@ -320,14 +322,18 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
GPU_ATTACHMENT_TEXTURE(e_data.transparent_accum_tx),
});
+ workbench_volume_cache_init(vedata);
+ const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING));
+ const int cull_state = (do_cull) ? DRW_STATE_CULL_BACK : 0;
+
/* Transparency Accum */
{
- int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT;
+ int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT | cull_state;
psl->transparent_accum_pass = DRW_pass_create("Transparent Accum", state);
}
/* Depth */
{
- int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | cull_state;
psl->object_outline_pass = DRW_pass_create("Object Outline Pass", state);
}
/* Composite */
@@ -371,7 +377,9 @@ void workbench_forward_engine_free()
DRW_SHADER_FREE_SAFE(e_data.object_outline_hair_sh);
DRW_SHADER_FREE_SAFE(e_data.checker_depth_sh);
+ workbench_volume_engine_free();
workbench_fxaa_engine_free();
+ workbench_taa_engine_free();
}
void workbench_forward_cache_init(WORKBENCH_Data *UNUSED(vedata))
@@ -443,6 +451,8 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
{
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PrivateData *wpd = stl->g_data;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
if (!DRW_object_is_renderable(ob))
return;
@@ -451,13 +461,22 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
workbench_forward_cache_populate_particles(vedata, ob);
}
+ ModifierData *md;
+ if (((ob->base_flag & BASE_FROMDUPLI) == 0) &&
+ (md = modifiers_findByType(ob, eModifierType_Smoke)) &&
+ (modifier_isEnabled(scene, md, eModifierMode_Realtime)) &&
+ (((SmokeModifierData *)md)->domain != NULL))
+ {
+ workbench_volume_cache_populate(vedata, scene, ob, md);
+ return; /* Do not draw solid in this case. */
+ }
+
if (!DRW_check_object_visible_within_active_context(ob)) {
return;
}
WORKBENCH_MaterialData *material;
if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
- const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
bool is_drawn = false;
@@ -467,7 +486,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (me->mloopuv) {
const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
- struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
+ struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
if (materials_len > 0 && geom_array) {
for (int i = 0; i < materials_len; i++) {
if (geom_array[i] == NULL) {
@@ -500,7 +519,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (!is_drawn) {
if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) {
/* No material split needed */
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type);
if (is_sculpt_mode) {
@@ -520,7 +539,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
gpumat_array[i] = NULL;
}
- struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(
+ struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get(
ob, gpumat_array, materials_len, NULL, NULL, NULL);
if (mat_geom) {
for (int i = 0; i < materials_len; ++i) {
@@ -594,6 +613,7 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata)
/* Composite */
GPU_framebuffer_bind(fbl->composite_fb);
DRW_draw_pass(psl->composite_pass);
+ DRW_draw_pass(psl->volume_pass);
/* Color correct and Anti aliasing */
workbench_aa_draw_pass(vedata, e_data.composite_buffer_tx);
@@ -603,4 +623,5 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata)
DRW_draw_pass(psl->checker_depth_pass);
workbench_private_data_free(wpd);
+ workbench_volume_smoke_textures_free(wpd);
}
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 6755bf82ecd..54e8aa1c3b3 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -129,8 +129,7 @@ uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template)
result += BLI_ghashutil_uinthash_v4_murmur(input);
/* add texture reference */
- if (material_template->ima)
- {
+ if (material_template->ima) {
result += BLI_ghashutil_inthash_p_murmur(material_template->ima);
}
@@ -182,10 +181,10 @@ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *i
return color_type;
}
-void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material)
+void workbench_material_shgroup_uniform(
+ WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material)
{
- if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR)
- {
+ if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR) {
GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false, 0.0f);
DRW_shgroup_uniform_texture(grp, "image", tex);
}
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 3bec6bb6d53..99d1b7060fd 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -36,12 +36,13 @@
#include "DRW_render.h"
+#include "workbench_engine.h"
#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
#define M_GOLDEN_RATION_CONJUGATE 0.618033988749895
#define MAX_SHADERS (1 << 10)
-#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->color_type & V3D_SHADING_TEXTURE_COLOR)
+#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->shading.color_type & V3D_SHADING_TEXTURE_COLOR)
#define FLAT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_FLAT)
#define STUDIOLIGHT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_STUDIO)
#define MATCAP_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_MATCAP)
@@ -51,7 +52,7 @@
#define CAVITY_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_CAVITY)
#define SHADOW_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_SHADOW)
-#define IS_NAVIGATING(wpd) (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING)
+#define IS_NAVIGATING(wpd) ((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING))
#define FXAA_ENABLED(wpd) ((!DRW_state_is_opengl_render()) && (IN_RANGE(wpd->user_preferences->gpu_viewport_quality, GPU_VIEWPORT_QUALITY_FXAA, GPU_VIEWPORT_QUALITY_TAA8) || ((wpd->user_preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8) && IS_NAVIGATING(wpd))))
#define TAA_ENABLED(wpd) (wpd->user_preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 && !IS_NAVIGATING(wpd))
#define SPECULAR_HIGHLIGHT_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && (!STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)))
@@ -59,7 +60,11 @@
#define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd) || SPECULAR_HIGHLIGHT_ENABLED(wpd))
#define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) || CAVITY_ENABLED(wpd))
#define NORMAL_ENCODING_ENABLED() (true)
-#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->color_type & V3D_SHADING_TEXTURE_COLOR)
+
+
+struct RenderEngine;
+struct RenderLayer;
+struct rcti;
typedef struct WORKBENCH_FramebufferList {
@@ -71,6 +76,7 @@ typedef struct WORKBENCH_FramebufferList {
struct GPUFrameBuffer *effect_fb;
struct GPUFrameBuffer *effect_taa_fb;
struct GPUFrameBuffer *depth_buffer_fb;
+ struct GPUFrameBuffer *volume_fb;
/* Forward render buffers */
struct GPUFrameBuffer *object_outline_fb;
@@ -102,6 +108,7 @@ typedef struct WORKBENCH_PassList {
struct DRWPass *composite_pass;
struct DRWPass *composite_shadow_pass;
struct DRWPass *effect_aa_pass;
+ struct DRWPass *volume_pass;
/* forward rendering */
struct DRWPass *transparent_accum_pass;
@@ -129,7 +136,7 @@ typedef struct WORKBENCH_UBO_World {
float background_color_low[4];
float background_color_high[4];
float object_outline_color[4];
- float light_direction_vs[4];
+ float shadow_direction_vs[4];
WORKBENCH_UBO_Light lights[3];
int num_lights;
int matcap_orientation;
@@ -153,7 +160,6 @@ typedef struct WORKBENCH_PrivateData {
View3DShading shading;
StudioLight *studio_light;
UserDef *user_preferences;
- int color_type;
struct GPUUniformBuffer *world_ubo;
struct DRWShadingGroup *shadow_shgrp;
struct DRWShadingGroup *depth_shgrp;
@@ -169,6 +175,10 @@ typedef struct WORKBENCH_PrivateData {
float shadow_near_sides[2][4]; /* This is a parallelogram, so only 2 normal and distance to the edges. */
bool shadow_changed;
+ /* Volumes */
+ bool volumes_do;
+ ListBase smoke_domains;
+
/* Ssao */
float winmat[4][4];
float viewvecs[3][4];
@@ -203,12 +213,8 @@ typedef struct WORKBENCH_MaterialData {
} WORKBENCH_MaterialData;
typedef struct WORKBENCH_ObjectData {
- struct ObjectEngineData *next, *prev;
- struct DrawEngineType *engine_type;
- /* Only nested data, NOT the engine data itself. */
- ObjectEngineDataFreeCb free;
- /* Accumulated recalc flags, which corresponds to ID->recalc flags. */
- int recalc;
+ DrawData dd;
+
/* Shadow direction in local object space. */
float shadow_dir[3], shadow_depth;
float shadow_min[3], shadow_max[3]; /* Min, max in shadow space */
@@ -231,6 +237,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata);
void workbench_deferred_engine_free(void);
void workbench_deferred_draw_background(WORKBENCH_Data *vedata);
void workbench_deferred_draw_scene(WORKBENCH_Data *vedata);
+void workbench_deferred_draw_finish(WORKBENCH_Data *vedata);
void workbench_deferred_cache_init(WORKBENCH_Data *vedata);
void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob);
void workbench_deferred_cache_finish(WORKBENCH_Data *vedata);
@@ -284,9 +291,17 @@ bool studiolight_camera_in_object_shadow(WORKBENCH_PrivateData *wpd, Object *ob,
void workbench_effect_info_init(WORKBENCH_EffectInfo *effect_info);
void workbench_private_data_init(WORKBENCH_PrivateData *wpd);
void workbench_private_data_free(WORKBENCH_PrivateData *wpd);
-void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float light_direction[3]);
-
-extern DrawEngineType draw_engine_workbench_solid;
-extern DrawEngineType draw_engine_workbench_transparent;
+void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float r_light_direction[3]);
+
+/* workbench_volume.c */
+void workbench_volume_engine_init(void);
+void workbench_volume_engine_free(void);
+void workbench_volume_cache_init(WORKBENCH_Data *vedata);
+void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Object *ob, struct ModifierData *md);
+void workbench_volume_smoke_textures_free(WORKBENCH_PrivateData *wpd);
+
+/* workbench_render.c */
+void workbench_render(WORKBENCH_Data *vedata, struct RenderEngine *engine, struct RenderLayer *render_layer, const struct rcti *rect);
+void workbench_render_update_passes(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer);
#endif
diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c
new file mode 100644
index 00000000000..1b25d4c875c
--- /dev/null
+++ b/source/blender/draw/engines/workbench/workbench_render.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2016, 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(s): Blender Institute
+ *
+ */
+
+/** \file workbench_render.c
+ * \ingroup draw_engine
+ *
+ * Render functions for final render output.
+ */
+
+#include "BLI_rect.h"
+
+#include "BKE_report.h"
+
+#include "DRW_render.h"
+
+#include "GPU_shader.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
+#include "RE_pipeline.h"
+
+#include "workbench_private.h"
+
+static void workbench_render_cache(
+ void *vedata, struct Object *ob,
+ struct RenderEngine *UNUSED(engine), struct Depsgraph *UNUSED(depsgraph))
+{
+ workbench_deferred_solid_cache_populate(vedata, ob);
+}
+
+static void workbench_render_matrices_init(RenderEngine *engine, Depsgraph *depsgraph)
+{
+ /* TODO(sergey): Shall render hold pointer to an evaluated camera instead? */
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ struct Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, RE_GetCamera(engine->re));
+ float frame = BKE_scene_frame_get(scene);
+
+ /* Set the persective, view and window matrix. */
+ float winmat[4][4], wininv[4][4];
+ float viewmat[4][4], viewinv[4][4];
+ float persmat[4][4], persinv[4][4];
+
+ RE_GetCameraWindow(engine->re, ob_camera_eval, frame, winmat);
+ RE_GetCameraModelMatrix(engine->re, ob_camera_eval, viewinv);
+
+ invert_m4_m4(viewmat, viewinv);
+ mul_m4_m4m4(persmat, winmat, viewmat);
+ invert_m4_m4(persinv, persmat);
+ invert_m4_m4(wininv, winmat);
+
+ DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS);
+ DRW_viewport_matrix_override_set(persinv, DRW_MAT_PERSINV);
+ DRW_viewport_matrix_override_set(winmat, DRW_MAT_WIN);
+ DRW_viewport_matrix_override_set(wininv, DRW_MAT_WININV);
+ DRW_viewport_matrix_override_set(viewmat, DRW_MAT_VIEW);
+ DRW_viewport_matrix_override_set(viewinv, DRW_MAT_VIEWINV);
+}
+
+static bool workbench_render_framebuffers_init(void)
+{
+ /* For image render, allocate own buffers because we don't have a viewport. */
+ const float *viewport_size = DRW_viewport_size_get();
+ const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
+
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ dtxl->color = GPU_texture_create_2D(size[0], size[1], GPU_RGBA8, NULL, NULL);
+ dtxl->depth = GPU_texture_create_2D(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL);
+
+ if (!(dtxl->depth && dtxl->color)) {
+ return false;
+ }
+
+ DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+
+ GPU_framebuffer_ensure_config(&dfbl->default_fb, {
+ GPU_ATTACHMENT_TEXTURE(dtxl->depth),
+ GPU_ATTACHMENT_TEXTURE(dtxl->color)
+ });
+
+ GPU_framebuffer_ensure_config(&dfbl->depth_only_fb, {
+ GPU_ATTACHMENT_TEXTURE(dtxl->depth),
+ GPU_ATTACHMENT_NONE
+ });
+
+ GPU_framebuffer_ensure_config(&dfbl->color_only_fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(dtxl->color)
+ });
+
+ bool ok = true;
+ ok = ok && GPU_framebuffer_check_valid(dfbl->default_fb, NULL);
+ ok = ok && GPU_framebuffer_check_valid(dfbl->color_only_fb, NULL);
+ ok = ok && GPU_framebuffer_check_valid(dfbl->depth_only_fb, NULL);
+
+ return ok;
+}
+
+static void workbench_render_framebuffers_finish(void)
+{
+}
+
+void workbench_render(WORKBENCH_Data *data, RenderEngine *engine, RenderLayer *render_layer, const rcti *rect)
+{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+
+ Depsgraph *depsgraph = draw_ctx->depsgraph;
+ workbench_render_matrices_init(engine, depsgraph);
+
+ if (!workbench_render_framebuffers_init()) {
+ RE_engine_report(engine, RPT_ERROR, "Failed to allocate OpenGL buffers");
+ return;
+ }
+
+ /* Init engine. */
+ workbench_deferred_engine_init(data);
+
+ /* Init objects. */
+ workbench_deferred_cache_init(data);
+ DRW_render_object_iter(data, engine, depsgraph, workbench_render_cache);
+ workbench_deferred_cache_finish(data);
+ DRW_render_instance_buffer_finish();
+
+ /* Draw. */
+ int num_samples = workbench_taa_calculate_num_iterations(data);
+ for (int sample = 0; sample < num_samples; sample++) {
+ if (RE_engine_test_break(engine)) {
+ break;
+ }
+
+ workbench_deferred_draw_background(data);
+ workbench_deferred_draw_scene(data);
+ }
+
+ workbench_deferred_draw_finish(data);
+
+ /* Write render output. */
+ const char *viewname = RE_GetActiveRenderView(engine->re);
+ RenderPass *rp = RE_pass_find_by_name(render_layer, RE_PASSNAME_COMBINED, viewname);
+
+ DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+ GPU_framebuffer_bind(dfbl->color_only_fb);
+ GPU_framebuffer_read_color(dfbl->color_only_fb,
+ rect->xmin, rect->ymin,
+ BLI_rcti_size_x(rect), BLI_rcti_size_y(rect),
+ 4, 0, rp->rect);
+
+ workbench_render_framebuffers_finish();
+}
+
+void workbench_render_update_passes(RenderEngine *engine, Scene *scene, ViewLayer *view_layer)
+{
+ RE_engine_register_pass(engine, scene, view_layer, RE_PASSNAME_COMBINED, 4, "RGBA", SOCK_RGBA);
+}
diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c
new file mode 100644
index 00000000000..ea4152486af
--- /dev/null
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2018, 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(s): Blender Institute
+ *
+ */
+
+/** \file workbench_volume.c
+ * \ingroup draw_engine
+ */
+
+#include "workbench_private.h"
+
+#include "BKE_modifier.h"
+
+#include "DNA_modifier_types.h"
+#include "DNA_object_force_types.h"
+#include "DNA_smoke_types.h"
+
+#include "GPU_draw.h"
+
+static struct {
+ struct GPUShader *volume_sh;
+ struct GPUShader *volume_slice_sh;
+} e_data = {NULL};
+
+extern char datatoc_workbench_volume_vert_glsl[];
+extern char datatoc_workbench_volume_frag_glsl[];
+
+void workbench_volume_engine_init(void)
+{
+ if (!e_data.volume_sh) {
+ e_data.volume_sh = DRW_shader_create(
+ datatoc_workbench_volume_vert_glsl, NULL,
+ datatoc_workbench_volume_frag_glsl, NULL);
+ e_data.volume_slice_sh = DRW_shader_create(
+ datatoc_workbench_volume_vert_glsl, NULL,
+ datatoc_workbench_volume_frag_glsl, "#define VOLUME_SLICE");
+ }
+}
+
+void workbench_volume_engine_free(void)
+{
+ DRW_SHADER_FREE_SAFE(e_data.volume_sh);
+ DRW_SHADER_FREE_SAFE(e_data.volume_slice_sh);
+}
+
+void workbench_volume_cache_init(WORKBENCH_Data *vedata)
+{
+ vedata->psl->volume_pass = DRW_pass_create("Volumes", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_PREMUL | DRW_STATE_CULL_FRONT);
+}
+
+void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Object *ob, ModifierData *md)
+{
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ SmokeDomainSettings *sds = smd->domain;
+ WORKBENCH_PrivateData *wpd = vedata->stl->g_data;
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+
+ /* Don't show smoke before simulation starts, this could be made an option in the future. */
+ if (!sds->fluid || CFRA < sds->point_cache[0]->startframe) {
+ return;
+ }
+
+ wpd->volumes_do = true;
+
+ if (!sds->wt || !(sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
+ GPU_create_smoke(smd, 0);
+ }
+ else if (sds->wt && (sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
+ GPU_create_smoke(smd, 1);
+ }
+
+ if (sds->tex == NULL) {
+ return;
+ }
+
+ if (sds->slice_method == MOD_SMOKE_SLICE_AXIS_ALIGNED &&
+ sds->axis_slice_method == AXIS_SLICE_SINGLE)
+ {
+ float invviewmat[4][4];
+ DRW_viewport_matrix_get(invviewmat, DRW_MAT_VIEWINV);
+
+ const int axis = (sds->slice_axis == SLICE_AXIS_AUTO)
+ ? axis_dominant_v3_single(invviewmat[2])
+ : sds->slice_axis - 1;
+
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.volume_slice_sh, vedata->psl->volume_pass);
+ DRW_shgroup_uniform_texture(grp, "densityTexture", sds->tex);
+ DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
+ DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * sds->display_thickness);
+ DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth);
+ DRW_shgroup_uniform_int_copy(grp, "sliceAxis", axis);
+ DRW_shgroup_state_disable(grp, DRW_STATE_CULL_FRONT);
+ BLI_addtail(&wpd->smoke_domains, BLI_genericNodeN(smd));
+
+ /* TODO Flame rendering */
+ /* TODO COBA Rendering */
+
+ DRW_shgroup_call_object_add(grp, DRW_cache_quad_get(), ob);
+ }
+ else {
+ int max_slices = max_iii(sds->res[0], sds->res[1], sds->res[2]) * sds->slice_per_voxel;
+
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.volume_sh, vedata->psl->volume_pass);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
+ DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
+ DRW_shgroup_uniform_texture(grp, "densityTexture", sds->tex);
+ DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * sds->display_thickness);
+ DRW_shgroup_uniform_int_copy(grp, "samplesLen", max_slices);
+ /* TODO FIXME : This step size is in object space but the ray itself
+ * is NOT unit length in object space so the required number of subdivisions
+ * is tricky to get. */
+ DRW_shgroup_uniform_float_copy(grp, "stepLength", 8.0f / max_slices);
+ DRW_shgroup_state_enable(grp, DRW_STATE_CULL_FRONT);
+ BLI_addtail(&wpd->smoke_domains, BLI_genericNodeN(smd));
+
+ /* TODO Flame rendering */
+ /* TODO COBA Rendering */
+
+ DRW_shgroup_call_object_add(grp, DRW_cache_cube_get(), ob);
+ }
+}
+
+void workbench_volume_smoke_textures_free(WORKBENCH_PrivateData *wpd)
+{
+ /* Free Smoke Textures after rendering */
+ /* XXX This is a waste of processing and GPU bandwidth if nothing
+ * is updated. But the problem is since Textures are stored in the
+ * modifier we don't want them to take precious VRAM if the
+ * modifier is not used for display. We should share them for
+ * all viewport in a redraw at least. */
+ for (LinkData *link = wpd->smoke_domains.first; link; link = link->next) {
+ SmokeModifierData *smd = (SmokeModifierData *)link->data;
+ GPU_free_smoke(smd);
+ }
+ BLI_freelistN(&wpd->smoke_domains);
+}
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index d6187e32036..adcfe2524c7 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -44,6 +44,7 @@
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_scene_types.h"
+#include "DNA_world_types.h"
#include "GPU_framebuffer.h"
#include "GPU_texture.h"
@@ -54,6 +55,7 @@
#include "draw_view.h"
#include "draw_manager_profiling.h"
+#include "draw_debug.h"
#include "MEM_guardedalloc.h"
@@ -69,7 +71,7 @@ struct GPUMaterial;
struct GPUTexture;
struct GPUUniformBuffer;
struct Object;
-struct Gwn_Batch;
+struct GPUBatch;
struct DefaultFramebufferList;
struct DefaultTextureList;
struct DRWTextStore;
@@ -224,6 +226,7 @@ void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo);
} while (0)
void DRW_transform_to_display(struct GPUTexture *tex);
+void DRW_transform_none(struct GPUTexture *tex);
void DRW_multisamples_resolve(
struct GPUTexture *src_depth, struct GPUTexture *src_color);
@@ -239,14 +242,14 @@ struct GPUShader *DRW_shader_create_2D(const char *frag, const char *defines);
struct GPUShader *DRW_shader_create_3D(const char *frag, const char *defines);
struct GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines);
struct GPUShader *DRW_shader_create_3D_depth_only(void);
-struct GPUMaterial *DRW_shader_find_from_world(struct World *wo, const void *engine_type, int options);
-struct GPUMaterial *DRW_shader_find_from_material(struct Material *ma, const void *engine_type, int options);
+struct GPUMaterial *DRW_shader_find_from_world(struct World *wo, const void *engine_type, int options, bool no_deferred);
+struct GPUMaterial *DRW_shader_find_from_material(struct Material *ma, const void *engine_type, int options, bool no_deferred);
struct GPUMaterial *DRW_shader_create_from_world(
struct Scene *scene, struct World *wo, const void *engine_type, int options,
- const char *vert, const char *geom, const char *frag_lib, const char *defines);
+ const char *vert, const char *geom, const char *frag_lib, const char *defines, bool no_deferred);
struct GPUMaterial *DRW_shader_create_from_material(
struct Scene *scene, struct Material *ma, const void *engine_type, int options,
- const char *vert, const char *geom, const char *frag_lib, const char *defines);
+ const char *vert, const char *geom, const char *frag_lib, const char *defines, bool no_deferred);
void DRW_shader_free(struct GPUShader *shader);
#define DRW_SHADER_FREE_SAFE(shader) do { \
if (shader != NULL) { \
@@ -303,7 +306,7 @@ typedef struct DRWInstanceAttribFormat {
int components;
} DRWInstanceAttribFormat;
-struct Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize);
+struct GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize);
#define DRW_shgroup_instance_format(format, ...) do { \
if (format == NULL) { \
DRWInstanceAttribFormat drw_format[] = __VA_ARGS__;\
@@ -314,25 +317,25 @@ struct Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrib
DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass);
DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass);
DRWShadingGroup *DRW_shgroup_material_instance_create(
- struct GPUMaterial *material, DRWPass *pass, struct Gwn_Batch *geom, struct Object *ob,
- struct Gwn_VertFormat *format);
+ struct GPUMaterial *material, DRWPass *pass, struct GPUBatch *geom, struct Object *ob,
+ struct GPUVertFormat *format);
DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create(struct GPUMaterial *material, DRWPass *pass, int size);
DRWShadingGroup *DRW_shgroup_instance_create(
- struct GPUShader *shader, DRWPass *pass, struct Gwn_Batch *geom, struct Gwn_VertFormat *format);
+ struct GPUShader *shader, DRWPass *pass, struct GPUBatch *geom, struct GPUVertFormat *format);
DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass);
DRWShadingGroup *DRW_shgroup_line_batch_create_with_format(
- struct GPUShader *shader, DRWPass *pass, struct Gwn_VertFormat *format);
+ struct GPUShader *shader, DRWPass *pass, struct GPUVertFormat *format);
DRWShadingGroup *DRW_shgroup_line_batch_create(
struct GPUShader *shader, DRWPass *pass);
DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(
struct GPUShader *shader, DRWPass *pass, int size);
DRWShadingGroup *DRW_shgroup_transform_feedback_create(
- struct GPUShader *shader, DRWPass *pass, struct Gwn_VertBuf *tf_target);
+ struct GPUShader *shader, DRWPass *pass, struct GPUVertBuf *tf_target);
typedef void (DRWCallGenerateFn)(
DRWShadingGroup *shgroup,
- void (*draw_fn)(DRWShadingGroup *shgroup, struct Gwn_Batch *geom),
+ void (*draw_fn)(DRWShadingGroup *shgroup, struct GPUBatch *geom),
void *user_data);
/* return final visibility */
@@ -340,27 +343,27 @@ typedef bool (DRWCallVisibilityFn)(
bool vis_in,
void *user_data);
-void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batch);
+void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch);
void DRW_shgroup_free(struct DRWShadingGroup *shgroup);
-void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]);
+void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4]);
void DRW_shgroup_call_range_add(
- DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count);
-void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, unsigned int point_count, float (*obmat)[4]);
-void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, unsigned int line_count, float (*obmat)[4]);
-void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, unsigned int tria_count, float (*obmat)[4]);
+ DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_count);
+void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]);
+void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]);
+void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]);
void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, struct Object *ob);
-void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, bool bypass_culling);
+void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, bool bypass_culling);
#define DRW_shgroup_call_object_add(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, false)
#define DRW_shgroup_call_object_add_no_cull(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, true)
void DRW_shgroup_call_object_add_with_callback(
- DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob,
+ DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob,
DRWCallVisibilityFn *callback, void *user_data);
/* Used for drawing a batch with instancing without instance attribs. */
void DRW_shgroup_call_instances_add(
- DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint *count);
+ DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint *count);
void DRW_shgroup_call_object_instances_add(
- DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, uint *count);
+ DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, uint *count);
void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shgroup, struct Object *ob, float (*obmat)[4]);
void DRW_shgroup_call_generate_add(
DRWShadingGroup *shgroup, DRWCallGenerateFn *geometry_fn, void *user_data, float (*obmat)[4]);
@@ -409,6 +412,7 @@ void DRW_pass_sort_shgroup_z(DRWPass *pass);
/* Viewport */
typedef enum {
+ /* keep in sync with the union struct DRWMatrixState. */
DRW_MAT_PERS = 0,
DRW_MAT_PERSINV,
DRW_MAT_VIEW,
@@ -420,7 +424,18 @@ typedef enum {
} DRWViewportMatrixType;
typedef struct DRWMatrixState {
- float mat[DRW_MAT_COUNT][4][4];
+ union {
+ float mat[DRW_MAT_COUNT][4][4];
+ struct {
+ /* keep in sync with the enum DRWViewportMatrixType. */
+ float persmat[4][4];
+ float persinv[4][4];
+ float viewmat[4][4];
+ float viewinv[4][4];
+ float winmat[4][4];
+ float wininv[4][4];
+ };
+ };
} DRWMatrixState;
void DRW_viewport_init(const bContext *C);
@@ -431,7 +446,7 @@ void DRW_viewport_matrix_override_set_all(DRWMatrixState *state);
void DRW_viewport_matrix_override_unset(DRWViewportMatrixType type);
void DRW_viewport_matrix_override_unset_all(void);
-/* Thoses are in viewspace so negative if in persp.
+/* These are in view-space so negative if in perspective.
* Extract near and far clip distance from the projection matrix. */
float DRW_viewport_near_distance_get(void);
float DRW_viewport_far_distance_get(void);
@@ -453,6 +468,12 @@ void DRW_render_object_iter(
void (*callback)(void *vedata, struct Object *ob, struct RenderEngine *engine, struct Depsgraph *depsgraph));
void DRW_render_instance_buffer_finish(void);
+void DRW_custom_pipeline(
+ DrawEngineType *draw_engine_type,
+ struct Depsgraph *depsgraph,
+ void (*callback)(void *vedata, void *user_data),
+ void *user_data);
+
/* ViewLayers */
void *DRW_view_layer_engine_data_get(DrawEngineType *engine_type);
void **DRW_view_layer_engine_data_ensure_ex(
@@ -460,16 +481,14 @@ void **DRW_view_layer_engine_data_ensure_ex(
void **DRW_view_layer_engine_data_ensure(
DrawEngineType *engine_type, void (*callback)(void *storage));
-/* Objects */
-ObjectEngineData *DRW_object_engine_data_get(Object *ob, DrawEngineType *engine_type);
-ObjectEngineData *DRW_object_engine_data_ensure(
- Object *ob,
+/* DrawData */
+DrawData *DRW_drawdata_get(ID *ib, DrawEngineType *engine_type);
+DrawData *DRW_drawdata_ensure(
+ ID *id,
DrawEngineType *engine_type,
size_t size,
- ObjectEngineDataInitCb init_cb,
- ObjectEngineDataFreeCb free_cb);
-struct LampEngineData *DRW_lamp_engine_data_ensure(Object *ob, struct RenderEngineType *engine_type);
-void DRW_lamp_engine_data_free(struct LampEngineData *led);
+ DrawDataInitCb init_cb,
+ DrawDataFreeCb free_cb);
/* Settings */
bool DRW_object_is_renderable(struct Object *ob);
@@ -496,7 +515,7 @@ void DRW_state_lock(DRWState state);
void DRW_state_invert_facing(void);
-void DRW_state_clip_planes_count_set(uint plane_ct);
+void DRW_state_clip_planes_count_set(uint plane_len);
void DRW_state_clip_planes_reset(void);
/* Culling, return true if object is inside view frustum. */
diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c
index 42c36ab3662..95894783cfe 100644
--- a/source/blender/draw/intern/draw_anim_viz.c
+++ b/source/blender/draw/intern/draw_anim_viz.c
@@ -98,36 +98,36 @@ struct {
/* *************************** Path Cache *********************************** */
/* Just convert the CPU cache to GPU cache. */
-static Gwn_VertBuf *mpath_vbo_get(bMotionPath *mpath)
+static GPUVertBuf *mpath_vbo_get(bMotionPath *mpath)
{
if (!mpath->points_vbo) {
- Gwn_VertFormat format = {0};
+ GPUVertFormat format = {0};
/* Match structure of bMotionPathVert. */
- uint pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- GWN_vertformat_attr_add(&format, "flag", GWN_COMP_I32, 1, GWN_FETCH_INT);
- mpath->points_vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(mpath->points_vbo, mpath->length);
+ uint pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ GPU_vertformat_attr_add(&format, "flag", GPU_COMP_I32, 1, GPU_FETCH_INT);
+ mpath->points_vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(mpath->points_vbo, mpath->length);
/* meh... a useless memcpy. */
- Gwn_VertBufRaw raw_data;
- GWN_vertbuf_attr_get_raw_data(mpath->points_vbo, pos, &raw_data);
- memcpy(GWN_vertbuf_raw_step(&raw_data), mpath->points, sizeof(bMotionPathVert) * mpath->length);
+ GPUVertBufRaw raw_data;
+ GPU_vertbuf_attr_get_raw_data(mpath->points_vbo, pos, &raw_data);
+ memcpy(GPU_vertbuf_raw_step(&raw_data), mpath->points, sizeof(bMotionPathVert) * mpath->length);
}
return mpath->points_vbo;
}
-static Gwn_Batch *mpath_batch_line_get(bMotionPath *mpath)
+static GPUBatch *mpath_batch_line_get(bMotionPath *mpath)
{
if (!mpath->batch_line) {
- mpath->batch_line = GWN_batch_create(GWN_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL);
+ mpath->batch_line = GPU_batch_create(GPU_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL);
}
return mpath->batch_line;
}
-static Gwn_Batch *mpath_batch_points_get(bMotionPath *mpath)
+static GPUBatch *mpath_batch_points_get(bMotionPath *mpath)
{
if (!mpath->batch_points) {
- mpath->batch_points = GWN_batch_create(GWN_PRIM_POINTS, mpath_vbo_get(mpath), NULL);
+ mpath->batch_points = GPU_batch_create(GPU_PRIM_POINTS, mpath_vbo_get(mpath), NULL);
}
return mpath->batch_points;
}
@@ -149,12 +149,12 @@ static void MPATH_cache_init(void *vedata)
MPATH_PassList *psl = ((MPATH_Data *)vedata)->psl;
{
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ DRWState state = DRW_STATE_WRITE_COLOR;
psl->lines = DRW_pass_create("Motionpath Line Pass", state);
}
{
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_POINT;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_POINT;
psl->points = DRW_pass_create("Motionpath Point Pass", state);
}
}
@@ -256,7 +256,7 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
bool show_kf_no = (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) != 0;
if ((avs->path_viewflag & (MOTIONPATH_VIEW_FNUMS)) || (show_kf_no && show_keyframes)) {
int i;
- unsigned char col[4], col_kf[4];
+ uchar col[4], col_kf[4];
UI_GetThemeColor3ubv(TH_TEXT_HI, col);
UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col_kf);
col[3] = col_kf[3] = 255;
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 82662d77020..f0a32dfc8e0 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -134,11 +134,11 @@ static void drw_shgroup_bone_octahedral(
const float bone_color[4], const float hint_color[4], const float outline_color[4])
{
if (g_data.bone_octahedral_outline == NULL) {
- struct Gwn_Batch *geom = DRW_cache_bone_octahedral_wire_get();
+ struct GPUBatch *geom = DRW_cache_bone_octahedral_wire_get();
g_data.bone_octahedral_outline = shgroup_instance_bone_shape_outline(g_data.passes.bone_outline, geom);
}
if (g_data.bone_octahedral_solid == NULL) {
- struct Gwn_Batch *geom = DRW_cache_bone_octahedral_get();
+ struct GPUBatch *geom = DRW_cache_bone_octahedral_get();
g_data.bone_octahedral_solid = shgroup_instance_bone_shape_solid(g_data.passes.bone_solid, geom);
}
float final_bonemat[4][4];
@@ -155,11 +155,11 @@ static void drw_shgroup_bone_box(
const float bone_color[4], const float hint_color[4], const float outline_color[4])
{
if (g_data.bone_box_wire == NULL) {
- struct Gwn_Batch *geom = DRW_cache_bone_box_wire_get();
+ struct GPUBatch *geom = DRW_cache_bone_box_wire_get();
g_data.bone_box_outline = shgroup_instance_bone_shape_outline(g_data.passes.bone_outline, geom);
}
if (g_data.bone_box_solid == NULL) {
- struct Gwn_Batch *geom = DRW_cache_bone_box_get();
+ struct GPUBatch *geom = DRW_cache_bone_box_get();
g_data.bone_box_solid = shgroup_instance_bone_shape_solid(g_data.passes.bone_solid, geom);
}
float final_bonemat[4][4];
@@ -319,9 +319,9 @@ static void drw_shgroup_bone_custom_solid(
Object *custom)
{
/* grr, not re-using instances! */
- struct Gwn_Batch *surf = DRW_cache_object_surface_get(custom);
- struct Gwn_Batch *edges = DRW_cache_object_edge_detection_get(custom, NULL);
- struct Gwn_Batch *ledges = DRW_cache_object_loose_edges_get(custom);
+ struct GPUBatch *surf = DRW_cache_object_surface_get(custom);
+ struct GPUBatch *edges = DRW_cache_object_edge_detection_get(custom, NULL);
+ struct GPUBatch *ledges = DRW_cache_object_loose_edges_get(custom);
float final_bonemat[4][4];
if (surf || edges || ledges) {
@@ -352,7 +352,7 @@ static void drw_shgroup_bone_custom_wire(
const float color[4], Object *custom)
{
/* grr, not re-using instances! */
- struct Gwn_Batch *geom = DRW_cache_object_wire_outline_get(custom);
+ struct GPUBatch *geom = DRW_cache_object_wire_outline_get(custom);
if (geom) {
DRWShadingGroup *shgrp_geom_wire = shgroup_instance_wire(g_data.passes.bone_wire, geom);
float final_bonemat[4][4], final_color[4];
@@ -514,7 +514,7 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan)
}
/* This function is for brightening/darkening a given color (like UI_GetThemeColorShade3ubv()) */
-static void cp_shade_color3ub(unsigned char cp[3], const int offset)
+static void cp_shade_color3ub(uchar cp[3], const int offset)
{
int r, g, b;
@@ -549,7 +549,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
case PCHAN_COLOR_NORMAL:
{
if (bcolor) {
- unsigned char cp[4] = {255};
+ uchar cp[4] = {255};
if (boneflag & BONE_DRAW_ACTIVE) {
copy_v3_v3_char((char *)cp, bcolor->active);
@@ -591,7 +591,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
if (bcolor) {
float solid_bcolor[3];
- rgb_uchar_to_float(solid_bcolor, (unsigned char *)bcolor->solid);
+ rgb_uchar_to_float(solid_bcolor, (uchar *)bcolor->solid);
interp_v3_v3v3(fcolor, fcolor, solid_bcolor, 1.0f);
}
@@ -600,7 +600,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
case PCHAN_COLOR_CONSTS:
{
if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) {
- unsigned char cp[4];
+ uchar cp[4];
if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 80);
else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 80);
else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 80);
@@ -618,7 +618,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
case PCHAN_COLOR_SPHEREBONE_BASE:
{
if (bcolor) {
- unsigned char cp[4] = {255};
+ uchar cp[4] = {255};
if (boneflag & BONE_DRAW_ACTIVE) {
copy_v3_v3_char((char *)cp, bcolor->active);
@@ -649,7 +649,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
case PCHAN_COLOR_SPHEREBONE_END:
{
if (bcolor) {
- unsigned char cp[4] = {255};
+ uchar cp[4] = {255};
if (boneflag & BONE_DRAW_ACTIVE) {
copy_v3_v3_char((char *)cp, bcolor->active);
@@ -683,7 +683,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
{
/* inner part in background color or constraint */
if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) {
- unsigned char cp[4];
+ uchar cp[4];
if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 255);
else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 255);
else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 255);
@@ -695,7 +695,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
else {
if (bcolor) {
const char *cp = bcolor->solid;
- rgb_uchar_to_float(fcolor, (unsigned char *)cp);
+ rgb_uchar_to_float(fcolor, (uchar *)cp);
fcolor[3] = 204.f / 255.f;
}
else {
@@ -1298,7 +1298,7 @@ static void draw_bone_line(
drw_shgroup_bone_stick(BONE_VAR(eBone, pchan, disp_mat), col_wire, col_bone, col_head, col_tail);
}
else {
- /* In selection mode, draw bone, root and tip separatly. */
+ /* In selection mode, draw bone, root and tip separately. */
DRW_select_load_id(select_id | BONESEL_BONE);
drw_shgroup_bone_stick(BONE_VAR(eBone, pchan, disp_mat), col_wire, col_bone, no_display, no_display);
@@ -1588,7 +1588,7 @@ static void draw_armature_edit(Object *ob)
/* Draw names of bone */
if (show_text && (arm->flag & ARM_DRAWNAMES)) {
- unsigned char color[4];
+ uchar color[4];
UI_GetThemeColor4ubv((eBone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, color);
float vec[3];
@@ -1623,7 +1623,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
/* We can't safely draw non-updated pose, might contain NULL bone pointers... */
if (ob->pose->flag & POSE_RECALC) {
- BKE_pose_rebuild(ob, arm);
+ return;
}
// if (!(base->flag & OB_FROMDUPLI)) // TODO
@@ -1702,7 +1702,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
/* Draw names of bone */
if (show_text && (arm->flag & ARM_DRAWNAMES)) {
- unsigned char color[4];
+ uchar color[4];
UI_GetThemeColor4ubv((arm->flag & ARM_POSEMODE) &&
(bone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, color);
float vec[3];
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index a8d2c2a3642..dff863b11bb 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -39,86 +39,93 @@
#include "BLI_math.h"
#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
+#include "GPU_batch_utils.h"
#include "draw_cache.h"
#include "draw_cache_impl.h"
/* Batch's only (free'd as an array) */
static struct DRWShapeCache {
- Gwn_Batch *drw_single_vertice;
- Gwn_Batch *drw_cursor;
- Gwn_Batch *drw_cursor_only_circle;
- Gwn_Batch *drw_fullscreen_quad;
- Gwn_Batch *drw_quad;
- Gwn_Batch *drw_sphere;
- Gwn_Batch *drw_screenspace_circle;
- Gwn_Batch *drw_plain_axes;
- Gwn_Batch *drw_single_arrow;
- Gwn_Batch *drw_cube;
- Gwn_Batch *drw_circle;
- Gwn_Batch *drw_square;
- Gwn_Batch *drw_line;
- Gwn_Batch *drw_line_endpoints;
- Gwn_Batch *drw_empty_sphere;
- Gwn_Batch *drw_empty_cone;
- Gwn_Batch *drw_arrows;
- Gwn_Batch *drw_axis_names;
- Gwn_Batch *drw_image_plane;
- Gwn_Batch *drw_image_plane_wire;
- Gwn_Batch *drw_field_wind;
- Gwn_Batch *drw_field_force;
- Gwn_Batch *drw_field_vortex;
- Gwn_Batch *drw_field_tube_limit;
- Gwn_Batch *drw_field_cone_limit;
- Gwn_Batch *drw_lamp;
- Gwn_Batch *drw_lamp_shadows;
- Gwn_Batch *drw_lamp_sunrays;
- Gwn_Batch *drw_lamp_area_square;
- Gwn_Batch *drw_lamp_area_disk;
- Gwn_Batch *drw_lamp_hemi;
- Gwn_Batch *drw_lamp_spot;
- Gwn_Batch *drw_lamp_spot_square;
- Gwn_Batch *drw_speaker;
- Gwn_Batch *drw_lightprobe_cube;
- Gwn_Batch *drw_lightprobe_planar;
- Gwn_Batch *drw_lightprobe_grid;
- Gwn_Batch *drw_bone_octahedral;
- Gwn_Batch *drw_bone_octahedral_wire;
- Gwn_Batch *drw_bone_box;
- Gwn_Batch *drw_bone_box_wire;
- Gwn_Batch *drw_bone_wire_wire;
- Gwn_Batch *drw_bone_envelope;
- Gwn_Batch *drw_bone_envelope_outline;
- Gwn_Batch *drw_bone_point;
- Gwn_Batch *drw_bone_point_wire;
- Gwn_Batch *drw_bone_stick;
- Gwn_Batch *drw_bone_arrows;
- Gwn_Batch *drw_camera;
- Gwn_Batch *drw_camera_frame;
- Gwn_Batch *drw_camera_tria;
- Gwn_Batch *drw_camera_focus;
- Gwn_Batch *drw_particle_cross;
- Gwn_Batch *drw_particle_circle;
- Gwn_Batch *drw_particle_axis;
+ GPUBatch *drw_single_vertice;
+ GPUBatch *drw_cursor;
+ GPUBatch *drw_cursor_only_circle;
+ GPUBatch *drw_fullscreen_quad;
+ GPUBatch *drw_fullscreen_quad_texcoord;
+ GPUBatch *drw_quad;
+ GPUBatch *drw_sphere;
+ GPUBatch *drw_screenspace_circle;
+ GPUBatch *drw_plain_axes;
+ GPUBatch *drw_single_arrow;
+ GPUBatch *drw_cube;
+ GPUBatch *drw_circle;
+ GPUBatch *drw_square;
+ GPUBatch *drw_line;
+ GPUBatch *drw_line_endpoints;
+ GPUBatch *drw_empty_cube;
+ GPUBatch *drw_empty_sphere;
+ GPUBatch *drw_empty_cylinder;
+ GPUBatch *drw_empty_capsule_body;
+ GPUBatch *drw_empty_capsule_cap;
+ GPUBatch *drw_empty_cone;
+ GPUBatch *drw_arrows;
+ GPUBatch *drw_axis_names;
+ GPUBatch *drw_image_plane;
+ GPUBatch *drw_image_plane_wire;
+ GPUBatch *drw_field_wind;
+ GPUBatch *drw_field_force;
+ GPUBatch *drw_field_vortex;
+ GPUBatch *drw_field_tube_limit;
+ GPUBatch *drw_field_cone_limit;
+ GPUBatch *drw_lamp;
+ GPUBatch *drw_lamp_shadows;
+ GPUBatch *drw_lamp_sunrays;
+ GPUBatch *drw_lamp_area_square;
+ GPUBatch *drw_lamp_area_disk;
+ GPUBatch *drw_lamp_hemi;
+ GPUBatch *drw_lamp_spot;
+ GPUBatch *drw_lamp_spot_square;
+ GPUBatch *drw_speaker;
+ GPUBatch *drw_lightprobe_cube;
+ GPUBatch *drw_lightprobe_planar;
+ GPUBatch *drw_lightprobe_grid;
+ GPUBatch *drw_bone_octahedral;
+ GPUBatch *drw_bone_octahedral_wire;
+ GPUBatch *drw_bone_box;
+ GPUBatch *drw_bone_box_wire;
+ GPUBatch *drw_bone_wire_wire;
+ GPUBatch *drw_bone_envelope;
+ GPUBatch *drw_bone_envelope_outline;
+ GPUBatch *drw_bone_point;
+ GPUBatch *drw_bone_point_wire;
+ GPUBatch *drw_bone_stick;
+ GPUBatch *drw_bone_arrows;
+ GPUBatch *drw_camera;
+ GPUBatch *drw_camera_frame;
+ GPUBatch *drw_camera_tria;
+ GPUBatch *drw_camera_focus;
+ GPUBatch *drw_particle_cross;
+ GPUBatch *drw_particle_circle;
+ GPUBatch *drw_particle_axis;
} SHC = {NULL};
void DRW_shape_cache_free(void)
{
- uint i = sizeof(SHC) / sizeof(Gwn_Batch *);
- Gwn_Batch **batch = (Gwn_Batch **)&SHC;
+ uint i = sizeof(SHC) / sizeof(GPUBatch *);
+ GPUBatch **batch = (GPUBatch **)&SHC;
while (i--) {
- GWN_BATCH_DISCARD_SAFE(*batch);
+ GPU_BATCH_DISCARD_SAFE(*batch);
batch++;
}
}
void DRW_shape_cache_reset(void)
{
- uint i = sizeof(SHC) / sizeof(Gwn_Batch *);
- Gwn_Batch **batch = (Gwn_Batch **)&SHC;
+ uint i = sizeof(SHC) / sizeof(GPUBatch *);
+ GPUBatch **batch = (GPUBatch **)&SHC;
while (i--) {
if (*batch) {
- gwn_batch_vao_cache_clear(*batch);
+ GPU_batch_vao_cache_clear(*batch);
}
batch++;
}
@@ -130,22 +137,22 @@ void DRW_shape_cache_reset(void)
* \{ */
static void UNUSED_FUNCTION(add_fancy_edge)(
- Gwn_VertBuf *vbo, uint pos_id, uint n1_id, uint n2_id,
+ GPUVertBuf *vbo, uint pos_id, uint n1_id, uint n2_id,
uint *v_idx, const float co1[3], const float co2[3],
const float n1[3], const float n2[3])
{
- GWN_vertbuf_attr_set(vbo, n1_id, *v_idx, n1);
- GWN_vertbuf_attr_set(vbo, n2_id, *v_idx, n2);
- GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co1);
+ GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1);
+ GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2);
+ GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co1);
- GWN_vertbuf_attr_set(vbo, n1_id, *v_idx, n1);
- GWN_vertbuf_attr_set(vbo, n2_id, *v_idx, n2);
- GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co2);
+ GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1);
+ GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2);
+ GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co2);
}
#if 0 /* UNUSED */
static void add_lat_lon_vert(
- Gwn_VertBuf *vbo, uint pos_id, uint nor_id,
+ GPUVertBuf *vbo, uint pos_id, uint nor_id,
uint *v_idx, const float rad, const float lat, const float lon)
{
float pos[3], nor[3];
@@ -154,23 +161,23 @@ static void add_lat_lon_vert(
nor[2] = sinf(lat) * sinf(lon);
mul_v3_v3fl(pos, nor, rad);
- GWN_vertbuf_attr_set(vbo, nor_id, *v_idx, nor);
- GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, pos);
+ GPU_vertbuf_attr_set(vbo, nor_id, *v_idx, nor);
+ GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, pos);
}
#endif
-static Gwn_VertBuf *fill_arrows_vbo(const float scale)
+static GPUVertBuf *fill_arrows_vbo(const float scale)
{
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
/* Line */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 6 * 3);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 6 * 3);
float v1[3] = {0.0, 0.0, 0.0};
float v2[3] = {0.0, 0.0, 0.0};
@@ -182,21 +189,21 @@ static Gwn_VertBuf *fill_arrows_vbo(const float scale)
v2[axis] = 1.0f;
mul_v3_v3fl(vtmp1, v1, scale);
mul_v3_v3fl(vtmp2, v2, scale);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 0, vtmp1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 1, vtmp2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 0, vtmp1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 1, vtmp2);
v1[axis] = 0.85f;
v1[arrow_axis] = -0.08f;
mul_v3_v3fl(vtmp1, v1, scale);
mul_v3_v3fl(vtmp2, v2, scale);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 2, vtmp1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 3, vtmp2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 2, vtmp1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 3, vtmp2);
v1[arrow_axis] = 0.08f;
mul_v3_v3fl(vtmp1, v1, scale);
mul_v3_v3fl(vtmp2, v2, scale);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 4, vtmp1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 5, vtmp2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 4, vtmp1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 5, vtmp2);
/* reset v1 & v2 to zero */
v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f;
@@ -205,18 +212,18 @@ static Gwn_VertBuf *fill_arrows_vbo(const float scale)
return vbo;
}
-static Gwn_VertBuf *sphere_wire_vbo(const float rad)
+static GPUVertBuf *sphere_wire_vbo(const float rad)
{
#define NSEGMENTS 32
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2 * 3);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2 * 3);
/* a single ring of vertices */
float p[NSEGMENTS][2];
@@ -241,7 +248,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad)
else
v[0] = 0.0f, v[1] = cv[0], v[2] = cv[1];
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + j + (NSEGMENTS * 2 * axis), v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + j + (NSEGMENTS * 2 * axis), v);
}
}
}
@@ -252,7 +259,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad)
/* Quads */
/* Use this one for rendering fullscreen passes. For 3D objects use DRW_cache_quad_get(). */
-Gwn_Batch *DRW_cache_fullscreen_quad_get(void)
+GPUBatch *DRW_cache_fullscreen_quad_get(void)
{
if (!SHC.drw_fullscreen_quad) {
/* Use a triangle instead of a real quad */
@@ -261,56 +268,57 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void)
float uvs[3][2] = {{ 0.0f, 0.0f}, { 2.0f, 0.0f}, { 0.0f, 2.0f}};
/* Position Only 2D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, uvs; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.uvs = GPU_vertformat_attr_add(&format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ GPU_vertformat_alias_add(&format, "texCoord");
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 3);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 3);
for (int i = 0; i < 3; ++i) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
- GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
}
- SHC.drw_fullscreen_quad = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_fullscreen_quad = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_fullscreen_quad;
}
/* Just a regular quad with 4 vertices. */
-Gwn_Batch *DRW_cache_quad_get(void)
+GPUBatch *DRW_cache_quad_get(void)
{
if (!SHC.drw_quad) {
float pos[4][2] = {{-1.0f, -1.0f}, { 1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}};
float uvs[4][2] = {{ 0.0f, 0.0f}, { 1.0f, 0.0f}, {1.0f, 1.0f}, { 0.0f, 1.0f}};
/* Position Only 2D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, uvs; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.uvs = GPU_vertformat_attr_add(&format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 4);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 4);
for (int i = 0; i < 4; ++i) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
- GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
}
- SHC.drw_quad = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_quad = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_quad;
}
/* Sphere */
-Gwn_Batch *DRW_cache_sphere_get(void)
+GPUBatch *DRW_cache_sphere_get(void)
{
if (!SHC.drw_sphere) {
SHC.drw_sphere = gpu_batch_sphere(32, 24);
@@ -325,7 +333,7 @@ Gwn_Batch *DRW_cache_sphere_get(void)
/** \name Common
* \{ */
-Gwn_Batch *DRW_cache_cube_get(void)
+GPUBatch *DRW_cache_cube_get(void)
{
if (!SHC.drw_cube) {
const GLfloat verts[8][3] = {
@@ -339,57 +347,105 @@ Gwn_Batch *DRW_cache_cube_get(void)
{ 1.0f, 1.0f, 1.0f}
};
+ const uint indices[36] = {
+ 0, 1, 2,
+ 1, 3, 2,
+ 0, 4, 1,
+ 4, 5, 1,
+ 6, 5, 4,
+ 6, 7, 5,
+ 2, 7, 6,
+ 2, 3, 7,
+ 3, 1, 7,
+ 1, 5, 7,
+ 0, 2, 4,
+ 2, 6, 4,
+ };
+
+ /* Position Only 3D format */
+ static GPUVertFormat format = { 0 };
+ static struct { uint pos; } attr_id;
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
+
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 36);
+
+ for (int i = 0; i < 36; ++i) {
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]);
+ }
+
+ SHC.drw_cube = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ }
+ return SHC.drw_cube;
+}
+
+GPUBatch *DRW_cache_empty_cube_get(void)
+{
+ if (!SHC.drw_empty_cube) {
+ const GLfloat verts[8][3] = {
+ {-1.0f, -1.0f, -1.0f},
+ {-1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f},
+ {-1.0f, 1.0f, 1.0f},
+ { 1.0f, -1.0f, -1.0f},
+ { 1.0f, -1.0f, 1.0f},
+ { 1.0f, 1.0f, -1.0f},
+ { 1.0f, 1.0f, 1.0f}
+ };
+
const GLubyte indices[24] = {0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5, 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 24);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 24);
for (int i = 0; i < 24; ++i) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]);
}
- SHC.drw_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_empty_cube = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
- return SHC.drw_cube;
+ return SHC.drw_empty_cube;
}
-Gwn_Batch *DRW_cache_circle_get(void)
+GPUBatch *DRW_cache_circle_get(void)
{
#define CIRCLE_RESOL 64
if (!SHC.drw_circle) {
float v[3] = {0.0f, 0.0f, 0.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL);
for (int a = 0; a < CIRCLE_RESOL; a++) {
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v);
}
- SHC.drw_circle = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_circle = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_circle;
#undef CIRCLE_RESOL
}
-Gwn_Batch *DRW_cache_square_get(void)
+GPUBatch *DRW_cache_square_get(void)
{
if (!SHC.drw_square) {
float p[4][3] = {{ 1.0f, 0.0f, 1.0f},
@@ -398,26 +454,26 @@ Gwn_Batch *DRW_cache_square_get(void)
{-1.0f, 0.0f, 1.0f}};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 8);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 8);
for (int i = 0; i < 4; i++) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2, p[i % 4]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i + 1) % 4]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2, p[i % 4]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i + 1) % 4]);
}
- SHC.drw_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_square;
}
-Gwn_Batch *DRW_cache_single_line_get(void)
+GPUBatch *DRW_cache_single_line_get(void)
{
/* Z axis line */
if (!SHC.drw_line) {
@@ -425,24 +481,24 @@ Gwn_Batch *DRW_cache_single_line_get(void)
float v2[3] = {0.0f, 0.0f, 1.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2);
- SHC.drw_line = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_line = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_line;
}
-Gwn_Batch *DRW_cache_single_line_endpoints_get(void)
+GPUBatch *DRW_cache_single_line_endpoints_get(void)
{
/* Z axis line */
if (!SHC.drw_line_endpoints) {
@@ -450,46 +506,46 @@ Gwn_Batch *DRW_cache_single_line_endpoints_get(void)
float v2[3] = {0.0f, 0.0f, 1.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2);
- SHC.drw_line_endpoints = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_line_endpoints = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_line_endpoints;
}
-Gwn_Batch *DRW_cache_screenspace_circle_get(void)
+GPUBatch *DRW_cache_screenspace_circle_get(void)
{
#define CIRCLE_RESOL 32
if (!SHC.drw_screenspace_circle) {
float v[3] = {0.0f, 0.0f, 0.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL + 1);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL + 1);
for (int a = 0; a <= CIRCLE_RESOL; a++) {
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v);
}
- SHC.drw_screenspace_circle = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_screenspace_circle = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_screenspace_circle;
#undef CIRCLE_RESOL
@@ -502,7 +558,7 @@ Gwn_Batch *DRW_cache_screenspace_circle_get(void)
/** \name Common Object API
* \{ */
-Gwn_Batch *DRW_cache_object_wire_outline_get(Object *ob)
+GPUBatch *DRW_cache_object_wire_outline_get(Object *ob)
{
switch (ob->type) {
case OB_MESH:
@@ -514,7 +570,7 @@ Gwn_Batch *DRW_cache_object_wire_outline_get(Object *ob)
}
}
-Gwn_Batch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
+GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
{
switch (ob->type) {
case OB_MESH:
@@ -538,7 +594,7 @@ void DRW_cache_object_face_wireframe_get(
}
}
-Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob)
+GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob)
{
switch (ob->type) {
case OB_MESH:
@@ -550,7 +606,7 @@ Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob)
}
}
-Gwn_Batch *DRW_cache_object_surface_get(Object *ob)
+GPUBatch *DRW_cache_object_surface_get(Object *ob)
{
switch (ob->type) {
case OB_MESH:
@@ -568,7 +624,7 @@ Gwn_Batch *DRW_cache_object_surface_get(Object *ob)
}
}
-Gwn_Batch **DRW_cache_object_surface_material_get(
+GPUBatch **DRW_cache_object_surface_material_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count)
{
@@ -603,7 +659,7 @@ Gwn_Batch **DRW_cache_object_surface_material_get(
/** \name Empties
* \{ */
-Gwn_Batch *DRW_cache_plain_axes_get(void)
+GPUBatch *DRW_cache_plain_axes_get(void)
{
if (!SHC.drw_plain_axes) {
int axis;
@@ -611,46 +667,46 @@ Gwn_Batch *DRW_cache_plain_axes_get(void)
float v2[3] = {0.0f, 0.0f, 0.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 6);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 6);
for (axis = 0; axis < 3; axis++) {
v1[axis] = 1.0f;
v2[axis] = -1.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 2, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 2 + 1, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 2, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 2 + 1, v2);
/* reset v1 & v2 to zero for next axis */
v1[axis] = v2[axis] = 0.0f;
}
- SHC.drw_plain_axes = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_plain_axes = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_plain_axes;
}
-Gwn_Batch *DRW_cache_single_arrow_get(void)
+GPUBatch *DRW_cache_single_arrow_get(void)
{
if (!SHC.drw_single_arrow) {
float v1[3] = {0.0f, 0.0f, 1.0f}, v2[3], v3[3];
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
/* Square Pyramid */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 12);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 12);
v2[0] = 0.035f; v2[1] = 0.035f;
v3[0] = -0.035f; v3[1] = 0.035f;
@@ -666,26 +722,26 @@ Gwn_Batch *DRW_cache_single_arrow_get(void)
v3[0] = -v3[0];
}
- GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 0, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 1, v2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 2, v3);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 0, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 1, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 2, v3);
}
- SHC.drw_single_arrow = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_single_arrow = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_single_arrow;
}
-Gwn_Batch *DRW_cache_empty_sphere_get(void)
+GPUBatch *DRW_cache_empty_sphere_get(void)
{
if (!SHC.drw_empty_sphere) {
- Gwn_VertBuf *vbo = sphere_wire_vbo(1.0f);
- SHC.drw_empty_sphere = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ GPUVertBuf *vbo = sphere_wire_vbo(1.0f);
+ SHC.drw_empty_sphere = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_empty_sphere;
}
-Gwn_Batch *DRW_cache_empty_cone_get(void)
+GPUBatch *DRW_cache_empty_cone_get(void)
{
#define NSEGMENTS 8
if (!SHC.drw_empty_cone) {
@@ -698,14 +754,14 @@ Gwn_Batch *DRW_cache_empty_cone_get(void)
}
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 4);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 4);
for (int i = 0; i < NSEGMENTS; ++i) {
float cv[2], v[3];
@@ -714,152 +770,290 @@ Gwn_Batch *DRW_cache_empty_cone_get(void)
/* cone sides */
v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1];
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v);
v[0] = 0.0f, v[1] = 2.0f, v[2] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v);
/* end ring */
v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1];
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v);
cv[0] = p[(i + 1) % NSEGMENTS][0];
cv[1] = p[(i + 1) % NSEGMENTS][1];
v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1];
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v);
}
- SHC.drw_empty_cone = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_empty_cone = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_empty_cone;
#undef NSEGMENTS
}
-Gwn_Batch *DRW_cache_arrows_get(void)
+GPUBatch *DRW_cache_empty_cylinder_get(void)
+{
+#define NSEGMENTS 12
+ if (!SHC.drw_empty_cylinder) {
+ /* a single ring of vertices */
+ float p[NSEGMENTS][2];
+ for (int i = 0; i < NSEGMENTS; ++i) {
+ float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
+ p[i][0] = cosf(angle);
+ p[i][1] = sinf(angle);
+ }
+
+ /* Position Only 3D format */
+ static GPUVertFormat format = { 0 };
+ static struct { uint pos; } attr_id;
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
+
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 6);
+
+ for (int i = 0; i < NSEGMENTS; ++i) {
+ float cv[2], pv[2], v[3];
+ cv[0] = p[(i) % NSEGMENTS][0];
+ cv[1] = p[(i) % NSEGMENTS][1];
+ pv[0] = p[(i + 1) % NSEGMENTS][0];
+ pv[1] = p[(i + 1) % NSEGMENTS][1];
+
+ /* cylinder sides */
+ copy_v3_fl3(v, cv[0], cv[1], -1.0f);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6, v);
+ copy_v3_fl3(v, cv[0], cv[1], 1.0f);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 1, v);
+
+ /* top ring */
+ copy_v3_fl3(v, cv[0], cv[1], 1.0f);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 2, v);
+ copy_v3_fl3(v, pv[0], pv[1], 1.0f);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 3, v);
+
+ /* bottom ring */
+ copy_v3_fl3(v, cv[0], cv[1], -1.0f);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 4, v);
+ copy_v3_fl3(v, pv[0], pv[1], -1.0f);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 5, v);
+ }
+
+ SHC.drw_empty_cylinder = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ }
+ return SHC.drw_empty_cylinder;
+#undef NSEGMENTS
+}
+
+GPUBatch *DRW_cache_empty_capsule_body_get(void)
+{
+ if (!SHC.drw_empty_capsule_body) {
+ const float pos[8][3] = {
+ { 1.0f, 0.0f, 1.0f},
+ { 1.0f, 0.0f, 0.0f},
+ { 0.0f, 1.0f, 1.0f},
+ { 0.0f, 1.0f, 0.0f},
+ {-1.0f, 0.0f, 1.0f},
+ {-1.0f, 0.0f, 0.0f},
+ { 0.0f, -1.0f, 1.0f},
+ { 0.0f, -1.0f, 0.0f}
+ };
+
+ /* Position Only 3D format */
+ static GPUVertFormat format = { 0 };
+ static struct { uint pos; } attr_id;
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
+
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 8);
+ GPU_vertbuf_attr_fill(vbo, attr_id.pos, pos);
+
+ SHC.drw_empty_capsule_body = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ }
+ return SHC.drw_empty_capsule_body;
+}
+
+GPUBatch *DRW_cache_empty_capsule_cap_get(void)
+{
+#define NSEGMENTS 24 /* Must be multiple of 2. */
+ if (!SHC.drw_empty_capsule_cap) {
+ /* a single ring of vertices */
+ float p[NSEGMENTS][2];
+ for (int i = 0; i < NSEGMENTS; ++i) {
+ float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
+ p[i][0] = cosf(angle);
+ p[i][1] = sinf(angle);
+ }
+
+ /* Position Only 3D format */
+ static GPUVertFormat format = { 0 };
+ static struct { uint pos; } attr_id;
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
+
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, (NSEGMENTS * 2) * 2);
+
+ /* Base circle */
+ int vidx = 0;
+ for (int i = 0; i < NSEGMENTS; ++i) {
+ float v[3] = {0.0f, 0.0f, 0.0f};
+ copy_v2_v2(v, p[(i) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ copy_v2_v2(v, p[(i + 1) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ }
+
+ for (int i = 0; i < NSEGMENTS / 2; ++i) {
+ float v[3] = {0.0f, 0.0f, 0.0f};
+ int ci = i % NSEGMENTS;
+ int pi = (i + 1) % NSEGMENTS;
+ /* Y half circle */
+ copy_v3_fl3(v, p[ci][0], 0.0f, p[ci][1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ copy_v3_fl3(v, p[pi][0], 0.0f, p[pi][1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ /* X half circle */
+ copy_v3_fl3(v, 0.0f, p[ci][0], p[ci][1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ copy_v3_fl3(v, 0.0f, p[pi][0], p[pi][1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ }
+
+ SHC.drw_empty_capsule_cap = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ }
+ return SHC.drw_empty_capsule_cap;
+#undef NSEGMENTS
+}
+
+GPUBatch *DRW_cache_arrows_get(void)
{
if (!SHC.drw_arrows) {
- Gwn_VertBuf *vbo = fill_arrows_vbo(1.0f);
+ GPUVertBuf *vbo = fill_arrows_vbo(1.0f);
- SHC.drw_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_arrows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_arrows;
}
-Gwn_Batch *DRW_cache_axis_names_get(void)
+GPUBatch *DRW_cache_axis_names_get(void)
{
if (!SHC.drw_axis_names) {
const float size = 0.1f;
float v1[3], v2[3];
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* Using 3rd component as axis indicator */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
/* Line */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 14);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 14);
/* X */
copy_v3_fl3(v1, -size, size, 0.0f);
copy_v3_fl3(v2, size, -size, 0.0f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2);
copy_v3_fl3(v1, size, size, 0.0f);
copy_v3_fl3(v2, -size, -size, 0.0f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 2, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 3, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 2, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 3, v2);
/* Y */
copy_v3_fl3(v1, -size + 0.25f * size, size, 1.0f);
copy_v3_fl3(v2, 0.0f, 0.0f, 1.0f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 4, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 5, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 4, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 5, v2);
copy_v3_fl3(v1, size - 0.25f * size, size, 1.0f);
copy_v3_fl3(v2, -size + 0.25f * size, -size, 1.0f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 6, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 7, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 6, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 7, v2);
/* Z */
copy_v3_fl3(v1, -size, size, 2.0f);
copy_v3_fl3(v2, size, size, 2.0f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 8, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 9, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 8, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 9, v2);
copy_v3_fl3(v1, size, size, 2.0f);
copy_v3_fl3(v2, -size, -size, 2.0f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 10, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 11, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 10, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 11, v2);
copy_v3_fl3(v1, -size, -size, 2.0f);
copy_v3_fl3(v2, size, -size, 2.0f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 12, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 13, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 12, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 13, v2);
- SHC.drw_axis_names = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_axis_names = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_axis_names;
}
-Gwn_Batch *DRW_cache_image_plane_get(void)
+GPUBatch *DRW_cache_image_plane_get(void)
{
if (!SHC.drw_image_plane) {
const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, texCoords; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.texCoords = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.texCoords = GPU_vertformat_attr_add(&format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 4);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 4);
for (uint j = 0; j < 4; j++) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]);
- GWN_vertbuf_attr_set(vbo, attr_id.texCoords, j, quad[j]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]);
+ GPU_vertbuf_attr_set(vbo, attr_id.texCoords, j, quad[j]);
}
- SHC.drw_image_plane = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_image_plane = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_image_plane;
}
-Gwn_Batch *DRW_cache_image_plane_wire_get(void)
+GPUBatch *DRW_cache_image_plane_wire_get(void)
{
if (!SHC.drw_image_plane_wire) {
const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 4);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 4);
for (uint j = 0; j < 4; j++) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]);
}
- SHC.drw_image_plane_wire = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_image_plane_wire = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_image_plane_wire;
}
/* Force Field */
-Gwn_Batch *DRW_cache_field_wind_get(void)
+GPUBatch *DRW_cache_field_wind_get(void)
{
#define CIRCLE_RESOL 32
if (!SHC.drw_field_wind) {
float v[3] = {0.0f, 0.0f, 0.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 4);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 4);
for (int i = 0; i < 4; i++) {
float z = 0.05f * (float)i;
@@ -867,36 +1061,36 @@ Gwn_Batch *DRW_cache_field_wind_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = z;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = z;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v);
}
}
- SHC.drw_field_wind = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_field_wind = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_field_wind;
#undef CIRCLE_RESOL
}
-Gwn_Batch *DRW_cache_field_force_get(void)
+GPUBatch *DRW_cache_field_force_get(void)
{
#define CIRCLE_RESOL 32
if (!SHC.drw_field_force) {
float v[3] = {0.0f, 0.0f, 0.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 3);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 3);
for (int i = 0; i < 3; i++) {
float radius = 1.0f + 0.5f * (float)i;
@@ -904,22 +1098,22 @@ Gwn_Batch *DRW_cache_field_force_get(void)
v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v);
v[0] = radius * sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = radius * cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v);
}
}
- SHC.drw_field_force = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_field_force = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_field_force;
#undef CIRCLE_RESOL
}
-Gwn_Batch *DRW_cache_field_vortex_get(void)
+GPUBatch *DRW_cache_field_vortex_get(void)
{
#define SPIRAL_RESOL 32
if (!SHC.drw_field_vortex) {
@@ -927,36 +1121,36 @@ Gwn_Batch *DRW_cache_field_vortex_get(void)
uint v_idx = 0;
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, SPIRAL_RESOL * 2 + 1);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, SPIRAL_RESOL * 2 + 1);
for (int a = SPIRAL_RESOL; a > -1; a--) {
v[0] = sinf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL);
v[1] = cosf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
}
for (int a = 1; a <= SPIRAL_RESOL; a++) {
v[0] = -sinf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL);
v[1] = -cosf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
}
- SHC.drw_field_vortex = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_field_vortex = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_field_vortex;
#undef SPIRAL_RESOL
}
-Gwn_Batch *DRW_cache_field_tube_limit_get(void)
+GPUBatch *DRW_cache_field_tube_limit_get(void)
{
#define CIRCLE_RESOL 32
if (!SHC.drw_field_tube_limit) {
@@ -964,14 +1158,14 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void)
uint v_idx = 0;
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8);
/* Caps */
for (int i = 0; i < 2; i++) {
@@ -980,12 +1174,12 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = z;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = z;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
}
}
/* Side Edges */
@@ -995,17 +1189,17 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void)
v[0] = sinf((2.0f * M_PI * a) / 4.0f);
v[1] = cosf((2.0f * M_PI * a) / 4.0f);
v[2] = z;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
}
}
- SHC.drw_field_tube_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_field_tube_limit = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_field_tube_limit;
#undef CIRCLE_RESOL
}
-Gwn_Batch *DRW_cache_field_cone_limit_get(void)
+GPUBatch *DRW_cache_field_cone_limit_get(void)
{
#define CIRCLE_RESOL 32
if (!SHC.drw_field_cone_limit) {
@@ -1013,14 +1207,14 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void)
uint v_idx = 0;
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8);
/* Caps */
for (int i = 0; i < 2; i++) {
@@ -1029,12 +1223,12 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = z;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = z;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
}
}
/* Side Edges */
@@ -1044,11 +1238,11 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void)
v[0] = z * sinf((2.0f * M_PI * a) / 4.0f);
v[1] = z * cosf((2.0f * M_PI * a) / 4.0f);
v[2] = z;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
}
}
- SHC.drw_field_cone_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_field_cone_limit = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_field_cone_limit;
#undef CIRCLE_RESOL
@@ -1061,84 +1255,84 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void)
/** \name Lamps
* \{ */
-Gwn_Batch *DRW_cache_lamp_get(void)
+GPUBatch *DRW_cache_lamp_get(void)
{
#define NSEGMENTS 8
if (!SHC.drw_lamp) {
float v[2];
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2);
for (int a = 0; a < NSEGMENTS * 2; a += 2) {
v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2));
v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v);
}
- SHC.drw_lamp = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lamp = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lamp;
#undef NSEGMENTS
}
-Gwn_Batch *DRW_cache_lamp_shadows_get(void)
+GPUBatch *DRW_cache_lamp_shadows_get(void)
{
#define NSEGMENTS 10
if (!SHC.drw_lamp_shadows) {
float v[2];
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2);
for (int a = 0; a < NSEGMENTS * 2; a += 2) {
v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2));
v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v);
}
- SHC.drw_lamp_shadows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lamp_shadows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_shadows;
#undef NSEGMENTS
}
-Gwn_Batch *DRW_cache_lamp_sunrays_get(void)
+GPUBatch *DRW_cache_lamp_sunrays_get(void)
{
if (!SHC.drw_lamp_sunrays) {
float v[2], v1[2], v2[2];
/* Position Only 2D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 32);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 32);
for (int a = 0; a < 8; a++) {
v[0] = sinf((2.0f * M_PI * a) / 8.0f);
@@ -1146,86 +1340,86 @@ Gwn_Batch *DRW_cache_lamp_sunrays_get(void)
mul_v2_v2fl(v1, v, 1.6f);
mul_v2_v2fl(v2, v, 1.9f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 1, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 1, v2);
mul_v2_v2fl(v1, v, 2.2f);
mul_v2_v2fl(v2, v, 2.5f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 2, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 3, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 2, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 3, v2);
}
- SHC.drw_lamp_sunrays = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lamp_sunrays = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_sunrays;
}
-Gwn_Batch *DRW_cache_lamp_area_square_get(void)
+GPUBatch *DRW_cache_lamp_area_square_get(void)
{
if (!SHC.drw_lamp_area_square) {
float v1[3] = {0.0f, 0.0f, 0.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 8);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 8);
v1[0] = v1[1] = 0.5f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
v1[0] = -0.5f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 2, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 2, v1);
v1[1] = -0.5f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 3, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 4, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 3, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 4, v1);
v1[0] = 0.5f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 5, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 6, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 5, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 6, v1);
v1[1] = 0.5f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 7, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 7, v1);
- SHC.drw_lamp_area_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lamp_area_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_area_square;
}
-Gwn_Batch *DRW_cache_lamp_area_disk_get(void)
+GPUBatch *DRW_cache_lamp_area_disk_get(void)
{
#define NSEGMENTS 32
if (!SHC.drw_lamp_area_disk) {
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 2 * NSEGMENTS);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 2 * NSEGMENTS);
float v[3] = {0.0f, 0.5f, 0.0f};
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v);
for (int a = 1; a < NSEGMENTS; a++) {
v[0] = 0.5f * sinf(2.0f * (float)M_PI * a / NSEGMENTS);
v[1] = 0.5f * cosf(2.0f * (float)M_PI * a / NSEGMENTS);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * a - 1, v);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * a, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * a - 1, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * a, v);
}
copy_v3_fl3(v, 0.0f, 0.5f, 0.0f);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, (2 * NSEGMENTS) - 1, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, (2 * NSEGMENTS) - 1, v);
- SHC.drw_lamp_area_disk = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lamp_area_disk = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_area_disk;
#undef NSEGMENTS
}
-Gwn_Batch *DRW_cache_lamp_hemi_get(void)
+GPUBatch *DRW_cache_lamp_hemi_get(void)
{
#define CIRCLE_RESOL 32
if (!SHC.drw_lamp_hemi) {
@@ -1233,26 +1427,26 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void)
int vidx = 0;
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 - 6 * 2 * 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 - 6 * 2 * 2);
/* XZ plane */
for (int a = 3; a < CIRCLE_RESOL / 2 - 3; a++) {
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL) - M_PI / 2);
v[2] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL) - M_PI / 2) - 1.0f;
v[1] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL) - M_PI / 2);
v[2] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL) - M_PI / 2) - 1.0f;
v[1] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
}
/* XY plane */
@@ -1260,12 +1454,12 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void)
v[2] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)) - 1.0f;
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[0] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
v[2] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)) - 1.0f;
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[0] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
}
/* YZ plane full circle */
@@ -1274,22 +1468,22 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void)
for (int a = 0; a < CIRCLE_RESOL; a++) {
v[1] = rad * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[0] = rad * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
v[1] = rad * sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[0] = rad * cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
}
- SHC.drw_lamp_hemi = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lamp_hemi = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_hemi;
#undef CIRCLE_RESOL
}
-Gwn_Batch *DRW_cache_lamp_spot_get(void)
+GPUBatch *DRW_cache_lamp_spot_get(void)
{
#define NSEGMENTS 32
if (!SHC.drw_lamp_spot) {
@@ -1311,16 +1505,16 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void)
}
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, n1, n2; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.n1 = GPU_vertformat_attr_add(&format, "N1", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.n2 = GPU_vertformat_attr_add(&format, "N2", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 4);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 4);
for (int i = 0; i < NSEGMENTS; ++i) {
float cv[2], v[3];
@@ -1329,36 +1523,36 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void)
/* cone sides */
v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v);
v[0] = 0.0f, v[1] = 0.0f, v[2] = 0.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v);
- GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4, n[(i) % NSEGMENTS]);
- GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 1, n[(i) % NSEGMENTS]);
- GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4, n[(i + 1) % NSEGMENTS]);
- GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 1, n[(i + 1) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4, n[(i) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 1, n[(i) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4, n[(i + 1) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 1, n[(i + 1) % NSEGMENTS]);
/* end ring */
v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v);
cv[0] = p[(i + 1) % NSEGMENTS][0];
cv[1] = p[(i + 1) % NSEGMENTS][1];
v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v);
- GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 2, n[(i) % NSEGMENTS]);
- GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 3, n[(i) % NSEGMENTS]);
- GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 2, neg[(i) % NSEGMENTS]);
- GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 2, n[(i) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 3, n[(i) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 2, neg[(i) % NSEGMENTS]);
+ GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]);
}
- SHC.drw_lamp_spot = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lamp_spot = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_spot;
#undef NSEGMENTS
}
-Gwn_Batch *DRW_cache_lamp_spot_square_get(void)
+GPUBatch *DRW_cache_lamp_spot_square_get(void)
{
if (!SHC.drw_lamp_spot_square) {
float p[5][3] = {{ 0.0f, 0.0f, 0.0f},
@@ -1370,25 +1564,25 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void)
uint v_idx = 0;
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 16);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 16);
/* piramid sides */
for (int i = 1; i <= 4; ++i) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[0]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[0]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[i]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[(i % 4) + 1]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i + 1) % 4) + 1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[(i % 4) + 1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i + 1) % 4) + 1]);
}
- SHC.drw_lamp_spot_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lamp_spot_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_spot_square;
}
@@ -1400,7 +1594,7 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void)
/** \name Speaker
* \{ */
-Gwn_Batch *DRW_cache_speaker_get(void)
+GPUBatch *DRW_cache_speaker_get(void)
{
if (!SHC.drw_speaker) {
float v[3];
@@ -1408,30 +1602,30 @@ Gwn_Batch *DRW_cache_speaker_get(void)
int vidx = 0;
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 3 * segments * 2 + 4 * 4);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 3 * segments * 2 + 4 * 4);
for (int j = 0; j < 3; j++) {
float z = 0.25f * j - 0.125f;
float r = (j == 0 ? 0.5f : 0.25f);
copy_v3_fl3(v, r, 0.0f, z);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
for (int i = 1; i < segments; i++) {
float x = cosf(2.f * (float)M_PI * i / segments) * r;
float y = sinf(2.f * (float)M_PI * i / segments) * r;
copy_v3_fl3(v, x, y, z);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
}
copy_v3_fl3(v, r, 0.0f, z);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
}
for (int j = 0; j < 4; j++) {
@@ -1445,14 +1639,14 @@ Gwn_Batch *DRW_cache_speaker_get(void)
float z = 0.25f * i - 0.125f;
copy_v3_fl3(v, x, y, z);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
if (i == 1) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
}
}
}
- SHC.drw_speaker = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_speaker = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_speaker;
}
@@ -1464,7 +1658,7 @@ Gwn_Batch *DRW_cache_speaker_get(void)
/** \name Probe
* \{ */
-Gwn_Batch *DRW_cache_lightprobe_cube_get(void)
+GPUBatch *DRW_cache_lightprobe_cube_get(void)
{
if (!SHC.drw_lightprobe_cube) {
int v_idx = 0;
@@ -1481,35 +1675,35 @@ Gwn_Batch *DRW_cache_lightprobe_cube_get(void)
};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, (6 + 3) * 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, (6 + 3) * 2);
for (int i = 0; i < 6; ++i) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]);
}
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
- SHC.drw_lightprobe_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lightprobe_cube = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lightprobe_cube;
}
-Gwn_Batch *DRW_cache_lightprobe_grid_get(void)
+GPUBatch *DRW_cache_lightprobe_grid_get(void)
{
if (!SHC.drw_lightprobe_grid) {
int v_idx = 0;
@@ -1526,47 +1720,47 @@ Gwn_Batch *DRW_cache_lightprobe_grid_get(void)
};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, (6 * 2 + 3) * 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, (6 * 2 + 3) * 2);
for (int i = 0; i < 6; ++i) {
float tmp_v1[3], tmp_v2[3], tmp_tr[3];
copy_v3_v3(tmp_v1, v[i]);
copy_v3_v3(tmp_v2, v[(i + 1) % 6]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2);
/* Internal wires. */
for (int j = 1; j < 2; ++j) {
mul_v3_v3fl(tmp_tr, v[(i / 2) * 2 + 1], -0.5f * j);
add_v3_v3v3(tmp_v1, v[i], tmp_tr);
add_v3_v3v3(tmp_v2, v[(i + 1) % 6], tmp_tr);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2);
}
}
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
- SHC.drw_lightprobe_grid = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lightprobe_grid = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lightprobe_grid;
}
-Gwn_Batch *DRW_cache_lightprobe_planar_get(void)
+GPUBatch *DRW_cache_lightprobe_planar_get(void)
{
if (!SHC.drw_lightprobe_planar) {
int v_idx = 0;
@@ -1579,21 +1773,21 @@ Gwn_Batch *DRW_cache_lightprobe_planar_get(void)
};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 4 * 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 4 * 2);
for (int i = 0; i < 4; ++i) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 4]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 4]);
}
- SHC.drw_lightprobe_planar = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_lightprobe_planar = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_lightprobe_planar;
}
@@ -1702,45 +1896,45 @@ static const float bone_octahedral_solid_normals[8][3] = {
{ 0.00000000f, 0.11043154f, 0.99388373f}
};
-Gwn_Batch *DRW_cache_bone_octahedral_get(void)
+GPUBatch *DRW_cache_bone_octahedral_get(void)
{
if (!SHC.drw_bone_octahedral) {
uint v_idx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, nor, snor; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.snor = GPU_vertformat_attr_add(&format, "snor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
/* Vertices */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 24);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 24);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 3; ++j) {
- GWN_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]);
- GWN_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_octahedral_smooth_normals[bone_octahedral_solid_tris[i][j]]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][j]]);
+ GPU_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_octahedral_smooth_normals[bone_octahedral_solid_tris[i][j]]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][j]]);
}
}
- SHC.drw_bone_octahedral = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL,
- GWN_BATCH_OWNS_VBO);
+ SHC.drw_bone_octahedral = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL,
+ GPU_BATCH_OWNS_VBO);
}
return SHC.drw_bone_octahedral;
}
-Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void)
+GPUBatch *DRW_cache_bone_octahedral_wire_get(void)
{
if (!SHC.drw_bone_octahedral_wire) {
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, 12, 24);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 24);
for (int i = 0; i < 12; i++) {
- GWN_indexbuf_add_line_adj_verts(&elb,
+ GPU_indexbuf_add_line_adj_verts(&elb,
bone_octahedral_wire_lines_adjacency[i][0],
bone_octahedral_wire_lines_adjacency[i][1],
bone_octahedral_wire_lines_adjacency[i][2],
@@ -1748,10 +1942,10 @@ Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void)
}
/* HACK Reuse vertex buffer. */
- Gwn_Batch *pos_nor_batch = DRW_cache_bone_octahedral_get();
+ GPUBatch *pos_nor_batch = DRW_cache_bone_octahedral_get();
- SHC.drw_bone_octahedral_wire = GWN_batch_create_ex(GWN_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GWN_indexbuf_build(&elb),
- GWN_BATCH_OWNS_INDEX);
+ SHC.drw_bone_octahedral_wire = GPU_batch_create_ex(GPU_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GPU_indexbuf_build(&elb),
+ GPU_BATCH_OWNS_INDEX);
}
return SHC.drw_bone_octahedral_wire;
}
@@ -1868,45 +2062,45 @@ static const float bone_box_solid_normals[12][3] = {
{ 0.0f, 1.0f, 0.0f},
};
-Gwn_Batch *DRW_cache_bone_box_get(void)
+GPUBatch *DRW_cache_bone_box_get(void)
{
if (!SHC.drw_bone_box) {
uint v_idx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, nor, snor; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.snor = GPU_vertformat_attr_add(&format, "snor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
/* Vertices */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 36);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 36);
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 3; j++) {
- GWN_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_box_solid_normals[i]);
- GWN_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_box_smooth_normals[bone_box_solid_tris[i][j]]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_box_verts[bone_box_solid_tris[i][j]]);
+ GPU_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_box_solid_normals[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_box_smooth_normals[bone_box_solid_tris[i][j]]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_box_verts[bone_box_solid_tris[i][j]]);
}
}
- SHC.drw_bone_box = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL,
- GWN_BATCH_OWNS_VBO);
+ SHC.drw_bone_box = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL,
+ GPU_BATCH_OWNS_VBO);
}
return SHC.drw_bone_box;
}
-Gwn_Batch *DRW_cache_bone_box_wire_get(void)
+GPUBatch *DRW_cache_bone_box_wire_get(void)
{
if (!SHC.drw_bone_box_wire) {
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, 12, 36);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 36);
for (int i = 0; i < 12; i++) {
- GWN_indexbuf_add_line_adj_verts(&elb,
+ GPU_indexbuf_add_line_adj_verts(&elb,
bone_box_wire_lines_adjacency[i][0],
bone_box_wire_lines_adjacency[i][1],
bone_box_wire_lines_adjacency[i][2],
@@ -1914,10 +2108,10 @@ Gwn_Batch *DRW_cache_bone_box_wire_get(void)
}
/* HACK Reuse vertex buffer. */
- Gwn_Batch *pos_nor_batch = DRW_cache_bone_box_get();
+ GPUBatch *pos_nor_batch = DRW_cache_bone_box_get();
- SHC.drw_bone_box_wire = GWN_batch_create_ex(GWN_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GWN_indexbuf_build(&elb),
- GWN_BATCH_OWNS_INDEX);
+ SHC.drw_bone_box_wire = GPU_batch_create_ex(GPU_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GPU_indexbuf_build(&elb),
+ GPU_BATCH_OWNS_INDEX);
}
return SHC.drw_bone_box_wire;
}
@@ -1931,7 +2125,7 @@ static void benv_lat_lon_to_co(const float lat, const float lon, float r_nor[3])
r_nor[2] = cosf(lat);
}
-Gwn_Batch *DRW_cache_bone_envelope_solid_get(void)
+GPUBatch *DRW_cache_bone_envelope_solid_get(void)
{
if (!SHC.drw_bone_envelope) {
const int lon_res = 24;
@@ -1940,15 +2134,15 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void)
const float lat_inc = M_PI / lat_res;
uint v_idx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
/* Vertices */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, ((lat_res + 1) * 2) * lon_res * 1);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, ((lat_res + 1) * 2) * lon_res * 1);
float lon = 0.0f;
for (int i = 0; i < lon_res; i++, lon += lon_inc) {
@@ -1962,24 +2156,24 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void)
benv_lat_lon_to_co(lat, lon, co1);
benv_lat_lon_to_co(lat, lon + lon_inc, co2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2);
}
/* Closing the loop */
benv_lat_lon_to_co(M_PI, lon, co1);
benv_lat_lon_to_co(M_PI, lon + lon_inc, co2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2);
}
- SHC.drw_bone_envelope = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_bone_envelope = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_bone_envelope;
}
-Gwn_Batch *DRW_cache_bone_envelope_outline_get(void)
+GPUBatch *DRW_cache_bone_envelope_outline_get(void)
{
if (!SHC.drw_bone_envelope_outline) {
# define CIRCLE_RESOL 64
@@ -1987,16 +2181,16 @@ Gwn_Batch *DRW_cache_bone_envelope_outline_get(void)
const float radius = 1.0f;
/* Position Only 2D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos0, pos1, pos2; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.pos2 = GWN_vertformat_attr_add(&format, "pos2", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos0 = GPU_vertformat_attr_add(&format, "pos0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.pos1 = GPU_vertformat_attr_add(&format, "pos1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.pos2 = GPU_vertformat_attr_add(&format, "pos2", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2);
v0[0] = radius * sinf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL));
v0[1] = radius * cosf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL));
@@ -2008,31 +2202,31 @@ Gwn_Batch *DRW_cache_bone_envelope_outline_get(void)
for (int a = 0; a < CIRCLE_RESOL; a++) {
v2[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v2[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
- GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
- GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
copy_v2_v2(v0, v1);
copy_v2_v2(v1, v2);
}
v2[0] = 0.0f;
v2[1] = radius;
- GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
- GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
- GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
-
- SHC.drw_bone_envelope_outline = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
+
+ SHC.drw_bone_envelope_outline = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
# undef CIRCLE_RESOL
}
return SHC.drw_bone_envelope_outline;
}
-Gwn_Batch *DRW_cache_bone_point_get(void)
+GPUBatch *DRW_cache_bone_point_get(void)
{
if (!SHC.drw_bone_point) {
#if 0 /* old style geometry sphere */
@@ -2043,16 +2237,16 @@ Gwn_Batch *DRW_cache_bone_point_get(void)
const float lat_inc = M_PI / lat_res;
uint v_idx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, nor; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
/* Vertices */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, (lat_res - 1) * lon_res * 6);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, (lat_res - 1) * lon_res * 6);
float lon = 0.0f;
for (int i = 0; i < lon_res; i++, lon += lon_inc) {
@@ -2072,56 +2266,56 @@ Gwn_Batch *DRW_cache_bone_point_get(void)
}
}
- SHC.drw_bone_point = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_bone_point = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
#else
# define CIRCLE_RESOL 64
float v[2];
const float radius = 0.05f;
/* Position Only 2D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL);
for (int a = 0; a < CIRCLE_RESOL; a++) {
v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v);
}
- SHC.drw_bone_point = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_bone_point = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO);
# undef CIRCLE_RESOL
#endif
}
return SHC.drw_bone_point;
}
-Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void)
+GPUBatch *DRW_cache_bone_point_wire_outline_get(void)
{
if (!SHC.drw_bone_point_wire) {
#if 0 /* old style geometry sphere */
- Gwn_VertBuf *vbo = sphere_wire_vbo(0.05f);
- SHC.drw_bone_point_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ GPUVertBuf *vbo = sphere_wire_vbo(0.05f);
+ SHC.drw_bone_point_wire = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
#else
# define CIRCLE_RESOL 64
float v0[2], v1[2];
const float radius = 0.05f;
/* Position Only 2D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos0, pos1; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos0 = GPU_vertformat_attr_add(&format, "pos0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.pos1 = GPU_vertformat_attr_add(&format, "pos1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2);
v0[0] = radius * sinf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL));
v0[1] = radius * cosf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL));
@@ -2130,20 +2324,20 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void)
for (int a = 0; a < CIRCLE_RESOL; a++) {
v1[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v1[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
- GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
- GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1);
copy_v2_v2(v0, v1);
}
v1[0] = 0.0f;
v1[1] = radius;
- GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
- GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
- GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1);
- SHC.drw_bone_point_wire = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_bone_point_wire = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
# undef CIRCLE_RESOL
#endif
}
@@ -2160,7 +2354,7 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void)
#define POS_TAIL (1 << 5)
#define POS_BONE (1 << 6)
-Gwn_Batch *DRW_cache_bone_stick_get(void)
+GPUBatch *DRW_cache_bone_stick_get(void)
{
if (!SHC.drw_bone_stick) {
#define CIRCLE_RESOL 12
@@ -2170,20 +2364,20 @@ Gwn_Batch *DRW_cache_bone_stick_get(void)
float pos[2];
/* Position Only 2D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, flag; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.flag = GWN_vertformat_attr_add(&format, "flag", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.flag = GPU_vertformat_attr_add(&format, "flag", GPU_COMP_U32, 1, GPU_FETCH_INT);
}
const uint vcount = (CIRCLE_RESOL + 1) * 2 + 6;
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vcount);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vcount);
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init_ex(&elb, GWN_PRIM_TRI_FAN, (CIRCLE_RESOL + 2) * 2 + 6 + 2, vcount, true);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init_ex(&elb, GPU_PRIM_TRI_FAN, (CIRCLE_RESOL + 2) * 2 + 6 + 2, vcount, true);
/* head/tail points */
for (int i = 0; i < 2; ++i) {
@@ -2191,22 +2385,22 @@ Gwn_Batch *DRW_cache_bone_stick_get(void)
copy_v2_fl(pos, 0.0f);
flag = (i == 0) ? POS_HEAD : POS_TAIL;
flag |= (i == 0) ? COL_HEAD : COL_TAIL;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
- GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
- GWN_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
+ GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
/* circle vertices */
flag |= COL_WIRE;
for (int a = 0; a < CIRCLE_RESOL; a++) {
pos[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
pos[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
- GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
- GWN_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
+ GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
}
/* Close the circle */
- GWN_indexbuf_add_generic_vert(&elb, v - CIRCLE_RESOL);
+ GPU_indexbuf_add_generic_vert(&elb, v - CIRCLE_RESOL);
- GWN_indexbuf_add_primitive_restart(&elb);
+ GPU_indexbuf_add_primitive_restart(&elb);
}
/* Bone rectangle */
@@ -2215,25 +2409,25 @@ Gwn_Batch *DRW_cache_bone_stick_get(void)
pos[1] = (i == 0 || i == 3) ? 0.0f : ((i < 3) ? 1.0f : -1.0f);
flag = ((i < 2 || i > 4) ? POS_HEAD : POS_TAIL) |
((i == 0 || i == 3) ? 0 : COL_WIRE) | COL_BONE | POS_BONE;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
- GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
- GWN_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
+ GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
}
- SHC.drw_bone_stick = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, GWN_indexbuf_build(&elb),
- GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
+ SHC.drw_bone_stick = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, GPU_indexbuf_build(&elb),
+ GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
#undef CIRCLE_RESOL
}
return SHC.drw_bone_stick;
}
static void set_bone_axis_vert(
- Gwn_VertBuf *vbo, uint axis, uint pos, uint col,
+ GPUVertBuf *vbo, uint axis, uint pos, uint col,
uint *v, const float *a, const float *p, const float *c)
{
- GWN_vertbuf_attr_set(vbo, axis, *v, a);
- GWN_vertbuf_attr_set(vbo, pos, *v, p);
- GWN_vertbuf_attr_set(vbo, col, *v, c);
+ GPU_vertbuf_attr_set(vbo, axis, *v, a);
+ GPU_vertbuf_attr_set(vbo, pos, *v, p);
+ GPU_vertbuf_attr_set(vbo, col, *v, c);
*v += 1;
}
@@ -2308,21 +2502,21 @@ static float axis_name_shadow[8][2] = {
#undef S_X
#undef S_Y
-Gwn_Batch *DRW_cache_bone_arrows_get(void)
+GPUBatch *DRW_cache_bone_arrows_get(void)
{
if (!SHC.drw_bone_arrows) {
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint axis, pos, col; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.axis = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- attr_id.pos = GWN_vertformat_attr_add(&format, "screenPos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.col = GWN_vertformat_attr_add(&format, "colorAxis", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.axis = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "screenPos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.col = GPU_vertformat_attr_add(&format, "colorAxis", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
/* Line */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, (2 + MARKER_LEN * MARKER_FILL_LAYER) * 3 +
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, (2 + MARKER_LEN * MARKER_FILL_LAYER) * 3 +
(X_LEN + Y_LEN + Z_LEN) * (1 + SHADOW_RES));
uint v = 0;
@@ -2349,26 +2543,26 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void)
a = axis + 0.31f;
/* Axis name */
- int axis_v_ct;
+ int axis_v_len;
float (*axis_verts)[2];
if (axis == 0) {
axis_verts = x_axis_name;
- axis_v_ct = X_LEN;
+ axis_v_len = X_LEN;
}
else if (axis == 1) {
axis_verts = y_axis_name;
- axis_v_ct = Y_LEN;
+ axis_v_len = Y_LEN;
}
else {
axis_verts = z_axis_name;
- axis_v_ct = Z_LEN;
+ axis_v_len = Z_LEN;
}
/* Axis name shadows */
copy_v3_fl(c, 0.0f);
c[axis] = 0.3f;
for (int j = 0; j < SHADOW_RES; ++j) {
- for (int i = 0; i < axis_v_ct; ++i) {
+ for (int i = 0; i < axis_v_len; ++i) {
float tmp[2];
add_v2_v2v2(tmp, axis_verts[i], axis_name_shadow[j]);
set_bone_axis_vert(vbo, attr_id.axis, attr_id.pos, attr_id.col,
@@ -2379,13 +2573,13 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void)
/* Axis name */
copy_v3_fl(c, 0.1f);
c[axis] = 1.0f;
- for (int i = 0; i < axis_v_ct; ++i) {
+ for (int i = 0; i < axis_v_len; ++i) {
set_bone_axis_vert(vbo, attr_id.axis, attr_id.pos, attr_id.col,
&v, &a, axis_verts[i], c);
}
}
- SHC.drw_bone_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_bone_arrows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_bone_arrows;
}
@@ -2420,52 +2614,52 @@ static const float camera_coords_frame_tri[3] = {
/** Draw a loop of lines. */
static void camera_fill_lines_loop_fl_v1(
- Gwn_VertBufRaw *pos_step,
+ GPUVertBufRaw *pos_step,
const float *coords, const uint coords_len)
{
for (uint i = 0, i_prev = coords_len - 1; i < coords_len; i_prev = i++) {
- *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i_prev];
- *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i];
+ *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i_prev];
+ *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i];
}
}
/** Fan lines out from the first vertex. */
static void camera_fill_lines_fan_fl_v1(
- Gwn_VertBufRaw *pos_step,
+ GPUVertBufRaw *pos_step,
const float *coords, const uint coords_len)
{
for (uint i = 1; i < coords_len; i++) {
- *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[0];
- *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i];
+ *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[0];
+ *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i];
}
}
/** Simply fill the array. */
static void camera_fill_array_fl_v1(
- Gwn_VertBufRaw *pos_step,
+ GPUVertBufRaw *pos_step,
const float *coords, const uint coords_len)
{
for (uint i = 0; i < coords_len; i++) {
- *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i];
+ *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i];
}
}
-Gwn_Batch *DRW_cache_camera_get(void)
+GPUBatch *DRW_cache_camera_get(void)
{
if (!SHC.drw_camera) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
/* Vertices */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = 22;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
- Gwn_VertBufRaw pos_step;
- GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPUVertBufRaw pos_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
/* camera cone (from center to frame) */
camera_fill_lines_fan_fl_v1(&pos_step, camera_coords_frame_bounds, ARRAY_SIZE(camera_coords_frame_bounds));
@@ -2476,62 +2670,62 @@ Gwn_Batch *DRW_cache_camera_get(void)
/* camera triangle (above the frame) */
camera_fill_lines_loop_fl_v1(&pos_step, camera_coords_frame_tri, ARRAY_SIZE(camera_coords_frame_tri));
- BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step));
+ BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step));
- SHC.drw_camera = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_camera = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_camera;
}
-Gwn_Batch *DRW_cache_camera_frame_get(void)
+GPUBatch *DRW_cache_camera_frame_get(void)
{
if (!SHC.drw_camera_frame) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
/* Vertices */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = 8;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
- Gwn_VertBufRaw pos_step;
- GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPUVertBufRaw pos_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
/* camera frame (skip center) */
camera_fill_lines_loop_fl_v1(&pos_step, &camera_coords_frame_bounds[1], ARRAY_SIZE(camera_coords_frame_bounds) - 1);
- BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step));
+ BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step));
- SHC.drw_camera_frame = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_camera_frame = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_camera_frame;
}
-Gwn_Batch *DRW_cache_camera_tria_get(void)
+GPUBatch *DRW_cache_camera_tria_get(void)
{
if (!SHC.drw_camera_tria) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
/* Vertices */
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = 3;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
- Gwn_VertBufRaw pos_step;
- GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPUVertBufRaw pos_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
/* camera triangle (above the frame) */
camera_fill_array_fl_v1(&pos_step, camera_coords_frame_tri, ARRAY_SIZE(camera_coords_frame_tri));
- BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step));
+ BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step));
- SHC.drw_camera_tria = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_camera_tria = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_camera_tria;
}
@@ -2544,24 +2738,24 @@ Gwn_Batch *DRW_cache_camera_tria_get(void)
* \{ */
/* Object Center */
-Gwn_Batch *DRW_cache_single_vert_get(void)
+GPUBatch *DRW_cache_single_vert_get(void)
{
if (!SHC.drw_single_vertice) {
float v1[3] = {0.0f, 0.0f, 0.0f};
/* Position Only 3D format */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 1);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 1);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
- SHC.drw_single_vertice = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_single_vertice = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_single_vertice;
}
@@ -2573,7 +2767,7 @@ Gwn_Batch *DRW_cache_single_vert_get(void)
/** \name Meshes
* \{ */
-Gwn_Batch *DRW_cache_mesh_surface_overlay_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
@@ -2582,7 +2776,7 @@ Gwn_Batch *DRW_cache_mesh_surface_overlay_get(Object *ob)
void DRW_cache_mesh_wire_overlay_get(
Object *ob,
- Gwn_Batch **r_tris, Gwn_Batch **r_ledges, Gwn_Batch **r_lverts)
+ GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts)
{
BLI_assert(ob->type == OB_MESH);
@@ -2595,7 +2789,7 @@ void DRW_cache_mesh_wire_overlay_get(
void DRW_cache_mesh_normals_overlay_get(
Object *ob,
- Gwn_Batch **r_tris, Gwn_Batch **r_ledges, Gwn_Batch **r_lverts)
+ GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts)
{
BLI_assert(ob->type == OB_MESH);
@@ -2606,7 +2800,7 @@ void DRW_cache_mesh_normals_overlay_get(
*r_lverts = DRW_mesh_batch_cache_get_overlay_loose_verts(me);
}
-Gwn_Batch *DRW_cache_face_centers_get(Object *ob)
+GPUBatch *DRW_cache_face_centers_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2615,7 +2809,7 @@ Gwn_Batch *DRW_cache_face_centers_get(Object *ob)
return DRW_mesh_batch_cache_get_overlay_facedots(me);
}
-Gwn_Batch *DRW_cache_mesh_wire_outline_get(Object *ob)
+GPUBatch *DRW_cache_mesh_wire_outline_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2623,7 +2817,7 @@ Gwn_Batch *DRW_cache_mesh_wire_outline_get(Object *ob)
return DRW_mesh_batch_cache_get_fancy_edges(me);
}
-Gwn_Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
+GPUBatch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
{
BLI_assert(ob->type == OB_MESH);
@@ -2631,7 +2825,7 @@ Gwn_Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
return DRW_mesh_batch_cache_get_edge_detection(me, r_is_manifold);
}
-Gwn_Batch *DRW_cache_mesh_surface_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2639,7 +2833,7 @@ Gwn_Batch *DRW_cache_mesh_surface_get(Object *ob)
return DRW_mesh_batch_cache_get_triangles_with_normals(me);
}
-Gwn_Batch *DRW_cache_mesh_loose_edges_get(Object *ob)
+GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2647,7 +2841,7 @@ Gwn_Batch *DRW_cache_mesh_loose_edges_get(Object *ob)
return DRW_mesh_batch_cache_get_loose_edges_with_normals(me);
}
-Gwn_Batch *DRW_cache_mesh_surface_weights_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2655,7 +2849,7 @@ Gwn_Batch *DRW_cache_mesh_surface_weights_get(Object *ob)
return DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me, ob->actdef - 1);
}
-Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2664,7 +2858,7 @@ Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)
}
/* Return list of batches */
-Gwn_Batch **DRW_cache_mesh_surface_shaded_get(
+GPUBatch **DRW_cache_mesh_surface_shaded_get(
Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count)
{
@@ -2676,7 +2870,7 @@ Gwn_Batch **DRW_cache_mesh_surface_shaded_get(
}
/* Return list of batches */
-Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(Object *ob)
+GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2684,7 +2878,7 @@ Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(Object *ob)
return DRW_mesh_batch_cache_get_surface_texpaint(me);
}
-Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2692,7 +2886,7 @@ Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
return DRW_mesh_batch_cache_get_surface_texpaint_single(me);
}
-Gwn_Batch *DRW_cache_mesh_surface_verts_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_verts_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2700,7 +2894,7 @@ Gwn_Batch *DRW_cache_mesh_surface_verts_get(Object *ob)
return DRW_mesh_batch_cache_get_points_with_normals(me);
}
-Gwn_Batch *DRW_cache_mesh_edges_get(Object *ob)
+GPUBatch *DRW_cache_mesh_edges_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2708,7 +2902,7 @@ Gwn_Batch *DRW_cache_mesh_edges_get(Object *ob)
return DRW_mesh_batch_cache_get_all_edges(me);
}
-Gwn_Batch *DRW_cache_mesh_verts_get(Object *ob)
+GPUBatch *DRW_cache_mesh_verts_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2716,7 +2910,7 @@ Gwn_Batch *DRW_cache_mesh_verts_get(Object *ob)
return DRW_mesh_batch_cache_get_all_verts(me);
}
-Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool use_sel)
+GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool use_sel)
{
BLI_assert(ob->type == OB_MESH);
@@ -2724,7 +2918,7 @@ Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, boo
return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel);
}
-Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)
+GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2732,7 +2926,7 @@ Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)
return DRW_mesh_batch_cache_get_weight_overlay_faces(me);
}
-Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob)
+GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2755,7 +2949,7 @@ void DRW_cache_mesh_sculpt_coords_ensure(Object *ob)
/** \name Curve
* \{ */
-Gwn_Batch *DRW_cache_curve_edge_wire_get(Object *ob)
+GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
{
BLI_assert(ob->type == OB_CURVE);
@@ -2763,7 +2957,7 @@ Gwn_Batch *DRW_cache_curve_edge_wire_get(Object *ob)
return DRW_curve_batch_cache_get_wire_edge(cu, ob->curve_cache);
}
-Gwn_Batch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size)
+GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size)
{
BLI_assert(ob->type == OB_CURVE);
@@ -2771,7 +2965,7 @@ Gwn_Batch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size)
return DRW_curve_batch_cache_get_normal_edge(cu, ob->curve_cache, normal_size);
}
-Gwn_Batch *DRW_cache_curve_edge_overlay_get(Object *ob)
+GPUBatch *DRW_cache_curve_edge_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_CURVE);
@@ -2779,7 +2973,7 @@ Gwn_Batch *DRW_cache_curve_edge_overlay_get(Object *ob)
return DRW_curve_batch_cache_get_overlay_edges(cu);
}
-Gwn_Batch *DRW_cache_curve_vert_overlay_get(Object *ob)
+GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_CURVE);
@@ -2787,7 +2981,7 @@ Gwn_Batch *DRW_cache_curve_vert_overlay_get(Object *ob)
return DRW_curve_batch_cache_get_overlay_verts(cu);
}
-Gwn_Batch *DRW_cache_curve_surface_get(Object *ob)
+GPUBatch *DRW_cache_curve_surface_get(Object *ob)
{
BLI_assert(ob->type == OB_CURVE);
@@ -2796,7 +2990,7 @@ Gwn_Batch *DRW_cache_curve_surface_get(Object *ob)
}
/* Return list of batches */
-Gwn_Batch **DRW_cache_curve_surface_shaded_get(
+GPUBatch **DRW_cache_curve_surface_shaded_get(
Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
{
BLI_assert(ob->type == OB_CURVE);
@@ -2812,13 +3006,13 @@ Gwn_Batch **DRW_cache_curve_surface_shaded_get(
/** \name MetaBall
* \{ */
-Gwn_Batch *DRW_cache_mball_surface_get(Object *ob)
+GPUBatch *DRW_cache_mball_surface_get(Object *ob)
{
BLI_assert(ob->type == OB_MBALL);
return DRW_metaball_batch_cache_get_triangles_with_normals(ob);
}
-Gwn_Batch **DRW_cache_mball_surface_shaded_get(
+GPUBatch **DRW_cache_mball_surface_shaded_get(
Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
{
BLI_assert(ob->type == OB_MBALL);
@@ -2833,7 +3027,7 @@ Gwn_Batch **DRW_cache_mball_surface_shaded_get(
/** \name Font
* \{ */
-Gwn_Batch *DRW_cache_text_edge_wire_get(Object *ob)
+GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
@@ -2841,7 +3035,7 @@ Gwn_Batch *DRW_cache_text_edge_wire_get(Object *ob)
return DRW_curve_batch_cache_get_wire_edge(cu, ob->curve_cache);
}
-Gwn_Batch *DRW_cache_text_surface_get(Object *ob)
+GPUBatch *DRW_cache_text_surface_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
@@ -2851,7 +3045,7 @@ Gwn_Batch *DRW_cache_text_surface_get(Object *ob)
return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->curve_cache);
}
-Gwn_Batch **DRW_cache_text_surface_shaded_get(
+GPUBatch **DRW_cache_text_surface_shaded_get(
Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
{
BLI_assert(ob->type == OB_FONT);
@@ -2862,14 +3056,14 @@ Gwn_Batch **DRW_cache_text_surface_shaded_get(
return DRW_curve_batch_cache_get_surface_shaded(cu, ob->curve_cache, gpumat_array, gpumat_array_len);
}
-Gwn_Batch *DRW_cache_text_cursor_overlay_get(Object *ob)
+GPUBatch *DRW_cache_text_cursor_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
return DRW_curve_batch_cache_get_overlay_cursor(cu);
}
-Gwn_Batch *DRW_cache_text_select_overlay_get(Object *ob)
+GPUBatch *DRW_cache_text_select_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
@@ -2883,7 +3077,7 @@ Gwn_Batch *DRW_cache_text_select_overlay_get(Object *ob)
/** \name Surface
* \{ */
-Gwn_Batch *DRW_cache_surf_surface_get(Object *ob)
+GPUBatch *DRW_cache_surf_surface_get(Object *ob)
{
BLI_assert(ob->type == OB_SURF);
@@ -2892,7 +3086,7 @@ Gwn_Batch *DRW_cache_surf_surface_get(Object *ob)
}
/* Return list of batches */
-Gwn_Batch **DRW_cache_surf_surface_shaded_get(
+GPUBatch **DRW_cache_surf_surface_shaded_get(
Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
{
BLI_assert(ob->type == OB_SURF);
@@ -2908,7 +3102,7 @@ Gwn_Batch **DRW_cache_surf_surface_shaded_get(
/** \name Lattice
* \{ */
-Gwn_Batch *DRW_cache_lattice_verts_get(Object *ob)
+GPUBatch *DRW_cache_lattice_verts_get(Object *ob)
{
BLI_assert(ob->type == OB_LATTICE);
@@ -2916,7 +3110,7 @@ Gwn_Batch *DRW_cache_lattice_verts_get(Object *ob)
return DRW_lattice_batch_cache_get_all_verts(lt);
}
-Gwn_Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
+GPUBatch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
{
BLI_assert(ob->type == OB_LATTICE);
@@ -2930,7 +3124,7 @@ Gwn_Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
return DRW_lattice_batch_cache_get_all_edges(lt, use_weight, actdef);
}
-Gwn_Batch *DRW_cache_lattice_vert_overlay_get(Object *ob)
+GPUBatch *DRW_cache_lattice_vert_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_LATTICE);
@@ -2945,17 +3139,17 @@ Gwn_Batch *DRW_cache_lattice_vert_overlay_get(Object *ob)
/** \name Particles
* \{ */
-Gwn_Batch *DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md)
+GPUBatch *DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md)
{
return DRW_particles_batch_cache_get_hair(object, psys, md);
}
-Gwn_Batch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys)
+GPUBatch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys)
{
return DRW_particles_batch_cache_get_dots(object, psys);
}
-Gwn_Batch *DRW_cache_particles_get_edit_strands(
+GPUBatch *DRW_cache_particles_get_edit_strands(
Object *object,
ParticleSystem *psys,
struct PTCacheEdit *edit)
@@ -2963,7 +3157,7 @@ Gwn_Batch *DRW_cache_particles_get_edit_strands(
return DRW_particles_batch_cache_get_edit_strands(object, psys, edit);
}
-Gwn_Batch *DRW_cache_particles_get_edit_inner_points(
+GPUBatch *DRW_cache_particles_get_edit_inner_points(
Object *object,
ParticleSystem *psys,
struct PTCacheEdit *edit)
@@ -2971,7 +3165,7 @@ Gwn_Batch *DRW_cache_particles_get_edit_inner_points(
return DRW_particles_batch_cache_get_edit_inner_points(object, psys, edit);
}
-Gwn_Batch *DRW_cache_particles_get_edit_tip_points(
+GPUBatch *DRW_cache_particles_get_edit_tip_points(
Object *object,
ParticleSystem *psys,
struct PTCacheEdit *edit)
@@ -2979,100 +3173,100 @@ Gwn_Batch *DRW_cache_particles_get_edit_tip_points(
return DRW_particles_batch_cache_get_edit_tip_points(object, psys, edit);
}
-Gwn_Batch *DRW_cache_particles_get_prim(int type)
+GPUBatch *DRW_cache_particles_get_prim(int type)
{
switch (type) {
case PART_DRAW_CROSS:
if (!SHC.drw_particle_cross) {
- static Gwn_VertFormat format = { 0 };
- static unsigned pos_id, axis_id;
+ static GPUVertFormat format = { 0 };
+ static uint pos_id, axis_id;
- if (format.attrib_ct == 0) {
- pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 6);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 6);
/* X axis */
float co[3] = {-1.0f, 0.0f, 0.0f};
int axis = -1;
- GWN_vertbuf_attr_set(vbo, pos_id, 0, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 0, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 0, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 0, &axis);
co[0] = 1.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, 1, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 1, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 1, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 1, &axis);
/* Y axis */
co[0] = 0.0f;
co[1] = -1.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, 2, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 2, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 2, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 2, &axis);
co[1] = 1.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, 3, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 3, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 3, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 3, &axis);
/* Z axis */
co[1] = 0.0f;
co[2] = -1.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, 4, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 4, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 4, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 4, &axis);
co[2] = 1.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, 5, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 5, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 5, &axis);
- SHC.drw_particle_cross = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_particle_cross = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_particle_cross;
case PART_DRAW_AXIS:
if (!SHC.drw_particle_axis) {
- static Gwn_VertFormat format = { 0 };
- static unsigned pos_id, axis_id;
+ static GPUVertFormat format = { 0 };
+ static uint pos_id, axis_id;
- if (format.attrib_ct == 0) {
- pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 6);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 6);
/* X axis */
float co[3] = {0.0f, 0.0f, 0.0f};
int axis = 0;
- GWN_vertbuf_attr_set(vbo, pos_id, 0, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 0, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 0, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 0, &axis);
co[0] = 1.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, 1, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 1, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 1, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 1, &axis);
/* Y axis */
co[0] = 0.0f;
axis = 1;
- GWN_vertbuf_attr_set(vbo, pos_id, 2, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 2, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 2, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 2, &axis);
co[1] = 1.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, 3, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 3, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 3, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 3, &axis);
/* Z axis */
co[1] = 0.0f;
axis = 2;
- GWN_vertbuf_attr_set(vbo, pos_id, 4, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 4, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 4, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 4, &axis);
co[2] = 1.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, 5, co);
- GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, 5, co);
+ GPU_vertbuf_attr_set(vbo, axis_id, 5, &axis);
- SHC.drw_particle_axis = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_particle_axis = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_particle_axis;
@@ -3082,26 +3276,26 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type)
float v[3] = {0.0f, 0.0f, 0.0f};
int axis = -1;
- static Gwn_VertFormat format = { 0 };
- static unsigned pos_id, axis_id;
+ static GPUVertFormat format = { 0 };
+ static uint pos_id, axis_id;
- if (format.attrib_ct == 0) {
- pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL);
for (int a = 0; a < CIRCLE_RESOL; a++) {
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = 0.0f;
- GWN_vertbuf_attr_set(vbo, pos_id, a, v);
- GWN_vertbuf_attr_set(vbo, axis_id, a, &axis);
+ GPU_vertbuf_attr_set(vbo, pos_id, a, v);
+ GPU_vertbuf_attr_set(vbo, axis_id, a, &axis);
}
- SHC.drw_particle_circle = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ SHC.drw_particle_circle = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_particle_circle;
@@ -3115,9 +3309,9 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type)
}
/* 3D cursor */
-Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines)
+GPUBatch *DRW_cache_cursor_get(bool crosshair_lines)
{
- Gwn_Batch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle;
+ GPUBatch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle;
if (*drw_cursor == NULL) {
const float f5 = 0.25f;
@@ -3125,24 +3319,24 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines)
const float f20 = 1.0f;
const int segments = 16;
- const int vert_ct = segments + 8;
- const int index_ct = vert_ct + 5;
+ const int vert_len = segments + 8;
+ const int index_len = vert_len + 5;
- unsigned char red[3] = {255, 0, 0};
- unsigned char white[3] = {255, 255, 255};
+ uchar red[3] = {255, 0, 0};
+ uchar white[3] = {255, 255, 255};
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, color; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- attr_id.color = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ attr_id.color = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init_ex(&elb, GWN_PRIM_LINE_STRIP, index_ct, vert_ct, true);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len, true);
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vert_ct);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vert_len);
int v = 0;
for (int i = 0; i < segments; ++i) {
@@ -3151,59 +3345,59 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines)
float y = f10 * sinf(angle);
if (i % 2 == 0)
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, red);
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, red);
else
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, white);
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, white);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){x, y});
- GWN_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){x, y});
+ GPU_indexbuf_add_generic_vert(&elb, v++);
}
- GWN_indexbuf_add_generic_vert(&elb, 0);
+ GPU_indexbuf_add_generic_vert(&elb, 0);
if (crosshair_lines) {
- unsigned char crosshair_color[3];
+ uchar crosshair_color[3];
UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color);
- GWN_indexbuf_add_primitive_restart(&elb);
+ GPU_indexbuf_add_primitive_restart(&elb);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0});
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
- GWN_indexbuf_add_generic_vert(&elb, v++);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0});
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
- GWN_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0});
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0});
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
- GWN_indexbuf_add_primitive_restart(&elb);
+ GPU_indexbuf_add_primitive_restart(&elb);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0});
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
- GWN_indexbuf_add_generic_vert(&elb, v++);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0});
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
- GWN_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0});
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0});
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
- GWN_indexbuf_add_primitive_restart(&elb);
+ GPU_indexbuf_add_primitive_restart(&elb);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20});
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
- GWN_indexbuf_add_generic_vert(&elb, v++);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5});
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
- GWN_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20});
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5});
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
- GWN_indexbuf_add_primitive_restart(&elb);
+ GPU_indexbuf_add_primitive_restart(&elb);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5});
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
- GWN_indexbuf_add_generic_vert(&elb, v++);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20});
- GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
- GWN_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5});
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20});
+ GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
+ GPU_indexbuf_add_generic_vert(&elb, v++);
}
- Gwn_IndexBuf *ibo = GWN_indexbuf_build(&elb);
+ GPUIndexBuf *ibo = GPU_indexbuf_build(&elb);
- *drw_cursor = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, ibo, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
+ *drw_cursor = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, ibo, GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
}
return *drw_cursor;
}
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index e7ab847d42e..129c0252f30 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -26,7 +26,7 @@
#ifndef __DRAW_CACHE_H__
#define __DRAW_CACHE_H__
-struct Gwn_Batch;
+struct GPUBatch;
struct GPUMaterial;
struct ModifierData;
struct Object;
@@ -36,158 +36,162 @@ void DRW_shape_cache_free(void);
void DRW_shape_cache_reset(void);
/* 3D cursor */
-struct Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines);
+struct GPUBatch *DRW_cache_cursor_get(bool crosshair_lines);
/* Common Shapes */
-struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void);
-struct Gwn_Batch *DRW_cache_quad_get(void);
-struct Gwn_Batch *DRW_cache_sphere_get(void);
-struct Gwn_Batch *DRW_cache_single_vert_get(void);
-struct Gwn_Batch *DRW_cache_single_line_get(void);
-struct Gwn_Batch *DRW_cache_single_line_endpoints_get(void);
-struct Gwn_Batch *DRW_cache_screenspace_circle_get(void);
+struct GPUBatch *DRW_cache_fullscreen_quad_get(void);
+struct GPUBatch *DRW_cache_quad_get(void);
+struct GPUBatch *DRW_cache_cube_get(void);
+struct GPUBatch *DRW_cache_sphere_get(void);
+struct GPUBatch *DRW_cache_single_vert_get(void);
+struct GPUBatch *DRW_cache_single_line_get(void);
+struct GPUBatch *DRW_cache_single_line_endpoints_get(void);
+struct GPUBatch *DRW_cache_screenspace_circle_get(void);
/* Common Object */
-struct Gwn_Batch *DRW_cache_object_wire_outline_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold);
-struct Gwn_Batch *DRW_cache_object_surface_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob);
-struct Gwn_Batch **DRW_cache_object_surface_material_get(
+struct GPUBatch *DRW_cache_object_wire_outline_get(struct Object *ob);
+struct GPUBatch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold);
+struct GPUBatch *DRW_cache_object_surface_get(struct Object *ob);
+struct GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob);
+struct GPUBatch **DRW_cache_object_surface_material_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
void DRW_cache_object_face_wireframe_get(
Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count);
/* Empties */
-struct Gwn_Batch *DRW_cache_plain_axes_get(void);
-struct Gwn_Batch *DRW_cache_single_arrow_get(void);
-struct Gwn_Batch *DRW_cache_cube_get(void);
-struct Gwn_Batch *DRW_cache_circle_get(void);
-struct Gwn_Batch *DRW_cache_square_get(void);
-struct Gwn_Batch *DRW_cache_empty_sphere_get(void);
-struct Gwn_Batch *DRW_cache_empty_cone_get(void);
-struct Gwn_Batch *DRW_cache_arrows_get(void);
-struct Gwn_Batch *DRW_cache_axis_names_get(void);
-struct Gwn_Batch *DRW_cache_image_plane_get(void);
-struct Gwn_Batch *DRW_cache_image_plane_wire_get(void);
+struct GPUBatch *DRW_cache_plain_axes_get(void);
+struct GPUBatch *DRW_cache_single_arrow_get(void);
+struct GPUBatch *DRW_cache_empty_cube_get(void);
+struct GPUBatch *DRW_cache_circle_get(void);
+struct GPUBatch *DRW_cache_square_get(void);
+struct GPUBatch *DRW_cache_empty_sphere_get(void);
+struct GPUBatch *DRW_cache_empty_cylinder_get(void);
+struct GPUBatch *DRW_cache_empty_cone_get(void);
+struct GPUBatch *DRW_cache_empty_capsule_cap_get(void);
+struct GPUBatch *DRW_cache_empty_capsule_body_get(void);
+struct GPUBatch *DRW_cache_arrows_get(void);
+struct GPUBatch *DRW_cache_axis_names_get(void);
+struct GPUBatch *DRW_cache_image_plane_get(void);
+struct GPUBatch *DRW_cache_image_plane_wire_get(void);
/* Force Field */
-struct Gwn_Batch *DRW_cache_field_wind_get(void);
-struct Gwn_Batch *DRW_cache_field_force_get(void);
-struct Gwn_Batch *DRW_cache_field_vortex_get(void);
-struct Gwn_Batch *DRW_cache_field_tube_limit_get(void);
-struct Gwn_Batch *DRW_cache_field_cone_limit_get(void);
+struct GPUBatch *DRW_cache_field_wind_get(void);
+struct GPUBatch *DRW_cache_field_force_get(void);
+struct GPUBatch *DRW_cache_field_vortex_get(void);
+struct GPUBatch *DRW_cache_field_tube_limit_get(void);
+struct GPUBatch *DRW_cache_field_cone_limit_get(void);
/* Lamps */
-struct Gwn_Batch *DRW_cache_lamp_get(void);
-struct Gwn_Batch *DRW_cache_lamp_shadows_get(void);
-struct Gwn_Batch *DRW_cache_lamp_sunrays_get(void);
-struct Gwn_Batch *DRW_cache_lamp_area_square_get(void);
-struct Gwn_Batch *DRW_cache_lamp_area_disk_get(void);
-struct Gwn_Batch *DRW_cache_lamp_hemi_get(void);
-struct Gwn_Batch *DRW_cache_lamp_spot_get(void);
-struct Gwn_Batch *DRW_cache_lamp_spot_square_get(void);
+struct GPUBatch *DRW_cache_lamp_get(void);
+struct GPUBatch *DRW_cache_lamp_shadows_get(void);
+struct GPUBatch *DRW_cache_lamp_sunrays_get(void);
+struct GPUBatch *DRW_cache_lamp_area_square_get(void);
+struct GPUBatch *DRW_cache_lamp_area_disk_get(void);
+struct GPUBatch *DRW_cache_lamp_hemi_get(void);
+struct GPUBatch *DRW_cache_lamp_spot_get(void);
+struct GPUBatch *DRW_cache_lamp_spot_square_get(void);
/* Camera */
-struct Gwn_Batch *DRW_cache_camera_get(void);
-struct Gwn_Batch *DRW_cache_camera_frame_get(void);
-struct Gwn_Batch *DRW_cache_camera_tria_get(void);
+struct GPUBatch *DRW_cache_camera_get(void);
+struct GPUBatch *DRW_cache_camera_frame_get(void);
+struct GPUBatch *DRW_cache_camera_tria_get(void);
/* Speaker */
-struct Gwn_Batch *DRW_cache_speaker_get(void);
+struct GPUBatch *DRW_cache_speaker_get(void);
/* Probe */
-struct Gwn_Batch *DRW_cache_lightprobe_cube_get(void);
-struct Gwn_Batch *DRW_cache_lightprobe_grid_get(void);
-struct Gwn_Batch *DRW_cache_lightprobe_planar_get(void);
+struct GPUBatch *DRW_cache_lightprobe_cube_get(void);
+struct GPUBatch *DRW_cache_lightprobe_grid_get(void);
+struct GPUBatch *DRW_cache_lightprobe_planar_get(void);
/* Bones */
-struct Gwn_Batch *DRW_cache_bone_octahedral_get(void);
-struct Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void);
-struct Gwn_Batch *DRW_cache_bone_box_get(void);
-struct Gwn_Batch *DRW_cache_bone_box_wire_get(void);
-struct Gwn_Batch *DRW_cache_bone_envelope_solid_get(void);
-struct Gwn_Batch *DRW_cache_bone_envelope_outline_get(void);
-struct Gwn_Batch *DRW_cache_bone_envelope_head_wire_outline_get(void);
-struct Gwn_Batch *DRW_cache_bone_point_get(void);
-struct Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void);
-struct Gwn_Batch *DRW_cache_bone_stick_get(void);
-struct Gwn_Batch *DRW_cache_bone_arrows_get(void);
+struct GPUBatch *DRW_cache_bone_octahedral_get(void);
+struct GPUBatch *DRW_cache_bone_octahedral_wire_get(void);
+struct GPUBatch *DRW_cache_bone_box_get(void);
+struct GPUBatch *DRW_cache_bone_box_wire_get(void);
+struct GPUBatch *DRW_cache_bone_envelope_solid_get(void);
+struct GPUBatch *DRW_cache_bone_envelope_outline_get(void);
+struct GPUBatch *DRW_cache_bone_envelope_head_wire_outline_get(void);
+struct GPUBatch *DRW_cache_bone_point_get(void);
+struct GPUBatch *DRW_cache_bone_point_wire_outline_get(void);
+struct GPUBatch *DRW_cache_bone_stick_get(void);
+struct GPUBatch *DRW_cache_bone_arrows_get(void);
/* Meshes */
-struct Gwn_Batch *DRW_cache_mesh_surface_overlay_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_overlay_get(struct Object *ob);
void DRW_cache_mesh_wire_overlay_get(
struct Object *ob,
- struct Gwn_Batch **r_tris, struct Gwn_Batch **r_ledges, struct Gwn_Batch **r_lverts);
+ struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts);
void DRW_cache_mesh_normals_overlay_get(
struct Object *ob,
- struct Gwn_Batch **r_tris, struct Gwn_Batch **r_ledges, struct Gwn_Batch **r_lverts);
-struct Gwn_Batch *DRW_cache_face_centers_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold);
-struct Gwn_Batch *DRW_cache_mesh_surface_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_loose_edges_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_edges_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_verts_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel);
-struct Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
-struct Gwn_Batch **DRW_cache_mesh_surface_shaded_get(
+ struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts);
+struct GPUBatch *DRW_cache_face_centers_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold);
+struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_edges_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_verts_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel);
+struct GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
+struct GPUBatch **DRW_cache_mesh_surface_shaded_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
-struct Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
+struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob);
/* Curve */
-struct Gwn_Batch *DRW_cache_curve_surface_get(struct Object *ob);
-struct Gwn_Batch **DRW_cache_curve_surface_shaded_get(
+struct GPUBatch *DRW_cache_curve_surface_get(struct Object *ob);
+struct GPUBatch **DRW_cache_curve_surface_shaded_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
-struct Gwn_Batch *DRW_cache_curve_surface_verts_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_curve_edge_wire_get(struct Object *ob);
+struct GPUBatch *DRW_cache_curve_surface_verts_get(struct Object *ob);
+struct GPUBatch *DRW_cache_curve_edge_wire_get(struct Object *ob);
/* edit-mode */
-struct Gwn_Batch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size);
-struct Gwn_Batch *DRW_cache_curve_edge_overlay_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_curve_vert_overlay_get(struct Object *ob);
+struct GPUBatch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size);
+struct GPUBatch *DRW_cache_curve_edge_overlay_get(struct Object *ob);
+struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob);
/* Font */
-struct Gwn_Batch *DRW_cache_text_edge_wire_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_text_surface_get(struct Object *ob);
-struct Gwn_Batch **DRW_cache_text_surface_shaded_get(
+struct GPUBatch *DRW_cache_text_edge_wire_get(struct Object *ob);
+struct GPUBatch *DRW_cache_text_surface_get(struct Object *ob);
+struct GPUBatch **DRW_cache_text_surface_shaded_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
/* edit-mode */
-struct Gwn_Batch *DRW_cache_text_cursor_overlay_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_text_select_overlay_get(struct Object *ob);
+struct GPUBatch *DRW_cache_text_cursor_overlay_get(struct Object *ob);
+struct GPUBatch *DRW_cache_text_select_overlay_get(struct Object *ob);
/* Surface */
-struct Gwn_Batch *DRW_cache_surf_surface_get(struct Object *ob);
-struct Gwn_Batch **DRW_cache_surf_surface_shaded_get(
+struct GPUBatch *DRW_cache_surf_surface_get(struct Object *ob);
+struct GPUBatch **DRW_cache_surf_surface_shaded_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
/* Lattice */
-struct Gwn_Batch *DRW_cache_lattice_verts_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_lattice_wire_get(struct Object *ob, bool use_weight);
-struct Gwn_Batch *DRW_cache_lattice_vert_overlay_get(struct Object *ob);
+struct GPUBatch *DRW_cache_lattice_verts_get(struct Object *ob);
+struct GPUBatch *DRW_cache_lattice_wire_get(struct Object *ob, bool use_weight);
+struct GPUBatch *DRW_cache_lattice_vert_overlay_get(struct Object *ob);
/* Particles */
-struct Gwn_Batch *DRW_cache_particles_get_hair(
+struct GPUBatch *DRW_cache_particles_get_hair(
struct Object *object, struct ParticleSystem *psys, struct ModifierData *md);
-struct Gwn_Batch *DRW_cache_particles_get_dots(
+struct GPUBatch *DRW_cache_particles_get_dots(
struct Object *object, struct ParticleSystem *psys);
-struct Gwn_Batch *DRW_cache_particles_get_edit_strands(
+struct GPUBatch *DRW_cache_particles_get_edit_strands(
struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
-struct Gwn_Batch *DRW_cache_particles_get_edit_inner_points(
+struct GPUBatch *DRW_cache_particles_get_edit_inner_points(
struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
-struct Gwn_Batch *DRW_cache_particles_get_edit_tip_points(
+struct GPUBatch *DRW_cache_particles_get_edit_tip_points(
struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
-struct Gwn_Batch *DRW_cache_particles_get_prim(int type);
+struct GPUBatch *DRW_cache_particles_get_prim(int type);
/* Metaball */
-struct Gwn_Batch *DRW_cache_mball_surface_get(struct Object *ob);
-struct Gwn_Batch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
+struct GPUBatch *DRW_cache_mball_surface_get(struct Object *ob);
+struct GPUBatch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
#endif /* __DRAW_CACHE_H__ */
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 5773daf8e96..eeb7b1c41ee 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -29,9 +29,9 @@
struct CurveCache;
struct GPUMaterial;
struct GPUTexture;
-struct Gwn_Batch;
-struct Gwn_IndexBuf;
-struct Gwn_VertBuf;
+struct GPUBatch;
+struct GPUIndexBuf;
+struct GPUVertBuf;
struct ListBase;
struct ModifierData;
struct ParticleSystem;
@@ -59,71 +59,71 @@ void DRW_particle_batch_cache_dirty(struct ParticleSystem *psys, int mode);
void DRW_particle_batch_cache_free(struct ParticleSystem *psys);
/* Curve */
-struct Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu, struct CurveCache *ob_curve_cache);
-struct Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(
+struct GPUBatch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu, struct CurveCache *ob_curve_cache);
+struct GPUBatch *DRW_curve_batch_cache_get_normal_edge(
struct Curve *cu, struct CurveCache *ob_curve_cache, float normal_size);
-struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(struct Curve *cu);
-struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(struct Curve *cu);
+struct GPUBatch *DRW_curve_batch_cache_get_overlay_edges(struct Curve *cu);
+struct GPUBatch *DRW_curve_batch_cache_get_overlay_verts(struct Curve *cu);
-struct Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals(
+struct GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(
struct Curve *cu, struct CurveCache *ob_curve_cache);
-struct Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded(
+struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded(
struct Curve *cu, struct CurveCache *ob_curve_cache,
struct GPUMaterial **gpumat_array, uint gpumat_array_len);
/* Metaball */
-struct Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob);
-struct Gwn_Batch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
+struct GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob);
+struct GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
/* Curve (Font) */
-struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu);
-struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu);
+struct GPUBatch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu);
+struct GPUBatch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu);
/* DispList */
-struct Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(struct ListBase *lb);
-struct Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(struct ListBase *lb);
-struct Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(
+struct GPUVertBuf *DRW_displist_vertbuf_calc_pos_with_normals(struct ListBase *lb);
+struct GPUIndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(struct ListBase *lb);
+struct GPUIndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(
struct ListBase *lb, uint gpumat_array_len);
-struct Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(
+struct GPUBatch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(
struct ListBase *lb, uint gpumat_array_len);
/* Lattice */
-struct Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef);
-struct Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt);
-struct Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
+struct GPUBatch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef);
+struct GPUBatch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt);
+struct GPUBatch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
/* Mesh */
-struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(
+struct GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
-struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
+struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel);
+struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup);
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset);
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide);
+struct GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold);
+struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
/* edit-mesh selection (use generic function for faces) */
-struct Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset);
+struct GPUBatch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset);
+struct GPUBatch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset);
+struct GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset);
/* Object mode Wireframe overlays */
void DRW_mesh_batch_cache_get_wireframes_face_texbuf(
struct Mesh *me, struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count);
@@ -131,15 +131,15 @@ void DRW_mesh_batch_cache_get_wireframes_face_texbuf(
void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me);
/* Particles */
-struct Gwn_Batch *DRW_particles_batch_cache_get_hair(
+struct GPUBatch *DRW_particles_batch_cache_get_hair(
struct Object *object, struct ParticleSystem *psys, struct ModifierData *md);
-struct Gwn_Batch *DRW_particles_batch_cache_get_dots(
+struct GPUBatch *DRW_particles_batch_cache_get_dots(
struct Object *object, struct ParticleSystem *psys);
-struct Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(
+struct GPUBatch *DRW_particles_batch_cache_get_edit_strands(
struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
-struct Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(
+struct GPUBatch *DRW_particles_batch_cache_get_edit_inner_points(
struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
-struct Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(
+struct GPUBatch *DRW_particles_batch_cache_get_edit_tip_points(
struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
#endif /* __DRAW_CACHE_IMPL_H__ */
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 3939ea062e9..cfaa3c6914f 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -61,7 +61,7 @@ enum {
* TODO
* - Ensure `CurveCache`, `SEQUENCER_DAG_WORKAROUND`.
* - Check number of verts/edges to see if cache is valid.
- * - Check if 'overlay.edges' can use single attribyte per edge, not 2 (for selection drawing).
+ * - Check if 'overlay.edges' can use single attribute per edge, not 2 (for selection drawing).
*/
static void curve_batch_cache_clear(Curve *cu);
@@ -298,43 +298,43 @@ enum {
};
/* ---------------------------------------------------------------------- */
-/* Curve Gwn_Batch Cache */
+/* Curve GPUBatch Cache */
typedef struct CurveBatchCache {
/* center-line */
struct {
- Gwn_VertBuf *verts;
- Gwn_VertBuf *edges;
- Gwn_Batch *batch;
- Gwn_IndexBuf *elem;
+ GPUVertBuf *verts;
+ GPUVertBuf *edges;
+ GPUBatch *batch;
+ GPUIndexBuf *elem;
} wire;
/* normals */
struct {
- Gwn_VertBuf *verts;
- Gwn_VertBuf *edges;
- Gwn_Batch *batch;
- Gwn_IndexBuf *elem;
+ GPUVertBuf *verts;
+ GPUVertBuf *edges;
+ GPUBatch *batch;
+ GPUIndexBuf *elem;
} normal;
/* control handles and vertices */
struct {
- Gwn_Batch *edges;
- Gwn_Batch *verts;
+ GPUBatch *edges;
+ GPUBatch *verts;
} overlay;
struct {
- Gwn_VertBuf *verts;
- Gwn_IndexBuf *triangles_in_order;
- Gwn_Batch **shaded_triangles;
- Gwn_Batch *batch;
+ GPUVertBuf *verts;
+ GPUIndexBuf *triangles_in_order;
+ GPUBatch **shaded_triangles;
+ GPUBatch *batch;
int mat_len;
} surface;
/* 3d text */
struct {
- Gwn_Batch *select;
- Gwn_Batch *cursor;
+ GPUBatch *select;
+ GPUBatch *cursor;
} text;
/* settings to determine if cache is invalid */
@@ -348,7 +348,7 @@ typedef struct CurveBatchCache {
bool is_editmode;
} CurveBatchCache;
-/* Gwn_Batch cache management. */
+/* GPUBatch cache management. */
static bool curve_batch_cache_valid(Curve *cu)
{
@@ -434,12 +434,12 @@ void DRW_curve_batch_cache_dirty(Curve *cu, int mode)
break;
case BKE_CURVE_BATCH_DIRTY_SELECT:
/* editnurb */
- GWN_BATCH_DISCARD_SAFE(cache->overlay.verts);
- GWN_BATCH_DISCARD_SAFE(cache->overlay.edges);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay.verts);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay.edges);
/* editfont */
- GWN_BATCH_DISCARD_SAFE(cache->text.select);
- GWN_BATCH_DISCARD_SAFE(cache->text.cursor);
+ GPU_BATCH_DISCARD_SAFE(cache->text.select);
+ GPU_BATCH_DISCARD_SAFE(cache->text.cursor);
break;
default:
BLI_assert(0);
@@ -453,34 +453,34 @@ static void curve_batch_cache_clear(Curve *cu)
return;
}
- GWN_BATCH_DISCARD_SAFE(cache->overlay.verts);
- GWN_BATCH_DISCARD_SAFE(cache->overlay.edges);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay.verts);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay.edges);
- GWN_VERTBUF_DISCARD_SAFE(cache->surface.verts);
- GWN_INDEXBUF_DISCARD_SAFE(cache->surface.triangles_in_order);
+ GPU_VERTBUF_DISCARD_SAFE(cache->surface.verts);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->surface.triangles_in_order);
if (cache->surface.shaded_triangles) {
for (int i = 0; i < cache->surface.mat_len; ++i) {
- GWN_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]);
+ GPU_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]);
}
}
MEM_SAFE_FREE(cache->surface.shaded_triangles);
- GWN_BATCH_DISCARD_SAFE(cache->surface.batch);
+ GPU_BATCH_DISCARD_SAFE(cache->surface.batch);
/* don't own vbo & elems */
- GWN_BATCH_DISCARD_SAFE(cache->wire.batch);
- GWN_VERTBUF_DISCARD_SAFE(cache->wire.verts);
- GWN_VERTBUF_DISCARD_SAFE(cache->wire.edges);
- GWN_INDEXBUF_DISCARD_SAFE(cache->wire.elem);
+ GPU_BATCH_DISCARD_SAFE(cache->wire.batch);
+ GPU_VERTBUF_DISCARD_SAFE(cache->wire.verts);
+ GPU_VERTBUF_DISCARD_SAFE(cache->wire.edges);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->wire.elem);
/* don't own vbo & elems */
- GWN_BATCH_DISCARD_SAFE(cache->normal.batch);
- GWN_VERTBUF_DISCARD_SAFE(cache->normal.verts);
- GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges);
- GWN_INDEXBUF_DISCARD_SAFE(cache->normal.elem);
+ GPU_BATCH_DISCARD_SAFE(cache->normal.batch);
+ GPU_VERTBUF_DISCARD_SAFE(cache->normal.verts);
+ GPU_VERTBUF_DISCARD_SAFE(cache->normal.edges);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->normal.elem);
/* 3d text */
- GWN_BATCH_DISCARD_SAFE(cache->text.cursor);
- GWN_BATCH_DISCARD_SAFE(cache->text.select);
+ GPU_BATCH_DISCARD_SAFE(cache->text.cursor);
+ GPU_BATCH_DISCARD_SAFE(cache->text.select);
}
void DRW_curve_batch_cache_free(Curve *cu)
@@ -494,30 +494,30 @@ void DRW_curve_batch_cache_free(Curve *cu)
/** \name Private Curve Cache API
* \{ */
-/* Gwn_Batch cache usage. */
-static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, CurveBatchCache *cache)
+/* GPUBatch cache usage. */
+static GPUVertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, CurveBatchCache *cache)
{
BLI_assert(rdata->types & CU_DATATYPE_WIRE);
BLI_assert(rdata->ob_curve_cache != NULL);
if (cache->wire.verts == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
const int vert_len = curve_render_data_wire_verts_len_get(rdata);
- Gwn_VertBuf *vbo = cache->wire.verts = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vert_len);
+ GPUVertBuf *vbo = cache->wire.verts = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vert_len);
int vbo_len_used = 0;
for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) {
if (bl->nr > 0) {
const int i_end = vbo_len_used + bl->nr;
for (const BevPoint *bevp = bl->bevpoints; vbo_len_used < i_end; vbo_len_used++, bevp++) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bevp->vec);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bevp->vec);
}
}
}
@@ -527,7 +527,7 @@ static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, Cur
return cache->wire.verts;
}
-static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, CurveBatchCache *cache)
+static GPUIndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, CurveBatchCache *cache)
{
BLI_assert(rdata->types & CU_DATATYPE_WIRE);
BLI_assert(rdata->ob_curve_cache != NULL);
@@ -537,8 +537,8 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu
const int edge_len = curve_render_data_wire_edges_len_get(rdata);
int edge_len_used = 0;
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len);
int i = 0;
for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) {
@@ -554,7 +554,7 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu
i += 1;
}
for (; i < i_end; i_prev = i++) {
- GWN_indexbuf_add_line_verts(&elb, i_prev, i);
+ GPU_indexbuf_add_line_verts(&elb, i_prev, i);
edge_len_used += 1;
}
}
@@ -567,30 +567,30 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu
BLI_assert(edge_len_used == edge_len);
}
- cache->wire.elem = GWN_indexbuf_build(&elb);
+ cache->wire.elem = GPU_indexbuf_build(&elb);
}
return cache->wire.elem;
}
-static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, CurveBatchCache *cache)
+static GPUVertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, CurveBatchCache *cache)
{
BLI_assert(rdata->types & CU_DATATYPE_NORMAL);
BLI_assert(rdata->ob_curve_cache != NULL);
if (cache->normal.verts == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
const int normal_len = curve_render_data_normal_len_get(rdata);
const int vert_len = normal_len * 3;
- Gwn_VertBuf *vbo = cache->normal.verts = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vert_len);
+ GPUVertBuf *vbo = cache->normal.verts = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vert_len);
int vbo_len_used = 0;
const BevList *bl;
@@ -622,9 +622,9 @@ static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, C
add_v3_v3(vec_a, bevp->vec);
add_v3_v3(vec_b, bevp->vec);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_a);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, bevp->vec);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_b);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_a);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, bevp->vec);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_b);
bevp += skip + 1;
nr -= skip;
@@ -636,7 +636,7 @@ static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, C
return cache->normal.verts;
}
-static Gwn_IndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, CurveBatchCache *cache)
+static GPUIndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, CurveBatchCache *cache)
{
BLI_assert(rdata->types & CU_DATATYPE_NORMAL);
BLI_assert(rdata->ob_curve_cache != NULL);
@@ -646,19 +646,19 @@ static Gwn_IndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata,
const int vert_len = normal_len * 3;
const int edge_len = normal_len * 2;
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len);
int vbo_len_used = 0;
for (int i = 0; i < normal_len; i++) {
- GWN_indexbuf_add_line_verts(&elb, vbo_len_used + 0, vbo_len_used + 1);
- GWN_indexbuf_add_line_verts(&elb, vbo_len_used + 1, vbo_len_used + 2);
+ GPU_indexbuf_add_line_verts(&elb, vbo_len_used + 0, vbo_len_used + 1);
+ GPU_indexbuf_add_line_verts(&elb, vbo_len_used + 1, vbo_len_used + 2);
vbo_len_used += 3;
}
BLI_assert(vbo_len_used == vert_len);
- cache->normal.elem = GWN_indexbuf_build(&elb);
+ cache->normal.elem = GPU_indexbuf_build(&elb);
}
return cache->normal.elem;
@@ -673,18 +673,18 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
CurveRenderData *rdata = curve_render_data_create(cu, NULL, options);
if (cache->overlay.verts == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, data; } attr_id;
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = curve_render_data_overlay_verts_len_get(rdata);
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
int i = 0;
for (Nurb *nu = rdata->nurbs->first; nu; nu = nu->next) {
if (nu->bezt) {
@@ -697,16 +697,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
if (rdata->hide_handles) {
vflag = (bezt->f2 & SELECT) ?
(is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
- GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
else {
for (int j = 0; j < 3; j++) {
vflag = ((&bezt->f1)[j] & SELECT) ?
(is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]);
- GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]);
+ GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
}
@@ -721,8 +721,8 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
const bool is_active = (i == rdata->actvert);
char vflag;
vflag = (bp->f1 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp->vec);
- GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp->vec);
+ GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
i += 1;
@@ -731,29 +731,29 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
i += nu->pntsu;
}
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
- cache->overlay.verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ cache->overlay.verts = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
if ((cache->overlay.edges == NULL) && (rdata->hide_handles == false)) {
/* Note: we could reference indices to vertices (above) */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, data; } attr_id;
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
const int edge_len = curve_render_data_overlay_edges_len_get(rdata);
const int vbo_len_capacity = edge_len * 2;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
int i = 0;
for (Nurb *nu = rdata->nurbs->first; nu; nu = nu->next, i++) {
const bool is_active_nurb = (i == cu->actnu);
@@ -766,7 +766,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
for (int j = 0; j < 2; j += 1) {
/* same vertex twice, only check different selection */
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
vbo_len_used += 1;
col_id = (&bezt->h1)[j];
@@ -777,8 +777,8 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
col_id |= ACTIVE_NURB;
}
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j * 2]);
- GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j * 2]);
+ GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id);
vbo_len_used += 1;
}
}
@@ -794,11 +794,11 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
col_id |= ACTIVE_NURB;
}
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_prev->vec);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_prev->vec);
vbo_len_used += 1;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_curr->vec);
- GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_curr->vec);
+ GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id);
vbo_len_used += 1;
}
@@ -806,16 +806,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
}
}
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
- cache->overlay.edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ cache->overlay.edges = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
curve_render_data_free(rdata);
}
-static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, CurveBatchCache *cache)
+static GPUBatch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, CurveBatchCache *cache)
{
BLI_assert(rdata->types & CU_DATATYPE_SURFACE);
if (cache->surface.batch == NULL) {
@@ -827,8 +827,8 @@ static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata,
if (cache->surface.triangles_in_order == NULL) {
cache->surface.triangles_in_order = DRW_displist_indexbuf_calc_triangles_in_order(lb);
}
- cache->surface.batch = GWN_batch_create(
- GWN_PRIM_TRIS, cache->surface.verts, cache->surface.triangles_in_order);
+ cache->surface.batch = GPU_batch_create(
+ GPU_PRIM_TRIS, cache->surface.verts, cache->surface.triangles_in_order);
}
return cache->surface.batch;
@@ -843,21 +843,21 @@ static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata,
* \{ */
-static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, CurveBatchCache *cache)
+static GPUBatch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, CurveBatchCache *cache)
{
BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT);
if (cache->text.select == NULL) {
EditFont *ef = rdata->text.edit_font;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = ef->selboxes_len * 6;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
float box[4][3];
@@ -904,37 +904,37 @@ static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, C
add_v2_v2(box[3], &sb->x);
}
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[1]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[1]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]);
}
BLI_assert(vbo_len_used == vbo_len_capacity);
- cache->text.select = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ cache->text.select = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return cache->text.select;
}
-static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, CurveBatchCache *cache)
+static GPUBatch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, CurveBatchCache *cache)
{
BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT);
if (cache->text.cursor == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = 4;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
for (int i = 0; i < 4; i++) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]);
}
- cache->text.cursor = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ cache->text.cursor = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return cache->text.cursor;
}
@@ -946,7 +946,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, C
/** \name Public Object/Curve API
* \{ */
-Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache)
+GPUBatch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
@@ -954,8 +954,8 @@ Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_c
/* create batch from Curve */
CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_WIRE);
- cache->wire.batch = GWN_batch_create(
- GWN_PRIM_LINES,
+ cache->wire.batch = GPU_batch_create(
+ GPU_PRIM_LINES,
curve_batch_cache_get_wire_verts(rdata, cache),
curve_batch_cache_get_wire_edges(rdata, cache));
@@ -964,15 +964,15 @@ Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_c
return cache->wire.batch;
}
-Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cache, float normal_size)
+GPUBatch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cache, float normal_size)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
if (cache->normal.batch != NULL) {
cache->normal_size = normal_size;
if (cache->normal_size != normal_size) {
- GWN_BATCH_DISCARD_SAFE(cache->normal.batch);
- GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges);
+ GPU_BATCH_DISCARD_SAFE(cache->normal.batch);
+ GPU_VERTBUF_DISCARD_SAFE(cache->normal.edges);
}
}
cache->normal_size = normal_size;
@@ -981,8 +981,8 @@ Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve
/* create batch from Curve */
CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_NORMAL);
- cache->normal.batch = GWN_batch_create(
- GWN_PRIM_LINES,
+ cache->normal.batch = GPU_batch_create(
+ GPU_PRIM_LINES,
curve_batch_cache_get_normal_verts(rdata, cache),
curve_batch_cache_get_normal_edges(rdata, cache));
@@ -992,7 +992,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve
return cache->normal.batch;
}
-Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu)
+GPUBatch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
@@ -1003,7 +1003,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu)
return cache->overlay.edges;
}
-Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu)
+GPUBatch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
@@ -1014,7 +1014,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu)
return cache->overlay.verts;
}
-Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals(
+GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(
struct Curve *cu, struct CurveCache *ob_curve_cache)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
@@ -1030,7 +1030,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals(
return cache->surface.batch;
}
-Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded(
+GPUBatch **DRW_curve_batch_cache_get_surface_shaded(
struct Curve *cu, struct CurveCache *ob_curve_cache,
struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len)
{
@@ -1040,7 +1040,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded(
/* TODO: deduplicate code */
if (cache->surface.shaded_triangles) {
for (int i = 0; i < cache->surface.mat_len; ++i) {
- GWN_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]);
+ GPU_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]);
}
}
MEM_SAFE_FREE(cache->surface.shaded_triangles);
@@ -1058,7 +1058,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded(
else {
cache->surface.shaded_triangles = MEM_mallocN(
sizeof(*cache->surface.shaded_triangles) * gpumat_array_len, __func__);
- Gwn_IndexBuf **el = DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(
+ GPUIndexBuf **el = DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(
lb, gpumat_array_len);
if (cache->surface.verts == NULL) {
@@ -1066,8 +1066,8 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded(
}
for (int i = 0; i < gpumat_array_len; ++i) {
- cache->surface.shaded_triangles[i] = GWN_batch_create_ex(
- GWN_PRIM_TRIS, cache->surface.verts, el[i], GWN_BATCH_OWNS_INDEX);
+ cache->surface.shaded_triangles[i] = GPU_batch_create_ex(
+ GPU_PRIM_TRIS, cache->surface.verts, el[i], GPU_BATCH_OWNS_INDEX);
}
MEM_freeN(el); /* Save `el` in cache? */
@@ -1085,7 +1085,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded(
/** \name Public Object/Font API
* \{ */
-Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu)
+GPUBatch *DRW_curve_batch_cache_get_overlay_select(Curve *cu)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
@@ -1100,7 +1100,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu)
return cache->text.select;
}
-Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(Curve *cu)
+GPUBatch *DRW_curve_batch_cache_get_overlay_cursor(Curve *cu)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index 3eecff024a1..5ea0f6fb05d 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -87,49 +87,49 @@ static int curve_render_surface_tri_len_get(const ListBase *lb)
return tri_len;
}
-static void displist_indexbufbuilder_set(Gwn_IndexBufBuilder *elb, const DispList *dl, const int ofs)
+static void displist_indexbufbuilder_set(GPUIndexBufBuilder *elb, const DispList *dl, const int ofs)
{
if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) {
const int *idx = dl->index;
if (dl->type == DL_INDEX3) {
const int i_end = dl->parts;
for (int i = 0; i < i_end; i++, idx += 3) {
- GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs);
+ GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs);
}
}
else if (dl->type == DL_SURF) {
const int i_end = dl->totindex;
for (int i = 0; i < i_end; i++, idx += 4) {
- GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs);
- GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[3] + ofs, idx[2] + ofs);
+ GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs);
+ GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[3] + ofs, idx[2] + ofs);
}
}
else {
BLI_assert(dl->type == DL_INDEX4);
const int i_end = dl->parts;
for (int i = 0; i < i_end; i++, idx += 4) {
- GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs);
+ GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs);
if (idx[2] != idx[3]) {
- GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs);
+ GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs);
}
}
}
}
}
-Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb)
+GPUVertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb)
{
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, nor; } attr_id;
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, curve_render_surface_vert_len_get(lb));
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, curve_render_surface_vert_len_get(lb));
BKE_displist_normals_add(lb);
@@ -141,9 +141,9 @@ Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb)
const float *fp_no = dl->nors;
const int vbo_end = vbo_len_used + dl_vert_len(dl);
while (vbo_len_used < vbo_end) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co);
if (fp_no) {
- GWN_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, fp_no);
+ GPU_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, fp_no);
if (ndata_is_single == false) {
fp_no += 3;
}
@@ -157,13 +157,13 @@ Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb)
return vbo;
}
-Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb)
+GPUIndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb)
{
const int tri_len = curve_render_surface_tri_len_get(lb);
const int vert_len = curve_render_surface_vert_len_get(lb);
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len);
int ofs = 0;
for (const DispList *dl = lb->first; dl; dl = dl->next) {
@@ -171,14 +171,14 @@ Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb)
ofs += dl_vert_len(dl);
}
- return GWN_indexbuf_build(&elb);
+ return GPU_indexbuf_build(&elb);
}
-Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(ListBase *lb, uint gpumat_array_len)
+GPUIndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(ListBase *lb, uint gpumat_array_len)
{
- Gwn_IndexBuf **shaded_triangles_in_order = MEM_callocN(
+ GPUIndexBuf **shaded_triangles_in_order = MEM_callocN(
sizeof(*shaded_triangles_in_order) * gpumat_array_len, __func__);
- Gwn_IndexBufBuilder *elb = BLI_array_alloca(elb, gpumat_array_len);
+ GPUIndexBufBuilder *elb = BLI_array_alloca(elb, gpumat_array_len);
const int tri_len = curve_render_surface_tri_len_get(lb);
const int vert_len = curve_render_surface_vert_len_get(lb);
@@ -186,7 +186,7 @@ Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(L
/* Init each index buffer builder */
for (i = 0; i < gpumat_array_len; i++) {
- GWN_indexbuf_init(&elb[i], GWN_PRIM_TRIS, tri_len, vert_len);
+ GPU_indexbuf_init(&elb[i], GPU_PRIM_TRIS, tri_len, vert_len);
}
/* calc each index buffer builder */
@@ -198,56 +198,56 @@ Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(L
/* build each indexbuf */
for (i = 0; i < gpumat_array_len; i++) {
- shaded_triangles_in_order[i] = GWN_indexbuf_build(&elb[i]);
+ shaded_triangles_in_order[i] = GPU_indexbuf_build(&elb[i]);
}
return shaded_triangles_in_order;
}
static void displist_vertbuf_attr_set_tri_pos_normals_and_uv(
- Gwn_VertBufRaw *pos_step, Gwn_VertBufRaw *nor_step, Gwn_VertBufRaw *uv_step,
+ GPUVertBufRaw *pos_step, GPUVertBufRaw *nor_step, GPUVertBufRaw *uv_step,
const float v1[3], const float v2[3], const float v3[3],
const float n1[3], const float n2[3], const float n3[3],
const float uv1[2], const float uv2[2], const float uv3[2])
{
- copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v1);
- copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n1);
- copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv1);
+ copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v1);
+ copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n1);
+ copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv1);
- copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v2);
- copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n2);
- copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv2);
+ copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v2);
+ copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n2);
+ copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv2);
- copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v3);
- copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n3);
- copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv3);
+ copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v3);
+ copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n3);
+ copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv3);
}
-Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(ListBase *lb, uint gpumat_array_len)
+GPUBatch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(ListBase *lb, uint gpumat_array_len)
{
- static Gwn_VertFormat shaded_triangles_format = { 0 };
+ static GPUVertFormat shaded_triangles_format = { 0 };
static struct { uint pos, nor, uv; } attr_id;
- if (shaded_triangles_format.attrib_ct == 0) {
+ if (shaded_triangles_format.attr_len == 0) {
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&shaded_triangles_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.nor = GWN_vertformat_attr_add(&shaded_triangles_format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.uv = GWN_vertformat_attr_add(&shaded_triangles_format, "u", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ attr_id.pos = GPU_vertformat_attr_add(&shaded_triangles_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.nor = GPU_vertformat_attr_add(&shaded_triangles_format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.uv = GPU_vertformat_attr_add(&shaded_triangles_format, "u", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
- Gwn_Batch **shaded_triangles = MEM_mallocN(sizeof(*shaded_triangles) * gpumat_array_len, __func__);
+ GPUBatch **shaded_triangles = MEM_mallocN(sizeof(*shaded_triangles) * gpumat_array_len, __func__);
- Gwn_VertBuf **vbo = BLI_array_alloca(vbo, gpumat_array_len);
+ GPUVertBuf **vbo = BLI_array_alloca(vbo, gpumat_array_len);
uint *vbo_len_capacity = BLI_array_alloca(vbo_len_capacity, gpumat_array_len);
- Gwn_VertBufRaw *pos_step, *nor_step, *uv_step;
+ GPUVertBufRaw *pos_step, *nor_step, *uv_step;
pos_step = BLI_array_alloca(pos_step, gpumat_array_len);
nor_step = BLI_array_alloca(nor_step, gpumat_array_len);
uv_step = BLI_array_alloca(uv_step, gpumat_array_len);
/* Create each vertex buffer */
for (int i = 0; i < gpumat_array_len; i++) {
- vbo[i] = GWN_vertbuf_create_with_format(&shaded_triangles_format);
+ vbo[i] = GPU_vertbuf_create_with_format(&shaded_triangles_format);
vbo_len_capacity[i] = 0;
}
@@ -258,10 +258,10 @@ Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(Lis
/* Alloc each vertex buffer and get each raw data */
for (int i = 0; i < gpumat_array_len; i++) {
- GWN_vertbuf_data_alloc(vbo[i], vbo_len_capacity[i]);
- GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.pos, &pos_step[i]);
- GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.nor, &nor_step[i]);
- GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.uv, &uv_step[i]);
+ GPU_vertbuf_data_alloc(vbo[i], vbo_len_capacity[i]);
+ GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.pos, &pos_step[i]);
+ GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.nor, &nor_step[i]);
+ GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.uv, &uv_step[i]);
}
BKE_displist_normals_add(lb);
@@ -388,11 +388,11 @@ Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(Lis
}
for (int i = 0; i < gpumat_array_len; i++) {
- uint vbo_len_used = GWN_vertbuf_raw_used(&pos_step[i]);
+ uint vbo_len_used = GPU_vertbuf_raw_used(&pos_step[i]);
if (vbo_len_capacity[i] != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo[i], vbo_len_used);
+ GPU_vertbuf_data_resize(vbo[i], vbo_len_used);
}
- shaded_triangles[i] = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo[i], NULL, GWN_BATCH_OWNS_VBO);
+ shaded_triangles[i] = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo[i], NULL, GPU_BATCH_OWNS_VBO);
}
return shaded_triangles;
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c
index 6046d9854fb..d6acc4112d6 100644
--- a/source/blender/draw/intern/draw_cache_impl_lattice.c
+++ b/source/blender/draw/intern/draw_cache_impl_lattice.c
@@ -279,16 +279,16 @@ enum {
};
/* ---------------------------------------------------------------------- */
-/* Lattice Gwn_Batch Cache */
+/* Lattice GPUBatch Cache */
typedef struct LatticeBatchCache {
- Gwn_VertBuf *pos;
- Gwn_IndexBuf *edges;
+ GPUVertBuf *pos;
+ GPUIndexBuf *edges;
- Gwn_Batch *all_verts;
- Gwn_Batch *all_edges;
+ GPUBatch *all_verts;
+ GPUBatch *all_edges;
- Gwn_Batch *overlay_verts;
+ GPUBatch *overlay_verts;
/* settings to determine if cache is invalid */
bool is_dirty;
@@ -301,7 +301,7 @@ typedef struct LatticeBatchCache {
bool is_editmode;
} LatticeBatchCache;
-/* Gwn_Batch cache management. */
+/* GPUBatch cache management. */
static bool lattice_batch_cache_valid(Lattice *lt)
{
@@ -373,7 +373,7 @@ void DRW_lattice_batch_cache_dirty(Lattice *lt, int mode)
break;
case BKE_LATTICE_BATCH_DIRTY_SELECT:
/* TODO Separate Flag vbo */
- GWN_BATCH_DISCARD_SAFE(cache->overlay_verts);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_verts);
break;
default:
BLI_assert(0);
@@ -387,12 +387,12 @@ static void lattice_batch_cache_clear(Lattice *lt)
return;
}
- GWN_BATCH_DISCARD_SAFE(cache->all_verts);
- GWN_BATCH_DISCARD_SAFE(cache->all_edges);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_verts);
+ GPU_BATCH_DISCARD_SAFE(cache->all_verts);
+ GPU_BATCH_DISCARD_SAFE(cache->all_edges);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_verts);
- GWN_VERTBUF_DISCARD_SAFE(cache->pos);
- GWN_INDEXBUF_DISCARD_SAFE(cache->edges);
+ GPU_VERTBUF_DISCARD_SAFE(cache->pos);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->edges);
}
void DRW_lattice_batch_cache_free(Lattice *lt)
@@ -401,38 +401,38 @@ void DRW_lattice_batch_cache_free(Lattice *lt)
MEM_SAFE_FREE(lt->batch_cache);
}
-/* Gwn_Batch cache usage. */
-static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache,
+/* GPUBatch cache usage. */
+static GPUVertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache,
bool use_weight, const int actdef)
{
BLI_assert(rdata->types & LR_DATATYPE_VERT);
if (cache->pos == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, col; } attr_id;
- GWN_vertformat_clear(&format);
+ GPU_vertformat_clear(&format);
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
if (use_weight) {
- attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
}
const int vert_len = lattice_render_data_verts_len_get(rdata);
- cache->pos = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(cache->pos, vert_len);
+ cache->pos = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(cache->pos, vert_len);
for (int i = 0; i < vert_len; ++i) {
const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i);
- GWN_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec);
+ GPU_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec);
if (use_weight) {
float w_col[4];
lattice_render_data_weight_col_get(rdata, i, actdef, w_col);
- GWN_vertbuf_attr_set(cache->pos, attr_id.col, i, w_col);
+ GPU_vertbuf_attr_set(cache->pos, attr_id.col, i, w_col);
}
}
}
@@ -440,7 +440,7 @@ static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, Lattic
return cache->pos;
}
-static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, LatticeBatchCache *cache)
+static GPUIndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, LatticeBatchCache *cache)
{
BLI_assert(rdata->types & (LR_DATATYPE_VERT | LR_DATATYPE_EDGE));
@@ -449,8 +449,8 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat
const int edge_len = lattice_render_data_edges_len_get(rdata);
int edge_len_real = 0;
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len);
#define LATT_INDEX(u, v, w) \
((((w) * rdata->dims.v_len + (v)) * rdata->dims.u_len) + (u))
@@ -463,17 +463,17 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat
int uxt = (u == 0 || u == rdata->dims.u_len - 1);
if (w && ((uxt || vxt) || !rdata->show_only_outside)) {
- GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w));
+ GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w));
BLI_assert(edge_len_real <= edge_len);
edge_len_real++;
}
if (v && ((uxt || wxt) || !rdata->show_only_outside)) {
- GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v - 1, w), LATT_INDEX(u, v, w));
+ GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v - 1, w), LATT_INDEX(u, v, w));
BLI_assert(edge_len_real <= edge_len);
edge_len_real++;
}
if (u && ((vxt || wxt) || !rdata->show_only_outside)) {
- GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u - 1, v, w), LATT_INDEX(u, v, w));
+ GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u - 1, v, w), LATT_INDEX(u, v, w));
BLI_assert(edge_len_real <= edge_len);
edge_len_real++;
}
@@ -490,7 +490,7 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat
BLI_assert(edge_len_real == edge_len);
}
- cache->edges = GWN_indexbuf_build(&elb);
+ cache->edges = GPU_indexbuf_build(&elb);
}
return cache->edges;
@@ -505,18 +505,18 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt)
LatticeRenderData *rdata = lattice_render_data_create(lt, options);
if (cache->overlay_verts == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, data; } attr_id;
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT);
}
const int vert_len = lattice_render_data_verts_len_get(rdata);
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vert_len);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vert_len);
for (int i = 0; i < vert_len; ++i) {
const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i);
@@ -530,17 +530,17 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt)
}
}
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i, bp->vec);
- GWN_vertbuf_attr_set(vbo, attr_id.data, i, &vflag);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, bp->vec);
+ GPU_vertbuf_attr_set(vbo, attr_id.data, i, &vflag);
}
- cache->overlay_verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ cache->overlay_verts = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
lattice_render_data_free(rdata);
}
-Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, const int actdef)
+GPUBatch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, const int actdef)
{
LatticeBatchCache *cache = lattice_batch_cache_get(lt);
@@ -548,7 +548,7 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, c
/* create batch from Lattice */
LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT | LR_DATATYPE_EDGE);
- cache->all_edges = GWN_batch_create(GWN_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache, use_weight, actdef),
+ cache->all_edges = GPU_batch_create(GPU_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache, use_weight, actdef),
lattice_batch_cache_get_edges(rdata, cache));
lattice_render_data_free(rdata);
@@ -557,14 +557,14 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, c
return cache->all_edges;
}
-Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt)
+GPUBatch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt)
{
LatticeBatchCache *cache = lattice_batch_cache_get(lt);
if (cache->all_verts == NULL) {
LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT);
- cache->all_verts = GWN_batch_create(GWN_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache, false, -1), NULL);
+ cache->all_verts = GPU_batch_create(GPU_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache, false, -1), NULL);
lattice_render_data_free(rdata);
}
@@ -572,7 +572,7 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt)
return cache->all_verts;
}
-Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(Lattice *lt)
+GPUBatch *DRW_lattice_batch_cache_get_overlay_verts(Lattice *lt)
{
LatticeBatchCache *cache = lattice_batch_cache_get(lt);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 687f116bbbf..87737fae820 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -116,10 +116,10 @@ typedef struct EdgeAdjacentVerts {
} EdgeAdjacentVerts;
typedef struct EdgeDrawAttr {
- unsigned char v_flag;
- unsigned char e_flag;
- unsigned char crease;
- unsigned char bweight;
+ uchar v_flag;
+ uchar e_flag;
+ uchar crease;
+ uchar bweight;
} EdgeDrawAttr;
typedef struct MeshRenderData {
@@ -202,8 +202,8 @@ typedef struct MeshRenderData {
float (*poly_normals)[3];
float (*vert_weight_color)[3];
char (*vert_color)[3];
- Gwn_PackedNormal *poly_normals_pack;
- Gwn_PackedNormal *vert_normals_pack;
+ GPUPackedNormal *poly_normals_pack;
+ GPUPackedNormal *vert_normals_pack;
bool *edge_select_bool;
} MeshRenderData;
@@ -952,7 +952,7 @@ static int mesh_render_data_polys_len_get(const MeshRenderData *rdata)
/** Ensure #MeshRenderData.poly_normals_pack */
static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata)
{
- Gwn_PackedNormal *pnors_pack = rdata->poly_normals_pack;
+ GPUPackedNormal *pnors_pack = rdata->poly_normals_pack;
if (pnors_pack == NULL) {
if (rdata->edit_bmesh) {
BMesh *bm = rdata->edit_bmesh->bm;
@@ -962,7 +962,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata)
pnors_pack = rdata->poly_normals_pack = MEM_mallocN(sizeof(*pnors_pack) * rdata->poly_len, __func__);
BM_ITER_MESH_INDEX(efa, &fiter, bm, BM_FACES_OF_MESH, i) {
- pnors_pack[i] = GWN_normal_convert_i10_v3(efa->no);
+ pnors_pack[i] = GPU_normal_convert_i10_v3(efa->no);
}
}
else {
@@ -977,7 +977,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata)
pnors_pack = rdata->poly_normals_pack = MEM_mallocN(sizeof(*pnors_pack) * rdata->poly_len, __func__);
for (int i = 0; i < rdata->poly_len; i++) {
- pnors_pack[i] = GWN_normal_convert_i10_v3(pnors[i]);
+ pnors_pack[i] = GPU_normal_convert_i10_v3(pnors[i]);
}
}
}
@@ -986,7 +986,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata)
/** Ensure #MeshRenderData.vert_normals_pack */
static void mesh_render_data_ensure_vert_normals_pack(MeshRenderData *rdata)
{
- Gwn_PackedNormal *vnors_pack = rdata->vert_normals_pack;
+ GPUPackedNormal *vnors_pack = rdata->vert_normals_pack;
if (vnors_pack == NULL) {
if (rdata->edit_bmesh) {
BMesh *bm = rdata->edit_bmesh->bm;
@@ -996,7 +996,7 @@ static void mesh_render_data_ensure_vert_normals_pack(MeshRenderData *rdata)
vnors_pack = rdata->vert_normals_pack = MEM_mallocN(sizeof(*vnors_pack) * rdata->vert_len, __func__);
BM_ITER_MESH_INDEX(eve, &viter, bm, BM_VERT, i) {
- vnors_pack[i] = GWN_normal_convert_i10_v3(eve->no);
+ vnors_pack[i] = GPU_normal_convert_i10_v3(eve->no);
}
}
else {
@@ -1349,9 +1349,9 @@ enum {
* (see gpu_shader_edit_mesh_overlay_geom.glsl) */
};
-static unsigned char mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace *efa)
+static uchar mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace *efa)
{
- unsigned char fflag = 0;
+ uchar fflag = 0;
if (efa == rdata->efa_act)
fflag |= VFLAG_FACE_ACTIVE;
@@ -1397,10 +1397,10 @@ static void mesh_render_data_edge_flag(
}
}
-static unsigned char mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *eve)
+static uchar mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *eve)
{
- unsigned char vflag = 0;
+ uchar vflag = 0;
/* Current vertex */
if (eve == rdata->eve_act)
@@ -1413,12 +1413,12 @@ static unsigned char mesh_render_data_vertex_flag(MeshRenderData *rdata, const B
}
static void add_overlay_tri(
- MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data,
+ MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data,
const uint pos_id, const uint vnor_id, const uint lnor_id, const uint data_id,
const BMLoop **bm_looptri, const int base_vert_idx)
{
- unsigned char fflag;
- unsigned char vflag;
+ uchar fflag;
+ uchar vflag;
if (vbo_pos) {
/* TODO(sybren): deduplicate this and all the other places it's pasted to in this file. */
@@ -1426,24 +1426,24 @@ static void add_overlay_tri(
for (uint i = 0; i < 3; i++) {
int vidx = BM_elem_index_get(bm_looptri[i]->v);
const float *pos = rdata->edit_data->vertexCos[vidx];
- GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos);
+ GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos);
}
}
else {
for (uint i = 0; i < 3; i++) {
const float *pos = bm_looptri[i]->v->co;
- GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos);
+ GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos);
}
}
}
if (vbo_nor) {
/* TODO real loop normal */
- Gwn_PackedNormal lnor = GWN_normal_convert_i10_v3(bm_looptri[0]->f->no);
+ GPUPackedNormal lnor = GPU_normal_convert_i10_v3(bm_looptri[0]->f->no);
for (uint i = 0; i < 3; i++) {
- Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(bm_looptri[i]->v->no);
- GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor);
- GWN_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor);
+ GPUPackedNormal vnor = GPU_normal_convert_i10_v3(bm_looptri[i]->v->no);
+ GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor);
+ GPU_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor);
}
}
@@ -1457,7 +1457,7 @@ static void add_overlay_tri(
mesh_render_data_edge_flag(rdata, bm_looptri[i_next]->e, &eattr);
}
eattr.v_flag = fflag | vflag;
- GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr);
+ GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr);
i_prev = i;
i = i_next;
@@ -1466,7 +1466,7 @@ static void add_overlay_tri(
}
static void add_overlay_loose_edge(
- MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data,
+ MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data,
const uint pos_id, const uint vnor_id, const uint data_id,
const BMEdge *eed, const int base_vert_idx)
{
@@ -1476,21 +1476,21 @@ static void add_overlay_loose_edge(
for (uint i = 0; i < 2; i++) {
int vidx = BM_elem_index_get((&eed->v1)[i]);
const float *pos = rdata->edit_data->vertexCos[vidx];
- GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos);
+ GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos);
}
}
else {
for (int i = 0; i < 2; ++i) {
const float *pos = (&eed->v1)[i]->co;
- GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos);
+ GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos);
}
}
}
if (vbo_nor) {
for (int i = 0; i < 2; ++i) {
- Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3((&eed->v1)[i]->no);
- GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor);
+ GPUPackedNormal vnor = GPU_normal_convert_i10_v3((&eed->v1)[i]->no);
+ GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor);
}
}
@@ -1499,13 +1499,13 @@ static void add_overlay_loose_edge(
mesh_render_data_edge_flag(rdata, eed, &eattr);
for (int i = 0; i < 2; ++i) {
eattr.v_flag = mesh_render_data_vertex_flag(rdata, (&eed->v1)[i]);
- GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr);
+ GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr);
}
}
}
static void add_overlay_loose_vert(
- MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data,
+ MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data,
const uint pos_id, const uint vnor_id, const uint data_id,
const BMVert *eve, const int base_vert_idx)
{
@@ -1514,23 +1514,23 @@ static void add_overlay_loose_vert(
if (rdata->edit_data && rdata->edit_data->vertexCos) {
int vidx = BM_elem_index_get(eve);
const float *pos = rdata->edit_data->vertexCos[vidx];
- GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos);
+ GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos);
}
else {
const float *pos = eve->co;
- GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos);
+ GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos);
}
}
if (vbo_nor) {
- Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(eve->no);
- GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx, &vnor);
+ GPUPackedNormal vnor = GPU_normal_convert_i10_v3(eve->no);
+ GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx, &vnor);
}
if (vbo_data) {
- unsigned char vflag[4] = {0, 0, 0, 0};
+ uchar vflag[4] = {0, 0, 0, 0};
vflag[0] = mesh_render_data_vertex_flag(rdata, eve);
- GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx, vflag);
+ GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx, vflag);
}
}
@@ -1539,102 +1539,102 @@ static void add_overlay_loose_vert(
/* ---------------------------------------------------------------------- */
-/** \name Mesh Gwn_Batch Cache
+/** \name Mesh GPUBatch Cache
* \{ */
typedef struct MeshBatchCache {
- Gwn_VertBuf *pos_in_order;
- Gwn_IndexBuf *edges_in_order;
- Gwn_IndexBuf *edges_adjacency; /* Store edges with adjacent vertices. */
- Gwn_IndexBuf *triangles_in_order;
- Gwn_IndexBuf *ledges_in_order;
+ GPUVertBuf *pos_in_order;
+ GPUIndexBuf *edges_in_order;
+ GPUIndexBuf *edges_adjacency; /* Store edges with adjacent vertices. */
+ GPUIndexBuf *triangles_in_order;
+ GPUIndexBuf *ledges_in_order;
GPUTexture *pos_in_order_tx; /* Depending on pos_in_order */
- Gwn_Batch *all_verts;
- Gwn_Batch *all_edges;
- Gwn_Batch *all_triangles;
+ GPUBatch *all_verts;
+ GPUBatch *all_edges;
+ GPUBatch *all_triangles;
- Gwn_VertBuf *pos_with_normals;
- Gwn_VertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */
+ GPUVertBuf *pos_with_normals;
+ GPUVertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */
/**
* Other uses are all positions or loose elements.
* This stores all visible elements, needed for selection.
*/
- Gwn_VertBuf *ed_fcenter_pos_with_nor_and_sel;
- Gwn_VertBuf *ed_edge_pos;
- Gwn_VertBuf *ed_vert_pos;
+ GPUVertBuf *ed_fcenter_pos_with_nor_and_sel;
+ GPUVertBuf *ed_edge_pos;
+ GPUVertBuf *ed_vert_pos;
- Gwn_Batch *triangles_with_normals;
- Gwn_Batch *ledges_with_normals;
+ GPUBatch *triangles_with_normals;
+ GPUBatch *ledges_with_normals;
/* Skip hidden (depending on paint select mode) */
- Gwn_Batch *triangles_with_weights;
- Gwn_Batch *triangles_with_vert_colors;
+ GPUBatch *triangles_with_weights;
+ GPUBatch *triangles_with_vert_colors;
/* Always skip hidden */
- Gwn_Batch *triangles_with_select_mask;
- Gwn_Batch *triangles_with_select_id;
+ GPUBatch *triangles_with_select_mask;
+ GPUBatch *triangles_with_select_id;
uint triangles_with_select_id_offset;
- Gwn_Batch *facedot_with_select_id; /* shares vbo with 'overlay_facedots' */
- Gwn_Batch *edges_with_select_id;
- Gwn_Batch *verts_with_select_id;
+ GPUBatch *facedot_with_select_id; /* shares vbo with 'overlay_facedots' */
+ GPUBatch *edges_with_select_id;
+ GPUBatch *verts_with_select_id;
uint facedot_with_select_id_offset;
uint edges_with_select_id_offset;
uint verts_with_select_id_offset;
- Gwn_Batch *points_with_normals;
- Gwn_Batch *fancy_edges; /* owns its vertex buffer (not shared) */
+ GPUBatch *points_with_normals;
+ GPUBatch *fancy_edges; /* owns its vertex buffer (not shared) */
- Gwn_Batch *edge_detection;
+ GPUBatch *edge_detection;
- Gwn_VertBuf *edges_face_overlay;
+ GPUVertBuf *edges_face_overlay;
GPUTexture *edges_face_overlay_tx;
int edges_face_overlay_tri_count; /* Number of tri in edges_face_overlay(_adj)_tx */
/* Maybe have shaded_triangles_data split into pos_nor and uv_tangent
- * to minimise data transfer for skinned mesh. */
- Gwn_VertFormat shaded_triangles_format;
- Gwn_VertBuf *shaded_triangles_data;
- Gwn_IndexBuf **shaded_triangles_in_order;
- Gwn_Batch **shaded_triangles;
+ * to minimize data transfer for skinned mesh. */
+ GPUVertFormat shaded_triangles_format;
+ GPUVertBuf *shaded_triangles_data;
+ GPUIndexBuf **shaded_triangles_in_order;
+ GPUBatch **shaded_triangles;
/* Texture Paint.*/
/* per-texture batch */
- Gwn_Batch **texpaint_triangles;
- Gwn_Batch *texpaint_triangles_single;
+ GPUBatch **texpaint_triangles;
+ GPUBatch *texpaint_triangles_single;
/* Edit Cage Mesh buffers */
- Gwn_VertBuf *ed_tri_pos;
- Gwn_VertBuf *ed_tri_nor; /* LoopNor, VertNor */
- Gwn_VertBuf *ed_tri_data;
+ GPUVertBuf *ed_tri_pos;
+ GPUVertBuf *ed_tri_nor; /* LoopNor, VertNor */
+ GPUVertBuf *ed_tri_data;
- Gwn_VertBuf *ed_ledge_pos;
- Gwn_VertBuf *ed_ledge_nor; /* VertNor */
- Gwn_VertBuf *ed_ledge_data;
+ GPUVertBuf *ed_ledge_pos;
+ GPUVertBuf *ed_ledge_nor; /* VertNor */
+ GPUVertBuf *ed_ledge_data;
- Gwn_VertBuf *ed_lvert_pos;
- Gwn_VertBuf *ed_lvert_nor; /* VertNor */
- Gwn_VertBuf *ed_lvert_data;
+ GPUVertBuf *ed_lvert_pos;
+ GPUVertBuf *ed_lvert_nor; /* VertNor */
+ GPUVertBuf *ed_lvert_data;
- Gwn_Batch *overlay_triangles;
- Gwn_Batch *overlay_triangles_nor; /* GWN_PRIM_POINTS */
- Gwn_Batch *overlay_loose_edges;
- Gwn_Batch *overlay_loose_edges_nor; /* GWN_PRIM_POINTS */
- Gwn_Batch *overlay_loose_verts;
- Gwn_Batch *overlay_facedots;
+ GPUBatch *overlay_triangles;
+ GPUBatch *overlay_triangles_nor; /* GPU_PRIM_POINTS */
+ GPUBatch *overlay_loose_edges;
+ GPUBatch *overlay_loose_edges_nor; /* GPU_PRIM_POINTS */
+ GPUBatch *overlay_loose_verts;
+ GPUBatch *overlay_facedots;
- Gwn_Batch *overlay_weight_faces;
- Gwn_Batch *overlay_weight_verts;
- Gwn_Batch *overlay_paint_edges;
+ GPUBatch *overlay_weight_faces;
+ GPUBatch *overlay_weight_verts;
+ GPUBatch *overlay_paint_edges;
/* arrays of bool uniform names (and value) that will be use to
* set srgb conversion for auto attribs.*/
char *auto_layer_names;
int *auto_layer_is_srgb;
- int auto_layer_ct;
+ int auto_layer_len;
/* settings to determine if cache is invalid */
bool is_maybe_dirty;
@@ -1653,7 +1653,7 @@ typedef struct MeshBatchCache {
bool is_manifold;
} MeshBatchCache;
-/* Gwn_Batch cache management. */
+/* GPUBatch cache management. */
static bool mesh_batch_cache_valid(Mesh *me)
{
@@ -1742,21 +1742,21 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode)
cache->is_maybe_dirty = true;
break;
case BKE_MESH_BATCH_DIRTY_SELECT:
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_data);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); /* Contains select flag */
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos);
-
- GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_facedots);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_data);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); /* Contains select flag */
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos);
+
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_facedots);
/* Edit mode selection. */
- GWN_BATCH_DISCARD_SAFE(cache->facedot_with_select_id);
- GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
- GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->facedot_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
break;
case BKE_MESH_BATCH_DIRTY_ALL:
cache->is_dirty = true;
@@ -1777,7 +1777,7 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode)
/**
* This only clear the batches associated to the given vertex buffer.
**/
-static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert)
+static void mesh_batch_cache_clear_selective(Mesh *me, GPUVertBuf *vert)
{
MeshBatchCache *cache = me->runtime.batch_cache;
if (!cache) {
@@ -1787,26 +1787,26 @@ static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert)
BLI_assert(vert != NULL);
if (cache->pos_with_normals == vert) {
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_normals);
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_weights);
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors);
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask);
- GWN_BATCH_DISCARD_SAFE(cache->points_with_normals);
- GWN_BATCH_DISCARD_SAFE(cache->ledges_with_normals);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_normals);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask);
+ GPU_BATCH_DISCARD_SAFE(cache->points_with_normals);
+ GPU_BATCH_DISCARD_SAFE(cache->ledges_with_normals);
if (cache->shaded_triangles) {
for (int i = 0; i < cache->mat_len; ++i) {
- GWN_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]);
+ GPU_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]);
}
}
MEM_SAFE_FREE(cache->shaded_triangles);
if (cache->texpaint_triangles) {
for (int i = 0; i < cache->mat_len; ++i) {
- GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]);
+ GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]);
}
}
MEM_SAFE_FREE(cache->texpaint_triangles);
- GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single);
+ GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single);
}
/* TODO: add the other ones if needed. */
else {
@@ -1822,69 +1822,69 @@ static void mesh_batch_cache_clear(Mesh *me)
return;
}
- GWN_BATCH_DISCARD_SAFE(cache->all_verts);
- GWN_BATCH_DISCARD_SAFE(cache->all_edges);
- GWN_BATCH_DISCARD_SAFE(cache->all_triangles);
+ GPU_BATCH_DISCARD_SAFE(cache->all_verts);
+ GPU_BATCH_DISCARD_SAFE(cache->all_edges);
+ GPU_BATCH_DISCARD_SAFE(cache->all_triangles);
- GWN_VERTBUF_DISCARD_SAFE(cache->pos_in_order);
+ GPU_VERTBUF_DISCARD_SAFE(cache->pos_in_order);
DRW_TEXTURE_FREE_SAFE(cache->pos_in_order_tx);
- GWN_INDEXBUF_DISCARD_SAFE(cache->edges_in_order);
- GWN_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order);
- GWN_INDEXBUF_DISCARD_SAFE(cache->ledges_in_order);
-
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_pos);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_nor);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_data);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_pos);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_nor);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_pos);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_nor);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor);
-
- GWN_BATCH_DISCARD_SAFE(cache->overlay_weight_faces);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_weight_verts);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_paint_edges);
- GWN_BATCH_DISCARD_SAFE(cache->overlay_facedots);
-
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_normals);
- GWN_BATCH_DISCARD_SAFE(cache->points_with_normals);
- GWN_BATCH_DISCARD_SAFE(cache->ledges_with_normals);
- GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_weights);
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors);
- GWN_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos);
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask);
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
- GWN_BATCH_DISCARD_SAFE(cache->facedot_with_select_id);
- GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
- GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
-
- GWN_BATCH_DISCARD_SAFE(cache->fancy_edges);
-
- GWN_INDEXBUF_DISCARD_SAFE(cache->edges_adjacency);
- GWN_BATCH_DISCARD_SAFE(cache->edge_detection);
-
- GWN_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->edges_in_order);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->ledges_in_order);
+
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_pos);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_nor);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_data);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_pos);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_nor);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_pos);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_nor);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor);
+
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_faces);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_verts);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_paint_edges);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_facedots);
+
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_normals);
+ GPU_BATCH_DISCARD_SAFE(cache->points_with_normals);
+ GPU_BATCH_DISCARD_SAFE(cache->ledges_with_normals);
+ GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors);
+ GPU_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->facedot_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
+
+ GPU_BATCH_DISCARD_SAFE(cache->fancy_edges);
+
+ GPU_INDEXBUF_DISCARD_SAFE(cache->edges_adjacency);
+ GPU_BATCH_DISCARD_SAFE(cache->edge_detection);
+
+ GPU_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay);
DRW_TEXTURE_FREE_SAFE(cache->edges_face_overlay_tx);
- GWN_VERTBUF_DISCARD_SAFE(cache->shaded_triangles_data);
+ GPU_VERTBUF_DISCARD_SAFE(cache->shaded_triangles_data);
if (cache->shaded_triangles_in_order) {
for (int i = 0; i < cache->mat_len; ++i) {
- GWN_INDEXBUF_DISCARD_SAFE(cache->shaded_triangles_in_order[i]);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->shaded_triangles_in_order[i]);
}
}
if (cache->shaded_triangles) {
for (int i = 0; i < cache->mat_len; ++i) {
- GWN_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]);
+ GPU_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]);
}
}
@@ -1896,12 +1896,12 @@ static void mesh_batch_cache_clear(Mesh *me)
if (cache->texpaint_triangles) {
for (int i = 0; i < cache->mat_len; ++i) {
- GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]);
+ GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]);
}
}
MEM_SAFE_FREE(cache->texpaint_triangles);
- GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single);
+ GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single);
}
@@ -1911,9 +1911,9 @@ void DRW_mesh_batch_cache_free(Mesh *me)
MEM_SAFE_FREE(me->runtime.batch_cache);
}
-/* Gwn_Batch cache usage. */
+/* GPUBatch cache usage. */
-static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, MeshBatchCache *cache)
+static GPUVertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
#define USE_COMP_MESH_DATA
@@ -1928,9 +1928,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
return NULL;
}
- Gwn_VertFormat *format = &cache->shaded_triangles_format;
+ GPUVertFormat *format = &cache->shaded_triangles_format;
- GWN_vertformat_clear(format);
+ GPU_vertformat_clear(format);
/* initialize vertex format */
uint *layers_combined_id = BLI_array_alloca(layers_combined_id, layers_combined_len);
@@ -1947,35 +1947,35 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
uint auto_names_len = 0;
uint auto_ofs = 0;
uint auto_id = 0;
- cache->auto_layer_ct = 0;
+ cache->auto_layer_len = 0;
for (uint i = 0; i < uv_len; i++) {
const char *attrib_name = mesh_render_data_uv_auto_layer_uuid_get(rdata, i);
auto_names_len += strlen(attrib_name) + 2; /* include null terminator and b prefix. */
- cache->auto_layer_ct++;
+ cache->auto_layer_len++;
}
for (uint i = 0; i < vcol_len; i++) {
if (rdata->cd.layers.auto_vcol[i]) {
const char *attrib_name = mesh_render_data_vcol_auto_layer_uuid_get(rdata, i);
auto_names_len += strlen(attrib_name) + 2; /* include null terminator and b prefix. */
- cache->auto_layer_ct++;
+ cache->auto_layer_len++;
}
}
auto_names_len += 1; /* add an ultimate '\0' terminator */
cache->auto_layer_names = MEM_callocN(auto_names_len * sizeof(char), "Auto layer name buf");
- cache->auto_layer_is_srgb = MEM_mallocN(cache->auto_layer_ct * sizeof(int), "Auto layer value buf");
+ cache->auto_layer_is_srgb = MEM_mallocN(cache->auto_layer_len * sizeof(int), "Auto layer value buf");
for (uint i = 0; i < uv_len; i++) {
/* UV */
const char *attrib_name = mesh_render_data_uv_layer_uuid_get(rdata, i);
#if defined(USE_COMP_MESH_DATA) && 0 /* these are clamped. Maybe use them as an option in the future */
- uv_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_I16, 2, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ uv_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT);
#else
- uv_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uv_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
#endif
/* Auto Name */
attrib_name = mesh_render_data_uv_auto_layer_uuid_get(rdata, i);
- GWN_vertformat_alias_add(format, attrib_name);
+ GPU_vertformat_alias_add(format, attrib_name);
/* +1 include null terminator. */
auto_ofs += 1 + BLI_snprintf_rlen(
@@ -1983,7 +1983,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
cache->auto_layer_is_srgb[auto_id++] = 0; /* tag as not srgb */
if (i == rdata->cd.layers.uv_active) {
- GWN_vertformat_alias_add(format, "u");
+ GPU_vertformat_alias_add(format, "u");
}
}
@@ -1993,25 +1993,25 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
* That may cause some problem but I could not make it to fail (fclem) */
#ifdef USE_COMP_MESH_DATA
/* Tangents need more precision than 10_10_10 */
- tangent_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ tangent_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
#else
- tangent_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ tangent_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
#endif
if (i == rdata->cd.layers.tangent_active) {
- GWN_vertformat_alias_add(format, "t");
+ GPU_vertformat_alias_add(format, "t");
}
}
for (uint i = 0; i < vcol_len; i++) {
const char *attrib_name = mesh_render_data_vcol_layer_uuid_get(rdata, i);
- vcol_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ vcol_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
/* Auto layer */
if (rdata->cd.layers.auto_vcol[i]) {
attrib_name = mesh_render_data_vcol_auto_layer_uuid_get(rdata, i);
- GWN_vertformat_alias_add(format, attrib_name);
+ GPU_vertformat_alias_add(format, attrib_name);
/* +1 include null terminator. */
auto_ofs += 1 + BLI_snprintf_rlen(
@@ -2020,23 +2020,23 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
}
if (i == rdata->cd.layers.vcol_active) {
- GWN_vertformat_alias_add(format, "c");
+ GPU_vertformat_alias_add(format, "c");
}
}
const uint tri_len = mesh_render_data_looptri_len_get(rdata);
- Gwn_VertBuf *vbo = cache->shaded_triangles_data = GWN_vertbuf_create_with_format(format);
+ GPUVertBuf *vbo = cache->shaded_triangles_data = GPU_vertbuf_create_with_format(format);
const int vbo_len_capacity = tri_len * 3;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
- Gwn_VertBufRaw *layers_combined_step = BLI_array_alloca(layers_combined_step, layers_combined_len);
+ GPUVertBufRaw *layers_combined_step = BLI_array_alloca(layers_combined_step, layers_combined_len);
- Gwn_VertBufRaw *uv_step = layers_combined_step;
- Gwn_VertBufRaw *tangent_step = uv_step + uv_len;
- Gwn_VertBufRaw *vcol_step = tangent_step + tangent_len;
+ GPUVertBufRaw *uv_step = layers_combined_step;
+ GPUVertBufRaw *tangent_step = uv_step + uv_len;
+ GPUVertBufRaw *vcol_step = tangent_step + tangent_len;
/* Not needed, just for sanity. */
if (uv_len == 0) { uv_step = NULL; }
@@ -2044,16 +2044,16 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
if (vcol_len == 0) { vcol_step = NULL; }
for (uint i = 0; i < uv_len; i++) {
- GWN_vertbuf_attr_get_raw_data(vbo, uv_id[i], &uv_step[i]);
+ GPU_vertbuf_attr_get_raw_data(vbo, uv_id[i], &uv_step[i]);
}
for (uint i = 0; i < tangent_len; i++) {
- GWN_vertbuf_attr_get_raw_data(vbo, tangent_id[i], &tangent_step[i]);
+ GPU_vertbuf_attr_get_raw_data(vbo, tangent_id[i], &tangent_step[i]);
}
for (uint i = 0; i < vcol_len; i++) {
- GWN_vertbuf_attr_get_raw_data(vbo, vcol_id[i], &vcol_step[i]);
+ GPU_vertbuf_attr_get_raw_data(vbo, vcol_id[i], &vcol_step[i]);
}
- /* TODO deduplicate all verts and make use of Gwn_IndexBuf in
+ /* TODO deduplicate all verts and make use of GPUIndexBuf in
* mesh_batch_cache_get_triangles_in_order_split_by_material. */
if (rdata->edit_bmesh) {
for (uint i = 0; i < tri_len; i++) {
@@ -2066,7 +2066,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
const uint layer_offset = rdata->cd.offset.uv[j];
for (uint t = 0; t < 3; t++) {
const float *elem = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(bm_looptri[t], layer_offset))->uv;
- copy_v2_v2(GWN_vertbuf_raw_step(&uv_step[j]), elem);
+ copy_v2_v2(GPU_vertbuf_raw_step(&uv_step[j]), elem);
}
}
/* TANGENTs */
@@ -2074,7 +2074,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
float (*layer_data)[4] = rdata->cd.layers.tangent[j];
for (uint t = 0; t < 3; t++) {
const float *elem = layer_data[BM_elem_index_get(bm_looptri[t])];
- normal_float_to_short_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem);
+ normal_float_to_short_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem);
}
}
/* VCOLs */
@@ -2082,7 +2082,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
const uint layer_offset = rdata->cd.offset.vcol[j];
for (uint t = 0; t < 3; t++) {
const uchar *elem = &((MLoopCol *)BM_ELEM_CD_GET_VOID_P(bm_looptri[t], layer_offset))->r;
- copy_v3_v3_uchar(GWN_vertbuf_raw_step(&vcol_step[j]), elem);
+ copy_v3_v3_uchar(GPU_vertbuf_raw_step(&vcol_step[j]), elem);
}
}
}
@@ -2096,7 +2096,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
const MLoopUV *layer_data = rdata->cd.layers.uv[j];
for (uint t = 0; t < 3; t++) {
const float *elem = layer_data[mlt->tri[t]].uv;
- copy_v2_v2(GWN_vertbuf_raw_step(&uv_step[j]), elem);
+ copy_v2_v2(GPU_vertbuf_raw_step(&uv_step[j]), elem);
}
}
/* TANGENTs */
@@ -2105,9 +2105,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
for (uint t = 0; t < 3; t++) {
const float *elem = layer_data[mlt->tri[t]];
#ifdef USE_COMP_MESH_DATA
- normal_float_to_short_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem);
+ normal_float_to_short_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem);
#else
- copy_v3_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem);
+ copy_v3_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem);
#endif
}
}
@@ -2116,25 +2116,25 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
const MLoopCol *layer_data = rdata->cd.layers.vcol[j];
for (uint t = 0; t < 3; t++) {
const uchar *elem = &layer_data[mlt->tri[t]].r;
- copy_v3_v3_uchar(GWN_vertbuf_raw_step(&vcol_step[j]), elem);
+ copy_v3_v3_uchar(GPU_vertbuf_raw_step(&vcol_step[j]), elem);
}
}
}
}
- vbo_len_used = GWN_vertbuf_raw_used(&layers_combined_step[0]);
+ vbo_len_used = GPU_vertbuf_raw_used(&layers_combined_step[0]);
#ifndef NDEBUG
/* Check all layers are write aligned. */
if (layers_combined_len > 1) {
for (uint i = 1; i < layers_combined_len; i++) {
- BLI_assert(vbo_len_used == GWN_vertbuf_raw_used(&layers_combined_step[i]));
+ BLI_assert(vbo_len_used == GPU_vertbuf_raw_used(&layers_combined_step[i]));
}
}
#endif
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
@@ -2143,7 +2143,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
return cache->shaded_triangles_data;
}
-static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active(
+static GPUVertBuf *mesh_batch_cache_get_tri_uv_active(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPUV));
@@ -2157,19 +2157,19 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active(
uint vidx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint uv; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.uv = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.uv = GPU_vertformat_attr_add(&format, "uv", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- Gwn_VertBuf *vbo = cache->tri_aligned_uv = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = cache->tri_aligned_uv = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = tri_len * 3;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
BMEditMesh *embm = rdata->edit_bmesh;
@@ -2189,7 +2189,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active(
const int index = BM_elem_index_get(loop);
if (index != -1) {
const float *elem = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(loop, layer_offset))->uv;
- GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, elem);
+ GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, elem);
}
}
}
@@ -2198,9 +2198,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active(
/* object mode */
for (int i = 0; i < tri_len; i++) {
const MLoopTri *mlt = &rdata->mlooptri[i];
- GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[0]].uv);
- GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[1]].uv);
- GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[2]].uv);
+ GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[0]].uv);
+ GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[1]].uv);
+ GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[2]].uv);
}
}
@@ -2213,36 +2213,36 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active(
return cache->tri_aligned_uv;
}
-static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
+static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
MeshRenderData *rdata, const bool use_hide,
- Gwn_VertBuf **r_vbo)
+ GPUVertBuf **r_vbo)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
if (*r_vbo == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, nor; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- Gwn_VertBuf *vbo = *r_vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = *r_vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = tri_len * 3;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
- Gwn_VertBufRaw pos_step, nor_step;
- GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
- GWN_vertbuf_attr_get_raw_data(vbo, attr_id.nor, &nor_step);
+ GPUVertBufRaw pos_step, nor_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id.nor, &nor_step);
float (*lnors)[3] = rdata->loop_normals;
if (rdata->edit_bmesh) {
- Gwn_PackedNormal *pnors_pack, *vnors_pack;
+ GPUPackedNormal *pnors_pack, *vnors_pack;
if (lnors == NULL) {
mesh_render_data_ensure_poly_normals_pack(rdata);
@@ -2264,18 +2264,18 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
if (lnors) {
for (uint t = 0; t < 3; t++) {
const float *nor = lnors[BM_elem_index_get(bm_looptri[t])];
- *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_v3(nor);
+ *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_v3(nor);
}
}
else if (BM_elem_flag_test(bm_face, BM_ELEM_SMOOTH)) {
for (uint t = 0; t < 3; t++) {
- *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = vnors_pack[BM_elem_index_get(bm_looptri[t]->v)];
+ *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = vnors_pack[BM_elem_index_get(bm_looptri[t]->v)];
}
}
else {
- const Gwn_PackedNormal *snor_pack = &pnors_pack[BM_elem_index_get(bm_face)];
+ const GPUPackedNormal *snor_pack = &pnors_pack[BM_elem_index_get(bm_face)];
for (uint t = 0; t < 3; t++) {
- *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = *snor_pack;
+ *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = *snor_pack;
}
}
@@ -2284,12 +2284,12 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
for (uint t = 0; t < 3; t++) {
int vidx = BM_elem_index_get(bm_looptri[t]->v);
const float *pos = rdata->edit_data->vertexCos[vidx];
- copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), pos);
+ copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), pos);
}
}
else {
for (uint t = 0; t < 3; t++) {
- copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), bm_looptri[t]->v->co);
+ copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), bm_looptri[t]->v->co);
}
}
}
@@ -2317,85 +2317,85 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
if (lnors) {
for (uint t = 0; t < 3; t++) {
const float *nor = lnors[mlt->tri[t]];
- *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_v3(nor);
+ *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_v3(nor);
}
}
else if (mp->flag & ME_SMOOTH) {
for (uint t = 0; t < 3; t++) {
const MVert *mv = &rdata->mvert[vtri[t]];
- *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_s3(mv->no);
+ *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_s3(mv->no);
}
}
else {
- const Gwn_PackedNormal *pnors_pack = &rdata->poly_normals_pack[mlt->poly];
+ const GPUPackedNormal *pnors_pack = &rdata->poly_normals_pack[mlt->poly];
for (uint t = 0; t < 3; t++) {
- *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = *pnors_pack;
+ *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = *pnors_pack;
}
}
for (uint t = 0; t < 3; t++) {
const MVert *mv = &rdata->mvert[vtri[t]];
- copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), mv->co);
+ copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), mv->co);
}
}
}
- vbo_len_used = GWN_vertbuf_raw_used(&pos_step);
- BLI_assert(vbo_len_used == GWN_vertbuf_raw_used(&nor_step));
+ vbo_len_used = GPU_vertbuf_raw_used(&pos_step);
+ BLI_assert(vbo_len_used == GPU_vertbuf_raw_used(&nor_step));
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return *r_vbo;
}
-static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals(
+static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals(
MeshRenderData *rdata, MeshBatchCache *cache)
{
return mesh_batch_cache_get_tri_pos_and_normals_ex(
rdata, false,
&cache->pos_with_normals);
}
-static Gwn_VertBuf *mesh_create_tri_pos_and_normals_visible_only(
+static GPUVertBuf *mesh_create_tri_pos_and_normals_visible_only(
MeshRenderData *rdata)
{
- Gwn_VertBuf *vbo_dummy = NULL;
+ GPUVertBuf *vbo_dummy = NULL;
return mesh_batch_cache_get_tri_pos_and_normals_ex(
rdata, true,
&vbo_dummy);
}
-static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag(
+static GPUVertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
if (cache->ed_fcenter_pos_with_nor_and_sel == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, data; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.data = GWN_vertformat_attr_add(&format, "norAndFlag", GWN_COMP_I10, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.data = GPU_vertformat_attr_add(&format, "norAndFlag", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata);
int vidx = 0;
- Gwn_VertBuf *vbo = cache->ed_fcenter_pos_with_nor_and_sel = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPUVertBuf *vbo = cache->ed_fcenter_pos_with_nor_and_sel = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
for (int i = 0; i < vbo_len_capacity; ++i) {
float pcenter[3], pnor[3];
bool selected = false;
if (mesh_render_data_pnors_pcenter_select_get(rdata, i, pnor, pcenter, &selected)) {
- Gwn_PackedNormal nor = { .x = 0, .y = 0, .z = -511 };
- nor = GWN_normal_convert_i10_v3(pnor);
+ GPUPackedNormal nor = { .x = 0, .y = 0, .z = -511 };
+ nor = GPU_normal_convert_i10_v3(pnor);
nor.w = selected ? 1 : 0;
- GWN_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor);
+ GPU_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, pcenter);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, pcenter);
vidx += 1;
}
@@ -2403,30 +2403,30 @@ static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag(
const int vbo_len_used = vidx;
BLI_assert(vbo_len_used <= vbo_len_capacity);
if (vbo_len_used != vbo_len_capacity) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return cache->ed_fcenter_pos_with_nor_and_sel;
}
-static Gwn_VertBuf *mesh_batch_cache_get_edges_visible(
+static GPUVertBuf *mesh_batch_cache_get_edges_visible(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE));
if (cache->ed_edge_pos == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, data; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
const int vbo_len_capacity = mesh_render_data_edges_len_get(rdata) * 2;
int vidx = 0;
- Gwn_VertBuf *vbo = cache->ed_edge_pos = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPUVertBuf *vbo = cache->ed_edge_pos = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
if (rdata->edit_bmesh) {
BMesh *bm = rdata->edit_bmesh->bm;
BMIter iter;
@@ -2434,9 +2434,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible(
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v1->co);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v1->co);
vidx += 1;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v2->co);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v2->co);
vidx += 1;
}
}
@@ -2447,7 +2447,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible(
}
const int vbo_len_used = vidx;
if (vbo_len_used != vbo_len_capacity) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
UNUSED_VARS_NDEBUG(vbo_len_used);
}
@@ -2455,23 +2455,23 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible(
return cache->ed_edge_pos;
}
-static Gwn_VertBuf *mesh_batch_cache_get_verts_visible(
+static GPUVertBuf *mesh_batch_cache_get_verts_visible(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
if (cache->ed_vert_pos == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, data; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata);
uint vidx = 0;
- Gwn_VertBuf *vbo = cache->ed_vert_pos = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPUVertBuf *vbo = cache->ed_vert_pos = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
if (rdata->edit_bmesh) {
BMesh *bm = rdata->edit_bmesh->bm;
BMIter iter;
@@ -2479,7 +2479,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible(
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eve->co);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eve->co);
vidx += 1;
}
}
@@ -2488,14 +2488,14 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible(
for (int i = 0; i < vbo_len_capacity; i++) {
const MVert *mv = &rdata->mvert[i];
if (!(mv->flag & ME_HIDE)) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, mv->co);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, mv->co);
vidx += 1;
}
}
}
const uint vbo_len_used = vidx;
if (vbo_len_used != vbo_len_capacity) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
UNUSED_VARS_NDEBUG(vbo_len_used);
@@ -2504,24 +2504,24 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible(
return cache->ed_vert_pos;
}
-static Gwn_VertBuf *mesh_create_facedot_select_id(
+static GPUVertBuf *mesh_create_facedot_select_id(
MeshRenderData *rdata, uint select_id_offset)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
- Gwn_VertBuf *vbo;
+ GPUVertBuf *vbo;
{
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, col; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata);
int vidx = 0;
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
uint select_index = select_id_offset;
if (rdata->edit_bmesh) {
@@ -2533,7 +2533,7 @@ static Gwn_VertBuf *mesh_create_facedot_select_id(
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
int select_id;
GPU_select_index_get(select_index, &select_id);
- GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
vidx += 1;
}
select_index += 1;
@@ -2545,31 +2545,31 @@ static Gwn_VertBuf *mesh_create_facedot_select_id(
}
const int vbo_len_used = vidx;
if (vbo_len_used != vbo_len_capacity) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return vbo;
}
-static Gwn_VertBuf *mesh_create_edges_select_id(
+static GPUVertBuf *mesh_create_edges_select_id(
MeshRenderData *rdata, uint select_id_offset)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE));
- Gwn_VertBuf *vbo;
+ GPUVertBuf *vbo;
{
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, col; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
const int vbo_len_capacity = mesh_render_data_edges_len_get(rdata) * 2;
int vidx = 0;
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
uint select_index = select_id_offset;
if (rdata->edit_bmesh) {
@@ -2581,9 +2581,9 @@ static Gwn_VertBuf *mesh_create_edges_select_id(
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
int select_id;
GPU_select_index_get(select_index, &select_id);
- GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
vidx += 1;
- GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
vidx += 1;
}
select_index += 1;
@@ -2595,31 +2595,31 @@ static Gwn_VertBuf *mesh_create_edges_select_id(
}
const int vbo_len_used = vidx;
if (vbo_len_used != vbo_len_capacity) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return vbo;
}
-static Gwn_VertBuf *mesh_create_verts_select_id(
+static GPUVertBuf *mesh_create_verts_select_id(
MeshRenderData *rdata, uint select_id_offset)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
- Gwn_VertBuf *vbo;
+ GPUVertBuf *vbo;
{
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, col; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata);
int vidx = 0;
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
uint select_index = select_id_offset;
if (rdata->edit_bmesh) {
@@ -2631,7 +2631,7 @@ static Gwn_VertBuf *mesh_create_verts_select_id(
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
int select_id;
GPU_select_index_get(select_index, &select_id);
- GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
vidx += 1;
}
select_index += 1;
@@ -2643,7 +2643,7 @@ static Gwn_VertBuf *mesh_create_verts_select_id(
if (!(mv->flag & ME_HIDE)) {
int select_id;
GPU_select_index_get(select_index, &select_id);
- GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
vidx += 1;
}
select_index += 1;
@@ -2651,36 +2651,36 @@ static Gwn_VertBuf *mesh_create_verts_select_id(
}
const int vbo_len_used = vidx;
if (vbo_len_used != vbo_len_capacity) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return vbo;
}
-static Gwn_VertBuf *mesh_create_tri_weights(
+static GPUVertBuf *mesh_create_tri_weights(
MeshRenderData *rdata, bool use_hide, int defgroup)
{
BLI_assert(
rdata->types &
(MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_DVERT));
- Gwn_VertBuf *vbo;
+ GPUVertBuf *vbo;
{
uint cidx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint col; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
- vbo = GWN_vertbuf_create_with_format(&format);
+ vbo = GPU_vertbuf_create_with_format(&format);
const int tri_len = mesh_render_data_looptri_len_get(rdata);
const int vbo_len_capacity = tri_len * 3;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
mesh_render_data_ensure_vert_weight_color(rdata, defgroup);
const float (*vert_weight_color)[3] = rdata->vert_weight_color;
@@ -2692,7 +2692,7 @@ static Gwn_VertBuf *mesh_create_tri_weights(
if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const int v_index = BM_elem_index_get(ltri[tri_corner]->v);
- GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]);
}
}
}
@@ -2703,7 +2703,7 @@ static Gwn_VertBuf *mesh_create_tri_weights(
if (!(use_hide && (rdata->mpoly[mlt->poly].flag & ME_HIDE))) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const uint v_index = rdata->mloop[mlt->tri[tri_corner]].v;
- GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]);
}
}
}
@@ -2711,36 +2711,36 @@ static Gwn_VertBuf *mesh_create_tri_weights(
vbo_len_used = cidx;
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return vbo;
}
-static Gwn_VertBuf *mesh_create_tri_vert_colors(
+static GPUVertBuf *mesh_create_tri_vert_colors(
MeshRenderData *rdata, bool use_hide)
{
BLI_assert(
rdata->types &
(MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL));
- Gwn_VertBuf *vbo;
+ GPUVertBuf *vbo;
{
uint cidx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint col; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ if (format.attr_len == 0) {
+ attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- vbo = GWN_vertbuf_create_with_format(&format);
+ vbo = GPU_vertbuf_create_with_format(&format);
const uint vbo_len_capacity = tri_len * 3;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
mesh_render_data_ensure_vert_color(rdata);
const char (*vert_color)[3] = rdata->vert_color;
@@ -2752,7 +2752,7 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors(
if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const int l_index = BM_elem_index_get(ltri[tri_corner]);
- GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]);
}
}
}
@@ -2763,7 +2763,7 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors(
if (!(use_hide && (rdata->mpoly[mlt->poly].flag & ME_HIDE))) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const uint l_index = mlt->tri[tri_corner];
- GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]);
}
}
}
@@ -2771,37 +2771,37 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors(
const uint vbo_len_used = cidx;
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return vbo;
}
-static Gwn_VertBuf *mesh_create_tri_select_id(
+static GPUVertBuf *mesh_create_tri_select_id(
MeshRenderData *rdata, bool use_hide, uint select_id_offset)
{
BLI_assert(
rdata->types &
(MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
- Gwn_VertBuf *vbo;
+ GPUVertBuf *vbo;
{
uint cidx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint col; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- vbo = GWN_vertbuf_create_with_format(&format);
+ vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = tri_len * 3;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
if (rdata->edit_bmesh) {
for (int i = 0; i < tri_len; i++) {
@@ -2812,7 +2812,7 @@ static Gwn_VertBuf *mesh_create_tri_select_id(
int select_id;
GPU_select_index_get(poly_index + select_id_offset, &select_id);
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
- GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
}
}
}
@@ -2825,7 +2825,7 @@ static Gwn_VertBuf *mesh_create_tri_select_id(
int select_id;
GPU_select_index_get(poly_index + select_id_offset, &select_id);
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
- GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
+ GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
}
}
}
@@ -2833,29 +2833,29 @@ static Gwn_VertBuf *mesh_create_tri_select_id(
vbo_len_used = cidx;
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return vbo;
}
-static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order(
+static GPUVertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
if (cache->pos_in_order == NULL) {
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, nor; } attr_id;
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* Normal is padded so that the vbo can be used as a buffer texture */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
- Gwn_VertBuf *vbo = cache->pos_in_order = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = cache->pos_in_order = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata);
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
if (rdata->edit_bmesh) {
BMesh *bm = rdata->edit_bmesh->bm;
@@ -2867,15 +2867,15 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order(
static short no_short[4];
normal_float_to_short_v3(no_short, eve->no);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i, eve->co);
- GWN_vertbuf_attr_set(vbo, attr_id.nor, i, no_short);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, eve->co);
+ GPU_vertbuf_attr_set(vbo, attr_id.nor, i, no_short);
}
BLI_assert(i == vbo_len_capacity);
}
else {
for (int i = 0; i < vbo_len_capacity; ++i) {
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->mvert[i].co);
- GWN_vertbuf_attr_set(vbo, attr_id.nor, i, rdata->mvert[i].no); /* XXX actually reading 4 shorts */
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->mvert[i].co);
+ GPU_vertbuf_attr_set(vbo, attr_id.nor, i, rdata->mvert[i].no); /* XXX actually reading 4 shorts */
}
}
}
@@ -2883,26 +2883,26 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order(
return cache->pos_in_order;
}
-static Gwn_VertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id)
+static GPUVertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id)
{
- static Gwn_VertFormat format_pos = { 0 };
- static unsigned pos_id;
- if (format_pos.attrib_ct == 0) {
- pos_id = GWN_vertformat_attr_add(&format_pos, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ static GPUVertFormat format_pos = { 0 };
+ static uint pos_id;
+ if (format_pos.attr_len == 0) {
+ pos_id = GPU_vertformat_attr_add(&format_pos, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
*r_pos_id = pos_id;
return &format_pos;
}
-static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lnor_id)
+static GPUVertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lnor_id)
{
- static Gwn_VertFormat format_nor = { 0 };
- static Gwn_VertFormat format_nor_loop = { 0 };
- static unsigned vnor_id, vnor_loop_id, lnor_id;
- if (format_nor.attrib_ct == 0) {
- vnor_id = GWN_vertformat_attr_add(&format_nor, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- vnor_loop_id = GWN_vertformat_attr_add(&format_nor_loop, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- lnor_id = GWN_vertformat_attr_add(&format_nor_loop, "lnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ static GPUVertFormat format_nor = { 0 };
+ static GPUVertFormat format_nor_loop = { 0 };
+ static uint vnor_id, vnor_loop_id, lnor_id;
+ if (format_nor.attr_len == 0) {
+ vnor_id = GPU_vertformat_attr_add(&format_nor, "vnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ vnor_loop_id = GPU_vertformat_attr_add(&format_nor_loop, "vnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ lnor_id = GPU_vertformat_attr_add(&format_nor_loop, "lnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
if (r_lnor_id) {
*r_vnor_id = vnor_loop_id;
@@ -2915,12 +2915,12 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno
}
}
-static Gwn_VertFormat *edit_mesh_overlay_data_format(uint *r_data_id)
+static GPUVertFormat *edit_mesh_overlay_data_format(uint *r_data_id)
{
- static Gwn_VertFormat format_flag = { 0 };
- static unsigned data_id;
- if (format_flag.attrib_ct == 0) {
- data_id = GWN_vertformat_attr_add(&format_flag, "data", GWN_COMP_U8, 4, GWN_FETCH_INT);
+ static GPUVertFormat format_flag = { 0 };
+ static uint data_id;
+ if (format_flag.attr_len == 0) {
+ data_id = GPU_vertformat_attr_add(&format_flag, "data", GPU_COMP_U8, 4, GPU_FETCH_INT);
}
*r_data_id = data_id;
return &format_flag;
@@ -2937,28 +2937,28 @@ static void mesh_batch_cache_create_overlay_tri_buffers(
int vbo_len_used = 0;
/* Positions */
- Gwn_VertBuf *vbo_pos = NULL;
+ GPUVertBuf *vbo_pos = NULL;
static struct { uint pos, vnor, lnor, data; } attr_id;
if (cache->ed_tri_pos == NULL) {
vbo_pos = cache->ed_tri_pos =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
- GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
+ GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity);
}
/* Normals */
- Gwn_VertBuf *vbo_nor = NULL;
+ GPUVertBuf *vbo_nor = NULL;
if (cache->ed_tri_nor == NULL) {
vbo_nor = cache->ed_tri_nor =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, &attr_id.lnor));
- GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, &attr_id.lnor));
+ GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity);
}
/* Data */
- Gwn_VertBuf *vbo_data = NULL;
+ GPUVertBuf *vbo_data = NULL;
if (cache->ed_tri_data == NULL) {
vbo_data = cache->ed_tri_data =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
- GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
+ GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity);
}
for (int i = 0; i < tri_len; i++) {
@@ -2976,13 +2976,13 @@ static void mesh_batch_cache_create_overlay_tri_buffers(
/* Finish */
if (vbo_len_used != vbo_len_capacity) {
if (vbo_pos != NULL) {
- GWN_vertbuf_data_resize(vbo_pos, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_pos, vbo_len_used);
}
if (vbo_nor != NULL) {
- GWN_vertbuf_data_resize(vbo_nor, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_nor, vbo_len_used);
}
if (vbo_data != NULL) {
- GWN_vertbuf_data_resize(vbo_data, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_data, vbo_len_used);
}
}
}
@@ -2998,28 +2998,28 @@ static void mesh_batch_cache_create_overlay_ledge_buffers(
int vbo_len_used = 0;
/* Positions */
- Gwn_VertBuf *vbo_pos = NULL;
+ GPUVertBuf *vbo_pos = NULL;
static struct { uint pos, vnor, data; } attr_id;
if (cache->ed_ledge_pos == NULL) {
vbo_pos = cache->ed_ledge_pos =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
- GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
+ GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity);
}
/* Normals */
- Gwn_VertBuf *vbo_nor = NULL;
+ GPUVertBuf *vbo_nor = NULL;
if (cache->ed_ledge_nor == NULL) {
vbo_nor = cache->ed_ledge_nor =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL));
- GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL));
+ GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity);
}
/* Data */
- Gwn_VertBuf *vbo_data = NULL;
+ GPUVertBuf *vbo_data = NULL;
if (cache->ed_ledge_data == NULL) {
vbo_data = cache->ed_ledge_data =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
- GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
+ GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity);
}
if (rdata->edit_bmesh) {
@@ -3039,13 +3039,13 @@ static void mesh_batch_cache_create_overlay_ledge_buffers(
/* Finish */
if (vbo_len_used != vbo_len_capacity) {
if (vbo_pos != NULL) {
- GWN_vertbuf_data_resize(vbo_pos, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_pos, vbo_len_used);
}
if (vbo_nor != NULL) {
- GWN_vertbuf_data_resize(vbo_nor, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_nor, vbo_len_used);
}
if (vbo_data != NULL) {
- GWN_vertbuf_data_resize(vbo_data, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_data, vbo_len_used);
}
}
}
@@ -3064,27 +3064,27 @@ static void mesh_batch_cache_create_overlay_lvert_buffers(
static struct { uint pos, vnor, data; } attr_id;
/* Positions */
- Gwn_VertBuf *vbo_pos = NULL;
+ GPUVertBuf *vbo_pos = NULL;
if (cache->ed_lvert_pos == NULL) {
vbo_pos = cache->ed_lvert_pos =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
- GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
+ GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity);
}
/* Normals */
- Gwn_VertBuf *vbo_nor = NULL;
+ GPUVertBuf *vbo_nor = NULL;
if (cache->ed_lvert_nor == NULL) {
vbo_nor = cache->ed_lvert_nor =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL));
- GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL));
+ GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity);
}
/* Data */
- Gwn_VertBuf *vbo_data = NULL;
+ GPUVertBuf *vbo_data = NULL;
if (cache->ed_lvert_data == NULL) {
vbo_data = cache->ed_lvert_data =
- GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
- GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity);
+ GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
+ GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity);
}
for (uint i = 0; i < lvert_len; i++) {
@@ -3099,19 +3099,19 @@ static void mesh_batch_cache_create_overlay_lvert_buffers(
/* Finish */
if (vbo_len_used != vbo_len_capacity) {
if (vbo_pos != NULL) {
- GWN_vertbuf_data_resize(vbo_pos, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_pos, vbo_len_used);
}
if (vbo_nor != NULL) {
- GWN_vertbuf_data_resize(vbo_nor, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_nor, vbo_len_used);
}
if (vbo_data != NULL) {
- GWN_vertbuf_data_resize(vbo_data, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo_data, vbo_len_used);
}
}
}
/* Position */
-static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_pos(
+static GPUVertBuf *mesh_batch_cache_get_edit_tri_pos(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3123,7 +3123,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_pos(
return cache->ed_tri_pos;
}
-static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_pos(
+static GPUVertBuf *mesh_batch_cache_get_edit_ledge_pos(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3135,7 +3135,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_pos(
return cache->ed_ledge_pos;
}
-static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_pos(
+static GPUVertBuf *mesh_batch_cache_get_edit_lvert_pos(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3148,7 +3148,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_pos(
}
/* Normal */
-static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_nor(
+static GPUVertBuf *mesh_batch_cache_get_edit_tri_nor(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3160,7 +3160,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_nor(
return cache->ed_tri_nor;
}
-static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_nor(
+static GPUVertBuf *mesh_batch_cache_get_edit_ledge_nor(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3172,7 +3172,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_nor(
return cache->ed_ledge_nor;
}
-static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_nor(
+static GPUVertBuf *mesh_batch_cache_get_edit_lvert_nor(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3185,7 +3185,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_nor(
}
/* Data */
-static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_data(
+static GPUVertBuf *mesh_batch_cache_get_edit_tri_data(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3197,7 +3197,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_data(
return cache->ed_tri_data;
}
-static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_data(
+static GPUVertBuf *mesh_batch_cache_get_edit_ledge_data(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3209,7 +3209,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_data(
return cache->ed_ledge_data;
}
-static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_data(
+static GPUVertBuf *mesh_batch_cache_get_edit_lvert_data(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@@ -3221,7 +3221,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_data(
return cache->ed_lvert_data;
}
-static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, MeshBatchCache *cache)
+static GPUIndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE));
@@ -3229,8 +3229,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata,
const int vert_len = mesh_render_data_verts_len_get(rdata);
const int edge_len = mesh_render_data_edges_len_get(rdata);
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len);
BLI_assert(rdata->types & MR_DATATYPE_EDGE);
@@ -3240,24 +3240,24 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata,
BMEdge *eed;
BM_ITER_MESH(eed, &eiter, bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- GWN_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2));
+ GPU_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2));
}
}
}
else {
const MEdge *ed = rdata->medge;
for (int i = 0; i < edge_len; i++, ed++) {
- GWN_indexbuf_add_line_verts(&elb, ed->v1, ed->v2);
+ GPU_indexbuf_add_line_verts(&elb, ed->v1, ed->v2);
}
}
- cache->edges_in_order = GWN_indexbuf_build(&elb);
+ cache->edges_in_order = GPU_indexbuf_build(&elb);
}
return cache->edges_in_order;
}
#define NO_EDGE INT_MAX
-static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, MeshBatchCache *cache)
+static GPUIndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
@@ -3268,8 +3268,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
cache->is_manifold = true;
/* Allocate max but only used indices are sent to GPU. */
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, tri_len * 3, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, tri_len * 3, vert_len);
EdgeHash *eh = BLI_edgehash_new_ex(__func__, tri_len * 3);
/* Create edges for each pair of triangles sharing an edge. */
@@ -3310,12 +3310,12 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
if (inv_opposite == inv_indices) {
/* Don't share edge if triangles have non matching winding. */
- GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
- GWN_indexbuf_add_line_adj_verts(&elb, v_opposite, v1, v2, v_opposite);
+ GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
+ GPU_indexbuf_add_line_adj_verts(&elb, v_opposite, v1, v2, v_opposite);
cache->is_manifold = false;
}
else {
- GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v_opposite);
+ GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v_opposite);
}
}
}
@@ -3336,13 +3336,13 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
if (v_data < 0) { /* inv_opposite */
SWAP(uint, v1, v2);
}
- GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
+ GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
cache->is_manifold = false;
}
BLI_edgehashIterator_free(ehi);
BLI_edgehash_free(eh, NULL);
- cache->edges_adjacency = GWN_indexbuf_build(&elb);
+ cache->edges_adjacency = GPU_indexbuf_build(&elb);
}
return cache->edges_adjacency;
@@ -3395,16 +3395,16 @@ static EdgeHash *create_looptri_edge_adjacency_hash(MeshRenderData *rdata)
return eh;
}
-static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderData *rdata)
+static GPUVertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderData *rdata)
{
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- Gwn_VertFormat format = {0};
- uint index_id = GWN_vertformat_attr_add(&format, "index", GWN_COMP_U32, 1, GWN_FETCH_INT);
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertFormat format = {0};
+ uint index_id = GPU_vertformat_attr_add(&format, "index", GPU_COMP_U32, 1, GPU_FETCH_INT);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
int vbo_len_capacity = tri_len * 3;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
int vidx = 0;
EdgeHash *eh = NULL;
@@ -3420,7 +3420,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender
int j, j_next;
for (j = 2, j_next = 0; j_next < 3; j = j_next++) {
MEdge *ed = &medge[mloop[mlt->tri[j]].e];
- unsigned int tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v};
+ uint tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v};
if (((ed->v1 == tri_edge[0]) && (ed->v2 == tri_edge[1])) ||
((ed->v1 == tri_edge[1]) && (ed->v2 == tri_edge[0])))
@@ -3442,7 +3442,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender
if (eav->vert_index[1] == -1) {
value |= (1 << 31);
}
- GWN_vertbuf_attr_set(vbo, index_id, vidx++, &value);
+ GPU_vertbuf_attr_set(vbo, index_id, vidx++, &value);
}
}
@@ -3451,7 +3451,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender
int vbo_len_used = vidx;
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
return vbo;
@@ -3467,10 +3467,10 @@ static GPUTexture *mesh_batch_cache_get_edges_overlay_texture_buf(MeshRenderData
return cache->edges_face_overlay_tx;
}
- Gwn_VertBuf *vbo = cache->edges_face_overlay = mesh_batch_cache_create_edges_overlay_texture_buf(rdata);
+ GPUVertBuf *vbo = cache->edges_face_overlay = mesh_batch_cache_create_edges_overlay_texture_buf(rdata);
/* Upload data early because we need to create the texture for it. */
- GWN_vertbuf_use(vbo);
+ GPU_vertbuf_use(vbo);
cache->edges_face_overlay_tx = GPU_texture_create_from_vertbuf(vbo);
cache->edges_face_overlay_tri_count = vbo->vertex_alloc / 3;
@@ -3482,15 +3482,15 @@ static GPUTexture *mesh_batch_cache_get_vert_pos_and_nor_in_order_buf(MeshRender
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
if (cache->pos_in_order_tx == NULL) {
- Gwn_VertBuf *pos_in_order = mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache);
- GWN_vertbuf_use(pos_in_order); /* Upload early for buffer texture creation. */
+ GPUVertBuf *pos_in_order = mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache);
+ GPU_vertbuf_use(pos_in_order); /* Upload early for buffer texture creation. */
cache->pos_in_order_tx = GPU_texture_create_buffer(GPU_R32F, pos_in_order->vbo_id);
}
return cache->pos_in_order_tx;
}
-static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rdata, MeshBatchCache *cache)
+static GPUIndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI));
@@ -3498,15 +3498,15 @@ static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rda
const int vert_len = mesh_render_data_verts_len_get(rdata);
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len);
if (rdata->edit_bmesh) {
for (int i = 0; i < tri_len; ++i) {
const BMLoop **ltri = (const BMLoop **)rdata->edit_bmesh->looptris[i];
if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
- GWN_indexbuf_add_generic_vert(&elb, BM_elem_index_get(ltri[tri_corner]->v));
+ GPU_indexbuf_add_generic_vert(&elb, BM_elem_index_get(ltri[tri_corner]->v));
}
}
}
@@ -3515,18 +3515,18 @@ static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rda
for (int i = 0; i < tri_len; ++i) {
const MLoopTri *mlt = &rdata->mlooptri[i];
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
- GWN_indexbuf_add_generic_vert(&elb, mlt->tri[tri_corner]);
+ GPU_indexbuf_add_generic_vert(&elb, mlt->tri[tri_corner]);
}
}
}
- cache->triangles_in_order = GWN_indexbuf_build(&elb);
+ cache->triangles_in_order = GPU_indexbuf_build(&elb);
}
return cache->triangles_in_order;
}
-static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, MeshBatchCache *cache)
+static GPUIndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI));
@@ -3535,8 +3535,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes
const int edge_len = mesh_render_data_edges_len_get(rdata);
/* Alloc max (edge_len) and upload only needed range. */
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len);
if (rdata->edit_bmesh) {
/* No need to support since edit mesh already draw them.
@@ -3546,7 +3546,7 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes
BMEdge *eed;
BM_ITER_MESH(eed, &eiter, bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_edge_is_wire(eed)) {
- GWN_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2));
+ GPU_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2));
}
}
}
@@ -3554,17 +3554,17 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes
for (int i = 0; i < edge_len; ++i) {
const MEdge *medge = &rdata->medge[i];
if (medge->flag & ME_LOOSEEDGE) {
- GWN_indexbuf_add_line_verts(&elb, medge->v1, medge->v2);
+ GPU_indexbuf_add_line_verts(&elb, medge->v1, medge->v2);
}
}
}
- cache->ledges_in_order = GWN_indexbuf_build(&elb);
+ cache->ledges_in_order = GPU_indexbuf_build(&elb);
}
return cache->ledges_in_order;
}
-static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
+static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_POLY));
@@ -3576,7 +3576,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
int *mat_tri_len = MEM_callocN(sizeof(*mat_tri_len) * mat_len, __func__);
cache->shaded_triangles_in_order = MEM_callocN(sizeof(*cache->shaded_triangles) * mat_len, __func__);
- Gwn_IndexBufBuilder *elb = MEM_callocN(sizeof(*elb) * mat_len, __func__);
+ GPUIndexBufBuilder *elb = MEM_callocN(sizeof(*elb) * mat_len, __func__);
/* Note that polygons (not triangles) are used here.
* This OK because result is _guaranteed_ to be the same. */
@@ -3602,7 +3602,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
/* Init ELBs. */
for (int i = 0; i < mat_len; ++i) {
- GWN_indexbuf_init(&elb[i], GWN_PRIM_TRIS, mat_tri_len[i], tri_len * 3);
+ GPU_indexbuf_init(&elb[i], GPU_PRIM_TRIS, mat_tri_len[i], tri_len * 3);
}
/* Populate ELBs. */
@@ -3616,7 +3616,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
const short ma_id = efa->mat_nr < mat_len ? efa->mat_nr : 0;
for (int j = 2; j < efa->len; j++) {
- GWN_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2);
+ GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2);
nidx += 3;
}
}
@@ -3627,7 +3627,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
const MPoly *mp = &rdata->mpoly[i]; ;
const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0;
for (int j = 2; j < mp->totloop; j++) {
- GWN_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2);
+ GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2);
nidx += 3;
}
}
@@ -3635,7 +3635,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
/* Build ELBs. */
for (int i = 0; i < mat_len; ++i) {
- cache->shaded_triangles_in_order[i] = GWN_indexbuf_build(&elb[i]);
+ cache->shaded_triangles_in_order[i] = GPU_indexbuf_build(&elb[i]);
}
MEM_freeN(mat_tri_len);
@@ -3645,30 +3645,30 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
return cache->shaded_triangles_in_order;
}
-static Gwn_VertBuf *mesh_create_edge_pos_with_sel(
+static GPUVertBuf *mesh_create_edge_pos_with_sel(
MeshRenderData *rdata, bool use_wire, bool use_select_bool)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP));
BLI_assert(rdata->edit_bmesh == NULL);
- Gwn_VertBuf *vbo;
+ GPUVertBuf *vbo;
{
uint vidx = 0, cidx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, sel; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.sel = GWN_vertformat_attr_add(&format, "select", GWN_COMP_U8, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.sel = GPU_vertformat_attr_add(&format, "select", GPU_COMP_U8, 1, GPU_FETCH_INT);
}
const int edge_len = mesh_render_data_edges_len_get(rdata);
- vbo = GWN_vertbuf_create_with_format(&format);
+ vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = edge_len * 2;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
if (use_select_bool) {
mesh_render_data_ensure_edge_select_bool(rdata, use_wire);
@@ -3689,23 +3689,23 @@ static Gwn_VertBuf *mesh_create_edge_pos_with_sel(
continue;
}
- GWN_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel);
- GWN_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel);
+ GPU_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel);
+ GPU_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v1].co);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v2].co);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v1].co);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v2].co);
}
vbo_len_used = vidx;
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return vbo;
}
-static Gwn_IndexBuf *mesh_create_tri_overlay_weight_faces(
+static GPUIndexBuf *mesh_create_tri_overlay_weight_faces(
MeshRenderData *rdata)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI));
@@ -3714,57 +3714,57 @@ static Gwn_IndexBuf *mesh_create_tri_overlay_weight_faces(
const int vert_len = mesh_render_data_verts_len_get(rdata);
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len);
for (int i = 0; i < tri_len; ++i) {
const MLoopTri *mlt = &rdata->mlooptri[i];
if (!(rdata->mpoly[mlt->poly].flag & (ME_FACE_SEL | ME_HIDE))) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
- GWN_indexbuf_add_generic_vert(&elb, rdata->mloop[mlt->tri[tri_corner]].v);
+ GPU_indexbuf_add_generic_vert(&elb, rdata->mloop[mlt->tri[tri_corner]].v);
}
}
}
- return GWN_indexbuf_build(&elb);
+ return GPU_indexbuf_build(&elb);
}
}
/**
* Non-edit mode vertices (only used for weight-paint mode).
*/
-static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data(
+static GPUVertBuf *mesh_create_vert_pos_with_overlay_data(
MeshRenderData *rdata)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT));
BLI_assert(rdata->edit_bmesh == NULL);
- Gwn_VertBuf *vbo;
+ GPUVertBuf *vbo;
{
uint cidx = 0;
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint data; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_I8, 1, GWN_FETCH_INT);
+ if (format.attr_len == 0) {
+ attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_I8, 1, GPU_FETCH_INT);
}
const int vert_len = mesh_render_data_verts_len_get(rdata);
- vbo = GWN_vertbuf_create_with_format(&format);
+ vbo = GPU_vertbuf_create_with_format(&format);
const int vbo_len_capacity = vert_len;
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
for (int i = 0; i < vert_len; i++) {
const MVert *mv = &rdata->mvert[i];
const char data = mv->flag & (SELECT | ME_HIDE);
- GWN_vertbuf_attr_set(vbo, attr_id.data, cidx++, &data);
+ GPU_vertbuf_attr_set(vbo, attr_id.data, cidx++, &data);
}
vbo_len_used = cidx;
if (vbo_len_capacity != vbo_len_used) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
}
return vbo;
@@ -3778,7 +3778,7 @@ static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data(
/** \name Public API
* \{ */
-Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_all_edges(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3787,8 +3787,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me)
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->all_edges = GWN_batch_create(
- GWN_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
+ cache->all_edges = GPU_batch_create(
+ GPU_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
mesh_batch_cache_get_edges_in_order(rdata, cache));
mesh_render_data_free(rdata);
@@ -3797,7 +3797,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me)
return cache->all_edges;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3806,8 +3806,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me)
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->all_triangles = GWN_batch_create(
- GWN_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
+ cache->all_triangles = GPU_batch_create(
+ GPU_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
mesh_batch_cache_get_triangles_in_order(rdata, cache));
mesh_render_data_free(rdata);
@@ -3816,7 +3816,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me)
return cache->all_triangles;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3824,8 +3824,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me)
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->triangles_with_normals = GWN_batch_create(
- GWN_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL);
+ cache->triangles_with_normals = GPU_batch_create(
+ GPU_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL);
mesh_render_data_free(rdata);
}
@@ -3833,7 +3833,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me)
return cache->triangles_with_normals;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3841,8 +3841,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me)
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->ledges_with_normals = GWN_batch_create(
- GWN_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
+ cache->ledges_with_normals = GPU_batch_create(
+ GPU_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
mesh_batch_cache_get_loose_edges(rdata, cache));
mesh_render_data_free(rdata);
@@ -3851,7 +3851,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me)
return cache->ledges_with_normals;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, int defgroup)
+GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, int defgroup)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3861,14 +3861,14 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me,
MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_DVERT;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->triangles_with_weights = GWN_batch_create_ex(
- GWN_PRIM_TRIS, mesh_create_tri_weights(rdata, use_hide, defgroup), NULL, GWN_BATCH_OWNS_VBO);
+ cache->triangles_with_weights = GPU_batch_create_ex(
+ GPU_PRIM_TRIS, mesh_create_tri_weights(rdata, use_hide, defgroup), NULL, GPU_BATCH_OWNS_VBO);
- Gwn_VertBuf *vbo_tris = use_hide ?
+ GPUVertBuf *vbo_tris = use_hide ?
mesh_create_tri_pos_and_normals_visible_only(rdata) :
mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- GWN_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide);
+ GPU_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide);
mesh_render_data_free(rdata);
}
@@ -3876,7 +3876,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me,
return cache->triangles_with_weights;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3886,13 +3886,13 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh
MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->triangles_with_vert_colors = GWN_batch_create_ex(
- GWN_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GWN_BATCH_OWNS_VBO);
+ cache->triangles_with_vert_colors = GPU_batch_create_ex(
+ GPU_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GPU_BATCH_OWNS_VBO);
- Gwn_VertBuf *vbo_tris = use_hide ?
+ GPUVertBuf *vbo_tris = use_hide ?
mesh_create_tri_pos_and_normals_visible_only(rdata) :
mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- GWN_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide);
+ GPU_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide);
mesh_render_data_free(rdata);
}
@@ -3901,14 +3901,14 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh
}
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(
struct Mesh *me, bool use_hide, uint select_id_offset)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->triangles_with_select_id_offset != select_id_offset) {
cache->triangles_with_select_id_offset = select_id_offset;
- GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
}
if (cache->triangles_with_select_id == NULL) {
@@ -3916,13 +3916,13 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(
MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->triangles_with_select_id = GWN_batch_create_ex(
- GWN_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GWN_BATCH_OWNS_VBO);
+ cache->triangles_with_select_id = GPU_batch_create_ex(
+ GPU_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GPU_BATCH_OWNS_VBO);
- Gwn_VertBuf *vbo_tris = use_hide ?
+ GPUVertBuf *vbo_tris = use_hide ?
mesh_create_tri_pos_and_normals_visible_only(rdata) :
mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- GWN_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide);
+ GPU_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide);
mesh_render_data_free(rdata);
}
@@ -3934,7 +3934,7 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(
* Same as #DRW_mesh_batch_cache_get_triangles_with_select_id
* without the ID's, use to mask out geometry, eg - dont select face-dots behind other faces.
*/
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide)
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->triangles_with_select_mask == NULL) {
@@ -3942,12 +3942,12 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mes
MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- Gwn_VertBuf *vbo_tris = use_hide ?
+ GPUVertBuf *vbo_tris = use_hide ?
mesh_create_tri_pos_and_normals_visible_only(rdata) :
mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- cache->triangles_with_select_mask = GWN_batch_create_ex(
- GWN_PRIM_TRIS, vbo_tris, NULL, use_hide ? GWN_BATCH_OWNS_VBO : 0);
+ cache->triangles_with_select_mask = GPU_batch_create_ex(
+ GPU_PRIM_TRIS, vbo_tris, NULL, use_hide ? GPU_BATCH_OWNS_VBO : 0);
mesh_render_data_free(rdata);
}
@@ -3955,7 +3955,7 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mes
return cache->triangles_with_select_mask;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3963,8 +3963,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me)
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->points_with_normals = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL);
+ cache->points_with_normals = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL);
mesh_render_data_free(rdata);
}
@@ -3972,7 +3972,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me)
return cache->points_with_normals;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_all_verts(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3980,8 +3980,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me)
/* create batch from DM */
MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT);
- cache->all_verts = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL);
+ cache->all_verts = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL);
mesh_render_data_free(rdata);
}
@@ -3989,21 +3989,21 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me)
return cache->all_verts;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->fancy_edges == NULL) {
/* create batch from DM */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static struct { uint pos, n1, n2; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ attr_id.n1 = GPU_vertformat_attr_add(&format, "N1", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ attr_id.n2 = GPU_vertformat_attr_add(&format, "N2", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
MeshRenderData *rdata = mesh_render_data_create(
me, MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_POLY);
@@ -4012,7 +4012,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
const int vbo_len_capacity = edge_len * 2; /* these are PRIM_LINE verts, not mesh verts */
int vbo_len_used = 0;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
for (int i = 0; i < edge_len; ++i) {
float *vcos1, *vcos2;
float *pnor1 = NULL, *pnor2 = NULL;
@@ -4020,33 +4020,33 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
if (mesh_render_data_edge_vcos_manifold_pnors(rdata, i, &vcos1, &vcos2, &pnor1, &pnor2, &is_manifold)) {
- Gwn_PackedNormal n1value = { .x = 0, .y = 0, .z = +511 };
- Gwn_PackedNormal n2value = { .x = 0, .y = 0, .z = -511 };
+ GPUPackedNormal n1value = { .x = 0, .y = 0, .z = +511 };
+ GPUPackedNormal n2value = { .x = 0, .y = 0, .z = -511 };
if (is_manifold) {
- n1value = GWN_normal_convert_i10_v3(pnor1);
- n2value = GWN_normal_convert_i10_v3(pnor2);
+ n1value = GPU_normal_convert_i10_v3(pnor1);
+ n2value = GPU_normal_convert_i10_v3(pnor2);
}
- const Gwn_PackedNormal *n1 = &n1value;
- const Gwn_PackedNormal *n2 = &n2value;
+ const GPUPackedNormal *n1 = &n1value;
+ const GPUPackedNormal *n2 = &n2value;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1);
- GWN_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1);
- GWN_vertbuf_attr_set(vbo, attr_id.n2, 2 * i, n2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1);
+ GPU_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1);
+ GPU_vertbuf_attr_set(vbo, attr_id.n2, 2 * i, n2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * i + 1, vcos2);
- GWN_vertbuf_attr_set(vbo, attr_id.n1, 2 * i + 1, n1);
- GWN_vertbuf_attr_set(vbo, attr_id.n2, 2 * i + 1, n2);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * i + 1, vcos2);
+ GPU_vertbuf_attr_set(vbo, attr_id.n1, 2 * i + 1, n1);
+ GPU_vertbuf_attr_set(vbo, attr_id.n2, 2 * i + 1, n2);
vbo_len_used += 2;
}
}
if (vbo_len_used != vbo_len_capacity) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
}
- cache->fancy_edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ cache->fancy_edges = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
mesh_render_data_free(rdata);
}
@@ -4054,7 +4054,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
return cache->fancy_edges;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold)
+GPUBatch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4063,8 +4063,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold
MeshRenderData *rdata = mesh_render_data_create(me, options);
- cache->edge_detection = GWN_batch_create_ex(
- GWN_PRIM_LINES_ADJ, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
+ cache->edge_detection = GPU_batch_create_ex(
+ GPU_PRIM_LINES_ADJ, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
mesh_batch_cache_get_edges_adjacency(rdata, cache), 0);
mesh_render_data_free(rdata);
@@ -4111,42 +4111,42 @@ static void mesh_batch_cache_create_overlay_batches(Mesh *me)
MeshRenderData *rdata = mesh_render_data_create(me, options);
if (cache->overlay_triangles == NULL) {
- cache->overlay_triangles = GWN_batch_create(
- GWN_PRIM_TRIS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL);
- GWN_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_nor(rdata, cache));
- GWN_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_data(rdata, cache));
+ cache->overlay_triangles = GPU_batch_create(
+ GPU_PRIM_TRIS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL);
+ GPU_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_nor(rdata, cache));
+ GPU_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_data(rdata, cache));
}
if (cache->overlay_loose_edges == NULL) {
- cache->overlay_loose_edges = GWN_batch_create(
- GWN_PRIM_LINES, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL);
- GWN_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_nor(rdata, cache));
- GWN_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_data(rdata, cache));
+ cache->overlay_loose_edges = GPU_batch_create(
+ GPU_PRIM_LINES, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL);
+ GPU_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_nor(rdata, cache));
+ GPU_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_data(rdata, cache));
}
if (cache->overlay_loose_verts == NULL) {
- cache->overlay_loose_verts = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_edit_lvert_pos(rdata, cache), NULL);
- GWN_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_nor(rdata, cache));
- GWN_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_data(rdata, cache));
+ cache->overlay_loose_verts = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_edit_lvert_pos(rdata, cache), NULL);
+ GPU_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_nor(rdata, cache));
+ GPU_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_data(rdata, cache));
}
if (cache->overlay_triangles_nor == NULL) {
- cache->overlay_triangles_nor = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL);
- GWN_batch_vertbuf_add(cache->overlay_triangles_nor, mesh_batch_cache_get_edit_tri_nor(rdata, cache));
+ cache->overlay_triangles_nor = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL);
+ GPU_batch_vertbuf_add(cache->overlay_triangles_nor, mesh_batch_cache_get_edit_tri_nor(rdata, cache));
}
if (cache->overlay_loose_edges_nor == NULL) {
- cache->overlay_loose_edges_nor = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL);
- GWN_batch_vertbuf_add(cache->overlay_loose_edges_nor, mesh_batch_cache_get_edit_ledge_nor(rdata, cache));
+ cache->overlay_loose_edges_nor = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL);
+ GPU_batch_vertbuf_add(cache->overlay_loose_edges_nor, mesh_batch_cache_get_edit_ledge_nor(rdata, cache));
}
mesh_render_data_free(rdata);
}
-Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4157,7 +4157,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me)
return cache->overlay_triangles;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4168,7 +4168,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me)
return cache->overlay_loose_edges;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4179,7 +4179,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me)
return cache->overlay_loose_verts;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4190,7 +4190,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me)
return cache->overlay_triangles_nor;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4201,15 +4201,15 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me)
return cache->overlay_loose_edges_nor;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->overlay_facedots == NULL) {
MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY);
- cache->overlay_facedots = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL);
+ cache->overlay_facedots = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL);
mesh_render_data_free(rdata);
}
@@ -4217,13 +4217,13 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me)
return cache->overlay_facedots;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint select_id_offset)
+GPUBatch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint select_id_offset)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->facedot_with_select_id_offset != select_id_offset) {
cache->facedot_with_select_id_offset = select_id_offset;
- GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
}
if (cache->facedot_with_select_id == NULL) {
@@ -4231,10 +4231,10 @@ Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint selec
/* We only want the 'pos', not the normals or flag.
* Use since this is almost certainly already created. */
- cache->facedot_with_select_id = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL);
+ cache->facedot_with_select_id = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL);
- GWN_batch_vertbuf_add_ex(
+ GPU_batch_vertbuf_add_ex(
cache->facedot_with_select_id,
mesh_create_facedot_select_id(rdata, select_id_offset), true);
@@ -4244,22 +4244,22 @@ Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint selec
return cache->facedot_with_select_id;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_id_offset)
+GPUBatch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_id_offset)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->edges_with_select_id_offset != select_id_offset) {
cache->edges_with_select_id_offset = select_id_offset;
- GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
}
if (cache->edges_with_select_id == NULL) {
MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_EDGE);
- cache->edges_with_select_id = GWN_batch_create(
- GWN_PRIM_LINES, mesh_batch_cache_get_edges_visible(rdata, cache), NULL);
+ cache->edges_with_select_id = GPU_batch_create(
+ GPU_PRIM_LINES, mesh_batch_cache_get_edges_visible(rdata, cache), NULL);
- GWN_batch_vertbuf_add_ex(
+ GPU_batch_vertbuf_add_ex(
cache->edges_with_select_id,
mesh_create_edges_select_id(rdata, select_id_offset), true);
@@ -4269,22 +4269,22 @@ Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_i
return cache->edges_with_select_id;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id_offset)
+GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id_offset)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->verts_with_select_id_offset != select_id_offset) {
cache->verts_with_select_id_offset = select_id_offset;
- GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
+ GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
}
if (cache->verts_with_select_id == NULL) {
MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT);
- cache->verts_with_select_id = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_verts_visible(rdata, cache), NULL);
+ cache->verts_with_select_id = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_verts_visible(rdata, cache), NULL);
- GWN_batch_vertbuf_add_ex(
+ GPU_batch_vertbuf_add_ex(
cache->verts_with_select_id,
mesh_create_verts_select_id(rdata, select_id_offset), true);
@@ -4294,7 +4294,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_i
return cache->verts_with_select_id;
}
-Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(
+GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count)
{
@@ -4311,16 +4311,16 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(
cache->shaded_triangles = MEM_callocN(sizeof(*cache->shaded_triangles) * mat_len, __func__);
- Gwn_IndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache);
+ GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache);
- Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- Gwn_VertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache);
+ GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ GPUVertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache);
for (int i = 0; i < mat_len; ++i) {
- cache->shaded_triangles[i] = GWN_batch_create(
- GWN_PRIM_TRIS, vbo, el[i]);
+ cache->shaded_triangles[i] = GPU_batch_create(
+ GPU_PRIM_TRIS, vbo, el[i]);
if (vbo_shading) {
- GWN_batch_vertbuf_add(cache->shaded_triangles[i], vbo_shading);
+ GPU_batch_vertbuf_add(cache->shaded_triangles[i], vbo_shading);
}
}
@@ -4330,13 +4330,13 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(
if (auto_layer_names) {
*auto_layer_names = cache->auto_layer_names;
*auto_layer_is_srgb = cache->auto_layer_is_srgb;
- *auto_layer_count = cache->auto_layer_ct;
+ *auto_layer_count = cache->auto_layer_len;
}
return cache->shaded_triangles;
}
-Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me)
+GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4350,15 +4350,15 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me)
cache->texpaint_triangles = MEM_callocN(sizeof(*cache->texpaint_triangles) * mat_len, __func__);
- Gwn_IndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache);
+ GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache);
- Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
for (int i = 0; i < mat_len; ++i) {
- cache->texpaint_triangles[i] = GWN_batch_create(
- GWN_PRIM_TRIS, vbo, el[i]);
- Gwn_VertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache);
+ cache->texpaint_triangles[i] = GPU_batch_create(
+ GPU_PRIM_TRIS, vbo, el[i]);
+ GPUVertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache);
if (vbo_uv) {
- GWN_batch_vertbuf_add(cache->texpaint_triangles[i], vbo_uv);
+ GPU_batch_vertbuf_add(cache->texpaint_triangles[i], vbo_uv);
}
}
mesh_render_data_free(rdata);
@@ -4367,7 +4367,7 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me)
return cache->texpaint_triangles;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4377,20 +4377,20 @@ Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me)
MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOPUV;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- cache->texpaint_triangles_single = GWN_batch_create(
- GWN_PRIM_TRIS, vbo, NULL);
- Gwn_VertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache);
+ cache->texpaint_triangles_single = GPU_batch_create(
+ GPU_PRIM_TRIS, vbo, NULL);
+ GPUVertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache);
if (vbo_uv) {
- GWN_batch_vertbuf_add(cache->texpaint_triangles_single, vbo_uv);
+ GPU_batch_vertbuf_add(cache->texpaint_triangles_single, vbo_uv);
}
mesh_render_data_free(rdata);
}
return cache->texpaint_triangles_single;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel)
+GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4399,8 +4399,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->overlay_paint_edges = GWN_batch_create_ex(
- GWN_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GWN_BATCH_OWNS_VBO);
+ cache->overlay_paint_edges = GPU_batch_create_ex(
+ GPU_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GPU_BATCH_OWNS_VBO);
mesh_render_data_free(rdata);
}
@@ -4408,7 +4408,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire
return cache->overlay_paint_edges;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4417,9 +4417,9 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me)
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->overlay_weight_faces = GWN_batch_create_ex(
- GWN_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
- mesh_create_tri_overlay_weight_faces(rdata), GWN_BATCH_OWNS_INDEX);
+ cache->overlay_weight_faces = GPU_batch_create_ex(
+ GPU_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
+ mesh_create_tri_overlay_weight_faces(rdata), GPU_BATCH_OWNS_INDEX);
mesh_render_data_free(rdata);
}
@@ -4427,7 +4427,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me)
return cache->overlay_weight_faces;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -4435,10 +4435,10 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me)
/* create batch from Mesh */
MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT);
- cache->overlay_weight_verts = GWN_batch_create(
- GWN_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL);
+ cache->overlay_weight_verts = GPU_batch_create(
+ GPU_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL);
- GWN_batch_vertbuf_add_ex(
+ GPU_batch_vertbuf_add_ex(
cache->overlay_weight_verts,
mesh_create_vert_pos_with_overlay_data(rdata), true);
mesh_render_data_free(rdata);
@@ -4458,7 +4458,7 @@ void DRW_mesh_cache_sculpt_coords_ensure(Mesh *me)
/* XXX Force update of all the batches that contains the pos_with_normals buffer.
* TODO(fclem): Ideally, Gawain should provide a way to update a buffer without destroying it. */
mesh_batch_cache_clear_selective(me, cache->pos_with_normals);
- GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
+ GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
}
cache->is_sculpt_points_tag = false;
}
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 24930921bee..375b0ba6bb2 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -45,18 +45,18 @@
static void metaball_batch_cache_clear(MetaBall *mb);
/* ---------------------------------------------------------------------- */
-/* MetaBall Gwn_Batch Cache */
+/* MetaBall GPUBatch Cache */
typedef struct MetaBallBatchCache {
- Gwn_Batch *batch;
- Gwn_Batch **shaded_triangles;
+ GPUBatch *batch;
+ GPUBatch **shaded_triangles;
int mat_len;
/* settings to determine if cache is invalid */
bool is_dirty;
} MetaBallBatchCache;
-/* Gwn_Batch cache management. */
+/* GPUBatch cache management. */
static bool metaball_batch_cache_valid(MetaBall *mb)
{
@@ -113,7 +113,7 @@ static void metaball_batch_cache_clear(MetaBall *mb)
return;
}
- GWN_BATCH_DISCARD_SAFE(cache->batch);
+ GPU_BATCH_DISCARD_SAFE(cache->batch);
/* Note: shaded_triangles[0] is already freed by cache->batch */
MEM_SAFE_FREE(cache->shaded_triangles);
cache->mat_len = 0;
@@ -130,7 +130,7 @@ void DRW_mball_batch_cache_free(MetaBall *mb)
/** \name Public Object/MetaBall API
* \{ */
-Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob)
+GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob)
{
if (!BKE_mball_is_basis(ob)) {
return NULL;
@@ -141,17 +141,17 @@ Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob)
if (cache->batch == NULL) {
ListBase *lb = &ob->curve_cache->disp;
- cache->batch = GWN_batch_create_ex(
- GWN_PRIM_TRIS,
+ cache->batch = GPU_batch_create_ex(
+ GPU_PRIM_TRIS,
DRW_displist_vertbuf_calc_pos_with_normals(lb),
DRW_displist_indexbuf_calc_triangles_in_order(lb),
- GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
+ GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
}
return cache->batch;
}
-Gwn_Batch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len)
+GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len)
{
if (!BKE_mball_is_basis(ob)) {
return NULL;
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 28693b47c89..b56396261d3 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -61,13 +61,13 @@
static void particle_batch_cache_clear(ParticleSystem *psys);
/* ---------------------------------------------------------------------- */
-/* Particle Gwn_Batch Cache */
+/* Particle GPUBatch Cache */
typedef struct ParticlePointCache {
- Gwn_VertBuf *pos;
- Gwn_Batch *points;
- int elems_count;
- int point_count;
+ GPUVertBuf *pos;
+ GPUBatch *points;
+ int elems_len;
+ int point_len;
} ParticlePointCache;
typedef struct ParticleBatchCache {
@@ -80,19 +80,19 @@ typedef struct ParticleBatchCache {
/* Control points when in edit mode. */
ParticleHairCache edit_hair;
- Gwn_VertBuf *edit_inner_pos;
- Gwn_Batch *edit_inner_points;
- int edit_inner_point_count;
+ GPUVertBuf *edit_inner_pos;
+ GPUBatch *edit_inner_points;
+ int edit_inner_point_len;
- Gwn_VertBuf *edit_tip_pos;
- Gwn_Batch *edit_tip_points;
- int edit_tip_point_count;
+ GPUVertBuf *edit_tip_pos;
+ GPUBatch *edit_tip_points;
+ int edit_tip_point_len;
/* Settings to determine if cache is invalid. */
bool is_dirty;
} ParticleBatchCache;
-/* Gwn_Batch cache management. */
+/* GPUBatch cache management. */
typedef struct HairAttributeID {
uint pos;
@@ -158,39 +158,39 @@ void DRW_particle_batch_cache_dirty(ParticleSystem *psys, int mode)
static void particle_batch_cache_clear_point(ParticlePointCache *point_cache)
{
- GWN_BATCH_DISCARD_SAFE(point_cache->points);
- GWN_VERTBUF_DISCARD_SAFE(point_cache->pos);
+ GPU_BATCH_DISCARD_SAFE(point_cache->points);
+ GPU_VERTBUF_DISCARD_SAFE(point_cache->pos);
}
static void particle_batch_cache_clear_hair(ParticleHairCache *hair_cache)
{
/* TODO more granular update tagging. */
- GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_point_buf);
+ GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_point_buf);
DRW_TEXTURE_FREE_SAFE(hair_cache->point_tex);
- GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_strand_buf);
+ GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_strand_buf);
DRW_TEXTURE_FREE_SAFE(hair_cache->strand_tex);
for (int i = 0; i < MAX_MTFACE; ++i) {
- GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_uv_buf[i]);
+ GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_uv_buf[i]);
DRW_TEXTURE_FREE_SAFE(hair_cache->uv_tex[i]);
}
for (int i = 0; i < MAX_MCOL; ++i) {
- GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_col_buf[i]);
+ GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_col_buf[i]);
DRW_TEXTURE_FREE_SAFE(hair_cache->col_tex[i]);
}
for (int i = 0; i < MAX_HAIR_SUBDIV; ++i) {
- GWN_VERTBUF_DISCARD_SAFE(hair_cache->final[i].proc_buf);
+ GPU_VERTBUF_DISCARD_SAFE(hair_cache->final[i].proc_buf);
DRW_TEXTURE_FREE_SAFE(hair_cache->final[i].proc_tex);
for (int j = 0; j < MAX_THICKRES; ++j) {
- GWN_BATCH_DISCARD_SAFE(hair_cache->final[i].proc_hairs[j]);
+ GPU_BATCH_DISCARD_SAFE(hair_cache->final[i].proc_hairs[j]);
}
}
/* "Normal" legacy hairs */
- GWN_BATCH_DISCARD_SAFE(hair_cache->hairs);
- GWN_VERTBUF_DISCARD_SAFE(hair_cache->pos);
- GWN_INDEXBUF_DISCARD_SAFE(hair_cache->indices);
+ GPU_BATCH_DISCARD_SAFE(hair_cache->hairs);
+ GPU_VERTBUF_DISCARD_SAFE(hair_cache->pos);
+ GPU_INDEXBUF_DISCARD_SAFE(hair_cache->indices);
}
static void particle_batch_cache_clear(ParticleSystem *psys)
@@ -205,10 +205,10 @@ static void particle_batch_cache_clear(ParticleSystem *psys)
particle_batch_cache_clear_hair(&cache->edit_hair);
- GWN_BATCH_DISCARD_SAFE(cache->edit_inner_points);
- GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos);
- GWN_BATCH_DISCARD_SAFE(cache->edit_tip_points);
- GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos);
+ GPU_BATCH_DISCARD_SAFE(cache->edit_inner_points);
+ GPU_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos);
+ GPU_BATCH_DISCARD_SAFE(cache->edit_tip_points);
+ GPU_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos);
}
void DRW_particle_batch_cache_free(ParticleSystem *psys)
@@ -225,9 +225,9 @@ static void count_cache_segment_keys(
for (int i = 0; i < num_path_cache_keys; i++) {
ParticleCacheKey *path = pathcache[i];
if (path->segments > 0) {
- hair_cache->strands_count++;
- hair_cache->elems_count += path->segments + 2;
- hair_cache->point_count += path->segments + 1;
+ hair_cache->strands_len++;
+ hair_cache->elems_len += path->segments + 2;
+ hair_cache->point_len += path->segments + 1;
}
}
}
@@ -243,9 +243,9 @@ static void ensure_seg_pt_count(
return;
}
- hair_cache->strands_count = 0;
- hair_cache->elems_count = 0;
- hair_cache->point_count = 0;
+ hair_cache->strands_len = 0;
+ hair_cache->elems_len = 0;
+ hair_cache->point_len = 0;
if (edit != NULL && edit->pathcache != NULL) {
count_cache_segment_keys(edit->pathcache, edit->totcached, hair_cache);
@@ -263,7 +263,7 @@ static void ensure_seg_pt_count(
}
}
-static void particle_pack_mcol(MCol *mcol, unsigned short r_scol[3])
+static void particle_pack_mcol(MCol *mcol, ushort r_scol[3])
{
/* Convert to linear ushort and swizzle */
r_scol[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mcol->b]);
@@ -514,7 +514,7 @@ static int particle_batch_cache_fill_segments(
uint *col_id,
float (***r_parent_uvs)[2],
MCol ***r_parent_mcol,
- Gwn_IndexBufBuilder *elb,
+ GPUIndexBufBuilder *elb,
HairAttributeID *attr_id,
ParticleHairCache *hair_cache)
{
@@ -561,51 +561,51 @@ static int particle_batch_cache_fill_segments(
else {
sub_v3_v3v3(tangent, path[j + 1].co, path[j - 1].co);
}
- GWN_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[j].co);
- GWN_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent);
- GWN_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &i);
+ GPU_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[j].co);
+ GPU_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent);
+ GPU_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &i);
if (psmd != NULL) {
for (int k = 0; k < num_uv_layers; k++) {
- GWN_vertbuf_attr_set(
+ GPU_vertbuf_attr_set(
hair_cache->pos, uv_id[k], curr_point,
(is_simple && is_child) ?
(*r_parent_uvs)[psys->child[i].parent][k] : uv[k]);
}
for (int k = 0; k < num_col_layers; k++) {
/* TODO Put the conversion outside the loop */
- unsigned short scol[4];
+ ushort scol[4];
particle_pack_mcol(
(is_simple && is_child) ?
&(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k],
scol);
- GWN_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol);
+ GPU_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol);
}
}
- GWN_indexbuf_add_generic_vert(elb, curr_point);
+ GPU_indexbuf_add_generic_vert(elb, curr_point);
curr_point++;
}
sub_v3_v3v3(tangent, path[path->segments].co, path[path->segments - 1].co);
int global_index = i + global_offset;
- GWN_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[path->segments].co);
- GWN_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent);
- GWN_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &global_index);
+ GPU_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[path->segments].co);
+ GPU_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent);
+ GPU_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &global_index);
if (psmd != NULL) {
for (int k = 0; k < num_uv_layers; k++) {
- GWN_vertbuf_attr_set(
+ GPU_vertbuf_attr_set(
hair_cache->pos, uv_id[k], curr_point,
(is_simple && is_child) ?
(*r_parent_uvs)[psys->child[i].parent][k] : uv[k]);
}
for (int k = 0; k < num_col_layers; k++) {
/* TODO Put the conversion outside the loop */
- unsigned short scol[4];
+ ushort scol[4];
particle_pack_mcol(
(is_simple && is_child) ?
&(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k],
scol);
- GWN_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol);
+ GPU_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol);
}
if (!is_simple) {
MEM_freeN(uv);
@@ -613,8 +613,8 @@ static int particle_batch_cache_fill_segments(
}
}
/* Finish the segment and add restart primitive. */
- GWN_indexbuf_add_generic_vert(elb, curr_point);
- GWN_indexbuf_add_primitive_restart(elb);
+ GPU_indexbuf_add_generic_vert(elb, curr_point);
+ GPU_indexbuf_add_primitive_restart(elb);
curr_point++;
}
return curr_point;
@@ -623,7 +623,7 @@ static int particle_batch_cache_fill_segments(
static void particle_batch_cache_fill_segments_proc_pos(
ParticleCacheKey **path_cache,
const int num_path_keys,
- Gwn_VertBufRaw *attr_step)
+ GPUVertBufRaw *attr_step)
{
for (int i = 0; i < num_path_keys; i++) {
ParticleCacheKey *path = path_cache[i];
@@ -633,7 +633,7 @@ static void particle_batch_cache_fill_segments_proc_pos(
float total_len = 0.0f;
float *co_prev = NULL, *seg_data_first;
for (int j = 0; j <= path->segments; j++) {
- float *seg_data = (float *)GWN_vertbuf_raw_step(attr_step);
+ float *seg_data = (float *)GPU_vertbuf_raw_step(attr_step);
copy_v3_v3(seg_data, path[j].co);
if (co_prev) {
total_len += len_v3v3(co_prev, path[j].co);
@@ -658,7 +658,7 @@ static int particle_batch_cache_fill_segments_indices(
const int start_index,
const int num_path_keys,
const int res,
- Gwn_IndexBufBuilder *elb)
+ GPUIndexBufBuilder *elb)
{
int curr_point = start_index;
for (int i = 0; i < num_path_keys; i++) {
@@ -667,9 +667,9 @@ static int particle_batch_cache_fill_segments_indices(
continue;
}
for (int k = 0; k < res; k++) {
- GWN_indexbuf_add_generic_vert(elb, curr_point++);
+ GPU_indexbuf_add_generic_vert(elb, curr_point++);
}
- GWN_indexbuf_add_primitive_restart(elb);
+ GPU_indexbuf_add_primitive_restart(elb);
}
return curr_point;
}
@@ -681,9 +681,9 @@ static int particle_batch_cache_fill_strands_data(
const ParticleSource particle_source,
const int start_index,
const int num_path_keys,
- Gwn_VertBufRaw *data_step,
- float (***r_parent_uvs)[2], Gwn_VertBufRaw *uv_step, MTFace **mtfaces, int num_uv_layers,
- MCol ***r_parent_mcol, Gwn_VertBufRaw *col_step, MCol **mcols, int num_col_layers)
+ GPUVertBufRaw *data_step,
+ float (***r_parent_uvs)[2], GPUVertBufRaw *uv_step, MTFace **mtfaces, int num_uv_layers,
+ MCol ***r_parent_mcol, GPUVertBufRaw *col_step, MCol **mcols, int num_col_layers)
{
const bool is_simple = (psys->part->childtype == PART_CHILD_PARTICLES);
const bool is_child = (particle_source == PARTICLE_SOURCE_CHILDREN);
@@ -705,7 +705,7 @@ static int particle_batch_cache_fill_strands_data(
continue;
}
- uint *seg_data = (uint *)GWN_vertbuf_raw_step(data_step);
+ uint *seg_data = (uint *)GPU_vertbuf_raw_step(data_step);
*seg_data = (curr_point & 0xFFFFFF) | (path->segments << 24);
curr_point += path->segments + 1;
@@ -730,11 +730,11 @@ static int particle_batch_cache_fill_strands_data(
*r_parent_mcol, &mcol);
for (int k = 0; k < num_uv_layers; k++) {
- float *t_uv = (float *)GWN_vertbuf_raw_step(uv_step + k);
+ float *t_uv = (float *)GPU_vertbuf_raw_step(uv_step + k);
copy_v2_v2(t_uv, uv[k]);
}
for (int k = 0; k < num_col_layers; k++) {
- unsigned short *scol = (unsigned short *)GWN_vertbuf_raw_step(col_step + k);
+ ushort *scol = (ushort *)GPU_vertbuf_raw_step(col_step + k);
particle_pack_mcol(
(is_simple && is_child) ?
&(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k],
@@ -754,17 +754,17 @@ static void particle_batch_cache_ensure_procedural_final_points(
int subdiv)
{
/* Same format as point_tex. */
- Gwn_VertFormat format = { 0 };
- GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat format = { 0 };
+ GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
- cache->final[subdiv].proc_buf = GWN_vertbuf_create_with_format(&format);
+ cache->final[subdiv].proc_buf = GPU_vertbuf_create_with_format(&format);
/* Create a destination buffer for the tranform feedback. Sized appropriately */
/* Thoses are points! not line segments. */
- GWN_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_count);
+ GPU_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_len);
/* Create vbo immediatly to bind to texture buffer. */
- GWN_vertbuf_use(cache->final[subdiv].proc_buf);
+ GPU_vertbuf_use(cache->final[subdiv].proc_buf);
cache->final[subdiv].proc_tex = GPU_texture_create_from_vertbuf(cache->final[subdiv].proc_buf);
}
@@ -791,37 +791,37 @@ static void particle_batch_cache_ensure_procedural_strand_data(
}
}
- Gwn_VertBufRaw data_step;
- Gwn_VertBufRaw uv_step[MAX_MTFACE];
- Gwn_VertBufRaw col_step[MAX_MCOL];
+ GPUVertBufRaw data_step;
+ GPUVertBufRaw uv_step[MAX_MTFACE];
+ GPUVertBufRaw col_step[MAX_MCOL];
MTFace *mtfaces[MAX_MTFACE] = {NULL};
MCol *mcols[MAX_MCOL] = {NULL};
float (**parent_uvs)[2] = NULL;
MCol **parent_mcol = NULL;
- Gwn_VertFormat format_data = {0};
- uint data_id = GWN_vertformat_attr_add(&format_data, "data", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ GPUVertFormat format_data = {0};
+ uint data_id = GPU_vertformat_attr_add(&format_data, "data", GPU_COMP_U32, 1, GPU_FETCH_INT);
- Gwn_VertFormat format_uv = {0};
- uint uv_id = GWN_vertformat_attr_add(&format_uv, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat format_uv = {0};
+ uint uv_id = GPU_vertformat_attr_add(&format_uv, "uv", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- Gwn_VertFormat format_col = {0};
- uint col_id = GWN_vertformat_attr_add(&format_col, "col", GWN_COMP_U16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat format_col = {0};
+ uint col_id = GPU_vertformat_attr_add(&format_col, "col", GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
memset(cache->uv_layer_names, 0, sizeof(cache->uv_layer_names));
memset(cache->col_layer_names, 0, sizeof(cache->col_layer_names));
/* Strand Data */
- cache->proc_strand_buf = GWN_vertbuf_create_with_format(&format_data);
- GWN_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_count);
- GWN_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step);
+ cache->proc_strand_buf = GPU_vertbuf_create_with_format(&format_data);
+ GPU_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len);
+ GPU_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step);
/* UV layers */
for (int i = 0; i < cache->num_uv_layers; i++) {
- cache->proc_uv_buf[i] = GWN_vertbuf_create_with_format(&format_uv);
- GWN_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_count);
- GWN_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]);
+ cache->proc_uv_buf[i] = GPU_vertbuf_create_with_format(&format_uv);
+ GPU_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len);
+ GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]);
const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
uint hash = BLI_ghashutil_strhash_p(name);
@@ -835,9 +835,9 @@ static void particle_batch_cache_ensure_procedural_strand_data(
}
/* Vertex colors */
for (int i = 0; i < cache->num_col_layers; i++) {
- cache->proc_col_buf[i] = GWN_vertbuf_create_with_format(&format_col);
- GWN_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_count);
- GWN_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]);
+ cache->proc_col_buf[i] = GPU_vertbuf_create_with_format(&format_col);
+ GPU_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len);
+ GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]);
const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i);
uint hash = BLI_ghashutil_strhash_p(name);
@@ -914,15 +914,15 @@ static void particle_batch_cache_ensure_procedural_strand_data(
}
/* Create vbo immediatly to bind to texture buffer. */
- GWN_vertbuf_use(cache->proc_strand_buf);
+ GPU_vertbuf_use(cache->proc_strand_buf);
cache->strand_tex = GPU_texture_create_from_vertbuf(cache->proc_strand_buf);
for (int i = 0; i < cache->num_uv_layers; i++) {
- GWN_vertbuf_use(cache->proc_uv_buf[i]);
+ GPU_vertbuf_use(cache->proc_uv_buf[i]);
cache->uv_tex[i] = GPU_texture_create_from_vertbuf(cache->proc_uv_buf[i]);
}
for (int i = 0; i < cache->num_col_layers; i++) {
- GWN_vertbuf_use(cache->proc_col_buf[i]);
+ GPU_vertbuf_use(cache->proc_col_buf[i]);
cache->col_tex[i] = GPU_texture_create_from_vertbuf(cache->proc_col_buf[i]);
}
}
@@ -942,20 +942,20 @@ static void particle_batch_cache_ensure_procedural_indices(
int verts_per_hair = cache->final[subdiv].strands_res * thickness_res;
/* +1 for primitive restart */
- int element_count = (verts_per_hair + 1) * cache->strands_count;
- Gwn_PrimType prim_type = (thickness_res == 1) ? GWN_PRIM_LINE_STRIP : GWN_PRIM_TRI_STRIP;
+ int element_count = (verts_per_hair + 1) * cache->strands_len;
+ GPUPrimType prim_type = (thickness_res == 1) ? GPU_PRIM_LINE_STRIP : GPU_PRIM_TRI_STRIP;
- static Gwn_VertFormat format = { 0 };
- GWN_vertformat_clear(&format);
+ static GPUVertFormat format = { 0 };
+ GPU_vertformat_clear(&format);
/* initialize vertex format */
- GWN_vertformat_attr_add(&format, "dummy", GWN_COMP_U8, 1, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, 1);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, 1);
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init_ex(&elb, prim_type, element_count, element_count, true);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init_ex(&elb, prim_type, element_count, element_count, true);
if (edit != NULL && edit->pathcache != NULL) {
particle_batch_cache_fill_segments_indices(
@@ -976,11 +976,11 @@ static void particle_batch_cache_ensure_procedural_indices(
}
}
- cache->final[subdiv].proc_hairs[thickness_res - 1] = GWN_batch_create_ex(
+ cache->final[subdiv].proc_hairs[thickness_res - 1] = GPU_batch_create_ex(
prim_type,
vbo,
- GWN_indexbuf_build(&elb),
- GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
+ GPU_indexbuf_build(&elb),
+ GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
}
static void particle_batch_cache_ensure_procedural_pos(
@@ -993,14 +993,14 @@ static void particle_batch_cache_ensure_procedural_pos(
}
/* initialize vertex format */
- Gwn_VertFormat format = {0};
- uint pos_id = GWN_vertformat_attr_add(&format, "posTime", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat format = {0};
+ uint pos_id = GPU_vertformat_attr_add(&format, "posTime", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
- cache->proc_point_buf = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(cache->proc_point_buf, cache->point_count);
+ cache->proc_point_buf = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len);
- Gwn_VertBufRaw pos_step;
- GWN_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step);
+ GPUVertBufRaw pos_step;
+ GPU_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step);
if (edit != NULL && edit->pathcache != NULL) {
particle_batch_cache_fill_segments_proc_pos(
@@ -1027,7 +1027,7 @@ static void particle_batch_cache_ensure_procedural_pos(
}
/* Create vbo immediatly to bind to texture buffer. */
- GWN_vertbuf_use(cache->proc_point_buf);
+ GPU_vertbuf_use(cache->proc_point_buf);
cache->point_tex = GPU_texture_create_from_vertbuf(cache->proc_point_buf);
}
@@ -1045,10 +1045,10 @@ static void particle_batch_cache_ensure_pos_and_seg(
int curr_point = 0;
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
- GWN_VERTBUF_DISCARD_SAFE(hair_cache->pos);
- GWN_INDEXBUF_DISCARD_SAFE(hair_cache->indices);
+ GPU_VERTBUF_DISCARD_SAFE(hair_cache->pos);
+ GPU_INDEXBUF_DISCARD_SAFE(hair_cache->indices);
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
HairAttributeID attr_id;
uint *uv_id = NULL;
uint *col_id = NULL;
@@ -1072,12 +1072,12 @@ static void particle_batch_cache_ensure_pos_and_seg(
}
}
- GWN_vertformat_clear(&format);
+ GPU_vertformat_clear(&format);
/* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.tan = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.ind = GWN_vertformat_attr_add(&format, "ind", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.tan = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.ind = GPU_vertformat_attr_add(&format, "ind", GPU_COMP_I32, 1, GPU_FETCH_INT);
if (psmd) {
uv_id = MEM_mallocN(sizeof(*uv_id) * num_uv_layers, "UV attrib format");
@@ -1088,10 +1088,10 @@ static void particle_batch_cache_ensure_pos_and_seg(
char uuid[32];
BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(name));
- uv_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (i == active_uv) {
- GWN_vertformat_alias_add(&format, "u");
+ GPU_vertformat_alias_add(&format, "u");
}
}
@@ -1100,22 +1100,22 @@ static void particle_batch_cache_ensure_pos_and_seg(
char uuid[32];
BLI_snprintf(uuid, sizeof(uuid), "c%u", BLI_ghashutil_strhash_p(name));
- col_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (i == active_col) {
- GWN_vertformat_alias_add(&format, "c");
+ GPU_vertformat_alias_add(&format, "c");
}
}
}
- hair_cache->pos = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_count);
+ hair_cache->pos = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len);
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init_ex(
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init_ex(
&elb,
- GWN_PRIM_LINE_STRIP,
- hair_cache->elems_count, hair_cache->point_count,
+ GPU_PRIM_LINE_STRIP,
+ hair_cache->elems_len, hair_cache->point_len,
true);
if (num_uv_layers || num_col_layers) {
@@ -1183,7 +1183,7 @@ static void particle_batch_cache_ensure_pos_and_seg(
if (psmd != NULL) {
MEM_freeN(uv_id);
}
- hair_cache->indices = GWN_indexbuf_build(&elb);
+ hair_cache->indices = GPU_indexbuf_build(&elb);
}
static void particle_batch_cache_ensure_pos(
@@ -1195,8 +1195,8 @@ static void particle_batch_cache_ensure_pos(
return;
}
- static Gwn_VertFormat format = { 0 };
- static unsigned pos_id, rot_id, val_id;
+ static GPUVertFormat format = { 0 };
+ static uint pos_id, rot_id, val_id;
int i, curr_point;
ParticleData *pa;
ParticleKey state;
@@ -1217,17 +1217,17 @@ static void particle_batch_cache_ensure_pos(
}
}
- GWN_VERTBUF_DISCARD_SAFE(point_cache->pos);
+ GPU_VERTBUF_DISCARD_SAFE(point_cache->pos);
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
- rot_id = GWN_vertformat_attr_add(&format, "rot", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
- val_id = GWN_vertformat_attr_add(&format, "val", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
+ pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ rot_id = GPU_vertformat_attr_add(&format, "rot", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ val_id = GPU_vertformat_attr_add(&format, "val", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
- point_cache->pos = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(point_cache->pos, psys->totpart);
+ point_cache->pos = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(point_cache->pos, psys->totpart);
for (curr_point = 0, i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) {
state.time = DEG_get_ctime(draw_ctx->depsgraph);
@@ -1237,8 +1237,8 @@ static void particle_batch_cache_ensure_pos(
float val;
- GWN_vertbuf_attr_set(point_cache->pos, pos_id, curr_point, pa->state.co);
- GWN_vertbuf_attr_set(point_cache->pos, rot_id, curr_point, pa->state.rot);
+ GPU_vertbuf_attr_set(point_cache->pos, pos_id, curr_point, pa->state.co);
+ GPU_vertbuf_attr_set(point_cache->pos, rot_id, curr_point, pa->state.rot);
switch (psys->part->draw_col) {
case PART_DRAW_COL_VEL:
@@ -1254,13 +1254,13 @@ static void particle_batch_cache_ensure_pos(
break;
}
- GWN_vertbuf_attr_set(point_cache->pos, val_id, curr_point, &val);
+ GPU_vertbuf_attr_set(point_cache->pos, val_id, curr_point, &val);
curr_point++;
}
if (curr_point != psys->totpart) {
- GWN_vertbuf_data_resize(point_cache->pos, curr_point);
+ GPU_vertbuf_data_resize(point_cache->pos, curr_point);
}
}
@@ -1334,7 +1334,7 @@ static void drw_particle_get_hair_source(
}
}
-Gwn_Batch *DRW_particles_batch_cache_get_hair(
+GPUBatch *DRW_particles_batch_cache_get_hair(
Object *object,
ParticleSystem *psys,
ModifierData *md)
@@ -1346,27 +1346,27 @@ Gwn_Batch *DRW_particles_batch_cache_get_hair(
drw_particle_get_hair_source(object, psys, md, NULL, &source);
ensure_seg_pt_count(source.edit, source.psys, &cache->hair);
particle_batch_cache_ensure_pos_and_seg(source.edit, source.psys, source.md, &cache->hair);
- cache->hair.hairs = GWN_batch_create(
- GWN_PRIM_LINE_STRIP,
+ cache->hair.hairs = GPU_batch_create(
+ GPU_PRIM_LINE_STRIP,
cache->hair.pos,
cache->hair.indices);
}
return cache->hair.hairs;
}
-Gwn_Batch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *psys)
+GPUBatch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *psys)
{
ParticleBatchCache *cache = particle_batch_cache_get(psys);
if (cache->point.points == NULL) {
particle_batch_cache_ensure_pos(object, psys, &cache->point);
- cache->point.points = GWN_batch_create(GWN_PRIM_POINTS, cache->point.pos, NULL);
+ cache->point.points = GPU_batch_create(GPU_PRIM_POINTS, cache->point.pos, NULL);
}
return cache->point.points;
}
-Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(
+GPUBatch *DRW_particles_batch_cache_get_edit_strands(
Object *object,
ParticleSystem *psys,
PTCacheEdit *edit)
@@ -1378,8 +1378,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(
drw_particle_update_ptcache_edit(object, psys, edit);
ensure_seg_pt_count(edit, psys, &cache->edit_hair);
particle_batch_cache_ensure_pos_and_seg(edit, psys, NULL, &cache->edit_hair);
- cache->edit_hair.hairs = GWN_batch_create(
- GWN_PRIM_LINE_STRIP,
+ cache->edit_hair.hairs = GPU_batch_create(
+ GPU_PRIM_LINE_STRIP,
cache->edit_hair.pos,
cache->edit_hair.indices);
return cache->edit_hair.hairs;
@@ -1392,11 +1392,11 @@ static void ensure_edit_inner_points_count(
if (cache->edit_inner_pos != NULL) {
return;
}
- cache->edit_inner_point_count = 0;
+ cache->edit_inner_point_len = 0;
for (int point_index = 0; point_index < edit->totpoint; point_index++) {
const PTCacheEditPoint *point = &edit->points[point_index];
BLI_assert(point->totkey >= 1);
- cache->edit_inner_point_count += (point->totkey - 1);
+ cache->edit_inner_point_len += (point->totkey - 1);
}
}
@@ -1419,19 +1419,19 @@ static void particle_batch_cache_ensure_edit_inner_pos(
return;
}
- static Gwn_VertFormat format = { 0 };
- static unsigned pos_id, color_id;
+ static GPUVertFormat format = { 0 };
+ static uint pos_id, color_id;
- GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos);
+ GPU_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos);
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
}
- cache->edit_inner_pos = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_count);
+ cache->edit_inner_pos = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len);
float selected_color[4], normal_color[4];
edit_colors_get(edit, selected_color, normal_color);
@@ -1441,19 +1441,19 @@ static void particle_batch_cache_ensure_edit_inner_pos(
const PTCacheEditPoint *point = &edit->points[point_index];
for (int key_index = 0; key_index < point->totkey - 1; key_index++) {
PTCacheEditKey *key = &point->keys[key_index];
- GWN_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co);
+ GPU_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co);
if (key->flag & PEK_SELECT) {
- GWN_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, selected_color);
+ GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, selected_color);
}
else {
- GWN_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, normal_color);
+ GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, normal_color);
}
global_key_index++;
}
}
}
-Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(
+GPUBatch *DRW_particles_batch_cache_get_edit_inner_points(
Object *object,
ParticleSystem *psys,
PTCacheEdit *edit)
@@ -1465,8 +1465,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(
drw_particle_update_ptcache_edit(object, psys, edit);
ensure_edit_inner_points_count(edit, cache);
particle_batch_cache_ensure_edit_inner_pos(edit, cache);
- cache->edit_inner_points = GWN_batch_create(
- GWN_PRIM_POINTS,
+ cache->edit_inner_points = GPU_batch_create(
+ GPU_PRIM_POINTS,
cache->edit_inner_pos,
NULL);
return cache->edit_inner_points;
@@ -1479,7 +1479,7 @@ static void ensure_edit_tip_points_count(
if (cache->edit_tip_pos != NULL) {
return;
}
- cache->edit_tip_point_count = edit->totpoint;
+ cache->edit_tip_point_len = edit->totpoint;
}
static void particle_batch_cache_ensure_edit_tip_pos(
@@ -1490,19 +1490,19 @@ static void particle_batch_cache_ensure_edit_tip_pos(
return;
}
- static Gwn_VertFormat format = { 0 };
- static unsigned pos_id, color_id;
+ static GPUVertFormat format = { 0 };
+ static uint pos_id, color_id;
- GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos);
+ GPU_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos);
- if (format.attrib_ct == 0) {
+ if (format.attr_len == 0) {
/* initialize vertex format */
- pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
}
- cache->edit_tip_pos = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_count);
+ cache->edit_tip_pos = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len);
float selected_color[4], normal_color[4];
edit_colors_get(edit, selected_color, normal_color);
@@ -1510,17 +1510,17 @@ static void particle_batch_cache_ensure_edit_tip_pos(
for (int point_index = 0; point_index < edit->totpoint; point_index++) {
const PTCacheEditPoint *point = &edit->points[point_index];
PTCacheEditKey *key = &point->keys[point->totkey - 1];
- GWN_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co);
+ GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co);
if (key->flag & PEK_SELECT) {
- GWN_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, selected_color);
+ GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, selected_color);
}
else {
- GWN_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, normal_color);
+ GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, normal_color);
}
}
}
-Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(
+GPUBatch *DRW_particles_batch_cache_get_edit_tip_points(
Object *object,
ParticleSystem *psys,
PTCacheEdit *edit)
@@ -1532,8 +1532,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(
drw_particle_update_ptcache_edit(object, psys, edit);
ensure_edit_tip_points_count(edit, cache);
particle_batch_cache_ensure_edit_tip_pos(edit, cache);
- cache->edit_tip_points = GWN_batch_create(
- GWN_PRIM_POINTS,
+ cache->edit_tip_points = GPU_batch_create(
+ GPU_PRIM_POINTS,
cache->edit_tip_pos,
NULL);
return cache->edit_tip_points;
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index a1c60be4742..c9fc5eba079 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -162,6 +162,8 @@ extern char datatoc_animviz_mpath_lines_vert_glsl[];
extern char datatoc_animviz_mpath_lines_geom_glsl[];
extern char datatoc_animviz_mpath_points_vert_glsl[];
+extern char datatoc_volume_velocity_vert_glsl[];
+
extern char datatoc_armature_axes_vert_glsl[];
extern char datatoc_armature_sphere_solid_vert_glsl[];
extern char datatoc_armature_sphere_solid_frag_glsl[];
@@ -199,33 +201,36 @@ static struct {
struct GPUShader *mpath_line_sh;
struct GPUShader *mpath_points_sh;
+ struct GPUShader *volume_velocity_needle_sh;
+ struct GPUShader *volume_velocity_sh;
+
struct GPUShader *mball_handles;
} g_shaders = {NULL};
static struct {
- struct Gwn_VertFormat *instance_screenspace;
- struct Gwn_VertFormat *instance_color;
- struct Gwn_VertFormat *instance_screen_aligned;
- struct Gwn_VertFormat *instance_scaled;
- struct Gwn_VertFormat *instance_sized;
- struct Gwn_VertFormat *instance_outline;
- struct Gwn_VertFormat *instance;
- struct Gwn_VertFormat *instance_camera;
- struct Gwn_VertFormat *instance_distance_lines;
- struct Gwn_VertFormat *instance_spot;
- struct Gwn_VertFormat *instance_bone;
- struct Gwn_VertFormat *instance_bone_stick;
- struct Gwn_VertFormat *instance_bone_outline;
- struct Gwn_VertFormat *instance_bone_envelope;
- struct Gwn_VertFormat *instance_bone_envelope_distance;
- struct Gwn_VertFormat *instance_bone_envelope_outline;
- struct Gwn_VertFormat *instance_mball_handles;
- struct Gwn_VertFormat *dynlines_color;
+ struct GPUVertFormat *instance_screenspace;
+ struct GPUVertFormat *instance_color;
+ struct GPUVertFormat *instance_screen_aligned;
+ struct GPUVertFormat *instance_scaled;
+ struct GPUVertFormat *instance_sized;
+ struct GPUVertFormat *instance_outline;
+ struct GPUVertFormat *instance;
+ struct GPUVertFormat *instance_camera;
+ struct GPUVertFormat *instance_distance_lines;
+ struct GPUVertFormat *instance_spot;
+ struct GPUVertFormat *instance_bone;
+ struct GPUVertFormat *instance_bone_stick;
+ struct GPUVertFormat *instance_bone_outline;
+ struct GPUVertFormat *instance_bone_envelope;
+ struct GPUVertFormat *instance_bone_envelope_distance;
+ struct GPUVertFormat *instance_bone_envelope_outline;
+ struct GPUVertFormat *instance_mball_handles;
+ struct GPUVertFormat *dynlines_color;
} g_formats = {NULL};
void DRW_globals_free(void)
{
- struct Gwn_VertFormat **format = &g_formats.instance_screenspace;
+ struct GPUVertFormat **format = &g_formats.instance_screenspace;
for (int i = 0; i < sizeof(g_formats) / sizeof(void *); ++i, ++format) {
MEM_SAFE_FREE(*format);
}
@@ -299,7 +304,7 @@ DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float color[4
return grp;
}
-DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *geom, float *size)
+DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct GPUBatch *geom, float *size)
{
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR);
@@ -317,7 +322,7 @@ DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *g
return grp;
}
-DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct GPUBatch *geom)
{
static float light[3] = {0.0f, 0.0f, 1.0f};
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR);
@@ -333,7 +338,7 @@ DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct Gwn_Batch *geom)
return grp;
}
-DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct GPUBatch *geom)
{
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR);
@@ -347,7 +352,7 @@ DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct Gwn_Batch *geom)
return grp;
}
-DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct GPUBatch *geom)
{
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED);
@@ -363,7 +368,7 @@ DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch
return grp;
}
-DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct GPUBatch *geom)
{
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS);
@@ -379,7 +384,7 @@ DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *ge
return grp;
}
-DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct GPUBatch *geom)
{
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE);
@@ -394,7 +399,7 @@ DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom)
return grp;
}
-DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance(DRWPass *pass, struct GPUBatch *geom)
{
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE);
@@ -409,7 +414,7 @@ DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom)
return grp;
}
-DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct Gwn_Batch *geom, int *baseid)
+DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct GPUBatch *geom, int *baseid)
{
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE);
@@ -425,7 +430,7 @@ DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct Gwn_Batch *geom,
return grp;
}
-DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct GPUBatch *geom)
{
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_CAMERA);
@@ -442,7 +447,7 @@ DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom)
return grp;
}
-DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct GPUBatch *geom)
{
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_DISTANCE_LINES);
static float point_size = 4.0f;
@@ -460,7 +465,7 @@ DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch
return grp;
}
-DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct GPUBatch *geom)
{
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR);
static const int True = true;
@@ -595,7 +600,7 @@ DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass)
}
/* Only works with batches with adjacency infos. */
-DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct GPUBatch *geom)
{
if (g_shaders.shape_outline == NULL) {
g_shaders.shape_outline = DRW_shader_create(
@@ -618,7 +623,7 @@ DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_B
return grp;
}
-DRWShadingGroup *shgroup_instance_bone_shape_solid(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance_bone_shape_solid(DRWPass *pass, struct GPUBatch *geom)
{
if (g_shaders.shape_solid == NULL) {
g_shaders.shape_solid = DRW_shader_create(
@@ -736,6 +741,26 @@ struct GPUShader *mpath_points_shader_get(void)
return g_shaders.mpath_points_sh;
}
+struct GPUShader *volume_velocity_shader_get(bool use_needle)
+{
+ if (use_needle) {
+ if (g_shaders.volume_velocity_needle_sh == NULL) {
+ g_shaders.volume_velocity_needle_sh = DRW_shader_create(
+ datatoc_volume_velocity_vert_glsl, NULL,
+ datatoc_gpu_shader_flat_color_frag_glsl, "#define USE_NEEDLE");
+ }
+ return g_shaders.volume_velocity_needle_sh;
+ }
+ else {
+ if (g_shaders.volume_velocity_sh == NULL) {
+ g_shaders.volume_velocity_sh = DRW_shader_create(
+ datatoc_volume_velocity_vert_glsl, NULL,
+ datatoc_gpu_shader_flat_color_frag_glsl, NULL);
+ }
+ return g_shaders.volume_velocity_sh;
+ }
+}
+
/* ******************************************** COLOR UTILS *********************************************** */
/* TODO FINISH */
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index 6227130fb05..80b2ec8db71 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -28,7 +28,7 @@
struct DRWPass;
struct DRWShadingGroup;
-struct Gwn_Batch;
+struct GPUBatch;
struct GPUMaterial;
struct Object;
struct ViewLayer;
@@ -112,25 +112,25 @@ struct DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(struct DRWPass *pa
struct DRWShadingGroup *shgroup_dynpoints_uniform_color(struct DRWPass *pass, float color[4], float *size);
struct DRWShadingGroup *shgroup_groundlines_uniform_color(struct DRWPass *pass, float color[4]);
struct DRWShadingGroup *shgroup_groundpoints_uniform_color(struct DRWPass *pass, float color[4]);
-struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct Gwn_Batch *geom, float *size);
-struct DRWShadingGroup *shgroup_instance_solid(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_instance_wire(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct Gwn_Batch *geom, int *baseid);
-struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
+struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct GPUBatch *geom, float *size);
+struct DRWShadingGroup *shgroup_instance_solid(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_instance_wire(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct GPUBatch *geom, int *baseid);
+struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct GPUBatch *geom);
struct DRWShadingGroup *shgroup_instance_mball_handles(struct DRWPass *pass);
struct DRWShadingGroup *shgroup_instance_bone_axes(struct DRWPass *pass);
struct DRWShadingGroup *shgroup_instance_bone_envelope_distance(struct DRWPass *pass);
struct DRWShadingGroup *shgroup_instance_bone_envelope_outline(struct DRWPass *pass);
struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass);
-struct DRWShadingGroup *shgroup_instance_bone_shape_outline(struct DRWPass *pass, struct Gwn_Batch *geom);
-struct DRWShadingGroup *shgroup_instance_bone_shape_solid(struct DRWPass *pass, struct Gwn_Batch *geom);
+struct DRWShadingGroup *shgroup_instance_bone_shape_outline(struct DRWPass *pass, struct GPUBatch *geom);
+struct DRWShadingGroup *shgroup_instance_bone_shape_solid(struct DRWPass *pass, struct GPUBatch *geom);
struct DRWShadingGroup *shgroup_instance_bone_sphere_outline(struct DRWPass *pass);
struct DRWShadingGroup *shgroup_instance_bone_sphere_solid(struct DRWPass *pass);
struct DRWShadingGroup *shgroup_instance_bone_stick(struct DRWPass *pass);
@@ -138,6 +138,8 @@ struct DRWShadingGroup *shgroup_instance_bone_stick(struct DRWPass *pass);
struct GPUShader *mpath_line_shader_get(void);
struct GPUShader *mpath_points_shader_get(void);
+struct GPUShader *volume_velocity_shader_get(bool use_needle);
+
int DRW_object_wire_theme_get(
struct Object *ob, struct ViewLayer *view_layer, float **r_color);
float *DRW_color_background_blend_get(int theme_id);
diff --git a/source/blender/draw/intern/draw_debug.c b/source/blender/draw/intern/draw_debug.c
index 0e4176f90a6..8af13d66c28 100644
--- a/source/blender/draw/intern/draw_debug.c
+++ b/source/blender/draw/intern/draw_debug.c
@@ -29,6 +29,8 @@
#include "DNA_object_types.h"
+#include "BKE_object.h"
+
#include "BLI_link_utils.h"
#include "GPU_immediate.h"
@@ -105,6 +107,36 @@ void DRW_debug_bbox(const BoundBox *bbox, const float color[4])
DRW_debug_line_v3v3(bbox->vec[3], bbox->vec[7], color);
}
+void DRW_debug_m4_as_bbox(const float m[4][4], const float color[4], const bool invert)
+{
+ BoundBox bb;
+ const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f};
+ float minv[4][4];
+ if (invert) {
+ invert_m4_m4(minv, m);
+ }
+
+ BKE_boundbox_init_from_minmax(&bb, min, max);
+ for (int i = 0; i < 8; ++i) {
+ mul_project_m4_v3((invert) ? minv : m, bb.vec[i]);
+ }
+ DRW_debug_bbox(&bb, color);
+}
+
+void DRW_debug_sphere(const float center[3], const float radius, const float color[4])
+{
+ float size_mat[4][4];
+ DRWDebugSphere *sphere = MEM_mallocN(sizeof(DRWDebugSphere), "DRWDebugSphere");
+ /* Bake all transform into a Matrix4 */
+ scale_m4_fl(size_mat, radius);
+ copy_m4_m4(sphere->mat, g_modelmat);
+ translate_m4(sphere->mat, center[0], center[1], center[2]);
+ mul_m4_m4m4(sphere->mat, sphere->mat, size_mat);
+
+ copy_v4_v4(sphere->color, color);
+ BLI_LINKS_PREPEND(DST.debug.spheres, sphere);
+}
+
/* --------- Render --------- */
static void drw_debug_draw_lines(void)
@@ -115,13 +147,13 @@ static void drw_debug_draw_lines(void)
return;
}
- Gwn_VertFormat *vert_format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- uint col = GWN_vertformat_attr_add(vert_format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat *vert_format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(vert_format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, count * 2);
+ immBegin(GPU_PRIM_LINES, count * 2);
while (DST.debug.lines) {
void *next = DST.debug.lines->next;
@@ -140,9 +172,51 @@ static void drw_debug_draw_lines(void)
immUnbindProgram();
}
+static void drw_debug_draw_spheres(void)
+{
+ int count = BLI_linklist_count((LinkNode *)DST.debug.spheres);
+
+ if (count == 0) {
+ return;
+ }
+
+ float one = 1.0f;
+ GPUVertFormat vert_format = {0};
+ uint mat = GPU_vertformat_attr_add(&vert_format, "InstanceModelMatrix", GPU_COMP_F32, 16, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(&vert_format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ uint siz = GPU_vertformat_attr_add(&vert_format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+
+ GPUVertBuf *inst_vbo = GPU_vertbuf_create_with_format(&vert_format);
+
+ GPU_vertbuf_data_alloc(inst_vbo, count);
+
+ int v = 0;
+ while (DST.debug.spheres) {
+ void *next = DST.debug.spheres->next;
+
+ GPU_vertbuf_attr_set(inst_vbo, mat, v, DST.debug.spheres->mat[0]);
+ GPU_vertbuf_attr_set(inst_vbo, col, v, DST.debug.spheres->color);
+ GPU_vertbuf_attr_set(inst_vbo, siz, v, &one);
+ v++;
+
+ MEM_freeN(DST.debug.spheres);
+ DST.debug.spheres = next;
+ }
+
+ GPUBatch *empty_sphere = DRW_cache_empty_sphere_get();
+
+ GPUBatch *draw_batch = GPU_batch_create(GPU_PRIM_LINES, empty_sphere->verts[0], NULL);
+ GPU_batch_instbuf_set(draw_batch, inst_vbo, true);
+ GPU_batch_program_set_builtin(draw_batch, GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE);
+
+ GPU_batch_draw(draw_batch);
+ GPU_batch_discard(draw_batch);
+}
+
void drw_debug_draw(void)
{
drw_debug_draw_lines();
+ drw_debug_draw_spheres();
}
void drw_debug_init(void)
diff --git a/source/blender/draw/intern/draw_debug.h b/source/blender/draw/intern/draw_debug.h
index 1dab431fc88..319d2674279 100644
--- a/source/blender/draw/intern/draw_debug.h
+++ b/source/blender/draw/intern/draw_debug.h
@@ -34,6 +34,8 @@ void DRW_debug_modelmat(const float modelmat[4][4]);
void DRW_debug_line_v3v3(const float v1[3], const float v2[3], const float color[4]);
void DRW_debug_polygon_v3(const float (*v)[3], const int vert_len, const float color[4]);
void DRW_debug_m4(const float m[4][4]);
+void DRW_debug_m4_as_bbox(const float m[4][4], const float color[4], const bool invert);
void DRW_debug_bbox(const BoundBox *bbox, const float color[4]);
+void DRW_debug_sphere(const float center[3], const float radius, const float color[4]);
#endif /* __DRAW_DEBUG_H__ */
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
index 8320ae55179..6ede573199f 100644
--- a/source/blender/draw/intern/draw_hair.c
+++ b/source/blender/draw/intern/draw_hair.c
@@ -137,14 +137,14 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(
/* Transform Feedback subdiv. */
if (need_ft_update) {
- int final_points_ct = hair_cache->final[subdiv].strands_res * hair_cache->strands_count;
+ int final_points_len = hair_cache->final[subdiv].strands_res * hair_cache->strands_len;
GPUShader *tf_shader = hair_refine_shader_get(PART_REFINE_CATMULL_ROM);
DRWShadingGroup *tf_shgrp = DRW_shgroup_transform_feedback_create(tf_shader, g_tf_pass,
hair_cache->final[subdiv].proc_buf);
DRW_shgroup_uniform_texture(tf_shgrp, "hairPointBuffer", hair_cache->point_tex);
DRW_shgroup_uniform_texture(tf_shgrp, "hairStrandBuffer", hair_cache->strand_tex);
DRW_shgroup_uniform_int(tf_shgrp, "hairStrandsRes", &hair_cache->final[subdiv].strands_res, 1);
- DRW_shgroup_call_procedural_points_add(tf_shgrp, final_points_ct, NULL);
+ DRW_shgroup_call_procedural_points_add(tf_shgrp, final_points_len, NULL);
}
return shgrp;
diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h
index 2e6c9a0d3c1..41f91e02459 100644
--- a/source/blender/draw/intern/draw_hair_private.h
+++ b/source/blender/draw/intern/draw_hair_private.h
@@ -31,7 +31,7 @@
#define __DRAW_HAIR_PRIVATE_H__
#define MAX_LAYER_NAME_CT 3 /* u0123456789, u, a0123456789 */
-#define MAX_LAYER_NAME_LEN DECIMAL_DIGITS_BOUND(unsigned int) + 2
+#define MAX_LAYER_NAME_LEN DECIMAL_DIGITS_BOUND(uint) + 2
#define MAX_THICKRES 2 /* see eHairType */
#define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */
@@ -42,32 +42,32 @@ struct ParticleHairCache;
typedef struct ParticleHairFinalCache {
/* Output of the subdivision stage: vertex buff sized to subdiv level. */
- Gwn_VertBuf *proc_buf;
+ GPUVertBuf *proc_buf;
GPUTexture *proc_tex;
/* Just contains a huge index buffer used to draw the final hair. */
- Gwn_Batch *proc_hairs[MAX_THICKRES];
+ GPUBatch *proc_hairs[MAX_THICKRES];
int strands_res; /* points per hair, at least 2 */
} ParticleHairFinalCache;
typedef struct ParticleHairCache {
- Gwn_VertBuf *pos;
- Gwn_IndexBuf *indices;
- Gwn_Batch *hairs;
+ GPUVertBuf *pos;
+ GPUIndexBuf *indices;
+ GPUBatch *hairs;
/* Hair Procedural display: Interpolation is done on the GPU. */
- Gwn_VertBuf *proc_point_buf; /* Input control points */
+ GPUVertBuf *proc_point_buf; /* Input control points */
GPUTexture *point_tex;
- Gwn_VertBuf *proc_strand_buf; /* Infos of control points strands (segment count and base index) */
+ GPUVertBuf *proc_strand_buf; /* Infos of control points strands (segment count and base index) */
GPUTexture *strand_tex;
- Gwn_VertBuf *proc_uv_buf[MAX_MTFACE];
+ GPUVertBuf *proc_uv_buf[MAX_MTFACE];
GPUTexture *uv_tex[MAX_MTFACE];
char uv_layer_names[MAX_MTFACE][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN];
- Gwn_VertBuf *proc_col_buf[MAX_MCOL];
+ GPUVertBuf *proc_col_buf[MAX_MCOL];
GPUTexture *col_tex[MAX_MCOL];
char col_layer_names[MAX_MCOL][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN];
@@ -76,9 +76,9 @@ typedef struct ParticleHairCache {
ParticleHairFinalCache final[MAX_HAIR_SUBDIV];
- int strands_count;
- int elems_count;
- int point_count;
+ int strands_len;
+ int elems_len;
+ int point_len;
} ParticleHairCache;
bool particles_ensure_procedural_data(
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 3e4f812af27..89cffd6c19c 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -45,17 +45,17 @@
typedef struct DRWBatchingBuffer {
struct DRWShadingGroup *shgroup; /* Link back to the owning shGroup. Also tells if it's used */
- Gwn_VertFormat *format; /* Identifier. */
- Gwn_VertBuf *vert; /* Gwn_VertBuf contained in the Gwn_Batch. */
- Gwn_Batch *batch; /* Gwn_Batch containing the Gwn_VertBuf. */
+ GPUVertFormat *format; /* Identifier. */
+ GPUVertBuf *vert; /* GPUVertBuf contained in the GPUBatch. */
+ GPUBatch *batch; /* GPUBatch containing the GPUVertBuf. */
} DRWBatchingBuffer;
typedef struct DRWInstancingBuffer {
struct DRWShadingGroup *shgroup; /* Link back to the owning shGroup. Also tells if it's used */
- Gwn_VertFormat *format; /* Identifier. */
- Gwn_Batch *instance; /* Identifier. */
- Gwn_VertBuf *vert; /* Gwn_VertBuf contained in the Gwn_Batch. */
- Gwn_Batch *batch; /* Gwn_Batch containing the Gwn_VertBuf. */
+ GPUVertFormat *format; /* Identifier. */
+ GPUBatch *instance; /* Identifier. */
+ GPUVertBuf *vert; /* GPUVertBuf contained in the GPUBatch. */
+ GPUBatch *batch; /* GPUBatch containing the GPUVertBuf. */
} DRWInstancingBuffer;
typedef struct DRWInstanceChunk {
@@ -100,7 +100,7 @@ static ListBase g_idatalists = {NULL, NULL};
* that would be too slow]).
**/
-static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data))
+static void instance_batch_free(GPUBatch *batch, void *UNUSED(user_data))
{
/* Free all batches that have the same key before they are reused. */
/* TODO: Make it thread safe! Batch freeing can happen from another thread. */
@@ -111,8 +111,8 @@ static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data))
for (int i = 0; i < idatalist->instancing.alloc_size; i++, ibuf++) {
if (ibuf->instance == batch) {
BLI_assert(ibuf->shgroup == NULL); /* Make sure it has no other users. */
- GWN_VERTBUF_DISCARD_SAFE(ibuf->vert);
- GWN_BATCH_DISCARD_SAFE(ibuf->batch);
+ GPU_VERTBUF_DISCARD_SAFE(ibuf->vert);
+ GPU_BATCH_DISCARD_SAFE(ibuf->batch);
/* Tag as non alloced. */
ibuf->format = NULL;
}
@@ -121,8 +121,8 @@ static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data))
}
void DRW_batching_buffer_request(
- DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_PrimType type, struct DRWShadingGroup *shgroup,
- Gwn_Batch **r_batch, Gwn_VertBuf **r_vert)
+ DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUPrimType type, struct DRWShadingGroup *shgroup,
+ GPUBatch **r_batch, GPUVertBuf **r_vert)
{
DRWInstanceChunk *chunk = &idatalist->batching;
DRWBatchingBuffer *bbuf = idatalist->batching.bbufs;
@@ -152,16 +152,16 @@ void DRW_batching_buffer_request(
}
/* Create the batch. */
bbuf = chunk->bbufs + new_id;
- bbuf->vert = *r_vert = GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_DYNAMIC);
- bbuf->batch = *r_batch = GWN_batch_create_ex(type, bbuf->vert, NULL, 0);
+ bbuf->vert = *r_vert = GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_DYNAMIC);
+ bbuf->batch = *r_batch = GPU_batch_create_ex(type, bbuf->vert, NULL, 0);
bbuf->format = format;
bbuf->shgroup = shgroup;
- GWN_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK);
+ GPU_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK);
}
void DRW_instancing_buffer_request(
- DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_Batch *instance, struct DRWShadingGroup *shgroup,
- Gwn_Batch **r_batch, Gwn_VertBuf **r_vert)
+ DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUBatch *instance, struct DRWShadingGroup *shgroup,
+ GPUBatch **r_batch, GPUVertBuf **r_vert)
{
DRWInstanceChunk *chunk = &idatalist->instancing;
DRWInstancingBuffer *ibuf = idatalist->instancing.ibufs;
@@ -193,15 +193,15 @@ void DRW_instancing_buffer_request(
}
/* Create the batch. */
ibuf = chunk->ibufs + new_id;
- ibuf->vert = *r_vert = GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_DYNAMIC);
- ibuf->batch = *r_batch = GWN_batch_duplicate(instance);
+ ibuf->vert = *r_vert = GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_DYNAMIC);
+ ibuf->batch = *r_batch = GPU_batch_duplicate(instance);
ibuf->format = format;
ibuf->shgroup = shgroup;
ibuf->instance = instance;
- GWN_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK);
- GWN_batch_instbuf_set(ibuf->batch, ibuf->vert, false);
+ GPU_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK);
+ GPU_batch_instbuf_set(ibuf->batch, ibuf->vert, false);
/* Make sure to free this ibuf if the instance batch gets free. */
- GWN_batch_callback_free_set(instance, &instance_batch_free, NULL);
+ GPU_batch_callback_free_set(instance, &instance_batch_free, NULL);
}
void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
@@ -213,19 +213,19 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
for (int i = 0; i < batching->alloc_size; i++, bbuf++) {
if (bbuf->shgroup != NULL) {
realloc_size = i + 1;
- uint vert_ct = DRW_shgroup_get_instance_count(bbuf->shgroup);
- vert_ct += (vert_ct == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */
- if (vert_ct + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_ct) {
- uint size = vert_ct + BUFFER_VERTS_CHUNK - 1;
+ uint vert_len = DRW_shgroup_get_instance_count(bbuf->shgroup);
+ vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */
+ if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_len) {
+ uint size = vert_len + BUFFER_VERTS_CHUNK - 1;
size = size - size % BUFFER_VERTS_CHUNK;
- GWN_vertbuf_data_resize(bbuf->vert, size);
+ GPU_vertbuf_data_resize(bbuf->vert, size);
}
- GWN_vertbuf_use(bbuf->vert); /* Send data. */
+ GPU_vertbuf_use(bbuf->vert); /* Send data. */
bbuf->shgroup = NULL; /* Set as non used for the next round. */
}
else {
- GWN_VERTBUF_DISCARD_SAFE(bbuf->vert);
- GWN_BATCH_DISCARD_SAFE(bbuf->batch);
+ GPU_VERTBUF_DISCARD_SAFE(bbuf->vert);
+ GPU_BATCH_DISCARD_SAFE(bbuf->batch);
bbuf->format = NULL; /* Tag as non alloced. */
}
}
@@ -245,19 +245,19 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
for (int i = 0; i < instancing->alloc_size; i++, ibuf++) {
if (ibuf->shgroup != NULL) {
realloc_size = i + 1;
- uint vert_ct = DRW_shgroup_get_instance_count(ibuf->shgroup);
- vert_ct += (vert_ct == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */
- if (vert_ct + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_ct) {
- uint size = vert_ct + BUFFER_VERTS_CHUNK - 1;
+ uint vert_len = DRW_shgroup_get_instance_count(ibuf->shgroup);
+ vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */
+ if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_len) {
+ uint size = vert_len + BUFFER_VERTS_CHUNK - 1;
size = size - size % BUFFER_VERTS_CHUNK;
- GWN_vertbuf_data_resize(ibuf->vert, size);
+ GPU_vertbuf_data_resize(ibuf->vert, size);
}
- GWN_vertbuf_use(ibuf->vert); /* Send data. */
+ GPU_vertbuf_use(ibuf->vert); /* Send data. */
ibuf->shgroup = NULL; /* Set as non used for the next round. */
}
else {
- GWN_VERTBUF_DISCARD_SAFE(ibuf->vert);
- GWN_BATCH_DISCARD_SAFE(ibuf->batch);
+ GPU_VERTBUF_DISCARD_SAFE(ibuf->vert);
+ GPU_BATCH_DISCARD_SAFE(ibuf->batch);
ibuf->format = NULL; /* Tag as non alloced. */
}
}
@@ -366,15 +366,15 @@ void DRW_instance_data_list_free(DRWInstanceDataList *idatalist)
DRWBatchingBuffer *bbuf = idatalist->batching.bbufs;
for (int i = 0; i < idatalist->batching.alloc_size; i++, bbuf++) {
- GWN_VERTBUF_DISCARD_SAFE(bbuf->vert);
- GWN_BATCH_DISCARD_SAFE(bbuf->batch);
+ GPU_VERTBUF_DISCARD_SAFE(bbuf->vert);
+ GPU_BATCH_DISCARD_SAFE(bbuf->batch);
}
MEM_freeN(idatalist->batching.bbufs);
DRWInstancingBuffer *ibuf = idatalist->instancing.ibufs;
for (int i = 0; i < idatalist->instancing.alloc_size; i++, ibuf++) {
- GWN_VERTBUF_DISCARD_SAFE(ibuf->vert);
- GWN_BATCH_DISCARD_SAFE(ibuf->batch);
+ GPU_VERTBUF_DISCARD_SAFE(ibuf->vert);
+ GPU_BATCH_DISCARD_SAFE(ibuf->batch);
}
MEM_freeN(idatalist->instancing.ibufs);
diff --git a/source/blender/draw/intern/draw_instance_data.h b/source/blender/draw/intern/draw_instance_data.h
index 0ea40a50a6b..174f03e3bc7 100644
--- a/source/blender/draw/intern/draw_instance_data.h
+++ b/source/blender/draw/intern/draw_instance_data.h
@@ -43,11 +43,11 @@ DRWInstanceData *DRW_instance_data_request(
DRWInstanceDataList *idatalist, uint attrib_size);
void DRW_batching_buffer_request(
- DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_PrimType type, struct DRWShadingGroup *shgroup,
- Gwn_Batch **r_batch, Gwn_VertBuf **r_vert);
+ DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUPrimType type, struct DRWShadingGroup *shgroup,
+ GPUBatch **r_batch, GPUVertBuf **r_vert);
void DRW_instancing_buffer_request(
- DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_Batch *instance, struct DRWShadingGroup *shgroup,
- Gwn_Batch **r_batch, Gwn_VertBuf **r_vert);
+ DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUBatch *instance, struct DRWShadingGroup *shgroup,
+ GPUBatch **r_batch, GPUVertBuf **r_vert);
/* Upload all instance data to the GPU as soon as possible. */
void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 504e53fd206..cc4f8ec7947 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -44,6 +44,7 @@
#include "DNA_camera_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_world_types.h"
#include "ED_space_api.h"
#include "ED_screen.h"
@@ -81,7 +82,7 @@
#include "engines/workbench/workbench_engine.h"
#include "engines/external/external_engine.h"
-#include "../../../intern/gawain/gawain/gwn_context.h"
+#include "GPU_context.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -119,16 +120,16 @@ void DRW_draw_callbacks_pre_scene(void)
{
RegionView3D *rv3d = DST.draw_ctx.rv3d;
- gpuLoadProjectionMatrix(rv3d->winmat);
- gpuLoadMatrix(rv3d->viewmat);
+ GPU_matrix_projection_set(rv3d->winmat);
+ GPU_matrix_set(rv3d->viewmat);
}
void DRW_draw_callbacks_post_scene(void)
{
RegionView3D *rv3d = DST.draw_ctx.rv3d;
- gpuLoadProjectionMatrix(rv3d->winmat);
- gpuLoadMatrix(rv3d->viewmat);
+ GPU_matrix_projection_set(rv3d->winmat);
+ GPU_matrix_set(rv3d->viewmat);
}
struct DRWTextStore *DRW_text_cache_ensure(void)
@@ -227,9 +228,9 @@ void DRW_transform_to_display(GPUTexture *tex)
{
drw_state_set(DRW_STATE_WRITE_COLOR);
- Gwn_VertFormat *vert_format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- uint texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *vert_format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
const float dither = 1.0f;
@@ -261,7 +262,7 @@ void DRW_transform_to_display(GPUTexture *tex)
immUniformMatrix4fv("ModelViewProjectionMatrix", mat);
/* Full screen triangle */
- immBegin(GWN_PRIM_TRIS, 3);
+ immBegin(GPU_PRIM_TRIS, 3);
immAttrib2f(texco, 0.0f, 0.0f);
immVertex2f(pos, -1.0f, -1.0f);
@@ -282,6 +283,29 @@ void DRW_transform_to_display(GPUTexture *tex)
}
}
+/* Draw texture to framebuffer without any color transforms */
+void DRW_transform_none(GPUTexture *tex)
+{
+ /* Draw as texture for final render (without immediate mode). */
+ GPUBatch *geom = DRW_cache_fullscreen_quad_get();
+ GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR);
+
+ GPU_texture_bind(tex, 0);
+
+ const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ GPU_batch_uniform_4fv(geom, "color", white);
+
+ float mat[4][4];
+ unit_m4(mat);
+ GPU_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat);
+
+ GPU_batch_program_use_begin(geom);
+ GPU_batch_draw_range_ex(geom, 0, 0, false);
+ GPU_batch_program_use_end(geom);
+
+ GPU_texture_unbind(tex);
+}
+
/** \} */
@@ -303,7 +327,7 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color)
BLI_assert(samples > 0);
BLI_assert(GPU_texture_samples(src_color) == samples);
- Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ GPUBatch *geom = DRW_cache_fullscreen_quad_get();
int builtin;
switch (samples) {
@@ -317,21 +341,21 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color)
break;
}
- GWN_batch_program_set_builtin(geom, builtin);
+ GPU_batch_program_set_builtin(geom, builtin);
GPU_texture_bind(src_depth, 0);
GPU_texture_bind(src_color, 1);
- GWN_batch_uniform_1i(geom, "depthMulti", 0);
- GWN_batch_uniform_1i(geom, "colorMulti", 1);
+ GPU_batch_uniform_1i(geom, "depthMulti", 0);
+ GPU_batch_uniform_1i(geom, "colorMulti", 1);
float mat[4][4];
unit_m4(mat);
- GWN_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat);
+ GPU_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat);
/* avoid gpuMatrix calls */
- GWN_batch_program_use_begin(geom);
- GWN_batch_draw_range_ex(geom, 0, 0, false);
- GWN_batch_program_use_end(geom);
+ GPU_batch_program_use_begin(geom);
+ GPU_batch_draw_range_ex(geom, 0, 0, false);
+ GPU_batch_program_use_end(geom);
}
/** \} */
@@ -696,34 +720,96 @@ void **DRW_view_layer_engine_data_ensure(DrawEngineType *engine_type, void (*cal
/* -------------------------------------------------------------------- */
-/** \name Objects (DRW_object)
+/** \name Draw Data (DRW_drawdata)
* \{ */
-ObjectEngineData *DRW_object_engine_data_get(Object *ob, DrawEngineType *engine_type)
+/* Used for DRW_drawdata_from_id()
+ * All ID-datablocks which have their own 'local' DrawData
+ * should have the same arrangement in their structs.
+ */
+typedef struct IdDdtTemplate {
+ ID id;
+ struct AnimData *adt;
+ DrawDataList drawdata;
+} IdDdtTemplate;
+
+/* Check if ID can have AnimData */
+static bool id_type_can_have_drawdata(const short id_type)
+{
+ /* Only some ID-blocks have this info for now */
+ /* TODO: finish adding this for the other blocktypes */
+ switch (id_type) {
+ /* has DrawData */
+ case ID_OB:
+ case ID_WO:
+ return true;
+
+ /* no DrawData */
+ default:
+ return false;
+ }
+}
+
+static bool id_can_have_drawdata(const ID *id)
+{
+ /* sanity check */
+ if (id == NULL)
+ return false;
+
+ return id_type_can_have_drawdata(GS(id->name));
+}
+
+/* Get DrawData from the given ID-block. In order for this to work, we assume that
+ * the DrawData pointer is stored in the struct in the same fashion as in IdDdtTemplate.
+ */
+DrawDataList *DRW_drawdatalist_from_id(ID *id)
{
- for (ObjectEngineData *oed = ob->drawdata.first; oed; oed = oed->next) {
- if (oed->engine_type == engine_type) {
- return oed;
+ /* only some ID-blocks have this info for now, so we cast the
+ * types that do to be of type IdDdtTemplate, and extract the
+ * DrawData that way
+ */
+ if (id_can_have_drawdata(id)) {
+ IdDdtTemplate *idt = (IdDdtTemplate *)id;
+ return &idt->drawdata;
+ }
+ else
+ return NULL;
+}
+
+DrawData *DRW_drawdata_get(ID *id, DrawEngineType *engine_type)
+{
+ DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
+
+ if (drawdata == NULL)
+ return NULL;
+
+ LISTBASE_FOREACH(DrawData *, dd, drawdata) {
+ if (dd->engine_type == engine_type) {
+ return dd;
}
}
return NULL;
}
-ObjectEngineData *DRW_object_engine_data_ensure(
- Object *ob,
+DrawData *DRW_drawdata_ensure(
+ ID *id,
DrawEngineType *engine_type,
size_t size,
- ObjectEngineDataInitCb init_cb,
- ObjectEngineDataFreeCb free_cb)
+ DrawDataInitCb init_cb,
+ DrawDataFreeCb free_cb)
{
- BLI_assert(size >= sizeof(ObjectEngineData));
+ BLI_assert(size >= sizeof(DrawData));
+ BLI_assert(id_can_have_drawdata(id));
/* Try to re-use existing data. */
- ObjectEngineData *oed = DRW_object_engine_data_get(ob, engine_type);
- if (oed != NULL) {
- return oed;
+ DrawData *dd = DRW_drawdata_get(id, engine_type);
+ if (dd != NULL) {
+ return dd;
}
+
+ DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
+
/* Allocate new data. */
- if ((ob->base_flag & BASE_FROMDUPLI) != 0) {
+ if ((GS(id->name) == ID_OB) && (((Object *)id)->base_flag & BASE_FROMDUPLI) != 0) {
/* NOTE: data is not persistent in this case. It is reset each redraw. */
BLI_assert(free_cb == NULL); /* No callback allowed. */
/* Round to sizeof(float) for DRW_instance_data_request(). */
@@ -734,21 +820,37 @@ ObjectEngineData *DRW_object_engine_data_ensure(
if (DST.object_instance_data[fsize] == NULL) {
DST.object_instance_data[fsize] = DRW_instance_data_request(DST.idatalist, fsize);
}
- oed = (ObjectEngineData *)DRW_instance_data_next(DST.object_instance_data[fsize]);
- memset(oed, 0, size);
+ dd = (DrawData *)DRW_instance_data_next(DST.object_instance_data[fsize]);
+ memset(dd, 0, size);
}
else {
- oed = MEM_callocN(size, "ObjectEngineData");
+ dd = MEM_callocN(size, "DrawData");
}
- oed->engine_type = engine_type;
- oed->free = free_cb;
+ dd->engine_type = engine_type;
+ dd->free = free_cb;
/* Perform user-side initialization, if needed. */
if (init_cb != NULL) {
- init_cb(oed);
+ init_cb(dd);
}
/* Register in the list. */
- BLI_addtail(&ob->drawdata, oed);
- return oed;
+ BLI_addtail((ListBase *)drawdata, dd);
+ return dd;
+}
+
+void DRW_drawdata_free(ID *id)
+{
+ DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
+
+ if (drawdata == NULL)
+ return;
+
+ LISTBASE_FOREACH(DrawData *, dd, drawdata) {
+ if (dd->free != NULL) {
+ dd->free(dd);
+ }
+ }
+
+ BLI_freelistN((ListBase *)drawdata);
}
/** \} */
@@ -794,6 +896,22 @@ static void drw_engines_cache_init(void)
}
}
+static void drw_engines_world_update(Scene *scene)
+{
+ if (scene->world == NULL) {
+ return;
+ }
+
+ for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ DrawEngineType *engine = link->data;
+ ViewportEngineData *data = drw_viewport_engine_data_ensure(engine);
+
+ if (engine->id_update) {
+ engine->id_update(data, &scene->world->id);
+ }
+ }
+}
+
static void drw_engines_cache_populate(Object *ob)
{
DST.ob_state = NULL;
@@ -877,7 +995,7 @@ static void drw_engines_draw_text(void)
PROFILE_START(stime);
if (data->text_draw_cache) {
- DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.v3d, DST.draw_ctx.ar, false);
+ DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.ar);
}
PROFILE_END_UPDATE(data->render_time, stime);
@@ -1105,7 +1223,7 @@ static void drw_engines_enable(ViewLayer *view_layer, RenderEngineType *engine_t
Object *obact = OBACT(view_layer);
const int mode = CTX_data_mode_enum_ex(DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode);
View3D * v3d = DST.draw_ctx.v3d;
- const int drawtype = v3d->drawtype;
+ const int drawtype = v3d->shading.type;
drw_engines_enable_from_engine(engine_type, drawtype, v3d->shading.flag);
@@ -1161,7 +1279,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
/* XXX Really nasty locking. But else this could
* be executed by the material previews thread
* while rendering a viewport. */
- BLI_mutex_lock(&DST.gl_context_mutex);
+ BLI_ticket_mutex_lock(DST.gl_context_mutex);
/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
@@ -1189,7 +1307,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
drw_engines_disable();
- BLI_mutex_unlock(&DST.gl_context_mutex);
+ BLI_ticket_mutex_unlock(DST.gl_context_mutex);
}
}
@@ -1209,7 +1327,7 @@ void DRW_draw_view(const bContext *C)
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
GPUViewport *viewport = WM_draw_region_get_bound_viewport(ar);
/* Reset before using it. */
@@ -1237,9 +1355,7 @@ void DRW_draw_render_loop_ex(
RegionView3D *rv3d = ar->regiondata;
DST.draw_ctx.evil_C = evil_C;
-
DST.viewport = viewport;
- v3d->zbuf = true;
/* Setup viewport */
GPU_viewport_engines_data_validate(DST.viewport, DRW_engines_get_hash());
@@ -1275,10 +1391,14 @@ void DRW_draw_render_loop_ex(
{
PROFILE_START(stime);
drw_engines_cache_init();
+ drw_engines_world_update(scene);
+ const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
{
- drw_engines_cache_populate(ob);
+ if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
+ drw_engines_cache_populate(ob);
+ }
}
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
@@ -1341,12 +1461,12 @@ void DRW_draw_render_loop_ex(
glEnable(GL_DEPTH_TEST);
if (DST.draw_ctx.evil_C) {
- /* needed so manipulator isn't obscured */
+ /* needed so gizmo isn't obscured */
if (((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
- ((v3d->twflag & V3D_MANIPULATOR_DRAW) != 0))
+ ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0))
{
glDisable(GL_DEPTH_TEST);
- DRW_draw_manipulator_3d();
+ DRW_draw_gizmo_3d();
}
DRW_draw_region_info();
@@ -1354,7 +1474,7 @@ void DRW_draw_render_loop_ex(
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
/* Draw 2D after region info so we can draw on top of the camera passepartout overlay.
* 'DRW_draw_region_info' sets the projection in pixel-space. */
- DRW_draw_manipulator_2d();
+ DRW_draw_gizmo_2d();
glEnable(GL_DEPTH_TEST);
}
}
@@ -1402,7 +1522,7 @@ void DRW_draw_render_loop(
drw_state_prepare_clean_for_draw(&DST);
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, viewport, NULL);
}
@@ -1453,18 +1573,14 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
}
void *re_gl_context = RE_gl_context_get(render);
- void *re_gwn_context = NULL;
+ void *re_gpu_context = NULL;
/* Changing Context */
if (re_gl_context != NULL) {
- /* TODO get rid of the blocking. Only here because of the static global DST. */
- BLI_mutex_lock(&DST.gl_context_mutex);
- WM_opengl_context_activate(re_gl_context);
- re_gwn_context = RE_gwn_context_get(render);
- if (GWN_context_active_get() == NULL) {
- GWN_context_active_set(re_gwn_context);
- }
- DRW_shape_cache_reset(); /* XXX fix that too. */
+ DRW_opengl_render_context_enable(re_gl_context);
+ /* We need to query gpu context after a gl context has been bound. */
+ re_gpu_context = RE_gpu_context_get(render);
+ DRW_gawain_render_context_enable(re_gpu_context);
}
else {
DRW_opengl_context_enable();
@@ -1543,12 +1659,8 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
/* Changing Context */
if (re_gl_context != NULL) {
- DRW_shape_cache_reset(); /* XXX fix that too. */
- glFlush();
- GWN_context_active_set(NULL);
- WM_opengl_context_release(re_gl_context);
- /* TODO get rid of the blocking. */
- BLI_mutex_unlock(&DST.gl_context_mutex);
+ DRW_gawain_render_context_disable(re_gpu_context);
+ DRW_opengl_render_context_disable(re_gl_context);
}
else {
DRW_opengl_context_disable();
@@ -1559,16 +1671,71 @@ void DRW_render_object_iter(
void *vedata, RenderEngine *engine, struct Depsgraph *depsgraph,
void (*callback)(void *vedata, Object *ob, RenderEngine *engine, struct Depsgraph *depsgraph))
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+
DRW_hair_init();
+ const int object_type_exclude_viewport = draw_ctx->v3d ? draw_ctx->v3d->object_type_exclude_viewport : 0;
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
{
- DST.ob_state = NULL;
- callback(vedata, ob, engine, depsgraph);
+ if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
+ DST.ob_state = NULL;
+ callback(vedata, ob, engine, depsgraph);
+ }
}
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END
}
+/* Assume a valid gl context is bound (and that the gl_context_mutex has been aquired).
+ * This function only setup DST and execute the given function.
+ * Warning: similar to DRW_render_to_image you cannot use default lists (dfbl & dtxl). */
+void DRW_custom_pipeline(
+ DrawEngineType *draw_engine_type,
+ struct Depsgraph *depsgraph,
+ void (*callback)(void *vedata, void *user_data),
+ void *user_data)
+{
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
+
+ /* Reset before using it. */
+ drw_state_prepare_clean_for_draw(&DST);
+ DST.options.is_image_render = true;
+ DST.options.is_scene_render = true;
+ DST.options.draw_background = false;
+
+ DST.draw_ctx = (DRWContextState){
+ .scene = scene,
+ .view_layer = view_layer,
+ .engine_type = NULL,
+ .depsgraph = depsgraph,
+ .object_mode = OB_MODE_OBJECT,
+ };
+ drw_context_state_init();
+
+ DST.viewport = GPU_viewport_create();
+ const int size[2] = {1, 1};
+ GPU_viewport_size_set(DST.viewport, size);
+
+ drw_viewport_var_init();
+
+ DRW_hair_init();
+
+ ViewportEngineData *data = drw_viewport_engine_data_ensure(draw_engine_type);
+
+ /* Execute the callback */
+ callback(data, user_data);
+ DST.buffer_finish_called = false;
+
+ GPU_viewport_free(DST.viewport);
+ GPU_framebuffer_restore();
+
+#ifdef DEBUG
+ /* Avoid accidental reuse. */
+ drw_state_ensure_not_reused(&DST);
+#endif
+}
+
static struct DRWSelectBuffer {
struct GPUFrameBuffer *framebuffer;
struct GPUTexture *texture_depth;
@@ -1620,7 +1787,7 @@ void DRW_draw_select_loop(
DRW_ObjectFilterFn object_filter_fn, void *object_filter_user_data)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
Object *obact = OBACT(view_layer);
Object *obedit = OBEDIT_FROM_OBACT(obact);
@@ -1644,7 +1811,7 @@ void DRW_draw_select_loop(
obedit_mode = CTX_MODE_EDIT_ARMATURE;
}
}
- if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECTION) {
+ if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT) {
if (!(v3d->flag2 & V3D_RENDER_OVERRIDE)) {
Object *obpose = OBPOSE_FROM_OBACT(obact);
if (obpose) {
@@ -1658,8 +1825,6 @@ void DRW_draw_select_loop(
GPU_viewport_size_set(viewport, (const int[2]){BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)});
DST.viewport = viewport;
- v3d->zbuf = true;
-
DST.options.is_select = true;
/* Get list of enabled engines */
@@ -1693,6 +1858,7 @@ void DRW_draw_select_loop(
{
drw_engines_cache_init();
+ drw_engines_world_update(scene);
if (use_obedit) {
#if 0
@@ -1705,6 +1871,9 @@ void DRW_draw_select_loop(
#endif
}
else {
+ const int object_type_exclude_select = (
+ v3d->object_type_exclude_viewport | v3d->object_type_exclude_select
+ );
bool filter_exclude = false;
DEG_OBJECT_ITER_BEGIN(
depsgraph, ob,
@@ -1712,8 +1881,9 @@ void DRW_draw_select_loop(
DEG_ITER_OBJECT_FLAG_VISIBLE |
DEG_ITER_OBJECT_FLAG_DUPLI)
{
- if ((ob->base_flag & BASE_SELECTABLE) != 0) {
-
+ if ((ob->base_flag & BASE_SELECTABLE) &&
+ (object_type_exclude_select & (1 << ob->type)) == 0)
+ {
if (object_filter_fn != NULL) {
if (ob->base_flag & BASE_FROMDUPLI) {
/* pass (use previous filter_exclude value) */
@@ -1797,9 +1967,9 @@ static void draw_depth_texture_to_screen(GPUTexture *texture)
const float w = (float)GPU_texture_width(texture);
const float h = (float)GPU_texture_height(texture);
- Gwn_VertFormat *format = immVertexFormat();
- uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_IMAGE_DEPTH_COPY);
@@ -1807,7 +1977,7 @@ static void draw_depth_texture_to_screen(GPUTexture *texture)
immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
- immBegin(GWN_PRIM_TRI_STRIP, 4);
+ immBegin(GPU_PRIM_TRI_STRIP, 4);
immAttrib2f(texcoord, 0.0f, 0.0f);
immVertex2f(pos, 0.0f, 0.0f);
@@ -1836,7 +2006,7 @@ void DRW_draw_depth_loop(
ARegion *ar, View3D *v3d)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
RegionView3D *rv3d = ar->regiondata;
@@ -1853,10 +2023,7 @@ void DRW_draw_depth_loop(
GPU_framebuffer_bind(g_select_buffer.framebuffer);
GPU_framebuffer_clear_depth(g_select_buffer.framebuffer, 1.0f);
- bool cache_is_dirty;
DST.viewport = viewport;
- v3d->zbuf = true;
-
DST.options.is_depth = true;
/* Get list of enabled engines */
@@ -1866,7 +2033,6 @@ void DRW_draw_depth_loop(
}
/* Setup viewport */
- cache_is_dirty = true;
/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
DST.draw_ctx = (DRWContextState){
@@ -1885,15 +2051,16 @@ void DRW_draw_depth_loop(
drw_engines_init();
DRW_hair_init();
- /* TODO : tag to refresh by the dependency graph */
- /* ideally only refresh when objects are added/removed */
- /* or render properties / materials change */
- if (cache_is_dirty) {
+ {
drw_engines_cache_init();
+ drw_engines_world_update(scene);
+ const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
{
- drw_engines_cache_populate(ob);
+ if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
+ drw_engines_cache_populate(ob);
+ }
}
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
@@ -1930,18 +2097,18 @@ void DRW_draw_depth_loop(
DRW_opengl_context_disable();
/* XXX Drawing the resulting buffer to the BACK_BUFFER */
- gpuPushMatrix();
- gpuPushProjectionMatrix();
+ GPU_matrix_push();
+ GPU_matrix_push_projection();
wmOrtho2_region_pixelspace(ar);
- gpuLoadIdentity();
+ GPU_matrix_identity_set();
glEnable(GL_DEPTH_TEST); /* Cannot write to depth buffer without testing */
glDepthFunc(GL_ALWAYS);
draw_depth_texture_to_screen(g_select_buffer.texture_depth);
glDepthFunc(GL_LEQUAL);
- gpuPopMatrix();
- gpuPopProjectionMatrix();
+ GPU_matrix_pop();
+ GPU_matrix_pop_projection();
}
/** \} */
@@ -2074,7 +2241,7 @@ void DRW_engine_register(DrawEngineType *draw_engine_type)
void DRW_engines_register(void)
{
RE_engines_register(&DRW_engine_viewport_eevee_type);
- RE_engines_register(&DRW_engine_viewport_workbench_type);
+ RE_engines_register(&DRW_engine_viewport_opengl_type);
DRW_engine_register(&draw_engine_workbench_solid);
DRW_engine_register(&draw_engine_workbench_transparent);
@@ -2131,7 +2298,7 @@ void DRW_engines_register(void)
}
}
-extern struct Gwn_VertFormat *g_pos_format; /* draw_shgroup.c */
+extern struct GPUVertFormat *g_pos_format; /* draw_shgroup.c */
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
extern struct GPUTexture *globals_ramp; /* draw_common.c */
void DRW_engines_free(void)
@@ -2178,16 +2345,14 @@ void DRW_opengl_context_create(void)
{
BLI_assert(DST.gl_context == NULL); /* Ensure it's called once */
- BLI_mutex_init(&DST.gl_context_mutex);
+ DST.gl_context_mutex = BLI_ticket_mutex_alloc();
if (!G.background) {
immDeactivate();
}
/* This changes the active context. */
DST.gl_context = WM_opengl_context_create();
- /* Make the context active for this thread (main thread) */
- WM_opengl_context_activate(DST.gl_context);
/* Be sure to create gawain.context too. */
- DST.gwn_context = GWN_context_create();
+ DST.gpu_context = GPU_context_create();
if (!G.background) {
immActivate();
}
@@ -2202,28 +2367,28 @@ void DRW_opengl_context_destroy(void)
BLI_assert(BLI_thread_is_main());
if (DST.gl_context != NULL) {
WM_opengl_context_activate(DST.gl_context);
- GWN_context_active_set(DST.gwn_context);
- GWN_context_discard(DST.gwn_context);
+ GPU_context_active_set(DST.gpu_context);
+ GPU_context_discard(DST.gpu_context);
WM_opengl_context_dispose(DST.gl_context);
- BLI_mutex_end(&DST.gl_context_mutex);
+ BLI_ticket_mutex_free(DST.gl_context_mutex);
}
}
-void DRW_opengl_context_enable(void)
+void DRW_opengl_context_enable_ex(bool restore)
{
if (DST.gl_context != NULL) {
/* IMPORTANT: We dont support immediate mode in render mode!
* This shall remain in effect until immediate mode supports
* multiple threads. */
- BLI_mutex_lock(&DST.gl_context_mutex);
- if (BLI_thread_is_main()) {
+ BLI_ticket_mutex_lock(DST.gl_context_mutex);
+ if (BLI_thread_is_main() && restore) {
if (!G.background) {
immDeactivate();
}
}
WM_opengl_context_activate(DST.gl_context);
- GWN_context_active_set(DST.gwn_context);
- if (BLI_thread_is_main()) {
+ GPU_context_active_set(DST.gpu_context);
+ if (BLI_thread_is_main() && restore) {
if (!G.background) {
immActivate();
}
@@ -2232,7 +2397,7 @@ void DRW_opengl_context_enable(void)
}
}
-void DRW_opengl_context_disable(void)
+void DRW_opengl_context_disable_ex(bool restore)
{
if (DST.gl_context != NULL) {
#ifdef __APPLE__
@@ -2241,16 +2406,61 @@ void DRW_opengl_context_disable(void)
glFlush();
#endif
- if (BLI_thread_is_main()) {
+ if (BLI_thread_is_main() && restore) {
wm_window_reset_drawable();
}
else {
WM_opengl_context_release(DST.gl_context);
- GWN_context_active_set(NULL);
+ GPU_context_active_set(NULL);
}
- BLI_mutex_unlock(&DST.gl_context_mutex);
+ BLI_ticket_mutex_unlock(DST.gl_context_mutex);
}
}
+void DRW_opengl_context_enable(void)
+{
+ DRW_opengl_context_enable_ex(true);
+}
+
+void DRW_opengl_context_disable(void)
+{
+ DRW_opengl_context_disable_ex(true);
+}
+
+void DRW_opengl_render_context_enable(void *re_gl_context)
+{
+ /* If thread is main you should use DRW_opengl_context_enable(). */
+ BLI_assert(!BLI_thread_is_main());
+
+ /* TODO get rid of the blocking. Only here because of the static global DST. */
+ BLI_ticket_mutex_lock(DST.gl_context_mutex);
+ WM_opengl_context_activate(re_gl_context);
+}
+
+void DRW_opengl_render_context_disable(void *re_gl_context)
+{
+ glFlush();
+ WM_opengl_context_release(re_gl_context);
+ /* TODO get rid of the blocking. */
+ BLI_ticket_mutex_unlock(DST.gl_context_mutex);
+}
+
+/* Needs to be called AFTER DRW_opengl_render_context_enable() */
+void DRW_gawain_render_context_enable(void *re_gpu_context)
+{
+ /* If thread is main you should use DRW_opengl_context_enable(). */
+ BLI_assert(!BLI_thread_is_main());
+
+ GPU_context_active_set(re_gpu_context);
+ DRW_shape_cache_reset(); /* XXX fix that too. */
+}
+
+/* Needs to be called BEFORE DRW_opengl_render_context_disable() */
+void DRW_gawain_render_context_disable(void *UNUSED(re_gpu_context))
+{
+ DRW_shape_cache_reset(); /* XXX fix that too. */
+ GPU_context_active_set(NULL);
+}
+
/** \} */
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index e811e9ea8a9..9b01f17649c 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -35,6 +35,7 @@
#include "BLI_threads.h"
#include "GPU_batch.h"
+#include "GPU_context.h"
#include "GPU_framebuffer.h"
#include "GPU_shader.h"
#include "GPU_uniformbuffer.h"
@@ -106,8 +107,8 @@ typedef struct DRWCallState {
DRWCallVisibilityFn *visibility_cb;
void *user_data;
- unsigned char flag;
- unsigned char cache_id; /* Compared with DST.state_cache_id to see if matrices are still valid. */
+ uchar flag;
+ uchar cache_id; /* Compared with DST.state_cache_id to see if matrices are still valid. */
uint16_t matflag; /* Which matrices to compute. */
/* Culling: Using Bounding Sphere for now for faster culling.
* Not ideal for planes. */
@@ -129,7 +130,7 @@ typedef enum {
DRW_CALL_RANGE, /* Like single but only draw a range of vertices/indices. */
DRW_CALL_INSTANCES, /* Draw instances without any instancing attribs. */
DRW_CALL_GENERATE, /* Uses a callback to draw with any number of batches. */
- DRW_CALL_PROCEDURAL, /* Generate a drawcall without any Gwn_Batch. */
+ DRW_CALL_PROCEDURAL, /* Generate a drawcall without any GPUBatch. */
} DRWCallType;
typedef struct DRWCall {
@@ -138,14 +139,14 @@ typedef struct DRWCall {
union {
struct { /* type == DRW_CALL_SINGLE */
- Gwn_Batch *geometry;
+ GPUBatch *geometry;
} single;
struct { /* type == DRW_CALL_RANGE */
- Gwn_Batch *geometry;
+ GPUBatch *geometry;
uint start, count;
} range;
struct { /* type == DRW_CALL_INSTANCES */
- Gwn_Batch *geometry;
+ GPUBatch *geometry;
/* Count can be adjusted between redraw. If needed, we can add fixed count. */
uint *count;
} instances;
@@ -155,7 +156,7 @@ typedef struct DRWCall {
} generate;
struct { /* type == DRW_CALL_PROCEDURAL */
uint vert_count;
- Gwn_PrimType prim_type;
+ GPUPrimType prim_type;
} procedural;
};
@@ -225,16 +226,16 @@ struct DRWShadingGroup {
} calls;
struct { /* DRW_SHG_FEEDBACK_TRANSFORM */
DRWCall *first, *last; /* Linked list of DRWCall or DRWCallDynamic depending of type */
- struct Gwn_VertBuf *tfeedback_target; /* Transform Feedback target. */
+ struct GPUVertBuf *tfeedback_target; /* Transform Feedback target. */
};
struct { /* DRW_SHG_***_BATCH */
- struct Gwn_Batch *batch_geom; /* Result of call batching */
- struct Gwn_VertBuf *batch_vbo;
+ struct GPUBatch *batch_geom; /* Result of call batching */
+ struct GPUVertBuf *batch_vbo;
uint primitive_count;
};
struct { /* DRW_SHG_INSTANCE[_EXTERNAL] */
- struct Gwn_Batch *instance_geom;
- struct Gwn_VertBuf *instance_vbo;
+ struct GPUBatch *instance_geom;
+ struct GPUVertBuf *instance_vbo;
uint instance_count;
float instance_orcofac[2][3]; /* TODO find a better place. */
};
@@ -263,7 +264,7 @@ struct DRWShadingGroup {
#endif
#ifdef USE_GPU_SELECT
- Gwn_VertBuf *inst_selectid;
+ GPUVertBuf *inst_selectid;
DRWPass *pass_parent; /* backlink to pass we're in */
int override_selectid; /* Override for single object instances. */
#endif
@@ -296,6 +297,12 @@ typedef struct DRWDebugLine {
float color[4];
} DRWDebugLine;
+typedef struct DRWDebugSphere {
+ struct DRWDebugSphere *next; /* linked list */
+ float mat[4][4];
+ float color[4];
+} DRWDebugSphere;
+
/* ------------- DRAW MANAGER ------------ */
#define MAX_CLIP_PLANES 6 /* GL_MAX_CLIP_PLANES is at least 6 */
@@ -308,7 +315,7 @@ typedef struct DRWManager {
DRWInstanceData *object_instance_data[MAX_INSTANCE_DATA_SIZE];
/* State of the object being evaluated if already allocated. */
DRWCallState *ob_state;
- unsigned char state_cache_id; /* Could be larger but 254 view changes is already a lot! */
+ uchar state_cache_id; /* Could be larger but 254 view changes is already a lot! */
/* Rendering state */
GPUShader *shader;
@@ -372,8 +379,8 @@ typedef struct DRWManager {
/* gl_context serves as the offset for clearing only
* the top portion of the struct so DO NOT MOVE IT! */
void *gl_context; /* Unique ghost context used by the draw manager. */
- Gwn_Context *gwn_context;
- ThreadMutex gl_context_mutex; /* Mutex to lock the drw manager and avoid concurent context usage. */
+ GPUContext *gpu_context;
+ TicketMutex *gl_context_mutex; /* Mutex to lock the drw manager and avoid concurent context usage. */
/** GPU Resource State: Memory storage between drawing. */
struct {
@@ -388,6 +395,7 @@ typedef struct DRWManager {
struct {
/* TODO(fclem) optimize: use chunks. */
DRWDebugLine *lines;
+ DRWDebugSphere *spheres;
} debug;
} DRWManager;
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index db4e16d362a..dccb869c133 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -41,7 +41,7 @@
#include "intern/gpu_codegen.h"
-struct Gwn_VertFormat *g_pos_format = NULL;
+struct GPUVertFormat *g_pos_format = NULL;
extern struct GPUUniformBuffer *view_ubo; /* draw_manager_exec.c */
@@ -355,7 +355,7 @@ static DRWCallState *drw_call_state_object(DRWShadingGroup *shgroup, float (*obm
return DST.ob_state;
}
-void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4])
+void DRW_shgroup_call_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4])
{
BLI_assert(geom != NULL);
BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
@@ -371,7 +371,7 @@ void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obm
BLI_LINKS_APPEND(&shgroup->calls, call);
}
-void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count)
+void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_count)
{
BLI_assert(geom != NULL);
BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
@@ -391,7 +391,7 @@ void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float
}
static void drw_shgroup_call_procedural_add_ex(
- DRWShadingGroup *shgroup, Gwn_PrimType prim_type, uint vert_count, float (*obmat)[4], Object *ob)
+ DRWShadingGroup *shgroup, GPUPrimType prim_type, uint vert_count, float (*obmat)[4], Object *ob)
{
BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
@@ -412,30 +412,30 @@ static void drw_shgroup_call_procedural_add_ex(
BLI_LINKS_APPEND(&shgroup->calls, call);
}
-void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_count, float (*obmat)[4])
+void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4])
{
- drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS, point_count, obmat, NULL);
+ drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_POINTS, point_len, obmat, NULL);
}
void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4])
{
- drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_LINES, line_count * 2, obmat, NULL);
+ drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_LINES, line_count * 2, obmat, NULL);
}
void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4])
{
- drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count * 3, obmat, NULL);
+ drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, obmat, NULL);
}
/* TODO (fclem): this is a sign that the api is starting to be limiting.
* Maybe add special function that general purpose for special cases. */
void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, Object *ob)
{
- drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count * 3, NULL, ob);
+ drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, NULL, ob);
}
/* These calls can be culled and are optimized for redraw */
-void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, bool bypass_culling)
+void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, bool bypass_culling)
{
BLI_assert(geom != NULL);
BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
@@ -455,7 +455,7 @@ void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, Gwn_Batch *geom, O
}
void DRW_shgroup_call_object_add_with_callback(
- DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob,
+ DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob,
DRWCallVisibilityFn *callback, void *user_data)
{
BLI_assert(geom != NULL);
@@ -474,7 +474,7 @@ void DRW_shgroup_call_object_add_with_callback(
BLI_LINKS_APPEND(&shgroup->calls, call);
}
-void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4], uint *count)
+void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4], uint *count)
{
BLI_assert(geom != NULL);
BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
@@ -492,7 +492,7 @@ void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, f
}
/* These calls can be culled and are optimized for redraw */
-void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, uint *count)
+void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, uint *count)
{
BLI_assert(geom != NULL);
BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
@@ -531,7 +531,7 @@ void DRW_shgroup_call_generate_add(
static void sculpt_draw_cb(
DRWShadingGroup *shgroup,
- void (*draw_fn)(DRWShadingGroup *shgroup, Gwn_Batch *geom),
+ void (*draw_fn)(DRWShadingGroup *shgroup, GPUBatch *geom),
void *user_data)
{
Object *ob = user_data;
@@ -540,7 +540,7 @@ static void sculpt_draw_cb(
if (pbvh) {
BKE_pbvh_draw_cb(
pbvh, NULL, NULL, false,
- (void (*)(void *, Gwn_Batch *))draw_fn, shgroup);
+ (void (*)(void *, GPUBatch *))draw_fn, shgroup);
}
}
@@ -553,10 +553,10 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
{
#ifdef USE_GPU_SELECT
if (G.f & G_PICKSEL) {
- if (shgroup->instance_count == shgroup->inst_selectid->vertex_ct) {
- GWN_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32);
+ if (shgroup->instance_count == shgroup->inst_selectid->vertex_len) {
+ GPU_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32);
}
- GWN_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id);
+ GPU_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id);
}
#endif
@@ -564,10 +564,10 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
UNUSED_VARS_NDEBUG(attr_len);
for (int i = 0; i < attr_len; ++i) {
- if (shgroup->instance_count == shgroup->instance_vbo->vertex_ct) {
- GWN_vertbuf_data_resize(shgroup->instance_vbo, shgroup->instance_count + 32);
+ if (shgroup->instance_count == shgroup->instance_vbo->vertex_len) {
+ GPU_vertbuf_data_resize(shgroup->instance_vbo, shgroup->instance_count + 32);
}
- GWN_vertbuf_attr_set(shgroup->instance_vbo, i, shgroup->instance_count, attr[i]);
+ GPU_vertbuf_attr_set(shgroup->instance_vbo, i, shgroup->instance_count, attr[i]);
}
shgroup->instance_count += 1;
@@ -601,25 +601,25 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
}
else {
/* Only here to support builtin shaders. This should not be used by engines. */
- drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEW, DST.view_data.matstate.mat[DRW_MAT_VIEW], 16, 1);
- drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEW_INV, DST.view_data.matstate.mat[DRW_MAT_VIEWINV], 16, 1);
- drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEWPROJECTION, DST.view_data.matstate.mat[DRW_MAT_PERS], 16, 1);
- drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEWPROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_PERSINV], 16, 1);
- drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_PROJECTION, DST.view_data.matstate.mat[DRW_MAT_WIN], 16, 1);
- drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_PROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_WININV], 16, 1);
- drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_CAMERATEXCO, DST.view_data.viewcamtexcofac, 3, 2);
+ drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEW, DST.view_data.matstate.mat[DRW_MAT_VIEW], 16, 1);
+ drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEW_INV, DST.view_data.matstate.mat[DRW_MAT_VIEWINV], 16, 1);
+ drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEWPROJECTION, DST.view_data.matstate.mat[DRW_MAT_PERS], 16, 1);
+ drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEWPROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_PERSINV], 16, 1);
+ drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION, DST.view_data.matstate.mat[DRW_MAT_WIN], 16, 1);
+ drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_WININV], 16, 1);
+ drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_CAMERATEXCO, DST.view_data.viewcamtexcofac, 3, 2);
}
- shgroup->model = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODEL);
- shgroup->modelinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODEL_INV);
- shgroup->modelview = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODELVIEW);
- shgroup->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODELVIEW_INV);
- shgroup->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MVP);
- shgroup->normalview = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_NORMAL);
- shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_WORLDNORMAL);
- shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_ORCO);
- shgroup->eye = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_EYE);
- shgroup->callid = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_CALLID);
+ shgroup->model = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODEL);
+ shgroup->modelinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODEL_INV);
+ shgroup->modelview = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW);
+ shgroup->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW_INV);
+ shgroup->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MVP);
+ shgroup->normalview = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_NORMAL);
+ shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_WORLDNORMAL);
+ shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_ORCO);
+ shgroup->eye = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_EYE);
+ shgroup->callid = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_CALLID);
shgroup->matflag = 0;
if (shgroup->modelinverse > -1)
@@ -641,7 +641,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
}
static void drw_shgroup_instance_init(
- DRWShadingGroup *shgroup, GPUShader *shader, Gwn_Batch *batch, Gwn_VertFormat *format)
+ DRWShadingGroup *shgroup, GPUShader *shader, GPUBatch *batch, GPUVertFormat *format)
{
BLI_assert(shgroup->type == DRW_SHG_INSTANCE);
BLI_assert(batch != NULL);
@@ -651,7 +651,7 @@ static void drw_shgroup_instance_init(
shgroup->instance_geom = batch;
#ifndef NDEBUG
- shgroup->attribs_count = format->attrib_ct;
+ shgroup->attribs_count = format->attr_len;
#endif
DRW_instancing_buffer_request(DST.idatalist, format, batch, shgroup,
@@ -661,34 +661,34 @@ static void drw_shgroup_instance_init(
if (G.f & G_PICKSEL) {
/* Not actually used for rendering but alloced in one chunk.
* Plus we don't have to care about ownership. */
- static Gwn_VertFormat inst_select_format = {0};
- if (inst_select_format.attrib_ct == 0) {
- GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ static GPUVertFormat inst_select_format = {0};
+ if (inst_select_format.attr_len == 0) {
+ GPU_vertformat_attr_add(&inst_select_format, "selectId", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
- Gwn_Batch *batch_dummy; /* Not used */
+ GPUBatch *batch_dummy; /* Not used */
DRW_batching_buffer_request(DST.idatalist, &inst_select_format,
- GWN_PRIM_POINTS, shgroup,
+ GPU_PRIM_POINTS, shgroup,
&batch_dummy, &shgroup->inst_selectid);
}
#endif
}
static void drw_shgroup_batching_init(
- DRWShadingGroup *shgroup, GPUShader *shader, Gwn_VertFormat *format)
+ DRWShadingGroup *shgroup, GPUShader *shader, GPUVertFormat *format)
{
drw_shgroup_init(shgroup, shader);
#ifndef NDEBUG
- shgroup->attribs_count = (format != NULL) ? format->attrib_ct : 0;
+ shgroup->attribs_count = (format != NULL) ? format->attr_len : 0;
#endif
BLI_assert(format != NULL);
- Gwn_PrimType type;
+ GPUPrimType type;
switch (shgroup->type) {
- case DRW_SHG_POINT_BATCH: type = GWN_PRIM_POINTS; break;
- case DRW_SHG_LINE_BATCH: type = GWN_PRIM_LINES; break;
- case DRW_SHG_TRIANGLE_BATCH: type = GWN_PRIM_TRIS; break;
- default: type = GWN_PRIM_NONE; BLI_assert(0); break;
+ case DRW_SHG_POINT_BATCH: type = GPU_PRIM_POINTS; break;
+ case DRW_SHG_LINE_BATCH: type = GPU_PRIM_LINES; break;
+ case DRW_SHG_TRIANGLE_BATCH: type = GPU_PRIM_TRIS; break;
+ default: type = GPU_PRIM_NONE; BLI_assert(0); break;
}
DRW_batching_buffer_request(DST.idatalist, format, type, shgroup,
@@ -697,13 +697,13 @@ static void drw_shgroup_batching_init(
#ifdef USE_GPU_SELECT
if (G.f & G_PICKSEL) {
/* Not actually used for rendering but alloced in one chunk. */
- static Gwn_VertFormat inst_select_format = {0};
- if (inst_select_format.attrib_ct == 0) {
- GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ static GPUVertFormat inst_select_format = {0};
+ if (inst_select_format.attr_len == 0) {
+ GPU_vertformat_attr_add(&inst_select_format, "selectId", GPU_COMP_I32, 1, GPU_FETCH_INT);
}
- Gwn_Batch *batch; /* Not used */
+ GPUBatch *batch; /* Not used */
DRW_batching_buffer_request(DST.idatalist, &inst_select_format,
- GWN_PRIM_POINTS, shgroup,
+ GPU_PRIM_POINTS, shgroup,
&batch, &shgroup->inst_selectid);
}
#endif
@@ -807,15 +807,15 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct
return grp;
}
-Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize)
+GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize)
{
- Gwn_VertFormat *format = MEM_callocN(sizeof(Gwn_VertFormat), "Gwn_VertFormat");
+ GPUVertFormat *format = MEM_callocN(sizeof(GPUVertFormat), "GPUVertFormat");
for (int i = 0; i < arraysize; ++i) {
- GWN_vertformat_attr_add(format, attribs[i].name,
- (attribs[i].type == DRW_ATTRIB_INT) ? GWN_COMP_I32 : GWN_COMP_F32,
+ GPU_vertformat_attr_add(format, attribs[i].name,
+ (attribs[i].type == DRW_ATTRIB_INT) ? GPU_COMP_I32 : GPU_COMP_F32,
attribs[i].components,
- (attribs[i].type == DRW_ATTRIB_INT) ? GWN_FETCH_INT : GWN_FETCH_FLOAT);
+ (attribs[i].type == DRW_ATTRIB_INT) ? GPU_FETCH_INT : GPU_FETCH_FLOAT);
}
return format;
}
@@ -835,7 +835,7 @@ DRWShadingGroup *DRW_shgroup_material_create(
}
DRWShadingGroup *DRW_shgroup_material_instance_create(
- struct GPUMaterial *material, DRWPass *pass, Gwn_Batch *geom, Object *ob, Gwn_VertFormat *format)
+ struct GPUMaterial *material, DRWPass *pass, GPUBatch *geom, Object *ob, GPUVertFormat *format)
{
GPUPass *gpupass = GPU_material_get_pass(material);
DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass);
@@ -861,7 +861,7 @@ DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create(
DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass);
if (shgroup) {
- /* Calling drw_shgroup_init will cause it to call GWN_draw_primitive(). */
+ /* Calling drw_shgroup_init will cause it to call GPU_draw_primitive(). */
drw_shgroup_init(shgroup, GPU_pass_shader_get(gpupass));
shgroup->type = DRW_SHG_TRIANGLE_BATCH;
shgroup->instance_count = tri_count * 3;
@@ -879,7 +879,7 @@ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
}
DRWShadingGroup *DRW_shgroup_instance_create(
- struct GPUShader *shader, DRWPass *pass, Gwn_Batch *geom, Gwn_VertFormat *format)
+ struct GPUShader *shader, DRWPass *pass, GPUBatch *geom, GPUVertFormat *format)
{
DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
shgroup->type = DRW_SHG_INSTANCE;
@@ -903,7 +903,7 @@ DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPas
}
DRWShadingGroup *DRW_shgroup_line_batch_create_with_format(
- struct GPUShader *shader, DRWPass *pass, Gwn_VertFormat *format)
+ struct GPUShader *shader, DRWPass *pass, GPUVertFormat *format)
{
DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
shgroup->type = DRW_SHG_LINE_BATCH;
@@ -930,7 +930,7 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DR
#endif
DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
- /* Calling drw_shgroup_init will cause it to call GWN_draw_primitive(). */
+ /* Calling drw_shgroup_init will cause it to call GPU_draw_primitive(). */
drw_shgroup_init(shgroup, shader);
shgroup->type = DRW_SHG_TRIANGLE_BATCH;
@@ -939,7 +939,7 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DR
return shgroup;
}
-DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, Gwn_VertBuf *tf_target)
+DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, GPUVertBuf *tf_target)
{
BLI_assert(tf_target != NULL);
DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
@@ -953,7 +953,7 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader,
}
/* Specify an external batch instead of adding each attrib one by one. */
-void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batch)
+void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch)
{
BLI_assert(shgroup->type == DRW_SHG_INSTANCE);
BLI_assert(shgroup->instance_count == 0);
@@ -966,7 +966,7 @@ void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batc
/* Note: This WILL break if batch->verts[0] is destroyed and reallocated
* at the same adress. Bindings/VAOs would remain obsolete. */
//if (shgroup->instancing_geom->inst != batch->verts[0])
- GWN_batch_instbuf_set(shgroup->instance_geom, batch->verts[0], false);
+ GPU_batch_instbuf_set(shgroup->instance_geom, batch->verts[0], false);
#ifdef USE_GPU_SELECT
shgroup->override_selectid = DST.select_id;
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 3b7d19ac361..1134f421c16 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -419,10 +419,10 @@ void DRW_state_invert_facing(void)
* and if the shaders have support for it (see usage of gl_ClipDistance).
* Be sure to call DRW_state_clip_planes_reset() after you finish drawing.
**/
-void DRW_state_clip_planes_count_set(uint plane_ct)
+void DRW_state_clip_planes_count_set(uint plane_len)
{
- BLI_assert(plane_ct <= MAX_CLIP_PLANES);
- DST.num_clip_planes = plane_ct;
+ BLI_assert(plane_len <= MAX_CLIP_PLANES);
+ DST.num_clip_planes = plane_len;
}
void DRW_state_clip_planes_reset(void)
@@ -827,29 +827,29 @@ static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCallState *state)
}
static void draw_geometry_execute_ex(
- DRWShadingGroup *shgroup, Gwn_Batch *geom, uint start, uint count, bool draw_instance)
+ DRWShadingGroup *shgroup, GPUBatch *geom, uint start, uint count, bool draw_instance)
{
/* Special case: empty drawcall, placement is done via shader, don't bind anything. */
/* TODO use DRW_CALL_PROCEDURAL instead */
if (geom == NULL) {
BLI_assert(shgroup->type == DRW_SHG_TRIANGLE_BATCH); /* Add other type if needed. */
/* Shader is already bound. */
- GWN_draw_primitive(GWN_PRIM_TRIS, count);
+ GPU_draw_primitive(GPU_PRIM_TRIS, count);
return;
}
/* step 2 : bind vertex array & draw */
- GWN_batch_program_set_no_use(
+ GPU_batch_program_set_no_use(
geom, GPU_shader_get_program(shgroup->shader), GPU_shader_get_interface(shgroup->shader));
/* XXX hacking gawain. we don't want to call glUseProgram! (huge performance loss) */
geom->program_in_use = true;
- GWN_batch_draw_range_ex(geom, start, count, draw_instance);
+ GPU_batch_draw_range_ex(geom, start, count, draw_instance);
geom->program_in_use = false; /* XXX hacking gawain */
}
-static void draw_geometry_execute(DRWShadingGroup *shgroup, Gwn_Batch *geom)
+static void draw_geometry_execute(DRWShadingGroup *shgroup, GPUBatch *geom)
{
draw_geometry_execute_ex(shgroup, geom, 0, 0, false);
}
@@ -923,7 +923,7 @@ static void release_texture_slots(bool with_persist)
}
}
- /* Reset so that slots are consistenly assigned for different shader
+ /* Reset so that slots are consistently assigned for different shader
* draw calls, to avoid shader specialization/patching by the driver. */
DST.RST.bind_tex_inc = 0;
}
@@ -940,7 +940,7 @@ static void release_ubo_slots(bool with_persist)
}
}
- /* Reset so that slots are consistenly assigned for different shader
+ /* Reset so that slots are consistently assigned for different shader
* draw calls, to avoid shader specialization/patching by the driver. */
DST.RST.bind_ubo_inc = 0;
}
@@ -1055,9 +1055,9 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
if (G.f & G_PICKSEL) { \
if (_shgroup->override_selectid == -1) { \
/* Hack : get vbo data without actually drawing. */ \
- Gwn_VertBufRaw raw; \
- GWN_vertbuf_attr_get_raw_data(_shgroup->inst_selectid, 0, &raw); \
- select_id = GWN_vertbuf_raw_step(&raw); \
+ GPUVertBufRaw raw; \
+ GPU_vertbuf_attr_get_raw_data(_shgroup->inst_selectid, 0, &raw); \
+ select_id = GPU_vertbuf_raw_step(&raw); \
switch (_shgroup->type) { \
case DRW_SHG_TRIANGLE_BATCH: _count = 3; break; \
case DRW_SHG_LINE_BATCH: _count = 2; break; \
@@ -1168,7 +1168,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
call->generate.geometry_fn(shgroup, draw_geometry_execute, call->generate.user_data);
break;
case DRW_CALL_PROCEDURAL:
- GWN_draw_primitive(call->procedural.prim_type, call->procedural.vert_count);
+ GPU_draw_primitive(call->procedural.prim_type, call->procedural.vert_count);
break;
default:
BLI_assert(0);
diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c
index e4c0877b907..edeb6c07733 100644
--- a/source/blender/draw/intern/draw_manager_profiling.c
+++ b/source/blender/draw/intern/draw_manager_profiling.c
@@ -305,7 +305,7 @@ void DRW_stats_draw(rcti *rect)
/* Memory Stats */
uint tex_mem = GPU_texture_memory_usage_get();
- uint vbo_mem = GWN_vertbuf_get_memory_usage();
+ uint vbo_mem = GPU_vertbuf_get_memory_usage();
sprintf(stat_string, "GPU Memory");
draw_stat(rect, 0, v, stat_string, sizeof(stat_string));
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 435c6c77e59..b0aec4a7600 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -154,10 +154,10 @@ static void drw_deferred_shader_compilation_free(void *custom_data)
MEM_freeN(comp);
}
-static void drw_deferred_shader_add(GPUMaterial *mat)
+static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
{
/* Do not deferre the compilation if we are rendering for image. */
- if (DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION) {
+ if (DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION || !deferred) {
/* Double checking that this GPUMaterial is not going to be
* compiled by another thread. */
DRW_deferred_shader_remove(mat);
@@ -308,10 +308,10 @@ GPUShader *DRW_shader_create_3D_depth_only(void)
return GPU_shader_get_builtin_shader(GPU_SHADER_3D_DEPTH_ONLY);
}
-GPUMaterial *DRW_shader_find_from_world(World *wo, const void *engine_type, int options)
+GPUMaterial *DRW_shader_find_from_world(World *wo, const void *engine_type, int options, bool deferred)
{
GPUMaterial *mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine_type, options);
- if (DRW_state_is_image_render()) {
+ if (DRW_state_is_image_render() || !deferred) {
if (mat != NULL && GPU_material_status(mat) == GPU_MAT_QUEUED) {
/* XXX Hack : we return NULL so that the engine will call DRW_shader_create_from_XXX
* with the shader code and we will resume the compilation from there. */
@@ -321,10 +321,10 @@ GPUMaterial *DRW_shader_find_from_world(World *wo, const void *engine_type, int
return mat;
}
-GPUMaterial *DRW_shader_find_from_material(Material *ma, const void *engine_type, int options)
+GPUMaterial *DRW_shader_find_from_material(Material *ma, const void *engine_type, int options, bool deferred)
{
GPUMaterial *mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine_type, options);
- if (DRW_state_is_image_render()) {
+ if (DRW_state_is_image_render() || !deferred) {
if (mat != NULL && GPU_material_status(mat) == GPU_MAT_QUEUED) {
/* XXX Hack : we return NULL so that the engine will call DRW_shader_create_from_XXX
* with the shader code and we will resume the compilation from there. */
@@ -336,7 +336,7 @@ GPUMaterial *DRW_shader_find_from_material(Material *ma, const void *engine_type
GPUMaterial *DRW_shader_create_from_world(
struct Scene *scene, World *wo, const void *engine_type, int options,
- const char *vert, const char *geom, const char *frag_lib, const char *defines)
+ const char *vert, const char *geom, const char *frag_lib, const char *defines, bool deferred)
{
GPUMaterial *mat = NULL;
if (DRW_state_is_image_render()) {
@@ -350,7 +350,7 @@ GPUMaterial *DRW_shader_create_from_world(
}
if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
- drw_deferred_shader_add(mat);
+ drw_deferred_shader_add(mat, deferred);
}
return mat;
@@ -358,7 +358,7 @@ GPUMaterial *DRW_shader_create_from_world(
GPUMaterial *DRW_shader_create_from_material(
struct Scene *scene, Material *ma, const void *engine_type, int options,
- const char *vert, const char *geom, const char *frag_lib, const char *defines)
+ const char *vert, const char *geom, const char *frag_lib, const char *defines, bool deferred)
{
GPUMaterial *mat = NULL;
if (DRW_state_is_image_render()) {
@@ -372,7 +372,7 @@ GPUMaterial *DRW_shader_create_from_material(
}
if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
- drw_deferred_shader_add(mat);
+ drw_deferred_shader_add(mat, deferred);
}
return mat;
diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c
index 56255af98ce..b32853959c8 100644
--- a/source/blender/draw/intern/draw_manager_text.c
+++ b/source/blender/draw/intern/draw_manager_text.c
@@ -46,7 +46,7 @@ typedef struct ViewCachedString {
struct ViewCachedString *next, *prev;
float vec[3];
union {
- unsigned char ub[4];
+ uchar ub[4];
int pack;
} col;
short sco[2];
@@ -79,7 +79,7 @@ void DRW_text_cache_add(
const float co[3],
const char *str, const int str_len,
short xoffs, short flag,
- const unsigned char col[4])
+ const uchar col[4])
{
int alloc_len;
ViewCachedString *vos;
@@ -111,9 +111,7 @@ void DRW_text_cache_add(
}
}
-void DRW_text_cache_draw(
- DRWTextStore *dt,
- View3D *v3d, ARegion *ar, bool depth_write)
+void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar)
{
RegionView3D *rv3d = ar->regiondata;
ViewCachedString *vos;
@@ -143,18 +141,11 @@ void DRW_text_cache_draw(
}
float original_proj[4][4];
- gpuGetProjectionMatrix(original_proj);
+ GPU_matrix_projection_get(original_proj);
wmOrtho2_region_pixelspace(ar);
- gpuPushMatrix();
- gpuLoadIdentity();
-
- if (depth_write) {
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- }
- else {
- glDepthMask(GL_FALSE);
- }
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
const int font_id = BLF_default();
@@ -171,7 +162,7 @@ void DRW_text_cache_draw(
BLF_position(
font_id,
- (float)(vos->sco[0] + vos->xoffs), (float)(vos->sco[1]), (depth_write) ? 0.0f : 2.0f);
+ (float)(vos->sco[0] + vos->xoffs), (float)(vos->sco[1]), 2.0f);
((vos->flag & DRW_TEXT_CACHE_ASCII) ?
BLF_draw_ascii :
@@ -182,15 +173,8 @@ void DRW_text_cache_draw(
}
}
- if (depth_write) {
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- }
- else {
- glDepthMask(GL_TRUE);
- }
-
- gpuPopMatrix();
- gpuLoadProjectionMatrix(original_proj);
+ GPU_matrix_pop();
+ GPU_matrix_projection_set(original_proj);
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_enable();
diff --git a/source/blender/draw/intern/draw_manager_text.h b/source/blender/draw/intern/draw_manager_text.h
index a58e167be0d..14c33be4cf8 100644
--- a/source/blender/draw/intern/draw_manager_text.h
+++ b/source/blender/draw/intern/draw_manager_text.h
@@ -34,11 +34,9 @@ void DRW_text_cache_add(
const float co[3],
const char *str, const int str_len,
short xoffs, short flag,
- const unsigned char col[4]);
+ const uchar col[4]);
-void DRW_text_cache_draw(
- struct DRWTextStore *dt,
- struct View3D *v3d, struct ARegion *ar, bool depth_write);
+void DRW_text_cache_draw(struct DRWTextStore *dt, struct ARegion *ar);
enum {
DRW_TEXT_CACHE_ASCII = (1 << 0),
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index a666ec5395f..05aecea1d7a 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -79,7 +79,7 @@ void DRW_draw_region_info(void)
/* ************************* Grid ************************** */
-static void gridline_range(double x0, double dx, double max, int *r_first, int *r_count)
+static void gridline_range(double x0, double dx, double max, int *r_first, int *r_len)
{
/* determine range of gridlines that appear in this Area -- similar calc but separate ranges for x & y
* x0 is gridline 0, the axis in screen space
@@ -90,11 +90,11 @@ static void gridline_range(double x0, double dx, double max, int *r_first, int *
if (first <= last) {
*r_first = first;
- *r_count = last - first + 1;
+ *r_len = last - first + 1;
}
else {
*r_first = 0;
- *r_count = 0;
+ *r_len = 0;
}
}
@@ -104,19 +104,19 @@ static int gridline_count(ARegion *ar, double x0, double y0, double dx)
* dx is the frequency, shared by x & y directions
* pass in dx of smallest (highest precision) grid we want to draw */
- int first, x_ct, y_ct;
+ int first, x_len, y_len;
- gridline_range(x0, dx, ar->winx, &first, &x_ct);
- gridline_range(y0, dx, ar->winy, &first, &y_ct);
+ gridline_range(x0, dx, ar->winx, &first, &x_len);
+ gridline_range(y0, dx, ar->winy, &first, &y_len);
- int total_ct = x_ct + y_ct;
+ int total_len = x_len + y_len;
- return total_ct;
+ return total_len;
}
static bool drawgrid_draw(
ARegion *ar, double x0, double y0, double dx, int skip_mod,
- unsigned pos, unsigned col, GLubyte col_value[3])
+ uint pos, uint col, GLubyte col_value[3])
{
/* skip every skip_mod lines relative to each axis; they will be overlaid by another drawgrid_draw
* always skip exact x0 & y0 axes; they will be drawn later in color
@@ -129,7 +129,7 @@ static bool drawgrid_draw(
const float y_max = (float)ar->winy;
int first, ct;
- int x_ct = 0, y_ct = 0; /* count of lines actually drawn */
+ int x_len = 0, y_len = 0; /* count of lines actually drawn */
int lines_skipped_for_next_unit = 0;
/* draw vertical lines */
@@ -143,13 +143,13 @@ static bool drawgrid_draw(
continue;
}
- if (x_ct == 0)
+ if (x_len == 0)
immAttrib3ub(col, col_value[0], col_value[1], col_value[2]);
float x = (float)(x0 + i * dx);
immVertex2f(pos, x, 0.0f);
immVertex2f(pos, x, y_max);
- ++x_ct;
+ ++x_len;
}
/* draw horizontal lines */
@@ -163,13 +163,13 @@ static bool drawgrid_draw(
continue;
}
- if (x_ct + y_ct == 0)
+ if (x_len + y_len == 0)
immAttrib3ub(col, col_value[0], col_value[1], col_value[2]);
float y = (float)(y0 + i * dx);
immVertex2f(pos, 0.0f, y);
immVertex2f(pos, x_max, y);
- ++y_ct;
+ ++y_len;
}
return lines_skipped_for_next_unit > 0;
@@ -214,13 +214,13 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
glDepthMask(GL_FALSE); /* disable write in zbuffer */
#endif
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- unsigned char col[3], col2[3];
+ uchar col[3], col2[3];
UI_GetThemeColor3ubv(TH_GRID, col);
if (unit->system) {
@@ -249,11 +249,11 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
*grid_unit = bUnit_GetNameDisplay(usys, i);
rv3d->gridview = (float)((scalar * (double)v3d->grid) / (double)unit->scale_length);
- int gridline_ct = gridline_count(ar, x, y, dx_scalar);
- if (gridline_ct == 0)
+ int gridline_len = gridline_count(ar, x, y, dx_scalar);
+ if (gridline_len == 0)
goto drawgrid_cleanup; /* nothing to draw */
- immBegin(GWN_PRIM_LINES, gridline_ct * 2);
+ immBegin(GPU_PRIM_LINES, gridline_len * 2);
}
float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar);
@@ -302,11 +302,11 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
}
}
- int gridline_ct = gridline_count(ar, x, y, dx);
- if (gridline_ct == 0)
+ int gridline_len = gridline_count(ar, x, y, dx);
+ if (gridline_len == 0)
goto drawgrid_cleanup; /* nothing to draw */
- immBegin(GWN_PRIM_LINES, gridline_ct * 2);
+ immBegin(GPU_PRIM_LINES, gridline_len * 2);
if (grids_to_draw == 2) {
UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2);
@@ -369,25 +369,25 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
bool show_axis_y = (v3d->gridflag & V3D_SHOW_Y) != 0;
bool show_axis_z = (v3d->gridflag & V3D_SHOW_Z) != 0;
- unsigned char col_grid[3], col_axis[3];
+ uchar col_grid[3], col_axis[3];
glLineWidth(1.0f);
UI_GetThemeColor3ubv(TH_GRID, col_grid);
if (show_floor) {
- const unsigned vertex_ct = 2 * (gridlines * 4 + 2);
+ const uint vertex_len = 2 * (gridlines * 4 + 2);
const int sublines = v3d->gridsubdiv;
- unsigned char col_bg[3], col_grid_emphasise[3], col_grid_light[3];
+ uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3];
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, vertex_ct);
+ immBegin(GPU_PRIM_LINES, vertex_len);
/* draw normal grid lines */
UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10);
@@ -469,12 +469,12 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
if (show_axis_x || show_axis_y || show_axis_z) {
/* draw axis lines -- sometimes grid floor is off, other times we still need to draw the Z axis */
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2);
+ immBegin(GPU_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2);
if (show_axis_x) {
UI_make_axis_color(col_grid, col_axis, 'X');
@@ -548,8 +548,8 @@ void DRW_draw_grid(void)
*(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */
drawgrid(&scene->unit, ar, v3d, &grid_unit);
- gpuLoadProjectionMatrix(rv3d->winmat);
- gpuLoadMatrix(rv3d->viewmat);
+ GPU_matrix_projection_set(rv3d->winmat);
+ GPU_matrix_set(rv3d->viewmat);
}
else {
glDepthMask(GL_TRUE);
@@ -582,21 +582,21 @@ void DRW_draw_background(void)
/* Gradient background Color */
glDisable(GL_DEPTH_TEST);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- unsigned char col_hi[3], col_lo[3];
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ uchar col_hi[3], col_lo[3];
- gpuPushMatrix();
- gpuLoadIdentity();
- gpuLoadProjectionMatrix(m);
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
+ GPU_matrix_projection_set(m);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR_DITHER);
UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo);
UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi);
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib3ubv(color, col_lo);
immVertex2f(pos, -1.0f, -1.0f);
immVertex2f(pos, 1.0f, -1.0f);
@@ -608,7 +608,7 @@ void DRW_draw_background(void)
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -689,10 +689,10 @@ void DRW_draw_cursor(void)
/* Draw lines */
if (is_aligned == false) {
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformThemeColor3(TH_VIEW_OVERLAY);
- immBegin(GWN_PRIM_LINES, 12);
+ immBegin(GPU_PRIM_LINES, 12);
const float scale = ED_view3d_pixel_size_no_ui_scale(rv3d, cursor->location) * U.widget_unit;
@@ -724,14 +724,14 @@ void DRW_draw_cursor(void)
}
ED_region_pixelspace(ar);
- gpuTranslate2f(co[0] + 0.5f, co[1] + 0.5f);
- gpuScale2f(U.widget_unit, U.widget_unit);
+ GPU_matrix_translate_2f(co[0] + 0.5f, co[1] + 0.5f);
+ GPU_matrix_scale_2f(U.widget_unit, U.widget_unit);
- Gwn_Batch *cursor_batch = DRW_cache_cursor_get(is_aligned);
+ GPUBatch *cursor_batch = DRW_cache_cursor_get(is_aligned);
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR);
- GWN_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
+ GPU_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
- GWN_batch_draw(cursor_batch);
+ GPU_batch_draw(cursor_batch);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
@@ -739,34 +739,30 @@ void DRW_draw_cursor(void)
}
}
-/* **************************** 3D Manipulator ******************************** */
+/* **************************** 3D Gizmo ******************************** */
-void DRW_draw_manipulator_3d(void)
+void DRW_draw_gizmo_3d(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
- View3D *v3d = draw_ctx->v3d;
- v3d->zbuf = false;
ARegion *ar = draw_ctx->ar;
- /* draw depth culled manipulators - manipulators need to be updated *after* view matrix was set up */
- /* TODO depth culling manipulators is not yet supported, just drawing _3D here, should
+ /* draw depth culled gizmos - gizmos need to be updated *after* view matrix was set up */
+ /* TODO depth culling gizmos is not yet supported, just drawing _3D here, should
* later become _IN_SCENE (and draw _3D separate) */
- WM_manipulatormap_draw(
- ar->manipulator_map, draw_ctx->evil_C,
- WM_MANIPULATORMAP_DRAWSTEP_3D);
+ WM_gizmomap_draw(
+ ar->gizmo_map, draw_ctx->evil_C,
+ WM_GIZMOMAP_DRAWSTEP_3D);
}
-void DRW_draw_manipulator_2d(void)
+void DRW_draw_gizmo_2d(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
- View3D *v3d = draw_ctx->v3d;
- v3d->zbuf = false;
ARegion *ar = draw_ctx->ar;
- WM_manipulatormap_draw(
- ar->manipulator_map, draw_ctx->evil_C,
- WM_MANIPULATORMAP_DRAWSTEP_2D);
+ WM_gizmomap_draw(
+ ar->gizmo_map, draw_ctx->evil_C,
+ WM_GIZMOMAP_DRAWSTEP_2D);
glDepthMask(GL_TRUE);
}
diff --git a/source/blender/draw/intern/draw_view.h b/source/blender/draw/intern/draw_view.h
index 203420483a7..8f45a5fd786 100644
--- a/source/blender/draw/intern/draw_view.h
+++ b/source/blender/draw/intern/draw_view.h
@@ -30,7 +30,7 @@ void DRW_draw_grid(void);
void DRW_draw_region_info(void);
void DRW_draw_background(void);
void DRW_draw_cursor(void);
-void DRW_draw_manipulator_3d(void);
-void DRW_draw_manipulator_2d(void);
+void DRW_draw_gizmo_3d(void);
+void DRW_draw_gizmo_2d(void);
#endif /* __DRAW_VIEW_H__ */
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index 50ce29b7b1a..c8b8f678ca6 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -244,7 +244,7 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
{
Curve *cu = ob->data;
/* Get geometry cache */
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
geom = DRW_cache_curve_edge_wire_get(ob);
DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c
index 870dd14d677..ca7903c555b 100644
--- a/source/blender/draw/modes/edit_lattice_mode.c
+++ b/source/blender/draw/modes/edit_lattice_mode.c
@@ -196,7 +196,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob)
if (ob->type == OB_LATTICE) {
if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) {
/* Get geometry cache */
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
geom = DRW_cache_lattice_wire_get(ob, true);
DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index 700132e0ee4..67a424b8081 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -147,7 +147,7 @@ static int EDIT_MESH_sh_index(ToolSettings *tsettings, RegionView3D *rv3d, bool
return result;
}
-static char *EDIT_MESH_sh_defines(ToolSettings *tsettings, RegionView3D *rv3d, bool anti_alias)
+static char *EDIT_MESH_sh_defines(ToolSettings *tsettings, RegionView3D *rv3d, bool anti_alias, bool looseedge)
{
const int selectmode = tsettings->selectmode;
const int fast_mode = rv3d->rflag & RV3D_NAVIGATING;
@@ -174,7 +174,10 @@ static char *EDIT_MESH_sh_defines(ToolSettings *tsettings, RegionView3D *rv3d, b
if (anti_alias) {
BLI_dynstr_append(ds, "#define ANTI_ALIASING\n");
}
- BLI_dynstr_append(ds, "#define VERTEX_FACING\n");
+
+ if (!looseedge) {
+ BLI_dynstr_append(ds, "#define VERTEX_FACING\n");
+ }
str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
@@ -198,7 +201,7 @@ static GPUShader *EDIT_MESH_ensure_shader(ToolSettings *tsettings, RegionView3D
const int index = EDIT_MESH_sh_index(tsettings, rv3d, fast_mode);
if (looseedge) {
if (!e_data.overlay_loose_edge_sh_cache[index]) {
- char *defines = EDIT_MESH_sh_defines(tsettings, rv3d, true);
+ char *defines = EDIT_MESH_sh_defines(tsettings, rv3d, true, true);
char *lib = EDIT_MESH_sh_lib();
e_data.overlay_loose_edge_sh_cache[index] = DRW_shader_create_with_lib(
datatoc_edit_mesh_overlay_vert_glsl,
@@ -213,7 +216,7 @@ static GPUShader *EDIT_MESH_ensure_shader(ToolSettings *tsettings, RegionView3D
}
else {
if (!e_data.overlay_tri_sh_cache[index]) {
- char *defines = EDIT_MESH_sh_defines(tsettings, rv3d, true);
+ char *defines = EDIT_MESH_sh_defines(tsettings, rv3d, true, false);
char *lib = EDIT_MESH_sh_lib();
e_data.overlay_tri_sh_cache[index] = DRW_shader_create_with_lib(
datatoc_edit_mesh_overlay_vert_glsl,
@@ -362,7 +365,7 @@ static void EDIT_MESH_cache_init(void *vedata)
const bool xray_enabled = ((draw_ctx->v3d->shading.flag & V3D_SHADING_XRAY) != 0) &&
- (draw_ctx->v3d->drawtype < OB_MATERIAL);
+ (draw_ctx->v3d->shading.type < OB_MATERIAL);
stl->g_data->do_zbufclip = ((v3d->flag & V3D_ZBUF_SELECT) == 0) || xray_enabled;
{
@@ -429,7 +432,7 @@ static void EDIT_MESH_cache_init(void *vedata)
DRW_shgroup_uniform_block(stl->g_data->facefill_occluded_shgrp, "globalsBlock", globals_ubo);
/* we need a full screen pass to combine the result */
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
psl->mix_occlude = DRW_pass_create(
"Mix Occluded Wires",
@@ -447,7 +450,7 @@ static void edit_mesh_add_ob_to_pass(
Scene *scene, Object *ob, DRWShadingGroup *face_shgrp, DRWShadingGroup *ledges_shgrp,
DRWShadingGroup *lverts_shgrp, DRWShadingGroup *facedot_shgrp, DRWShadingGroup *facefill_shgrp)
{
- struct Gwn_Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter;
+ struct GPUBatch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter;
ToolSettings *tsettings = scene->toolsettings;
DRW_cache_mesh_wire_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts);
@@ -474,7 +477,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
Scene *scene = draw_ctx->scene;
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
if (ob->type == OB_MESH) {
if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) {
@@ -509,7 +512,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
}
if (vnormals_do || lnormals_do) {
- struct Gwn_Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts;
+ struct GPUBatch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts;
DRW_cache_mesh_normals_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts);
if (vnormals_do) {
diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c
index def96e79eba..56a015d0e6b 100644
--- a/source/blender/draw/modes/edit_mesh_mode_text.c
+++ b/source/blender/draw/modes/edit_mesh_mode_text.c
@@ -63,7 +63,7 @@ void DRW_edit_mesh_mode_text_measure_stats(
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 */
+ uchar col[4] = {0, 0, 0, 255}; /* color of the text to draw */
float area; /* area of the face */
float grid = unit->system ? unit->scale_length : v3d->grid;
const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0;
diff --git a/source/blender/draw/modes/edit_surface_mode.c b/source/blender/draw/modes/edit_surface_mode.c
index 7074ba3d024..3c5d0dbf5a1 100644
--- a/source/blender/draw/modes/edit_surface_mode.c
+++ b/source/blender/draw/modes/edit_surface_mode.c
@@ -180,7 +180,7 @@ static void EDIT_SURFACE_cache_populate(void *vedata, Object *ob)
if (ob->type == OB_MESH) {
/* Get geometry cache */
- struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob);
/* Add geom to a shading group */
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c
index 5750dc8a0b9..f21715ef399 100644
--- a/source/blender/draw/modes/edit_text_mode.c
+++ b/source/blender/draw/modes/edit_text_mode.c
@@ -197,7 +197,7 @@ static void EDIT_TEXT_cache_populate(void *vedata, Object *ob)
if (ob == draw_ctx->object_edit) {
const Curve *cu = ob->data;
/* Get geometry cache */
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
if (cu->flag & CU_FAST) {
geom = DRW_cache_text_edge_wire_get(ob);
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 736bde725ae..9e9785f5e5c 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -32,10 +32,12 @@
#include "DNA_curve_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
+#include "DNA_modifier_types.h"
#include "DNA_object_force_types.h"
#include "DNA_lightprobe_types.h"
#include "DNA_particle_types.h"
#include "DNA_rigidbody_types.h"
+#include "DNA_smoke_types.h"
#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
@@ -49,6 +51,7 @@
#include "BKE_global.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
+#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_image.h"
@@ -58,6 +61,7 @@
#include "GPU_shader.h"
#include "GPU_texture.h"
+#include "GPU_draw.h"
#include "MEM_guardedalloc.h"
@@ -141,6 +145,9 @@ typedef struct OBJECT_PrivateData {
DRWShadingGroup *cube;
DRWShadingGroup *circle;
DRWShadingGroup *sphere;
+ DRWShadingGroup *cylinder;
+ DRWShadingGroup *capsule_cap;
+ DRWShadingGroup *capsule_body;
DRWShadingGroup *cone;
DRWShadingGroup *single_arrow;
DRWShadingGroup *single_arrow_line;
@@ -248,9 +255,9 @@ typedef struct OBJECT_PrivateData {
static struct {
/* Instance Data format */
- struct Gwn_VertFormat *particle_format;
- struct Gwn_VertFormat *empty_image_format;
- struct Gwn_VertFormat *empty_image_wire_format;
+ struct GPUVertFormat *particle_format;
+ struct GPUVertFormat *empty_image_format;
+ struct GPUVertFormat *empty_image_wire_format;
/* fullscreen shaders */
GPUShader *outline_prepass_sh;
@@ -286,6 +293,8 @@ static struct {
struct GPUTexture *outlines_id_tx;
struct GPUTexture *outlines_color_tx;
struct GPUTexture *outlines_blur_tx;
+
+ ListBase smoke_domains;
} e_data = {NULL}; /* Engine data */
@@ -468,33 +477,54 @@ static void OBJECT_engine_init(void *vedata)
if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) {
e_data.grid_flag = PLANE_YZ;
- e_data.grid_flag |= SHOW_AXIS_Y;
- e_data.grid_flag |= SHOW_AXIS_Z;
- e_data.grid_flag |= SHOW_GRID;
- e_data.grid_flag |= GRID_BACK;
+ if (show_axis_y) {
+ e_data.grid_flag |= SHOW_AXIS_Y;
+ }
+ if (show_axis_z) {
+ e_data.grid_flag |= SHOW_AXIS_Z;
+ }
+ if (show_floor) {
+ e_data.grid_flag |= SHOW_GRID;
+ e_data.grid_flag |= GRID_BACK;
+ }
}
else if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) {
e_data.grid_flag = PLANE_XY;
- e_data.grid_flag |= SHOW_AXIS_X;
- e_data.grid_flag |= SHOW_AXIS_Y;
- e_data.grid_flag |= SHOW_GRID;
- e_data.grid_flag |= GRID_BACK;
+ if (show_axis_x) {
+ e_data.grid_flag |= SHOW_AXIS_X;
+ }
+ if (show_axis_y) {
+ e_data.grid_flag |= SHOW_AXIS_Y;
+ }
+ if (show_floor) {
+ e_data.grid_flag |= SHOW_GRID;
+ e_data.grid_flag |= GRID_BACK;
+ }
}
else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) {
e_data.grid_flag = PLANE_XZ;
- e_data.grid_flag |= SHOW_AXIS_X;
- e_data.grid_flag |= SHOW_AXIS_Z;
- e_data.grid_flag |= SHOW_GRID;
- e_data.grid_flag |= GRID_BACK;
+ if (show_axis_x) {
+ e_data.grid_flag |= SHOW_AXIS_X;
+ }
+ if (show_axis_z) {
+ e_data.grid_flag |= SHOW_AXIS_Z;
+ }
+ if (show_floor) {
+ e_data.grid_flag |= SHOW_GRID;
+ e_data.grid_flag |= GRID_BACK;
+ }
}
else { /* RV3D_VIEW_USER */
e_data.grid_flag = PLANE_XY;
- if (show_axis_x)
+ if (show_axis_x) {
e_data.grid_flag |= SHOW_AXIS_X;
- if (show_axis_y)
+ }
+ if (show_axis_y) {
e_data.grid_flag |= SHOW_AXIS_Y;
- if (show_floor)
+ }
+ if (show_floor) {
e_data.grid_flag |= SHOW_GRID;
+ }
}
}
@@ -821,7 +851,7 @@ static void DRW_shgroup_empty_image(
{"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
});
- struct Gwn_Batch *geom = DRW_cache_image_plane_get();
+ struct GPUBatch *geom = DRW_cache_image_plane_get();
DRWShadingGroup *grp = DRW_shgroup_instance_create(
e_data.object_empty_image_sh, psl->non_meshes, geom, e_data.empty_image_format);
DRW_shgroup_uniform_texture(grp, "image", tex);
@@ -835,13 +865,13 @@ static void DRW_shgroup_empty_image(
{
DRW_shgroup_instance_format(e_data.empty_image_wire_format, {
- {"objectColor", DRW_ATTRIB_FLOAT, 4},
+ {"color", DRW_ATTRIB_FLOAT, 4},
{"size", DRW_ATTRIB_FLOAT, 1},
{"offset", DRW_ATTRIB_FLOAT, 2},
{"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
});
- struct Gwn_Batch *geom = DRW_cache_image_plane_wire_get();
+ struct GPUBatch *geom = DRW_cache_image_plane_wire_get();
DRWShadingGroup *grp = DRW_shgroup_instance_create(
e_data.object_empty_image_wire_sh, psl->non_meshes, geom, e_data.empty_image_wire_format);
DRW_shgroup_uniform_vec2(grp, "aspect", empty_image_data->image_aspect, 1);
@@ -877,7 +907,7 @@ static void OBJECT_cache_init(void *vedata)
OBJECT_PrivateData *g_data;
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool xray_enabled = ((draw_ctx->v3d->shading.flag & V3D_SHADING_XRAY) != 0) &&
- (draw_ctx->v3d->drawtype < OB_MATERIAL);
+ (draw_ctx->v3d->shading.type < OB_MATERIAL);
/* TODO : use dpi setting for enabling the second pass */
const bool do_outline_expand = false;
@@ -908,10 +938,10 @@ static void OBJECT_cache_init(void *vedata)
}
{
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_POINT;
DRWPass *pass = psl->lightprobes = DRW_pass_create("Object Probe Pass", state);
- struct Gwn_Batch *sphere = DRW_cache_sphere_get();
- struct Gwn_Batch *quad = DRW_cache_quad_get();
+ struct GPUBatch *sphere = DRW_cache_sphere_get();
+ struct GPUBatch *quad = DRW_cache_quad_get();
/* Cubemap */
g_data->lightprobes_cube_select = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_select);
@@ -930,7 +960,7 @@ static void OBJECT_cache_init(void *vedata)
{
DRWState state = DRW_STATE_WRITE_COLOR;
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
/* Don't occlude the "outline" detection pass if in xray mode (too much flickering). */
float alphaOcclu = (xray_enabled) ? 1.0f : 0.35f;
/* Reminder : bool uniforms need to be 4 bytes. */
@@ -970,7 +1000,7 @@ static void OBJECT_cache_init(void *vedata)
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND;
psl->outlines_resolve = DRW_pass_create("Outlines Resolve Pass", state);
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
GPUTexture **outline_tx = (do_outline_expand) ? &e_data.outlines_blur_tx : &e_data.outlines_color_tx;
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_aa_sh, psl->outlines_resolve);
@@ -984,7 +1014,7 @@ static void OBJECT_cache_init(void *vedata)
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND;
psl->grid = DRW_pass_create("Infinite Grid Pass", state);
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
static float mat[4][4];
unit_m4(mat);
@@ -1045,7 +1075,7 @@ static void OBJECT_cache_init(void *vedata)
{
/* Non Meshes Pass (Camera, empties, lamps ...) */
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
DRWState state =
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
@@ -1057,7 +1087,7 @@ static void OBJECT_cache_init(void *vedata)
geom = DRW_cache_plain_axes_get();
stl->g_data->plain_axes = shgroup_instance(psl->non_meshes, geom);
- geom = DRW_cache_cube_get();
+ geom = DRW_cache_empty_cube_get();
stl->g_data->cube = shgroup_instance(psl->non_meshes, geom);
geom = DRW_cache_circle_get();
@@ -1066,6 +1096,15 @@ static void OBJECT_cache_init(void *vedata)
geom = DRW_cache_empty_sphere_get();
stl->g_data->sphere = shgroup_instance(psl->non_meshes, geom);
+ geom = DRW_cache_empty_cylinder_get();
+ stl->g_data->cylinder = shgroup_instance(psl->non_meshes, geom);
+
+ geom = DRW_cache_empty_capsule_cap_get();
+ stl->g_data->capsule_cap = shgroup_instance(psl->non_meshes, geom);
+
+ geom = DRW_cache_empty_capsule_body_get();
+ stl->g_data->capsule_body = shgroup_instance(psl->non_meshes, geom);
+
geom = DRW_cache_empty_cone_get();
stl->g_data->cone = shgroup_instance(psl->non_meshes, geom);
@@ -1135,7 +1174,7 @@ static void OBJECT_cache_init(void *vedata)
stl->g_data->camera_mist_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
/* Texture Space */
- geom = DRW_cache_cube_get();
+ geom = DRW_cache_empty_cube_get();
stl->g_data->texspace = shgroup_instance(psl->non_meshes, geom);
}
@@ -1182,7 +1221,7 @@ static void OBJECT_cache_init(void *vedata)
/* TODO
* for now we create multiple times the same VBO with only lamp center coordinates
* but ideally we would only create it once */
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
/* start with buflimit because we don't want stipples */
geom = DRW_cache_single_line_get();
@@ -1234,7 +1273,7 @@ static void OBJECT_cache_init(void *vedata)
{
/* -------- STIPPLES ------- */
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
/* Relationship Lines */
stl->g_data->relationship_lines = shgroup_dynlines_dashed_uniform_color(psl->non_meshes, ts.colorWire);
@@ -1355,14 +1394,14 @@ static void DRW_shgroup_lamp(OBJECT_StorageList *stl, Object *ob, ViewLayer *vie
static float zero = 0.0f;
typedef struct LampEngineData {
- ObjectEngineData engine_data;
+ DrawData dd;
float shape_mat[4][4];
float spot_blend_mat[4][4];
} LampEngineData;
LampEngineData *lamp_engine_data =
- (LampEngineData *)DRW_object_engine_data_ensure(
- ob,
+ (LampEngineData *)DRW_drawdata_ensure(
+ &ob->id,
&draw_engine_object_type,
sizeof(LampEngineData),
NULL,
@@ -1702,6 +1741,85 @@ static void DRW_shgroup_forcefield(OBJECT_StorageList *stl, Object *ob, ViewLaye
}
}
+static void DRW_shgroup_volume_extra(
+ OBJECT_PassList *psl, OBJECT_StorageList *stl,
+ Object *ob, ViewLayer *view_layer, Scene *scene, ModifierData *md)
+{
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ SmokeDomainSettings *sds = smd->domain;
+ float *color;
+ float one = 1.0f;
+
+ if (sds == NULL) {
+ return;
+ }
+
+ DRW_object_wire_theme_get(ob, view_layer, &color);
+
+ /* Small cube showing voxel size. */
+ float voxel_cubemat[4][4] = {{0.0f}};
+ voxel_cubemat[0][0] = 1.0f / (float)sds->res[0];
+ voxel_cubemat[1][1] = 1.0f / (float)sds->res[1];
+ voxel_cubemat[2][2] = 1.0f / (float)sds->res[2];
+ voxel_cubemat[3][0] = voxel_cubemat[3][1] = voxel_cubemat[3][2] = -1.0f;
+ voxel_cubemat[3][3] = 1.0f;
+ translate_m4(voxel_cubemat, 1.0f, 1.0f, 1.0f);
+ mul_m4_m4m4(voxel_cubemat, ob->obmat, voxel_cubemat);
+
+ DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &one, voxel_cubemat);
+
+ /* Don't show smoke before simulation starts, this could be made an option in the future. */
+ if (!sds->draw_velocity || !sds->fluid || CFRA < sds->point_cache[0]->startframe) {
+ return;
+ }
+
+ const bool use_needle = (sds->vector_draw_type == VECTOR_DRAW_NEEDLE);
+ int line_count = (use_needle) ? 6 : 1;
+ int slice_axis = -1;
+ line_count *= sds->res[0] * sds->res[1] * sds->res[2];
+
+ if (sds->slice_method == MOD_SMOKE_SLICE_AXIS_ALIGNED &&
+ sds->axis_slice_method == AXIS_SLICE_SINGLE)
+ {
+ float invviewmat[4][4];
+ DRW_viewport_matrix_get(invviewmat, DRW_MAT_VIEWINV);
+
+ const int axis = (sds->slice_axis == SLICE_AXIS_AUTO)
+ ? axis_dominant_v3_single(invviewmat[2])
+ : sds->slice_axis - 1;
+ slice_axis = axis;
+ line_count /= sds->res[axis];
+ }
+
+ GPU_create_smoke_velocity(smd);
+
+ DRWShadingGroup *grp = DRW_shgroup_create(volume_velocity_shader_get(use_needle), psl->non_meshes);
+ DRW_shgroup_uniform_texture(grp, "velocityX", sds->tex_velocity_x);
+ DRW_shgroup_uniform_texture(grp, "velocityY", sds->tex_velocity_y);
+ DRW_shgroup_uniform_texture(grp, "velocityZ", sds->tex_velocity_z);
+ DRW_shgroup_uniform_float_copy(grp, "displaySize", sds->vector_scale);
+ DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth);
+ DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis);
+ DRW_shgroup_call_procedural_lines_add(grp, line_count, ob->obmat);
+
+ BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(smd));
+}
+
+static void volumes_free_smoke_textures(void)
+{
+ /* Free Smoke Textures after rendering */
+ /* XXX This is a waste of processing and GPU bandwidth if nothing
+ * is updated. But the problem is since Textures are stored in the
+ * modifier we don't want them to take precious VRAM if the
+ * modifier is not used for display. We should share them for
+ * all viewport in a redraw at least. */
+ for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) {
+ SmokeModifierData *smd = (SmokeModifierData *)link->data;
+ GPU_free_smoke(smd);
+ }
+ BLI_freelistN(&e_data.smoke_domains);
+}
+
static void DRW_shgroup_speaker(OBJECT_StorageList *stl, Object *ob, ViewLayer *view_layer)
{
float *color;
@@ -1712,7 +1830,7 @@ static void DRW_shgroup_speaker(OBJECT_StorageList *stl, Object *ob, ViewLayer *
}
typedef struct OBJECT_LightProbeEngineData {
- ObjectEngineData engine_data;
+ DrawData dd;
float prb_mats[6][4][4];
float probe_cube_mat[4][4];
@@ -1733,8 +1851,8 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl
int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color);
OBJECT_LightProbeEngineData *prb_data =
- (OBJECT_LightProbeEngineData *)DRW_object_engine_data_ensure(
- ob,
+ (OBJECT_LightProbeEngineData *)DRW_drawdata_ensure(
+ &ob->id,
&draw_engine_object_type,
sizeof(OBJECT_LightProbeEngineData),
NULL,
@@ -1785,15 +1903,17 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl
DRW_shgroup_uniform_vec3(grp, "increment_y", prb_data->increment_y, 1);
DRW_shgroup_uniform_vec3(grp, "increment_z", prb_data->increment_z, 1);
DRW_shgroup_uniform_ivec3(grp, "grid_resolution", &prb->grid_resolution_x, 1);
- DRW_shgroup_uniform_float(grp, "sphere_size", &prb->data_draw_size, 1);
- DRW_shgroup_call_instances_add(grp, DRW_cache_sphere_get(), NULL, &prb_data->cell_count);
+ DRW_shgroup_call_procedural_points_add(grp, prb_data->cell_count, NULL);
}
else if (prb->type == LIGHTPROBE_TYPE_CUBE) {
- prb_data->draw_size = prb->data_draw_size * 0.1f;
- unit_m4(prb_data->probe_cube_mat);
- copy_v3_v3(prb_data->probe_cube_mat[3], ob->obmat[3]);
+ // prb_data->draw_size = prb->data_draw_size * 0.1f;
+ // unit_m4(prb_data->probe_cube_mat);
+ // copy_v3_v3(prb_data->probe_cube_mat[3], ob->obmat[3]);
DRWShadingGroup *grp = shgroup_theme_id_to_probe_cube_outline_shgrp(stl, theme_id);
+ /* TODO remove or change the drawing of the cube probes. Theses line draws nothing on purpose
+ * to keep the call ids correct. */
+ zero_m4(prb_data->probe_cube_mat);
DRW_shgroup_call_dynamic_add(grp, call_id, &prb_data->draw_size, prb_data->probe_cube_mat);
}
else {
@@ -1952,6 +2072,10 @@ static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob)
static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob, ViewLayer *view_layer, View3D *v3d)
{
+ if (v3d->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_ORIGINS) {
+ return;
+ }
+
const bool is_library = ob->id.us > 1 || ID_IS_LINKED(ob);
DRWShadingGroup *shgroup;
@@ -2034,6 +2158,82 @@ static void DRW_shgroup_texture_space(OBJECT_StorageList *stl, Object *ob, int t
DRW_shgroup_call_dynamic_add(stl->g_data->texspace, color, &one, tmp);
}
+static void DRW_shgroup_bounds(OBJECT_StorageList *stl, Object *ob, int theme_id)
+{
+ float color[4], center[3], size[3], tmp[4][4], final_mat[4][4], one = 1.0f;
+ BoundBox bb_local;
+
+ if (ob->type == OB_MBALL && !BKE_mball_is_basis(ob)) {
+ return;
+ }
+
+ BoundBox *bb = BKE_object_boundbox_get(ob);
+
+ if (!ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT,
+ OB_MBALL, OB_ARMATURE, OB_LATTICE))
+ {
+ const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f};
+ bb = &bb_local;
+ BKE_boundbox_init_from_minmax(bb, min, max);
+ }
+
+ UI_GetThemeColor4fv(theme_id, color);
+ BKE_boundbox_calc_center_aabb(bb, center);
+ BKE_boundbox_calc_size_aabb(bb, size);
+
+ switch (ob->boundtype) {
+ case OB_BOUND_BOX:
+ size_to_mat4(tmp, size);
+ copy_v3_v3(tmp[3], center);
+ mul_m4_m4m4(tmp, ob->obmat, tmp);
+ DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &one, tmp);
+ break;
+ case OB_BOUND_SPHERE:
+ size[0] = max_fff(size[0], size[1], size[2]);
+ size[1] = size[2] = size[0];
+ size_to_mat4(tmp, size);
+ copy_v3_v3(tmp[3], center);
+ mul_m4_m4m4(tmp, ob->obmat, tmp);
+ DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, &one, tmp);
+ break;
+ case OB_BOUND_CYLINDER:
+ size[0] = max_ff(size[0], size[1]);
+ size[1] = size[0];
+ size_to_mat4(tmp, size);
+ copy_v3_v3(tmp[3], center);
+ mul_m4_m4m4(tmp, ob->obmat, tmp);
+ DRW_shgroup_call_dynamic_add(stl->g_data->cylinder, color, &one, tmp);
+ break;
+ case OB_BOUND_CONE:
+ size[0] = max_ff(size[0], size[1]);
+ size[1] = size[0];
+ size_to_mat4(tmp, size);
+ copy_v3_v3(tmp[3], center);
+ /* Cone batch has base at 0 and is pointing towards +Y. */
+ swap_v3_v3(tmp[1], tmp[2]);
+ tmp[3][2] -= size[2];
+ mul_m4_m4m4(tmp, ob->obmat, tmp);
+ DRW_shgroup_call_dynamic_add(stl->g_data->cone, color, &one, tmp);
+ break;
+ case OB_BOUND_CAPSULE:
+ size[0] = max_ff(size[0], size[1]);
+ size[1] = size[0];
+ scale_m4_fl(tmp, size[0]);
+ copy_v2_v2(tmp[3], center);
+ tmp[3][2] = center[2] + max_ff(0.0f, size[2] - size[0]);
+ mul_m4_m4m4(final_mat, ob->obmat, tmp);
+ DRW_shgroup_call_dynamic_add(stl->g_data->capsule_cap, color, &one, final_mat);
+ negate_v3(tmp[2]);
+ tmp[3][2] = center[2] - max_ff(0.0f, size[2] - size[0]);
+ mul_m4_m4m4(final_mat, ob->obmat, tmp);
+ DRW_shgroup_call_dynamic_add(stl->g_data->capsule_cap, color, &one, final_mat);
+ tmp[2][2] = max_ff(0.0f, size[2] * 2.0f - size[0] * 2.0f);
+ mul_m4_m4m4(final_mat, ob->obmat, tmp);
+ DRW_shgroup_call_dynamic_add(stl->g_data->capsule_body, color, &one, final_mat);
+ break;
+ }
+}
+
static void OBJECT_cache_populate_particles(Object *ob,
OBJECT_PassList *psl)
{
@@ -2052,7 +2252,7 @@ static void OBJECT_cache_populate_particles(Object *ob,
unit_m4(mat);
if (draw_as != PART_DRAW_PATH) {
- struct Gwn_Batch *geom = DRW_cache_particles_get_dots(ob, psys);
+ struct GPUBatch *geom = DRW_cache_particles_get_dots(ob, psys);
DRWShadingGroup *shgrp = NULL;
static int screen_space[2] = {0, 1};
static float def_prim_col[3] = {0.5f, 0.5f, 0.5f};
@@ -2115,7 +2315,9 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
ViewLayer *view_layer = draw_ctx->view_layer;
+ Scene *scene = draw_ctx->scene;
View3D *v3d = draw_ctx->v3d;
+ ModifierData *md = NULL;
int theme_id = TH_UNDEFINED;
/* Handle particles first in case the emitter itself shouldn't be rendered. */
@@ -2129,12 +2331,13 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
bool do_outlines = (draw_ctx->v3d->flag & V3D_SELECT_OUTLINE) && ((ob->base_flag & BASE_SELECTED) != 0);
bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0);
+ const bool hide_object_extra = (v3d->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) != 0;
if (do_outlines) {
if ((ob != draw_ctx->object_edit) && !((ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT))) {
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
const bool xray_enabled = ((v3d->shading.flag & V3D_SHADING_XRAY) != 0) &&
- (v3d->drawtype < OB_MATERIAL);
+ (v3d->shading.type < OB_MATERIAL);
if (xray_enabled) {
geom = DRW_cache_object_edge_detection_get(ob, NULL);
}
@@ -2154,10 +2357,13 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
switch (ob->type) {
case OB_MESH:
{
+ if (hide_object_extra) {
+ break;
+ }
if (ob != draw_ctx->object_edit) {
Mesh *me = ob->data;
if (me->totedge == 0) {
- struct Gwn_Batch *geom = DRW_cache_mesh_verts_get(ob);
+ struct GPUBatch *geom = DRW_cache_mesh_verts_get(ob);
if (geom) {
if (theme_id == TH_UNDEFINED) {
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
@@ -2168,7 +2374,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
}
}
else {
- struct Gwn_Batch *geom = DRW_cache_mesh_loose_edges_get(ob);
+ struct GPUBatch *geom = DRW_cache_mesh_loose_edges_get(ob);
if (geom) {
if (theme_id == TH_UNDEFINED) {
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
@@ -2186,7 +2392,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
case OB_LATTICE:
{
if (ob != draw_ctx->object_edit) {
- struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false);
+ if (hide_object_extra) {
+ break;
+ }
+ struct GPUBatch *geom = DRW_cache_lattice_wire_get(ob, false);
if (theme_id == TH_UNDEFINED) {
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
@@ -2196,11 +2405,13 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
}
break;
}
-
case OB_CURVE:
{
if (ob != draw_ctx->object_edit) {
- struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob);
+ if (hide_object_extra) {
+ break;
+ }
+ struct GPUBatch *geom = DRW_cache_curve_edge_wire_get(ob);
if (theme_id == TH_UNDEFINED) {
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
@@ -2217,22 +2428,40 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
break;
}
case OB_LAMP:
+ if (hide_object_extra) {
+ break;
+ }
DRW_shgroup_lamp(stl, ob, view_layer);
break;
case OB_CAMERA:
- DRW_shgroup_camera(stl, ob, view_layer);
+ if (hide_object_extra) {
+ break;
+ }
+ DRW_shgroup_camera(stl, ob, view_layer);
break;
case OB_EMPTY:
+ if (hide_object_extra) {
+ break;
+ }
DRW_shgroup_empty(stl, psl, ob, view_layer);
break;
case OB_SPEAKER:
+ if (hide_object_extra) {
+ break;
+ }
DRW_shgroup_speaker(stl, ob, view_layer);
break;
case OB_LIGHTPROBE:
+ if (hide_object_extra) {
+ break;
+ }
DRW_shgroup_lightprobe(stl, psl, ob, view_layer);
break;
case OB_ARMATURE:
{
+ if (v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES) {
+ break;
+ }
bArmature *arm = ob->data;
if (arm->edbo == NULL) {
if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) {
@@ -2259,7 +2488,6 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
/* don't show object extras in set's */
if ((ob->base_flag & (BASE_FROM_SET | BASE_FROMDUPLI)) == 0) {
-
DRW_shgroup_object_center(stl, ob, view_layer, v3d);
if (show_relations) {
@@ -2273,7 +2501,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
if ((ob->dtx & OB_DRAWNAME) && DRW_state_show_text()) {
struct DRWTextStore *dt = DRW_text_cache_ensure();
- unsigned char color[4];
+ uchar color[4];
UI_GetThemeColor4ubv(theme_id, color);
DRW_text_cache_add(
@@ -2285,6 +2513,17 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
if ((ob->dtx & OB_TEXSPACE) && ELEM(ob->type, OB_MESH, OB_CURVE, OB_MBALL)) {
DRW_shgroup_texture_space(stl, ob, theme_id);
}
+
+ if (ob->dtx & OB_DRAWBOUNDOX) {
+ DRW_shgroup_bounds(stl, ob, theme_id);
+ }
+
+ if ((md = modifiers_findByType(ob, eModifierType_Smoke)) &&
+ (modifier_isEnabled(scene, md, eModifierMode_Realtime)) &&
+ (((SmokeModifierData *)md)->domain != NULL))
+ {
+ DRW_shgroup_volume_extra(psl, stl, ob, view_layer, scene, md);
+ }
}
}
@@ -2383,6 +2622,8 @@ static void OBJECT_draw_scene(void *vedata)
BLI_ghash_free(stl->g_data->image_plane_map, NULL, MEM_freeN);
stl->g_data->image_plane_map = NULL;
}
+
+ volumes_free_smoke_textures();
}
static const DrawEngineDataSize OBJECT_data_size = DRW_VIEWPORT_DATA_SIZE(OBJECT_Data);
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index a67c7ffb131..e3c986bde5a 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -175,7 +175,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
return;
if (stl->g_data->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) {
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
DRW_shgroup_call_add(pd->face_orientation_shgrp, geom, ob->obmat);
}
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index 85cff28b313..8256bb4d0d7 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -293,9 +293,9 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
if (use_surface) {
if (me->mloopuv != NULL) {
if (use_material_slots) {
- struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
+ struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
if ((me->totcol == 0) || (geom_array == NULL)) {
- struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
ok = true;
}
@@ -312,7 +312,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
}
}
else {
- struct Gwn_Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
+ struct GPUBatch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
if (geom && stl->g_data->shgroup_image_array[0]) {
DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
ok = true;
@@ -321,7 +321,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
}
if (!ok) {
- struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
}
}
@@ -329,7 +329,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
/* Face Mask */
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
if (use_face_sel) {
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
/* Note: ideally selected faces wouldn't show interior wire. */
const bool use_wire = true;
geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, use_face_sel);
diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c
index 9cf6ea52d33..33af72e8616 100644
--- a/source/blender/draw/modes/paint_vertex_mode.c
+++ b/source/blender/draw/modes/paint_vertex_mode.c
@@ -150,7 +150,7 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0;
const bool use_surface = v3d->overlay.vertex_paint_mode_opacity != 0.0f;
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
if (use_surface) {
geom = DRW_cache_mesh_surface_vert_colors_get(ob);
diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c
index 2b510a9a4c9..d4fc73e7f88 100644
--- a/source/blender/draw/modes/paint_weight_mode.c
+++ b/source/blender/draw/modes/paint_weight_mode.c
@@ -38,6 +38,8 @@
#include "BKE_mesh.h"
+#include "DEG_depsgraph_query.h"
+
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
extern struct GlobalsUboStorage ts; /* draw_common.c */
@@ -181,12 +183,14 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
const View3D *v3d = draw_ctx->v3d;
if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) {
+ /* We're always painting on original, display original data. */
+ ob = DEG_get_original_object(ob);
const Mesh *me = ob->data;
const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0;
const bool use_surface = v3d->overlay.weight_paint_mode_opacity != 0.0f;
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
- struct Gwn_Batch *geom;
+ struct GPUBatch *geom;
if (use_surface) {
geom = DRW_cache_mesh_surface_weights_get(ob);
diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c
index 19c3ddd4b50..f4879483540 100644
--- a/source/blender/draw/modes/particle_mode.c
+++ b/source/blender/draw/modes/particle_mode.c
@@ -148,17 +148,17 @@ static void particle_edit_cache_populate(void *vedata,
const DRWContextState *draw_ctx = DRW_context_state_get();
ParticleEditSettings *pset = PE_settings(draw_ctx->scene);
{
- struct Gwn_Batch *strands =
+ struct GPUBatch *strands =
DRW_cache_particles_get_edit_strands(object, psys, edit);
DRW_shgroup_call_add(stl->g_data->strands_group, strands, NULL);
}
if (pset->selectmode == SCE_SELECT_POINT) {
- struct Gwn_Batch *points =
+ struct GPUBatch *points =
DRW_cache_particles_get_edit_inner_points(object, psys, edit);
DRW_shgroup_call_add(stl->g_data->inner_points_group, points, NULL);
}
if (ELEM(pset->selectmode, SCE_SELECT_POINT, SCE_SELECT_END)) {
- struct Gwn_Batch *points =
+ struct GPUBatch *points =
DRW_cache_particles_get_edit_tip_points(object, psys, edit);
DRW_shgroup_call_add(stl->g_data->tip_points_group, points, NULL);
}
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index ad9567cd9c0..040195b889b 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -87,7 +87,7 @@ static bool POSE_is_bone_selection_overlay_active(void)
{
const DRWContextState *dcs = DRW_context_state_get();
const View3D *v3d = dcs->v3d;
- return v3d && (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECTION);
+ return v3d && (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT) && OBPOSE_FROM_OBACT(dcs->obact);
}
static void POSE_engine_init(void *UNUSED(vedata))
@@ -155,8 +155,8 @@ static void POSE_cache_init(void *vedata)
{
if (POSE_is_bone_selection_overlay_active()) {
- copy_v4_fl4(ppd->blend_color, 0.0f, 0.0f, 0.0f, v3d->overlay.bone_selection_alpha);
- copy_v4_fl4(ppd->blend_color_invert, 0.0f, 0.0f, 0.0f, pow(v3d->overlay.bone_selection_alpha, 4));
+ copy_v4_fl4(ppd->blend_color, 0.0f, 0.0f, 0.0f, v3d->overlay.bone_select_alpha);
+ copy_v4_fl4(ppd->blend_color_invert, 0.0f, 0.0f, 0.0f, pow(v3d->overlay.bone_select_alpha, 4));
DRWShadingGroup *grp;
psl->bone_selection = DRW_pass_create(
"Bone Selection",
@@ -198,10 +198,13 @@ static void POSE_cache_populate(void *vedata, Object *ob)
POSE_StorageList *stl = ((POSE_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
- /* In the future this will allow us to implement face manipulators,
+ /* In the future this will allow us to implement face gizmos,
* and similar functionalities. For now we handle only pose bones. */
if (ob->type == OB_ARMATURE) {
+ if (draw_ctx->v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES) {
+ return;
+ }
if (DRW_pose_mode_armature(ob, draw_ctx->obact)) {
DRWArmaturePasses passes = {
.bone_solid = psl->bone_solid,
@@ -218,7 +221,7 @@ static void POSE_cache_populate(void *vedata, Object *ob)
!DRW_state_is_select() &&
POSE_is_bone_selection_overlay_active())
{
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
if (POSE_is_driven_by_active_armature(ob)) {
DRW_shgroup_call_object_add(stl->g_data->bone_selection_shgrp, geom, ob);
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
index 09d0b0a910d..fe9062a8d50 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
@@ -36,11 +36,10 @@ out vec4 FragColor;
void distToEdgeAndPoint(vec2 dir, vec2 ori, out float edge, out float point)
{
dir = normalize(dir.xy);
+ dir = vec2(-dir.y, dir.x);
vec2 of = gl_FragCoord.xy - ori;
- point = dot(of, of);
- float dof = dot(dir, of);
- edge = sqrt(abs(point - dof * dof));
- point = sqrt(point);
+ point = sqrt(dot(of, of));
+ edge = abs(dot(dir, of));
}
void colorDist(vec4 color, float dist)
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
index e0ec6e50dc2..f19c203a70d 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
@@ -96,11 +96,11 @@ void doLoopStrip(int v, vec3 offset)
void main()
{
/* Edge */
- ivec3 eflag; vec3 ecrease, ebweight;
+ ivec3 eflag;
for (int v = 0; v < 3; ++v) {
flag[v] = eflag[v] = vData[v].y | (vData[v].x << 8);
- edgesCrease[v] = ecrease[v] = vData[v].z / 255.0;
- edgesBweight[v] = ebweight[v] = vData[v].w / 255.0;
+ edgesCrease[v] = vData[v].z / 255.0;
+ edgesBweight[v] = vData[v].w / 255.0;
}
/* Face */
@@ -112,10 +112,9 @@ void main()
faceColor = colorFace;
/* Vertex */
- vec2 pos[3];
- ssPos[0] = pos[0] = proj(pPos[0]);
- ssPos[1] = pos[1] = proj(pPos[1]);
- ssPos[2] = pos[2] = proj(pPos[2]);
+ ssPos[0] = proj(pPos[0]);
+ ssPos[1] = proj(pPos[1]);
+ ssPos[2] = proj(pPos[2]);
doVertex(0);
doVertex(1);
diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl
index 2b04bb0d855..82780e0cddc 100644
--- a/source/blender/draw/modes/shaders/object_grid_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl
@@ -113,12 +113,15 @@ void main()
viewvec /= dist;
float angle;
- if ((gridFlag & PLANE_XZ) > 0)
+ if ((gridFlag & PLANE_XZ) != 0) {
angle = viewvec.y;
- else if ((gridFlag & PLANE_YZ) > 0)
+ }
+ else if ((gridFlag & PLANE_YZ) != 0) {
angle = viewvec.x;
- else
+ }
+ else {
angle = viewvec.z;
+ }
angle = 1.0 - abs(angle);
angle *= angle;
@@ -130,7 +133,7 @@ void main()
fade = 1.0 - smoothstep(0.0, 0.5, dist - 0.5);
dist = 1.0; /* avoid branch after */
- if ((gridFlag & PLANE_XY) > 0) {
+ if ((gridFlag & PLANE_XY) != 0) {
float angle = 1.0 - abs(eye.z);
dist = 1.0 + angle * 2.0;
angle *= angle;
@@ -138,7 +141,7 @@ void main()
}
}
- if ((gridFlag & GRID) > 0) {
+ if ((gridFlag & GRID) != 0) {
float grid_res = log(dist * gridResolution) * gridOneOverLogSubdiv;
float blend = fract(-max(grid_res, 0.0));
@@ -150,11 +153,11 @@ void main()
float scaleC = gridScale * pow(gridSubdiv, max(lvl + 1.0, 1.0));
vec2 grid_pos, grid_fwidth;
- if ((gridFlag & PLANE_XZ) > 0) {
+ if ((gridFlag & PLANE_XZ) != 0) {
grid_pos = wPos.xz;
grid_fwidth = fwidthPos.xz;
}
- else if ((gridFlag & PLANE_YZ) > 0) {
+ else if ((gridFlag & PLANE_YZ) != 0) {
grid_pos = wPos.yz;
grid_fwidth = fwidthPos.yz;
}
@@ -175,19 +178,19 @@ void main()
FragColor = vec4(colorGrid.rgb, 0.0);
}
- if ((gridFlag & (AXIS_X | AXIS_Y | AXIS_Z)) > 0) {
+ if ((gridFlag & (AXIS_X | AXIS_Y | AXIS_Z)) != 0) {
/* Setup axes 'domains' */
vec3 axes_dist, axes_fwidth;
- if ((gridFlag & AXIS_X) > 0) {
+ if ((gridFlag & AXIS_X) != 0) {
axes_dist.x = dot(wPos.yz, planeAxes.yz);
axes_fwidth.x = dot(fwidthPos.yz, planeAxes.yz);
}
- if ((gridFlag & AXIS_Y) > 0) {
+ if ((gridFlag & AXIS_Y) != 0) {
axes_dist.y = dot(wPos.xz, planeAxes.xz);
axes_fwidth.y = dot(fwidthPos.xz, planeAxes.xz);
}
- if ((gridFlag & AXIS_Z) > 0) {
+ if ((gridFlag & AXIS_Z) != 0) {
axes_dist.z = dot(wPos.xy, planeAxes.xy);
axes_fwidth.z = dot(fwidthPos.xy, planeAxes.xy);
}
@@ -195,19 +198,19 @@ void main()
/* Computing all axes at once using vec3 */
vec3 axes = get_axes(axes_dist, axes_fwidth, 0.1);
- if ((gridFlag & AXIS_X) > 0) {
+ if ((gridFlag & AXIS_X) != 0) {
FragColor = mix(FragColor, colorGridAxisX, axes.x);
}
- if ((gridFlag & AXIS_Y) > 0) {
+ if ((gridFlag & AXIS_Y) != 0) {
FragColor = mix(FragColor, colorGridAxisY, axes.y);
}
- if ((gridFlag & AXIS_Z) > 0) {
+ if ((gridFlag & AXIS_Z) != 0) {
FragColor = mix(FragColor, colorGridAxisZ, axes.z);
}
}
float scene_depth = texture(depthBuffer, sPos).r;
- if ((gridFlag & GRID_BACK) > 0) {
+ if ((gridFlag & GRID_BACK) != 0) {
fade *= (scene_depth == 1.0) ? 1.0 : 0.0;
}
else {
diff --git a/source/blender/draw/modes/shaders/object_grid_vert.glsl b/source/blender/draw/modes/shaders/object_grid_vert.glsl
index 3f99d8b5d0a..a346973a597 100644
--- a/source/blender/draw/modes/shaders/object_grid_vert.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_vert.glsl
@@ -27,11 +27,11 @@ void main()
vec3 vert_pos, proj_camera_pos;
/* Project camera pos to the needed plane */
- if ((gridFlag & PLANE_XY) > 0) {
+ if ((gridFlag & PLANE_XY) != 0) {
vert_pos = vec3(pos.x, pos.y, 0.0);
proj_camera_pos = vec3(cameraPos.x, cameraPos.y, 0.0);
}
- else if ((gridFlag & PLANE_XZ) > 0) {
+ else if ((gridFlag & PLANE_XZ) != 0) {
vert_pos = vec3(pos.x, 0.0, pos.y);
proj_camera_pos = vec3(cameraPos.x, 0.0, cameraPos.z);
}
@@ -52,10 +52,10 @@ void main()
vec3 realPos = proj_camera_pos + vert_pos;
/* Used for additional Z axis */
- if ((gridFlag & CLIP_Z_POS) > 0) {
+ if ((gridFlag & CLIP_Z_POS) != 0) {
realPos.z = max(realPos.z, 0.0);
}
- if ((gridFlag & CLIP_Z_NEG) > 0) {
+ if ((gridFlag & CLIP_Z_NEG) != 0) {
realPos.z = min(-realPos.z, 0.0);
}
diff --git a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl
index d9616076dbf..bcdf5adca55 100644
--- a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl
+++ b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl
@@ -1,7 +1,4 @@
-in vec3 pos;
-in vec3 nor;
-
uniform mat4 ViewProjectionMatrix;
uniform float sphere_size;
@@ -10,6 +7,7 @@ uniform vec3 corner;
uniform vec3 increment_x;
uniform vec3 increment_y;
uniform vec3 increment_z;
+uniform vec3 screen_vecs[2];
uniform int call_id; /* we don't want the builtin callId which would be 0. */
uniform int baseId;
@@ -20,16 +18,17 @@ void main()
{
vec3 ls_cell_location;
/* Keep in sync with update_irradiance_probe */
- ls_cell_location.z = float(gl_InstanceID % grid_resolution.z);
- ls_cell_location.y = float((gl_InstanceID / grid_resolution.z) % grid_resolution.y);
- ls_cell_location.x = float(gl_InstanceID / (grid_resolution.z * grid_resolution.y));
+ ls_cell_location.z = float(gl_VertexID % grid_resolution.z);
+ ls_cell_location.y = float((gl_VertexID / grid_resolution.z) % grid_resolution.y);
+ ls_cell_location.x = float(gl_VertexID / (grid_resolution.z * grid_resolution.y));
vec3 ws_cell_location = corner +
(increment_x * ls_cell_location.x +
increment_y * ls_cell_location.y +
increment_z * ls_cell_location.z);
- gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0);
+ gl_Position = ViewProjectionMatrix * vec4(ws_cell_location, 1.0);
+ gl_PointSize = 2.0f;
finalId = uint(baseId + call_id);
}
diff --git a/source/blender/draw/modes/shaders/volume_velocity_vert.glsl b/source/blender/draw/modes/shaders/volume_velocity_vert.glsl
new file mode 100644
index 00000000000..574c434920e
--- /dev/null
+++ b/source/blender/draw/modes/shaders/volume_velocity_vert.glsl
@@ -0,0 +1,115 @@
+
+uniform mat4 ModelViewProjectionMatrix;
+
+uniform sampler3D velocityX;
+uniform sampler3D velocityY;
+uniform sampler3D velocityZ;
+uniform float displaySize = 1.0;
+uniform float slicePosition;
+uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */
+
+flat out vec4 finalColor;
+
+const vec3 corners[4] = vec3[4](
+ vec3(0.0, 0.2, -0.5),
+ vec3(-0.2 * 0.866, -0.2 * 0.5, -0.5),
+ vec3(0.2 * 0.866, -0.2 * 0.5, -0.5),
+ vec3(0.0, 0.0, 0.5)
+);
+
+const int indices[12] = int[12](0, 1, 1, 2, 2, 0, 0, 3, 1, 3, 2, 3);
+
+/* Straight Port from BKE_defvert_weight_to_rgb()
+ * TODO port this to a color ramp. */
+vec3 weight_to_color(float weight)
+{
+ vec3 r_rgb = vec3(0.0);
+ float blend = ((weight / 2.0) + 0.5);
+
+ if (weight <= 0.25) { /* blue->cyan */
+ r_rgb.g = blend * weight * 4.0;
+ r_rgb.b = blend;
+ }
+ else if (weight <= 0.50) { /* cyan->green */
+ r_rgb.g = blend;
+ r_rgb.b = blend * (1.0 - ((weight - 0.25) * 4.0));
+ }
+ else if (weight <= 0.75) { /* green->yellow */
+ r_rgb.r = blend * ((weight - 0.50) * 4.0);
+ r_rgb.g = blend;
+ }
+ else if (weight <= 1.0) { /* yellow->red */
+ r_rgb.r = blend;
+ r_rgb.g = blend * (1.0 - ((weight - 0.75) * 4.0));
+ }
+ else {
+ /* exceptional value, unclamped or nan,
+ * avoid uninitialized memory use */
+ r_rgb = vec3(1.0, 0.0, 1.0);
+ }
+
+ return r_rgb;
+}
+
+mat3 rotation_from_vector(vec3 v)
+{
+ /* Add epsilon to avoid NaN. */
+ vec3 N = normalize(v + 1e-8);
+ vec3 UpVector = abs(N.z) < 0.99999 ? vec3(0.0,0.0,1.0) : vec3(1.0,0.0,0.0);
+ vec3 T = normalize(cross(UpVector, N));
+ vec3 B = cross(N, T);
+ return mat3(T, B, N);
+}
+
+void main()
+{
+#ifdef USE_NEEDLE
+ int cell = gl_VertexID / 12;
+#else
+ int cell = gl_VertexID / 2;
+#endif
+
+ ivec3 volume_size = textureSize(velocityX, 0);
+ float voxel_size = 1.0 / float(max(max(volume_size.x, volume_size.y), volume_size.z));
+
+ ivec3 cell_ofs = ivec3(0);
+ ivec3 cell_div = volume_size;
+ if (sliceAxis == 0) {
+ cell_ofs.x = int(slicePosition * float(volume_size.x));
+ cell_div.x = 1;
+ }
+ else if (sliceAxis == 1) {
+ cell_ofs.y = int(slicePosition * float(volume_size.y));
+ cell_div.y = 1;
+ }
+ else if (sliceAxis == 2) {
+ cell_ofs.z = int(slicePosition * float(volume_size.z));
+ cell_div.z = 1;
+ }
+
+ ivec3 cell_co;
+ cell_co.x = cell % cell_div.x;
+ cell_co.y = (cell / cell_div.x) % cell_div.y;
+ cell_co.z = cell / (cell_div.x * cell_div.y);
+ cell_co += cell_ofs;
+
+ vec3 pos = (vec3(cell_co) + 0.5) / vec3(volume_size);
+ pos = pos * 2.0 - 1.0;
+
+ vec3 velocity;
+ velocity.x = texelFetch(velocityX, cell_co, 0).r;
+ velocity.y = texelFetch(velocityY, cell_co, 0).r;
+ velocity.z = texelFetch(velocityZ, cell_co, 0).r;
+
+ finalColor = vec4(weight_to_color(length(velocity)), 1.0);
+
+#ifdef USE_NEEDLE
+ mat3 rot_mat = rotation_from_vector(velocity);
+ vec3 rotated_pos = rot_mat * corners[indices[gl_VertexID % 12]];
+ pos += rotated_pos * length(velocity) * displaySize * voxel_size;
+#else
+ pos += (((gl_VertexID % 2) == 1) ? velocity : vec3(0.0)) * displaySize * voxel_size;
+#endif
+
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+}
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index 2b30382f4a4..cf1db751c85 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -30,7 +30,7 @@ if(WITH_BLENDER)
add_subdirectory(interface)
add_subdirectory(io)
add_subdirectory(lattice)
- add_subdirectory(manipulator_library)
+ add_subdirectory(gizmo_library)
add_subdirectory(mask)
add_subdirectory(mesh)
add_subdirectory(metaball)
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index f0bde9dcdfb..3c10cda6456 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -146,7 +146,7 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
@@ -223,7 +223,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
else {
// FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
int colOfs = 20 - 20 * indent;
- UI_GetThemeColorShade3fv(TH_HEADER, colOfs, r_color);
+ UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, colOfs, r_color);
}
}
@@ -235,7 +235,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
@@ -638,7 +638,7 @@ static int acf_object_icon(bAnimListElem *ale)
/* icon depends on object-type */
switch (ob->type) {
case OB_LAMP:
- return ICON_OUTLINER_OB_LAMP;
+ return ICON_OUTLINER_OB_LIGHT;
case OB_MESH:
return ICON_OUTLINER_OB_MESH;
case OB_CAMERA:
@@ -1452,16 +1452,16 @@ static bAnimChannelType ACF_DSMAT =
acf_dsmat_setting_ptr /* pointer for setting */
};
-/* Lamp Expander ------------------------------------------- */
+/* Light Expander ------------------------------------------- */
// TODO: just get this from RNA?
-static int acf_dslam_icon(bAnimListElem *UNUSED(ale))
+static int acf_dslight_icon(bAnimListElem *UNUSED(ale))
{
- return ICON_LAMP_DATA;
+ return ICON_LIGHT_DATA;
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
+static int acf_dslight_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1486,7 +1486,7 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
}
/* get pointer to the setting */
-static void *acf_dslam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
+static void *acf_dslight_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Lamp *la = (Lamp *)ale->data;
@@ -1510,9 +1510,9 @@ static void *acf_dslam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
}
/* lamp expander type define */
-static bAnimChannelType ACF_DSLAM =
+static bAnimChannelType ACF_DSLIGHT =
{
- "Lamp Expander", /* type name */
+ "Light Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
@@ -1521,12 +1521,12 @@ static bAnimChannelType ACF_DSLAM =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_name_prop, /* name prop */
- acf_dslam_icon, /* icon */
+ acf_generic_idblock_name_prop, /* name prop */
+ acf_dslight_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
- acf_dslam_setting_flag, /* flag for setting */
- acf_dslam_setting_ptr /* pointer for setting */
+ acf_dslight_setting_flag, /* flag for setting */
+ acf_dslight_setting_ptr /* pointer for setting */
};
/* Texture Expander ------------------------------------------- */
@@ -3580,7 +3580,7 @@ static void ANIM_init_channel_typeinfo_data(void)
animchannelTypeInfo[type++] = &ACF_FILLDRIVERS; /* Drivers Expander */
animchannelTypeInfo[type++] = &ACF_DSMAT; /* Material Channel */
- animchannelTypeInfo[type++] = &ACF_DSLAM; /* Lamp Channel */
+ animchannelTypeInfo[type++] = &ACF_DSLIGHT; /* Light Channel */
animchannelTypeInfo[type++] = &ACF_DSCAM; /* Camera Channel */
animchannelTypeInfo[type++] = &ACF_DSCACHEFILE; /* CacheFile Channel */
animchannelTypeInfo[type++] = &ACF_DSCUR; /* Curve Channel */
@@ -3868,7 +3868,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* for F-Curves, draw color-preview of curve behind checkbox */
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
FCurve *fcu = (FCurve *)ale->data;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -3924,7 +3924,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* draw red underline if channel is disabled */
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -3933,7 +3933,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
GPU_line_width(2.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, (float)offset, yminc);
immVertex2f(pos, (float)v2d->cur.xmax, yminc);
immEnd();
@@ -3952,7 +3952,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
short draw_sliders = 0;
float ymin_ofs = 0.0f;
float color[3];
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index f629c20b04a..d768be49ad4 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2339,10 +2339,24 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
/* 'standard' behavior - check if selected, then apply relevant selection */
- if (RNA_boolean_get(op->ptr, "invert"))
- ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT);
- else
- ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD);
+ const int action = RNA_enum_get(op->ptr, "action");
+ switch (action) {
+ case SEL_TOGGLE:
+ ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD);
+ break;
+ case SEL_SELECT:
+ ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_ADD);
+ break;
+ case SEL_DESELECT:
+ ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_CLEAR);
+ break;
+ case SEL_INVERT:
+ ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
@@ -2350,11 +2364,11 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot)
+static void ANIM_OT_channels_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Select All";
- ot->idname = "ANIM_OT_channels_select_all_toggle";
+ ot->idname = "ANIM_OT_channels_select_all";
ot->description = "Toggle selection of all animation channels";
/* api callbacks */
@@ -2364,8 +2378,8 @@ static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* props */
- ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", "");
+ /* properties */
+ WM_operator_properties_select_all(ot);
}
/* ******************** Borderselect Operator *********************** */
@@ -3146,7 +3160,7 @@ static void ANIM_OT_channel_select_keys(wmOperatorType *ot)
void ED_operatortypes_animchannels(void)
{
- WM_operatortype_append(ANIM_OT_channels_select_all_toggle);
+ WM_operatortype_append(ANIM_OT_channels_select_all);
WM_operatortype_append(ANIM_OT_channels_select_border);
WM_operatortype_append(ANIM_OT_channels_click);
@@ -3199,8 +3213,12 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0);
/* deselect all */
- WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0);
- RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", true);
+ kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", AKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
+ kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
/* borderselect */
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0);
@@ -3235,7 +3253,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf)
/* grouping */
WM_keymap_add_item(keymap, "ANIM_OT_channels_group", GKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
}
/* ************************************************************************** */
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 953898a0586..780e984f870 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -87,8 +87,8 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
/* because the frame number text is subject to the same scaling as the contents of the view */
UI_view2d_scale_get(v2d, &xscale, NULL);
- gpuPushMatrix();
- gpuScale2f(1.0f / xscale, 1.0f);
+ GPU_matrix_push();
+ GPU_matrix_scale_2f(1.0f / xscale, 1.0f);
/* get timecode string
* - padding on str-buf passed so that it doesn't sit on the frame indicator
@@ -128,7 +128,7 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
numstr, col);
/* restore view transform */
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/* General call for drawing current frame indicator in animation editor */
@@ -141,15 +141,15 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
GPU_line_width((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* Draw a light green line to indicate current frame */
immUniformThemeColor(TH_CFRAME);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */
immVertex2f(pos, x, v2d->cur.ymax);
immEnd();
@@ -170,8 +170,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_ANIM_ACTIVE, -25, -30);
@@ -203,8 +203,8 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
@@ -222,7 +222,7 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
/* thin lines where the actual frames are */
immUniformThemeColorShade(TH_BACK, -60);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, (float)SFRA, v2d->cur.ymin);
immVertex2f(pos, (float)SFRA, v2d->cur.ymax);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 05350ffd18e..e1f4092c494 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -400,8 +400,8 @@ static void draw_marker(
if (flag & DRAW_MARKERS_LINES)
#endif
{
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -418,7 +418,7 @@ static void draw_marker(
immUniform1f("dash_width", 6.0f);
immUniform1f("dash_factor", 0.5f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, xpos + 0.5f, 12.0f);
immVertex2f(pos, xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
immEnd();
@@ -486,7 +486,7 @@ void ED_markers_draw(const bContext *C, int flag)
v2d = UI_view2d_fromcontext(C);
if (flag & DRAW_MARKERS_MARGIN) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
const unsigned char shade[4] = {0, 0, 0, 16};
@@ -505,8 +505,8 @@ void ED_markers_draw(const bContext *C, int flag)
/* no time correction for framelen! space is drawn with old values */
ypixels = BLI_rcti_size_y(&v2d->mask);
UI_view2d_scale_get(v2d, &xscale, &yscale);
- gpuPushMatrix();
- gpuScale2f(1.0f / xscale, 1.0f);
+ GPU_matrix_push();
+ GPU_matrix_scale_2f(1.0f / xscale, 1.0f);
/* x-bounds with offset for text (adjust for long string, avoid checking string width) */
font_width_max = (10 * UI_DPI_FAC) / xscale;
@@ -529,7 +529,7 @@ void ED_markers_draw(const bContext *C, int flag)
}
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/* ************************ Marker Wrappers API ********************* */
@@ -1670,7 +1670,11 @@ void ED_keymap_marker(wmKeyConfig *keyconf)
#endif
WM_keymap_verify_item(keymap, "MARKER_OT_select_border", BKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, 0, 0);
+
+ kmi = WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
WM_keymap_add_item(keymap, "MARKER_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MARKER_OT_delete", DELKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 99725c7da99..fe57909be75 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -953,7 +953,7 @@ static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *
/* 2) Show editing panel for setting up this driver */
/* TODO: Use a different one from the editing popever, so we can have the single/all toggle? */
- UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports);
+ UI_popover_panel_invoke(C, "GRAPH_PT_drivers_popover", true, op->reports);
}
return OPERATOR_INTERFACE;
@@ -1041,7 +1041,7 @@ static int edit_driver_button_exec(bContext *C, wmOperator *op)
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
if (ptr.id.data && ptr.data && prop) {
- UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports);
+ UI_popover_panel_invoke(C, "GRAPH_PT_drivers_popover", true, op->reports);
}
return OPERATOR_INTERFACE;
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index fcccf07190b..30130ce4dac 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -585,20 +585,20 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
copy_v4_v4(unsel_mhcol, unsel_color);
unsel_mhcol[3] *= 0.8f;
- unsigned int block_ct = 0;
+ uint block_len = 0;
for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) {
if (actkeyblock_is_valid(ab, keys)) {
- block_ct++;
+ block_len++;
}
}
- if (block_ct > 0) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ if (block_len > 0) {
+ GPUVertFormat *format = immVertexFormat();
+ uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_TRIS, 6 * block_ct);
+ immBegin(GPU_PRIM_TRIS, 6 * block_len);
for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) {
if (actkeyblock_is_valid(ab, keys)) {
if (ab->flag & ACTKEYBLOCK_FLAG_MOVING_HOLD) {
@@ -622,25 +622,25 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
if (keys) {
/* count keys */
- unsigned int key_ct = 0;
+ uint key_len = 0;
for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
/* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw
* - this might give some improvements, since we current have to flip between view/region matrices
*/
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax))
- key_ct++;
+ key_len++;
}
- if (key_ct > 0) {
+ if (key_len > 0) {
/* draw keys */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
- unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
GPU_enable_program_point_size();
- immBegin(GWN_PRIM_POINTS, key_ct);
+ immBegin(GPU_PRIM_POINTS, key_len);
for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index e234a3a131a..7f045fa477f 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1107,7 +1107,12 @@ short insert_keyframe(
}
if (ret) {
- DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ if (act != NULL) {
+ DEG_id_tag_update(&act->id, DEG_TAG_COPY_ON_WRITE);
+ }
+ if (adt != NULL && adt->action != NULL && adt->action != act) {
+ DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ }
}
return ret;
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index a37a2bada08..7c0dd09a237 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -137,7 +137,6 @@ void POSE_OT_rotation_mode_set(struct wmOperatorType *ot);
void POSE_OT_quaternions_flip(struct wmOperatorType *ot);
void POSE_OT_bone_layers(struct wmOperatorType *ot);
-void POSE_OT_toggle_bone_selection_overlay(struct wmOperatorType *ot);
/* ******************************************************* */
/* Pose Tool Utilities (for PoseLib, Pose Sliding, etc.) */
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 067b9fd76a8..039bb7f1847 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -132,8 +132,6 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_bone_layers);
- WM_operatortype_append(POSE_OT_toggle_bone_selection_overlay);
-
WM_operatortype_append(POSE_OT_propagate);
/* POSELIB */
@@ -219,7 +217,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
@@ -333,7 +333,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
#endif
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
@@ -355,7 +357,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "POSE_OT_select_mirror", FKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "POSE_OT_select_mirror", MKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
@@ -373,7 +375,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "POSE_OT_toggle_bone_selection_overlay", ZKEY, KM_PRESS, 0, 0);
+
+ kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ZKEY, KM_PRESS, 0, 0);
+ RNA_string_set(kmi->ptr, "data_path", "space_data.overlay.show_bone_select");
/* special transforms: */
/* 1) envelope/b-bone size */
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index ae2e7339c66..7602bccc48c 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -426,7 +426,7 @@ static EditBone *get_nearest_editbonepoint(
if (use_cycle) {
static int last_mval[2] = {-100, -100};
- if (vc->v3d->drawtype > OB_WIRE) {
+ if (vc->v3d->shading.type > OB_WIRE) {
do_nearest = true;
if (len_manhattan_v2v2_int(vc->mval, last_mval) < 3) {
do_nearest = false;
@@ -435,7 +435,7 @@ static EditBone *get_nearest_editbonepoint(
copy_v2_v2_int(last_mval, vc->mval);
}
else {
- if (vc->v3d->drawtype > OB_WIRE) {
+ if (vc->v3d->shading.type > OB_WIRE) {
do_nearest = true;
}
}
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 02d45a4e041..c93bfb5d8c3 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -681,7 +681,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
/* so all users of this armature should get rebuilt */
for (obt = bmain->object.first; obt; obt = obt->id.next) {
if (obt->data == arm) {
- BKE_pose_rebuild(obt, arm);
+ BKE_pose_rebuild(bmain, obt, arm);
}
}
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 661492ba056..a9ba8c405ba 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -1248,35 +1248,3 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
-/* -------------------------------------------------------------------- */
-/** \name Toggle Bone selection Overlay Operator
- * \{ */
-
-static int toggle_bone_selection_exec(bContext *C, wmOperator *UNUSED(op))
-{
- View3D *v3d = CTX_wm_view3d(C);
- v3d->overlay.flag ^= V3D_OVERLAY_BONE_SELECTION;
- ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C));
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
- return OPERATOR_FINISHED;
-}
-
-static bool pose_select_linked_poll(bContext *C)
-{
- return (ED_operator_view3d_active(C) && ED_operator_posemode(C));
-}
-
-void POSE_OT_toggle_bone_selection_overlay(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Toggle Bone Selection Overlay";
- ot->description = "Toggle bone selection overlay of the viewport";
- ot->idname = "POSE_OT_toggle_bone_selection_overlay";
-
- /* api callbacks */
- ot->exec = toggle_bone_selection_exec;
- ot->poll = pose_select_linked_poll;
-}
-
-/** \} */
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 29124f9c895..925358b5304 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -245,7 +245,9 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index e679b04f25d..dd0430f4f65 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -50,6 +50,7 @@
#include "BIF_gl.h"
#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -373,7 +374,6 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
return;
}
- View3D *v3d = cdd->vc.v3d;
Object *obedit = cdd->vc.obedit;
Curve *cu = obedit->data;
@@ -387,17 +387,17 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
float color[3];
UI_GetThemeColor3fv(TH_WIRE, color);
- Gwn_Batch *sphere = GPU_batch_preset_sphere(0);
- GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_3fv(sphere, "color", color);
+ GPUBatch *sphere = GPU_batch_preset_sphere(0);
+ GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
+ GPU_batch_uniform_3fv(sphere, "color", color);
/* scale to edit-mode space */
- gpuPushMatrix();
- gpuMultMatrix(obedit->obmat);
+ GPU_matrix_push();
+ GPU_matrix_mul(obedit->obmat);
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
- gpuTranslate3f(
+ GPU_matrix_translate_3f(
selem->location_local[0] - location_prev[0],
selem->location_local[1] - location_prev[1],
selem->location_local[2] - location_prev[2]);
@@ -405,15 +405,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
const float radius = stroke_elem_radius(cdd, selem);
- gpuPushMatrix();
- gpuScaleUniform(radius);
- GWN_batch_draw(sphere);
- gpuPopMatrix();
+ GPU_matrix_push();
+ GPU_matrix_scale_1f(radius);
+ GPU_batch_draw(sphere);
+ GPU_matrix_pop();
location_prev = selem->location_local;
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
if (stroke_len > 1) {
@@ -430,41 +430,33 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
}
{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+ GPU_depth_test(false);
GPU_blend(true);
GPU_line_smooth(true);
-
- imm_cpack(0x0);
- immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
GPU_line_width(3.0f);
- if (v3d->zbuf) {
- GPU_depth_test(false);
- }
-
+ imm_cpack(0x0);
+ immBegin(GPU_PRIM_LINE_STRIP, stroke_len);
for (int i = 0; i < stroke_len; i++) {
immVertex3fv(pos, coord_array[i]);
}
-
immEnd();
- imm_cpack(0xffffffff);
- immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
GPU_line_width(1.0f);
+ imm_cpack(0xffffffff);
+ immBegin(GPU_PRIM_LINE_STRIP, stroke_len);
for (int i = 0; i < stroke_len; i++) {
immVertex3fv(pos, coord_array[i]);
}
-
immEnd();
- if (v3d->zbuf) {
- GPU_depth_test(true);
- }
-
+ /* Reset defaults */
+ GPU_depth_test(true);
GPU_blend(false);
GPU_line_smooth(false);
@@ -1103,7 +1095,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) &&
- (v3d->drawtype > OB_WIRE))
+ (v3d->shading.type > OB_WIRE))
{
/* needed or else the draw matrix can be incorrect */
view3d_operator_needs_opengl(C);
diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt
index 640239ccc60..0e09ef6f583 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -435,6 +435,10 @@ set(ICON_NAMES
copydown
pasteflipup
pasteflipdown
+ vis_sel_11
+ vis_sel_10
+ vis_sel_10
+ vis_sel_00
snap_surface
automerge_on
automerge_off
diff --git a/source/blender/editors/manipulator_library/CMakeLists.txt b/source/blender/editors/gizmo_library/CMakeLists.txt
index 86e1bb3b6d7..389820240e2 100644
--- a/source/blender/editors/manipulator_library/CMakeLists.txt
+++ b/source/blender/editors/gizmo_library/CMakeLists.txt
@@ -37,24 +37,24 @@ set(INC_SYS
)
set(SRC
- manipulator_draw_utils.c
- manipulator_geometry.h
- manipulator_library_intern.h
- manipulator_library_presets.c
- manipulator_library_utils.c
- geometry/geom_arrow_manipulator.c
- geometry/geom_cube_manipulator.c
- geometry/geom_dial_manipulator.c
- manipulator_types/arrow2d_manipulator.c
- manipulator_types/arrow3d_manipulator.c
- manipulator_types/button2d_manipulator.c
- manipulator_types/cage2d_manipulator.c
- manipulator_types/cage3d_manipulator.c
- manipulator_types/dial3d_manipulator.c
- manipulator_types/grab3d_manipulator.c
- manipulator_types/primitive3d_manipulator.c
+ gizmo_draw_utils.c
+ gizmo_geometry.h
+ gizmo_library_intern.h
+ gizmo_library_presets.c
+ gizmo_library_utils.c
+ geometry/geom_arrow_gizmo.c
+ geometry/geom_cube_gizmo.c
+ geometry/geom_dial_gizmo.c
+ gizmo_types/arrow2d_gizmo.c
+ gizmo_types/arrow3d_gizmo.c
+ gizmo_types/button2d_gizmo.c
+ gizmo_types/cage2d_gizmo.c
+ gizmo_types/cage3d_gizmo.c
+ gizmo_types/dial3d_gizmo.c
+ gizmo_types/grab3d_gizmo.c
+ gizmo_types/primitive3d_gizmo.c
)
add_definitions(${GL_DEFINITIONS})
-blender_add_lib(bf_editor_manipulator_library "${SRC}" "${INC}" "${INC_SYS}")
+blender_add_lib(bf_editor_gizmo_library "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/manipulator_library/geometry/geom_arrow_manipulator.c b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c
index 34f7d73589c..11708f5b5ce 100644
--- a/source/blender/editors/manipulator_library/geometry/geom_arrow_manipulator.c
+++ b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c
@@ -21,11 +21,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file geom_arrow_manipulator.c
+/** \file geom_arrow_gizmo.c
* \ingroup wm
*/
-#include "../manipulator_geometry.h"
+#include "../gizmo_geometry.h"
static float verts[][3] = {
{-0.000000, 0.012320, 0.000000},
@@ -132,7 +132,7 @@ static unsigned short indices[] = {
3, 1, 17,
};
-ManipulatorGeomInfo wm_manipulator_geom_data_arrow = {
+GizmoGeomInfo wm_gizmo_geom_data_arrow = {
.nverts = 25,
.ntris = 46,
.verts = verts,
diff --git a/source/blender/editors/manipulator_library/geometry/geom_cube_manipulator.c b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c
index cee8e1e22ee..28eb772c082 100644
--- a/source/blender/editors/manipulator_library/geometry/geom_cube_manipulator.c
+++ b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c
@@ -23,11 +23,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file geom_cube_manipulator.c
+/** \file geom_cube_gizmo.c
* \ingroup wm
*/
-#include "../manipulator_geometry.h"
+#include "../gizmo_geometry.h"
static const float verts[][3] = {
{1.000000, 1.000000, -1.000000},
@@ -66,7 +66,7 @@ static const unsigned short indices[] = {
4, 0, 7,
};
-ManipulatorGeomInfo wm_manipulator_geom_data_cube = {
+GizmoGeomInfo wm_gizmo_geom_data_cube = {
.nverts = 8,
.ntris = 12,
.verts = verts,
diff --git a/source/blender/editors/manipulator_library/geometry/geom_dial_manipulator.c b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c
index 811fc872a81..0225a662ff3 100644
--- a/source/blender/editors/manipulator_library/geometry/geom_dial_manipulator.c
+++ b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c
@@ -21,11 +21,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file geom_dial_manipulator.c
+/** \file geom_dial_gizmo.c
* \ingroup wm
*/
-#include "../manipulator_geometry.h"
+#include "../gizmo_geometry.h"
static const float verts[][3] = {
{1.034000, 0.000000, 0.000000},
@@ -804,7 +804,7 @@ static const unsigned short indices[] = {
186, 191, 0,
};
-ManipulatorGeomInfo wm_manipulator_geom_data_dial = {
+GizmoGeomInfo wm_gizmo_geom_data_dial = {
.nverts = 192,
.ntris = 384,
.verts = verts,
diff --git a/source/blender/editors/manipulator_library/manipulator_draw_utils.c b/source/blender/editors/gizmo_library/gizmo_draw_utils.c
index a0b226b7502..5ccb1fa1f6d 100644
--- a/source/blender/editors/manipulator_library/manipulator_draw_utils.c
+++ b/source/blender/editors/gizmo_library/gizmo_draw_utils.c
@@ -23,7 +23,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file manipulator_draw_utils.c
+/** \file gizmo_draw_utils.c
* \ingroup wm
*/
@@ -50,56 +50,45 @@
#include "WM_api.h"
#include "WM_types.h"
-/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */
+/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */
#include "wm.h"
/* own includes */
-#include "manipulator_library_intern.h"
+#include "gizmo_library_intern.h"
/**
- * Main draw call for ManipulatorGeomInfo data
+ * Main draw call for GizmoGeomInfo data
*/
-void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const bool select, const float color[4])
+void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(select), const float color[4])
{
- /* TODO store the Batches inside the ManipulatorGeomInfo and updated it when geom changes
+ /* TODO store the Batches inside the GizmoGeomInfo and updated it when geom changes
* So we don't need to re-created and discard it every time */
- const bool use_lighting = true || (!select && ((U.manipulator_flag & USER_MANIPULATOR_SHADED) != 0));
- Gwn_VertBuf *vbo;
- Gwn_IndexBuf *el;
- Gwn_Batch *batch;
- Gwn_IndexBufBuilder elb = {0};
+ GPUVertBuf *vbo;
+ GPUIndexBuf *el;
+ GPUBatch *batch;
+ GPUIndexBufBuilder elb = {0};
- Gwn_VertFormat format = {0};
- uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- uint nor_id;
-
- if (use_lighting) {
- nor_id = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- }
+ GPUVertFormat format = {0};
+ uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
/* Elements */
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, info->ntris, info->nverts);
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, info->ntris, info->nverts);
for (int i = 0; i < info->ntris; ++i) {
const unsigned short *idx = &info->indices[i * 3];
- GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
+ GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
}
- el = GWN_indexbuf_build(&elb);
+ el = GPU_indexbuf_build(&elb);
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, info->nverts);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, info->nverts);
- GWN_vertbuf_attr_fill(vbo, pos_id, info->verts);
-
- if (use_lighting) {
- /* Normals are expected to be smooth. */
- GWN_vertbuf_attr_fill(vbo, nor_id, info->normals);
- }
+ GPU_vertbuf_attr_fill(vbo, pos_id, info->verts);
- batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, el, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ batch = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, el, GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_4fv(batch, "color", color);
+ GPU_batch_uniform_4fv(batch, "color", color);
/* We may want to re-visit this, for now disable
* since it causes issues leaving the GL state modified. */
@@ -108,7 +97,7 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo
GPU_depth_test(true);
#endif
- GWN_batch_draw(batch);
+ GPU_batch_draw(batch);
#if 0
GPU_depth_test(false);
@@ -116,10 +105,10 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo
#endif
- GWN_batch_discard(batch);
+ GPU_batch_discard(batch);
}
-void wm_manipulator_vec_draw(
+void wm_gizmo_vec_draw(
const float color[4], const float (*verts)[3], uint vert_count,
uint pos, uint primitive_type)
{
diff --git a/source/blender/editors/manipulator_library/manipulator_geometry.h b/source/blender/editors/gizmo_library/gizmo_geometry.h
index 2083f9d4d31..254fb6b0957 100644
--- a/source/blender/editors/manipulator_library/manipulator_geometry.h
+++ b/source/blender/editors/gizmo_library/gizmo_geometry.h
@@ -21,34 +21,34 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file manipulator_geometry.h
+/** \file gizmo_geometry.h
* \ingroup wm
*
- * \name Manipulator Geometry
+ * \name Gizmo Geometry
*
- * \brief Prototypes for arrays defining the manipulator geometry. The actual definitions can be found in files usually
- * called geom_xxx_manipulator.c
+ * \brief Prototypes for arrays defining the gizmo geometry. The actual definitions can be found in files usually
+ * called geom_xxx_gizmo.c
*/
-#ifndef __MANIPULATOR_GEOMETRY_H__
-#define __MANIPULATOR_GEOMETRY_H__
+#ifndef __GIZMO_GEOMETRY_H__
+#define __GIZMO_GEOMETRY_H__
-typedef struct ManipulatorGeomInfo {
+typedef struct GizmoGeomInfo {
int nverts;
int ntris;
const float (*verts)[3];
const float (*normals)[3];
const unsigned short *indices;
-} ManipulatorGeomInfo;
+} GizmoGeomInfo;
-/* arrow manipulator */
-extern ManipulatorGeomInfo wm_manipulator_geom_data_arrow;
+/* arrow gizmo */
+extern GizmoGeomInfo wm_gizmo_geom_data_arrow;
-/* cube manipulator */
-extern ManipulatorGeomInfo wm_manipulator_geom_data_cube;
+/* cube gizmo */
+extern GizmoGeomInfo wm_gizmo_geom_data_cube;
-/* dial manipulator */
-extern ManipulatorGeomInfo wm_manipulator_geom_data_dial;
+/* dial gizmo */
+extern GizmoGeomInfo wm_gizmo_geom_data_dial;
-#endif /* __MANIPULATOR_GEOMETRY_H__ */
+#endif /* __GIZMO_GEOMETRY_H__ */
diff --git a/source/blender/editors/manipulator_library/manipulator_library_intern.h b/source/blender/editors/gizmo_library/gizmo_library_intern.h
index 55db99236e0..f5584d86847 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_intern.h
+++ b/source/blender/editors/gizmo_library/gizmo_library_intern.h
@@ -23,32 +23,32 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file manipulator_library_intern.h
+/** \file gizmo_library_intern.h
* \ingroup wm
*/
-#ifndef __MANIPULATOR_LIBRARY_INTERN_H__
-#define __MANIPULATOR_LIBRARY_INTERN_H__
+#ifndef __GIZMO_LIBRARY_INTERN_H__
+#define __GIZMO_LIBRARY_INTERN_H__
-/* distance around which manipulators respond to input (and get highlighted) */
-#define MANIPULATOR_HOTSPOT 14.0f
+/* distance around which gizmos respond to input (and get highlighted) */
+#define GIZMO_HOTSPOT 14.0f
/**
- * Data for common interactions. Used in manipulator_library_utils.c functions.
+ * Data for common interactions. Used in gizmo_library_utils.c functions.
*/
-typedef struct ManipulatorCommonData {
+typedef struct GizmoCommonData {
int flag;
float range_fac; /* factor for arrow min/max distance */
float offset;
- /* property range for constrained manipulators */
+ /* property range for constrained gizmos */
float range;
- /* min/max value for constrained manipulators */
+ /* min/max value for constrained gizmos */
float min, max;
-} ManipulatorCommonData;
+} GizmoCommonData;
-typedef struct ManipulatorInteraction {
+typedef struct GizmoInteraction {
float init_value; /* initial property value */
float init_mval[2];
float init_offset;
@@ -60,52 +60,52 @@ typedef struct ManipulatorInteraction {
/* Total offset added by precision tweaking.
* Needed to allow toggling precision on/off without causing jumps */
float precision_offset;
-} ManipulatorInteraction;
+} GizmoInteraction;
-/* ManipulatorCommonData->flag */
+/* GizmoCommonData->flag */
enum {
- MANIPULATOR_CUSTOM_RANGE_SET = (1 << 0),
+ GIZMO_CUSTOM_RANGE_SET = (1 << 0),
};
-float manipulator_offset_from_value(
- ManipulatorCommonData *data, const float value,
+float gizmo_offset_from_value(
+ GizmoCommonData *data, const float value,
const bool constrained, const bool inverted);
-float manipulator_value_from_offset(
- ManipulatorCommonData *data, ManipulatorInteraction *inter, const float offset,
+float gizmo_value_from_offset(
+ GizmoCommonData *data, GizmoInteraction *inter, const float offset,
const bool constrained, const bool inverted, const bool use_precision);
-void manipulator_property_data_update(
- struct wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop,
+void gizmo_property_data_update(
+ struct wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop,
const bool constrained, const bool inverted);
-void manipulator_property_value_reset(
- bContext *C, const struct wmManipulator *mpr, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop);
+void gizmo_property_value_reset(
+ bContext *C, const struct wmGizmo *gz, GizmoInteraction *inter, wmGizmoProperty *gz_prop);
/* -------------------------------------------------------------------- */
-void manipulator_color_get(
- const struct wmManipulator *mpr, const bool highlight,
+void gizmo_color_get(
+ const struct wmGizmo *gz, const bool highlight,
float r_color[4]);
-bool manipulator_window_project_2d(
- bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset,
+bool gizmo_window_project_2d(
+ bContext *C, const struct wmGizmo *gz, const float mval[2], int axis, bool use_offset,
float r_co[2]);
-bool manipulator_window_project_3d(
- bContext *C, const struct wmManipulator *mpr, const float mval[2], bool use_offset,
+bool gizmo_window_project_3d(
+ bContext *C, const struct wmGizmo *gz, const float mval[2], bool use_offset,
float r_co[3]);
/* -------------------------------------------------------------------- */
-/* Manipulator drawing */
+/* Gizmo drawing */
-#include "manipulator_geometry.h"
+#include "gizmo_geometry.h"
-void wm_manipulator_geometryinfo_draw(const struct ManipulatorGeomInfo *info, const bool select, const float color[4]);
-void wm_manipulator_vec_draw(
+void wm_gizmo_geometryinfo_draw(const struct GizmoGeomInfo *info, const bool select, const float color[4]);
+void wm_gizmo_vec_draw(
const float color[4], const float (*verts)[3], uint vert_count,
uint pos, uint primitive_type);
-#endif /* __MANIPULATOR_LIBRARY_INTERN_H__ */
+#endif /* __GIZMO_LIBRARY_INTERN_H__ */
diff --git a/source/blender/editors/manipulator_library/manipulator_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c
index 12f07611722..ab92905192b 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_presets.c
+++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c
@@ -18,12 +18,12 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/manipulator_library/manipulator_library_presets.c
+/** \file blender/editors/gizmo_library/gizmo_library_presets.c
* \ingroup wm
*
- * \name Manipulator Lib Presets
+ * \name Gizmo Lib Presets
*
- * \brief Preset shapes that can be drawn from any manipulator type.
+ * \brief Preset shapes that can be drawn from any gizmo type.
*/
#include "MEM_guardedalloc.h"
@@ -54,10 +54,10 @@
#include "ED_screen.h"
/* own includes */
-#include "ED_manipulator_library.h" /* own include */
-#include "manipulator_library_intern.h" /* own include */
+#include "ED_gizmo_library.h" /* own include */
+#include "gizmo_library_intern.h" /* own include */
-/* TODO, this is to be used by RNA. might move to ED_manipulator_library */
+/* TODO, this is to be used by RNA. might move to ED_gizmo_library */
/**
* Given a single axis, orient the matrix to a different direction.
@@ -80,69 +80,69 @@ static void single_axis_convert(
/**
* Use for all geometry.
*/
-static void ed_manipulator_draw_preset_geometry(
- const struct wmManipulator *mpr, float mat[4][4], int select_id,
- const ManipulatorGeomInfo *info)
+static void ed_gizmo_draw_preset_geometry(
+ const struct wmGizmo *gz, float mat[4][4], int select_id,
+ const GizmoGeomInfo *info)
{
const bool is_select = (select_id != -1);
- const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
+ const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
float color[4];
- manipulator_color_get(mpr, is_highlight, color);
+ gizmo_color_get(gz, is_highlight, color);
if (is_select) {
GPU_select_load_id(select_id);
}
- gpuPushMatrix();
- gpuMultMatrix(mat);
- wm_manipulator_geometryinfo_draw(info, is_select, color);
- gpuPopMatrix();
+ GPU_matrix_push();
+ GPU_matrix_mul(mat);
+ wm_gizmo_geometryinfo_draw(info, is_select, color);
+ GPU_matrix_pop();
if (is_select) {
GPU_select_load_id(-1);
}
}
-void ED_manipulator_draw_preset_box(
- const struct wmManipulator *mpr, float mat[4][4], int select_id)
+void ED_gizmo_draw_preset_box(
+ const struct wmGizmo *gz, float mat[4][4], int select_id)
{
- ed_manipulator_draw_preset_geometry(mpr, mat, select_id, &wm_manipulator_geom_data_cube);
+ ed_gizmo_draw_preset_geometry(gz, mat, select_id, &wm_gizmo_geom_data_cube);
}
-void ED_manipulator_draw_preset_arrow(
- const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id)
+void ED_gizmo_draw_preset_arrow(
+ const struct wmGizmo *gz, float mat[4][4], int axis, int select_id)
{
float mat_rotate[4][4];
single_axis_convert(OB_POSZ, mat, axis, mat_rotate);
- ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_manipulator_geom_data_arrow);
+ ed_gizmo_draw_preset_geometry(gz, mat_rotate, select_id, &wm_gizmo_geom_data_arrow);
}
-void ED_manipulator_draw_preset_circle(
- const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id)
+void ED_gizmo_draw_preset_circle(
+ const struct wmGizmo *gz, float mat[4][4], int axis, int select_id)
{
float mat_rotate[4][4];
single_axis_convert(OB_POSZ, mat, axis, mat_rotate);
- ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_manipulator_geom_data_dial);
+ ed_gizmo_draw_preset_geometry(gz, mat_rotate, select_id, &wm_gizmo_geom_data_dial);
}
-void ED_manipulator_draw_preset_facemap(
- const bContext *C, const struct wmManipulator *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id)
+void ED_gizmo_draw_preset_facemap(
+ const bContext *C, const struct wmGizmo *gz, struct Scene *scene, Object *ob, const int facemap, int select_id)
{
const bool is_select = (select_id != -1);
- const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
+ const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
float color[4];
- manipulator_color_get(mpr, is_highlight, color);
+ gizmo_color_get(gz, is_highlight, color);
if (is_select) {
GPU_select_load_id(select_id);
}
- gpuPushMatrix();
- gpuMultMatrix(ob->obmat);
+ GPU_matrix_push();
+ GPU_matrix_mul(ob->obmat);
ED_draw_object_facemap(CTX_data_depsgraph(C), scene, ob, color, facemap);
- gpuPopMatrix();
+ GPU_matrix_pop();
if (is_select) {
GPU_select_load_id(-1);
diff --git a/source/blender/editors/manipulator_library/manipulator_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c
index 957f0abdd71..07c230c5503 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_utils.c
+++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c
@@ -23,12 +23,12 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file manipulator_library_utils.c
+/** \file gizmo_library_utils.c
* \ingroup wm
*
- * \name Manipulator Library Utilities
+ * \name Gizmo Library Utilities
*
- * \brief This file contains functions for common behaviors of manipulators.
+ * \brief This file contains functions for common behaviors of gizmos.
*/
#include "BLI_math.h"
@@ -47,37 +47,37 @@
#include "ED_view3d.h"
/* own includes */
-#include "manipulator_library_intern.h"
+#include "gizmo_library_intern.h"
/* factor for precision tweaking */
-#define MANIPULATOR_PRECISION_FAC 0.05f
+#define GIZMO_PRECISION_FAC 0.05f
-BLI_INLINE float manipulator_offset_from_value_constr(
+BLI_INLINE float gizmo_offset_from_value_constr(
const float range_fac, const float min, const float range, const float value,
const bool inverted)
{
return inverted ? (range_fac * (min + range - value) / range) : (range_fac * (value / range));
}
-BLI_INLINE float manipulator_value_from_offset_constr(
+BLI_INLINE float gizmo_value_from_offset_constr(
const float range_fac, const float min, const float range, const float value,
const bool inverted)
{
return inverted ? (min + range - (value * range / range_fac)) : (value * range / range_fac);
}
-float manipulator_offset_from_value(
- ManipulatorCommonData *data, const float value, const bool constrained, const bool inverted)
+float gizmo_offset_from_value(
+ GizmoCommonData *data, const float value, const bool constrained, const bool inverted)
{
if (constrained)
- return manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted);
+ return gizmo_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted);
return value;
}
-float manipulator_value_from_offset(
- ManipulatorCommonData *data, ManipulatorInteraction *inter, const float offset,
+float gizmo_value_from_offset(
+ GizmoCommonData *data, GizmoInteraction *inter, const float offset,
const bool constrained, const bool inverted, const bool use_precision)
{
const float max = data->min + data->range;
@@ -88,32 +88,32 @@ float manipulator_value_from_offset(
}
inter->prev_offset = offset;
- float ofs_new = inter->init_offset + offset - inter->precision_offset * (1.0f - MANIPULATOR_PRECISION_FAC);
+ float ofs_new = inter->init_offset + offset - inter->precision_offset * (1.0f - GIZMO_PRECISION_FAC);
float value;
if (constrained) {
- value = manipulator_value_from_offset_constr(data->range_fac, data->min, data->range, ofs_new, inverted);
+ value = gizmo_value_from_offset_constr(data->range_fac, data->min, data->range, ofs_new, inverted);
}
else {
value = ofs_new;
}
/* clamp to custom range */
- if (data->flag & MANIPULATOR_CUSTOM_RANGE_SET) {
+ if (data->flag & GIZMO_CUSTOM_RANGE_SET) {
CLAMP(value, data->min, max);
}
return value;
}
-void manipulator_property_data_update(
- wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop,
+void gizmo_property_data_update(
+ wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop,
const bool constrained, const bool inverted)
{
- if (mpr_prop->custom_func.value_get_fn != NULL) {
+ if (gz_prop->custom_func.value_get_fn != NULL) {
/* pass */
}
- else if (mpr_prop->prop != NULL) {
+ else if (gz_prop->prop != NULL) {
/* pass */
}
else {
@@ -121,12 +121,12 @@ void manipulator_property_data_update(
return;
}
- float value = WM_manipulator_target_property_value_get(mpr, mpr_prop);
+ float value = WM_gizmo_target_property_value_get(gz, gz_prop);
if (constrained) {
- if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) {
+ if ((data->flag & GIZMO_CUSTOM_RANGE_SET) == 0) {
float range[2];
- if (WM_manipulator_target_property_range_get(mpr, mpr_prop, range)) {
+ if (WM_gizmo_target_property_range_get(gz, gz_prop, range)) {
data->range = range[1] - range[0];
data->min = range[0];
}
@@ -134,57 +134,57 @@ void manipulator_property_data_update(
BLI_assert(0);
}
}
- data->offset = manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted);
+ data->offset = gizmo_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted);
}
else {
data->offset = value;
}
}
-void manipulator_property_value_reset(
- bContext *C, const wmManipulator *mpr, ManipulatorInteraction *inter,
- wmManipulatorProperty *mpr_prop)
+void gizmo_property_value_reset(
+ bContext *C, const wmGizmo *gz, GizmoInteraction *inter,
+ wmGizmoProperty *gz_prop)
{
- WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_value);
+ WM_gizmo_target_property_value_set(C, gz, gz_prop, inter->init_value);
}
/* -------------------------------------------------------------------- */
-void manipulator_color_get(
- const wmManipulator *mpr, const bool highlight,
+void gizmo_color_get(
+ const wmGizmo *gz, const bool highlight,
float r_col[4])
{
- if (highlight && !(mpr->flag & WM_MANIPULATOR_DRAW_HOVER)) {
- copy_v4_v4(r_col, mpr->color_hi);
+ if (highlight && !(gz->flag & WM_GIZMO_DRAW_HOVER)) {
+ copy_v4_v4(r_col, gz->color_hi);
}
else {
- copy_v4_v4(r_col, mpr->color);
+ copy_v4_v4(r_col, gz->color);
}
}
/* -------------------------------------------------------------------- */
/**
- * Takes mouse coordinates and returns them in relation to the manipulator.
- * Both 2D & 3D supported, use so we can use 2D manipulators in the 3D view.
+ * Takes mouse coordinates and returns them in relation to the gizmo.
+ * Both 2D & 3D supported, use so we can use 2D gizmos in the 3D view.
*/
-bool manipulator_window_project_2d(
- bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset,
+bool gizmo_window_project_2d(
+ bContext *C, const struct wmGizmo *gz, const float mval[2], int axis, bool use_offset,
float r_co[2])
{
float mat[4][4];
{
float mat_identity[4][4];
- struct WM_ManipulatorMatrixParams params = {NULL};
+ struct WM_GizmoMatrixParams params = {NULL};
if (use_offset == false) {
unit_m4(mat_identity);
params.matrix_offset = mat_identity;
}
- WM_manipulator_calc_matrix_final_params(mpr, &params, mat);
+ WM_gizmo_calc_matrix_final_params(gz, &params, mat);
}
/* rotate mouse in relation to the center and relocate it */
- if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
/* For 3d views, transform 2D mouse pos onto plane. */
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
@@ -220,26 +220,26 @@ bool manipulator_window_project_2d(
}
}
-bool manipulator_window_project_3d(
- bContext *C, const struct wmManipulator *mpr, const float mval[2], bool use_offset,
+bool gizmo_window_project_3d(
+ bContext *C, const struct wmGizmo *gz, const float mval[2], bool use_offset,
float r_co[3])
{
float mat[4][4];
{
float mat_identity[4][4];
- struct WM_ManipulatorMatrixParams params = {NULL};
+ struct WM_GizmoMatrixParams params = {NULL};
if (use_offset == false) {
unit_m4(mat_identity);
params.matrix_offset = mat_identity;
}
- WM_manipulator_calc_matrix_final_params(mpr, &params, mat);
+ WM_gizmo_calc_matrix_final_params(gz, &params, mat);
}
- if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
/* Note: we might want a custom reference point passed in,
- * instead of the manipulator center. */
+ * instead of the gizmo center. */
ED_view3d_win_to_3d(v3d, ar, mat[3], mval, r_co);
invert_m4(mat);
mul_m4_v3(mat, r_co);
diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
index 5acf1ab2d64..cb8e2a90b07 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
@@ -23,12 +23,12 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file arrow2d_manipulator.c
+/** \file arrow2d_gizmo.c
* \ingroup wm
*
- * \name 2D Arrow Manipulator
+ * \name 2D Arrow Gizmo
*
- * \brief Simple arrow manipulator which is dragged into a certain direction.
+ * \brief Simple arrow gizmo which is dragged into a certain direction.
*/
#include "BLI_listbase.h"
@@ -54,38 +54,38 @@
#include "WM_types.h"
#include "ED_screen.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
/* own includes */
#include "WM_api.h"
-#include "../manipulator_library_intern.h"
+#include "../gizmo_library_intern.h"
-static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], const float color[4])
+static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float color[4])
{
const float size = 0.11f;
const float size_breadth = size / 2.0f;
const float size_length = size * 1.7f;
/* Subtract the length so the arrow fits in the hotspot. */
- const float arrow_length = RNA_float_get(mpr->ptr, "length") - size_length;
- const float arrow_angle = RNA_float_get(mpr->ptr, "angle");
+ const float arrow_length = RNA_float_get(gz->ptr, "length") - size_length;
+ const float arrow_angle = RNA_float_get(gz->ptr, "angle");
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- gpuPushMatrix();
- gpuMultMatrix(matrix);
- gpuRotate2D(RAD2DEGF(arrow_angle));
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix);
+ GPU_matrix_rotate_2d(RAD2DEGF(arrow_angle));
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, 0.0f, 0.0f);
immVertex2f(pos, 0.0f, arrow_length);
immEnd();
- immBegin(GWN_PRIM_TRIS, 3);
+ immBegin(GPU_PRIM_TRIS, 3);
immVertex2f(pos, size_breadth, arrow_length);
immVertex2f(pos, -size_breadth, arrow_length);
immVertex2f(pos, 0.0f, arrow_length + size_length);
@@ -93,63 +93,63 @@ static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], cons
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
}
-static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *mpr)
+static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *gz)
{
float color[4];
float matrix_final[4][4];
- manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, color);
+ gizmo_color_get(gz, gz->state & WM_GIZMO_STATE_HIGHLIGHT, color);
- GPU_line_width(mpr->line_width);
+ GPU_line_width(gz->line_width);
- WM_manipulator_calc_matrix_final(mpr, matrix_final);
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
GPU_blend(true);
- arrow2d_draw_geom(mpr, matrix_final, color);
+ arrow2d_draw_geom(gz, matrix_final, color);
GPU_blend(false);
- if (mpr->interaction_data) {
- ManipulatorInteraction *inter = mpr->interaction_data;
+ if (gz->interaction_data) {
+ GizmoInteraction *inter = gz->interaction_data;
GPU_blend(true);
- arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
+ arrow2d_draw_geom(gz, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
GPU_blend(false);
}
}
-static void manipulator_arrow2d_setup(wmManipulator *mpr)
+static void gizmo_arrow2d_setup(wmGizmo *gz)
{
- mpr->flag |= WM_MANIPULATOR_DRAW_MODAL;
+ gz->flag |= WM_GIZMO_DRAW_MODAL;
}
-static int manipulator_arrow2d_invoke(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event))
+static int gizmo_arrow2d_invoke(
+ bContext *UNUSED(C), wmGizmo *gz, const wmEvent *UNUSED(event))
{
- ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
+ GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__);
- copy_m4_m4(inter->init_matrix_basis, mpr->matrix_basis);
- WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
+ copy_m4_m4(inter->init_matrix_basis, gz->matrix_basis);
+ WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final);
- mpr->interaction_data = inter;
+ gz->interaction_data = inter;
return OPERATOR_RUNNING_MODAL;
}
-static int manipulator_arrow2d_test_select(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
+static int gizmo_arrow2d_test_select(
+ bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
{
const float mval[2] = {event->mval[0], event->mval[1]};
- const float arrow_length = RNA_float_get(mpr->ptr, "length");
- const float arrow_angle = RNA_float_get(mpr->ptr, "angle");
- const float line_len = arrow_length * mpr->scale_final;
+ const float arrow_length = RNA_float_get(gz->ptr, "length");
+ const float arrow_angle = RNA_float_get(gz->ptr, "angle");
+ const float line_len = arrow_length * gz->scale_final;
float mval_local[2];
copy_v2_v2(mval_local, mval);
- sub_v2_v2(mval_local, mpr->matrix_basis[3]);
+ sub_v2_v2(mval_local, gz->matrix_basis[3]);
float line[2][2];
line[0][0] = line[0][1] = line[1][0] = 0.0f;
@@ -165,14 +165,14 @@ static int manipulator_arrow2d_test_select(
/* arrow line intersection check */
float isect_1[2], isect_2[2];
const int isect = isect_line_sphere_v2(
- line[0], line[1], mval_local, MANIPULATOR_HOTSPOT + mpr->line_width * 0.5f,
+ line[0], line[1], mval_local, GIZMO_HOTSPOT + gz->line_width * 0.5f,
isect_1, isect_2);
if (isect > 0) {
float line_ext[2][2]; /* extended line for segment check including hotspot */
copy_v2_v2(line_ext[0], line[0]);
- line_ext[1][0] = line[1][0] + MANIPULATOR_HOTSPOT * ((line[1][0] - line[0][0]) / line_len);
- line_ext[1][1] = line[1][1] + MANIPULATOR_HOTSPOT * ((line[1][1] - line[0][1]) / line_len);
+ line_ext[1][0] = line[1][0] + GIZMO_HOTSPOT * ((line[1][0] - line[0][0]) / line_len);
+ line_ext[1][1] = line[1][1] + GIZMO_HOTSPOT * ((line[1][1] - line[0][1]) / line_len);
const float lambda_1 = line_point_factor_v2(isect_1, line_ext[0], line_ext[1]);
if (isect == 1) {
@@ -193,33 +193,33 @@ static int manipulator_arrow2d_test_select(
}
/* -------------------------------------------------------------------- */
-/** \name 2D Arrow Manipulator API
+/** \name 2D Arrow Gizmo API
*
* \{ */
-static void MANIPULATOR_WT_arrow_2d(wmManipulatorType *wt)
+static void GIZMO_GT_arrow_2d(wmGizmoType *gzt)
{
/* identifiers */
- wt->idname = "MANIPULATOR_WT_arrow_2d";
+ gzt->idname = "GIZMO_GT_arrow_2d";
/* api callbacks */
- wt->draw = manipulator_arrow2d_draw;
- wt->setup = manipulator_arrow2d_setup;
- wt->invoke = manipulator_arrow2d_invoke;
- wt->test_select = manipulator_arrow2d_test_select;
+ gzt->draw = gizmo_arrow2d_draw;
+ gzt->setup = gizmo_arrow2d_setup;
+ gzt->invoke = gizmo_arrow2d_invoke;
+ gzt->test_select = gizmo_arrow2d_test_select;
- wt->struct_size = sizeof(wmManipulator);
+ gzt->struct_size = sizeof(wmGizmo);
/* rna */
- RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX);
+ RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX);
RNA_def_float_rotation(
- wt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f),
+ gzt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f),
"Roll", "", DEG2RADF(-360.0f), DEG2RADF(360.0f));
}
-void ED_manipulatortypes_arrow_2d(void)
+void ED_gizmotypes_arrow_2d(void)
{
- WM_manipulatortype_append(MANIPULATOR_WT_arrow_2d);
+ WM_gizmotype_append(GIZMO_GT_arrow_2d);
}
/** \} */
diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
new file mode 100644
index 00000000000..0f8389af17d
--- /dev/null
+++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
@@ -0,0 +1,492 @@
+/*
+ * ***** 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
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file arrow3d_gizmo.c
+ * \ingroup wm
+ *
+ * \name Arrow Gizmo
+ *
+ * 3D Gizmo
+ *
+ * \brief Simple arrow gizmo which is dragged into a certain direction.
+ * The arrow head can have varying shapes, e.g. cone, box, etc.
+ *
+ * - `matrix[0]` is derived from Y and Z.
+ * - `matrix[1]` is 'up' for gizmo types that have an up.
+ * - `matrix[2]` is the arrow direction (for all arrowes).
+ */
+
+#include "BIF_gl.h"
+
+#include "BLI_math.h"
+
+#include "DNA_view3d_types.h"
+
+#include "BKE_context.h"
+
+#include "GPU_draw.h"
+#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_matrix.h"
+#include "GPU_select.h"
+#include "GPU_state.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_types.h"
+#include "WM_api.h"
+
+#include "ED_view3d.h"
+#include "ED_screen.h"
+#include "ED_gizmo_library.h"
+
+/* own includes */
+#include "../gizmo_geometry.h"
+#include "../gizmo_library_intern.h"
+
+/* to use custom arrows exported to geom_arrow_gizmo.c */
+//#define USE_GIZMO_CUSTOM_ARROWS
+
+typedef struct ArrowGizmo3D {
+ wmGizmo gizmo;
+ GizmoCommonData data;
+} ArrowGizmo3D;
+
+
+/* -------------------------------------------------------------------- */
+
+static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
+{
+ ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
+
+ copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis);
+ madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset);
+}
+
+static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4])
+{
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ bool unbind_shader = true;
+ const int draw_style = RNA_enum_get(arrow->gizmo.ptr, "draw_style");
+ const int draw_options = RNA_enum_get(arrow->gizmo.ptr, "draw_options");
+
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+
+ if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) {
+ immUniformColor4fv(color);
+
+ immBegin(GPU_PRIM_LINES, 4);
+ immVertex3f(pos, -1.0f, 0.0f, 0.0f);
+ immVertex3f(pos, 1.0f, 0.0f, 0.0f);
+ immVertex3f(pos, 0.0f, -1.0f, 0.0f);
+ immVertex3f(pos, 0.0f, 1.0f, 0.0f);
+ immEnd();
+ }
+ else if (draw_style == ED_GIZMO_ARROW_STYLE_CONE) {
+ float aspect[2];
+ RNA_float_get_array(arrow->gizmo.ptr, "aspect", aspect);
+ const float unitx = aspect[0];
+ const float unity = aspect[1];
+ const float vec[4][3] = {
+ {-unitx, -unity, 0},
+ { unitx, -unity, 0},
+ { unitx, unity, 0},
+ {-unitx, unity, 0},
+ };
+
+ GPU_line_width(arrow->gizmo.line_width);
+ wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_LOOP);
+ }
+ else {
+#ifdef USE_GIZMO_CUSTOM_ARROWS
+ wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_arrow, select, color);
+#else
+ const float arrow_length = RNA_float_get(arrow->gizmo.ptr, "length");
+
+ const float vec[2][3] = {
+ {0.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, arrow_length},
+ };
+
+ if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) {
+ GPU_line_width(arrow->gizmo.line_width);
+ wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_STRIP);
+ }
+ else {
+ immUniformColor4fv(color);
+ }
+
+ /* *** draw arrow head *** */
+
+ GPU_matrix_push();
+
+ if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
+ const float size = 0.05f;
+
+ /* translate to line end with some extra offset so box starts exactly where line ends */
+ GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length + size);
+ /* scale down to box size */
+ GPU_matrix_scale_3f(size, size, size);
+
+ /* draw cube */
+ immUnbindProgram();
+ unbind_shader = false;
+ wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_cube, select, color);
+ }
+ else {
+ BLI_assert(draw_style == ED_GIZMO_ARROW_STYLE_NORMAL);
+
+ const float len = 0.25f;
+ const float width = 0.06f;
+
+ /* translate to line end */
+ GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
+
+ imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8);
+ imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1);
+ }
+
+ GPU_matrix_pop();
+#endif /* USE_GIZMO_CUSTOM_ARROWS */
+ }
+
+ if (unbind_shader) {
+ immUnbindProgram();
+ }
+}
+
+static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight)
+{
+ wmGizmo *gz = &arrow->gizmo;
+ float color[4];
+ float matrix_final[4][4];
+
+ gizmo_color_get(gz, highlight, color);
+
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
+
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
+ GPU_blend(true);
+ arrow_draw_geom(arrow, select, color);
+ GPU_blend(false);
+
+ GPU_matrix_pop();
+
+ if (gz->interaction_data) {
+ GizmoInteraction *inter = gz->interaction_data;
+
+ GPU_matrix_push();
+ GPU_matrix_mul(inter->init_matrix_final);
+
+
+ GPU_blend(true);
+ arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
+ GPU_blend(false);
+
+ GPU_matrix_pop();
+ }
+}
+
+static void gizmo_arrow_draw_select(
+ const bContext *UNUSED(C), wmGizmo *gz,
+ int select_id)
+{
+ GPU_select_load_id(select_id);
+ arrow_draw_intern((ArrowGizmo3D *)gz, true, false);
+}
+
+static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz)
+{
+ arrow_draw_intern((ArrowGizmo3D *)gz, false, (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0);
+}
+
+/**
+ * Calculate arrow offset independent from prop min value,
+ * meaning the range will not be offset by min value first.
+ */
+static int gizmo_arrow_modal(
+ bContext *C, wmGizmo *gz, const wmEvent *event,
+ eWM_GizmoFlagTweak tweak_flag)
+{
+ ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
+ GizmoInteraction *inter = gz->interaction_data;
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
+
+ float offset[3];
+ float facdir = 1.0f;
+
+ /* (src, dst) */
+ struct {
+ float mval[2];
+ float ray_origin[3], ray_direction[3];
+ float location[3];
+ } proj[2] = {
+ {.mval = {UNPACK2(inter->init_mval)}},
+ {.mval = {UNPACK2(event->mval)}},
+ };
+
+ float arrow_co[3];
+ float arrow_no[3];
+ copy_v3_v3(arrow_co, inter->init_matrix_basis[3]);
+ normalize_v3_v3(arrow_no, arrow->gizmo.matrix_basis[2]);
+
+ int ok = 0;
+
+ for (int j = 0; j < 2; j++) {
+ if (ED_view3d_win_to_ray(
+ CTX_data_depsgraph(C),
+ ar, v3d, proj[j].mval,
+ proj[j].ray_origin, proj[j].ray_direction, false))
+ {
+ /* Force Y axis if we're view aligned */
+ if (j == 0) {
+ if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) {
+ normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
+ }
+ }
+
+ float arrow_no_proj[3];
+ project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
+
+ normalize_v3(arrow_no_proj);
+
+ float plane[4];
+ plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj);
+
+ float lambda;
+ if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) {
+ madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
+ ok++;
+ }
+ }
+ }
+
+ if (ok != 2) {
+ return OPERATOR_RUNNING_MODAL;
+ }
+
+ sub_v3_v3v3(offset, proj[1].location, proj[0].location);
+ facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1;
+
+ GizmoCommonData *data = &arrow->data;
+ const float ofs_new = facdir * len_v3(offset);
+
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
+
+ /* set the property for the operator and call its modal function */
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
+ const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
+ const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
+ const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0;
+ float value = gizmo_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision);
+
+ WM_gizmo_target_property_value_set(C, gz, gz_prop, value);
+ /* get clamped value */
+ value = WM_gizmo_target_property_value_get(gz, gz_prop);
+
+ data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
+ }
+ else {
+ data->offset = ofs_new;
+ }
+
+ /* tag the region for redraw */
+ ED_region_tag_redraw(ar);
+ WM_event_add_mousemove(C);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static void gizmo_arrow_setup(wmGizmo *gz)
+{
+ ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
+
+ arrow->gizmo.flag |= WM_GIZMO_DRAW_MODAL;
+
+ arrow->data.range_fac = 1.0f;
+}
+
+static int gizmo_arrow_invoke(
+ bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
+{
+ ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
+ GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__);
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
+
+ /* Some gizmos don't use properties. */
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ inter->init_value = WM_gizmo_target_property_value_get(gz, gz_prop);
+ }
+
+ inter->init_offset = arrow->data.offset;
+
+ inter->init_mval[0] = event->mval[0];
+ inter->init_mval[1] = event->mval[1];
+
+ gizmo_arrow_matrix_basis_get(gz, inter->init_matrix_basis);
+ WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final);
+
+ gz->interaction_data = inter;
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static void gizmo_arrow_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
+{
+ ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
+ const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
+ const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
+ const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
+ gizmo_property_data_update(gz, &arrow->data, gz_prop, constrained, inverted);
+}
+
+static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
+{
+ ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
+ GizmoCommonData *data = &arrow->data;
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
+ const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop);
+
+ if (!cancel) {
+ /* Assign incase applying the opetration needs an updated offset
+ * editmesh bisect needs this. */
+ if (is_prop_valid) {
+ data->offset = WM_gizmo_target_property_value_get(gz, gz_prop);
+ }
+ return;
+ }
+
+ GizmoInteraction *inter = gz->interaction_data;
+ if (is_prop_valid) {
+ gizmo_property_value_reset(C, gz, inter, gz_prop);
+ }
+ data->offset = inter->init_offset;
+}
+
+
+/* -------------------------------------------------------------------- */
+/** \name Arrow Gizmo API
+ *
+ * \{ */
+
+/**
+ * Define a custom property UI range
+ *
+ * \note Needs to be called before WM_gizmo_target_property_def_rna!
+ */
+void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max)
+{
+ ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
+
+ BLI_assert(min < max);
+ BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(gz, "offset")) &&
+ "Make sure this function is called before WM_gizmo_target_property_def_rna"));
+
+ arrow->data.range = max - min;
+ arrow->data.min = min;
+ arrow->data.flag |= GIZMO_CUSTOM_RANGE_SET;
+}
+
+/**
+ * Define a custom factor for arrow min/max distance
+ *
+ * \note Needs to be called before WM_gizmo_target_property_def_rna!
+ */
+void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
+{
+ ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
+ BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(gz, "offset")) &&
+ "Make sure this function is called before WM_gizmo_target_property_def_rna"));
+
+ arrow->data.range_fac = range_fac;
+}
+
+static void GIZMO_GT_arrow_3d(wmGizmoType *gzt)
+{
+ /* identifiers */
+ gzt->idname = "GIZMO_GT_arrow_3d";
+
+ /* api callbacks */
+ gzt->draw = gizmo_arrow_draw;
+ gzt->draw_select = gizmo_arrow_draw_select;
+ gzt->matrix_basis_get = gizmo_arrow_matrix_basis_get;
+ gzt->modal = gizmo_arrow_modal;
+ gzt->setup = gizmo_arrow_setup;
+ gzt->invoke = gizmo_arrow_invoke;
+ gzt->property_update = gizmo_arrow_property_update;
+ gzt->exit = gizmo_arrow_exit;
+
+ gzt->struct_size = sizeof(ArrowGizmo3D);
+
+ /* rna */
+ static EnumPropertyItem rna_enum_draw_style_items[] = {
+ {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
+ {ED_GIZMO_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""},
+ {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
+ {ED_GIZMO_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem rna_enum_draw_options_items[] = {
+ {ED_GIZMO_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem rna_enum_transform_items[] = {
+ {ED_GIZMO_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
+ {ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ RNA_def_enum(
+ gzt->srna, "draw_style", rna_enum_draw_style_items,
+ ED_GIZMO_ARROW_STYLE_NORMAL,
+ "Draw Style", "");
+ RNA_def_enum_flag(
+ gzt->srna, "draw_options", rna_enum_draw_options_items,
+ ED_GIZMO_ARROW_DRAW_FLAG_STEM,
+ "Draw Options", "");
+ RNA_def_enum_flag(
+ gzt->srna, "transform", rna_enum_transform_items,
+ 0,
+ "Transform", "");
+
+ RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX);
+ RNA_def_float_vector(gzt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);
+
+ WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1);
+}
+
+void ED_gizmotypes_arrow_3d(void)
+{
+ WM_gizmotype_append(GIZMO_GT_arrow_3d);
+}
+
+/** \} */
diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
index db33f457056..d976adc06bf 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
@@ -18,14 +18,14 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file button2d_manipulator.c
+/** \file button2d_gizmo.c
* \ingroup wm
*
- * \name Button Manipulator
+ * \name Button Gizmo
*
- * 2D Manipulator, also works in 3D views.
+ * 2D Gizmo, also works in 3D views.
*
- * \brief Single click button action for use in manipulator groups.
+ * \brief Single click button action for use in gizmo groups.
*
* \note Currently only basic icon & vector-shape buttons are supported.
*
@@ -45,6 +45,7 @@
#include "GPU_matrix.h"
#include "GPU_select.h"
#include "GPU_batch.h"
+#include "GPU_batch_utils.h"
#include "GPU_state.h"
#include "RNA_access.h"
@@ -56,35 +57,35 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "UI_resources.h"
/* own includes */
-#include "../manipulator_geometry.h"
-#include "../manipulator_library_intern.h"
+#include "../gizmo_geometry.h"
+#include "../gizmo_library_intern.h"
-typedef struct ButtonManipulator2D {
- wmManipulator manipulator;
+typedef struct ButtonGizmo2D {
+ wmGizmo gizmo;
bool is_init;
/* Use an icon or shape */
int icon;
- Gwn_Batch *shape_batch[2];
-} ButtonManipulator2D;
+ GPUBatch *shape_batch[2];
+} ButtonGizmo2D;
#define CIRCLE_RESOLUTION 32
/* -------------------------------------------------------------------- */
static void button2d_geom_draw_backdrop(
- const wmManipulator *mpr, const float color[4], const bool select)
+ const wmGizmo *gz, const float color[4], const bool select)
{
- GPU_line_width(mpr->line_width);
+ GPU_line_width(gz->line_width);
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -99,24 +100,24 @@ static void button2d_geom_draw_backdrop(
}
static void button2d_draw_intern(
- const bContext *C, wmManipulator *mpr,
+ const bContext *C, wmGizmo *gz,
const bool select, const bool highlight)
{
- ButtonManipulator2D *button = (ButtonManipulator2D *)mpr;
+ ButtonGizmo2D *button = (ButtonGizmo2D *)gz;
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
if (button->is_init == false) {
button->is_init = true;
- PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "icon");
- if (RNA_property_is_set(mpr->ptr, prop)) {
- button->icon = RNA_property_enum_get(mpr->ptr, prop);
+ PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon");
+ if (RNA_property_is_set(gz->ptr, prop)) {
+ button->icon = RNA_property_enum_get(gz->ptr, prop);
}
else {
- prop = RNA_struct_find_property(mpr->ptr, "shape");
- const uint polys_len = RNA_property_string_length(mpr->ptr, prop);
+ prop = RNA_struct_find_property(gz->ptr, "shape");
+ const uint polys_len = RNA_property_string_length(gz->ptr, prop);
/* We shouldn't need the +1, but a NULL char is set. */
char *polys = MEM_mallocN(polys_len + 1, __func__);
- RNA_property_string_get(mpr->ptr, prop, polys);
+ RNA_property_string_get(gz->ptr, prop, polys);
button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded((uchar *)polys, polys_len, NULL);
button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded((uchar *)polys, polys_len, NULL);
MEM_freeN(polys);
@@ -126,22 +127,22 @@ static void button2d_draw_intern(
float color[4];
float matrix_final[4][4];
- manipulator_color_get(mpr, highlight, color);
- WM_manipulator_calc_matrix_final(mpr, matrix_final);
+ gizmo_color_get(gz, highlight, color);
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
- bool is_3d = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) != 0;
+ bool is_3d = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) != 0;
- if (draw_options & ED_MANIPULATOR_BUTTON_SHOW_HELPLINE) {
+ if (draw_options & ED_GIZMO_BUTTON_SHOW_HELPLINE) {
float matrix_final_no_offset[4][4];
- WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset);
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor4fv(color);
- GPU_line_width(mpr->line_width);
+ GPU_line_width(gz->line_width);
immUniformColor4fv(color);
- immBegin(GWN_PRIM_LINE_STRIP, 2);
+ immBegin(GPU_PRIM_LINE_STRIP, 2);
immVertex3fv(pos, matrix_final[3]);
immVertex3fv(pos, matrix_final_no_offset[3]);
immEnd();
@@ -149,8 +150,8 @@ static void button2d_draw_intern(
}
bool need_to_pop = true;
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
if (is_3d) {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -160,12 +161,12 @@ static void button2d_draw_intern(
mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit);
zero_v3(matrix_align[3]);
transpose_m4(matrix_align);
- gpuMultMatrix(matrix_align);
+ GPU_matrix_mul(matrix_align);
}
if (select) {
BLI_assert(is_3d);
- button2d_geom_draw_backdrop(mpr, color, select);
+ button2d_geom_draw_backdrop(gz, color, select);
}
else {
@@ -176,11 +177,11 @@ static void button2d_draw_intern(
GPU_line_width(1.0f);
for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) {
/* Invert line color for wire. */
- GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR);
- GWN_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color));
- GWN_batch_draw(button->shape_batch[i]);
+ GPU_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR);
+ GPU_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color));
+ GPU_batch_draw(button->shape_batch[i]);
- if (draw_options & ED_MANIPULATOR_BUTTON_SHOW_OUTLINE) {
+ if (draw_options & ED_GIZMO_BUTTON_SHOW_OUTLINE) {
color[0] = 1.0f - color[0];
color[1] = 1.0f - color[1];
color[2] = 1.0f - color[2];
@@ -190,19 +191,19 @@ static void button2d_draw_intern(
GPU_polygon_smooth(true);
}
else if (button->icon != ICON_NONE) {
- button2d_geom_draw_backdrop(mpr, color, select);
+ button2d_geom_draw_backdrop(gz, color, select);
float size[2];
if (is_3d) {
const float fac = 2.0f;
- gpuTranslate2f(-(fac / 2), -(fac / 2));
- gpuScale2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC));
+ GPU_matrix_translate_2f(-(fac / 2), -(fac / 2));
+ GPU_matrix_scale_2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC));
size[0] = 1.0f;
size[1] = 1.0f;
}
else {
- size[0] = mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC;
- size[1] = mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC;
- gpuPopMatrix();
+ size[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC;
+ size[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC;
+ GPU_matrix_pop();
need_to_pop = false;
}
UI_icon_draw(size[0], size[1], button->icon);
@@ -211,44 +212,44 @@ static void button2d_draw_intern(
}
if (need_to_pop) {
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
-static void manipulator_button2d_draw_select(const bContext *C, wmManipulator *mpr, int select_id)
+static void gizmo_button2d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
{
GPU_select_load_id(select_id);
- button2d_draw_intern(C, mpr, true, false);
+ button2d_draw_intern(C, gz, true, false);
}
-static void manipulator_button2d_draw(const bContext *C, wmManipulator *mpr)
+static void gizmo_button2d_draw(const bContext *C, wmGizmo *gz)
{
- const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
+ const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
GPU_blend(true);
- button2d_draw_intern(C, mpr, false, is_highlight);
+ button2d_draw_intern(C, gz, false, is_highlight);
GPU_blend(false);
}
-static int manipulator_button2d_test_select(
- bContext *C, wmManipulator *mpr, const wmEvent *event)
+static int gizmo_button2d_test_select(
+ bContext *C, wmGizmo *gz, const wmEvent *event)
{
float point_local[2];
if (0) {
/* correct, but unnecessarily slow. */
- if (manipulator_window_project_2d(
- C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
+ if (gizmo_window_project_2d(
+ C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
{
return -1;
}
}
else {
copy_v2_v2(point_local, (float[2]){UNPACK2(event->mval)});
- sub_v2_v2(point_local, mpr->matrix_basis[3]);
- mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC));
+ sub_v2_v2(point_local, gz->matrix_basis[3]);
+ mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC));
}
- /* The 'mpr->scale_final' is already applied when projecting. */
+ /* The 'gz->scale_final' is already applied when projecting. */
if (len_squared_v2(point_local) < 1.0f) {
return 0;
}
@@ -256,67 +257,67 @@ static int manipulator_button2d_test_select(
return -1;
}
-static int manipulator_button2d_cursor_get(wmManipulator *mpr)
+static int gizmo_button2d_cursor_get(wmGizmo *gz)
{
- if (RNA_boolean_get(mpr->ptr, "show_drag")) {
+ if (RNA_boolean_get(gz->ptr, "show_drag")) {
return BC_NSEW_SCROLLCURSOR;
}
return CURSOR_STD;
}
-static void manipulator_button2d_free(wmManipulator *mpr)
+static void gizmo_button2d_free(wmGizmo *gz)
{
- ButtonManipulator2D *shape = (ButtonManipulator2D *)mpr;
+ ButtonGizmo2D *shape = (ButtonGizmo2D *)gz;
for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) {
- GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]);
+ GPU_BATCH_DISCARD_SAFE(shape->shape_batch[i]);
}
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Button Manipulator API
+/** \name Button Gizmo API
*
* \{ */
-static void MANIPULATOR_WT_button_2d(wmManipulatorType *wt)
+static void GIZMO_GT_button_2d(wmGizmoType *gzt)
{
/* identifiers */
- wt->idname = "MANIPULATOR_WT_button_2d";
+ gzt->idname = "GIZMO_GT_button_2d";
/* api callbacks */
- wt->draw = manipulator_button2d_draw;
- wt->draw_select = manipulator_button2d_draw_select;
- wt->test_select = manipulator_button2d_test_select;
- wt->cursor_get = manipulator_button2d_cursor_get;
- wt->free = manipulator_button2d_free;
+ gzt->draw = gizmo_button2d_draw;
+ gzt->draw_select = gizmo_button2d_draw_select;
+ gzt->test_select = gizmo_button2d_test_select;
+ gzt->cursor_get = gizmo_button2d_cursor_get;
+ gzt->free = gizmo_button2d_free;
- wt->struct_size = sizeof(ButtonManipulator2D);
+ gzt->struct_size = sizeof(ButtonGizmo2D);
/* rna */
static EnumPropertyItem rna_enum_draw_options[] = {
- {ED_MANIPULATOR_BUTTON_SHOW_OUTLINE, "OUTLINE", 0, "Outline", ""},
- {ED_MANIPULATOR_BUTTON_SHOW_HELPLINE, "HELPLINE", 0, "Help Line", ""},
+ {ED_GIZMO_BUTTON_SHOW_OUTLINE, "OUTLINE", 0, "Outline", ""},
+ {ED_GIZMO_BUTTON_SHOW_HELPLINE, "HELPLINE", 0, "Help Line", ""},
{0, NULL, 0, NULL, NULL}
};
PropertyRNA *prop;
- RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
+ RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
- prop = RNA_def_property(wt->srna, "icon", PROP_ENUM, PROP_NONE);
+ prop = RNA_def_property(gzt->srna, "icon", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_icon_items);
/* Passed to 'GPU_batch_tris_from_poly_2d_encoded' */
- RNA_def_property(wt->srna, "shape", PROP_STRING, PROP_BYTESTRING);
+ RNA_def_property(gzt->srna, "shape", PROP_STRING, PROP_BYTESTRING);
/* Currently only used for cursor display. */
- RNA_def_boolean(wt->srna, "show_drag", true, "Show Drag", "");
+ RNA_def_boolean(gzt->srna, "show_drag", true, "Show Drag", "");
}
-void ED_manipulatortypes_button_2d(void)
+void ED_gizmotypes_button_2d(void)
{
- WM_manipulatortype_append(MANIPULATOR_WT_button_2d);
+ WM_gizmotype_append(GIZMO_GT_button_2d);
}
-/** \} */ // Button Manipulator API
+/** \} */ // Button Gizmo API
diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
index b7b19ccd634..2869b93a790 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -23,15 +23,15 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file cage2d_manipulator.c
+/** \file cage2d_gizmo.c
* \ingroup wm
*
- * \name Cage Manipulator
+ * \name Cage Gizmo
*
- * 2D Manipulator
+ * 2D Gizmo
*
- * \brief Rectangular manipulator acting as a 'cage' around its content.
- * Interacting scales or translates the manipulator.
+ * \brief Rectangular gizmo acting as a 'cage' around its content.
+ * Interacting scales or translates the gizmo.
*/
#include "MEM_guardedalloc.h"
@@ -59,16 +59,16 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
/* own includes */
-#include "../manipulator_library_intern.h"
+#include "../gizmo_library_intern.h"
-#define MANIPULATOR_RESIZER_SIZE 10.0f
-#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f
+#define GIZMO_RESIZER_SIZE 10.0f
+#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
-static void manipulator_calc_rect_view_scale(
- const wmManipulator *mpr, const float dims[2], float scale[2])
+static void gizmo_calc_rect_view_scale(
+ const wmGizmo *gz, const float dims[2], float scale[2])
{
float matrix_final_no_offset[4][4];
float asp[2] = {1.0f, 1.0f};
@@ -79,9 +79,9 @@ static void manipulator_calc_rect_view_scale(
asp[1] = dims[0] / dims[1];
}
float x_axis[3], y_axis[3];
- WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset);
- mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]);
- mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]);
+ WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset);
+ mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]);
+ mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]);
mul_v2_v2(x_axis, asp);
mul_v2_v2(y_axis, asp);
@@ -90,37 +90,37 @@ static void manipulator_calc_rect_view_scale(
scale[1] = 1.0f / len_v3(y_axis);
}
-static void manipulator_calc_rect_view_margin(
- const wmManipulator *mpr, const float dims[2], float margin[2])
+static void gizmo_calc_rect_view_margin(
+ const wmGizmo *gz, const float dims[2], float margin[2])
{
float handle_size;
- if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
handle_size = 0.15f;
}
else {
- handle_size = MANIPULATOR_RESIZER_SIZE;
+ handle_size = GIZMO_RESIZER_SIZE;
}
- handle_size *= mpr->scale_final;
+ handle_size *= gz->scale_final;
float scale_xy[2];
- manipulator_calc_rect_view_scale(mpr, dims, scale_xy);
+ gizmo_calc_rect_view_scale(gz, dims, scale_xy);
margin[0] = ((handle_size * scale_xy[0]));
margin[1] = ((handle_size * scale_xy[1]));
}
/* -------------------------------------------------------------------- */
-static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_constrain_axis[2])
+static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_constrain_axis[2])
{
bool x = true, y = true;
switch (part) {
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.0); x = false; break; }
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.0); x = false; break; }
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, 0.5); y = false; break; }
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, -0.5); y = false; break; }
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.5); x = y = false; break; }
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, -0.5); x = y = false; break; }
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.5); x = y = false; break; }
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, -0.5); x = y = false; break; }
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.0); x = false; break; }
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.0); x = false; break; }
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, 0.5); y = false; break; }
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, -0.5); y = false; break; }
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.5); x = y = false; break; }
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, -0.5); x = y = false; break; }
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.5); x = y = false; break; }
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, -0.5); x = y = false; break; }
default: BLI_assert(0);
}
r_constrain_axis[0] = x;
@@ -130,18 +130,18 @@ static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[2], bool
/* -------------------------------------------------------------------- */
/** \name Box Draw Style
*
- * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX
+ * Useful for 3D views, see: #ED_GIZMO_CAGE2D_STYLE_BOX
* \{ */
static void cage2d_draw_box_corners(
const rctf *r, const float margin[2], const float color[3])
{
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fv(color);
- immBegin(GWN_PRIM_LINES, 16);
+ immBegin(GPU_PRIM_LINES, 16);
immVertex2f(pos, r->xmin, r->ymin + margin[1]);
immVertex2f(pos, r->xmin, r->ymin);
@@ -176,10 +176,10 @@ static void cage2d_draw_box_interaction(
/* 4 verts for translate, otherwise only 3 are used. */
float verts[4][2];
uint verts_len = 0;
- Gwn_PrimType prim_type = GWN_PRIM_NONE;
+ GPUPrimType prim_type = GPU_PRIM_NONE;
switch (highlighted) {
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X:
{
rctf r = {
.xmin = -size[0], .xmax = -size[0] + margin[0],
@@ -192,14 +192,14 @@ static void cage2d_draw_box_interaction(
ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax);
ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin);
verts_len += 2;
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X:
{
rctf r = {
.xmin = size[0] - margin[0], .xmax = size[0],
@@ -212,14 +212,14 @@ static void cage2d_draw_box_interaction(
ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax);
ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin);
verts_len += 2;
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y:
{
rctf r = {
.xmin = -size[0] + margin[0], .xmax = size[0] - margin[0],
@@ -232,14 +232,14 @@ static void cage2d_draw_box_interaction(
ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax);
ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax);
verts_len += 2;
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y:
{
rctf r = {
.xmin = -size[0] + margin[0], .xmax = size[0] - margin[0],
@@ -252,14 +252,14 @@ static void cage2d_draw_box_interaction(
ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin);
ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin);
verts_len += 2;
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y:
{
rctf r = {
.xmin = -size[0], .xmax = -size[0] + margin[0],
@@ -272,14 +272,14 @@ static void cage2d_draw_box_interaction(
if (is_solid) {
ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin);
verts_len += 1;
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y:
{
rctf r = {
.xmin = -size[0], .xmax = -size[0] + margin[0],
@@ -292,14 +292,14 @@ static void cage2d_draw_box_interaction(
if (is_solid) {
ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax);
verts_len += 1;
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y:
{
rctf r = {
.xmin = size[0] - margin[0], .xmax = size[0],
@@ -312,14 +312,14 @@ static void cage2d_draw_box_interaction(
if (is_solid) {
ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin);
verts_len += 1;
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y:
{
rctf r = {
.xmin = size[0] - margin[0], .xmax = size[0],
@@ -332,14 +332,14 @@ static void cage2d_draw_box_interaction(
if (is_solid) {
ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymax);
verts_len += 1;
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_ROTATE:
+ case ED_GIZMO_CAGE2D_PART_ROTATE:
{
const float rotate_pt[2] = {0.0f, size[1] + margin[1]};
const rctf r_rotate = {
@@ -355,26 +355,26 @@ static void cage2d_draw_box_interaction(
ARRAY_SET_ITEMS(verts[3], r_rotate.xmax, r_rotate.ymin);
verts_len = 4;
if (is_solid) {
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
break;
}
- case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE:
- if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ case ED_GIZMO_CAGE2D_PART_TRANSLATE:
+ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
ARRAY_SET_ITEMS(verts[0], -margin[0] / 2, -margin[1] / 2);
ARRAY_SET_ITEMS(verts[1], margin[0] / 2, margin[1] / 2);
ARRAY_SET_ITEMS(verts[2], -margin[0] / 2, margin[1] / 2);
ARRAY_SET_ITEMS(verts[3], margin[0] / 2, -margin[1] / 2);
verts_len = 4;
if (is_solid) {
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
- prim_type = GWN_PRIM_LINES;
+ prim_type = GPU_PRIM_LINES;
}
}
else {
@@ -385,12 +385,12 @@ static void cage2d_draw_box_interaction(
ARRAY_SET_ITEMS(verts[3], size[0], -size[1]);
verts_len = 4;
if (is_solid) {
- prim_type = GWN_PRIM_TRI_FAN;
+ prim_type = GPU_PRIM_TRI_FAN;
}
else {
/* unreachable */
BLI_assert(0);
- prim_type = GWN_PRIM_LINE_STRIP;
+ prim_type = GPU_PRIM_LINE_STRIP;
}
}
break;
@@ -398,20 +398,20 @@ static void cage2d_draw_box_interaction(
return;
}
- BLI_assert(prim_type != GWN_PRIM_NONE);
+ BLI_assert(prim_type != GPU_PRIM_NONE);
- Gwn_VertFormat *format = immVertexFormat();
+ GPUVertFormat *format = immVertexFormat();
struct {
uint pos, col;
} attr_id = {
- .pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT),
- .col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT),
+ .pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT),
+ .col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT),
};
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
{
if (is_solid) {
- BLI_assert(ELEM(prim_type, GWN_PRIM_TRI_FAN));
+ BLI_assert(ELEM(prim_type, GPU_PRIM_TRI_FAN));
immBegin(prim_type, verts_len);
immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f);
for (uint i = 0; i < verts_len; i++) {
@@ -420,7 +420,7 @@ static void cage2d_draw_box_interaction(
immEnd();
}
else {
- BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES));
+ BLI_assert(ELEM(prim_type, GPU_PRIM_LINE_STRIP, GPU_PRIM_LINES));
GPU_line_width(line_width + 3.0f);
immBegin(prim_type, verts_len);
@@ -449,13 +449,13 @@ static void cage2d_draw_box_interaction(
/* -------------------------------------------------------------------- */
/** \name Circle Draw Style
*
- * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE
+ * Useful for 2D views, see: #ED_GIZMO_CAGE2D_STYLE_CIRCLE
* \{ */
static void imm_draw_point_aspect_2d(
uint pos, float x, float y, float rad_x, float rad_y, bool solid)
{
- immBegin(solid ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4);
+ immBegin(solid ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, 4);
immVertex2f(pos, x - rad_x, y - rad_y);
immVertex2f(pos, x - rad_x, y + rad_y);
immVertex2f(pos, x + rad_x, y + rad_y);
@@ -467,31 +467,31 @@ static void cage2d_draw_circle_wire(
const rctf *r, const float margin[2], const float color[3],
const int transform_flag, const int draw_options)
{
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fv(color);
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2f(pos, r->xmin, r->ymin);
immVertex2f(pos, r->xmax, r->ymin);
immVertex2f(pos, r->xmax, r->ymax);
immVertex2f(pos, r->xmin, r->ymax);
immEnd();
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
- immBegin(GWN_PRIM_LINE_LOOP, 2);
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) {
+ immBegin(GPU_PRIM_LINE_LOOP, 2);
immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax);
immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax + margin[1]);
immEnd();
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
- if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
const float rad[2] = {margin[0] / 2, margin[1] / 2};
const float center[2] = {BLI_rctf_cent_x(r), BLI_rctf_cent_y(r)};
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]);
immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]);
immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]);
@@ -508,7 +508,7 @@ static void cage2d_draw_circle_handles(
const int transform_flag,
bool solid)
{
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
void (*circle_fn)(uint, float, float, float, float, int) =
(solid) ? imm_draw_circle_fill_aspect_2d : imm_draw_circle_wire_aspect_2d;
const int resolu = 12;
@@ -525,8 +525,8 @@ static void cage2d_draw_circle_handles(
imm_draw_point_aspect_2d(pos, r->xmin, r->ymax, rad[0], rad[1], solid);
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
- const float handle[2] = {BLI_rctf_cent_x(r), r->ymax + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)};
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) {
+ const float handle[2] = {BLI_rctf_cent_x(r), r->ymax + (margin[1] * GIZMO_MARGIN_OFFSET_SCALE)};
circle_fn(pos, handle[0], handle[1], rad[0], rad[1], resolu);
}
@@ -535,32 +535,32 @@ static void cage2d_draw_circle_handles(
/** \} */
-static void manipulator_cage2d_draw_intern(
- wmManipulator *mpr, const bool select, const bool highlight, const int select_id)
+static void gizmo_cage2d_draw_intern(
+ wmGizmo *gz, const bool select, const bool highlight, const int select_id)
{
- // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0;
+ // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0;
float dims[2];
- RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ RNA_float_get_array(gz->ptr, "dimensions", dims);
float matrix_final[4][4];
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
- const int draw_style = RNA_enum_get(mpr->ptr, "draw_style");
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
+ const int transform_flag = RNA_enum_get(gz->ptr, "transform");
+ const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
- WM_manipulator_calc_matrix_final(mpr, matrix_final);
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
float margin[2];
- manipulator_calc_rect_view_margin(mpr, dims, margin);
+ gizmo_calc_rect_view_margin(gz, dims, margin);
/* Handy for quick testing draw (if it's outside bounds). */
if (false) {
GPU_blend(true);
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
float s = 0.5f;
@@ -573,33 +573,33 @@ static void manipulator_cage2d_draw_intern(
/* expand for hotspot */
const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE) {
int scale_parts[] = {
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y,
-
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y,
+ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X,
+ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X,
+ ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y,
+ ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y,
+
+ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y,
+ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y,
+ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y,
+ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y,
};
for (int i = 0; i < ARRAY_SIZE(scale_parts); i++) {
GPU_select_load_id(select_id | scale_parts[i]);
cage2d_draw_box_interaction(
- mpr->color, scale_parts[i], size, margin, mpr->line_width, true, draw_options);
+ gz->color, scale_parts[i], size, margin, gz->line_width, true, draw_options);
}
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
- const int transform_part = ED_MANIPULATOR_CAGE2D_PART_TRANSLATE;
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ const int transform_part = ED_GIZMO_CAGE2D_PART_TRANSLATE;
GPU_select_load_id(select_id | transform_part);
cage2d_draw_box_interaction(
- mpr->color, transform_part, size, margin, mpr->line_width, true, draw_options);
+ gz->color, transform_part, size, margin, gz->line_width, true, draw_options);
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) {
cage2d_draw_box_interaction(
- mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, true, draw_options);
+ gz->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, gz->line_width, true, draw_options);
}
}
else {
@@ -609,22 +609,22 @@ static void manipulator_cage2d_draw_intern(
.xmax = size_real[0],
.ymax = size_real[1],
};
- if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) {
- /* corner manipulators */
- GPU_line_width(mpr->line_width + 3.0f);
+ if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) {
+ /* corner gizmos */
+ GPU_line_width(gz->line_width + 3.0f);
cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0});
- /* corner manipulators */
+ /* corner gizmos */
float color[4];
- manipulator_color_get(mpr, highlight, color);
- GPU_line_width(mpr->line_width);
+ gizmo_color_get(gz, highlight, color);
+ GPU_line_width(gz->line_width);
cage2d_draw_box_corners(&r, margin, color);
bool show = false;
- if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) {
+ if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) {
/* Only show if we're drawing the center handle
* otherwise the entire rectangle is the hotspot. */
- if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
show = true;
}
}
@@ -634,28 +634,28 @@ static void manipulator_cage2d_draw_intern(
if (show) {
cage2d_draw_box_interaction(
- mpr->color, mpr->highlight_part, size_real, margin, mpr->line_width, false, draw_options);
+ gz->color, gz->highlight_part, size_real, margin, gz->line_width, false, draw_options);
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) {
cage2d_draw_box_interaction(
- mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, false, draw_options);
+ gz->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, gz->line_width, false, draw_options);
}
}
- else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) {
+ else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) {
float color[4];
- manipulator_color_get(mpr, highlight, color);
+ gizmo_color_get(gz, highlight, color);
GPU_line_smooth(true);
GPU_blend(true);
- GPU_line_width(mpr->line_width + 3.0f);
+ GPU_line_width(gz->line_width + 3.0f);
cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options);
- GPU_line_width(mpr->line_width);
+ GPU_line_width(gz->line_width);
cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options);
- /* corner manipulators */
+ /* corner gizmos */
cage2d_draw_circle_handles(&r, margin, color, transform_flag, true);
cage2d_draw_circle_handles(&r, margin, (const float[3]){0, 0, 0}, transform_flag, false);
@@ -668,80 +668,80 @@ static void manipulator_cage2d_draw_intern(
}
GPU_line_width(1.0);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/**
* For when we want to draw 2d cage in 3d views.
*/
-static void manipulator_cage2d_draw_select(const bContext *UNUSED(C), wmManipulator *mpr, int select_id)
+static void gizmo_cage2d_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id)
{
- manipulator_cage2d_draw_intern(mpr, true, false, select_id);
+ gizmo_cage2d_draw_intern(gz, true, false, select_id);
}
-static void manipulator_cage2d_draw(const bContext *UNUSED(C), wmManipulator *mpr)
+static void gizmo_cage2d_draw(const bContext *UNUSED(C), wmGizmo *gz)
{
- const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
- manipulator_cage2d_draw_intern(mpr, false, is_highlight, -1);
+ const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
+ gizmo_cage2d_draw_intern(gz, false, is_highlight, -1);
}
-static int manipulator_cage2d_get_cursor(wmManipulator *mpr)
+static int gizmo_cage2d_get_cursor(wmGizmo *gz)
{
- int highlight_part = mpr->highlight_part;
+ int highlight_part = gz->highlight_part;
- if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
return BC_NSEW_SCROLLCURSOR;
}
switch (highlight_part) {
- case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE:
+ case ED_GIZMO_CAGE2D_PART_TRANSLATE:
return BC_NSEW_SCROLLCURSOR;
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X:
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X:
return CURSOR_X_MOVE;
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y:
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y:
return CURSOR_Y_MOVE;
/* TODO diagonal cursor */
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y:
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y:
return BC_NSEW_SCROLLCURSOR;
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y:
- case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y:
+ case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y:
return BC_NSEW_SCROLLCURSOR;
- case ED_MANIPULATOR_CAGE2D_PART_ROTATE:
+ case ED_GIZMO_CAGE2D_PART_ROTATE:
return BC_CROSSCURSOR;
default:
return CURSOR_STD;
}
}
-static int manipulator_cage2d_test_select(
- bContext *C, wmManipulator *mpr, const wmEvent *event)
+static int gizmo_cage2d_test_select(
+ bContext *C, wmGizmo *gz, const wmEvent *event)
{
float point_local[2];
float dims[2];
- RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ RNA_float_get_array(gz->ptr, "dimensions", dims);
const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
- if (manipulator_window_project_2d(
- C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
+ if (gizmo_window_project_2d(
+ C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
{
return -1;
}
float margin[2];
- manipulator_calc_rect_view_margin(mpr, dims, margin);
+ gizmo_calc_rect_view_margin(gz, dims, margin);
/* expand for hotspot */
const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
+ const int transform_flag = RNA_enum_get(gz->ptr, "transform");
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
rctf r;
- if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
r.xmin = -margin[0] / 2;
r.ymin = -margin[1] / 2;
r.xmax = margin[0] / 2;
@@ -755,12 +755,12 @@ static int manipulator_cage2d_test_select(
};
bool isect = BLI_rctf_isect_pt_v(&r, point_local);
if (isect) {
- return ED_MANIPULATOR_CAGE2D_PART_TRANSLATE;
+ return ED_GIZMO_CAGE2D_PART_TRANSLATE;
}
}
- /* if manipulator does not have a scale intersection, don't do it */
- if (transform_flag & (ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM)) {
+ /* if gizmo does not have a scale intersection, don't do it */
+ if (transform_flag & (ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM)) {
const rctf r_xmin = {.xmin = -size[0], .ymin = -size[1], .xmax = -size[0] + margin[0], .ymax = size[1]};
const rctf r_xmax = {.xmin = size[0] - margin[0], .ymin = -size[1], .xmax = size[0], .ymax = size[1]};
const rctf r_ymin = {.xmin = -size[0], .ymin = -size[1], .xmax = size[0], .ymax = -size[1] + margin[1]};
@@ -768,37 +768,37 @@ static int manipulator_cage2d_test_select(
if (BLI_rctf_isect_pt_v(&r_xmin, point_local)) {
if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) {
- return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y;
+ return ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y;
}
if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) {
- return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y;
+ return ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y;
}
- return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X;
+ return ED_GIZMO_CAGE2D_PART_SCALE_MIN_X;
}
if (BLI_rctf_isect_pt_v(&r_xmax, point_local)) {
if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) {
- return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y;
+ return ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y;
}
if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) {
- return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y;
+ return ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y;
}
- return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X;
+ return ED_GIZMO_CAGE2D_PART_SCALE_MAX_X;
}
if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) {
- return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y;
+ return ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y;
}
if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) {
- return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y;
+ return ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y;
}
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) {
/* Rotate:
* (*) <-- hot spot is here!
* +---+
* | |
* +---+ */
- const float r_rotate_pt[2] = {0.0f, size_real[1] + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)};
+ const float r_rotate_pt[2] = {0.0f, size_real[1] + (margin[1] * GIZMO_MARGIN_OFFSET_SCALE)};
const rctf r_rotate = {
.xmin = r_rotate_pt[0] - margin[0] / 2.0f,
.xmax = r_rotate_pt[0] + margin[0] / 2.0f,
@@ -807,7 +807,7 @@ static int manipulator_cage2d_test_select(
};
if (BLI_rctf_isect_pt_v(&r_rotate, point_local)) {
- return ED_MANIPULATOR_CAGE2D_PART_ROTATE;
+ return ED_GIZMO_CAGE2D_PART_ROTATE;
}
}
@@ -821,33 +821,33 @@ typedef struct RectTransformInteraction {
Dial *dial;
} RectTransformInteraction;
-static void manipulator_cage2d_setup(wmManipulator *mpr)
+static void gizmo_cage2d_setup(wmGizmo *gz)
{
- mpr->flag |= WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_NO_SCALE;
+ gz->flag |= WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_NO_SCALE;
}
-static int manipulator_cage2d_invoke(
- bContext *C, wmManipulator *mpr, const wmEvent *event)
+static int gizmo_cage2d_invoke(
+ bContext *C, wmGizmo *gz, const wmEvent *event)
{
RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction");
- copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset);
- WM_manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset);
+ copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset);
+ WM_gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset);
- if (manipulator_window_project_2d(
- C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0)
+ if (gizmo_window_project_2d(
+ C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0)
{
zero_v2(data->orig_mouse);
}
- mpr->interaction_data = data;
+ gz->interaction_data = data;
return OPERATOR_RUNNING_MODAL;
}
-static int manipulator_cage2d_modal(
- bContext *C, wmManipulator *mpr, const wmEvent *event,
- eWM_ManipulatorTweak UNUSED(tweak_flag))
+static int gizmo_cage2d_modal(
+ bContext *C, wmGizmo *gz, const wmEvent *event,
+ eWM_GizmoFlagTweak UNUSED(tweak_flag))
{
/* For transform logic to be managable we operate in -0.5..0.5 2D space,
* no matter the size of the rectangle, mouse coorts are scaled to unit space.
@@ -856,40 +856,40 @@ static int manipulator_cage2d_modal(
* - The cursor offset are multiplied by 'dims'.
* - Matrix translation is also multiplied by 'dims'.
*/
- RectTransformInteraction *data = mpr->interaction_data;
+ RectTransformInteraction *data = gz->interaction_data;
float point_local[2];
float dims[2];
- RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ RNA_float_get_array(gz->ptr, "dimensions", dims);
{
float matrix_back[4][4];
- copy_m4_m4(matrix_back, mpr->matrix_offset);
- copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+ copy_m4_m4(matrix_back, gz->matrix_offset);
+ copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
- bool ok = manipulator_window_project_2d(
- C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local);
- copy_m4_m4(mpr->matrix_offset, matrix_back);
+ bool ok = gizmo_window_project_2d(
+ C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local);
+ copy_m4_m4(gz->matrix_offset, matrix_back);
if (!ok) {
return OPERATOR_RUNNING_MODAL;
}
}
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
- wmManipulatorProperty *mpr_prop;
+ const int transform_flag = RNA_enum_get(gz->ptr, "transform");
+ wmGizmoProperty *gz_prop;
- mpr_prop = WM_manipulator_target_property_find(mpr, "matrix");
- if (mpr_prop->type != NULL) {
- WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]);
+ gz_prop = WM_gizmo_target_property_find(gz, "matrix");
+ if (gz_prop->type != NULL) {
+ WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]);
}
- if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) {
+ if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) {
/* do this to prevent clamping from changing size */
- copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
- mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]);
- mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]);
+ copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
+ gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]);
+ gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]);
}
- else if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_ROTATE) {
+ else if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_ROTATE) {
#define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \
mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0}))
@@ -915,28 +915,28 @@ static int manipulator_cage2d_modal(
copy_v3_v3(pivot, data->orig_matrix_offset[3]);
- invert_m4_m4(matrix_space_inv, mpr->matrix_space);
+ invert_m4_m4(matrix_space_inv, gz->matrix_space);
unit_m4(matrix_rotate);
mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv);
rotate_m4(matrix_rotate, 'Z', -angle);
- mul_m4_m4m4(matrix_rotate, matrix_rotate, mpr->matrix_space);
+ mul_m4_m4m4(matrix_rotate, matrix_rotate, gz->matrix_space);
zero_v3(matrix_rotate[3]);
transform_pivot_set_m4(matrix_rotate, pivot);
- mul_m4_m4m4(mpr->matrix_offset, matrix_rotate, data->orig_matrix_offset);
+ mul_m4_m4m4(gz->matrix_offset, matrix_rotate, data->orig_matrix_offset);
#undef MUL_V2_V3_M4_FINAL
}
else {
/* scale */
- copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+ copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
float pivot[2];
bool constrain_axis[2] = {false};
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
- manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis);
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis);
}
else {
zero_v2(pivot);
@@ -960,7 +960,7 @@ static int manipulator_cage2d_modal(
scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i]));
- if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) {
+ if ((transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) {
if (sign != signum_i(scale[i])) {
scale[i] = 0.0f;
}
@@ -968,7 +968,7 @@ static int manipulator_cage2d_modal(
}
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) {
if (constrain_axis[0] == false && constrain_axis[1] == false) {
scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
}
@@ -991,11 +991,11 @@ static int manipulator_cage2d_modal(
mul_v3_fl(matrix_scale[1], scale[1]);
transform_pivot_set_m4(matrix_scale, (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], 0.0f});
- mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale);
+ mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale);
}
- if (mpr_prop->type != NULL) {
- WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]);
+ if (gz_prop->type != NULL) {
+ WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]);
}
/* tag the region for redraw */
@@ -1005,11 +1005,11 @@ static int manipulator_cage2d_modal(
return OPERATOR_RUNNING_MODAL;
}
-static void manipulator_cage2d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
+static void gizmo_cage2d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
{
- if (STREQ(mpr_prop->type->idname, "matrix")) {
- if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) {
- WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]);
+ if (STREQ(gz_prop->type->idname, "matrix")) {
+ if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) {
+ WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]);
}
else {
BLI_assert(0);
@@ -1020,81 +1020,81 @@ static void manipulator_cage2d_property_update(wmManipulator *mpr, wmManipulator
}
}
-static void manipulator_cage2d_exit(bContext *C, wmManipulator *mpr, const bool cancel)
+static void gizmo_cage2d_exit(bContext *C, wmGizmo *gz, const bool cancel)
{
- RectTransformInteraction *data = mpr->interaction_data;
+ RectTransformInteraction *data = gz->interaction_data;
MEM_SAFE_FREE(data->dial);
if (!cancel)
return;
- wmManipulatorProperty *mpr_prop;
+ wmGizmoProperty *gz_prop;
/* reset properties */
- mpr_prop = WM_manipulator_target_property_find(mpr, "matrix");
- if (mpr_prop->type != NULL) {
- WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]);
+ gz_prop = WM_gizmo_target_property_find(gz, "matrix");
+ if (gz_prop->type != NULL) {
+ WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]);
}
- copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+ copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
}
/* -------------------------------------------------------------------- */
-/** \name Cage Manipulator API
+/** \name Cage Gizmo API
*
* \{ */
-static void MANIPULATOR_WT_cage_2d(wmManipulatorType *wt)
+static void GIZMO_GT_cage_2d(wmGizmoType *gzt)
{
/* identifiers */
- wt->idname = "MANIPULATOR_WT_cage_2d";
+ gzt->idname = "GIZMO_GT_cage_2d";
/* api callbacks */
- wt->draw = manipulator_cage2d_draw;
- wt->draw_select = manipulator_cage2d_draw_select;
- wt->test_select = manipulator_cage2d_test_select;
- wt->setup = manipulator_cage2d_setup;
- wt->invoke = manipulator_cage2d_invoke;
- wt->property_update = manipulator_cage2d_property_update;
- wt->modal = manipulator_cage2d_modal;
- wt->exit = manipulator_cage2d_exit;
- wt->cursor_get = manipulator_cage2d_get_cursor;
-
- wt->struct_size = sizeof(wmManipulator);
+ gzt->draw = gizmo_cage2d_draw;
+ gzt->draw_select = gizmo_cage2d_draw_select;
+ gzt->test_select = gizmo_cage2d_test_select;
+ gzt->setup = gizmo_cage2d_setup;
+ gzt->invoke = gizmo_cage2d_invoke;
+ gzt->property_update = gizmo_cage2d_property_update;
+ gzt->modal = gizmo_cage2d_modal;
+ gzt->exit = gizmo_cage2d_exit;
+ gzt->cursor_get = gizmo_cage2d_get_cursor;
+
+ gzt->struct_size = sizeof(wmGizmo);
/* rna */
static EnumPropertyItem rna_enum_draw_style[] = {
- {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""},
- {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
+ {ED_GIZMO_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""},
+ {ED_GIZMO_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem rna_enum_transform[] = {
- {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
- {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""},
- {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
- {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
+ {ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
+ {ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""},
+ {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
+ {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem rna_enum_draw_options[] = {
- {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""},
+ {ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""},
{0, NULL, 0, NULL, NULL}
};
static float unit_v2[2] = {1.0f, 1.0f};
- RNA_def_float_vector(wt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
- RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
- RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", "");
+ RNA_def_float_vector(gzt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
+ RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
+ RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", "");
RNA_def_enum_flag(
- wt->srna, "draw_options", rna_enum_draw_options,
- ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", "");
+ gzt->srna, "draw_options", rna_enum_draw_options,
+ ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", "");
- WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16);
+ WM_gizmotype_target_property_def(gzt, "matrix", PROP_FLOAT, 16);
}
-void ED_manipulatortypes_cage_2d(void)
+void ED_gizmotypes_cage_2d(void)
{
- WM_manipulatortype_append(MANIPULATOR_WT_cage_2d);
+ WM_gizmotype_append(GIZMO_GT_cage_2d);
}
/** \} */
diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
index a907816b08f..0f1d309c927 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
@@ -23,15 +23,15 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file cage3d_manipulator.c
+/** \file cage3d_gizmo.c
* \ingroup wm
*
- * \name Cage Manipulator
+ * \name Cage Gizmo
*
- * 2D Manipulator
+ * 2D Gizmo
*
- * \brief Rectangular manipulator acting as a 'cage' around its content.
- * Interacting scales or translates the manipulator.
+ * \brief Rectangular gizmo acting as a 'cage' around its content.
+ * Interacting scales or translates the gizmo.
*/
#include "MEM_guardedalloc.h"
@@ -58,29 +58,29 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
/* own includes */
-#include "../manipulator_library_intern.h"
+#include "../gizmo_library_intern.h"
-#define MANIPULATOR_RESIZER_SIZE 10.0f
-#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f
+#define GIZMO_RESIZER_SIZE 10.0f
+#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
-static void manipulator_calc_matrix_final_no_offset(
- const wmManipulator *mpr, float orig_matrix_final_no_offset[4][4], bool use_space)
+static void gizmo_calc_matrix_final_no_offset(
+ const wmGizmo *gz, float orig_matrix_final_no_offset[4][4], bool use_space)
{
float mat_identity[4][4];
- struct WM_ManipulatorMatrixParams params = {NULL};
+ struct WM_GizmoMatrixParams params = {NULL};
unit_m4(mat_identity);
if (use_space == false) {
params.matrix_basis = mat_identity;
}
params.matrix_offset = mat_identity;
- WM_manipulator_calc_matrix_final_params(mpr, &params, orig_matrix_final_no_offset);
+ WM_gizmo_calc_matrix_final_params(gz, &params, orig_matrix_final_no_offset);
}
-static void manipulator_calc_rect_view_scale(
- const wmManipulator *mpr, const float dims[3], float scale[3])
+static void gizmo_calc_rect_view_scale(
+ const wmGizmo *gz, const float dims[3], float scale[3])
{
UNUSED_VARS(dims);
@@ -88,31 +88,31 @@ static void manipulator_calc_rect_view_scale(
float matrix_final_no_offset[4][4];
float x_axis[3], y_axis[3], z_axis[3];
- manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset, false);
- mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]);
- mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]);
- mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, mpr->matrix_offset[2]);
+ gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset, false);
+ mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]);
+ mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]);
+ mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, gz->matrix_offset[2]);
scale[0] = 1.0f / len_v3(x_axis);
scale[1] = 1.0f / len_v3(y_axis);
scale[2] = 1.0f / len_v3(z_axis);
}
-static void manipulator_calc_rect_view_margin(
- const wmManipulator *mpr, const float dims[3], float margin[3])
+static void gizmo_calc_rect_view_margin(
+ const wmGizmo *gz, const float dims[3], float margin[3])
{
float handle_size;
- if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
handle_size = 0.15f;
}
else {
- handle_size = MANIPULATOR_RESIZER_SIZE;
+ handle_size = GIZMO_RESIZER_SIZE;
}
// XXX, the scale isn't taking offset into account, we need to calculate scale per handle!
- // handle_size *= mpr->scale_final;
+ // handle_size *= gz->scale_final;
float scale_xyz[3];
- manipulator_calc_rect_view_scale(mpr, dims, scale_xyz);
+ gizmo_calc_rect_view_scale(gz, dims, scale_xyz);
margin[0] = ((handle_size * scale_xyz[0]));
margin[1] = ((handle_size * scale_xyz[1]));
margin[2] = ((handle_size * scale_xyz[2]));
@@ -120,12 +120,12 @@ static void manipulator_calc_rect_view_margin(
/* -------------------------------------------------------------------- */
-static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3])
+static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3])
{
- if (part >= ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z &&
- part <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z)
+ if (part >= ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z &&
+ part <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z)
{
- int index = (part - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z);
+ int index = (part - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z);
int range[3];
range[2] = index % 3;
index = index / 3;
@@ -144,13 +144,13 @@ static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[3], bool
/* -------------------------------------------------------------------- */
/** \name Box Draw Style
*
- * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX
+ * Useful for 3D views, see: #ED_GIZMO_CAGE2D_STYLE_BOX
* \{ */
static void cage3d_draw_box_corners(
const float r[3], const float margin[3], const float color[3])
{
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
UNUSED_VARS(margin);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -165,10 +165,10 @@ static void cage3d_draw_box_interaction(
const float color[4], const int highlighted,
const float size[3], const float margin[3])
{
- if (highlighted >= ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z &&
- highlighted <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z)
+ if (highlighted >= ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z &&
+ highlighted <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z)
{
- int index = (highlighted - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z);
+ int index = (highlighted - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z);
int range[3];
range[2] = index % 3;
index = index / 3;
@@ -185,7 +185,7 @@ static void cage3d_draw_box_interaction(
const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
{
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3fv(color);
imm_draw_cube_fill_3d(pos, co, rad);
@@ -199,7 +199,7 @@ static void cage3d_draw_box_interaction(
/* -------------------------------------------------------------------- */
/** \name Circle Draw Style
*
- * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE
+ * Useful for 2D views, see: #ED_GIZMO_CAGE2D_STYLE_CIRCLE
* \{ */
static void imm_draw_point_aspect_3d(
@@ -217,7 +217,7 @@ static void cage3d_draw_circle_wire(
const float r[3], const float margin[3], const float color[3],
const int transform_flag, const int draw_options)
{
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3fv(color);
@@ -225,12 +225,12 @@ static void cage3d_draw_circle_wire(
imm_draw_cube_wire_3d(pos, (float[3]){0}, r);
#if 0
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
- if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
const float rad[2] = {margin[0] / 2, margin[1] / 2};
const float center[2] = {0.0f, 0.0f};
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]);
immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]);
immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]);
@@ -251,7 +251,7 @@ static void cage3d_draw_circle_handles(
const float r[3], const float margin[3], const float color[3],
bool solid, float scale)
{
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -279,33 +279,33 @@ static void cage3d_draw_circle_handles(
/** \} */
-static void manipulator_cage3d_draw_intern(
+static void gizmo_cage3d_draw_intern(
RegionView3D *rv3d,
- wmManipulator *mpr, const bool select, const bool highlight, const int select_id)
+ wmGizmo *gz, const bool select, const bool highlight, const int select_id)
{
- // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0;
+ // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0;
float dims[3];
- RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ RNA_float_get_array(gz->ptr, "dimensions", dims);
float matrix_final[4][4];
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
- const int draw_style = RNA_enum_get(mpr->ptr, "draw_style");
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
+ const int transform_flag = RNA_enum_get(gz->ptr, "transform");
+ const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f};
- WM_manipulator_calc_matrix_final(mpr, matrix_final);
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
float margin[3];
- manipulator_calc_rect_view_margin(mpr, dims, margin);
+ gizmo_calc_rect_view_margin(gz, dims, margin);
/* Handy for quick testing draw (if it's outside bounds). */
if (false) {
GPU_blend(true);
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
float s = 0.5f;
@@ -328,24 +328,24 @@ static void manipulator_cage3d_draw_intern(
#endif
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) {
- for (int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z;
- i <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z;
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE) {
+ for (int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z;
+ i <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z;
i++)
{
- if (i == ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z) {
+ if (i == ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z) {
continue;
}
GPU_select_load_id(select_id | i);
cage3d_draw_box_interaction(
- mpr->color, i, size, margin);
+ gz->color, i, size, margin);
}
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
- const int transform_part = ED_MANIPULATOR_CAGE3D_PART_TRANSLATE;
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ const int transform_part = ED_GIZMO_CAGE3D_PART_TRANSLATE;
GPU_select_load_id(select_id | transform_part);
cage3d_draw_box_interaction(
- mpr->color, transform_part, size, margin);
+ gz->color, transform_part, size, margin);
}
}
else {
@@ -357,22 +357,22 @@ static void manipulator_cage3d_draw_intern(
.ymax = size_real[1],
};
#endif
- if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) {
- /* corner manipulators */
- GPU_line_width(mpr->line_width + 3.0f);
+ if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) {
+ /* corner gizmos */
+ GPU_line_width(gz->line_width + 3.0f);
cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0});
- /* corner manipulators */
+ /* corner gizmos */
float color[4];
- manipulator_color_get(mpr, highlight, color);
- GPU_line_width(mpr->line_width);
+ gizmo_color_get(gz, highlight, color);
+ GPU_line_width(gz->line_width);
cage3d_draw_box_corners(size_real, margin, color);
bool show = false;
- if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_TRANSLATE) {
+ if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) {
/* Only show if we're drawing the center handle
* otherwise the entire rectangle is the hotspot. */
- if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
show = true;
}
}
@@ -382,23 +382,23 @@ static void manipulator_cage3d_draw_intern(
if (show) {
cage3d_draw_box_interaction(
- mpr->color, mpr->highlight_part, size_real, margin);
+ gz->color, gz->highlight_part, size_real, margin);
}
}
- else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) {
+ else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) {
float color[4];
- manipulator_color_get(mpr, highlight, color);
+ gizmo_color_get(gz, highlight, color);
GPU_line_smooth(true);
GPU_polygon_smooth(true);
GPU_blend(true);
- GPU_line_width(mpr->line_width + 3.0f);
+ GPU_line_width(gz->line_width + 3.0f);
cage3d_draw_circle_wire(size_real, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options);
- GPU_line_width(mpr->line_width);
+ GPU_line_width(gz->line_width);
cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options);
- /* corner manipulators */
+ /* corner gizmos */
cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, (const float[3]){0, 0, 0}, true, 60);
cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 40);
@@ -412,30 +412,30 @@ static void manipulator_cage3d_draw_intern(
}
GPU_line_width(1.0);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/**
* For when we want to draw 3d cage in 3d views.
*/
-static void manipulator_cage3d_draw_select(const bContext *C, wmManipulator *mpr, int select_id)
+static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
{
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
- manipulator_cage3d_draw_intern(rv3d, mpr, true, false, select_id);
+ gizmo_cage3d_draw_intern(rv3d, gz, true, false, select_id);
}
-static void manipulator_cage3d_draw(const bContext *C, wmManipulator *mpr)
+static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
{
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
- const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
- manipulator_cage3d_draw_intern(rv3d, mpr, false, is_highlight, -1);
+ const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
+ gizmo_cage3d_draw_intern(rv3d, gz, false, is_highlight, -1);
}
-static int manipulator_cage3d_get_cursor(wmManipulator *mpr)
+static int gizmo_cage3d_get_cursor(wmGizmo *gz)
{
- if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
return BC_NSEW_SCROLLCURSOR;
}
@@ -448,34 +448,34 @@ typedef struct RectTransformInteraction {
float orig_matrix_final_no_offset[4][4];
} RectTransformInteraction;
-static void manipulator_cage3d_setup(wmManipulator *mpr)
+static void gizmo_cage3d_setup(wmGizmo *gz)
{
- mpr->flag |= /* WM_MANIPULATOR_DRAW_MODAL | */ /* TODO */
- WM_MANIPULATOR_DRAW_NO_SCALE;
+ gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */
+ WM_GIZMO_DRAW_NO_SCALE;
}
-static int manipulator_cage3d_invoke(
- bContext *C, wmManipulator *mpr, const wmEvent *event)
+static int gizmo_cage3d_invoke(
+ bContext *C, wmGizmo *gz, const wmEvent *event)
{
RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction");
- copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset);
- manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset, true);
+ copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset);
+ gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset, true);
- if (manipulator_window_project_3d(
- C, mpr, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0)
+ if (gizmo_window_project_3d(
+ C, gz, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0)
{
zero_v3(data->orig_mouse);
}
- mpr->interaction_data = data;
+ gz->interaction_data = data;
return OPERATOR_RUNNING_MODAL;
}
-static int manipulator_cage3d_modal(
- bContext *C, wmManipulator *mpr, const wmEvent *event,
- eWM_ManipulatorTweak UNUSED(tweak_flag))
+static int gizmo_cage3d_modal(
+ bContext *C, wmGizmo *gz, const wmEvent *event,
+ eWM_GizmoFlagTweak UNUSED(tweak_flag))
{
/* For transform logic to be managable we operate in -0.5..0.5 2D space,
* no matter the size of the rectangle, mouse coorts are scaled to unit space.
@@ -484,51 +484,51 @@ static int manipulator_cage3d_modal(
* - The cursor offset are multiplied by 'dims'.
* - Matrix translation is also multiplied by 'dims'.
*/
- RectTransformInteraction *data = mpr->interaction_data;
+ RectTransformInteraction *data = gz->interaction_data;
float point_local[3];
float dims[3];
- RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ RNA_float_get_array(gz->ptr, "dimensions", dims);
{
float matrix_back[4][4];
- copy_m4_m4(matrix_back, mpr->matrix_offset);
- copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+ copy_m4_m4(matrix_back, gz->matrix_offset);
+ copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
- bool ok = manipulator_window_project_3d(
- C, mpr, (const float[2]){UNPACK2(event->mval)}, false, point_local);
- copy_m4_m4(mpr->matrix_offset, matrix_back);
+ bool ok = gizmo_window_project_3d(
+ C, gz, (const float[2]){UNPACK2(event->mval)}, false, point_local);
+ copy_m4_m4(gz->matrix_offset, matrix_back);
if (!ok) {
return OPERATOR_RUNNING_MODAL;
}
}
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
- wmManipulatorProperty *mpr_prop;
+ const int transform_flag = RNA_enum_get(gz->ptr, "transform");
+ wmGizmoProperty *gz_prop;
- mpr_prop = WM_manipulator_target_property_find(mpr, "matrix");
- if (mpr_prop->type != NULL) {
- WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]);
+ gz_prop = WM_gizmo_target_property_find(gz, "matrix");
+ if (gz_prop->type != NULL) {
+ WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]);
}
- if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_TRANSLATE) {
+ if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) {
/* do this to prevent clamping from changing size */
- copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
- mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]);
- mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]);
- mpr->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]);
+ copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
+ gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]);
+ gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]);
+ gz->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]);
}
- else if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_ROTATE) {
+ else if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_ROTATE) {
/* TODO (if needed) */
}
else {
/* scale */
- copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+ copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
float pivot[3];
bool constrain_axis[3] = {false};
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
- manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis);
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis);
}
else {
zero_v3(pivot);
@@ -553,7 +553,7 @@ static int manipulator_cage3d_modal(
scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i]));
- if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) {
+ if ((transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) {
if (sign != signum_i(scale[i])) {
scale[i] = 0.0f;
}
@@ -561,7 +561,7 @@ static int manipulator_cage3d_modal(
}
}
- if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) {
+ if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) {
if (constrain_axis[0] == false && constrain_axis[1] == false) {
scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
}
@@ -587,11 +587,11 @@ static int manipulator_cage3d_modal(
transform_pivot_set_m4(
matrix_scale,
(const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]});
- mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale);
+ mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale);
}
- if (mpr_prop->type != NULL) {
- WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]);
+ if (gz_prop->type != NULL) {
+ WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]);
}
/* tag the region for redraw */
@@ -601,11 +601,11 @@ static int manipulator_cage3d_modal(
return OPERATOR_RUNNING_MODAL;
}
-static void manipulator_cage3d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
+static void gizmo_cage3d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
{
- if (STREQ(mpr_prop->type->idname, "matrix")) {
- if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) {
- WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]);
+ if (STREQ(gz_prop->type->idname, "matrix")) {
+ if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) {
+ WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]);
}
else {
BLI_assert(0);
@@ -616,77 +616,77 @@ static void manipulator_cage3d_property_update(wmManipulator *mpr, wmManipulator
}
}
-static void manipulator_cage3d_exit(bContext *C, wmManipulator *mpr, const bool cancel)
+static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
{
- RectTransformInteraction *data = mpr->interaction_data;
+ RectTransformInteraction *data = gz->interaction_data;
if (!cancel)
return;
- wmManipulatorProperty *mpr_prop;
+ wmGizmoProperty *gz_prop;
/* reset properties */
- mpr_prop = WM_manipulator_target_property_find(mpr, "matrix");
- if (mpr_prop->type != NULL) {
- WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]);
+ gz_prop = WM_gizmo_target_property_find(gz, "matrix");
+ if (gz_prop->type != NULL) {
+ WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]);
}
- copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+ copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
}
/* -------------------------------------------------------------------- */
-/** \name Cage Manipulator API
+/** \name Cage Gizmo API
*
* \{ */
-static void MANIPULATOR_WT_cage_3d(wmManipulatorType *wt)
+static void GIZMO_GT_cage_3d(wmGizmoType *gzt)
{
/* identifiers */
- wt->idname = "MANIPULATOR_WT_cage_3d";
+ gzt->idname = "GIZMO_GT_cage_3d";
/* api callbacks */
- wt->draw = manipulator_cage3d_draw;
- wt->draw_select = manipulator_cage3d_draw_select;
- wt->setup = manipulator_cage3d_setup;
- wt->invoke = manipulator_cage3d_invoke;
- wt->property_update = manipulator_cage3d_property_update;
- wt->modal = manipulator_cage3d_modal;
- wt->exit = manipulator_cage3d_exit;
- wt->cursor_get = manipulator_cage3d_get_cursor;
+ gzt->draw = gizmo_cage3d_draw;
+ gzt->draw_select = gizmo_cage3d_draw_select;
+ gzt->setup = gizmo_cage3d_setup;
+ gzt->invoke = gizmo_cage3d_invoke;
+ gzt->property_update = gizmo_cage3d_property_update;
+ gzt->modal = gizmo_cage3d_modal;
+ gzt->exit = gizmo_cage3d_exit;
+ gzt->cursor_get = gizmo_cage3d_get_cursor;
- wt->struct_size = sizeof(wmManipulator);
+ gzt->struct_size = sizeof(wmGizmo);
/* rna */
static EnumPropertyItem rna_enum_draw_style[] = {
- {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""},
- {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
+ {ED_GIZMO_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""},
+ {ED_GIZMO_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem rna_enum_transform[] = {
- {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
- {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
- {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
+ {ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
+ {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
+ {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem rna_enum_draw_options[] = {
- {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""},
+ {ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""},
{0, NULL, 0, NULL, NULL}
};
static float unit_v3[3] = {1.0f, 1.0f, 1.0f};
- RNA_def_float_vector(wt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
- RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
- RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", "");
+ RNA_def_float_vector(gzt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
+ RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
+ RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", "");
RNA_def_enum_flag(
- wt->srna, "draw_options", rna_enum_draw_options,
- ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", "");
+ gzt->srna, "draw_options", rna_enum_draw_options,
+ ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", "");
- WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16);
+ WM_gizmotype_target_property_def(gzt, "matrix", PROP_FLOAT, 16);
}
-void ED_manipulatortypes_cage_3d(void)
+void ED_gizmotypes_cage_3d(void)
{
- WM_manipulatortype_append(MANIPULATOR_WT_cage_3d);
+ WM_gizmotype_append(GIZMO_GT_cage_3d);
}
/** \} */
diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
index 74ba8bd77a9..8e04703c14e 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
@@ -23,18 +23,18 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file dial3d_manipulator.c
+/** \file dial3d_gizmo.c
* \ingroup wm
*
- * \name Dial Manipulator
+ * \name Dial Gizmo
*
- * 3D Manipulator
+ * 3D Gizmo
*
- * \brief Circle shaped manipulator for circular interaction.
+ * \brief Circle shaped gizmo for circular interaction.
* Currently no own handling, use with operator only.
*
* - `matrix[0]` is derived from Y and Z.
- * - `matrix[1]` is 'up' when DialManipulator.use_start_y_axis is set.
+ * - `matrix[1]` is 'up' when DialGizmo.use_start_y_axis is set.
* - `matrix[2]` is the axis the dial rotates around (all dials).
*/
@@ -61,18 +61,18 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
/* own includes */
-#include "../manipulator_geometry.h"
-#include "../manipulator_library_intern.h"
+#include "../gizmo_geometry.h"
+#include "../gizmo_library_intern.h"
-/* to use custom dials exported to geom_dial_manipulator.c */
-// #define USE_MANIPULATOR_CUSTOM_DIAL
+/* to use custom dials exported to geom_dial_gizmo.c */
+// #define USE_GIZMO_CUSTOM_DIAL
-static int manipulator_dial_modal(
- bContext *C, wmManipulator *mpr, const wmEvent *event,
- eWM_ManipulatorTweak tweak_flag);
+static int gizmo_dial_modal(
+ bContext *C, wmGizmo *gz, const wmEvent *event,
+ eWM_GizmoFlagTweak tweak_flag);
typedef struct DialInteraction {
float init_mval[2];
@@ -99,35 +99,35 @@ typedef struct DialInteraction {
#define DIAL_CLIP_BIAS 0.02
/**
- * We can't use this for the #wmManipulatorType.matrix_basis_get callback, it conflicts with depth picking.
+ * We can't use this for the #wmGizmoType.matrix_basis_get callback, it conflicts with depth picking.
*/
-static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4])
+static void dial_calc_matrix(const wmGizmo *gz, float mat[4][4])
{
float rot[3][3];
const float up[3] = {0.0f, 0.0f, 1.0f};
- rotation_between_vecs_to_mat3(rot, up, mpr->matrix_basis[2]);
+ rotation_between_vecs_to_mat3(rot, up, gz->matrix_basis[2]);
copy_m4_m3(mat, rot);
- copy_v3_v3(mat[3], mpr->matrix_basis[3]);
+ copy_v3_v3(mat[3], gz->matrix_basis[3]);
}
/* -------------------------------------------------------------------- */
static void dial_geom_draw(
- const wmManipulator *mpr, const float color[4], const bool select,
+ const wmGizmo *gz, const float color[4], const bool select,
float axis_modal_mat[4][4], float clip_plane[4])
{
-#ifdef USE_MANIPULATOR_CUSTOM_DIAL
+#ifdef USE_GIZMO_CUSTOM_DIAL
UNUSED_VARS(dial, col, axis_modal_mat, clip_plane);
- wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_dial, select);
+ wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_dial, select);
#else
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
- const bool filled = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL) != 0;
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
+ const bool filled = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_FILL) != 0;
- GPU_line_width(mpr->line_width);
+ GPU_line_width(gz->line_width);
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (clip_plane) {
immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR);
@@ -161,32 +161,32 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[
{
GPU_line_width(1.0f);
- gpuPushMatrix();
- gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f);
+ GPU_matrix_push();
+ GPU_matrix_rotate_3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f);
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor4fv(color);
- immBegin(GWN_PRIM_LINE_STRIP, 2);
+ immBegin(GPU_PRIM_LINE_STRIP, 2);
immVertex3f(pos, 0.0f, 0.0f, 0.0f);
immVertex3fv(pos, co_outer);
immEnd();
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
}
static void dial_ghostarc_draw(
- const wmManipulator *mpr, const float angle_ofs, const float angle_delta, const float color[4])
+ const wmGizmo *gz, const float angle_ofs, const float angle_delta, const float color[4])
{
- const float width_inner = DIAL_WIDTH - mpr->line_width * 0.5f / U.manipulator_size;
+ const float width_inner = DIAL_WIDTH - gz->line_width * 0.5f / U.gizmo_size;
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor4fv(color);
imm_draw_disk_partial_fill_2d(
@@ -196,24 +196,24 @@ static void dial_ghostarc_draw(
static void dial_ghostarc_get_angles(
struct Depsgraph *depsgraph,
- const wmManipulator *mpr,
+ const wmGizmo *gz,
const wmEvent *event,
const ARegion *ar, const View3D *v3d,
float mat[4][4], const float co_outer[3],
float *r_start, float *r_delta)
{
- DialInteraction *inter = mpr->interaction_data;
+ DialInteraction *inter = gz->interaction_data;
const RegionView3D *rv3d = ar->regiondata;
const float mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin};
/* we might need to invert the direction of the angles */
float view_vec[3], axis_vec[3];
- ED_view3d_global_to_vector(rv3d, mpr->matrix_basis[3], view_vec);
- normalize_v3_v3(axis_vec, mpr->matrix_basis[2]);
+ ED_view3d_global_to_vector(rv3d, gz->matrix_basis[3], view_vec);
+ normalize_v3_v3(axis_vec, gz->matrix_basis[2]);
float proj_outer_rel[3];
mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer);
- sub_v3_v3(proj_outer_rel, mpr->matrix_basis[3]);
+ sub_v3_v3(proj_outer_rel, gz->matrix_basis[3]);
float proj_mval_new_rel[3];
float proj_mval_init_rel[3];
@@ -221,7 +221,7 @@ static void dial_ghostarc_get_angles(
float ray_co[3], ray_no[3];
float ray_lambda;
- plane_from_point_normal_v3(dial_plane, mpr->matrix_basis[3], axis_vec);
+ plane_from_point_normal_v3(dial_plane, gz->matrix_basis[3], axis_vec);
if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, inter->init_mval, ray_co, ray_no, false) ||
!isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
@@ -229,7 +229,7 @@ static void dial_ghostarc_get_angles(
goto fail;
}
madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda);
- sub_v3_v3(proj_mval_init_rel, mpr->matrix_basis[3]);
+ sub_v3_v3(proj_mval_init_rel, gz->matrix_basis[3]);
if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, mval, ray_co, ray_no, false) ||
!isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
@@ -237,14 +237,14 @@ static void dial_ghostarc_get_angles(
goto fail;
}
madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda);
- sub_v3_v3(proj_mval_new_rel, mpr->matrix_basis[3]);
+ sub_v3_v3(proj_mval_new_rel, gz->matrix_basis[3]);
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
/* Start direction from mouse or set by user */
const float *proj_init_rel =
- (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y) ?
- mpr->matrix_basis[1] : proj_mval_init_rel;
+ (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y) ?
+ gz->matrix_basis[1] : proj_mval_init_rel;
/* return angles */
const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec));
@@ -274,7 +274,7 @@ fail:
}
static void dial_draw_intern(
- const bContext *C, wmManipulator *mpr,
+ const bContext *C, wmGizmo *gz,
const bool select, const bool highlight, float clip_plane[4])
{
float matrix_basis_adjust[4][4];
@@ -283,30 +283,30 @@ static void dial_draw_intern(
BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D);
- manipulator_color_get(mpr, highlight, color);
+ gizmo_color_get(gz, highlight, color);
- dial_calc_matrix(mpr, matrix_basis_adjust);
+ dial_calc_matrix(gz, matrix_basis_adjust);
- WM_manipulator_calc_matrix_final_params(
- mpr, &((struct WM_ManipulatorMatrixParams) {
+ WM_gizmo_calc_matrix_final_params(
+ gz, &((struct WM_GizmoMatrixParams) {
.matrix_basis = (void *)matrix_basis_adjust,
}), matrix_final);
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
/* draw rotation indicator arc first */
- if ((mpr->flag & WM_MANIPULATOR_DRAW_VALUE) &&
- (mpr->state & WM_MANIPULATOR_STATE_MODAL))
+ if ((gz->flag & WM_GIZMO_DRAW_VALUE) &&
+ (gz->state & WM_GIZMO_STATE_MODAL))
{
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
- DialInteraction *inter = mpr->interaction_data;
+ DialInteraction *inter = gz->interaction_data;
- /* XXX, View3D rotation manipulator doesn't call modal. */
- if (!WM_manipulator_target_property_is_valid_any(mpr)) {
+ /* XXX, View3D rotation gizmo doesn't call modal. */
+ if (!WM_gizmo_target_property_is_valid_any(gz)) {
wmWindow *win = CTX_wm_window(C);
- manipulator_dial_modal((bContext *)C, mpr, win->eventstate, 0);
+ gizmo_dial_modal((bContext *)C, gz, win->eventstate, 0);
}
float angle_ofs = inter->output.angle_ofs;
@@ -315,15 +315,15 @@ static void dial_draw_intern(
/* draw! */
for (int i = 0; i < 2; i++) {
GPU_polygon_smooth(false);
- dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f});
+ dial_ghostarc_draw(gz, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f});
GPU_polygon_smooth(true);
dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */
dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */
if (i == 0) {
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
- if ((draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) {
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
+ if ((draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) {
break;
}
}
@@ -332,17 +332,17 @@ static void dial_draw_intern(
}
}
- /* draw actual dial manipulator */
- dial_geom_draw(mpr, color, select, matrix_basis_adjust, clip_plane);
+ /* draw actual dial gizmo */
+ dial_geom_draw(gz, color, select, matrix_basis_adjust, clip_plane);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
-static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int select_id)
+static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
{
float clip_plane_buf[4];
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
- float *clip_plane = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL;
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
+ float *clip_plane = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL;
/* enable clipping if needed */
if (clip_plane) {
@@ -350,26 +350,26 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr,
RegionView3D *rv3d = ar->regiondata;
copy_v3_v3(clip_plane, rv3d->viewinv[2]);
- clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
- clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final;
+ clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]);
+ clip_plane[3] += DIAL_CLIP_BIAS * gz->scale_final;
glEnable(GL_CLIP_DISTANCE0);
}
GPU_select_load_id(select_id);
- dial_draw_intern(C, mpr, true, false, clip_plane);
+ dial_draw_intern(C, gz, true, false, clip_plane);
if (clip_plane) {
glDisable(GL_CLIP_DISTANCE0);
}
}
-static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
+static void gizmo_dial_draw(const bContext *C, wmGizmo *gz)
{
- const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL;
- const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
+ const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL;
+ const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
float clip_plane_buf[4];
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
- float *clip_plane = (!is_modal && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL;
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
+ float *clip_plane = (!is_modal && (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL;
/* enable clipping if needed */
if (clip_plane) {
@@ -377,14 +377,14 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
RegionView3D *rv3d = ar->regiondata;
copy_v3_v3(clip_plane, rv3d->viewinv[2]);
- clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
- clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final;
+ clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]);
+ clip_plane[3] += DIAL_CLIP_BIAS * gz->scale_final;
glEnable(GL_CLIP_DISTANCE0);
}
GPU_blend(true);
- dial_draw_intern(C, mpr, false, is_highlight, clip_plane);
+ dial_draw_intern(C, gz, false, is_highlight, clip_plane);
GPU_blend(false);
if (clip_plane) {
@@ -392,96 +392,96 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
}
}
-static int manipulator_dial_modal(
- bContext *C, wmManipulator *mpr, const wmEvent *event,
- eWM_ManipulatorTweak UNUSED(tweak_flag))
+static int gizmo_dial_modal(
+ bContext *C, wmGizmo *gz, const wmEvent *event,
+ eWM_GizmoFlagTweak UNUSED(tweak_flag))
{
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
float angle_ofs, angle_delta;
float matrix[4][4];
- dial_calc_matrix(mpr, matrix);
+ dial_calc_matrix(gz, matrix);
dial_ghostarc_get_angles(
CTX_data_depsgraph(C),
- mpr, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta);
+ gz, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta);
- DialInteraction *inter = mpr->interaction_data;
+ DialInteraction *inter = gz->interaction_data;
inter->output.angle_delta = angle_delta;
inter->output.angle_ofs = angle_ofs;
/* set the property for the operator and call its modal function */
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta);
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ WM_gizmo_target_property_value_set(C, gz, gz_prop, inter->init_prop_angle + angle_delta);
}
return OPERATOR_RUNNING_MODAL;
}
-static void manipulator_dial_setup(wmManipulator *mpr)
+static void gizmo_dial_setup(wmGizmo *gz)
{
const float dir_default[3] = {0.0f, 0.0f, 1.0f};
/* defaults */
- copy_v3_v3(mpr->matrix_basis[2], dir_default);
+ copy_v3_v3(gz->matrix_basis[2], dir_default);
}
-static int manipulator_dial_invoke(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
+static int gizmo_dial_invoke(
+ bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
{
DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__);
inter->init_mval[0] = event->mval[0];
inter->init_mval[1] = event->mval[1];
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- inter->init_prop_angle = WM_manipulator_target_property_value_get(mpr, mpr_prop);
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ inter->init_prop_angle = WM_gizmo_target_property_value_get(gz, gz_prop);
}
- mpr->interaction_data = inter;
+ gz->interaction_data = inter;
return OPERATOR_RUNNING_MODAL;
}
/* -------------------------------------------------------------------- */
-/** \name Dial Manipulator API
+/** \name Dial Gizmo API
*
* \{ */
-static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt)
+static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
{
/* identifiers */
- wt->idname = "MANIPULATOR_WT_dial_3d";
+ gzt->idname = "GIZMO_GT_dial_3d";
/* api callbacks */
- wt->draw = manipulator_dial_draw;
- wt->draw_select = manipulator_dial_draw_select;
- wt->setup = manipulator_dial_setup;
- wt->invoke = manipulator_dial_invoke;
- wt->modal = manipulator_dial_modal;
+ gzt->draw = gizmo_dial_draw;
+ gzt->draw_select = gizmo_dial_draw_select;
+ gzt->setup = gizmo_dial_setup;
+ gzt->invoke = gizmo_dial_invoke;
+ gzt->modal = gizmo_dial_modal;
- wt->struct_size = sizeof(wmManipulator);
+ gzt->struct_size = sizeof(wmGizmo);
/* rna */
static EnumPropertyItem rna_enum_draw_options[] = {
- {ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""},
- {ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
- {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""},
- {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""},
+ {ED_GIZMO_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""},
+ {ED_GIZMO_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
+ {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""},
+ {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""},
{0, NULL, 0, NULL, NULL}
};
- RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
+ RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
- WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1);
+ WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1);
}
-void ED_manipulatortypes_dial_3d(void)
+void ED_gizmotypes_dial_3d(void)
{
- WM_manipulatortype_append(MANIPULATOR_WT_dial_3d);
+ WM_gizmotype_append(GIZMO_GT_dial_3d);
}
/** \} */
diff --git a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c
new file mode 100644
index 00000000000..8d4db81c11f
--- /dev/null
+++ b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c
@@ -0,0 +1,375 @@
+/*
+ * ***** 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 grab3d_gizmo.c
+ * \ingroup wm
+ *
+ * \name Grab Gizmo
+ *
+ * 3D Gizmo, also works in 2D views.
+ *
+ * \brief Simple gizmo to grab and translate.
+ *
+ * - `matrix[0]` is derived from Y and Z.
+ * - `matrix[1]` currently not used.
+ * - `matrix[2]` is the widget direction (for all gizmos).
+ *
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "BKE_context.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_matrix.h"
+#include "GPU_select.h"
+#include "GPU_state.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_screen.h"
+#include "ED_view3d.h"
+#include "ED_gizmo_library.h"
+
+/* own includes */
+#include "../gizmo_geometry.h"
+#include "../gizmo_library_intern.h"
+
+typedef struct GrabGizmo3D {
+ wmGizmo gizmo;
+ /* Added to 'matrix_basis' when calculating the matrix. */
+ float prop_co[3];
+} GrabGizmo3D;
+
+static void gizmo_grab_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
+{
+ GrabGizmo3D *grab = (GrabGizmo3D *)gz;
+
+ copy_m4_m4(r_matrix, grab->gizmo.matrix_basis);
+ add_v3_v3(r_matrix[3], grab->prop_co);
+}
+
+static int gizmo_grab_modal(
+ bContext *C, wmGizmo *gz, const wmEvent *event,
+ eWM_GizmoFlagTweak tweak_flag);
+
+typedef struct GrabInteraction {
+ float init_mval[2];
+
+ /* only for when using properties */
+ float init_prop_co[3];
+
+ float init_matrix_final[4][4];
+} GrabInteraction;
+
+#define DIAL_RESOLUTION 32
+
+/* -------------------------------------------------------------------- */
+
+static void grab_geom_draw(
+ const wmGizmo *gz, const float color[4], const bool select, const int draw_options)
+{
+#ifdef USE_GIZMO_CUSTOM_DIAL
+ UNUSED_VARS(grab3d, col, axis_modal_mat);
+ wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_grab3d, select);
+#else
+ const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
+ const bool filled = (draw_options & ED_GIZMO_GRAB_DRAW_FLAG_FILL) != 0;
+
+ GPU_line_width(gz->line_width);
+
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+
+ immUniformColor4fv(color);
+
+ if (draw_style == ED_GIZMO_GRAB_STYLE_RING_2D) {
+ if (filled) {
+ imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION);
+ }
+ else {
+ imm_draw_circle_wire_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION);
+ }
+ }
+ else if (draw_style == ED_GIZMO_GRAB_STYLE_CROSS_2D) {
+ immBegin(GPU_PRIM_LINES, 4);
+ immVertex2f(pos, 1.0f, 1.0f);
+ immVertex2f(pos, -1.0f, -1.0f);
+
+ immVertex2f(pos, -1.0f, 1.0f);
+ immVertex2f(pos, 1.0f, -1.0f);
+ immEnd();
+ }
+ else {
+ BLI_assert(0);
+ }
+
+ immUnbindProgram();
+
+ UNUSED_VARS(select);
+#endif
+}
+
+static void grab3d_get_translate(
+ const wmGizmo *gz, const wmEvent *event, const ARegion *ar,
+ float co_delta[3])
+{
+ GrabInteraction *inter = gz->interaction_data;
+ const float mval_delta[2] = {
+ event->mval[0] - inter->init_mval[0],
+ event->mval[1] - inter->init_mval[1],
+ };
+
+ RegionView3D *rv3d = ar->regiondata;
+ float co_ref[3];
+ mul_v3_mat3_m4v3(co_ref, gz->matrix_space, inter->init_prop_co);
+ const float zfac = ED_view3d_calc_zfac(rv3d, co_ref, NULL);
+
+ ED_view3d_win_to_delta(ar, mval_delta, co_delta, zfac);
+
+ float matrix_space_inv[3][3];
+ copy_m3_m4(matrix_space_inv, gz->matrix_space);
+ invert_m3(matrix_space_inv);
+ mul_m3_v3(matrix_space_inv, co_delta);
+}
+
+static void grab3d_draw_intern(
+ const bContext *C, wmGizmo *gz,
+ const bool select, const bool highlight)
+{
+ GrabInteraction *inter = gz->interaction_data;
+ const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
+ const bool align_view = (draw_options & ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0;
+ float color[4];
+ float matrix_final[4][4];
+ float matrix_align[4][4];
+
+ gizmo_color_get(gz, highlight, color);
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
+
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
+
+ if (align_view) {
+ float matrix_final_unit[4][4];
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ normalize_m4_m4(matrix_final_unit, matrix_final);
+ mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit);
+ zero_v3(matrix_align[3]);
+ transpose_m4(matrix_align);
+ GPU_matrix_mul(matrix_align);
+ }
+
+ GPU_blend(true);
+ grab_geom_draw(gz, color, select, draw_options);
+ GPU_blend(false);
+ GPU_matrix_pop();
+
+ if (gz->interaction_data) {
+ GPU_matrix_push();
+ GPU_matrix_mul(inter->init_matrix_final);
+
+ if (align_view) {
+ GPU_matrix_mul(matrix_align);
+ }
+
+ GPU_blend(true);
+ grab_geom_draw(gz, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options);
+ GPU_blend(false);
+ GPU_matrix_pop();
+ }
+}
+
+static void gizmo_grab_draw_select(const bContext *C, wmGizmo *gz, int select_id)
+{
+ GPU_select_load_id(select_id);
+ grab3d_draw_intern(C, gz, true, false);
+}
+
+static void gizmo_grab_draw(const bContext *C, wmGizmo *gz)
+{
+ const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL;
+ const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
+
+ (void)is_modal;
+
+ GPU_blend(true);
+ grab3d_draw_intern(C, gz, false, is_highlight);
+ GPU_blend(false);
+}
+
+static int gizmo_grab_modal(
+ bContext *C, wmGizmo *gz, const wmEvent *event,
+ eWM_GizmoFlagTweak UNUSED(tweak_flag))
+{
+ GrabGizmo3D *grab = (GrabGizmo3D *)gz;
+ GrabInteraction *inter = gz->interaction_data;
+ ARegion *ar = CTX_wm_region(C);
+
+ float prop_delta[3];
+ if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) {
+ grab3d_get_translate(gz, event, ar, prop_delta);
+ }
+ else {
+ float mval_proj_init[2], mval_proj_curr[2];
+ if ((gizmo_window_project_2d(
+ C, gz, inter->init_mval, 2, false, mval_proj_init) == false) ||
+ (gizmo_window_project_2d(
+ C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false))
+ {
+ return OPERATOR_RUNNING_MODAL;
+ }
+ sub_v2_v2v2(prop_delta, mval_proj_curr, mval_proj_init);
+ prop_delta[2] = 0.0f;
+ }
+ add_v3_v3v3(grab->prop_co, inter->init_prop_co, prop_delta);
+
+ /* set the property for the operator and call its modal function */
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ WM_gizmo_target_property_value_set_array(C, gz, gz_prop, grab->prop_co);
+ }
+ else {
+ zero_v3(grab->prop_co);
+ }
+
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int gizmo_grab_invoke(
+ bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
+{
+ GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__);
+
+ inter->init_mval[0] = event->mval[0];
+ inter->init_mval[1] = event->mval[1];
+
+#if 0
+ copy_v3_v3(inter->init_prop_co, grab->prop_co);
+#else
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ WM_gizmo_target_property_value_get_array(gz, gz_prop, inter->init_prop_co);
+ }
+#endif
+
+ WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final);
+
+ gz->interaction_data = inter;
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+
+static int gizmo_grab_test_select(
+ bContext *C, wmGizmo *gz, const wmEvent *event)
+{
+ float point_local[2];
+
+ if (gizmo_window_project_2d(
+ C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
+ {
+ return -1;
+ }
+
+ /* The 'gz->scale_final' is already applied when projecting. */
+ if (len_squared_v2(point_local) < 1.0f) {
+ return 0;
+ }
+
+ return -1;
+}
+
+static void gizmo_grab_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
+{
+ GrabGizmo3D *grab = (GrabGizmo3D *)gz;
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ WM_gizmo_target_property_value_get_array(gz, gz_prop, grab->prop_co);
+ }
+ else {
+ zero_v3(grab->prop_co);
+ }
+}
+
+static int gizmo_grab_cursor_get(wmGizmo *UNUSED(gz))
+{
+ return BC_NSEW_SCROLLCURSOR;
+}
+
+/* -------------------------------------------------------------------- */
+/** \name Grab Gizmo API
+ *
+ * \{ */
+
+static void GIZMO_GT_grab_3d(wmGizmoType *gzt)
+{
+ /* identifiers */
+ gzt->idname = "GIZMO_GT_grab_3d";
+
+ /* api callbacks */
+ gzt->draw = gizmo_grab_draw;
+ gzt->draw_select = gizmo_grab_draw_select;
+ gzt->test_select = gizmo_grab_test_select;
+ gzt->matrix_basis_get = gizmo_grab_matrix_basis_get;
+ gzt->invoke = gizmo_grab_invoke;
+ gzt->property_update = gizmo_grab_property_update;
+ gzt->modal = gizmo_grab_modal;
+ gzt->cursor_get = gizmo_grab_cursor_get;
+
+ gzt->struct_size = sizeof(GrabGizmo3D);
+
+ /* rna */
+ static EnumPropertyItem rna_enum_draw_style[] = {
+ {ED_GIZMO_GRAB_STYLE_RING_2D, "RING_2D", 0, "Ring", ""},
+ {ED_GIZMO_GRAB_STYLE_CROSS_2D, "CROSS_2D", 0, "Ring", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem rna_enum_draw_options[] = {
+ {ED_GIZMO_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
+ {ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_GRAB_STYLE_RING_2D, "Draw Style", "");
+ RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
+
+ WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 3);
+}
+
+void ED_gizmotypes_grab_3d(void)
+{
+ WM_gizmotype_append(GIZMO_GT_grab_3d);
+}
+
+/** \} */ // Grab Gizmo API
diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c
new file mode 100644
index 00000000000..6443a6bf038
--- /dev/null
+++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c
@@ -0,0 +1,191 @@
+/*
+ * ***** 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 primitive3d_gizmo.c
+ * \ingroup wm
+ *
+ * \name Primitive Gizmo
+ *
+ * 3D Gizmo
+ *
+ * \brief Gizmo with primitive drawing type (plane, cube, etc.).
+ * Currently only plane primitive supported without own handling, use with operator only.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "DNA_view3d_types.h"
+
+#include "BKE_context.h"
+
+#include "BIF_gl.h"
+
+#include "GPU_immediate.h"
+#include "GPU_matrix.h"
+#include "GPU_select.h"
+#include "GPU_state.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_gizmo_library.h"
+
+/* own includes */
+#include "../gizmo_library_intern.h"
+
+static float verts_plane[4][3] = {
+ {-1, -1, 0},
+ { 1, -1, 0},
+ { 1, 1, 0},
+ {-1, 1, 0},
+};
+
+
+/* -------------------------------------------------------------------- */
+
+static void gizmo_primitive_draw_geom(
+ const float col_inner[4], const float col_outer[4], const int draw_style)
+{
+ float (*verts)[3];
+ uint vert_count = 0;
+
+ if (draw_style == ED_GIZMO_PRIMITIVE_STYLE_PLANE) {
+ verts = verts_plane;
+ vert_count = ARRAY_SIZE(verts_plane);
+ }
+
+ if (vert_count > 0) {
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+ wm_gizmo_vec_draw(col_inner, verts, vert_count, pos, GPU_PRIM_TRI_FAN);
+ wm_gizmo_vec_draw(col_outer, verts, vert_count, pos, GPU_PRIM_LINE_LOOP);
+ immUnbindProgram();
+ }
+}
+
+static void gizmo_primitive_draw_intern(
+ wmGizmo *gz, const bool UNUSED(select),
+ const bool highlight)
+{
+ float color_inner[4], color_outer[4];
+ float matrix_final[4][4];
+ const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
+
+ gizmo_color_get(gz, highlight, color_outer);
+ copy_v4_v4(color_inner, color_outer);
+ color_inner[3] *= 0.5f;
+
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
+
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
+
+ GPU_blend(true);
+ gizmo_primitive_draw_geom(color_inner, color_outer, draw_style);
+ GPU_blend(false);
+
+ GPU_matrix_pop();
+
+ if (gz->interaction_data) {
+ GizmoInteraction *inter = gz->interaction_data;
+
+ copy_v4_fl(color_inner, 0.5f);
+ copy_v3_fl(color_outer, 0.5f);
+ color_outer[3] = 0.8f;
+
+ GPU_matrix_push();
+ GPU_matrix_mul(inter->init_matrix_final);
+
+ GPU_blend(true);
+ gizmo_primitive_draw_geom(color_inner, color_outer, draw_style);
+ GPU_blend(false);
+
+ GPU_matrix_pop();
+ }
+}
+
+static void gizmo_primitive_draw_select(
+ const bContext *UNUSED(C), wmGizmo *gz,
+ int select_id)
+{
+ GPU_select_load_id(select_id);
+ gizmo_primitive_draw_intern(gz, true, false);
+}
+
+static void gizmo_primitive_draw(const bContext *UNUSED(C), wmGizmo *gz)
+{
+ gizmo_primitive_draw_intern(
+ gz, false,
+ (gz->state & WM_GIZMO_STATE_HIGHLIGHT));
+}
+
+static void gizmo_primitive_setup(wmGizmo *gz)
+{
+ gz->flag |= WM_GIZMO_DRAW_MODAL;
+}
+
+static int gizmo_primitive_invoke(
+ bContext *UNUSED(C), wmGizmo *gz, const wmEvent *UNUSED(event))
+{
+ GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__);
+
+ WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final);
+
+ gz->interaction_data = inter;
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+/* -------------------------------------------------------------------- */
+/** \name Primitive Gizmo API
+ *
+ * \{ */
+
+static void GIZMO_GT_primitive_3d(wmGizmoType *gzt)
+{
+ /* identifiers */
+ gzt->idname = "GIZMO_GT_primitive_3d";
+
+ /* api callbacks */
+ gzt->draw = gizmo_primitive_draw;
+ gzt->draw_select = gizmo_primitive_draw_select;
+ gzt->setup = gizmo_primitive_setup;
+ gzt->invoke = gizmo_primitive_invoke;
+
+ gzt->struct_size = sizeof(wmGizmo);
+
+ static EnumPropertyItem rna_enum_draw_style[] = {
+ {ED_GIZMO_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_PRIMITIVE_STYLE_PLANE, "Draw Style", "");
+}
+
+void ED_gizmotypes_primitive_3d(void)
+{
+ WM_gizmotype_append(GIZMO_GT_primitive_3d);
+}
+
+/** \} */
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a79a5052eb8..29b24886017 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -150,14 +150,14 @@ static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, f
/* draw triangulation data */
if (tot_triangles > 0) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
/* Draw all triangles for filling the polygon */
- immBegin(GWN_PRIM_TRIS, tot_triangles * 3);
+ immBegin(GPU_PRIM_TRIS, tot_triangles * 3);
/* TODO: use batch instead of immediate mode, to share vertices */
const tGPspoint *pt;
@@ -208,9 +208,9 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
return;
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
const tGPspoint *pt = points;
@@ -218,7 +218,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
/* if drawing a single point, draw it larger */
GPU_point_size((float)(thickness + 2) * points->pressure);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
gp_set_tpoint_varying_color(pt, ink, color);
immVertex2iv(pos, &pt->x);
}
@@ -228,7 +228,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
/* draw stroke curve */
GPU_line_width(max_ff(oldpressure * thickness, 1.0));
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
- immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints);
/* TODO: implement this with a geometry shader to draw one continuous tapered stroke */
@@ -247,7 +247,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
draw_points = 0;
GPU_line_width(max_ff(pt->pressure * thickness, 1.0f));
- immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
if (i != 0) {
@@ -319,14 +319,14 @@ static void gp_draw_stroke_volumetric_buffer(const tGPspoint *points, int totpoi
if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
return;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
GPU_enable_program_point_size();
- immBegin(GWN_PRIM_POINTS, totpoints);
+ immBegin(GPU_PRIM_POINTS, totpoints);
const tGPspoint *pt = points;
for (int i = 0; i < totpoints; i++, pt++) {
@@ -346,14 +346,14 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points, int totpoints
int offsx, int offsy, int winx, int winy,
const float diff_mat[4][4], const float ink[4])
{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
GPU_enable_program_point_size();
- immBegin(GWN_PRIM_POINTS, totpoints);
+ immBegin(GPU_PRIM_POINTS, totpoints);
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints; i++, pt++) {
@@ -379,14 +379,14 @@ static void gp_draw_stroke_volumetric_3d(
const bGPDspoint *points, int totpoints, short thickness,
const float ink[4])
{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
GPU_enable_program_point_size();
- immBegin(GWN_PRIM_POINTS, totpoints);
+ immBegin(GPU_PRIM_POINTS, totpoints);
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints && pt; i++, pt++) {
@@ -517,20 +517,20 @@ static void gp_draw_stroke_fill(
}
BLI_assert(gps->tot_triangles >= 1);
- unsigned int pos;
+ uint pos;
if (gps->flag & GP_STROKE_3DSPACE) {
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
}
else {
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
}
immUniformColor4fv(color);
/* Draw all triangles for filling the polygon (cache must be calculated before) */
- immBegin(GWN_PRIM_TRIS, gps->tot_triangles * 3);
+ immBegin(GPU_PRIM_TRIS, gps->tot_triangles * 3);
/* TODO: use batch instead of immediate mode, to share vertices */
bGPDtriangle *stroke_triangle = gps->triangles;
@@ -575,8 +575,8 @@ static void gp_draw_stroke_point(
float fpt[3];
mul_v3_m4v3(fpt, diff_mat, &pt->x);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
if (sflag & GP_STROKE_3DSPACE) {
immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
@@ -594,7 +594,7 @@ static void gp_draw_stroke_point(
/* set point thickness (since there's only one of these) */
immUniform1f("size", (float)(thickness + 2) * pt->pressure);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex3fv(pos, fpt);
immEnd();
@@ -617,9 +617,9 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
@@ -627,7 +627,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
/* draw stroke curve */
GPU_line_width(max_ff(curpressure * thickness, 1.0f));
- immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints + cyclic_add);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints + cyclic_add);
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints; i++, pt++) {
gp_set_point_varying_color(pt, ink, color);
@@ -648,7 +648,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
curpressure = pt->pressure;
GPU_line_width(max_ff(curpressure * thickness, 1.0f));
- immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
if (i != 0) {
@@ -716,12 +716,12 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, int totpoints, short thi
int i;
float fpt[3];
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_TRI_STRIP, totpoints * 2 + 4);
+ immBegin(GPU_PRIM_TRI_STRIP, totpoints * 2 + 4);
/* get x and y coordinates from first point */
mul_v3_m4v3(fpt, diff_mat, &points->x);
@@ -1150,21 +1150,21 @@ static void gp_draw_strokes_edit(
UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, selectColor);
selectColor[3] = alpha;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos; /* specified later */
- unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos; /* specified later */
+ uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
if (gps->flag & GP_STROKE_3DSPACE) {
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
}
else {
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR);
}
- immBegin(GWN_PRIM_POINTS, gps->totpoints);
+ immBegin(GPU_PRIM_POINTS, gps->totpoints);
/* Draw start and end point differently if enabled stroke direction hint */
bool show_direction_hint = (gpd->flag & GP_DATA_SHOW_DIRECTION) && (gps->totpoints > 1);
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 75e4c510bcf..bd9bfcf7025 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -985,8 +985,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda
GP_EditBrush_Data *brush = gpsculpt_get_brush(CTX_data_scene(C));
if (brush) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_line_smooth(true);
@@ -1832,7 +1832,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
case DOWNARROWKEY:
return OPERATOR_PASS_THROUGH;
- /* Camera/View Manipulations - Allowed */
+ /* Camera/View Gizmo's - Allowed */
/* (See rationale in gpencil_paint.c -> gpencil_draw_modal()) */
case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index f22d653800e..3f114a4dd4a 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -184,7 +184,9 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
/* Selection ------------------------------------- */
/* select all */
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index ec8a213301f..789e9865ae4 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1875,8 +1875,8 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
tGPsdata *p = (tGPsdata *)p_ptr;
if (p->paintmode == GP_PAINTMODE_ERASER) {
- Gwn_VertFormat *format = immVertexFormat();
- const uint shdr_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ const uint shdr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_line_smooth(true);
diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h
new file mode 100644
index 00000000000..2bf3488a8d3
--- /dev/null
+++ b/source/blender/editors/include/ED_gizmo_library.h
@@ -0,0 +1,222 @@
+/*
+ * ***** 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 ED_gizmo_library.h
+ * \ingroup wm
+ *
+ * \name Generic Gizmos.
+ *
+ * This is exposes pre-defined gizmos for re-use.
+ */
+
+
+#ifndef __ED_GIZMO_LIBRARY_H__
+#define __ED_GIZMO_LIBRARY_H__
+
+/* initialize gizmos */
+void ED_gizmotypes_arrow_2d(void);
+void ED_gizmotypes_arrow_3d(void);
+void ED_gizmotypes_button_2d(void);
+void ED_gizmotypes_cage_2d(void);
+void ED_gizmotypes_cage_3d(void);
+void ED_gizmotypes_dial_3d(void);
+void ED_gizmotypes_grab_3d(void);
+void ED_gizmotypes_facemap_3d(void);
+void ED_gizmotypes_primitive_3d(void);
+
+struct wmGizmo;
+struct wmGizmoGroup;
+
+
+/* -------------------------------------------------------------------- */
+/* Shape Presets
+ *
+ * Intended to be called by custom draw functions.
+ */
+
+/* gizmo_library_presets.c */
+void ED_gizmo_draw_preset_box(
+ const struct wmGizmo *gz, float mat[4][4], int select_id);
+void ED_gizmo_draw_preset_arrow(
+ const struct wmGizmo *gz, float mat[4][4], int axis, int select_id);
+void ED_gizmo_draw_preset_circle(
+ const struct wmGizmo *gz, float mat[4][4], int axis, int select_id);
+void ED_gizmo_draw_preset_facemap(
+ const struct bContext *C, const struct wmGizmo *gz, struct Scene *scene,
+ struct Object *ob, const int facemap, int select_id);
+
+
+/* -------------------------------------------------------------------- */
+/* 3D Arrow Gizmo */
+
+enum {
+ ED_GIZMO_ARROW_STYLE_NORMAL = 0,
+ ED_GIZMO_ARROW_STYLE_CROSS = 1,
+ ED_GIZMO_ARROW_STYLE_BOX = 2,
+ ED_GIZMO_ARROW_STYLE_CONE = 3,
+};
+
+/* transform */
+enum {
+ /* inverted offset during interaction - if set it also sets constrained below */
+ ED_GIZMO_ARROW_XFORM_FLAG_INVERTED = (1 << 3),
+ /* clamp arrow interaction to property width */
+ ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED = (1 << 4),
+};
+
+/* draw_options */
+enum {
+ /* Show arrow stem. */
+ ED_GIZMO_ARROW_DRAW_FLAG_STEM = (1 << 0),
+};
+
+void ED_gizmo_arrow3d_set_ui_range(struct wmGizmo *gz, const float min, const float max);
+void ED_gizmo_arrow3d_set_range_fac(struct wmGizmo *gz, const float range_fac);
+
+/* -------------------------------------------------------------------- */
+/* 2D Arrow Gizmo */
+
+/* none */
+
+/* -------------------------------------------------------------------- */
+/* Cage Gizmo */
+
+enum {
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE = (1 << 0), /* Translates */
+ ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE = (1 << 1), /* Rotates */
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE = (1 << 2), /* Scales */
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Scales uniformly */
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED = (1 << 4), /* Negative scale allowed */
+};
+
+/* draw_style */
+enum {
+ ED_GIZMO_CAGE2D_STYLE_BOX = 0,
+ ED_GIZMO_CAGE2D_STYLE_CIRCLE = 1,
+};
+
+/* draw_options */
+enum {
+ /** Draw a central handle (instead of having the entire area selectable)
+ * Needed for large rectangles that we don't want to swallow all events. */
+ ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE = (1 << 0),
+};
+
+/** #wmGizmo.highlight_part */
+enum {
+ ED_GIZMO_CAGE2D_PART_TRANSLATE = 0,
+ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X = 1,
+ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X = 2,
+ ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y = 3,
+ ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y = 4,
+ /* Corners */
+ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y = 5,
+ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y = 6,
+ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y = 7,
+ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y = 8,
+
+ ED_GIZMO_CAGE2D_PART_ROTATE = 9,
+};
+
+/** #wmGizmo.highlight_part */
+enum {
+ /* ordered min/mid/max so we can loop over values (MIN/MID/MAX) on each axis. */
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z = 0,
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MAX_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MIN_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MAX_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MIN_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MAX_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MIN_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MAX_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MIN_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MAX_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MIN_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MAX_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MIN_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MAX_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MIN_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MAX_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MIN_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MID_Z,
+ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z,
+
+ ED_GIZMO_CAGE3D_PART_TRANSLATE,
+
+ ED_GIZMO_CAGE3D_PART_ROTATE,
+};
+
+/* -------------------------------------------------------------------- */
+/* Dial Gizmo */
+
+/* draw_options */
+enum {
+ ED_GIZMO_DIAL_DRAW_FLAG_NOP = 0,
+ ED_GIZMO_DIAL_DRAW_FLAG_CLIP = (1 << 0),
+ ED_GIZMO_DIAL_DRAW_FLAG_FILL = (1 << 1),
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 2),
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 3),
+};
+
+/* -------------------------------------------------------------------- */
+/* Grab Gizmo */
+
+/* draw_options */
+enum {
+ ED_GIZMO_GRAB_DRAW_FLAG_NOP = 0,
+ /* only for solid shapes */
+ ED_GIZMO_GRAB_DRAW_FLAG_FILL = (1 << 0),
+ ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW = (1 << 1),
+};
+
+enum {
+ ED_GIZMO_GRAB_STYLE_RING_2D = 0,
+ ED_GIZMO_GRAB_STYLE_CROSS_2D = 1,
+};
+
+/* -------------------------------------------------------------------- */
+/* Button Gizmo */
+
+enum {
+ ED_GIZMO_BUTTON_SHOW_OUTLINE = (1 << 0),
+ /**
+ * Draw a line from the origin to the offset (similar to an arrow)
+ * sometimes needed to show what the button edits.
+ */
+ ED_GIZMO_BUTTON_SHOW_HELPLINE = (1 << 1),
+};
+
+
+/* -------------------------------------------------------------------- */
+/* Primitive Gizmo */
+
+enum {
+ ED_GIZMO_PRIMITIVE_STYLE_PLANE = 0,
+};
+
+#endif /* __ED_GIZMO_LIBRARY_H__ */
diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h
index 9b0b2c970b2..64dee410526 100644
--- a/source/blender/editors/include/ED_keyframes_draw.h
+++ b/source/blender/editors/include/ED_keyframes_draw.h
@@ -109,7 +109,7 @@ typedef enum eKeyframeShapeDrawOpts {
} eKeyframeShapeDrawOpts;
/* draw simple diamond-shape keyframe */
-/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(GWN_PRIM_POINTS, n), then call this n times */
+/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(GPU_PRIM_POINTS, n), then call this n times */
void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type, short mode, float alpha,
unsigned int pos_id, unsigned int size_id, unsigned int color_id, unsigned int outline_color_id);
diff --git a/source/blender/editors/include/ED_manipulator_library.h b/source/blender/editors/include/ED_manipulator_library.h
deleted file mode 100644
index fca0f5c8806..00000000000
--- a/source/blender/editors/include/ED_manipulator_library.h
+++ /dev/null
@@ -1,222 +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 ED_manipulator_library.h
- * \ingroup wm
- *
- * \name Generic Manipulators.
- *
- * This is exposes pre-defined manipulators for re-use.
- */
-
-
-#ifndef __ED_MANIPULATOR_LIBRARY_H__
-#define __ED_MANIPULATOR_LIBRARY_H__
-
-/* initialize manipulators */
-void ED_manipulatortypes_arrow_2d(void);
-void ED_manipulatortypes_arrow_3d(void);
-void ED_manipulatortypes_button_2d(void);
-void ED_manipulatortypes_cage_2d(void);
-void ED_manipulatortypes_cage_3d(void);
-void ED_manipulatortypes_dial_3d(void);
-void ED_manipulatortypes_grab_3d(void);
-void ED_manipulatortypes_facemap_3d(void);
-void ED_manipulatortypes_primitive_3d(void);
-
-struct wmManipulator;
-struct wmManipulatorGroup;
-
-
-/* -------------------------------------------------------------------- */
-/* Shape Presets
- *
- * Intended to be called by custom draw functions.
- */
-
-/* manipulator_library_presets.c */
-void ED_manipulator_draw_preset_box(
- const struct wmManipulator *mpr, float mat[4][4], int select_id);
-void ED_manipulator_draw_preset_arrow(
- const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id);
-void ED_manipulator_draw_preset_circle(
- const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id);
-void ED_manipulator_draw_preset_facemap(
- const struct bContext *C, const struct wmManipulator *mpr, struct Scene *scene,
- struct Object *ob, const int facemap, int select_id);
-
-
-/* -------------------------------------------------------------------- */
-/* 3D Arrow Manipulator */
-
-enum {
- ED_MANIPULATOR_ARROW_STYLE_NORMAL = 0,
- ED_MANIPULATOR_ARROW_STYLE_CROSS = 1,
- ED_MANIPULATOR_ARROW_STYLE_BOX = 2,
- ED_MANIPULATOR_ARROW_STYLE_CONE = 3,
-};
-
-/* transform */
-enum {
- /* inverted offset during interaction - if set it also sets constrained below */
- ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED = (1 << 3),
- /* clamp arrow interaction to property width */
- ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED = (1 << 4),
-};
-
-/* draw_options */
-enum {
- /* Show arrow stem. */
- ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM = (1 << 0),
-};
-
-void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *mpr, const float min, const float max);
-void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const float range_fac);
-
-/* -------------------------------------------------------------------- */
-/* 2D Arrow Manipulator */
-
-/* none */
-
-/* -------------------------------------------------------------------- */
-/* Cage Manipulator */
-
-enum {
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE = (1 << 0), /* Translates */
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE = (1 << 1), /* Rotates */
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE = (1 << 2), /* Scales */
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Scales uniformly */
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED = (1 << 4), /* Negative scale allowed */
-};
-
-/* draw_style */
-enum {
- ED_MANIPULATOR_CAGE2D_STYLE_BOX = 0,
- ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE = 1,
-};
-
-/* draw_options */
-enum {
- /** Draw a central handle (instead of having the entire area selectable)
- * Needed for large rectangles that we don't want to swallow all events. */
- ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE = (1 << 0),
-};
-
-/** #wmManipulator.highlight_part */
-enum {
- ED_MANIPULATOR_CAGE2D_PART_TRANSLATE = 0,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X = 1,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X = 2,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y = 3,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y = 4,
- /* Corners */
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y = 5,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y = 6,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y = 7,
- ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y = 8,
-
- ED_MANIPULATOR_CAGE2D_PART_ROTATE = 9,
-};
-
-/** #wmManipulator.highlight_part */
-enum {
- /* ordered min/mid/max so we can loop over values (MIN/MID/MAX) on each axis. */
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z = 0,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MAX_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MIN_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MAX_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MIN_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MAX_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MIN_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MAX_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MIN_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MAX_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MIN_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MAX_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MIN_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MAX_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MIN_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MAX_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MIN_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MID_Z,
- ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z,
-
- ED_MANIPULATOR_CAGE3D_PART_TRANSLATE,
-
- ED_MANIPULATOR_CAGE3D_PART_ROTATE,
-};
-
-/* -------------------------------------------------------------------- */
-/* Dial Manipulator */
-
-/* draw_options */
-enum {
- ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP = 0,
- ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP = (1 << 0),
- ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL = (1 << 1),
- ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 2),
- ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 3),
-};
-
-/* -------------------------------------------------------------------- */
-/* Grab Manipulator */
-
-/* draw_options */
-enum {
- ED_MANIPULATOR_GRAB_DRAW_FLAG_NOP = 0,
- /* only for solid shapes */
- ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL = (1 << 0),
- ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW = (1 << 1),
-};
-
-enum {
- ED_MANIPULATOR_GRAB_STYLE_RING_2D = 0,
- ED_MANIPULATOR_GRAB_STYLE_CROSS_2D = 1,
-};
-
-/* -------------------------------------------------------------------- */
-/* Button Manipulator */
-
-enum {
- ED_MANIPULATOR_BUTTON_SHOW_OUTLINE = (1 << 0),
- /**
- * Draw a line from the origin to the offset (similar to an arrow)
- * sometimes needed to show what the button edits.
- */
- ED_MANIPULATOR_BUTTON_SHOW_HELPLINE = (1 << 1),
-};
-
-
-/* -------------------------------------------------------------------- */
-/* Primitive Manipulator */
-
-enum {
- ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE = 0,
-};
-
-#endif /* __ED_MANIPULATOR_LIBRARY_H__ */
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 29f7edaebf0..38545137740 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -62,6 +62,7 @@ struct Depsgraph;
struct uiLayout;
#include "DNA_object_enums.h"
+#include "BLI_compiler_attrs.h"
/* object_edit.c */
struct Object *ED_object_context(struct bContext *C); /* context.object */
diff --git a/source/blender/editors/include/ED_scene.h b/source/blender/editors/include/ED_scene.h
index 9b48187e541..116d9bd24fc 100644
--- a/source/blender/editors/include/ED_scene.h
+++ b/source/blender/editors/include/ED_scene.h
@@ -31,10 +31,7 @@ enum eSceneCopyMethod;
struct Scene *ED_scene_add(struct Main *bmain, struct bContext *C, struct wmWindow *win, enum eSceneCopyMethod method) ATTR_NONNULL();
bool ED_scene_delete(struct bContext *C, struct Main *bmain, struct wmWindow *win, struct Scene *scene) ATTR_NONNULL();
-void ED_scene_change_update(
- struct Main *bmain, struct bContext *C,
- struct wmWindow *win, const struct bScreen *screen,
- struct Scene *scene_old, struct Scene *scene_new) ATTR_NONNULL();
+void ED_scene_change_update(struct Main *bmain, struct Scene *scene, struct ViewLayer *layer) ATTR_NONNULL();
bool ED_scene_view_layer_delete(
struct Main *bmain, struct Scene *scene, struct ViewLayer *layer,
struct ReportList *reports) ATTR_NONNULL(1, 2, 3);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 1a7055e2cfa..2445cbdb16c 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -67,7 +67,7 @@ struct PropertyRNA;
/* regions */
void ED_region_do_listen(
- struct bScreen *sc, struct ScrArea *sa, struct ARegion *ar,
+ struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar,
struct wmNotifier *note, const Scene *scene);
void ED_region_do_layout(struct bContext *C, struct ARegion *ar);
void ED_region_do_draw(struct bContext *C, struct ARegion *ar);
@@ -137,8 +137,7 @@ void ED_area_exit(struct bContext *C, struct ScrArea *sa);
int ED_screen_area_active(const struct bContext *C);
void ED_screen_global_areas_create(
struct wmWindow *win);
-void ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, Scene *scene,
- struct WorkSpace *workspace);
+void ED_area_do_listen(struct wmWindow *win, ScrArea *sa, struct wmNotifier *note, Scene *scene);
void ED_area_tag_redraw(ScrArea *sa);
void ED_area_tag_redraw_no_rebuild(ScrArea *sa);
void ED_area_tag_redraw_regiontype(ScrArea *sa, int type);
@@ -185,10 +184,7 @@ void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *win, struct bScreen *screen);
void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
bool ED_screen_change(struct bContext *C, struct bScreen *sc);
-void ED_screen_update_after_scene_change(
- const struct bScreen *screen,
- struct Scene *scene_new,
- struct ViewLayer *view_layer);
+void ED_screen_scene_change(struct bContext *C, struct wmWindow *win, struct Scene *scene);
void ED_screen_set_active_region(struct bContext *C, struct wmWindow *win, const int xy[2]);
void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
void ED_screen_animation_timer(struct bContext *C, int redraws, int refresh, int sync, int enable);
@@ -208,9 +204,7 @@ void ED_screen_preview_render(const struct bScreen *screen, int size_x, int s
/* workspaces */
struct WorkSpace *ED_workspace_add(
struct Main *bmain,
- const char *name,
- Scene *scene,
- ViewLayer *act_render_layer) ATTR_NONNULL();
+ const char *name) ATTR_NONNULL();
bool ED_workspace_change(
struct WorkSpace *workspace_new,
struct bContext *C,
@@ -224,9 +218,6 @@ bool ED_workspace_delete(
struct wmWindowManager *wm) ATTR_NONNULL();
void ED_workspace_scene_data_sync(
struct WorkSpaceInstanceHook *hook, Scene *scene) ATTR_NONNULL();
-void ED_workspace_view_layer_unset(
- const struct Main *bmain, struct Scene *scene,
- const ViewLayer *layer_unset, ViewLayer *layer_new) ATTR_NONNULL(1, 2);
struct WorkSpaceLayout *ED_workspace_layout_add(
struct Main *bmain,
struct WorkSpace *workspace,
@@ -243,11 +234,6 @@ bool ED_workspace_layout_cycle(
struct WorkSpace *workspace, const short direction,
struct bContext *C) ATTR_NONNULL();
-void ED_workspace_object_mode_sync_from_object(
- struct wmWindowManager *wm, WorkSpace *workspace, struct Object *obact);
-void ED_workspace_object_mode_sync_from_scene(
- struct wmWindowManager *wm, WorkSpace *workspace, struct Scene *scene);
-
void ED_workspace_status_text(struct bContext *C, const char *str);
/* anim */
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index c005f83b3fb..a8e8b347da2 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -114,8 +114,8 @@ bool calculateTransformCenter(struct bContext *C, int centerMode, float cent3d[3
struct TransInfo;
struct Scene;
struct Object;
-struct wmManipulatorGroup;
-struct wmManipulatorGroupType;
+struct wmGizmoGroup;
+struct wmGizmoGroupType;
struct wmOperator;
/* UNUSED */
@@ -159,15 +159,15 @@ int BIF_countTransformOrientation(const struct bContext *C);
void Transform_Properties(struct wmOperatorType *ot, int flags);
-/* transform manipulators */
+/* transform gizmos */
-void TRANSFORM_WGT_manipulator(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_xform_cage(struct wmManipulatorGroupType *wgt);
+void TRANSFORM_GGT_gizmo(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_xform_cage(struct wmGizmoGroupType *gzgt);
-bool ED_widgetgroup_manipulator2d_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt);
-void ED_widgetgroup_manipulator2d_setup(const struct bContext *C, struct wmManipulatorGroup *mgroup);
-void ED_widgetgroup_manipulator2d_refresh(const struct bContext *C, struct wmManipulatorGroup *mgroup);
-void ED_widgetgroup_manipulator2d_draw_prepare(const struct bContext *C, struct wmManipulatorGroup *mgroup);
+bool ED_widgetgroup_gizmo2d_poll(const struct bContext *C, struct wmGizmoGroupType *gzgt);
+void ED_widgetgroup_gizmo2d_setup(const struct bContext *C, struct wmGizmoGroup *gzgroup);
+void ED_widgetgroup_gizmo2d_refresh(const struct bContext *C, struct wmGizmoGroup *gzgroup);
+void ED_widgetgroup_gizmo2d_draw_prepare(const struct bContext *C, struct wmGizmoGroup *gzgroup);
/* Snapping */
@@ -213,7 +213,7 @@ struct TransformCalcParams {
/* Use 'Scene.orientation_type' when zero, otherwise subtract one and use. */
ushort orientation_type;
};
-int ED_transform_calc_manipulator_stats(
+int ED_transform_calc_gizmo_stats(
const struct bContext *C,
const struct TransformCalcParams *params,
struct TransformBounds *tbounds);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index efcf5978968..516b121031e 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -523,7 +523,7 @@ void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *a
void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa);
#define V3D_IS_ZBUF(v3d) \
- (((v3d)->flag & V3D_ZBUF_SELECT) && ((v3d)->drawtype > OB_WIRE))
+ (((v3d)->flag & V3D_ZBUF_SELECT) && ((v3d)->shading.type > OB_WIRE))
void ED_view3d_id_remap(struct View3D *v3d, const struct ID *old_id, struct ID *new_id);
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 4c67a306e75..ec4c7dddd4c 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -119,7 +119,7 @@ DEF_ICON(FULLSCREEN_EXIT)
DEF_ICON(BLANK1) // Not actually blank - this is used all over the place
/* BUTTONS */
-DEF_ICON(LAMP)
+DEF_ICON(LIGHT)
DEF_ICON(MATERIAL)
DEF_ICON(TEXTURE)
DEF_ICON(ANIM)
@@ -216,7 +216,7 @@ DEF_ICON(MESH_DATA)
DEF_ICON(CURVE_DATA)
DEF_ICON(META_DATA)
DEF_ICON(LATTICE_DATA)
-DEF_ICON(LAMP_DATA)
+DEF_ICON(LIGHT_DATA)
DEF_ICON(MATERIAL_DATA)
DEF_ICON(TEXTURE_DATA)
DEF_ICON(ANIM_DATA)
@@ -304,7 +304,7 @@ DEF_ICON(OUTLINER_OB_MESH)
DEF_ICON(OUTLINER_OB_CURVE)
DEF_ICON(OUTLINER_OB_LATTICE)
DEF_ICON(OUTLINER_OB_META)
-DEF_ICON(OUTLINER_OB_LAMP)
+DEF_ICON(OUTLINER_OB_LIGHT)
DEF_ICON(OUTLINER_OB_CAMERA)
DEF_ICON(OUTLINER_OB_ARMATURE)
DEF_ICON(OUTLINER_OB_FONT)
@@ -336,7 +336,7 @@ DEF_ICON(OUTLINER_DATA_MESH)
DEF_ICON(OUTLINER_DATA_CURVE)
DEF_ICON(OUTLINER_DATA_LATTICE)
DEF_ICON(OUTLINER_DATA_META)
-DEF_ICON(OUTLINER_DATA_LAMP)
+DEF_ICON(OUTLINER_DATA_LIGHT)
DEF_ICON(OUTLINER_DATA_CAMERA)
DEF_ICON(OUTLINER_DATA_ARMATURE)
DEF_ICON(OUTLINER_DATA_FONT)
@@ -377,11 +377,11 @@ DEF_ICON(MESH_CAPSULE)
#ifndef DEF_ICON_BLANK_SKIP
DEF_ICON(BLANK611)
#endif
-DEF_ICON(LAMP_POINT)
-DEF_ICON(LAMP_SUN)
-DEF_ICON(LAMP_SPOT)
-DEF_ICON(LAMP_HEMI)
-DEF_ICON(LAMP_AREA)
+DEF_ICON(LIGHT_POINT)
+DEF_ICON(LIGHT_SUN)
+DEF_ICON(LIGHT_SPOT)
+DEF_ICON(LIGHT_HEMI)
+DEF_ICON(LIGHT_AREA)
#ifndef DEF_ICON_BLANK_SKIP
DEF_ICON(BLANK617)
DEF_ICON(BLANK618)
@@ -728,12 +728,10 @@ DEF_ICON(PASTEDOWN)
DEF_ICON(COPYDOWN)
DEF_ICON(PASTEFLIPUP)
DEF_ICON(PASTEFLIPDOWN)
-#ifndef DEF_ICON_BLANK_SKIP
- DEF_ICON(BLANK227)
- DEF_ICON(BLANK228)
- DEF_ICON(BLANK229)
- DEF_ICON(BLANK230)
-#endif
+DEF_ICON(VIS_SEL_11)
+DEF_ICON(VIS_SEL_10)
+DEF_ICON(VIS_SEL_01)
+DEF_ICON(VIS_SEL_00)
DEF_ICON(SNAP_SURFACE)
DEF_ICON(AUTOMERGE_ON)
DEF_ICON(AUTOMERGE_OFF)
@@ -1032,3 +1030,55 @@ DEF_VICO(COLORSET_17_VEC)
DEF_VICO(COLORSET_18_VEC)
DEF_VICO(COLORSET_19_VEC)
DEF_VICO(COLORSET_20_VEC)
+
+/* Events */
+DEF_ICON(EVENT_A)
+DEF_ICON(EVENT_B)
+DEF_ICON(EVENT_C)
+DEF_ICON(EVENT_D)
+DEF_ICON(EVENT_E)
+DEF_ICON(EVENT_F)
+DEF_ICON(EVENT_G)
+DEF_ICON(EVENT_H)
+DEF_ICON(EVENT_I)
+DEF_ICON(EVENT_J)
+DEF_ICON(EVENT_K)
+DEF_ICON(EVENT_L)
+DEF_ICON(EVENT_M)
+DEF_ICON(EVENT_N)
+DEF_ICON(EVENT_O)
+DEF_ICON(EVENT_P)
+DEF_ICON(EVENT_Q)
+DEF_ICON(EVENT_R)
+DEF_ICON(EVENT_S)
+DEF_ICON(EVENT_T)
+DEF_ICON(EVENT_U)
+DEF_ICON(EVENT_V)
+DEF_ICON(EVENT_W)
+DEF_ICON(EVENT_X)
+DEF_ICON(EVENT_Y)
+DEF_ICON(EVENT_Z)
+DEF_ICON(EVENT_SHIFT)
+DEF_ICON(EVENT_CTRL)
+DEF_ICON(EVENT_ALT)
+DEF_ICON(EVENT_OS)
+DEF_ICON(EVENT_F1)
+DEF_ICON(EVENT_F2)
+DEF_ICON(EVENT_F3)
+DEF_ICON(EVENT_F4)
+DEF_ICON(EVENT_F5)
+DEF_ICON(EVENT_F6)
+DEF_ICON(EVENT_F7)
+DEF_ICON(EVENT_F8)
+DEF_ICON(EVENT_F9)
+DEF_ICON(EVENT_F10)
+DEF_ICON(EVENT_F11)
+DEF_ICON(EVENT_F12)
+DEF_ICON(EVENT_ESC)
+DEF_ICON(EVENT_TAB)
+DEF_ICON(EVENT_PAGEUP)
+DEF_ICON(EVENT_PAGEDOWN)
+DEF_ICON(EVENT_HOME)
+DEF_ICON(EVENT_END)
+DEF_ICON(EVENT_RETURN)
+/* add as needed. */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index e5218e287d4..087e0c4ab7b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -73,9 +73,10 @@ struct bNodeSocket;
struct wmDropBox;
struct wmDrag;
struct wmEvent;
-struct wmManipulator;
+struct wmGizmo;
struct wmMsgBus;
struct wmKeyMap;
+struct wmKeyMapItem;
typedef struct uiBut uiBut;
typedef struct uiBlock uiBlock;
@@ -233,6 +234,8 @@ enum {
UI_BUT_ACTIVE_LEFT = (1 << 21), /* Active left part of number button */
UI_BUT_ACTIVE_RIGHT = (1 << 22), /* Active right part of number button */
+
+ UI_BUT_HAS_SHORTCUT = (1 << 23), /* Button has shortcut text */
};
/* scale fixed button widths by this to account for DPI */
@@ -441,10 +444,10 @@ void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *b
typedef struct uiPopover uiPopover;
int UI_popover_panel_invoke(
- struct bContext *C, int space_id, int region_id, const char *idname,
+ struct bContext *C, const char *idname,
bool keep_open, struct ReportList *reports);
-uiPopover *UI_popover_begin(struct bContext *C) ATTR_NONNULL(1);
+uiPopover *UI_popover_begin(struct bContext *C, int menu_width) ATTR_NONNULL(1);
void UI_popover_end(struct bContext *C, struct uiPopover *head, struct wmKeyMap *keymap);
struct uiLayout *UI_popover_layout(uiPopover *head);
void UI_popover_once_clear(uiPopover *pup);
@@ -552,7 +555,7 @@ void UI_but_drag_set_path(uiBut *but, const char *path, const bool use_free);
void UI_but_drag_set_name(uiBut *but, const char *name);
void UI_but_drag_set_value(uiBut *but);
void UI_but_drag_set_image(
- uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale, const bool use_free);
+ uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale, const bool use_free);
bool UI_but_active_drop_name(struct bContext *C);
bool UI_but_active_drop_color(struct bContext *C);
@@ -590,13 +593,14 @@ bool UI_but_online_manual_id_from_active(
* - R: RNA
* - O: operator */
-uiBut *uiDefBut(uiBlock *block,
- int type, int retval, const char *str,
- int x1, int y1,
- short x2, short y2,
- void *poin,
- float min, float max,
- float a1, float a2, const char *tip);
+uiBut *uiDefBut(
+ uiBlock *block,
+ int type, int retval, const char *str,
+ int x1, int y1,
+ short x2, short y2,
+ void *poin,
+ float min, float max,
+ float a1, float a2, const char *tip);
uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
@@ -610,13 +614,14 @@ uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int
uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip);
uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip);
-uiBut *uiDefIconBut(uiBlock *block,
- int type, int retval, int icon,
- int x1, int y1,
- short x2, short y2,
- void *poin,
- float min, float max,
- float a1, float a2, const char *tip);
+uiBut *uiDefIconBut(
+ uiBlock *block,
+ int type, int retval, int icon,
+ int x1, int y1,
+ short x2, short y2,
+ void *poin,
+ float min, float max,
+ float a1, float a2, const char *tip);
uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
@@ -630,13 +635,14 @@ uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x,
uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x, int y, short width, short height, const char *tip);
uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x, int y, short width, short height, const char *tip);
-uiBut *uiDefIconTextBut(uiBlock *block,
- int type, int retval, int icon, const char *str,
- int x1, int y1,
- short x2, short y2,
- void *poin,
- float min, float max,
- float a1, float a2, const char *tip);
+uiBut *uiDefIconTextBut(
+ uiBlock *block,
+ int type, int retval, int icon, const char *str,
+ int x1, int y1,
+ short x2, short y2,
+ void *poin,
+ float min, float max,
+ float a1, float a2, const char *tip);
uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
@@ -721,6 +727,9 @@ enum {
int UI_icon_from_id(struct ID *id);
int UI_icon_from_report_type(int type);
+int UI_icon_from_event_type(short event_type, short event_value);
+int UI_icon_from_keymap_item(const struct wmKeyMapItem *kmi, int r_icon_mod[4]);
+
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip);
@@ -736,9 +745,10 @@ uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y
uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *keypoin, short *modkeypoin, const char *tip);
uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip);
-uiBut *uiDefSearchButO_ptr(uiBlock *block, struct wmOperatorType *ot, struct IDProperty *properties,
- void *arg, int retval, int icon, int maxlen, int x, int y,
- short width, short height, float a1, float a2, const char *tip);
+uiBut *uiDefSearchButO_ptr(
+ uiBlock *block, struct wmOperatorType *ot, struct IDProperty *properties,
+ void *arg, int retval, int icon, int maxlen, int x, int y,
+ short width, short height, float a1, float a2, const char *tip);
/* For uiDefAutoButsRNA */
@@ -799,8 +809,9 @@ void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN);
void UI_but_tooltip_refresh(struct bContext *C, uiBut *but);
void UI_but_tooltip_timer_remove(struct bContext *C, uiBut *but);
-bool UI_textbutton_activate_rna(const struct bContext *C, struct ARegion *ar,
- const void *rna_poin_data, const char *rna_prop_id);
+bool UI_textbutton_activate_rna(
+ const struct bContext *C, struct ARegion *ar,
+ const void *rna_poin_data, const char *rna_prop_id);
bool UI_textbutton_activate_but(const struct bContext *C, uiBut *but);
void UI_but_focus_on_enter_event(struct wmWindow *win, uiBut *but);
@@ -834,9 +845,10 @@ void UI_panels_end(const struct bContext *C, struct ARegion *ar, int *x, int *y)
void UI_panels_draw(const struct bContext *C, struct ARegion *ar);
struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt);
-struct Panel *UI_panel_begin(struct ScrArea *sa, struct ARegion *ar, struct ListBase *lb,
- uiBlock *block, struct PanelType *pt, struct Panel *pa,
- bool *r_open);
+struct Panel *UI_panel_begin(
+ struct ScrArea *sa, struct ARegion *ar, struct ListBase *lb,
+ uiBlock *block, struct PanelType *pt, struct Panel *pa,
+ bool *r_open);
void UI_panel_end(uiBlock *block, int width, int height);
void UI_panels_scale(struct ARegion *ar, float new_width);
void UI_panel_label_offset(struct uiBlock *block, int *x, int *y);
@@ -996,8 +1008,9 @@ uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, bool align);
uiLayout *uiLayoutGridFlow(
uiLayout *layout, bool row_major, int columns_len, bool even_columns, bool even_rows, bool align);
uiLayout *uiLayoutBox(uiLayout *layout);
-uiLayout *uiLayoutListBox(uiLayout *layout, struct uiList *ui_list, struct PointerRNA *ptr, struct PropertyRNA *prop,
- struct PointerRNA *actptr, struct PropertyRNA *actprop);
+uiLayout *uiLayoutListBox(
+ uiLayout *layout, struct uiList *ui_list, struct PointerRNA *ptr, struct PropertyRNA *prop,
+ struct PointerRNA *actptr, struct PropertyRNA *actprop);
uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align);
uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align);
uiLayout *uiLayoutOverlap(uiLayout *layout);
@@ -1020,8 +1033,9 @@ void uiTemplateIDTabs(
PointerRNA *ptr, const char *propname,
const char *newop, const char *openop, const char *unlinkop,
int filter);
-void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
- const char *proptypename, const char *text);
+void uiTemplateAnyID(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname,
+ const char *proptypename, const char *text);
void uiTemplateSearch(
uiLayout *layout, struct bContext *C,
struct PointerRNA *ptr, const char *propname,
@@ -1033,27 +1047,32 @@ void uiTemplateSearchPreview(
struct PointerRNA *searchptr, const char *searchpropname,
const char *newop, const char *unlinkop,
const int rows, const int cols);
-void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
- struct PointerRNA *root_ptr, const char *text);
+void uiTemplatePathBuilder(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname,
+ struct PointerRNA *root_ptr, const char *text);
uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
void uiTemplateOperatorRedoProperties(uiLayout *layout, const struct bContext *C);
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
-void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, bool show_buttons, struct ID *parent,
- struct MTex *slot, const char *preview_id);
+void uiTemplatePreview(
+ uiLayout *layout, struct bContext *C, struct ID *id, bool show_buttons, struct ID *parent,
+ struct MTex *slot, const char *preview_id);
void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool expand);
void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale);
void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool show_labels, float icon_scale);
void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
-void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type,
- bool levels, bool brush, bool neg_slope);
+void uiTemplateCurveMapping(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type,
+ bool levels, bool brush, bool neg_slope);
void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic);
void uiTemplatePalette(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool color);
-void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
- PointerRNA *used_ptr, const char *used_propname, int active_layer);
+void uiTemplateCryptoPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
+void uiTemplateLayers(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname,
+ PointerRNA *used_ptr, const char *used_propname, int active_layer);
void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, bool compact, bool multiview);
void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, bool color_management);
void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA *stereo3d_format_ptr);
@@ -1080,10 +1099,11 @@ void uiTemplateCacheFile(uiLayout *layout, struct bContext *C, struct PointerRNA
/* Default UIList class name, keep in sync with its declaration in bl_ui/__init__.py */
#define UI_UL_DEFAULT_CLASS_NAME "UI_UL_list"
-void uiTemplateList(uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id,
- struct PointerRNA *dataptr, const char *propname, struct PointerRNA *active_dataptr,
- const char *active_propname, const char *item_dyntip_propname,
- int rows, int maxrows, int layout_type, int columns);
+void uiTemplateList(
+ uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id,
+ struct PointerRNA *dataptr, const char *propname, struct PointerRNA *active_dataptr,
+ const char *active_propname, const char *item_dyntip_propname,
+ int rows, int maxrows, int layout_type, int columns);
void uiTemplateNodeLink(uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
@@ -1151,7 +1171,7 @@ void uiItemPopoverPanel_ptr(
const char *name, int icon);
void uiItemPopoverPanel(
uiLayout *layout, struct bContext *C,
- int space_id, int region_id, const char *panelname,
+ const char *panelname,
const char *name, int icon);
void uiItemPopoverPanelFromGroup(
uiLayout *layout, struct bContext *C,
@@ -1199,14 +1219,18 @@ uiBut *UI_region_active_but_get(struct ARegion *ar);
/* Styled text draw */
void UI_fontstyle_set(const struct uiFontStyle *fs);
-void UI_fontstyle_draw_ex(const struct uiFontStyle *fs, const struct rcti *rect, const char *str,
- const unsigned char col[4], size_t len, float *r_xofs, float *r_yofs);
-void UI_fontstyle_draw(const struct uiFontStyle *fs, const struct rcti *rect, const char *str,
- const unsigned char col[4]);
-void UI_fontstyle_draw_rotated(const struct uiFontStyle *fs, const struct rcti *rect, const char *str,
- const unsigned char col[4]);
-void UI_fontstyle_draw_simple(const struct uiFontStyle *fs, float x, float y, const char *str,
- const unsigned char col[4]);
+void UI_fontstyle_draw_ex(
+ const struct uiFontStyle *fs, const struct rcti *rect, const char *str,
+ const unsigned char col[4], size_t len, float *r_xofs, float *r_yofs);
+void UI_fontstyle_draw(
+ const struct uiFontStyle *fs, const struct rcti *rect, const char *str,
+ const unsigned char col[4]);
+void UI_fontstyle_draw_rotated(
+ const struct uiFontStyle *fs, const struct rcti *rect, const char *str,
+ const unsigned char col[4]);
+void UI_fontstyle_draw_simple(
+ const struct uiFontStyle *fs, float x, float y, const char *str,
+ const unsigned char col[4]);
void UI_fontstyle_draw_simple_backdrop(
const struct uiFontStyle *fs, float x, float y, const char *str,
const float col_fg[4], const float col_bg[4]);
@@ -1242,7 +1266,7 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p);
/* ui_interface_region_tooltip.c */
struct ARegion *UI_tooltip_create_from_button(struct bContext *C, struct ARegion *butregion, uiBut *but);
-struct ARegion *UI_tooltip_create_from_manipulator(struct bContext *C, struct wmManipulator *mpr);
+struct ARegion *UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *gz);
void UI_tooltip_free(struct bContext *C, struct bScreen *sc, struct ARegion *ar);
/* How long before a tool-tip shows. */
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index cab0fa8645d..d2fbb881a0a 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -75,8 +75,6 @@ typedef enum ThemeColorID {
TH_PANEL_HEADER,
TH_PANEL_BACK,
TH_PANEL_SUB_BACK,
- TH_PANEL_SHOW_HEADER,
- TH_PANEL_SHOW_BACK,
TH_BUTBACK,
TH_BUTBACK_TEXT,
@@ -282,11 +280,11 @@ typedef enum ThemeColorID {
TH_AXIS_Y,
TH_AXIS_Z,
- TH_MANIPULATOR_HI,
- TH_MANIPULATOR_PRIMARY,
- TH_MANIPULATOR_SECONDARY,
- TH_MANIPULATOR_A,
- TH_MANIPULATOR_B,
+ TH_GIZMO_HI,
+ TH_GIZMO_PRIMARY,
+ TH_GIZMO_SECONDARY,
+ TH_GIZMO_A,
+ TH_GIZMO_B,
TH_LOW_GRAD,
TH_HIGH_GRAD,
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index d407878d063..4c4ee1e01c5 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -103,8 +103,6 @@ enum eView2D_Gridlines {
/* ------ Defines for Scrollers ----- */
/* scroller area */
-#define V2D_SCROLL_HEIGHT_MIN (0.25f * U.widget_unit)
-#define V2D_SCROLL_WIDTH_MIN (0.25f * U.widget_unit)
#define V2D_SCROLL_HEIGHT (0.45f * U.widget_unit)
#define V2D_SCROLL_WIDTH (0.45f * U.widget_unit)
/* For scrollers with scale markings (text written onto them) */
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index ee18f956cac..cf172441be1 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -54,6 +54,7 @@ set(SRC
interface_eyedropper_driver.c
interface_handlers.c
interface_icons.c
+ interface_icons_event.c
interface_layout.c
interface_ops.c
interface_panel.c
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 3b2a2e9d3ed..37c56d454bb 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -280,7 +280,7 @@ static void ui_update_window_matrix(const wmWindow *window, const ARegion *regio
/* window matrix and aspect */
if (region && region->visible) {
/* Get projection matrix which includes View2D translation and zoom. */
- gpuGetProjectionMatrix(block->winmat);
+ GPU_matrix_projection_get(block->winmat);
block->aspect = 2.0f / fabsf(region->winx * block->winmat[0][0]);
}
else {
@@ -916,7 +916,6 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
* but this could be supported */
void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_strip)
{
-
if (do_strip && (but->flag & UI_BUT_HAS_SEP_CHAR)) {
char *cpoin = strrchr(but->str, UI_SEP_CHAR);
if (cpoin) {
@@ -943,47 +942,111 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str
MEM_freeN(butstr_orig);
but->str = but->strdata;
but->flag |= UI_BUT_HAS_SEP_CHAR;
+ but->drawflag |= UI_BUT_HAS_SHORTCUT;
ui_but_update(but);
}
}
-static bool ui_but_event_operator_string(
+/* -------------------------------------------------------------------- */
+/** \name Find Key Shortcut for Button
+ *
+ * - #ui_but_event_operator_string (and helpers)
+ * - #ui_but_event_property_operator_string
+ * \{ */
+
+static bool ui_but_event_operator_string_from_operator(
const bContext *C, uiBut *but,
char *buf, const size_t buf_len)
{
- MenuType *mt;
+ BLI_assert(but->optype != NULL);
bool found = false;
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
- if (but->optype) {
- IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
+ if (WM_key_event_operator_string(
+ C, but->optype->idname, but->opcontext, prop, true,
+ buf, buf_len))
+ {
+ found = true;
+ }
+ return found;
+}
- if (WM_key_event_operator_string(
- C, but->optype->idname, but->opcontext, prop, true,
- buf, buf_len))
- {
- found = true;
- }
+static bool ui_but_event_operator_string_from_menu(
+ const bContext *C, uiBut *but,
+ char *buf, const size_t buf_len)
+{
+ MenuType *mt = UI_but_menutype_get(but);
+ BLI_assert(mt != NULL);
+
+ bool found = false;
+ IDProperty *prop_menu;
+
+ /* annoying, create a property */
+ IDPropertyTemplate val = {0};
+ prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
+ IDP_AddToGroup(prop_menu, IDP_NewString(mt->idname, "name", sizeof(mt->idname)));
+
+ if (WM_key_event_operator_string(
+ C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true,
+ buf, buf_len))
+ {
+ found = true;
}
- else if ((mt = UI_but_menutype_get(but))) {
- IDProperty *prop_menu;
- IDProperty *prop_menu_name;
- /* annoying, create a property */
- IDPropertyTemplate val = {0};
- prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
- IDP_AddToGroup(prop_menu, (prop_menu_name = IDP_NewString("", "name", sizeof(mt->idname))));
+ IDP_FreeProperty(prop_menu);
+ MEM_freeN(prop_menu);
+ return found;
+}
- IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname));
+static bool ui_but_event_operator_string_from_panel(
+ const bContext *C, uiBut *but,
+ char *buf, const size_t buf_len)
+{
+ /** Nearly exact copy of #ui_but_event_operator_string_from_menu */
+ PanelType *pt = UI_but_paneltype_get(but);
+ BLI_assert(pt != NULL);
+ bool found = false;
+ IDProperty *prop_panel;
+
+ /* annoying, create a property */
+ IDPropertyTemplate val = {0};
+ prop_panel = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
+ IDP_AddToGroup(prop_panel, IDP_NewString(pt->idname, "name", sizeof(pt->idname)));
+ IDP_AddToGroup(prop_panel, IDP_New(IDP_INT, &(IDPropertyTemplate){ .i = pt->space_type, }, "space_type"));
+ IDP_AddToGroup(prop_panel, IDP_New(IDP_INT, &(IDPropertyTemplate){ .i = pt->region_type, }, "region_type"));
+
+ for (int i = 0; i < 2; i++) {
+ /* FIXME(campbell): We can't reasonably search all configurations - long term. */
+ IDP_ReplaceInGroup(prop_panel, IDP_New(IDP_INT, &(IDPropertyTemplate){ .i = i, }, "keep_open"));
if (WM_key_event_operator_string(
- C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true,
- buf, buf_len))
+ C, "WM_OT_call_panel", WM_OP_INVOKE_REGION_WIN, prop_panel, true,
+ buf, buf_len))
{
found = true;
+ break;
}
+ }
+
+ IDP_FreeProperty(prop_panel);
+ MEM_freeN(prop_panel);
+ return found;
+}
+
+static bool ui_but_event_operator_string(
+ const bContext *C, uiBut *but,
+ char *buf, const size_t buf_len)
+{
+ bool found = false;
- IDP_FreeProperty(prop_menu);
- MEM_freeN(prop_menu);
+ if (but->optype != NULL) {
+ found = ui_but_event_operator_string_from_operator(C, but, buf, buf_len);
+ }
+ else if (UI_but_menutype_get(but) != NULL) {
+ found = ui_but_event_operator_string_from_menu(C, but, buf, buf_len);
+ }
+ else if (UI_but_paneltype_get(but) != NULL) {
+ found = ui_but_event_operator_string_from_panel(C, but, buf, buf_len);
}
return found;
@@ -1105,6 +1168,8 @@ static bool ui_but_event_property_operator_string(
return found;
}
+/** \} */
+
/**
* This goes in a seemingly weird pattern:
*
@@ -1383,9 +1448,9 @@ void UI_block_draw(const bContext *C, uiBlock *block)
ui_but_to_pixelrect(&rect, ar, block, NULL);
/* pixel space for AA widgets */
- gpuPushProjectionMatrix();
- gpuPushMatrix();
- gpuLoadIdentity();
+ GPU_matrix_push_projection();
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
wmOrtho2_region_pixelspace(ar);
@@ -1420,8 +1485,8 @@ void UI_block_draw(const bContext *C, uiBlock *block)
BLF_batch_draw_end();
/* restore matrix */
- gpuPopProjectionMatrix();
- gpuPopMatrix();
+ GPU_matrix_pop_projection();
+ GPU_matrix_pop();
}
static void ui_block_message_subscribe(ARegion *ar, struct wmMsgBus *mbus, uiBlock *block)
@@ -3453,6 +3518,12 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
block->flag |= UI_BLOCK_IS_FLIP;
}
+static void ui_but_submenu_enable(uiBlock *block, uiBut *but)
+{
+ but->flag |= UI_BUT_ICON_SUBMENU;
+ block->content_hints |= BLOCK_CONTAINS_SUBMENU_BUT;
+}
+
/**
* ui_def_but_rna_propname and ui_def_but_rna
* both take the same args except for propname vs prop, this is done so we can
@@ -3588,7 +3659,7 @@ static uiBut *ui_def_but_rna(
}
if ((type == UI_BTYPE_MENU) && (but->dt == UI_EMBOSS_PULLDOWN)) {
- but->flag |= UI_BUT_ICON_SUBMENU;
+ ui_but_submenu_enable(block, but);
}
const char *info;
@@ -4327,7 +4398,7 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in
ui_def_but_icon(but, icon, UI_HAS_ICON);
but->drawflag |= UI_BUT_ICON_LEFT;
- but->flag |= UI_BUT_ICON_SUBMENU;
+ ui_but_submenu_enable(block, but);
but->menu_create_func = func;
ui_but_update(but);
@@ -4359,7 +4430,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
but->drawflag |= UI_BUT_ICON_LEFT;
}
but->flag |= UI_HAS_ICON;
- but->flag |= UI_BUT_ICON_SUBMENU;
+ ui_but_submenu_enable(block, but);
but->block_create_func = func;
ui_but_update(but);
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index c336c48f62a..6a304a8150e 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -55,6 +55,7 @@
#include "BLF_api.h"
#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -129,19 +130,19 @@ void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, float
/* WATCH: This is assuming the ModelViewProjectionMatrix is area pixel space.
* If it has been scaled, then it's no longer valid. */
- Gwn_Batch *batch = ui_batch_roundbox_get(filled, true);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
- GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
- GWN_batch_draw(batch);
+ GPUBatch *batch = ui_batch_roundbox_get(filled, true);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
+ GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
+ GPU_batch_draw(batch);
}
else {
/* plain antialiased unfilled box */
GPU_line_smooth(true);
- Gwn_Batch *batch = ui_batch_roundbox_get(filled, false);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
- GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
- GWN_batch_draw(batch);
+ GPUBatch *batch = ui_batch_roundbox_get(filled, false);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
+ GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
+ GPU_batch_draw(batch);
GPU_line_smooth(false);
}
@@ -158,24 +159,24 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float
};
int a;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
/* mult */
for (a = 0; a < 7; a++) {
mul_v2_fl(vec[a], rad);
}
- unsigned int vert_ct = 0;
- vert_ct += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 9 : 1;
- vert_ct += (roundboxtype & UI_CNR_TOP_RIGHT) ? 9 : 1;
- vert_ct += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1;
- vert_ct += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1;
+ uint vert_len = 0;
+ vert_len += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 9 : 1;
+ vert_len += (roundboxtype & UI_CNR_TOP_RIGHT) ? 9 : 1;
+ vert_len += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1;
+ vert_len += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1;
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(col);
- immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_ct);
+ immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_len);
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
immVertex2f(pos, maxx - rad, miny);
@@ -243,10 +244,10 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float
.alpha_discard = 1.0f,
};
- Gwn_Batch *batch = ui_batch_roundbox_get(filled, false);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
- GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
- GWN_batch_draw(batch);
+ GPUBatch *batch = ui_batch_roundbox_get(filled, false);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
+ GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
+ GPU_batch_draw(batch);
}
#if 0
@@ -279,9 +280,9 @@ void UI_draw_roundbox_shade_x(
int vert_count = 0;
int a;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
@@ -303,7 +304,7 @@ void UI_draw_roundbox_shade_x(
vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1;
vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1;
- immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count);
+ immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_count);
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
@@ -403,10 +404,10 @@ void UI_draw_roundbox_shade_x(
.alpha_discard = 1.0f,
};
- Gwn_Batch *batch = ui_batch_roundbox_get(filled, false);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
- GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
- GWN_batch_draw(batch);
+ GPUBatch *batch = ui_batch_roundbox_get(filled, false);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
+ GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
+ GPU_batch_draw(batch);
}
#if 0 /* unused */
@@ -431,9 +432,9 @@ void UI_draw_roundbox_shade_y(
mul_v2_fl(vec[a], rad);
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
@@ -451,7 +452,7 @@ void UI_draw_roundbox_shade_y(
vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1;
vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1;
- immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count);
+ immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_count);
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
@@ -534,8 +535,8 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo
{
int ofs_y = 4 * U.pixelsize;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
@@ -549,9 +550,9 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo
/* based on UI_draw_roundbox_gl_mode, check on making a version which allows us to skip some sides */
void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highlight[3], unsigned char highlight_fade[3])
{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
/* add a 1px offset, looks nicer */
const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - U.pixelsize;
const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize;
@@ -570,7 +571,7 @@ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highligh
}
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
- immBeginAtMost(GWN_PRIM_LINE_STRIP, 25);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, 25);
immAttrib3ubv(col, highlight);
@@ -684,8 +685,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
*
* \Note This functionn is to be used with the 2D dashed shader enabled.
*
- * \param pos is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib
- * \param line_origin is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib
+ * \param pos is a PRIM_FLOAT, 2, GPU_FETCH_FLOAT vertex attrib
+ * \param line_origin is a PRIM_FLOAT, 2, GPU_FETCH_FLOAT vertex attrib
*
* The next 4 parameters are the offsets for the view, not the zones.
*/
@@ -748,7 +749,7 @@ static void histogram_draw_one(
/* curve outline */
GPU_line_width(1.5);
- immBegin(GWN_PRIM_LINE_STRIP, res);
+ immBegin(GPU_PRIM_LINE_STRIP, res);
for (int i = 0; i < res; i++) {
float x2 = x + i * (w / (float)res);
immVertex2f(pos_attrib, x2, y + (data[i] * h));
@@ -757,7 +758,7 @@ static void histogram_draw_one(
}
else {
/* under the curve */
- immBegin(GWN_PRIM_TRI_STRIP, res * 2);
+ immBegin(GPU_PRIM_TRI_STRIP, res * 2);
immVertex2f(pos_attrib, x, y);
immVertex2f(pos_attrib, x, y + (data[0] * h));
for (int i = 1; i < res; i++) {
@@ -771,7 +772,7 @@ static void histogram_draw_one(
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- immBegin(GWN_PRIM_LINE_STRIP, res);
+ immBegin(GPU_PRIM_LINE_STRIP, res);
for (int i = 0; i < res; i++) {
float x2 = x + i * (w / (float)res);
immVertex2f(pos_attrib, x2, y + (data[i] * h));
@@ -817,8 +818,8 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS
(rect.xmax + 1) - (rect.xmin - 1),
(rect.ymax + 1) - (rect.ymin - 1));
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -832,7 +833,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
}
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, rect.xmin, rect.ymin + fac * h);
immVertex2f(pos, rect.xmax, rect.ymin + fac * h);
@@ -868,21 +869,21 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS
static void waveform_draw_one(float *waveform, int nbr, const float col[3])
{
- Gwn_VertFormat format = {0};
- unsigned int pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat format = {0};
+ uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, nbr);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, nbr);
- GWN_vertbuf_attr_fill(vbo, pos_id, waveform);
+ GPU_vertbuf_attr_fill(vbo, pos_id, waveform);
- /* TODO store the Gwn_Batch inside the scope */
- Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR);
- GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f);
- GWN_batch_draw(batch);
+ /* TODO store the GPUBatch inside the scope */
+ GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR);
+ GPU_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f);
+ GPU_batch_draw(batch);
- GWN_batch_discard(batch);
+ GPU_batch_discard(batch);
}
void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
@@ -956,15 +957,15 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
/* draw grid lines here */
- immBegin(GWN_PRIM_LINES, 12);
+ immBegin(GPU_PRIM_LINES, 12);
for (int i = 0; i < 6; i++) {
immVertex2f(pos, rect.xmin + 22, yofs + (i * 0.2f) * h);
@@ -975,7 +976,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
/* 3 vertical separation */
if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
for (int i = 1; i < 3; i++) {
immVertex2f(pos, rect.xmin + i * w3, rect.ymin);
@@ -986,7 +987,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
}
/* separate min max zone on the right */
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, rect.xmin + w, rect.ymin);
immVertex2f(pos, rect.xmin + w, rect.ymax);
immEnd();
@@ -994,7 +995,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
/* 16-235-240 level in case of ITU-R BT601/709 */
immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f);
if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) {
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
immVertex2f(pos, rect.xmin + 22, yofs + h * 16.0f / 255.0f);
immVertex2f(pos, rect.xmax + 1, yofs + h * 16.0f / 255.0f);
@@ -1012,7 +1013,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
}
/* 7.5 IRE black point level for NTSC */
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, rect.xmin, yofs + h * 0.075f);
immVertex2f(pos, rect.xmax + 1, yofs + h * 0.075f);
immEnd();
@@ -1026,13 +1027,13 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
float col[3] = {alpha, alpha, alpha};
- gpuPushMatrix();
- gpuTranslate2f(rect.xmin, yofs);
- gpuScale2f(w, h);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(rect.xmin, yofs);
+ GPU_matrix_scale_2f(w, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col);
- gpuPopMatrix();
+ GPU_matrix_pop();
/* min max */
immUniformColor3f(0.5f, 0.5f, 0.5f);
@@ -1041,22 +1042,22 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
CLAMP(min, rect.ymin, rect.ymax);
CLAMP(max, rect.ymin, rect.ymax);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, rect.xmax - 3, min);
immVertex2f(pos, rect.xmax - 3, max);
immEnd();
}
/* RGB (3 channel) */
else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) {
- gpuPushMatrix();
- gpuTranslate2f(rect.xmin, yofs);
- gpuScale2f(w, h);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(rect.xmin, yofs);
+ GPU_matrix_scale_2f(w, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]);
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]);
waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, colors_alpha[2]);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/* PARADE / YCC (3 channels) */
else if (ELEM(scopes->wavefrm_mode,
@@ -1068,19 +1069,19 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
{
int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE);
- gpuPushMatrix();
- gpuTranslate2f(rect.xmin, yofs);
- gpuScale2f(w3, h);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(rect.xmin, yofs);
+ GPU_matrix_scale_2f(w3, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
- gpuTranslate2f(1.0f, 0.0f);
+ GPU_matrix_translate_2f(1.0f, 0.0f);
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
- gpuTranslate2f(1.0f, 0.0f);
+ GPU_matrix_translate_2f(1.0f, 0.0f);
waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/* min max */
@@ -1095,7 +1096,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
CLAMP(min, rect.ymin, rect.ymax);
CLAMP(max, rect.ymin, rect.ymax);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, rect.xmin + w + 2 + c * 2, min);
immVertex2f(pos, rect.xmin + w + 2 + c * 2, max);
immEnd();
@@ -1139,7 +1140,7 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.12f);
dangle = DEG2RADF(2.5f);
dampli = 2.5f / 200.0f;
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
@@ -1151,22 +1152,22 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente
dampli = 0.2f * tampli;
dangle2 = DEG2RADF(5.0f);
dampli2 = 0.5f * dampli;
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2));
immEnd();
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2));
immEnd();
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2));
immEnd();
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2));
@@ -1214,15 +1215,15 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
(rect.xmax + 1) - (rect.xmin - 1),
(rect.ymax + 1) - (rect.ymin - 1));
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
/* draw grid elements */
/* cross */
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery);
immVertex2f(pos, centerx + (diam * 0.5f) + 5, centery);
@@ -1235,7 +1236,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
/* circles */
for (int j = 0; j < 5; j++) {
const int increment = 15;
- immBegin(GWN_PRIM_LINE_LOOP, (int)(360 / increment));
+ immBegin(GPU_PRIM_LINE_LOOP, (int)(360 / increment));
for (int i = 0; i <= 360 - increment; i += increment) {
const float a = DEG2RADF((float)i);
const float r = (j + 1) * 0.1f;
@@ -1246,7 +1247,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
/* skin tone line */
immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5f, skin_rad));
immVertex2f(pos, polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1f, skin_rad));
immEnd();
@@ -1262,13 +1263,13 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
glBlendFunc(GL_ONE, GL_ONE);
GPU_point_size(1.0);
- gpuPushMatrix();
- gpuTranslate2f(centerx, centery);
- gpuScaleUniform(diam);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(centerx, centery);
+ GPU_matrix_scale_1f(diam);
waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
immUnbindProgram();
@@ -1283,7 +1284,7 @@ static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, floa
{
GPU_line_smooth(true);
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, x1 + halfwidth, y1);
immVertex2f(pos, x1, y1 + height);
immVertex2f(pos, x1 - halfwidth, y1);
@@ -1296,7 +1297,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f
{
glEnable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH);
- immBegin(fill ? GWN_PRIM_TRIS : GWN_PRIM_LINE_LOOP, 3);
+ immBegin(fill ? GPU_PRIM_TRIS : GPU_PRIM_LINE_LOOP, 3);
immVertex2f(pos, x1 + halfwidth, y1);
immVertex2f(pos, x1, y1 + height);
immVertex2f(pos, x1 - halfwidth, y1);
@@ -1307,7 +1308,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f
static void ui_draw_colorband_handle_box(unsigned int pos, float x1, float y1, float x2, float y2, bool fill)
{
- immBegin(fill ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4);
+ immBegin(fill ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, 4);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x1, y2);
immVertex2f(pos, x2, y2);
@@ -1347,7 +1348,7 @@ static void ui_draw_colorband_handle(
immUniformArray4fv("colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
immUniform1f("dash_width", active ? 4.0f : 2.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(shdr_pos, x, y1);
immVertex2f(shdr_pos, x, y2);
immEnd();
@@ -1404,7 +1405,7 @@ static void ui_draw_colorband_handle(
void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *rect)
{
struct ColorManagedDisplay *display = NULL;
- unsigned int position, color;
+ uint pos_id, col_id;
ColorBand *coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
if (coba == NULL) return;
@@ -1418,21 +1419,21 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
float sizey_solid = sizey * 0.25f;
float y1 = rect->ymin;
- Gwn_VertFormat *format = immVertexFormat();
- position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
/* Drawing the checkerboard. */
immUniform4f("color1", UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_DARK / 255.0f, 1.0f);
immUniform4f("color2", UI_ALPHA_CHECKER_LIGHT / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 1.0f);
immUniform1i("size", 8);
- immRectf(position, x1, y1, x1 + sizex, rect->ymax);
+ immRectf(pos_id, x1, y1, x1 + sizex, rect->ymax);
immUnbindProgram();
/* New format */
format = immVertexFormat();
- position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ col_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
/* layer: color ramp */
@@ -1446,7 +1447,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
v1[1] = y1 + sizey_solid;
v2[1] = rect->ymax;
- immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2);
+ immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
for (int a = 0; a <= sizex; a++) {
float pos = ((float)a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
@@ -1455,9 +1456,9 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
v1[0] = v2[0] = x1 + a;
- immAttrib4fv(color, colf);
- immVertex2fv(position, v1);
- immVertex2fv(position, v2);
+ immAttrib4fv(col_id, colf);
+ immVertex2fv(pos_id, v1);
+ immVertex2fv(pos_id, v2);
}
immEnd();
@@ -1465,7 +1466,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
v1[1] = y1;
v2[1] = y1 + sizey_solid;
- immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2);
+ immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
for (int a = 0; a <= sizex; a++) {
float pos = ((float)a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
@@ -1474,9 +1475,9 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
v1[0] = v2[0] = x1 + a;
- immAttrib4f(color, colf[0], colf[1], colf[2], 1.0f);
- immVertex2fv(position, v1);
- immVertex2fv(position, v2);
+ immAttrib4f(col_id, colf[0], colf[1], colf[2], 1.0f);
+ immVertex2fv(pos_id, v1);
+ immVertex2fv(pos_id, v2);
}
immEnd();
@@ -1486,27 +1487,27 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
/* New format */
format = immVertexFormat();
- position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* layer: box outline */
immUniformColor4f(0.0f, 0.0f, 0.0f, 1.0f);
- imm_draw_box_wire_2d(position, x1, y1, x1 + sizex, rect->ymax);
+ imm_draw_box_wire_2d(pos_id, x1, y1, x1 + sizex, rect->ymax);
/* layer: box outline */
GPU_blend(true);
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
- immBegin(GWN_PRIM_LINES, 2);
- immVertex2f(position, x1, y1);
- immVertex2f(position, x1 + sizex, y1);
+ immBegin(GPU_PRIM_LINES, 2);
+ immVertex2f(pos_id, x1, y1);
+ immVertex2f(pos_id, x1 + sizex, y1);
immEnd();
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f);
- immBegin(GWN_PRIM_LINES, 2);
- immVertex2f(position, x1, y1 - 1);
- immVertex2f(position, x1 + sizex, y1 - 1);
+ immBegin(GPU_PRIM_LINES, 2);
+ immVertex2f(pos_id, x1, y1 - 1);
+ immVertex2f(pos_id, x1 + sizex, y1 - 1);
immEnd();
GPU_blend(false);
@@ -1515,7 +1516,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
for (int a = 0; a < coba->tot; a++, cbd++) {
if (a != coba->cur) {
float pos = x1 + cbd->pos * (sizex - 1) + 1;
- ui_draw_colorband_handle(position, rect, pos, &cbd->r, display, false);
+ ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, false);
}
}
@@ -1523,7 +1524,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
if (coba->tot != 0) {
cbd = &coba->data[coba->cur];
float pos = x1 + cbd->pos * (sizex - 1) + 1;
- ui_draw_colorband_handle(position, rect, pos, &cbd->r, display, true);
+ ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, true);
}
immUnbindProgram();
@@ -1547,28 +1548,28 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
ui_but_v3_get(but, light);
/* transform to button */
- gpuPushMatrix();
+ GPU_matrix_push();
if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
size = 0.5f * BLI_rcti_size_x(rect);
else
size = 0.5f * BLI_rcti_size_y(rect);
- gpuTranslate2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect));
- gpuScaleUniform(size);
+ GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect));
+ GPU_matrix_scale_1f(size);
- Gwn_Batch *sphere = GPU_batch_preset_sphere(2);
- GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING);
- GWN_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f);
- GWN_batch_uniform_3fv(sphere, "light", light);
- GWN_batch_draw(sphere);
+ GPUBatch *sphere = GPU_batch_preset_sphere(2);
+ GPU_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING);
+ GPU_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f);
+ GPU_batch_uniform_3fv(sphere, "light", light);
+ GPU_batch_draw(sphere);
/* restore */
glDisable(GL_CULL_FACE);
/* AA circle */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv((unsigned char *)wcol->inner);
@@ -1579,7 +1580,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
GPU_line_smooth(false);
/* matrix after circle */
- gpuPopMatrix();
+ GPU_matrix_pop();
immUnbindProgram();
}
@@ -1598,7 +1599,7 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo
floorf((rect->xmax - fx) / dx) + 1.0f +
floorf((rect->ymax - fy) / dy) + 1.0f);
- immBegin(GWN_PRIM_LINES, (int)line_count * 2);
+ immBegin(GPU_PRIM_LINES, (int)line_count * 2);
while (fx < rect->xmax) {
immVertex2f(pos, fx, rect->ymin);
immVertex2f(pos, fx, rect->ymax);
@@ -1674,8 +1675,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
GPU_line_width(1.0f);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* backdrop */
@@ -1711,7 +1712,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f);
/* axes */
gl_shaded_color((unsigned char *)wcol->inner, -50);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (-offsy));
immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (-offsy));
immVertex2f(pos, rect->xmin + zoomx * (-offsx), rect->ymin);
@@ -1724,7 +1725,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
#if 0
if (cumap->flag & CUMA_DRAW_CFRA) {
immUniformColor3ub(0x60, 0xc0, 0x40);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin);
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax);
immEnd();
@@ -1733,7 +1734,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
/* sample option */
if (cumap->flag & CUMA_DRAW_SAMPLE) {
- immBegin(GWN_PRIM_LINES, 2); /* will draw one of the following 3 lines */
+ immBegin(GPU_PRIM_LINES, 2); /* will draw one of the following 3 lines */
if (but->a1 == UI_GRAD_H) {
float tsample[3];
float hsv[3];
@@ -1769,7 +1770,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
immUniformColor3ubv((unsigned char *)wcol->item);
GPU_line_smooth(true);
GPU_blend(true);
- immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
+ immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
if (cuma->table == NULL)
curvemapping_changed(cumap, false);
@@ -1806,13 +1807,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
/* the points, use aspect to make them visible on edges */
format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
cmp = cuma->curve;
GPU_point_size(3.0f);
- immBegin(GWN_PRIM_POINTS, cuma->totpoint);
+ immBegin(GPU_PRIM_POINTS, cuma->totpoint);
for (int a = 0; a < cuma->totpoint; a++) {
float color[4];
if (cmp[a].flag & CUMA_SELECT)
@@ -1832,7 +1833,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
/* outline */
format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv((unsigned char *)wcol->outline);
@@ -1899,7 +1900,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
}
if (!ok && scopes->track_preview) {
- gpuPushMatrix();
+ GPU_matrix_push();
/* draw content of pattern area */
GPU_scissor(rect.xmin, rect.ymin, scissor[2], scissor[3]);
@@ -1918,23 +1919,23 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
immDrawPixelsTex(&state, rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL);
/* draw cross for pixel position */
- gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
+ GPU_matrix_translate_2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
GPU_scissor(
rect.xmin,
rect.ymin,
BLI_rctf_size_x(&rect),
BLI_rctf_size_y(&rect));
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel);
UI_GetThemeColor4fv(TH_MARKER_OUTLINE, col_outline);
/* Do stipple cross with geometry */
- immBegin(GWN_PRIM_LINES, 7 * 2 * 2);
+ immBegin(GPU_PRIM_LINES, 7 * 2 * 2);
float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f};
for (int axe = 0; axe < 2; ++axe) {
for (int i = 0; i < 7; ++i) {
@@ -1957,7 +1958,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
immUnbindProgram();
}
- gpuPopMatrix();
+ GPU_matrix_pop();
ok = true;
}
@@ -2017,13 +2018,13 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
float x = 0.5f * (recti->xmin + recti->xmax);
float y = 0.5f * (recti->ymin + recti->ymax);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv(but->col);
GPU_blend(true);
- immBegin(GWN_PRIM_TRI_FAN, 16);
+ immBegin(GPU_PRIM_TRI_FAN, 16);
for (int a = 0; a < 16; a++)
immVertex2f(pos, x + size * si[a], y + size * co[a]);
immEnd();
@@ -2031,7 +2032,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
immUniformColor4ub(0, 0, 0, 150);
GPU_line_width(1);
GPU_line_smooth(true);
- immBegin(GWN_PRIM_LINE_LOOP, 16);
+ immBegin(GPU_PRIM_LINE_LOOP, 16);
for (int a = 0; a < 16; a++)
immVertex2f(pos, x + size * si[a], y + size * co[a]);
immEnd();
@@ -2114,13 +2115,13 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
{
GPU_blend(true);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
- immBegin(GWN_PRIM_TRIS, 54);
+ immBegin(GPU_PRIM_TRIS, 54);
/* accumulated outline boxes to make shade not linear, is more pleasant */
ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
@@ -2185,11 +2186,11 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
.alpha_discard = 1.0f,
};
- Gwn_Batch *batch = ui_batch_roundbox_shadow_get();
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW);
- GWN_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params);
- GWN_batch_uniform_1f(batch, "alpha", 1.0f - visibility);
- GWN_batch_draw(batch);
+ GPUBatch *batch = ui_batch_roundbox_shadow_get();
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW);
+ GPU_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params);
+ GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility);
+ GPU_batch_draw(batch);
/* outline emphasis */
GPU_line_smooth(true);
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index eb8fff471e2..424019995ad 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -82,6 +82,7 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf)
/* assign to operators */
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorband");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color");
+ WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color_crypto");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_id");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_depth");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_driver");
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c
index 73efc59feb7..bcce70d9d8a 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -36,6 +36,7 @@
#include "DNA_screen_types.h"
#include "BLI_math_vector.h"
+#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_main.h"
@@ -72,6 +73,8 @@ typedef struct Eyedropper {
bool accum_start; /* has mouse been pressed */
float accum_col[3];
int accum_tot;
+
+ bool accumulate; /* Color picking for cryptomatte, without accumulation. */
} Eyedropper;
static bool eyedropper_init(bContext *C, wmOperator *op)
@@ -80,6 +83,7 @@ static bool eyedropper_init(bContext *C, wmOperator *op)
Eyedropper *eye;
op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper");
+ eye->accumulate = !STREQ(op->type->idname, "UI_OT_eyedropper_color_crypto");
UI_context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index);
@@ -207,29 +211,30 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3
RNA_property_update(C, &eye->ptr, eye->prop);
}
-/* set sample from accumulated values */
-static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye)
-{
- float col[3];
- mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot);
- eyedropper_color_set(C, eye, col);
-}
-
-/* single point sample & set */
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my)
{
+ /* Accumulate color. */
float col[3];
eyedropper_color_sample_fl(C, mx, my, col);
- eyedropper_color_set(C, eye, col);
-}
-static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, int my)
-{
- float col[3];
- eyedropper_color_sample_fl(C, mx, my, col);
- /* delay linear conversion */
- add_v3_v3(eye->accum_col, col);
- eye->accum_tot++;
+ if (eye->accumulate) {
+ add_v3_v3(eye->accum_col, col);
+ eye->accum_tot++;
+ }
+ else {
+ copy_v3_v3(eye->accum_col, col);
+ eye->accum_tot = 1;
+ }
+
+ /* Apply to property. */
+ float accum_col[3];
+ if (eye->accum_tot > 1) {
+ mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / (float)eye->accum_tot);
+ }
+ else {
+ copy_v3_v3(accum_col, eye->accum_col);
+ }
+ eyedropper_color_set(C, eye, accum_col);
}
static void eyedropper_cancel(bContext *C, wmOperator *op)
@@ -254,29 +259,24 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (eye->accum_tot == 0) {
eyedropper_color_sample(C, eye, event->x, event->y);
}
- else {
- eyedropper_color_set_accum(C, eye);
- }
eyedropper_exit(C, op);
return OPERATOR_FINISHED;
case EYE_MODAL_SAMPLE_BEGIN:
/* enable accum and make first sample */
eye->accum_start = true;
- eyedropper_color_sample_accum(C, eye, event->x, event->y);
+ eyedropper_color_sample(C, eye, event->x, event->y);
break;
case EYE_MODAL_SAMPLE_RESET:
eye->accum_tot = 0;
zero_v3(eye->accum_col);
- eyedropper_color_sample_accum(C, eye, event->x, event->y);
- eyedropper_color_set_accum(C, eye);
+ eyedropper_color_sample(C, eye, event->x, event->y);
break;
}
}
- else if (event->type == MOUSEMOVE) {
+ else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
if (eye->accum_start) {
/* button is pressed so keep sampling */
- eyedropper_color_sample_accum(C, eye, event->x, event->y);
- eyedropper_color_set_accum(C, eye);
+ eyedropper_color_sample(C, eye, event->x, event->y);
}
}
@@ -297,7 +297,7 @@ static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
}
else {
eyedropper_exit(C, op);
- return OPERATOR_CANCELLED;
+ return OPERATOR_PASS_THROUGH;
}
}
@@ -315,26 +315,15 @@ static int eyedropper_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
else {
- return OPERATOR_CANCELLED;
+ return OPERATOR_PASS_THROUGH;
}
}
static bool eyedropper_poll(bContext *C)
{
- PointerRNA ptr;
- PropertyRNA *prop;
- int index_dummy;
- uiBut *but;
-
- /* Only color buttons */
- if ((CTX_wm_window(C) != NULL) &&
- (but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) &&
- (but->type == UI_BTYPE_COLOR))
- {
- return 1;
- }
-
- return 0;
+ /* Actual test for active button happens later, since we don't
+ * know which one is active until mouse over. */
+ return (CTX_wm_window(C) != NULL);
}
void UI_OT_eyedropper_color(wmOperatorType *ot)
@@ -353,6 +342,22 @@ void UI_OT_eyedropper_color(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
+}
+
+void UI_OT_eyedropper_color_crypto(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Cryptomatte Eyedropper";
+ ot->idname = "UI_OT_eyedropper_color_crypto";
+ ot->description = "Pick a color from Cryptomatte node Pick output image";
- /* properties */
+ /* api callbacks */
+ ot->invoke = eyedropper_invoke;
+ ot->modal = eyedropper_modal;
+ ot->cancel = eyedropper_cancel;
+ ot->exec = eyedropper_exec;
+ ot->poll = eyedropper_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index c3246213d4e..22b82898288 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -108,6 +108,7 @@ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
#define ICON_TYPE_BUFFER 3
#define ICON_TYPE_VECTOR 4
#define ICON_TYPE_GEOM 5
+#define ICON_TYPE_EVENT 6 /* draw keymap entries using custom renderer. */
typedef struct DrawInfo {
int type;
@@ -126,6 +127,14 @@ typedef struct DrawInfo {
struct {
int x, y, w, h;
} texture;
+ struct {
+ /* Can be packed into a single int. */
+ short event_type;
+ short event_value;
+ int icon;
+ /* Allow lookups. */
+ struct DrawInfo *next;
+ } input;
} data;
} DrawInfo;
@@ -241,11 +250,11 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float
viconutil_set_point(pts[1], cx - d2, cy - d);
viconutil_set_point(pts[2], cx + d2, cy);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(0.2f, 0.2f, 0.2f, alpha);
- immBegin(GWN_PRIM_TRIS, 3);
+ immBegin(GPU_PRIM_TRIS, 3);
immVertex2iv(pos, pts[0]);
immVertex2iv(pos, pts[1]);
immVertex2iv(pos, pts[2]);
@@ -271,15 +280,15 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha,
int xco = x + w / 2;
int yco = y + h / 2;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
- unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
GPU_enable_program_point_size();
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
/* draw keyframe
* - size: 0.6 * h (found out experimentally... dunno why!)
@@ -334,7 +343,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU
const int b = x + w / 3 * 2;
const int c = x + w;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* XXX: Include alpha into this... */
@@ -437,6 +446,143 @@ static void init_brush_icons(void)
#undef INIT_BRUSH_ICON
}
+static DrawInfo *g_di_event_list = NULL;
+
+int UI_icon_from_event_type(short event_type, short event_value)
+{
+ if (event_type == RIGHTSHIFTKEY) {
+ event_type = LEFTSHIFTKEY;
+ }
+ else if (event_type == RIGHTCTRLKEY) {
+ event_type = LEFTCTRLKEY;
+ }
+ else if (event_type == RIGHTALTKEY) {
+ event_type = LEFTALTKEY;
+ }
+ else if (event_type == EVT_TWEAK_L) {
+ event_type = LEFTMOUSE;
+ event_value = KM_CLICK_DRAG;
+ }
+ else if (event_type == EVT_TWEAK_M) {
+ event_type = MIDDLEMOUSE;
+ event_value = KM_CLICK_DRAG;
+ }
+ else if (event_type == EVT_TWEAK_R) {
+ event_type = RIGHTMOUSE;
+ event_value = KM_CLICK_DRAG;
+ }
+
+ DrawInfo *di = g_di_event_list;
+ do {
+ if (di->data.input.event_type == event_type) {
+ return di->data.input.icon;
+ }
+ } while ((di = di->data.input.next));
+
+ if (event_type == LEFTMOUSE) {
+ return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_LMB : ICON_MOUSE_LMB_DRAG;
+ }
+ else if (event_type == MIDDLEMOUSE) {
+ return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_MMB : ICON_MOUSE_MMB_DRAG;
+ }
+ else if (event_type == RIGHTMOUSE) {
+ return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_RMB : ICON_MOUSE_RMB_DRAG;
+ }
+
+ return ICON_NONE;
+}
+
+int UI_icon_from_keymap_item(const wmKeyMapItem *kmi, int r_icon_mod[4])
+{
+ if (r_icon_mod) {
+ memset(r_icon_mod, 0x0, sizeof(int[4]));
+ int i = 0;
+ if (!ELEM(kmi->ctrl, KM_NOTHING, KM_ANY)) {
+ r_icon_mod[i++] = ICON_EVENT_CTRL;
+ }
+ if (!ELEM(kmi->alt, KM_NOTHING, KM_ANY)) {
+ r_icon_mod[i++] = ICON_EVENT_ALT;
+ }
+ if (!ELEM(kmi->shift, KM_NOTHING, KM_ANY)) {
+ r_icon_mod[i++] = ICON_EVENT_SHIFT;
+ }
+ if (!ELEM(kmi->oskey, KM_NOTHING, KM_ANY)) {
+ r_icon_mod[i++] = ICON_EVENT_OS;
+ }
+ }
+ return UI_icon_from_event_type(kmi->type, kmi->val);
+}
+
+static void init_event_icons(void)
+{
+ DrawInfo *di_next = NULL;
+
+#define INIT_EVENT_ICON(icon_id, type, value) \
+ { \
+ DrawInfo *di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_EVENT); \
+ di->data.input.event_type = type; \
+ di->data.input.event_value = value; \
+ di->data.input.icon = icon_id; \
+ di->data.input.next = di_next; \
+ di_next = di; \
+ }
+ /* end INIT_EVENT_ICON */
+
+ const int w = 16; /* DUMMY */
+
+ INIT_EVENT_ICON(ICON_EVENT_A, AKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_B, BKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_C, CKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_D, DKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_E, EKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F, FKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_G, GKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_H, HKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_I, IKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_J, JKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_K, KKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_L, LKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_M, MKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_N, NKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_O, OKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_P, PKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_Q, QKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_R, RKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_S, SKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_T, TKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_U, UKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_V, VKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_W, WKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_X, XKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_Y, YKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_Z, ZKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_SHIFT, LEFTSHIFTKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_CTRL, LEFTCTRLKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_ALT, LEFTALTKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_OS, OSKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F1, F1KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F2, F2KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F3, F3KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F4, F4KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F5, F5KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F6, F6KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F7, F7KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F8, F8KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F9, F9KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F10, F10KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F11, F11KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_F12, F12KEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_ESC, ESCKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_TAB, TABKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_PAGEUP, PAGEUPKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_PAGEDOWN, PAGEDOWNKEY, KM_ANY);
+ INIT_EVENT_ICON(ICON_EVENT_RETURN, RETKEY, KM_ANY);
+
+ g_di_event_list = di_next;
+
+#undef INIT_EVENT_ICON
+}
+
static void icon_verify_datatoc(IconImage *iimg)
{
/* if it has own rect, things are all OK */
@@ -795,6 +941,7 @@ void UI_icons_init(int first_dyn_id)
init_iconfile_list(&iconfilelist);
init_internal_icons();
init_brush_icons();
+ init_event_icons();
#endif
}
@@ -1115,7 +1262,7 @@ static void icon_draw_cache_flush_ex(void)
glUniform1i(img_loc, 0);
glUniform4fv(data_loc, ICON_DRAW_CACHE_SIZE * 3, (float *)g_icon_draw_cache.drawcall_cache);
- GWN_draw_primitive(GWN_PRIM_TRIS, 6 * g_icon_draw_cache.calls);
+ GPU_draw_primitive(GPU_PRIM_TRIS, 6 * g_icon_draw_cache.calls);
glBindTexture(GL_TEXTURE_2D, 0);
@@ -1145,7 +1292,7 @@ static void icon_draw_texture_cached(
{
float mvp[4][4];
- gpuGetModelViewProjectionMatrix(mvp);
+ GPU_matrix_model_view_projection_get(mvp);
IconDrawCall *call = &g_icon_draw_cache.drawcall_cache[g_icon_draw_cache.calls];
g_icon_draw_cache.calls++;
@@ -1195,14 +1342,14 @@ static void icon_draw_texture(
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
GPU_shader_bind(shader);
- if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha);
- else glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
+ if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha);
+ else glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
glUniform1i(GPU_shader_get_uniform(shader, "image"), 0);
glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), x1, y1, x2, y2);
glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x, y, x + w, y + h);
- GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4);
+ GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4);
glBindTexture(GL_TEXTURE_2D, 0);
}
@@ -1285,6 +1432,11 @@ static void icon_draw_size(
icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, rgb, desaturate);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
}
+ else if (di->type == ICON_TYPE_EVENT) {
+ const short event_type = di->data.input.event_type;
+ const short event_value = di->data.input.event_value;
+ icon_draw_rect_input(x, y, w, h, alpha, event_type, event_value);
+ }
else if (di->type == ICON_TYPE_TEXTURE) {
/* texture image use premul alpha for correct scaling */
GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
@@ -1292,7 +1444,7 @@ static void icon_draw_size(
di->data.texture.w, di->data.texture.h, alpha, rgb);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
}
- else if (di->type== ICON_TYPE_MONO_TEXTURE) {
+ else if (di->type == ICON_TYPE_MONO_TEXTURE) {
/* icon that matches text color, assumed to be white */
float text_color[4];
UI_GetThemeColor4fv(TH_TEXT, text_color);
@@ -1554,7 +1706,7 @@ int UI_idcode_icon_get(const int idcode)
case ID_IM:
return ICON_IMAGE_DATA;
case ID_LA:
- return ICON_LAMP_DATA;
+ return ICON_LIGHT_DATA;
case ID_LS:
return ICON_LINE_DATA;
case ID_LT:
diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c
new file mode 100644
index 00000000000..fabf5f9bf48
--- /dev/null
+++ b/source/blender/editors/interface/interface_icons_event.c
@@ -0,0 +1,295 @@
+/*
+ * ***** 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/editors/interface/interface_icons_event.c
+ * \ingroup edinterface
+ *
+ * A special set of icons to represent input devices,
+ * this is a mix of text (via fonts) and a handful of custom glyphs for special keys.
+ *
+ * Event codes are used as identifiers.
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "GPU_draw.h"
+#include "GPU_matrix.h"
+#include "GPU_batch.h"
+#include "GPU_immediate.h"
+#include "GPU_state.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+#include "BLI_fileops_types.h"
+#include "BLI_math_vector.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_curve_types.h"
+#include "DNA_dynamicpaint_types.h"
+#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_workspace_types.h"
+
+#include "RNA_access.h"
+#include "RNA_enum_types.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_icons.h"
+#include "BKE_appdir.h"
+#include "BKE_studiolight.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_thumbs.h"
+
+#include "BIF_glutil.h"
+#include "BLF_api.h"
+
+#include "DEG_depsgraph.h"
+
+#include "DRW_engine.h"
+
+#include "ED_datafiles.h"
+#include "ED_keyframes_draw.h"
+#include "ED_render.h"
+
+#include "UI_interface.h"
+#include "UI_interface_icons.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "interface_intern.h"
+
+static void icon_draw_rect_input_small_text_ex(
+ const rctf *rect, const float color[4], const float margin[2], const char *str,
+ int font_size)
+{
+ BLF_batch_draw_flush();
+ const int font_id = BLF_default();
+ BLF_color4fv(font_id, color);
+ BLF_size(font_id, font_size * U.pixelsize, U.dpi);
+ BLF_position(font_id, rect->xmin + margin[0] * 2, rect->ymin + margin[1] * 5, 0.0f);
+ BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX);
+ BLF_batch_draw_flush();
+}
+
+static void icon_draw_rect_input_small_text(
+ const rctf *rect, const float color[4], const float margin[2], const char *str)
+{
+ icon_draw_rect_input_small_text_ex(rect, color, margin, str, 8);
+}
+
+static void icon_draw_rect_input_default_text(
+ const rctf *rect,
+ const float color[4], const float margin[2], const char *str)
+{
+ BLF_batch_draw_flush();
+ const int font_id = BLF_default();
+ BLF_color4fv(font_id, color);
+ BLF_position(font_id, (int)(rect->xmin + margin[0] * 5), (int)(rect->ymin + margin[1] * 5), 0.0f);
+ BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX);
+ BLF_batch_draw_flush();
+}
+
+static void icon_draw_rect_input_mono_text(
+ const rctf *rect,
+ const float color[4], const float margin[2], const char *str)
+{
+ BLF_batch_draw_flush();
+ const int font_id = blf_mono_font;
+ BLF_color4fv(font_id, color);
+ BLF_size(font_id, 20 * U.pixelsize, U.dpi);
+ BLF_position(font_id, (int)(rect->xmin + margin[0] * 5), (int)(rect->ymin + margin[1] * 5), 0.0f);
+ BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX);
+ BLF_batch_draw_flush();
+}
+
+static void icon_draw_rect_input_line_prim(
+ const rctf *rect,
+ const float color[4],
+ const int prim,
+ const char lines[][2], int lines_len)
+{
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+ BLI_assert(ELEM(prim, GPU_PRIM_LINE_LOOP, GPU_PRIM_LINE_STRIP));
+ const uint pos_id = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4fv(color);
+ immBegin(prim, lines_len);
+ float w_inv = BLI_rctf_size_x(rect) / 255.0f;
+ float h_inv = BLI_rctf_size_y(rect) / 255.0f;
+ for (int i = 0; i < lines_len; i++) {
+ immVertex2f(
+ pos_id,
+ round_fl_to_int(rect->xmin + ((float)lines[i][0] * w_inv)),
+ round_fl_to_int(rect->ymin + ((float)lines[i][1] * h_inv))
+ );
+ }
+ immEnd();
+ immUnbindProgram();
+ glDisable(GL_LINE_SMOOTH);
+ glDisable(GL_BLEND);
+}
+
+void icon_draw_rect_input(
+ float x, float y, int w, int h, float UNUSED(alpha),
+ short event_type, short UNUSED(event_value))
+{
+ float color[4];
+ const float margin[2] = {w / 20.0f, h / 20.0f};
+ UI_GetThemeColor4fv(TH_TEXT, color);
+ UI_draw_roundbox_corner_set(UI_CNR_ALL);
+ UI_draw_roundbox_aa(
+ false,
+ (int)x,
+ (int)y,
+ (int)(x + w),
+ (int)(y + h), 4.0f, color
+ );
+
+ const rctf rect = {
+ .xmin = x,
+ .ymin = y,
+ .xmax = x + w,
+ .ymax = y + h,
+ };
+
+ const bool simple_text = false;
+
+ if ((event_type >= AKEY) || (ZKEY <= event_type)) {
+ char str[2] = {'A' + (event_type - AKEY), '\0'};
+ icon_draw_rect_input_default_text(&rect, color, margin, str);
+ }
+ if ((event_type >= F1KEY) || (F12KEY <= event_type)) {
+ char str[3] = {'F', '1' + (event_type - F1KEY), '\0'};
+ icon_draw_rect_input_default_text(&rect, color, margin, str);
+ }
+ else if (event_type == LEFTSHIFTKEY) {
+ if (simple_text) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "Shift");
+ }
+ else {
+ rctf rect_ofs = rect;
+ BLI_rctf_translate(&rect_ofs, (w / -14.0f), (w / -14.0f));
+ icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x87, 0xa7, 0x0});
+ }
+ }
+ else if (event_type == LEFTCTRLKEY) {
+ if (simple_text) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "Ctrl");
+ }
+ else {
+ rctf rect_ofs = rect;
+ BLI_rctf_translate(&rect_ofs, (w / -16.0f), 0.0f);
+ icon_draw_rect_input_default_text(&rect_ofs, color, margin, "^");
+ }
+ }
+ else if (event_type == LEFTALTKEY) {
+ if (simple_text) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "Alt");
+ }
+ else {
+ rctf rect_ofs = rect;
+ BLI_rctf_translate(&rect_ofs, (w / -8.0f), 0.0f);
+ icon_draw_rect_input_default_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x8c, 0xa5, 0x0});
+ }
+ }
+ else if (event_type == OSKEY) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "OS");
+ }
+ else if (event_type == DELKEY) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "Del");
+ }
+ else if (event_type == TABKEY) {
+ if (simple_text) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "Tab");
+ }
+ else {
+ rctf rect_ofs = rect;
+ BLI_rctf_translate(&rect_ofs, (w / -12.0f), (w / -12.0f));
+ icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x86, 0xb9, 0x0});
+ }
+ }
+ else if (event_type == HOMEKEY) {
+ if (simple_text) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "Home");
+ }
+ else {
+ rctf rect_ofs = rect;
+ BLI_rctf_translate(&rect_ofs, (w / -12.0f), (w / -12.0f));
+ icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x87, 0xa4, 0x0});
+ }
+ }
+ else if (event_type == ENDKEY) {
+ if (simple_text) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "End");
+ }
+ else {
+ rctf rect_ofs = rect;
+ BLI_rctf_translate(&rect_ofs, (w / -12.0f), (w / -12.0f));
+ icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x87, 0xa5, 0x0});
+ }
+ }
+ else if (event_type == RETKEY) {
+ if (simple_text) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "Ret");
+ }
+ else {
+ rctf rect_ofs = rect;
+ BLI_rctf_translate(&rect_ofs, (w / -8.0f), (w / -6.0f));
+ icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x8f, 0x8e, 0x0});
+ }
+ }
+ else if (event_type == ESCKEY) {
+ icon_draw_rect_input_small_text(&rect, color, margin, "Esc");
+ }
+ else if (event_type == PAGEUPKEY) {
+ icon_draw_rect_input_small_text_ex(&rect, color, margin, (const char[]){'P', 0xe2, 0x86, 0x91, 0x0}, 10);
+ }
+ else if (event_type == PAGEDOWNKEY) {
+ icon_draw_rect_input_small_text_ex(&rect, color, margin, (const char[]){'P', 0xe2, 0x86, 0x93, 0x0}, 10);
+ }
+ else if (event_type == LEFTARROWKEY) {
+ icon_draw_rect_input_default_text(&rect, color, margin, (const char[]){0xe2, 0x86, 0x90, 0x0});
+ }
+ else if (event_type == UPARROWKEY) {
+ icon_draw_rect_input_default_text(&rect, color, margin, (const char[]){0xe2, 0x86, 0x91, 0x0});
+ }
+ else if (event_type == RIGHTARROWKEY) {
+ icon_draw_rect_input_default_text(&rect, color, margin, (const char[]){0xe2, 0x86, 0x92, 0x0});
+ }
+ else if (event_type == DOWNARROWKEY) {
+ icon_draw_rect_input_default_text(&rect, color, margin, (const char[]){0xe2, 0x86, 0x93, 0x0});
+ }
+ else if (event_type == SPACEKEY) {
+ const uchar lines[] = {60, 118, 60, 60, 195, 60, 195, 118};
+ icon_draw_rect_input_line_prim(
+ &rect, color, GPU_PRIM_LINE_STRIP,
+ (const void *)lines, ARRAY_SIZE(lines) / 2);
+ }
+}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 04e9e2b18b4..fa60ac0552b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -105,7 +105,8 @@ typedef enum {
UI_WTYPE_PROGRESSBAR,
} uiWidgetTypeEnum;
-#define UI_MENU_WIDTH_MIN (UI_UNIT_Y * 9)
+#define UI_MENU_WIDTH_MIN (UI_UNIT_Y * 9)
+#define UI_MENU_SUBMENU_PADDING (6 * UI_DPI_FAC) /* some extra padding added to menus containing submenu icons */
/* menu scrolling */
#define UI_MENU_SCROLL_ARROW 12
@@ -349,6 +350,13 @@ struct PieMenuData {
float alphafac;
};
+/* uiBlock.content_hints */
+enum eBlockContentHints {
+ /* In a menu block, if there is a single sub-menu button, we add some
+ * padding to the right to put nicely aligned triangle icons there. */
+ BLOCK_CONTAINS_SUBMENU_BUT = (1 << 0),
+};
+
struct uiBlock {
uiBlock *next, *prev;
@@ -395,11 +403,15 @@ struct uiBlock {
int flag;
short alignnr;
+ /* Hints about the buttons of this block. Used to avoid iterating over
+ * buttons to find out if some criteria is met by any. Instead, check this
+ * criteria when adding the button and set a flag here if it's met. */
+ short content_hints; /* eBlockContentHints */
char direction;
char dt; /* drawtype: UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied to buttons */
bool auto_open;
- char _pad[7];
+ char _pad[5];
double auto_open_last;
const char *lockstr;
@@ -740,12 +752,11 @@ enum {
ROUNDBOX_TRIA_MAX, /* don't use */
};
-struct Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased);
-struct Gwn_Batch *ui_batch_roundbox_widget_get(int tria);
-struct Gwn_Batch *ui_batch_roundbox_shadow_get(void);
+struct GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased);
+struct GPUBatch *ui_batch_roundbox_widget_get(int tria);
+struct GPUBatch *ui_batch_roundbox_shadow_get(void);
-void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy,
- float rad, bool use_alpha, const float color[4]);
+void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4]);
void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
void ui_draw_popover_back(ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect);
void ui_draw_pie_center(uiBlock *block);
@@ -778,6 +789,11 @@ void uiStyleInit(void);
void ui_icon_ensure_deferred(const struct bContext *C, const int icon_id, const bool big);
int ui_id_icon_get(const struct bContext *C, struct ID *id, const bool big);
+/* interface_icons_event.c */
+void icon_draw_rect_input(
+ float x, float y, int w, int h, float alpha,
+ short event_type, short event_value);
+
/* resources.c */
void init_userdef_do_versions(struct Main *bmain);
void ui_theme_init_default(void);
@@ -827,6 +843,7 @@ struct wmKeyMap *eyedropper_colorband_modal_keymap(struct wmKeyConfig *keyconf);
/* interface_eyedropper_color.c */
void UI_OT_eyedropper_color(struct wmOperatorType *ot);
+void UI_OT_eyedropper_color_crypto(struct wmOperatorType *ot);
/* interface_eyedropper_colorband.c */
void UI_OT_eyedropper_colorband(struct wmOperatorType *ot);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 9b9199538d6..82ed4c5acba 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -681,8 +681,14 @@ static void ui_item_enum_expand(
for (item = item_array; item->identifier; item++) {
if (!item->identifier[0]) {
- if (radial && layout_radial) {
- uiItemS(layout_radial);
+ const EnumPropertyItem *next_item = item + 1;
+ if (next_item->identifier) {
+ if (radial && layout_radial) {
+ uiItemS(layout_radial);
+ }
+ else {
+ uiItemS(block->curlayout);
+ }
}
continue;
}
@@ -2179,32 +2185,13 @@ void uiItemPopoverPanel_ptr(uiLayout *layout, bContext *C, PanelType *pt, const
void uiItemPopoverPanel(
uiLayout *layout, bContext *C,
- int space_id, int region_id, const char *panel_type,
- const char *name, int icon)
+ const char *panel_type, const char *name, int icon)
{
- SpaceType *st = BKE_spacetype_from_id(space_id);
- if (st == NULL) {
- RNA_warning("space type not found %d", space_id);
- return;
- }
- ARegionType *art = BKE_regiontype_from_id(st, region_id);
- if (art == NULL) {
- RNA_warning("region type not found %d", region_id);
- return;
- }
-
- PanelType *pt;
- for (pt = art->paneltypes.first; pt; pt = pt->next) {
- if (STREQ(pt->idname, panel_type)) {
- break;
- }
- }
-
+ PanelType *pt = WM_paneltype_find(panel_type, true);
if (pt == NULL) {
- RNA_warning("area type not found %s", panel_type);
+ RNA_warning("Panel type not found '%s'", panel_type);
return;
}
-
uiItemPopoverPanel_ptr(layout, C, pt, name, icon);
}
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 3457d2e2eeb..ec10fc9d494 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -948,11 +948,14 @@ void UI_editsource_active_but_test(uiBut *but)
static int editsource_text_edit(
bContext *C, wmOperator *op,
- char filepath[FILE_MAX], int line)
+ const char filepath[FILE_MAX], const int line)
{
struct Main *bmain = CTX_data_main(C);
Text *text;
+ /* Developers may wish to copy-paste to an external editor. */
+ printf("%s:%d\n", filepath, line);
+
for (text = bmain->text.first; text; text = text->id.next) {
if (text->name && BLI_path_cmp(text->name, filepath) == 0) {
break;
@@ -1356,6 +1359,7 @@ void ED_operatortypes_ui(void)
/* external */
WM_operatortype_append(UI_OT_eyedropper_color);
+ WM_operatortype_append(UI_OT_eyedropper_color_crypto);
WM_operatortype_append(UI_OT_eyedropper_colorband);
WM_operatortype_append(UI_OT_eyedropper_colorband_point);
WM_operatortype_append(UI_OT_eyedropper_id);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 8107254f30b..59fdf7e672d 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -117,12 +117,17 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
/*********************** space specific code ************************/
/* temporary code to remove all sbuts stuff from panel code */
+/* SpaceButs.align */
+typedef enum eSpaceButtons_Align {
+ BUT_HORIZONTAL = 0,
+ BUT_VERTICAL = 1,
+ BUT_AUTO = 2,
+} eSpaceButtons_Align;
+
static int panel_aligned(ScrArea *sa, ARegion *ar)
{
- if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
- SpaceButs *sbuts = sa->spacedata.first;
- return sbuts->align;
- }
+ if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW)
+ return BUT_VERTICAL;
else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW)
return BUT_VERTICAL;
else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
@@ -180,10 +185,8 @@ static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **pa_animate)
if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
SpaceButs *sbuts = sa->spacedata.first;
- if (sbuts->align) {
- if (sbuts->re_align || sbuts->mainbo != sbuts->mainb) {
- return true;
- }
+ if (sbuts->mainbo != sbuts->mainb) {
+ return true;
}
}
else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) {
@@ -466,23 +469,6 @@ void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
}
}
-/* triangle 'icon' inside rect */
-static void ui_draw_tria_rect(const rctf *rect, char dir)
-{
- float color[4];
- UI_GetThemeColor3fv(TH_TITLE, color);
- color[3] = 1.0f;
-
- if (dir == 'h') {
- float half = 0.5f * BLI_rctf_size_y(rect);
- UI_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half, color);
- }
- else {
- float half = 0.5f * BLI_rctf_size_x(rect);
- UI_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin, color);
- }
-}
-
static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float y2)
{
@@ -492,7 +478,7 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float
GPU_line_width(2.0);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y2);
@@ -533,7 +519,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect)
GPU_blend(true);
immUniformColor4ub(255, 255, 255, 50);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, xmin, ymin);
immVertex2f(pos, xmax, ymax);
@@ -545,7 +531,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect)
immUniformColor4ub(0, 0, 0, 50);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, xmin, ymin + 1);
immVertex2f(pos, xmax, ymax + 1);
@@ -594,12 +580,11 @@ static void ui_draw_panel_dragwidget(unsigned int pos, unsigned int col, const r
const int x_ofs = y_ofs;
int i_x, i_y;
- int col_id = UI_GetThemeValue(TH_PANEL_SHOW_HEADER) ? TH_PANEL_HEADER : TH_PANEL_BACK;
- UI_GetThemeColorShade4fv(col_id, col_tint, col_high);
- UI_GetThemeColorShade4fv(col_id, -col_tint, col_dark);
+ UI_GetThemeColorShade4fv(TH_PANEL_HEADER, col_tint, col_high);
+ UI_GetThemeColorShade4fv(TH_PANEL_BACK, -col_tint, col_dark);
/* draw multiple boxes */
- immBegin(GWN_PRIM_TRIS, 4 * 2 * (6 * 2));
+ immBegin(GPU_PRIM_TRIS, 4 * 2 * (6 * 2));
for (i_x = 0; i_x < 4; i_x++) {
for (i_y = 0; i_y < 2; i_y++) {
const int x_co = (x_min + x_ofs) + (i_x * (box_size + box_margin));
@@ -692,7 +677,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
titlerect.xmin += 5.0f / block->aspect;
}
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
if (!is_subpanel) {
@@ -702,43 +687,19 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
GPU_blend(true);
- if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) {
- /* draw with background color */
- immUniformThemeColor(TH_PANEL_HEADER);
- immRectf(pos, minx, headrect.ymin + 1, maxx, y);
-
- immBegin(GWN_PRIM_LINES, 4);
+ /* draw with background color */
+ immUniformThemeColor(TH_PANEL_HEADER);
+ immRectf(pos, minx, headrect.ymin, maxx, y);
- immVertex2f(pos, minx, y);
- immVertex2f(pos, maxx, y);
+ immBegin(GPU_PRIM_LINES, 4);
- immVertex2f(pos, minx, y);
- immVertex2f(pos, maxx, y);
+ immVertex2f(pos, minx, y);
+ immVertex2f(pos, maxx, y);
- immEnd();
- }
- else if (!(panel->runtime_flag & PNL_FIRST)) {
- /* draw embossed separator */
-
- if (is_closed_x == false) {
- minx += 5.0f / block->aspect;
- maxx -= 5.0f / block->aspect;
- }
-
- immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex2f(pos, minx, y);
- immVertex2f(pos, maxx, y);
- immEnd();
+ immVertex2f(pos, minx, y);
+ immVertex2f(pos, maxx, y);
- immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex2f(pos, minx, y - 1);
- immVertex2f(pos, maxx, y - 1);
- immEnd();
- }
+ immEnd();
GPU_blend(false);
}
@@ -767,10 +728,10 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
ui_draw_aligned_panel_header(style, block, &titlerect, 'h');
if (show_drag) {
- unsigned int col;
- Gwn_VertFormat *format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ uint col;
+ GPUVertFormat *format = immVertexFormat();
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
/* itemrect smaller */
itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
@@ -784,7 +745,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
immUnbindProgram();
/* Restore format for the following draws. */
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
}
@@ -797,7 +758,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
else if (is_closed_x) {
/* draw vertical title */
ui_draw_aligned_panel_header(style, block, &headrect, 'v');
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
/* an open panel */
else {
@@ -812,17 +773,13 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ GPU_blend(true);
+
/* panel backdrop */
- if (is_subpanel) {
- GPU_blend(true);
- immUniformThemeColor(TH_PANEL_SUB_BACK);
- immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
- }
- else if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) {
- GPU_blend(true);
- immUniformThemeColor(TH_PANEL_BACK);
- immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
- }
+ int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK;
+
+ immUniformThemeColor(panel_col);
+ immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
if (panel->control & UI_PNL_SCALE)
ui_draw_panel_scalewidget(pos, rect);
@@ -850,12 +807,18 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
BLI_rctf_scale(&itemrect, 0.25f);
- if (is_closed_y)
- ui_draw_tria_rect(&itemrect, 'h');
- else if (is_closed_x)
- ui_draw_tria_rect(&itemrect, 'h');
- else
- ui_draw_tria_rect(&itemrect, 'v');
+ {
+ float tria_color[4];
+ UI_GetThemeColor3fv(TH_TITLE, tria_color);
+ tria_color[3] = 1.0f;
+
+ if (is_closed_y)
+ ui_draw_anti_tria_rect(&itemrect, 'h', tria_color);
+ else if (is_closed_x)
+ ui_draw_anti_tria_rect(&itemrect, 'h', tria_color);
+ else
+ ui_draw_anti_tria_rect(&itemrect, 'v', tria_color);
+ }
}
/************************** panel alignment *************************/
@@ -1737,31 +1700,31 @@ static void ui_panel_category_draw_tab(
{0.98, 0.805}};
int a;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
/* mult */
for (a = 0; a < 4; a++) {
mul_v2_fl(vec[a], rad);
}
- unsigned int vert_ct = 0;
+ uint vert_len = 0;
if (use_highlight) {
- vert_ct += (roundboxtype & UI_CNR_TOP_RIGHT) ? 6 : 1;
- vert_ct += (roundboxtype & UI_CNR_TOP_LEFT) ? 6 : 1;
+ vert_len += (roundboxtype & UI_CNR_TOP_RIGHT) ? 6 : 1;
+ vert_len += (roundboxtype & UI_CNR_TOP_LEFT) ? 6 : 1;
}
if (use_highlight && !use_shadow) {
- vert_ct++;
+ vert_len++;
}
else {
- vert_ct += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 6 : 1;
- vert_ct += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 6 : 1;
+ vert_len += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 6 : 1;
+ vert_len += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 6 : 1;
}
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
- immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_STRIP, vert_ct);
+ immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_STRIP, vert_len);
/* start with corner right-top */
if (use_highlight) {
@@ -1966,7 +1929,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
/* begin drawing */
GPU_line_smooth(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* draw the background */
@@ -2028,7 +1991,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
/* tab blackline */
if (!is_active) {
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv(theme_col_tab_divider);
@@ -2059,7 +2022,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
GPU_blend(false);
/* tab blackline remaining (last tab) */
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
if (pc_dyn->prev == NULL) {
immUniformColor3ubv(theme_col_tab_divider);
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index fb14ca745c6..376e367f4da 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -87,6 +87,9 @@ struct uiPopover {
uiMenuCreateFunc menu_func;
void *menu_arg;
+ /* Size in pixels (ui scale applied). */
+ int ui_size_x;
+
#ifdef USE_UI_POPOVER_ONCE
bool is_once;
#endif
@@ -94,12 +97,13 @@ struct uiPopover {
static void ui_popover_create_block(bContext *C, uiPopover *pup, int opcontext)
{
- uiStyle *style = UI_style_get_dpi();
+ BLI_assert(pup->ui_size_x != 0);
+ uiStyle *style = UI_style_get_dpi();
pup->block = UI_block_begin(C, NULL, __func__, UI_EMBOSS);
pup->layout = UI_block_layout(
pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0,
- U.widget_unit * UI_POPOVER_WIDTH_UNITS, 0, MENU_PADDING, style);
+ pup->ui_size_x, 0, MENU_PADDING, style);
uiLayoutSetOperatorContext(pup->layout, opcontext);
@@ -234,6 +238,13 @@ uiPopupBlockHandle *ui_popover_panel_create(
/* Create popover, buttons are created from callback. */
uiPopover *pup = MEM_callocN(sizeof(uiPopover), __func__);
pup->but = but;
+
+ /* FIXME: maybe one day we want non panel popovers? */
+ {
+ int ui_units_x = ((PanelType *)arg)->ui_units_x;
+ pup->ui_size_x = U.widget_unit * (ui_units_x ? ui_units_x : UI_POPOVER_WIDTH_UNITS);
+ }
+
pup->menu_func = menu_func;
pup->menu_arg = arg;
@@ -266,16 +277,13 @@ uiPopupBlockHandle *ui_popover_panel_create(
* \{ */
int UI_popover_panel_invoke(
- bContext *C, int space_id, int region_id, const char *idname,
+ bContext *C, const char *idname,
bool keep_open, ReportList *reports)
{
uiLayout *layout;
- PanelType *pt = UI_paneltype_find(space_id, region_id, idname);
+ PanelType *pt = WM_paneltype_find(idname, true);
if (pt == NULL) {
- BKE_reportf(
- reports, RPT_ERROR,
- "Panel \"%s\" not found (space %d, region %d)",
- idname, space_id, region_id);
+ BKE_reportf(reports, RPT_ERROR, "Panel \"%s\" not found", idname);
return OPERATOR_CANCELLED;
}
@@ -288,7 +296,7 @@ int UI_popover_panel_invoke(
ui_popover_panel_create(C, NULL, NULL, ui_item_paneltype_func, pt);
}
else {
- uiPopover *pup = UI_popover_begin(C);
+ uiPopover *pup = UI_popover_begin(C, U.widget_unit * pt->ui_units_x);
layout = UI_popover_layout(pup);
UI_paneltype_draw(C, pt, layout);
UI_popover_end(C, pup, NULL);
@@ -306,9 +314,13 @@ int UI_popover_panel_invoke(
/**
* Only return handler, and set optional title.
*/
-uiPopover *UI_popover_begin(bContext *C)
+uiPopover *UI_popover_begin(bContext *C, int ui_size_x)
{
uiPopover *pup = MEM_callocN(sizeof(uiPopover), "popover menu");
+ if (ui_size_x == 0) {
+ ui_size_x = U.widget_unit * UI_POPOVER_WIDTH_UNITS;
+ }
+ pup->ui_size_x = ui_size_x;
/* Opertor context default same as menus, change if needed. */
ui_popover_create_block(C, pup, WM_OP_EXEC_REGION_WIN);
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 0ac4d4d28ec..1bbf2242c5d 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -116,6 +116,9 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut
BLI_rctf_init_minmax(&block->rect);
for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ if (block->content_hints & BLOCK_CONTAINS_SUBMENU_BUT) {
+ bt->rect.xmax += UI_MENU_SUBMENU_PADDING;
+ }
BLI_rctf_union(&block->rect, &bt->rect);
}
}
@@ -342,7 +345,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar)
* Use to refresh centered popups on screen resizing (for splash).
*/
static void ui_block_region_popup_window_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene))
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene))
{
switch (wmn->category) {
case NC_WINDOW:
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index 9ca79a3dc63..d262cbc38bd 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -406,7 +406,7 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *ar)
wmOrtho2_region_pixelspace(ar);
if (data->noback == false) {
- ui_draw_widget_back(UI_WTYPE_BOX, true, &data->bbox);
+ ui_draw_widget_back(UI_WTYPE_MENU_BACK, true, &data->bbox);
}
/* draw text */
@@ -686,7 +686,7 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
wmOrtho2_region_pixelspace(ar);
if (data->noback == false) {
- ui_draw_widget_back(UI_WTYPE_BOX, true, &data->bbox);
+ ui_draw_widget_back(UI_WTYPE_MENU_BACK, true, &data->bbox);
}
/* draw text */
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index ed83a715c7e..97f501b7448 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -615,31 +615,31 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
}
}
-static uiTooltipData *ui_tooltip_data_from_manipulator(bContext *C, wmManipulator *mpr)
+static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz)
{
uiTooltipData *data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData");
- /* TODO(campbell): a way for manipulators to have their own descriptions (low priority). */
+ /* TODO(campbell): a way for gizmos to have their own descriptions (low priority). */
/* Operator Actions */
{
- bool use_drag = mpr->drag_part != -1 && mpr->highlight_part != mpr->drag_part;
+ bool use_drag = gz->drag_part != -1 && gz->highlight_part != gz->drag_part;
const struct {
int part;
const char *prefix;
} mpop_actions[] = {
{
- .part = mpr->highlight_part,
+ .part = gz->highlight_part,
.prefix = use_drag ? TIP_("Click") : NULL,
}, {
- .part = use_drag ? mpr->drag_part : -1,
+ .part = use_drag ? gz->drag_part : -1,
.prefix = use_drag ? TIP_("Drag") : NULL,
},
};
for (int i = 0; i < ARRAY_SIZE(mpop_actions); i++) {
- wmManipulatorOpElem *mpop = (mpop_actions[i].part != -1) ? WM_manipulator_operator_get(mpr, mpop_actions[i].part) : NULL;
+ wmGizmoOpElem *mpop = (mpop_actions[i].part != -1) ? WM_gizmo_operator_get(gz, mpop_actions[i].part) : NULL;
if (mpop != NULL) {
/* Description */
const char *info = RNA_struct_ui_description(mpop->type->srna);
@@ -691,13 +691,13 @@ static uiTooltipData *ui_tooltip_data_from_manipulator(bContext *C, wmManipulato
}
/* Property Actions */
- if (mpr->type->target_property_defs_len) {
- wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr);
- for (int i = 0; i < mpr->type->target_property_defs_len; i++) {
+ if (gz->type->target_property_defs_len) {
+ wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz);
+ for (int i = 0; i < gz->type->target_property_defs_len; i++) {
/* TODO(campbell): function callback descriptions. */
- wmManipulatorProperty *mpr_prop = &mpr_prop_array[i];
- if (mpr_prop->prop != NULL) {
- const char *info = RNA_property_ui_description(mpr_prop->prop);
+ wmGizmoProperty *gz_prop = &gz_prop_array[i];
+ if (gz_prop->prop != NULL) {
+ const char *info = RNA_property_ui_description(gz_prop->prop);
if (info && info[0]) {
uiTooltipField *field = text_field_add(
data, &(uiTooltipFormat){
@@ -934,13 +934,13 @@ ARegion *UI_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *b
return ui_tooltip_create_with_data(C, data, init_position, aspect);
}
-ARegion *UI_tooltip_create_from_manipulator(bContext *C, wmManipulator *mpr)
+ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *gz)
{
wmWindow *win = CTX_wm_window(C);
const float aspect = 1.0f;
float init_position[2];
- uiTooltipData *data = ui_tooltip_data_from_manipulator(C, mpr);
+ uiTooltipData *data = ui_tooltip_data_from_gizmo(C, gz);
if (data == NULL) {
return NULL;
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index fbfa64cbdbd..2dcc18af4ea 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -390,36 +390,22 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
/* for new/open operators */
void UI_context_active_but_prop_get_templateID(
- bContext *C,
- PointerRNA *r_ptr, PropertyRNA **r_prop)
+ bContext *C,
+ PointerRNA *r_ptr, PropertyRNA **r_prop)
{
TemplateID *template_ui;
- ARegion *ar = CTX_wm_region(C);
- uiBlock *block;
- uiBut *but;
+ uiBut *but = UI_context_active_but_get(C);
memset(r_ptr, 0, sizeof(*r_ptr));
*r_prop = NULL;
- if (!ar)
- return;
-
- for (block = ar->uiblocks.first; block; block = block->next) {
- for (but = block->buttons.first; but; but = but->next) {
- /* find the button before the active one */
- if ((but->flag & (UI_BUT_LAST_ACTIVE | UI_ACTIVE))) {
- if (but->func_argN) {
- template_ui = but->func_argN;
- *r_ptr = template_ui->ptr;
- *r_prop = template_ui->prop;
- return;
- }
- }
- }
+ if (but && but->func_argN) {
+ template_ui = but->func_argN;
+ *r_ptr = template_ui->ptr;
+ *r_prop = template_ui->prop;
}
}
-
static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
{
TemplateID *template_ui = (TemplateID *)arg_litem;
@@ -535,7 +521,7 @@ static const char *template_id_browse_tip(const StructRNA *type)
case ID_IM: return N_("Browse Image to be linked");
case ID_LS: return N_("Browse Line Style Data to be linked");
case ID_LT: return N_("Browse Lattice Data to be linked");
- case ID_LA: return N_("Browse Lamp Data to be linked");
+ case ID_LA: return N_("Browse Light Data to be linked");
case ID_CA: return N_("Browse Camera Data to be linked");
case ID_WO: return N_("Browse World Settings to be linked");
case ID_SCR: return N_("Choose Screen layout");
@@ -1880,7 +1866,7 @@ void uiTemplatePreview(
char _preview_id[UI_MAX_NAME_STR];
if (id && !ELEM(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");
+ RNA_warning("Expected ID of type material, texture, light, world or line style");
return;
}
@@ -1971,7 +1957,7 @@ void uiTemplatePreview(
pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
}
else if (GS(parent->name) == ID_LA) {
- uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Lamp"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
+ uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Light"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
}
else if (GS(parent->name) == ID_WO) {
@@ -3057,6 +3043,24 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname,
}
}
+void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propname)
+{
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
+ uiBlock *block;
+ uiBut *but;
+
+ if (!prop) {
+ RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+
+ block = uiLayoutGetBlock(layout);
+
+ but = uiDefIconTextButO(block, UI_BTYPE_BUT, "UI_OT_eyedropper_color_crypto", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, RNA_property_ui_name(prop), 0, 0, UI_UNIT_X, UI_UNIT_Y, RNA_property_ui_description(prop));
+ but->rnapoin = *ptr;
+ but->rnaprop = prop;
+ but->rnaindex = -1;
+}
/********************* Layer Buttons Template ************************/
@@ -4347,6 +4351,10 @@ void uiTemplateInputStatus(uiLayout *layout, struct bContext *C)
return;
}
+ if (WM_window_modal_keymap_status_draw(C, win, layout)) {
+ return;
+ }
+
/* Otherwise should cursor keymap status. */
for (int i = 0; i < 3; i++) {
uiLayout *box = uiLayoutRow(layout, false);
@@ -4357,7 +4365,9 @@ void uiTemplateInputStatus(uiLayout *layout, struct bContext *C)
const char *msg = WM_window_cursor_keymap_status_get(win, i, 0);
const char *msg_drag = WM_window_cursor_keymap_status_get(win, i, 1);
- uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i));
+ if (msg || (msg_drag == NULL)) {
+ uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i));
+ }
if (msg_drag) {
uiItemL(row, msg_drag, (ICON_MOUSE_LMB_DRAG + i));
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index dbd65ade307..52e6e237a58 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -55,6 +55,7 @@
#include "GPU_basic_shader.h"
#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -246,22 +247,22 @@ static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {
};
static struct {
- Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX];
+ GPUBatch *roundbox_widget[ROUNDBOX_TRIA_MAX];
- Gwn_Batch *roundbox_simple;
- Gwn_Batch *roundbox_simple_aa;
- Gwn_Batch *roundbox_simple_outline;
- Gwn_Batch *roundbox_shadow;
+ GPUBatch *roundbox_simple;
+ GPUBatch *roundbox_simple_aa;
+ GPUBatch *roundbox_simple_outline;
+ GPUBatch *roundbox_shadow;
- Gwn_VertFormat format;
+ GPUVertFormat format;
uint vflag_id;
} g_ui_batch_cache = {{0}};
-static Gwn_VertFormat *vflag_format(void)
+static GPUVertFormat *vflag_format(void)
{
- if (g_ui_batch_cache.format.attrib_ct == 0) {
- Gwn_VertFormat *format = &g_ui_batch_cache.format;
- g_ui_batch_cache.vflag_id = GWN_vertformat_attr_add(format, "vflag", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ if (g_ui_batch_cache.format.attr_len == 0) {
+ GPUVertFormat *format = &g_ui_batch_cache.format;
+ g_ui_batch_cache.vflag_id = GPU_vertformat_attr_add(format, "vflag", GPU_COMP_U32, 1, GPU_FETCH_INT);
}
return &g_ui_batch_cache.format;
}
@@ -272,17 +273,17 @@ static Gwn_VertFormat *vflag_format(void)
#define NO_AA WIDGET_AA_JITTER
static void set_roundbox_vertex_data(
- Gwn_VertBufRaw *vflag_step, uint32_t d)
+ GPUVertBufRaw *vflag_step, uint32_t d)
{
- uint32_t *data = GWN_vertbuf_raw_step(vflag_step);
+ uint32_t *data = GPU_vertbuf_raw_step(vflag_step);
*data = d;
}
static uint32_t set_roundbox_vertex(
- Gwn_VertBufRaw *vflag_step,
+ GPUVertBufRaw *vflag_step,
int corner_id, int corner_v, int jit_v, bool inner, bool emboss, int color)
{
- uint32_t *data = GWN_vertbuf_raw_step(vflag_step);
+ uint32_t *data = GPU_vertbuf_raw_step(vflag_step);
*data = corner_id;
*data |= corner_v << 2;
*data |= jit_v << 6;
@@ -293,10 +294,10 @@ static uint32_t set_roundbox_vertex(
}
static uint32_t set_tria_vertex(
- Gwn_VertBufRaw *vflag_step,
+ GPUVertBufRaw *vflag_step,
int tria_type, int tria_v, int tria_id, int jit_v)
{
- uint32_t *data = GWN_vertbuf_raw_step(vflag_step);
+ uint32_t *data = GPU_vertbuf_raw_step(vflag_step);
if (ELEM(tria_type, ROUNDBOX_TRIA_ARROWS)) {
tria_v += tria_id * tria_vcount[ROUNDBOX_TRIA_ARROWS];
}
@@ -307,7 +308,7 @@ static uint32_t set_tria_vertex(
return *data;
}
-static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data)
+static void roundbox_batch_add_tria(GPUVertBufRaw *vflag_step, int tria, uint32_t last_data)
{
const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW, ROUNDBOX_TRIA_MENU) ? 1 : 2;
/* for each tria */
@@ -323,12 +324,12 @@ static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32
}
}
-Gwn_Batch *ui_batch_roundbox_widget_get(int tria)
+GPUBatch *ui_batch_roundbox_widget_get(int tria)
{
if (g_ui_batch_cache.roundbox_widget[tria] == NULL) {
uint32_t last_data;
- Gwn_VertBufRaw vflag_step;
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format());
+ GPUVertBufRaw vflag_step;
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format());
int vcount = WIDGET_SIZE_MAX; /* inner */
vcount += 2; /* restart */
vcount += ((WIDGET_SIZE_MAX + 1) * 2) * WIDGET_AA_JITTER; /* outline (edges) */
@@ -340,8 +341,8 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria)
vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */
}
}
- GWN_vertbuf_data_alloc(vbo, vcount);
- GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
+ GPU_vertbuf_data_alloc(vbo, vcount);
+ GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
/* Inner */
for (int c1 = 0, c2 = 3; c1 < 2; c1++, c2--) {
for (int a1 = 0, a2 = WIDGET_CURVE_RESOLU -1; a2 >= 0; a1++, a2--) {
@@ -382,15 +383,15 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria)
if (tria) {
roundbox_batch_add_tria(&vflag_step, tria, last_data);
}
- g_ui_batch_cache.roundbox_widget[tria] = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ g_ui_batch_cache.roundbox_widget[tria] = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
gpu_batch_presets_register(g_ui_batch_cache.roundbox_widget[tria]);
}
return g_ui_batch_cache.roundbox_widget[tria];
}
-Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased)
+GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased)
{
- Gwn_Batch **batch = NULL;
+ GPUBatch **batch = NULL;
if (filled) {
if (antialiased)
@@ -407,13 +408,13 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased)
if (*batch == NULL) {
uint32_t last_data;
- Gwn_VertBufRaw vflag_step;
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format());
+ GPUVertBufRaw vflag_step;
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format());
int vcount = WIDGET_SIZE_MAX;
vcount += (filled) ? 2 : 0;
vcount *= (antialiased) ? WIDGET_AA_JITTER : 1;
- GWN_vertbuf_data_alloc(vbo, vcount);
- GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
+ GPU_vertbuf_data_alloc(vbo, vcount);
+ GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
if (filled) {
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
@@ -434,7 +435,7 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased)
break;
}
}
- *batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ *batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
else {
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
@@ -450,7 +451,7 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased)
break;
}
}
- *batch = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ *batch = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
gpu_batch_presets_register(*batch);
@@ -458,15 +459,15 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased)
return *batch;
}
-Gwn_Batch *ui_batch_roundbox_shadow_get(void)
+GPUBatch *ui_batch_roundbox_shadow_get(void)
{
if (g_ui_batch_cache.roundbox_shadow == NULL) {
uint32_t last_data;
- Gwn_VertBufRaw vflag_step;
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format());
+ GPUVertBufRaw vflag_step;
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format());
int vcount = (WIDGET_SIZE_MAX + 1) * 2 + 2 + WIDGET_SIZE_MAX;
- GWN_vertbuf_data_alloc(vbo, vcount);
- GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
+ GPU_vertbuf_data_alloc(vbo, vcount);
+ GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
for (int c = 0; c < 4; c++) {
for (int a = 0; a < WIDGET_CURVE_RESOLU; a++) {
@@ -487,7 +488,7 @@ Gwn_Batch *ui_batch_roundbox_shadow_get(void)
set_roundbox_vertex(&vflag_step, c2, a2, NO_AA, true, false, INNER);
}
}
- g_ui_batch_cache.roundbox_shadow = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ g_ui_batch_cache.roundbox_shadow = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow);
}
return g_ui_batch_cache.roundbox_shadow;
@@ -512,11 +513,11 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
GPU_blend(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(draw_color);
- immBegin(GWN_PRIM_TRIS, 3 * WIDGET_AA_JITTER);
+ immBegin(GPU_PRIM_TRIS, 3 * WIDGET_AA_JITTER);
/* for each AA step */
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
@@ -532,6 +533,20 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
GPU_blend(false);
}
+/* triangle 'icon' inside rect */
+void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4])
+{
+ if (dir == 'h') {
+ float half = 0.5f * BLI_rctf_size_y(rect);
+ UI_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half, color);
+ }
+ else {
+ float half = 0.5f * BLI_rctf_size_x(rect);
+ UI_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin, color);
+ }
+}
+
+
void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float color[4])
{
float draw_color[4];
@@ -541,14 +556,14 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col
GPU_blend(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(draw_color);
/* for each AA step */
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
- immBegin(GWN_PRIM_TRI_FAN, length);
+ immBegin(GPU_PRIM_TRI_FAN, length);
immVertex2f(pos, tri_array[0][0], tri_array[0][1]);
immVertex2f(pos, tri_array[1][0], tri_array[1][1]);
@@ -1069,7 +1084,7 @@ static void widgetbase_set_uniform_colors_ubv(
#define MAX_WIDGET_PARAMETERS 11
struct {
- Gwn_Batch *batch; /* Batch type */
+ GPUBatch *batch; /* Batch type */
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH];
int count;
bool enabled;
@@ -1082,22 +1097,22 @@ void UI_widgetbase_draw_cache_flush(void)
if (g_widget_base_batch.count == 0)
return;
- Gwn_Batch *batch = g_widget_base_batch.batch;
+ GPUBatch *batch = g_widget_base_batch.batch;
if (g_widget_base_batch.count == 1) {
/* draw single */
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
- GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params);
- GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
- GWN_batch_draw(batch);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
+ GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params);
+ GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
+ GPU_batch_draw(batch);
}
else {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST);
- GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH,
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST);
+ GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH,
(float *)g_widget_base_batch.params);
- GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
- gpuBindMatrices(batch->interface);
- GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true);
- GWN_batch_program_use_end(batch);
+ GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
+ GPU_matrix_bind(batch->interface);
+ GPU_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true);
+ GPU_batch_program_use_end(batch);
}
g_widget_base_batch.count = 0;
}
@@ -1120,7 +1135,7 @@ void UI_widgetbase_draw_cache_end(void)
GPU_blend(false);
}
-static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb)
+static void draw_widgetbase_batch(GPUBatch *batch, uiWidgetBase *wtb)
{
wtb->uniform_params.tria1_size = wtb->tria1.size;
wtb->uniform_params.tria2_size = wtb->tria2.size;
@@ -1156,10 +1171,10 @@ static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb)
else {
float checker_params[3] = {UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 8.0f};
/* draw single */
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
- GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params);
- GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
- GWN_batch_draw(batch);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
+ GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params);
+ GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
+ GPU_batch_draw(batch);
}
}
@@ -1213,7 +1228,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol)
if (inner_col1[3] || inner_col2[3] || outline_col[3] || emboss_col[3] || tria_col[3] || alpha_check) {
widgetbase_set_uniform_colors_ubv(wtb, inner_col1, inner_col2, outline_col, emboss_col, tria_col, alpha_check);
- Gwn_Batch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type);
+ GPUBatch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type);
draw_widgetbase_batch(roundbox_batch, wtb);
}
@@ -1255,8 +1270,8 @@ static int ui_but_draw_menu_icon(const uiBut *but)
/* icons have been standardized... and this call draws in untransformed coordinates */
static void widget_draw_icon_ex(
- const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const bool show_menu_icon,
- const int icon_size)
+ const uiBut *but, BIFIconID icon, float alpha,
+ const rcti *rect, const int icon_size)
{
float xs = 0.0f, ys = 0.0f;
float aspect, height;
@@ -1331,20 +1346,35 @@ static void widget_draw_icon_ex(
}
}
- if (show_menu_icon) {
- xs = rect->xmax - UI_DPI_ICON_SIZE - aspect;
- ys = (rect->ymin + rect->ymax - height) / 2.0f;
-
- UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha);
- }
-
GPU_blend(false);
}
static void widget_draw_icon(
- const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const bool show_menu_icon)
+ const uiBut *but, BIFIconID icon, float alpha, const rcti *rect)
+{
+ widget_draw_icon_ex(but, icon, alpha, rect, ICON_DEFAULT_HEIGHT);
+}
+
+static void widget_draw_submenu_tria(const uiBut *but, const rcti *rect, const uiWidgetColors *wcol)
{
- widget_draw_icon_ex(but, icon, alpha, rect, show_menu_icon, ICON_DEFAULT_HEIGHT);
+ const float aspect = but->block->aspect / UI_DPI_FAC;
+ const int tria_height = (int)(ICON_DEFAULT_HEIGHT / aspect);
+ const int tria_width = (int)(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize;
+ const int xs = rect->xmax - tria_width;
+ const int ys = (rect->ymin + rect->ymax - tria_height) / 2.0f;
+ float col[4];
+ rctf tria_rect;
+
+ rgba_uchar_to_float(col, (const uchar *)wcol->text);
+ col[3] *= 0.8f;
+
+ BLI_rctf_init(&tria_rect, xs, xs + tria_width, ys, ys + tria_height);
+ BLI_rctf_scale(&tria_rect, 0.4f);
+
+ GPU_blend(true);
+ UI_widgetbase_draw_cache_flush();
+ GPU_blend(false);
+ ui_draw_anti_tria_rect(&tria_rect, 'h', col);
}
static void ui_text_clip_give_prev_off(uiBut *but, const char *str)
@@ -1806,7 +1836,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv((unsigned char *)wcol->item);
@@ -1842,7 +1872,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
UI_widgetbase_draw_cache_flush();
GPU_blend(false);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(0.2f, 0.6f, 0.9f);
@@ -1878,7 +1908,7 @@ 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 | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)) &&
+ if ((but->drawflag & UI_BUT_HAS_SHORTCUT) &&
(but->editstr == NULL))
{
if (but->flag & UI_BUT_HAS_SEP_CHAR) {
@@ -1961,9 +1991,15 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* part text right aligned */
if (drawstr_right) {
+ char col[4];
+ copy_v4_v4_char(col, wcol->text);
+ if (but->drawflag & UI_BUT_HAS_SHORTCUT) {
+ col[3] *= 0.5f;
+ }
+
fstyle->align = UI_STYLE_TEXT_RIGHT;
rect->xmax -= UI_TEXT_CLIP_MARGIN;
- UI_fontstyle_draw(fstyle, rect, drawstr_right, (unsigned char *)wcol->text);
+ UI_fontstyle_draw(fstyle, rect, drawstr_right, (const uchar *)col);
}
}
@@ -1981,7 +2017,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && (but->flag & UI_BUT_NODE_LINK)) {
rcti temp = *rect;
temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
- widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, false);
+ widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp);
rect->xmax = temp.xmin;
}
@@ -2051,17 +2087,17 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
else if (ui_block_is_menu(but->block))
rect->xmin += 0.3f * U.widget_unit;
- widget_draw_icon(but, icon, alpha, rect, show_menu_icon);
+ widget_draw_icon(but, icon, alpha, rect);
+ if (show_menu_icon) {
+ BLI_assert(but->block->content_hints & BLOCK_CONTAINS_SUBMENU_BUT);
+ widget_draw_submenu_tria(but, rect, wcol);
+ }
#ifdef USE_UI_TOOLBAR_HACK
but->block->aspect = aspect_orig;
#endif
rect->xmin += icon_size;
- /* without this menu keybindings will overlap the arrow icon [#38083] */
- if (show_menu_icon) {
- rect->xmax -= icon_size / 2.0f;
- }
}
if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
@@ -2071,6 +2107,12 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
+ /* Menu contains sub-menu items with triangle icon on their right. Shortcut
+ * strings should be drawn with some padding to the right then. */
+ if (ui_block_is_menu(but->block) && (but->block->content_hints & BLOCK_CONTAINS_SUBMENU_BUT)) {
+ rect->xmax -= UI_MENU_SUBMENU_PADDING;
+ }
+
/* extra icons, e.g. 'x' icon to clear text or icon for eyedropper */
if (extra_icon_type != UI_BUT_ICONEXTRA_NONE) {
rcti temp = *rect;
@@ -2078,10 +2120,10 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f);
if (extra_icon_type == UI_BUT_ICONEXTRA_CLEAR) {
- widget_draw_icon(but, ICON_PANEL_CLOSE, alpha, &temp, false);
+ widget_draw_icon(but, ICON_PANEL_CLOSE, alpha, &temp);
}
else if (extra_icon_type == UI_BUT_ICONEXTRA_EYEDROPPER) {
- widget_draw_icon(but, ICON_EYEDROPPER, alpha, &temp, false);
+ widget_draw_icon(but, ICON_EYEDROPPER, alpha, &temp);
}
else {
BLI_assert(0);
@@ -2381,7 +2423,7 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
/* we draw a number of increasing size alpha quad strips */
alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -2433,7 +2475,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
static void ui_hsv_cursor(float x, float y)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -2529,13 +2571,13 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
- immBegin(GWN_PRIM_TRI_FAN, tot + 2);
+ immBegin(GPU_PRIM_TRI_FAN, tot + 2);
immAttrib3fv(color, colcent);
immVertex2f(pos, centx, centy);
@@ -2556,7 +2598,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
/* fully rounded outline */
format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -2640,12 +2682,12 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
}
/* old below */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
- immBegin(GWN_PRIM_TRIS, steps * 3 * 6);
+ immBegin(GPU_PRIM_TRIS, steps * 3 * 6);
for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */
const float dx_next = dx + color_step;
@@ -2801,7 +2843,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
ui_hsv_cursor(x, y);
/* outline */
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ub(0, 0, 0);
imm_draw_box_wire_2d(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
@@ -2898,14 +2940,14 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol)
30
};
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_blend(true);
immUniformColor4ubv(col);
GPU_line_width(1.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, rect->xmin, y);
immVertex2f(pos, rect->xmax, y);
immEnd();
@@ -3360,11 +3402,11 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
UI_widgetbase_draw_cache_flush();
GPU_blend(false);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(bw, bw, bw);
- immBegin(GWN_PRIM_TRIS, 3);
+ immBegin(GPU_PRIM_TRIS, 3);
immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.9f * height);
immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.5f * height);
immVertex2f(pos, rect->xmin + 0.5f * width, rect->ymin + 0.9f * height);
@@ -3452,30 +3494,6 @@ static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
widgetbase_draw(&wtb, wcol);
}
-static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
-{
- /* silly node link button hacks */
- uiWidgetBase wtb;
- uiWidgetColors wcol_backup = *wcol;
- float rad;
-
- widget_init(&wtb);
-
- rad = wcol->roundness * U.widget_unit;
- round_box_edges(&wtb, roundboxalign, rect, rad);
-
- wcol->inner[0] = min_ii(wcol->inner[0] + 15, 255);
- wcol->inner[1] = min_ii(wcol->inner[1] + 15, 255);
- wcol->inner[2] = min_ii(wcol->inner[2] + 15, 255);
- wcol->outline[0] = min_ii(wcol->outline[0] + 15, 255);
- wcol->outline[1] = min_ii(wcol->outline[1] + 15, 255);
- wcol->outline[2] = min_ii(wcol->outline[2] + 15, 255);
-
- /* decoration */
- widgetbase_draw(&wtb, wcol);
- *wcol = wcol_backup;
-}
-
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
float back[4];
@@ -3765,7 +3783,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
/* note: drawextra can change rect +1 or -1, to match round errors of existing previews */
but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* make mask to draw over image */
@@ -3876,6 +3894,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
case UI_WTYPE_MENU_ICON_RADIO:
+ case UI_WTYPE_MENU_NODE_LINK:
wt.wcol_theme = &btheme->tui.wcol_menu;
wt.draw = widget_menuiconbut;
break;
@@ -3885,11 +3904,6 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.draw = widget_menubut;
break;
- case UI_WTYPE_MENU_NODE_LINK:
- wt.wcol_theme = &btheme->tui.wcol_menu;
- wt.draw = widget_menunodebut;
- break;
-
case UI_WTYPE_PULLDOWN:
wt.wcol_theme = &btheme->tui.wcol_pulldown;
wt.draw = widget_pulldownbut;
@@ -4380,11 +4394,11 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
* because we need to pass in the original location so we know where to show the arrow.
*/
static void ui_draw_popover_back_impl(
- const uiWidgetColors *wcol, rcti *rect, int direction,
+ const uiWidgetColors *wcol, rcti *rect, int direction, const float unit_size,
const float mval_origin[2])
{
/* tsk, this isn't nice. */
- const float unit_half = (BLI_rcti_size_x(rect) / UI_POPOVER_WIDTH_UNITS) / 2;
+ const float unit_half = unit_size / 2;
const float cent_x = mval_origin ? mval_origin[0] : BLI_rcti_cent_x(rect);
rect->ymax -= unit_half;
rect->ymin += unit_half;
@@ -4406,11 +4420,11 @@ static void ui_draw_popover_back_impl(
/* Draw popover arrow (top/bottom) */
if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv((unsigned char *)wcol->inner);
GPU_blend(true);
- immBegin(GWN_PRIM_TRIS, 3);
+ immBegin(GPU_PRIM_TRIS, 3);
if (direction == UI_DIR_DOWN) {
const float y = rect->ymax;
immVertex2f(pos, cent_x - unit_half, y);
@@ -4437,7 +4451,7 @@ void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, r
if (block) {
float mval_origin[2] = {block->mx, block->my};
ui_window_to_block_fl(ar, block, &mval_origin[0], &mval_origin[1]);
- ui_draw_popover_back_impl(wt->wcol_theme, rect, block->direction, mval_origin);
+ ui_draw_popover_back_impl(wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin);
}
else {
wt->state(wt, 0);
@@ -4462,10 +4476,10 @@ static void draw_disk_shaded(
unsigned char r_col[4];
unsigned int pos, col;
- Gwn_VertFormat *format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (shaded) {
- col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
}
else {
@@ -4473,7 +4487,7 @@ static void draw_disk_shaded(
immUniformColor4ubv((unsigned char *)col1);
}
- immBegin(GWN_PRIM_TRI_STRIP, subd * 2);
+ immBegin(GPU_PRIM_TRI_STRIP, subd * 2);
for (i = 0; i < subd; i++) {
float a;
@@ -4518,8 +4532,8 @@ void ui_draw_pie_center(uiBlock *block)
float angle = atan2f(pie_dir[1], pie_dir[0]);
float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4;
- gpuPushMatrix();
- gpuTranslate2f(cx, cy);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(cx, cy);
GPU_blend(true);
if (btheme->tui.wcol_pie_menu.shaded) {
@@ -4542,8 +4556,8 @@ void ui_draw_pie_center(uiBlock *block)
}
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv((unsigned char *)btheme->tui.wcol_pie_menu.outline);
@@ -4565,7 +4579,7 @@ void ui_draw_pie_center(uiBlock *block)
}
GPU_blend(false);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
@@ -4586,6 +4600,7 @@ void ui_draw_widget_back_color(
if (use_shadow) {
GPU_blend(true);
+ GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit);
GPU_blend(false);
}
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index fb4d6e0ea14..47d664eaeb2 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -260,14 +260,6 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp = ts->panelcolors.back; break;
case TH_PANEL_SUB_BACK:
cp = ts->panelcolors.sub_back; break;
- case TH_PANEL_SHOW_HEADER:
- cp = &setting;
- setting = ts->panelcolors.show_header;
- break;
- case TH_PANEL_SHOW_BACK:
- cp = &setting;
- setting = ts->panelcolors.show_back;
- break;
case TH_BUTBACK:
cp = ts->button; break;
@@ -687,16 +679,16 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case TH_AXIS_Z:
cp = btheme->tui.zaxis; break;
- case TH_MANIPULATOR_HI:
- cp = btheme->tui.manipulator_hi; break;
- case TH_MANIPULATOR_PRIMARY:
- cp = btheme->tui.manipulator_primary; break;
- case TH_MANIPULATOR_SECONDARY:
- cp = btheme->tui.manipulator_secondary; break;
- case TH_MANIPULATOR_A:
- cp = btheme->tui.manipulator_a; break;
- case TH_MANIPULATOR_B:
- cp = btheme->tui.manipulator_b; break;
+ case TH_GIZMO_HI:
+ cp = btheme->tui.gizmo_hi; break;
+ case TH_GIZMO_PRIMARY:
+ cp = btheme->tui.gizmo_primary; break;
+ case TH_GIZMO_SECONDARY:
+ cp = btheme->tui.gizmo_secondary; break;
+ case TH_GIZMO_A:
+ cp = btheme->tui.gizmo_a; break;
+ case TH_GIZMO_B:
+ cp = btheme->tui.gizmo_b; break;
case TH_INFO_SELECTED:
cp = ts->info_selected;
@@ -755,7 +747,9 @@ void ui_theme_init_default(void)
UI_SetTheme(0, 0); /* make sure the global used in this file is set */
+ const int active_theme_area = btheme->active_theme_area;
memcpy(btheme, &U_theme_default, sizeof(*btheme));
+ btheme->active_theme_area = active_theme_area;
}
void ui_style_init_default(void)
@@ -1344,9 +1338,9 @@ void init_userdef_do_versions(Main *bmain)
U.savetime = 1;
// XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
}
- if (U.manipulator_size == 0) {
- U.manipulator_size = 75;
- U.manipulator_flag |= USER_MANIPULATOR_DRAW;
+ if (U.gizmo_size == 0) {
+ U.gizmo_size = 75;
+ U.gizmo_flag |= USER_GIZMO_DRAW;
}
if (U.pad_rot_angle == 0.0f)
U.pad_rot_angle = 15.0f;
@@ -1389,7 +1383,7 @@ void init_userdef_do_versions(Main *bmain)
if (U.rvisize == 0) {
U.rvisize = 15;
U.rvibright = 8;
- U.uiflag |= USER_SHOW_ROTVIEWICON;
+ U.uiflag |= USER_SHOW_GIZMO_AXIS;
}
}
@@ -1568,7 +1562,7 @@ void init_userdef_do_versions(Main *bmain)
if (!USER_VERSION_ATLEAST(278, 6)) {
/* Clear preference flags for re-use. */
U.flag &= ~(
- USER_FLAG_DEPRECATED_1 | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 |
+ USER_FLAG_NUMINPUT_ADVANCED | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 |
USER_FLAG_DEPRECATED_6 | USER_FLAG_DEPRECATED_7 |
USER_FLAG_DEPRECATED_9 | USER_DEVELOPER_UI);
U.uiflag &= ~(
@@ -1608,11 +1602,7 @@ void init_userdef_do_versions(Main *bmain)
/* Not versioning, just avoid errors. */
#ifndef WITH_CYCLES
- bAddon *addon = BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module));
- if (addon) {
- BLI_remlink(&U.addons, addon);
- BKE_addon_free(addon);
- }
+ BKE_addon_remove_safe(&U.addons, "cycles");
#endif
/* funny name, but it is GE stuff, moves userdef stuff to engine */
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index fc282e50ce2..3a527712367 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -153,11 +153,10 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
* - if they overlap, they must not occupy the corners (which are reserved for other widgets)
*/
if (scroll) {
- int scroll_width = (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) ? V2D_SCROLL_WIDTH_TEXT : v2d->size_vert;
- int scroll_height = (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) ? V2D_SCROLL_HEIGHT_TEXT : v2d->size_hor;
-
- CLAMP_MIN(scroll_width, V2D_SCROLL_WIDTH_MIN);
- CLAMP_MIN(scroll_height, V2D_SCROLL_HEIGHT_MIN);
+ const int scroll_width = (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) ?
+ V2D_SCROLL_WIDTH_TEXT : V2D_SCROLL_WIDTH;
+ const int scroll_height = (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) ?
+ V2D_SCROLL_HEIGHT_TEXT : V2D_SCROLL_HEIGHT;
/* vertical scroller */
if (scroll & V2D_SCROLL_LEFT) {
@@ -1152,7 +1151,7 @@ void UI_view2d_view_restore(const bContext *C)
int height = BLI_rcti_size_y(&ar->winrct) + 1;
wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
- gpuLoadIdentity();
+ GPU_matrix_identity_set();
// ED_region_pixelspace(CTX_wm_region(C));
}
@@ -1339,12 +1338,12 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
if (vertex_count == 0)
return;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, vertex_count);
+ immBegin(GPU_PRIM_LINES, vertex_count);
/* vertical lines */
if (flag & V2D_VERTICAL_LINES) {
@@ -1481,15 +1480,15 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
count_y = (v2d->cur.ymax - start_y) / step + 1;
if (count_x > 0 || count_y > 0) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
float theme_color[3];
UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, count_x * 2 + count_y * 2 + 4);
+ immBegin(GPU_PRIM_LINES, count_x * 2 + count_y * 2 + 4);
immAttrib3fv(color, theme_color);
for (int i = 0; i < count_x ; start_x += step, i++) {
@@ -1532,14 +1531,14 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
vertex_count += 2 * ((int)((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1);
vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
GPU_line_width(1.0f);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBeginAtMost(GWN_PRIM_LINES, vertex_count);
+ immBeginAtMost(GPU_PRIM_LINES, vertex_count);
for (int level = 0; level < totlevels; ++level) {
UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color);
diff --git a/source/blender/editors/lattice/lattice_ops.c b/source/blender/editors/lattice/lattice_ops.c
index 4f2e87c11c1..e7d9fc146ce 100644
--- a/source/blender/editors/lattice/lattice_ops.c
+++ b/source/blender/editors/lattice/lattice_ops.c
@@ -62,7 +62,9 @@ void ED_keymap_lattice(wmKeyConfig *keyconf)
keymap->poll = ED_operator_editlattice;
kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
WM_keymap_add_item(keymap, "LATTICE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
@@ -70,7 +72,7 @@ void ED_keymap_lattice(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "LATTICE_OT_flip", FKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "LATTICE_OT_flip", FKEY, KM_PRESS, KM_ALT, 0);
/* menus */
WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
deleted file mode 100644
index a5bcef7ed5e..00000000000
--- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
+++ /dev/null
@@ -1,498 +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) 2014 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file arrow3d_manipulator.c
- * \ingroup wm
- *
- * \name Arrow Manipulator
- *
- * 3D Manipulator
- *
- * \brief Simple arrow manipulator which is dragged into a certain direction.
- * The arrow head can have varying shapes, e.g. cone, box, etc.
- *
- * - `matrix[0]` is derived from Y and Z.
- * - `matrix[1]` is 'up' for manipulator types that have an up.
- * - `matrix[2]` is the arrow direction (for all arrowes).
- */
-
-#include "BIF_gl.h"
-
-#include "BLI_math.h"
-
-#include "DNA_view3d_types.h"
-
-#include "BKE_context.h"
-
-#include "GPU_draw.h"
-#include "GPU_immediate.h"
-#include "GPU_immediate_util.h"
-#include "GPU_matrix.h"
-#include "GPU_select.h"
-#include "GPU_state.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "WM_types.h"
-#include "WM_api.h"
-
-#include "ED_view3d.h"
-#include "ED_screen.h"
-#include "ED_manipulator_library.h"
-
-/* own includes */
-#include "../manipulator_geometry.h"
-#include "../manipulator_library_intern.h"
-
-/* to use custom arrows exported to geom_arrow_manipulator.c */
-//#define USE_MANIPULATOR_CUSTOM_ARROWS
-
-typedef struct ArrowManipulator3D {
- wmManipulator manipulator;
- ManipulatorCommonData data;
-} ArrowManipulator3D;
-
-
-/* -------------------------------------------------------------------- */
-
-static void manipulator_arrow_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4])
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
-
- copy_m4_m4(r_matrix, arrow->manipulator.matrix_basis);
- madd_v3_v3fl(r_matrix[3], arrow->manipulator.matrix_basis[2], arrow->data.offset);
-}
-
-static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float color[4])
-{
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- bool unbind_shader = true;
- const int draw_style = RNA_enum_get(arrow->manipulator.ptr, "draw_style");
- const int draw_options = RNA_enum_get(arrow->manipulator.ptr, "draw_options");
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CROSS) {
- immUniformColor4fv(color);
-
- immBegin(GWN_PRIM_LINES, 4);
- immVertex3f(pos, -1.0f, 0.0f, 0.0f);
- immVertex3f(pos, 1.0f, 0.0f, 0.0f);
- immVertex3f(pos, 0.0f, -1.0f, 0.0f);
- immVertex3f(pos, 0.0f, 1.0f, 0.0f);
- immEnd();
- }
- else if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CONE) {
- float aspect[2];
- RNA_float_get_array(arrow->manipulator.ptr, "aspect", aspect);
- const float unitx = aspect[0];
- const float unity = aspect[1];
- const float vec[4][3] = {
- {-unitx, -unity, 0},
- { unitx, -unity, 0},
- { unitx, unity, 0},
- {-unitx, unity, 0},
- };
-
- GPU_line_width(arrow->manipulator.line_width);
- wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP);
- }
- else {
-#ifdef USE_MANIPULATOR_CUSTOM_ARROWS
- wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_arrow, select, color);
-#else
- const float arrow_length = RNA_float_get(arrow->manipulator.ptr, "length");
-
- const float vec[2][3] = {
- {0.0f, 0.0f, 0.0f},
- {0.0f, 0.0f, arrow_length},
- };
-
- if (draw_options & ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM) {
- GPU_line_width(arrow->manipulator.line_width);
- wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP);
- }
- else {
- immUniformColor4fv(color);
- }
-
- /* *** draw arrow head *** */
-
- gpuPushMatrix();
-
- if (draw_style == ED_MANIPULATOR_ARROW_STYLE_BOX) {
- const float size = 0.05f;
-
- /* translate to line end with some extra offset so box starts exactly where line ends */
- gpuTranslate3f(0.0f, 0.0f, arrow_length + size);
- /* scale down to box size */
- gpuScale3f(size, size, size);
-
- /* draw cube */
- immUnbindProgram();
- unbind_shader = false;
- wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_cube, select, color);
- }
- else {
- BLI_assert(draw_style == ED_MANIPULATOR_ARROW_STYLE_NORMAL);
-
- const float len = 0.25f;
- const float width = 0.06f;
- const bool use_lighting = (!select && ((U.manipulator_flag & USER_MANIPULATOR_SHADED) != 0));
-
- /* translate to line end */
- gpuTranslate3f(0.0f, 0.0f, arrow_length);
-
- if (use_lighting) {
- immUnbindProgram();
- immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
- }
-
- imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8);
- imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1);
- }
-
- gpuPopMatrix();
-#endif /* USE_MANIPULATOR_CUSTOM_ARROWS */
- }
-
- if (unbind_shader) {
- immUnbindProgram();
- }
-}
-
-static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, const bool highlight)
-{
- wmManipulator *mpr = &arrow->manipulator;
- float color[4];
- float matrix_final[4][4];
-
- manipulator_color_get(mpr, highlight, color);
-
- WM_manipulator_calc_matrix_final(mpr, matrix_final);
-
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
- GPU_blend(true);
- arrow_draw_geom(arrow, select, color);
- GPU_blend(false);
-
- gpuPopMatrix();
-
- if (mpr->interaction_data) {
- ManipulatorInteraction *inter = mpr->interaction_data;
-
- gpuPushMatrix();
- gpuMultMatrix(inter->init_matrix_final);
-
-
- GPU_blend(true);
- arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
- GPU_blend(false);
-
- gpuPopMatrix();
- }
-}
-
-static void manipulator_arrow_draw_select(
- const bContext *UNUSED(C), wmManipulator *mpr,
- int select_id)
-{
- GPU_select_load_id(select_id);
- arrow_draw_intern((ArrowManipulator3D *)mpr, true, false);
-}
-
-static void manipulator_arrow_draw(const bContext *UNUSED(C), wmManipulator *mpr)
-{
- arrow_draw_intern((ArrowManipulator3D *)mpr, false, (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0);
-}
-
-/**
- * Calculate arrow offset independent from prop min value,
- * meaning the range will not be offset by min value first.
- */
-static int manipulator_arrow_modal(
- bContext *C, wmManipulator *mpr, const wmEvent *event,
- eWM_ManipulatorTweak tweak_flag)
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
- ManipulatorInteraction *inter = mpr->interaction_data;
- View3D *v3d = CTX_wm_view3d(C);
- ARegion *ar = CTX_wm_region(C);
- RegionView3D *rv3d = ar->regiondata;
-
- float offset[3];
- float facdir = 1.0f;
-
- /* (src, dst) */
- struct {
- float mval[2];
- float ray_origin[3], ray_direction[3];
- float location[3];
- } proj[2] = {
- {.mval = {UNPACK2(inter->init_mval)}},
- {.mval = {UNPACK2(event->mval)}},
- };
-
- float arrow_co[3];
- float arrow_no[3];
- copy_v3_v3(arrow_co, inter->init_matrix_basis[3]);
- normalize_v3_v3(arrow_no, arrow->manipulator.matrix_basis[2]);
-
- int ok = 0;
-
- for (int j = 0; j < 2; j++) {
- if (ED_view3d_win_to_ray(
- CTX_data_depsgraph(C),
- ar, v3d, proj[j].mval,
- proj[j].ray_origin, proj[j].ray_direction, false))
- {
- /* Force Y axis if we're view aligned */
- if (j == 0) {
- if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->manipulator.matrix_basis[2]))) < 5.0f) {
- normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
- }
- }
-
- float arrow_no_proj[3];
- project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
-
- normalize_v3(arrow_no_proj);
-
- float plane[4];
- plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj);
-
- float lambda;
- if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) {
- madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
- ok++;
- }
- }
- }
-
- if (ok != 2) {
- return OPERATOR_RUNNING_MODAL;
- }
-
- sub_v3_v3v3(offset, proj[1].location, proj[0].location);
- facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1;
-
- ManipulatorCommonData *data = &arrow->data;
- const float ofs_new = facdir * len_v3(offset);
-
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
-
- /* set the property for the operator and call its modal function */
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- const int transform_flag = RNA_enum_get(arrow->manipulator.ptr, "transform");
- const bool constrained = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
- const bool inverted = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED) != 0;
- const bool use_precision = (tweak_flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0;
- float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision);
-
- WM_manipulator_target_property_value_set(C, mpr, mpr_prop, value);
- /* get clamped value */
- value = WM_manipulator_target_property_value_get(mpr, mpr_prop);
-
- data->offset = manipulator_offset_from_value(data, value, constrained, inverted);
- }
- else {
- data->offset = ofs_new;
- }
-
- /* tag the region for redraw */
- ED_region_tag_redraw(ar);
- WM_event_add_mousemove(C);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static void manipulator_arrow_setup(wmManipulator *mpr)
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
-
- arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_MODAL;
-
- arrow->data.range_fac = 1.0f;
-}
-
-static int manipulator_arrow_invoke(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
- ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
-
- /* Some manipulators don't use properties. */
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- inter->init_value = WM_manipulator_target_property_value_get(mpr, mpr_prop);
- }
-
- inter->init_offset = arrow->data.offset;
-
- inter->init_mval[0] = event->mval[0];
- inter->init_mval[1] = event->mval[1];
-
- manipulator_arrow_matrix_basis_get(mpr, inter->init_matrix_basis);
- WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
-
- mpr->interaction_data = inter;
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
- const int transform_flag = RNA_enum_get(arrow->manipulator.ptr, "transform");
- const bool constrained = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
- const bool inverted = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED) != 0;
- manipulator_property_data_update(mpr, &arrow->data, mpr_prop, constrained, inverted);
-}
-
-static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool cancel)
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
- ManipulatorCommonData *data = &arrow->data;
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
- const bool is_prop_valid = WM_manipulator_target_property_is_valid(mpr_prop);
-
- if (!cancel) {
- /* Assign incase applying the opetration needs an updated offset
- * editmesh bisect needs this. */
- if (is_prop_valid) {
- data->offset = WM_manipulator_target_property_value_get(mpr, mpr_prop);
- }
- return;
- }
-
- ManipulatorInteraction *inter = mpr->interaction_data;
- if (is_prop_valid) {
- manipulator_property_value_reset(C, mpr, inter, mpr_prop);
- }
- data->offset = inter->init_offset;
-}
-
-
-/* -------------------------------------------------------------------- */
-/** \name Arrow Manipulator API
- *
- * \{ */
-
-/**
- * Define a custom property UI range
- *
- * \note Needs to be called before WM_manipulator_target_property_def_rna!
- */
-void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, const float max)
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
-
- BLI_assert(min < max);
- BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr, "offset")) &&
- "Make sure this function is called before WM_manipulator_target_property_def_rna"));
-
- arrow->data.range = max - min;
- arrow->data.min = min;
- arrow->data.flag |= MANIPULATOR_CUSTOM_RANGE_SET;
-}
-
-/**
- * Define a custom factor for arrow min/max distance
- *
- * \note Needs to be called before WM_manipulator_target_property_def_rna!
- */
-void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac)
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
- BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr, "offset")) &&
- "Make sure this function is called before WM_manipulator_target_property_def_rna"));
-
- arrow->data.range_fac = range_fac;
-}
-
-static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt)
-{
- /* identifiers */
- wt->idname = "MANIPULATOR_WT_arrow_3d";
-
- /* api callbacks */
- wt->draw = manipulator_arrow_draw;
- wt->draw_select = manipulator_arrow_draw_select;
- wt->matrix_basis_get = manipulator_arrow_matrix_basis_get;
- wt->modal = manipulator_arrow_modal;
- wt->setup = manipulator_arrow_setup;
- wt->invoke = manipulator_arrow_invoke;
- wt->property_update = manipulator_arrow_property_update;
- wt->exit = manipulator_arrow_exit;
-
- wt->struct_size = sizeof(ArrowManipulator3D);
-
- /* rna */
- static EnumPropertyItem rna_enum_draw_style_items[] = {
- {ED_MANIPULATOR_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
- {ED_MANIPULATOR_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""},
- {ED_MANIPULATOR_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
- {ED_MANIPULATOR_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
- {0, NULL, 0, NULL, NULL}
- };
- static EnumPropertyItem rna_enum_draw_options_items[] = {
- {ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
- {0, NULL, 0, NULL, NULL}
- };
- static EnumPropertyItem rna_enum_transform_items[] = {
- {ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
- {ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- RNA_def_enum(
- wt->srna, "draw_style", rna_enum_draw_style_items,
- ED_MANIPULATOR_ARROW_STYLE_NORMAL,
- "Draw Style", "");
- RNA_def_enum_flag(
- wt->srna, "draw_options", rna_enum_draw_options_items,
- ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM,
- "Draw Options", "");
- RNA_def_enum_flag(
- wt->srna, "transform", rna_enum_transform_items,
- 0,
- "Transform", "");
-
- RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX);
- RNA_def_float_vector(wt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);
-
- WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1);
-}
-
-void ED_manipulatortypes_arrow_3d(void)
-{
- WM_manipulatortype_append(MANIPULATOR_WT_arrow_3d);
-}
-
-/** \} */
diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
deleted file mode 100644
index 458dc2fd1c8..00000000000
--- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
+++ /dev/null
@@ -1,375 +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 grab3d_manipulator.c
- * \ingroup wm
- *
- * \name Grab Manipulator
- *
- * 3D Manipulator, also works in 2D views.
- *
- * \brief Simple manipulator to grab and translate.
- *
- * - `matrix[0]` is derived from Y and Z.
- * - `matrix[1]` currently not used.
- * - `matrix[2]` is the widget direction (for all manipulators).
- *
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-
-#include "BKE_context.h"
-
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
-#include "GPU_immediate.h"
-#include "GPU_immediate_util.h"
-#include "GPU_matrix.h"
-#include "GPU_select.h"
-#include "GPU_state.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_screen.h"
-#include "ED_view3d.h"
-#include "ED_manipulator_library.h"
-
-/* own includes */
-#include "../manipulator_geometry.h"
-#include "../manipulator_library_intern.h"
-
-typedef struct GrabManipulator3D {
- wmManipulator manipulator;
- /* Added to 'matrix_basis' when calculating the matrix. */
- float prop_co[3];
-} GrabManipulator3D;
-
-static void manipulator_grab_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4])
-{
- GrabManipulator3D *grab = (GrabManipulator3D *)mpr;
-
- copy_m4_m4(r_matrix, grab->manipulator.matrix_basis);
- add_v3_v3(r_matrix[3], grab->prop_co);
-}
-
-static int manipulator_grab_modal(
- bContext *C, wmManipulator *mpr, const wmEvent *event,
- eWM_ManipulatorTweak tweak_flag);
-
-typedef struct GrabInteraction {
- float init_mval[2];
-
- /* only for when using properties */
- float init_prop_co[3];
-
- float init_matrix_final[4][4];
-} GrabInteraction;
-
-#define DIAL_RESOLUTION 32
-
-/* -------------------------------------------------------------------- */
-
-static void grab_geom_draw(
- const wmManipulator *mpr, const float color[4], const bool select, const int draw_options)
-{
-#ifdef USE_MANIPULATOR_CUSTOM_DIAL
- UNUSED_VARS(grab3d, col, axis_modal_mat);
- wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_grab3d, select);
-#else
- const int draw_style = RNA_enum_get(mpr->ptr, "draw_style");
- const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0;
-
- GPU_line_width(mpr->line_width);
-
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- immUniformColor4fv(color);
-
- if (draw_style == ED_MANIPULATOR_GRAB_STYLE_RING_2D) {
- if (filled) {
- imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION);
- }
- else {
- imm_draw_circle_wire_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION);
- }
- }
- else if (draw_style == ED_MANIPULATOR_GRAB_STYLE_CROSS_2D) {
- immBegin(GWN_PRIM_LINES, 4);
- immVertex2f(pos, 1.0f, 1.0f);
- immVertex2f(pos, -1.0f, -1.0f);
-
- immVertex2f(pos, -1.0f, 1.0f);
- immVertex2f(pos, 1.0f, -1.0f);
- immEnd();
- }
- else {
- BLI_assert(0);
- }
-
- immUnbindProgram();
-
- UNUSED_VARS(select);
-#endif
-}
-
-static void grab3d_get_translate(
- const wmManipulator *mpr, const wmEvent *event, const ARegion *ar,
- float co_delta[3])
-{
- GrabInteraction *inter = mpr->interaction_data;
- const float mval_delta[2] = {
- event->mval[0] - inter->init_mval[0],
- event->mval[1] - inter->init_mval[1],
- };
-
- RegionView3D *rv3d = ar->regiondata;
- float co_ref[3];
- mul_v3_mat3_m4v3(co_ref, mpr->matrix_space, inter->init_prop_co);
- const float zfac = ED_view3d_calc_zfac(rv3d, co_ref, NULL);
-
- ED_view3d_win_to_delta(ar, mval_delta, co_delta, zfac);
-
- float matrix_space_inv[3][3];
- copy_m3_m4(matrix_space_inv, mpr->matrix_space);
- invert_m3(matrix_space_inv);
- mul_m3_v3(matrix_space_inv, co_delta);
-}
-
-static void grab3d_draw_intern(
- const bContext *C, wmManipulator *mpr,
- const bool select, const bool highlight)
-{
- GrabInteraction *inter = mpr->interaction_data;
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
- const bool align_view = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0;
- float color[4];
- float matrix_final[4][4];
- float matrix_align[4][4];
-
- manipulator_color_get(mpr, highlight, color);
- WM_manipulator_calc_matrix_final(mpr, matrix_final);
-
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
-
- if (align_view) {
- float matrix_final_unit[4][4];
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- normalize_m4_m4(matrix_final_unit, matrix_final);
- mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit);
- zero_v3(matrix_align[3]);
- transpose_m4(matrix_align);
- gpuMultMatrix(matrix_align);
- }
-
- GPU_blend(true);
- grab_geom_draw(mpr, color, select, draw_options);
- GPU_blend(false);
- gpuPopMatrix();
-
- if (mpr->interaction_data) {
- gpuPushMatrix();
- gpuMultMatrix(inter->init_matrix_final);
-
- if (align_view) {
- gpuMultMatrix(matrix_align);
- }
-
- GPU_blend(true);
- grab_geom_draw(mpr, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options);
- GPU_blend(false);
- gpuPopMatrix();
- }
-}
-
-static void manipulator_grab_draw_select(const bContext *C, wmManipulator *mpr, int select_id)
-{
- GPU_select_load_id(select_id);
- grab3d_draw_intern(C, mpr, true, false);
-}
-
-static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr)
-{
- const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL;
- const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
-
- (void)is_modal;
-
- GPU_blend(true);
- grab3d_draw_intern(C, mpr, false, is_highlight);
- GPU_blend(false);
-}
-
-static int manipulator_grab_modal(
- bContext *C, wmManipulator *mpr, const wmEvent *event,
- eWM_ManipulatorTweak UNUSED(tweak_flag))
-{
- GrabManipulator3D *grab = (GrabManipulator3D *)mpr;
- GrabInteraction *inter = mpr->interaction_data;
- ARegion *ar = CTX_wm_region(C);
-
- float prop_delta[3];
- if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) {
- grab3d_get_translate(mpr, event, ar, prop_delta);
- }
- else {
- float mval_proj_init[2], mval_proj_curr[2];
- if ((manipulator_window_project_2d(
- C, mpr, inter->init_mval, 2, false, mval_proj_init) == false) ||
- (manipulator_window_project_2d(
- C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false))
- {
- return OPERATOR_RUNNING_MODAL;
- }
- sub_v2_v2v2(prop_delta, mval_proj_curr, mval_proj_init);
- prop_delta[2] = 0.0f;
- }
- add_v3_v3v3(grab->prop_co, inter->init_prop_co, prop_delta);
-
- /* set the property for the operator and call its modal function */
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, grab->prop_co);
- }
- else {
- zero_v3(grab->prop_co);
- }
-
- ED_region_tag_redraw(ar);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static int manipulator_grab_invoke(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
-{
- GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__);
-
- inter->init_mval[0] = event->mval[0];
- inter->init_mval[1] = event->mval[1];
-
-#if 0
- copy_v3_v3(inter->init_prop_co, grab->prop_co);
-#else
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- WM_manipulator_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co);
- }
-#endif
-
- WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
-
- mpr->interaction_data = inter;
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-
-static int manipulator_grab_test_select(
- bContext *C, wmManipulator *mpr, const wmEvent *event)
-{
- float point_local[2];
-
- if (manipulator_window_project_2d(
- C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
- {
- return -1;
- }
-
- /* The 'mpr->scale_final' is already applied when projecting. */
- if (len_squared_v2(point_local) < 1.0f) {
- return 0;
- }
-
- return -1;
-}
-
-static void manipulator_grab_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
-{
- GrabManipulator3D *grab = (GrabManipulator3D *)mpr;
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- WM_manipulator_target_property_value_get_array(mpr, mpr_prop, grab->prop_co);
- }
- else {
- zero_v3(grab->prop_co);
- }
-}
-
-static int manipulator_grab_cursor_get(wmManipulator *UNUSED(mpr))
-{
- return BC_NSEW_SCROLLCURSOR;
-}
-
-/* -------------------------------------------------------------------- */
-/** \name Grab Manipulator API
- *
- * \{ */
-
-static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt)
-{
- /* identifiers */
- wt->idname = "MANIPULATOR_WT_grab_3d";
-
- /* api callbacks */
- wt->draw = manipulator_grab_draw;
- wt->draw_select = manipulator_grab_draw_select;
- wt->test_select = manipulator_grab_test_select;
- wt->matrix_basis_get = manipulator_grab_matrix_basis_get;
- wt->invoke = manipulator_grab_invoke;
- wt->property_update = manipulator_grab_property_update;
- wt->modal = manipulator_grab_modal;
- wt->cursor_get = manipulator_grab_cursor_get;
-
- wt->struct_size = sizeof(GrabManipulator3D);
-
- /* rna */
- static EnumPropertyItem rna_enum_draw_style[] = {
- {ED_MANIPULATOR_GRAB_STYLE_RING_2D, "RING_2D", 0, "Ring", ""},
- {ED_MANIPULATOR_GRAB_STYLE_CROSS_2D, "CROSS_2D", 0, "Ring", ""},
- {0, NULL, 0, NULL, NULL}
- };
- static EnumPropertyItem rna_enum_draw_options[] = {
- {ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
- {ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_GRAB_STYLE_RING_2D, "Draw Style", "");
- RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
-
- WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 3);
-}
-
-void ED_manipulatortypes_grab_3d(void)
-{
- WM_manipulatortype_append(MANIPULATOR_WT_grab_3d);
-}
-
-/** \} */ // Grab Manipulator API
diff --git a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
deleted file mode 100644
index 419873ccfff..00000000000
--- a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
+++ /dev/null
@@ -1,191 +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 primitive3d_manipulator.c
- * \ingroup wm
- *
- * \name Primitive Manipulator
- *
- * 3D Manipulator
- *
- * \brief Manipulator with primitive drawing type (plane, cube, etc.).
- * Currently only plane primitive supported without own handling, use with operator only.
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-
-#include "DNA_view3d_types.h"
-
-#include "BKE_context.h"
-
-#include "BIF_gl.h"
-
-#include "GPU_immediate.h"
-#include "GPU_matrix.h"
-#include "GPU_select.h"
-#include "GPU_state.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_manipulator_library.h"
-
-/* own includes */
-#include "../manipulator_library_intern.h"
-
-static float verts_plane[4][3] = {
- {-1, -1, 0},
- { 1, -1, 0},
- { 1, 1, 0},
- {-1, 1, 0},
-};
-
-
-/* -------------------------------------------------------------------- */
-
-static void manipulator_primitive_draw_geom(
- const float col_inner[4], const float col_outer[4], const int draw_style)
-{
- float (*verts)[3];
- uint vert_count = 0;
-
- if (draw_style == ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE) {
- verts = verts_plane;
- vert_count = ARRAY_SIZE(verts_plane);
- }
-
- if (vert_count > 0) {
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, GWN_PRIM_TRI_FAN);
- wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, GWN_PRIM_LINE_LOOP);
- immUnbindProgram();
- }
-}
-
-static void manipulator_primitive_draw_intern(
- wmManipulator *mpr, const bool UNUSED(select),
- const bool highlight)
-{
- float color_inner[4], color_outer[4];
- float matrix_final[4][4];
- const int draw_style = RNA_enum_get(mpr->ptr, "draw_style");
-
- manipulator_color_get(mpr, highlight, color_outer);
- copy_v4_v4(color_inner, color_outer);
- color_inner[3] *= 0.5f;
-
- WM_manipulator_calc_matrix_final(mpr, matrix_final);
-
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
-
- GPU_blend(true);
- manipulator_primitive_draw_geom(color_inner, color_outer, draw_style);
- GPU_blend(false);
-
- gpuPopMatrix();
-
- if (mpr->interaction_data) {
- ManipulatorInteraction *inter = mpr->interaction_data;
-
- copy_v4_fl(color_inner, 0.5f);
- copy_v3_fl(color_outer, 0.5f);
- color_outer[3] = 0.8f;
-
- gpuPushMatrix();
- gpuMultMatrix(inter->init_matrix_final);
-
- GPU_blend(true);
- manipulator_primitive_draw_geom(color_inner, color_outer, draw_style);
- GPU_blend(false);
-
- gpuPopMatrix();
- }
-}
-
-static void manipulator_primitive_draw_select(
- const bContext *UNUSED(C), wmManipulator *mpr,
- int select_id)
-{
- GPU_select_load_id(select_id);
- manipulator_primitive_draw_intern(mpr, true, false);
-}
-
-static void manipulator_primitive_draw(const bContext *UNUSED(C), wmManipulator *mpr)
-{
- manipulator_primitive_draw_intern(
- mpr, false,
- (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT));
-}
-
-static void manipulator_primitive_setup(wmManipulator *mpr)
-{
- mpr->flag |= WM_MANIPULATOR_DRAW_MODAL;
-}
-
-static int manipulator_primitive_invoke(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event))
-{
- ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
-
- WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
-
- mpr->interaction_data = inter;
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-/* -------------------------------------------------------------------- */
-/** \name Primitive Manipulator API
- *
- * \{ */
-
-static void MANIPULATOR_WT_primitive_3d(wmManipulatorType *wt)
-{
- /* identifiers */
- wt->idname = "MANIPULATOR_WT_primitive_3d";
-
- /* api callbacks */
- wt->draw = manipulator_primitive_draw;
- wt->draw_select = manipulator_primitive_draw_select;
- wt->setup = manipulator_primitive_setup;
- wt->invoke = manipulator_primitive_invoke;
-
- wt->struct_size = sizeof(wmManipulator);
-
- static EnumPropertyItem rna_enum_draw_style[] = {
- {ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""},
- {0, NULL, 0, NULL, NULL}
- };
- RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "Draw Style", "");
-}
-
-void ED_manipulatortypes_primitive_3d(void)
-{
- WM_manipulatortype_append(MANIPULATOR_WT_primitive_3d);
-}
-
-/** \} */
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 6b5fce26deb..506dec2aa3e 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -124,8 +124,8 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
return;
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -134,7 +134,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
/* this could be split into its own loop */
if (draw_type == MASK_DT_OUTLINE) {
GPU_line_width(3.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(pos, point_pos);
immVertex2fv(pos, handle_pos);
immEnd();
@@ -154,7 +154,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
}
GPU_line_width(1.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(pos, point_pos);
immVertex2fv(pos, handle_pos);
immEnd();
@@ -178,7 +178,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
immUniform4fv("outlineColor", point_color);
immUniformColor3fvAlpha(point_color, 0.25f);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2fv(pos, handle_pos);
immEnd();
@@ -212,8 +212,8 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
mask_spline_color_get(masklay, spline, is_spline_sel, rgb_spline);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
immUniform1f("size", 0.7f * handle_size);
@@ -251,7 +251,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
immUniformThemeColor(TH_HANDLE_VERTEX);
}
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2fv(pos, feather_point);
immEnd();
@@ -320,7 +320,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
else
immUniformThemeColor(TH_HANDLE_VERTEX);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2fv(pos, vert);
immEnd();
@@ -350,7 +350,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f);
immUniform1f("size", 12.0f);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2f(pos, x, y);
immEnd();
@@ -371,10 +371,10 @@ static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char r
}
}
-static void mask_draw_array(unsigned int pos, Gwn_PrimType prim_type, const float (*points)[2], unsigned int vertex_ct)
+static void mask_draw_array(unsigned int pos, GPUPrimType prim_type, const float (*points)[2], unsigned int vertex_len)
{
- immBegin(prim_type, vertex_ct);
- for (unsigned int i = 0; i < vertex_ct; ++i) {
+ immBegin(prim_type, vertex_len);
+ for (unsigned int i = 0; i < vertex_len; ++i) {
immVertex2fv(pos, points[i]);
}
immEnd();
@@ -384,7 +384,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
const bool is_feather, const bool is_active,
const unsigned char rgb_spline[4], const char draw_type)
{
- const Gwn_PrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GWN_PRIM_LINE_LOOP : GWN_PRIM_LINE_STRIP;
+ const GPUPrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GPU_PRIM_LINE_LOOP : GPU_PRIM_LINE_STRIP;
const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
unsigned char rgb_tmp[4];
SpaceClip *sc = CTX_wm_space_clip(C);
@@ -402,8 +402,8 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
}
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
switch (draw_type) {
@@ -695,17 +695,17 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO);
}
- gpuPushMatrix();
- gpuTranslate2f(x, y);
- gpuScale2f(zoomx, zoomy);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_scale_2f(zoomx, zoomy);
if (stabmat) {
- gpuMultMatrix(stabmat);
+ GPU_matrix_mul(stabmat);
}
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red);
immDrawPixelsTex(&state, 0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL);
- gpuPopMatrix();
+ GPU_matrix_pop();
if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
GPU_blend(false);
@@ -715,13 +715,13 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
}
/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
- gpuPushMatrix();
- gpuTranslate2f(x + xofs, y + yofs);
- gpuScale2f(zoomx, zoomy);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(x + xofs, y + yofs);
+ GPU_matrix_scale_2f(zoomx, zoomy);
if (stabmat) {
- gpuMultMatrix(stabmat);
+ GPU_matrix_mul(stabmat);
}
- gpuScale2f(maxdim, maxdim);
+ GPU_matrix_scale_2f(maxdim, maxdim);
if (do_draw_cb) {
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -734,7 +734,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra, const int efra)
@@ -747,12 +747,12 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra
unsigned int num_lines = BLI_listbase_count(&masklay->splines_shapes);
if (num_lines > 0) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(255, 175, 0, 255);
- immBegin(GWN_PRIM_LINES, 2 * num_lines);
+ immBegin(GPU_PRIM_LINES, 2 * num_lines);
for (MaskLayerShape *masklay_shape = masklay->splines_shapes.first;
masklay_shape;
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 85f5836ecd7..7d5fc5126ef 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -555,7 +555,9 @@ void ED_keymap_mask(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "toggle", true);
kmi = WM_keymap_add_item(keymap, "MASK_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "MASK_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "MASK_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index 5cd768b4fe3..81ec591fc89 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -44,7 +44,7 @@ set(INC_SYS
set(SRC
editface.c
editmesh_add.c
- editmesh_add_manipulator.c
+ editmesh_add_gizmo.c
editmesh_bevel.c
editmesh_bisect.c
editmesh_extrude.c
diff --git a/source/blender/editors/mesh/editmesh_add_manipulator.c b/source/blender/editors/mesh/editmesh_add_gizmo.c
index bfeccfe33a4..6fa0eb33b89 100644
--- a/source/blender/editors/mesh/editmesh_add_manipulator.c
+++ b/source/blender/editors/mesh/editmesh_add_gizmo.c
@@ -18,10 +18,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/mesh/editmesh_add_manipulator.c
+/** \file blender/editors/mesh/editmesh_add_gizmo.c
* \ingroup edmesh
*
- * Creation manipulators.
+ * Creation gizmos.
*/
#include "MEM_guardedalloc.h"
@@ -34,7 +34,7 @@
#include "BKE_context.h"
#include "BKE_editmesh.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_screen.h"
@@ -123,24 +123,24 @@ static void calc_initial_placement_point_from_view(
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Placement Manipulator
+/** \name Placement Gizmo
* \{ */
-typedef struct ManipulatorPlacementGroup {
- struct wmManipulator *cage;
+typedef struct GizmoPlacementGroup {
+ struct wmGizmo *cage;
struct {
bContext *context;
wmOperator *op;
PropertyRNA *prop_matrix;
} data;
-} ManipulatorPlacementGroup;
+} GizmoPlacementGroup;
/**
* \warning Calling redo from property updates is not great.
* This is needed because changing the RNA doesn't cause a redo
* and we're not using operator UI which does just this.
*/
-static void manipulator_placement_exec(ManipulatorPlacementGroup *man)
+static void gizmo_placement_exec(GizmoPlacementGroup *man)
{
wmOperator *op = man->data.op;
if (op == WM_operator_last_redo((bContext *)man->data.context)) {
@@ -148,7 +148,7 @@ static void manipulator_placement_exec(ManipulatorPlacementGroup *man)
}
}
-static void manipulator_mesh_placement_update_from_op(ManipulatorPlacementGroup *man)
+static void gizmo_mesh_placement_update_from_op(GizmoPlacementGroup *man)
{
wmOperator *op = man->data.op;
UNUSED_VARS(op);
@@ -159,15 +159,15 @@ static void manipulator_mesh_placement_update_from_op(ManipulatorPlacementGroup
}
/* translate callbacks */
-static void manipulator_placement_prop_matrix_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_placement_prop_matrix_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
- ManipulatorPlacementGroup *man = mpr->parent_mgroup->customdata;
+ GizmoPlacementGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 16);
+ UNUSED_VARS_NDEBUG(gz_prop);
if (value_p != man->cage->matrix_offset) {
mul_m4_m4m4(value_p, man->cage->matrix_basis, man->cage->matrix_offset);
@@ -175,15 +175,15 @@ static void manipulator_placement_prop_matrix_get(
}
}
-static void manipulator_placement_prop_matrix_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_placement_prop_matrix_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value)
{
- ManipulatorPlacementGroup *man = mpr->parent_mgroup->customdata;
+ GizmoPlacementGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
- BLI_assert(mpr_prop->type->array_length == 16);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 16);
+ UNUSED_VARS_NDEBUG(gz_prop);
float mat[4][4];
mul_m4_m4m4(mat, man->cage->matrix_basis, value);
@@ -194,41 +194,41 @@ static void manipulator_placement_prop_matrix_set(
RNA_property_float_set_array(op->ptr, man->data.prop_matrix, &mat[0][0]);
- manipulator_placement_exec(man);
+ gizmo_placement_exec(man);
}
-static bool manipulator_mesh_placement_poll(const bContext *C, wmManipulatorGroupType *wgt)
+static bool gizmo_mesh_placement_poll(const bContext *C, wmGizmoGroupType *gzgt)
{
wmOperator *op = WM_operator_last_redo(C);
- if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_manipulator")) {
- WM_manipulator_group_type_unlink_delayed_ptr(wgt);
+ if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_gizmo")) {
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
return false;
}
return true;
}
-static void manipulator_mesh_placement_modal_from_setup(
- const bContext *C, wmManipulatorGroup *mgroup)
+static void gizmo_mesh_placement_modal_from_setup(
+ const bContext *C, wmGizmoGroup *gzgroup)
{
- ManipulatorPlacementGroup *man = mgroup->customdata;
+ GizmoPlacementGroup *man = gzgroup->customdata;
/* Initial size. */
{
- wmManipulator *mpr = man->cage;
- zero_m4(mpr->matrix_offset);
-
- /* TODO: support zero scaled matrix in 'MANIPULATOR_WT_cage_3d'. */
- mpr->matrix_offset[0][0] = 0.01;
- mpr->matrix_offset[1][1] = 0.01;
- mpr->matrix_offset[2][2] = 0.01;
- mpr->matrix_offset[3][3] = 1.0f;
+ wmGizmo *gz = man->cage;
+ zero_m4(gz->matrix_offset);
+
+ /* TODO: support zero scaled matrix in 'GIZMO_GT_cage_3d'. */
+ gz->matrix_offset[0][0] = 0.01;
+ gz->matrix_offset[1][1] = 0.01;
+ gz->matrix_offset[2][2] = 0.01;
+ gz->matrix_offset[3][3] = 1.0f;
}
/* Start off dragging. */
{
wmWindow *win = CTX_wm_window(C);
ARegion *ar = CTX_wm_region(C);
- wmManipulator *mpr = man->cage;
+ wmGizmo *gz = man->cage;
{
float mat3[3][3];
@@ -239,92 +239,92 @@ static void manipulator_mesh_placement_modal_from_setup(
win->eventstate->y - ar->winrct.ymin,
},
location, mat3);
- copy_m4_m3(mpr->matrix_basis, mat3);
- copy_v3_v3(mpr->matrix_basis[3], location);
+ copy_m4_m3(gz->matrix_basis, mat3);
+ copy_v3_v3(gz->matrix_basis[3], location);
}
if (1) {
- wmManipulatorMap *mmap = mgroup->parent_mmap;
- WM_manipulator_modal_set_from_setup(
- mmap, (bContext *)C, man->cage, ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, win->eventstate);
+ wmGizmoMap *gzmap = gzgroup->parent_gzmap;
+ WM_gizmo_modal_set_from_setup(
+ gzmap, (bContext *)C, man->cage, ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, win->eventstate);
}
}
}
-static void manipulator_mesh_placement_setup(const bContext *C, wmManipulatorGroup *mgroup)
+static void gizmo_mesh_placement_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
wmOperator *op = WM_operator_last_redo(C);
- if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_manipulator")) {
+ if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_gizmo")) {
return;
}
- struct ManipulatorPlacementGroup *man = MEM_callocN(sizeof(ManipulatorPlacementGroup), __func__);
- mgroup->customdata = man;
+ struct GizmoPlacementGroup *man = MEM_callocN(sizeof(GizmoPlacementGroup), __func__);
+ gzgroup->customdata = man;
- const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true);
+ const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_3d", true);
- man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL);
+ man->cage = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->cage->color);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->cage->color);
RNA_enum_set(man->cage->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE |
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE |
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED);
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE |
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE |
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED);
- WM_manipulator_set_flag(man->cage, WM_MANIPULATOR_DRAW_VALUE, true);
+ WM_gizmo_set_flag(man->cage, WM_GIZMO_DRAW_VALUE, true);
man->data.context = (bContext *)C;
man->data.op = op;
man->data.prop_matrix = RNA_struct_find_property(op->ptr, "matrix");
- manipulator_mesh_placement_update_from_op(man);
+ gizmo_mesh_placement_update_from_op(man);
/* Setup property callbacks */
{
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
man->cage, "matrix",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_placement_prop_matrix_get,
- .value_set_fn = manipulator_placement_prop_matrix_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_placement_prop_matrix_get,
+ .value_set_fn = gizmo_placement_prop_matrix_set,
.range_get_fn = NULL,
.user_data = NULL,
});
}
- manipulator_mesh_placement_modal_from_setup(C, mgroup);
+ gizmo_mesh_placement_modal_from_setup(C, gzgroup);
}
-static void manipulator_mesh_placement_draw_prepare(
- const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void gizmo_mesh_placement_draw_prepare(
+ const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
- ManipulatorPlacementGroup *man = mgroup->customdata;
+ GizmoPlacementGroup *man = gzgroup->customdata;
if (man->data.op->next) {
man->data.op = WM_operator_last_redo((bContext *)man->data.context);
}
- manipulator_mesh_placement_update_from_op(man);
+ gizmo_mesh_placement_update_from_op(man);
}
-static void MESH_WGT_add_bounds(struct wmManipulatorGroupType *wgt)
+static void MESH_GGT_add_bounds(struct wmGizmoGroupType *gzgt)
{
- wgt->name = "Mesh Add Bounds";
- wgt->idname = "MESH_WGT_add_bounds";
+ gzgt->name = "Mesh Add Bounds";
+ gzgt->idname = "MESH_GGT_add_bounds";
- wgt->flag = WM_MANIPULATORGROUPTYPE_3D;
+ gzgt->flag = WM_GIZMOGROUPTYPE_3D;
- wgt->mmap_params.spaceid = SPACE_VIEW3D;
- wgt->mmap_params.regionid = RGN_TYPE_WINDOW;
+ gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
+ gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
- wgt->poll = manipulator_mesh_placement_poll;
- wgt->setup = manipulator_mesh_placement_setup;
- wgt->draw_prepare = manipulator_mesh_placement_draw_prepare;
+ gzgt->poll = gizmo_mesh_placement_poll;
+ gzgt->setup = gizmo_mesh_placement_setup;
+ gzgt->draw_prepare = gizmo_mesh_placement_draw_prepare;
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Add Cube Manipulator-Operator
+/** \name Add Cube Gizmo-Operator
*
* For now we use a separate operator to add a cube,
* we can try to merge then however they are invoked differently
@@ -332,13 +332,13 @@ static void MESH_WGT_add_bounds(struct wmManipulatorGroupType *wgt)
* \{ */
-static int add_primitive_cube_manipulator_exec(bContext *C, wmOperator *op)
+static int add_primitive_cube_gizmo_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
float matrix[4][4];
- /* Get the matrix that defines the cube bounds (as set by the manipulator cage). */
+ /* Get the matrix that defines the cube bounds (as set by the gizmo cage). */
{
PropertyRNA *prop_matrix = RNA_struct_find_property(op->ptr, "matrix");
if (RNA_property_is_set(op->ptr, prop_matrix)) {
@@ -372,25 +372,25 @@ static int add_primitive_cube_manipulator_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int add_primitive_cube_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int add_primitive_cube_gizmo_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
View3D *v3d = CTX_wm_view3d(C);
- int ret = add_primitive_cube_manipulator_exec(C, op);
+ int ret = add_primitive_cube_gizmo_exec(C, op);
if (ret & OPERATOR_FINISHED) {
- /* Setup manipulators */
- if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) {
+ /* Setup gizmos */
+ if (v3d && ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0)) {
ARegion *ar = CTX_wm_region(C);
- wmManipulatorMap *mmap = ar->manipulator_map;
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find("MESH_WGT_add_bounds", false);
- wmManipulatorGroup *mgroup = WM_manipulatormap_group_find_ptr(mmap, wgt);
- if (mgroup != NULL) {
- ManipulatorPlacementGroup *man = mgroup->customdata;
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find("MESH_GGT_add_bounds", false);
+ wmGizmoGroup *gzgroup = WM_gizmomap_group_find_ptr(gzmap, gzgt);
+ if (gzgroup != NULL) {
+ GizmoPlacementGroup *man = gzgroup->customdata;
man->data.op = op;
- manipulator_mesh_placement_modal_from_setup(C, mgroup);
+ gizmo_mesh_placement_modal_from_setup(C, gzgroup);
}
else {
- WM_manipulator_group_type_ensure_ptr(wgt);
+ WM_gizmo_group_type_ensure_ptr(gzgt);
}
}
}
@@ -398,16 +398,16 @@ static int add_primitive_cube_manipulator_invoke(bContext *C, wmOperator *op, co
return ret;
}
-void MESH_OT_primitive_cube_add_manipulator(wmOperatorType *ot)
+void MESH_OT_primitive_cube_add_gizmo(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Add Cube";
ot->description = "Construct a cube mesh";
- ot->idname = "MESH_OT_primitive_cube_add_manipulator";
+ ot->idname = "MESH_OT_primitive_cube_add_gizmo";
/* api callbacks */
- ot->invoke = add_primitive_cube_manipulator_invoke;
- ot->exec = add_primitive_cube_manipulator_exec;
+ ot->invoke = add_primitive_cube_gizmo_invoke;
+ ot->exec = add_primitive_cube_gizmo_exec;
ot->poll = ED_operator_editmesh_view3d;
/* flags */
@@ -420,7 +420,7 @@ void MESH_OT_primitive_cube_add_manipulator(wmOperatorType *ot)
PropertyRNA *prop = RNA_def_float_matrix(ot->srna, "matrix", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
- WM_manipulatorgrouptype_append(MESH_WGT_add_bounds);
+ WM_gizmogrouptype_append(MESH_GGT_add_bounds);
}
/** \} */
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 83da84357dc..51bfaaf61e5 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -97,7 +97,7 @@ typedef struct {
/* modal only */
float mcenter[2];
void *draw_handle_pixel;
- short twflag;
+ short gizmo_flag;
short value_mode; /* Which value does mouse movement and numeric input affect? */
float segments; /* Segments as float so smooth mouse pan works in small increments */
} BevelData;
@@ -287,8 +287,8 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
G.moving = G_TRANSFORM_EDIT;
if (v3d) {
- opdata->twflag = v3d->twflag;
- v3d->twflag = 0;
+ opdata->gizmo_flag = v3d->gizmo_flag;
+ v3d->gizmo_flag = V3D_GIZMO_HIDE;
}
}
@@ -377,7 +377,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op)
}
ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
if (v3d) {
- v3d->twflag = opdata->twflag;
+ v3d->gizmo_flag = opdata->gizmo_flag;
}
G.moving = 0;
}
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index 568983e47ee..9416d889a3b 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -54,10 +54,10 @@
#include "mesh_intern.h" /* own include */
-#define USE_MANIPULATOR
+#define USE_GIZMO
-#ifdef USE_MANIPULATOR
-#include "ED_manipulator_library.h"
+#ifdef USE_GIZMO
+#include "ED_gizmo_library.h"
#include "ED_undo.h"
#endif
@@ -70,7 +70,7 @@ typedef struct {
/* modal only */
BMBackup mesh_backup;
bool is_first;
- short twflag;
+ short gizmo_flag;
} BisectData;
static bool mesh_bisect_interactive_calc(
@@ -156,8 +156,8 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* misc other vars */
G.moving = G_TRANSFORM_EDIT;
- opdata->twflag = v3d->twflag;
- v3d->twflag = 0;
+ opdata->gizmo_flag = v3d->gizmo_flag;
+ v3d->gizmo_flag = V3D_GIZMO_HIDE;
/* initialize modal callout */
ED_workspace_status_text(C, IFACE_("LMB: Click and drag to draw cut line"));
@@ -169,7 +169,7 @@ static void edbm_bisect_exit(bContext *C, BisectData *opdata)
{
View3D *v3d = CTX_wm_view3d(C);
EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
- v3d->twflag = opdata->twflag;
+ v3d->gizmo_flag = opdata->gizmo_flag;
G.moving = 0;
}
@@ -195,12 +195,12 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (ret & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) {
edbm_bisect_exit(C, &opdata_back);
-#ifdef USE_MANIPULATOR
- /* Setup manipulators */
+#ifdef USE_GIZMO
+ /* Setup gizmos */
{
View3D *v3d = CTX_wm_view3d(C);
- if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) {
- WM_manipulator_group_type_ensure("MESH_WGT_bisect");
+ if (v3d && (v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) {
+ WM_gizmo_group_type_ensure("MESH_GGT_bisect");
}
}
#endif
@@ -333,8 +333,8 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
}
}
-#ifdef USE_MANIPULATOR
-static void MESH_WGT_bisect(struct wmManipulatorGroupType *wgt);
+#ifdef USE_GIZMO
+static void MESH_GGT_bisect(struct wmGizmoGroupType *gzgt);
#endif
void MESH_OT_bisect(struct wmOperatorType *ot)
@@ -373,26 +373,26 @@ void MESH_OT_bisect(struct wmOperatorType *ot)
WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT);
-#ifdef USE_MANIPULATOR
- WM_manipulatorgrouptype_append(MESH_WGT_bisect);
+#ifdef USE_GIZMO
+ WM_gizmogrouptype_append(MESH_GGT_bisect);
#endif
}
-#ifdef USE_MANIPULATOR
+#ifdef USE_GIZMO
/* -------------------------------------------------------------------- */
-/** \name Bisect Manipulator
+/** \name Bisect Gizmo
* \{ */
-typedef struct ManipulatorGroup {
+typedef struct GizmoGroup {
/* Arrow to change plane depth. */
- struct wmManipulator *translate_z;
+ struct wmGizmo *translate_z;
/* Translate XYZ */
- struct wmManipulator *translate_c;
- /* For grabbing the manipulator and moving freely. */
- struct wmManipulator *rotate_c;
+ struct wmGizmo *translate_c;
+ /* For grabbing the gizmo and moving freely. */
+ struct wmGizmo *rotate_c;
/* We could store more vars here! */
struct {
@@ -404,14 +404,14 @@ typedef struct ManipulatorGroup {
float rotate_axis[3];
float rotate_up[3];
} data;
-} ManipulatorGroup;
+} GizmoGroup;
/**
* XXX. calling redo from property updates is not great.
* This is needed because changing the RNA doesn't cause a redo
* and we're not using operator UI which does just this.
*/
-static void manipulator_bisect_exec(ManipulatorGroup *man)
+static void gizmo_bisect_exec(GizmoGroup *man)
{
wmOperator *op = man->data.op;
if (op == WM_operator_last_redo((bContext *)man->data.context)) {
@@ -419,7 +419,7 @@ static void manipulator_bisect_exec(ManipulatorGroup *man)
}
}
-static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man)
+static void gizmo_mesh_bisect_update_from_op(GizmoGroup *man)
{
wmOperator *op = man->data.op;
@@ -428,13 +428,13 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man)
RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co);
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no);
- WM_manipulator_set_matrix_location(man->translate_z, plane_co);
- WM_manipulator_set_matrix_location(man->rotate_c, plane_co);
+ WM_gizmo_set_matrix_location(man->translate_z, plane_co);
+ WM_gizmo_set_matrix_location(man->rotate_c, plane_co);
/* translate_c location comes from the property. */
- WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_z, plane_no);
+ WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_z, plane_no);
- WM_manipulator_set_scale(man->translate_c, 0.2);
+ WM_gizmo_set_scale(man->translate_c, 0.2);
RegionView3D *rv3d = ED_view3d_context_rv3d(man->data.context);
if (rv3d) {
@@ -445,103 +445,103 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man)
project_plane_normalized_v3_v3v3(man->data.rotate_up, man->data.rotate_up, man->data.rotate_axis);
normalize_v3(man->data.rotate_up);
- WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_c, plane_no);
+ WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_c, plane_no);
float plane_no_cross[3];
cross_v3_v3v3(plane_no_cross, plane_no, man->data.rotate_axis);
- WM_manipulator_set_matrix_offset_rotation_from_yz_axis(man->rotate_c, plane_no_cross, man->data.rotate_axis);
+ WM_gizmo_set_matrix_offset_rotation_from_yz_axis(man->rotate_c, plane_no_cross, man->data.rotate_axis);
RNA_enum_set(man->rotate_c->ptr, "draw_options",
- ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR |
- ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y);
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR |
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y);
}
}
/* depth callbacks */
-static void manipulator_bisect_prop_depth_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_bisect_prop_depth_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
- ManipulatorGroup *man = mpr->parent_mgroup->customdata;
+ GizmoGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
float plane_co[3], plane_no[3];
RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co);
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no);
- value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix_basis[3]);
+ value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, gz->matrix_basis[3]);
}
-static void manipulator_bisect_prop_depth_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_bisect_prop_depth_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value_p)
{
- ManipulatorGroup *man = mpr->parent_mgroup->customdata;
+ GizmoGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
const float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
float plane_co[3], plane[4];
RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co);
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane);
normalize_v3(plane);
- plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix_basis[3]);
+ plane[3] = -value[0] - dot_v3v3(plane, gz->matrix_basis[3]);
/* Keep our location, may be offset simply to be inside the viewport. */
closest_to_plane_normalized_v3(plane_co, plane, plane_co);
RNA_property_float_set_array(op->ptr, man->data.prop_plane_co, plane_co);
- manipulator_bisect_exec(man);
+ gizmo_bisect_exec(man);
}
/* translate callbacks */
-static void manipulator_bisect_prop_translate_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_bisect_prop_translate_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
- ManipulatorGroup *man = mpr->parent_mgroup->customdata;
+ GizmoGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
- BLI_assert(mpr_prop->type->array_length == 3);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 3);
+ UNUSED_VARS_NDEBUG(gz_prop);
RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, value_p);
}
-static void manipulator_bisect_prop_translate_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_bisect_prop_translate_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value_p)
{
- ManipulatorGroup *man = mpr->parent_mgroup->customdata;
+ GizmoGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
- BLI_assert(mpr_prop->type->array_length == 3);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 3);
+ UNUSED_VARS_NDEBUG(gz_prop);
RNA_property_float_set_array(op->ptr, man->data.prop_plane_co, value_p);
- manipulator_bisect_exec(man);
+ gizmo_bisect_exec(man);
}
/* angle callbacks */
-static void manipulator_bisect_prop_angle_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_bisect_prop_angle_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
- ManipulatorGroup *man = mpr->parent_mgroup->customdata;
+ GizmoGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
float plane_no[4];
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no);
@@ -559,16 +559,16 @@ static void manipulator_bisect_prop_angle_get(
}
}
-static void manipulator_bisect_prop_angle_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_bisect_prop_angle_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value_p)
{
- ManipulatorGroup *man = mpr->parent_mgroup->customdata;
+ GizmoGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
const float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
float plane_no[4];
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no);
@@ -588,22 +588,22 @@ static void manipulator_bisect_prop_angle_set(
/* re-normalize - seems acceptable */
RNA_property_float_set_array(op->ptr, man->data.prop_plane_no, plane_no);
- manipulator_bisect_exec(man);
+ gizmo_bisect_exec(man);
}
}
}
-static bool manipulator_mesh_bisect_poll(const bContext *C, wmManipulatorGroupType *wgt)
+static bool gizmo_mesh_bisect_poll(const bContext *C, wmGizmoGroupType *gzgt)
{
wmOperator *op = WM_operator_last_redo(C);
if (op == NULL || !STREQ(op->type->idname, "MESH_OT_bisect")) {
- WM_manipulator_group_type_unlink_delayed_ptr(wgt);
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
return false;
}
return true;
}
-static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup *mgroup)
+static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
wmOperator *op = WM_operator_last_redo(C);
@@ -611,26 +611,26 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup
return;
}
- struct ManipulatorGroup *man = MEM_callocN(sizeof(ManipulatorGroup), __func__);
- mgroup->customdata = man;
+ struct GizmoGroup *man = MEM_callocN(sizeof(GizmoGroup), __func__);
+ gzgroup->customdata = man;
- const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true);
- const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true);
- const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true);
+ const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true);
+ const wmGizmoType *gzt_grab = WM_gizmotype_find("GIZMO_GT_grab_3d", true);
+ const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true);
- man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
- man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, NULL);
- man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
+ man->translate_z = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL);
+ man->translate_c = WM_gizmo_new_ptr(gzt_grab, gzgroup, NULL);
+ man->rotate_c = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_z->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_c->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, man->rotate_c->color);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_z->color);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_c->color);
+ UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, man->rotate_c->color);
- RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D);
+ RNA_enum_set(man->translate_z->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_NORMAL);
+ RNA_enum_set(man->translate_c->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_RING_2D);
- WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true);
- WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true);
+ WM_gizmo_set_flag(man->translate_c, WM_GIZMO_DRAW_VALUE, true);
+ WM_gizmo_set_flag(man->rotate_c, WM_GIZMO_DRAW_VALUE, true);
{
man->data.context = (bContext *)C;
@@ -639,64 +639,64 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup
man->data.prop_plane_no = RNA_struct_find_property(op->ptr, "plane_no");
}
- manipulator_mesh_bisect_update_from_op(man);
+ gizmo_mesh_bisect_update_from_op(man);
/* Setup property callbacks */
{
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
man->translate_z, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_bisect_prop_depth_get,
- .value_set_fn = manipulator_bisect_prop_depth_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_bisect_prop_depth_get,
+ .value_set_fn = gizmo_bisect_prop_depth_set,
.range_get_fn = NULL,
.user_data = NULL,
});
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
man->translate_c, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_bisect_prop_translate_get,
- .value_set_fn = manipulator_bisect_prop_translate_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_bisect_prop_translate_get,
+ .value_set_fn = gizmo_bisect_prop_translate_set,
.range_get_fn = NULL,
.user_data = NULL,
});
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
man->rotate_c, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_bisect_prop_angle_get,
- .value_set_fn = manipulator_bisect_prop_angle_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_bisect_prop_angle_get,
+ .value_set_fn = gizmo_bisect_prop_angle_set,
.range_get_fn = NULL,
.user_data = NULL,
});
}
}
-static void manipulator_mesh_bisect_draw_prepare(
- const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void gizmo_mesh_bisect_draw_prepare(
+ const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
- ManipulatorGroup *man = mgroup->customdata;
+ GizmoGroup *man = gzgroup->customdata;
if (man->data.op->next) {
man->data.op = WM_operator_last_redo((bContext *)man->data.context);
}
- manipulator_mesh_bisect_update_from_op(man);
+ gizmo_mesh_bisect_update_from_op(man);
}
-static void MESH_WGT_bisect(struct wmManipulatorGroupType *wgt)
+static void MESH_GGT_bisect(struct wmGizmoGroupType *gzgt)
{
- wgt->name = "Mesh Bisect";
- wgt->idname = "MESH_WGT_bisect";
+ gzgt->name = "Mesh Bisect";
+ gzgt->idname = "MESH_GGT_bisect";
- wgt->flag = WM_MANIPULATORGROUPTYPE_3D;
+ gzgt->flag = WM_GIZMOGROUPTYPE_3D;
- wgt->mmap_params.spaceid = SPACE_VIEW3D;
- wgt->mmap_params.regionid = RGN_TYPE_WINDOW;
+ gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
+ gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
- wgt->poll = manipulator_mesh_bisect_poll;
- wgt->setup = manipulator_mesh_bisect_setup;
- wgt->draw_prepare = manipulator_mesh_bisect_draw_prepare;
+ gzgt->poll = gizmo_mesh_bisect_poll;
+ gzgt->setup = gizmo_mesh_bisect_setup;
+ gzgt->draw_prepare = gizmo_mesh_bisect_draw_prepare;
}
/** \} */
-#endif /* USE_MANIPULATOR */
+#endif /* USE_GIZMO */
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index be68bfda09c..061cc3ebc32 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -53,7 +53,7 @@
#include "ED_screen.h"
#include "ED_transform.h"
#include "ED_view3d.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "UI_resources.h"
@@ -61,7 +61,7 @@
#include "mesh_intern.h" /* own include */
-#define USE_MANIPULATOR
+#define USE_GIZMO
/* -------------------------------------------------------------------- */
/** \name Extrude Internal Utilities
@@ -360,10 +360,10 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
-/** \name Extrude Manipulator
+/** \name Extrude Gizmo
* \{ */
-#ifdef USE_MANIPULATOR
+#ifdef USE_GIZMO
const float extrude_button_scale = 0.15f;
const float extrude_button_offset_scale = 1.5f;
@@ -380,11 +380,11 @@ static const uchar shape_plus[] = {
0x90, 0x6e, 0xd7, 0x80, 0xff, 0x5f, 0xfb, 0x5f, 0xfb,
};
-typedef struct ManipulatorExtrudeGroup {
+typedef struct GizmoExtrudeGroup {
/* XYZ & normal. */
- struct wmManipulator *invoke_xyz_no[4];
- struct wmManipulator *adjust_xyz_no[5];
+ struct wmGizmo *invoke_xyz_no[4];
+ struct wmGizmo *adjust_xyz_no[5];
struct {
float normal_mat3[3][3]; /* use Z axis for normal. */
@@ -392,10 +392,10 @@ typedef struct ManipulatorExtrudeGroup {
} data;
wmOperatorType *ot_extrude;
-} ManipulatorExtrudeGroup;
+} GizmoExtrudeGroup;
-static void manipulator_mesh_extrude_orientation_matrix_set(
- struct ManipulatorExtrudeGroup *man, const float mat[3][3])
+static void gizmo_mesh_extrude_orientation_matrix_set(
+ struct GizmoExtrudeGroup *man, const float mat[3][3])
{
for (int i = 0; i < 3; i++) {
/* Set orientation without location. */
@@ -417,32 +417,32 @@ static void manipulator_mesh_extrude_orientation_matrix_set(
}
}
-static bool manipulator_mesh_extrude_poll(const bContext *C, wmManipulatorGroupType *wgt)
+static bool gizmo_mesh_extrude_poll(const bContext *C, wmGizmoGroupType *gzgt)
{
ScrArea *sa = CTX_wm_area(C);
bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL;
if ((tref_rt == NULL) ||
- !STREQ(wgt->idname, tref_rt->manipulator_group) ||
+ !STREQ(gzgt->idname, tref_rt->gizmo_group) ||
!ED_operator_editmesh_view3d((bContext *)C))
{
- WM_manipulator_group_type_unlink_delayed_ptr(wgt);
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
return false;
}
return true;
}
-static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void gizmo_mesh_extrude_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
- struct ManipulatorExtrudeGroup *man = MEM_callocN(sizeof(ManipulatorExtrudeGroup), __func__);
- mgroup->customdata = man;
+ struct GizmoExtrudeGroup *man = MEM_callocN(sizeof(GizmoExtrudeGroup), __func__);
+ gzgroup->customdata = man;
- const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true);
- const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_button_2d", true);
+ const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true);
+ const wmGizmoType *gzt_grab = WM_gizmotype_find("GIZMO_GT_button_2d", true);
for (int i = 0; i < 4; i++) {
- man->adjust_xyz_no[i] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
- man->invoke_xyz_no[i] = WM_manipulator_new_ptr(wt_grab, mgroup, NULL);
- man->invoke_xyz_no[i]->flag |= WM_MANIPULATOR_DRAW_OFFSET_SCALE;
+ man->adjust_xyz_no[i] = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL);
+ man->invoke_xyz_no[i] = WM_gizmo_new_ptr(gzt_grab, gzgroup, NULL);
+ man->invoke_xyz_no[i]->flag |= WM_GIZMO_DRAW_OFFSET_SCALE;
}
{
@@ -460,25 +460,25 @@ static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipula
UI_GetThemeColor3fv(TH_AXIS_X + i, man->invoke_xyz_no[i]->color);
UI_GetThemeColor3fv(TH_AXIS_X + i, man->adjust_xyz_no[i]->color);
}
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->invoke_xyz_no[3]->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->adjust_xyz_no[3]->color);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->invoke_xyz_no[3]->color);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->adjust_xyz_no[3]->color);
for (int i = 0; i < 4; i++) {
- WM_manipulator_set_scale(man->invoke_xyz_no[i], extrude_button_scale);
- WM_manipulator_set_scale(man->adjust_xyz_no[i], extrude_arrow_scale);
+ WM_gizmo_set_scale(man->invoke_xyz_no[i], extrude_button_scale);
+ WM_gizmo_set_scale(man->adjust_xyz_no[i], extrude_arrow_scale);
}
- WM_manipulator_set_scale(man->adjust_xyz_no[3], extrude_arrow_normal_axis_scale);
+ WM_gizmo_set_scale(man->adjust_xyz_no[3], extrude_arrow_normal_axis_scale);
for (int i = 0; i < 4; i++) {
}
for (int i = 0; i < 4; i++) {
- WM_manipulator_set_flag(man->adjust_xyz_no[i], WM_MANIPULATOR_DRAW_VALUE, true);
+ WM_gizmo_set_flag(man->adjust_xyz_no[i], WM_GIZMO_DRAW_VALUE, true);
}
/* XYZ & normal axis extrude. */
for (int i = 0; i < 4; i++) {
- PointerRNA *ptr = WM_manipulator_operator_set(man->invoke_xyz_no[i], 0, man->ot_extrude, NULL);
+ PointerRNA *ptr = WM_gizmo_operator_set(man->invoke_xyz_no[i], 0, man->ot_extrude, NULL);
{
bool constraint[3] = {0, 0, 0};
constraint[MIN2(i, 2)] = 1;
@@ -490,7 +490,7 @@ static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipula
/* Adjust extrude. */
for (int i = 0; i < 4; i++) {
- PointerRNA *ptr = WM_manipulator_operator_set(man->adjust_xyz_no[i], 0, man->ot_extrude, NULL);
+ PointerRNA *ptr = WM_gizmo_operator_set(man->adjust_xyz_no[i], 0, man->ot_extrude, NULL);
{
bool constraint[3] = {0, 0, 0};
constraint[MIN2(i, 2)] = 1;
@@ -498,18 +498,18 @@ static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipula
RNA_boolean_set(&macroptr, "release_confirm", true);
RNA_boolean_set_array(&macroptr, "constraint_axis", constraint);
}
- wmManipulatorOpElem *mpop = WM_manipulator_operator_get(man->adjust_xyz_no[i], 0);
+ wmGizmoOpElem *mpop = WM_gizmo_operator_get(man->adjust_xyz_no[i], 0);
mpop->is_redo = true;
}
}
-static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void gizmo_mesh_extrude_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- ManipulatorExtrudeGroup *man = mgroup->customdata;
+ GizmoExtrudeGroup *man = gzgroup->customdata;
for (int i = 0; i < 4; i++) {
- WM_manipulator_set_flag(man->invoke_xyz_no[i], WM_MANIPULATOR_HIDDEN, true);
- WM_manipulator_set_flag(man->adjust_xyz_no[i], WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(man->invoke_xyz_no[i], WM_GIZMO_HIDDEN, true);
+ WM_gizmo_set_flag(man->adjust_xyz_no[i], WM_GIZMO_HIDDEN, true);
}
if (G.moving) {
@@ -525,7 +525,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro
if (use_normal) {
struct TransformBounds tbounds_normal;
- if (!ED_transform_calc_manipulator_stats(
+ if (!ED_transform_calc_gizmo_stats(
C, &(struct TransformCalcParams){
.orientation_type = V3D_MANIP_NORMAL + 1,
}, &tbounds_normal))
@@ -536,7 +536,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro
}
/* TODO(campbell): run second since this modifies the 3D view, it should not. */
- if (!ED_transform_calc_manipulator_stats(
+ if (!ED_transform_calc_gizmo_stats(
C, &(struct TransformCalcParams){
.orientation_type = man->data.orientation_type + 1,
}, &tbounds))
@@ -556,15 +556,15 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro
(extrude_arrow_normal_axis_scale * extrude_button_offset_scale) / extrude_button_scale);
/* Needed for normal orientation. */
- manipulator_mesh_extrude_orientation_matrix_set(man, tbounds.axis);
+ gizmo_mesh_extrude_orientation_matrix_set(man, tbounds.axis);
if (use_normal) {
copy_m4_m3(man->adjust_xyz_no[3]->matrix_basis, man->data.normal_mat3);
}
/* Location. */
for (int i = 0; i < axis_len_used; i++) {
- WM_manipulator_set_matrix_location(man->invoke_xyz_no[i], tbounds.center);
- WM_manipulator_set_matrix_location(man->adjust_xyz_no[i], tbounds.center);
+ WM_gizmo_set_matrix_location(man->invoke_xyz_no[i], tbounds.center);
+ WM_gizmo_set_matrix_location(man->adjust_xyz_no[i], tbounds.center);
}
wmOperator *op = WM_operator_last_redo(C);
@@ -572,13 +572,13 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro
/* Un-hide. */
for (int i = 0; i < axis_len_used; i++) {
- WM_manipulator_set_flag(man->invoke_xyz_no[i], WM_MANIPULATOR_HIDDEN, false);
- WM_manipulator_set_flag(man->adjust_xyz_no[i], WM_MANIPULATOR_HIDDEN, !has_redo);
+ WM_gizmo_set_flag(man->invoke_xyz_no[i], WM_GIZMO_HIDDEN, false);
+ WM_gizmo_set_flag(man->adjust_xyz_no[i], WM_GIZMO_HIDDEN, !has_redo);
}
/* Operator properties. */
if (use_normal) {
- wmManipulatorOpElem *mpop = WM_manipulator_operator_get(man->invoke_xyz_no[3], 0);
+ wmGizmoOpElem *mpop = WM_gizmo_operator_get(man->invoke_xyz_no[3], 0);
PointerRNA macroptr = RNA_pointer_get(&mpop->ptr, "TRANSFORM_OT_translate");
RNA_enum_set(&macroptr, "constraint_orientation", V3D_MANIP_NORMAL);
}
@@ -598,7 +598,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro
(orientation_type == man->data.orientation_type && constraint_axis[i]) :
(orientation_type == V3D_MANIP_NORMAL && constraint_axis[2]))
{
- wmManipulatorOpElem *mpop = WM_manipulator_operator_get(man->adjust_xyz_no[i], 0);
+ wmGizmoOpElem *mpop = WM_gizmo_operator_get(man->adjust_xyz_no[i], 0);
PointerRNA macroptr = RNA_pointer_get(&mpop->ptr, "TRANSFORM_OT_translate");
@@ -609,7 +609,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro
else {
/* TODO(campbell): ideally we could adjust all,
* this is complicated by how operator redo and the transform macro works. */
- WM_manipulator_set_flag(man->adjust_xyz_no[i], WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(man->adjust_xyz_no[i], WM_GIZMO_HIDDEN, true);
}
}
}
@@ -618,14 +618,14 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro
RNA_enum_set(
man->invoke_xyz_no[i]->ptr,
"draw_options",
- (man->adjust_xyz_no[i]->flag & WM_MANIPULATOR_HIDDEN) ?
- ED_MANIPULATOR_BUTTON_SHOW_HELPLINE : 0);
+ (man->adjust_xyz_no[i]->flag & WM_GIZMO_HIDDEN) ?
+ ED_GIZMO_BUTTON_SHOW_HELPLINE : 0);
}
}
-static void manipulator_mesh_extrude_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+static void gizmo_mesh_extrude_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
- ManipulatorExtrudeGroup *man = mgroup->customdata;
+ GizmoExtrudeGroup *man = gzgroup->customdata;
switch (man->data.orientation_type) {
case V3D_MANIP_VIEW:
{
@@ -633,48 +633,48 @@ static void manipulator_mesh_extrude_draw_prepare(const bContext *C, wmManipulat
float mat[3][3];
copy_m3_m4(mat, rv3d->viewinv);
normalize_m3(mat);
- manipulator_mesh_extrude_orientation_matrix_set(man, mat);
+ gizmo_mesh_extrude_orientation_matrix_set(man, mat);
break;
}
}
}
-static void manipulator_mesh_extrude_message_subscribe(
- const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus)
+static void gizmo_mesh_extrude_message_subscribe(
+ const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus)
{
ARegion *ar = CTX_wm_region(C);
/* Subscribe to view properties */
- wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = {
+ wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = {
.owner = ar,
- .user_data = mgroup->parent_mmap,
- .notify = WM_manipulator_do_msg_notify_tag_refresh,
+ .user_data = gzgroup->parent_gzmap,
+ .notify = WM_gizmo_do_msg_notify_tag_refresh,
};
{
- WM_msg_subscribe_rna_anon_prop(mbus, Scene, transform_orientation, &msg_sub_value_mpr_tag_refresh);
+ WM_msg_subscribe_rna_anon_prop(mbus, Scene, transform_orientation, &msg_sub_value_gz_tag_refresh);
}
}
-static void MESH_WGT_extrude(struct wmManipulatorGroupType *wgt)
+static void MESH_GGT_extrude(struct wmGizmoGroupType *gzgt)
{
- wgt->name = "Mesh Extrude";
- wgt->idname = "MESH_WGT_extrude";
+ gzgt->name = "Mesh Extrude";
+ gzgt->idname = "MESH_GGT_extrude";
- wgt->flag = WM_MANIPULATORGROUPTYPE_3D;
+ gzgt->flag = WM_GIZMOGROUPTYPE_3D;
- wgt->mmap_params.spaceid = SPACE_VIEW3D;
- wgt->mmap_params.regionid = RGN_TYPE_WINDOW;
+ gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
+ gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
- wgt->poll = manipulator_mesh_extrude_poll;
- wgt->setup = manipulator_mesh_extrude_setup;
- wgt->refresh = manipulator_mesh_extrude_refresh;
- wgt->draw_prepare = manipulator_mesh_extrude_draw_prepare;
- wgt->message_subscribe = manipulator_mesh_extrude_message_subscribe;
+ gzgt->poll = gizmo_mesh_extrude_poll;
+ gzgt->setup = gizmo_mesh_extrude_setup;
+ gzgt->refresh = gizmo_mesh_extrude_refresh;
+ gzgt->draw_prepare = gizmo_mesh_extrude_draw_prepare;
+ gzgt->message_subscribe = gizmo_mesh_extrude_message_subscribe;
}
-#endif /* USE_MANIPULATOR */
+#endif /* USE_GIZMO */
/** \} */
@@ -825,8 +825,8 @@ void MESH_OT_extrude_context(wmOperatorType *ot)
Transform_Properties(ot, P_NO_DEFAULTS | P_MIRROR_DUMMY);
-#ifdef USE_MANIPULATOR
- WM_manipulatorgrouptype_append(MESH_WGT_extrude);
+#ifdef USE_GIZMO
+ WM_gizmogrouptype_append(MESH_GGT_extrude);
#endif
}
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c
index f98d7dacac8..adb7ee71ee0 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin.c
@@ -54,27 +54,27 @@
#include "mesh_intern.h" /* own include */
-#define USE_MANIPULATOR
+#define USE_GIZMO
-#ifdef USE_MANIPULATOR
-#include "ED_manipulator_library.h"
+#ifdef USE_GIZMO
+#include "ED_gizmo_library.h"
#include "ED_undo.h"
#endif
/* -------------------------------------------------------------------- */
-/** \name Spin Manipulator
+/** \name Spin Gizmo
* \{ */
-#ifdef USE_MANIPULATOR
-typedef struct ManipulatorSpinGroup {
+#ifdef USE_GIZMO
+typedef struct GizmoSpinGroup {
/* Arrow to change plane depth. */
- struct wmManipulator *translate_z;
+ struct wmGizmo *translate_z;
/* Translate XYZ */
- struct wmManipulator *translate_c;
- /* For grabbing the manipulator and moving freely. */
- struct wmManipulator *rotate_c;
+ struct wmGizmo *translate_c;
+ /* For grabbing the gizmo and moving freely. */
+ struct wmGizmo *rotate_c;
/* Spin angle */
- struct wmManipulator *angle_z;
+ struct wmGizmo *angle_z;
/* We could store more vars here! */
struct {
@@ -87,14 +87,14 @@ typedef struct ManipulatorSpinGroup {
float rotate_axis[3];
float rotate_up[3];
} data;
-} ManipulatorSpinGroup;
+} GizmoSpinGroup;
/**
* XXX. calling redo from property updates is not great.
* This is needed because changing the RNA doesn't cause a redo
* and we're not using operator UI which does just this.
*/
-static void manipulator_spin_exec(ManipulatorSpinGroup *man)
+static void gizmo_spin_exec(GizmoSpinGroup *man)
{
wmOperator *op = man->data.op;
if (op == WM_operator_last_redo((bContext *)man->data.context)) {
@@ -102,7 +102,7 @@ static void manipulator_spin_exec(ManipulatorSpinGroup *man)
}
}
-static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man)
+static void gizmo_mesh_spin_update_from_op(GizmoSpinGroup *man)
{
wmOperator *op = man->data.op;
@@ -111,15 +111,15 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man)
RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co);
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no);
- WM_manipulator_set_matrix_location(man->translate_z, plane_co);
- WM_manipulator_set_matrix_location(man->rotate_c, plane_co);
- WM_manipulator_set_matrix_location(man->angle_z, plane_co);
+ WM_gizmo_set_matrix_location(man->translate_z, plane_co);
+ WM_gizmo_set_matrix_location(man->rotate_c, plane_co);
+ WM_gizmo_set_matrix_location(man->angle_z, plane_co);
/* translate_c location comes from the property. */
- WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_z, plane_no);
- WM_manipulator_set_matrix_rotation_from_z_axis(man->angle_z, plane_no);
+ WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_z, plane_no);
+ WM_gizmo_set_matrix_rotation_from_z_axis(man->angle_z, plane_no);
- WM_manipulator_set_scale(man->translate_c, 0.2);
+ WM_gizmo_set_scale(man->translate_c, 0.2);
RegionView3D *rv3d = ED_view3d_context_rv3d(man->data.context);
if (rv3d) {
@@ -130,103 +130,103 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man)
project_plane_normalized_v3_v3v3(man->data.rotate_up, man->data.rotate_up, man->data.rotate_axis);
normalize_v3(man->data.rotate_up);
- WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_c, plane_no);
- WM_manipulator_set_matrix_rotation_from_yz_axis(man->rotate_c, plane_no, man->data.rotate_axis);
+ WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_c, plane_no);
+ WM_gizmo_set_matrix_rotation_from_yz_axis(man->rotate_c, plane_no, man->data.rotate_axis);
/* show the axis instead of mouse cursor */
RNA_enum_set(man->rotate_c->ptr, "draw_options",
- ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR |
- ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y);
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR |
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y);
}
}
/* depth callbacks */
-static void manipulator_spin_prop_depth_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_spin_prop_depth_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
- ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata;
+ GizmoSpinGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
float plane_co[3], plane_no[3];
RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co);
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no);
- value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix_basis[3]);
+ value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, gz->matrix_basis[3]);
}
-static void manipulator_spin_prop_depth_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_spin_prop_depth_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value_p)
{
- ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata;
+ GizmoSpinGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
const float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
float plane_co[3], plane[4];
RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co);
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane);
normalize_v3(plane);
- plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix_basis[3]);
+ plane[3] = -value[0] - dot_v3v3(plane, gz->matrix_basis[3]);
/* Keep our location, may be offset simply to be inside the viewport. */
closest_to_plane_normalized_v3(plane_co, plane, plane_co);
RNA_property_float_set_array(op->ptr, man->data.prop_axis_co, plane_co);
- manipulator_spin_exec(man);
+ gizmo_spin_exec(man);
}
/* translate callbacks */
-static void manipulator_spin_prop_translate_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_spin_prop_translate_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
- ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata;
+ GizmoSpinGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 3);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 3);
+ UNUSED_VARS_NDEBUG(gz_prop);
RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, value);
}
-static void manipulator_spin_prop_translate_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_spin_prop_translate_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value)
{
- ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata;
+ GizmoSpinGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
- BLI_assert(mpr_prop->type->array_length == 3);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 3);
+ UNUSED_VARS_NDEBUG(gz_prop);
RNA_property_float_set_array(op->ptr, man->data.prop_axis_co, value);
- manipulator_spin_exec(man);
+ gizmo_spin_exec(man);
}
/* angle callbacks */
-static void manipulator_spin_prop_axis_angle_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_spin_prop_axis_angle_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
- ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata;
+ GizmoSpinGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
float plane_no[4];
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no);
@@ -244,16 +244,16 @@ static void manipulator_spin_prop_axis_angle_get(
}
}
-static void manipulator_spin_prop_axis_angle_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_spin_prop_axis_angle_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value_p)
{
- ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata;
+ GizmoSpinGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
const float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
float plane_no[4];
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no);
@@ -273,50 +273,50 @@ static void manipulator_spin_prop_axis_angle_set(
/* re-normalize - seems acceptable */
RNA_property_float_set_array(op->ptr, man->data.prop_axis_no, plane_no);
- manipulator_spin_exec(man);
+ gizmo_spin_exec(man);
}
}
}
/* angle callbacks */
-static void manipulator_spin_prop_angle_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_spin_prop_angle_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
- ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata;
+ GizmoSpinGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
value[0] = RNA_property_float_get(op->ptr, man->data.prop_angle);
}
-static void manipulator_spin_prop_angle_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_spin_prop_angle_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value_p)
{
- ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata;
+ GizmoSpinGroup *man = gz->parent_gzgroup->customdata;
wmOperator *op = man->data.op;
- BLI_assert(mpr_prop->type->array_length == 1);
- UNUSED_VARS_NDEBUG(mpr_prop);
+ BLI_assert(gz_prop->type->array_length == 1);
+ UNUSED_VARS_NDEBUG(gz_prop);
const float *value = value_p;
RNA_property_float_set(op->ptr, man->data.prop_angle, value[0]);
- manipulator_spin_exec(man);
+ gizmo_spin_exec(man);
}
-static bool manipulator_mesh_spin_poll(const bContext *C, wmManipulatorGroupType *wgt)
+static bool gizmo_mesh_spin_poll(const bContext *C, wmGizmoGroupType *gzgt)
{
wmOperator *op = WM_operator_last_redo(C);
if (op == NULL || !STREQ(op->type->idname, "MESH_OT_spin")) {
- WM_manipulator_group_type_unlink_delayed_ptr(wgt);
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
return false;
}
return true;
}
-static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *mgroup)
+static void gizmo_mesh_spin_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
wmOperator *op = WM_operator_last_redo(C);
@@ -324,32 +324,32 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m
return;
}
- struct ManipulatorSpinGroup *man = MEM_callocN(sizeof(ManipulatorSpinGroup), __func__);
- mgroup->customdata = man;
+ struct GizmoSpinGroup *man = MEM_callocN(sizeof(GizmoSpinGroup), __func__);
+ gzgroup->customdata = man;
- const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true);
- const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true);
- const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true);
+ const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true);
+ const wmGizmoType *gzt_grab = WM_gizmotype_find("GIZMO_GT_grab_3d", true);
+ const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true);
- man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
- man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, NULL);
- man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
- man->angle_z = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
+ man->translate_z = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL);
+ man->translate_c = WM_gizmo_new_ptr(gzt_grab, gzgroup, NULL);
+ man->rotate_c = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL);
+ man->angle_z = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_z->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_c->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, man->rotate_c->color);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_z->color);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_c->color);
+ UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, man->rotate_c->color);
UI_GetThemeColor3fv(TH_AXIS_Z, man->angle_z->color);
- RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D);
+ RNA_enum_set(man->translate_z->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_NORMAL);
+ RNA_enum_set(man->translate_c->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_RING_2D);
- WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true);
- WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true);
- WM_manipulator_set_flag(man->angle_z, WM_MANIPULATOR_DRAW_VALUE, true);
+ WM_gizmo_set_flag(man->translate_c, WM_GIZMO_DRAW_VALUE, true);
+ WM_gizmo_set_flag(man->rotate_c, WM_GIZMO_DRAW_VALUE, true);
+ WM_gizmo_set_flag(man->angle_z, WM_GIZMO_DRAW_VALUE, true);
- WM_manipulator_set_scale(man->angle_z, 0.5f);
+ WM_gizmo_set_scale(man->angle_z, 0.5f);
{
man->data.context = (bContext *)C;
@@ -359,42 +359,42 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m
man->data.prop_angle = RNA_struct_find_property(op->ptr, "angle");
}
- manipulator_mesh_spin_update_from_op(man);
+ gizmo_mesh_spin_update_from_op(man);
/* Setup property callbacks */
{
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
man->translate_z, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_spin_prop_depth_get,
- .value_set_fn = manipulator_spin_prop_depth_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_spin_prop_depth_get,
+ .value_set_fn = gizmo_spin_prop_depth_set,
.range_get_fn = NULL,
.user_data = NULL,
});
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
man->translate_c, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_spin_prop_translate_get,
- .value_set_fn = manipulator_spin_prop_translate_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_spin_prop_translate_get,
+ .value_set_fn = gizmo_spin_prop_translate_set,
.range_get_fn = NULL,
.user_data = NULL,
});
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
man->rotate_c, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_spin_prop_axis_angle_get,
- .value_set_fn = manipulator_spin_prop_axis_angle_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_spin_prop_axis_angle_get,
+ .value_set_fn = gizmo_spin_prop_axis_angle_set,
.range_get_fn = NULL,
.user_data = NULL,
});
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
man->angle_z, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_spin_prop_angle_get,
- .value_set_fn = manipulator_spin_prop_angle_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_spin_prop_angle_get,
+ .value_set_fn = gizmo_spin_prop_angle_set,
.range_get_fn = NULL,
.user_data = NULL,
});
@@ -402,34 +402,34 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m
}
}
-static void manipulator_mesh_spin_draw_prepare(
- const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void gizmo_mesh_spin_draw_prepare(
+ const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
- ManipulatorSpinGroup *man = mgroup->customdata;
+ GizmoSpinGroup *man = gzgroup->customdata;
if (man->data.op->next) {
man->data.op = WM_operator_last_redo((bContext *)man->data.context);
}
- manipulator_mesh_spin_update_from_op(man);
+ gizmo_mesh_spin_update_from_op(man);
}
-static void MESH_WGT_spin(struct wmManipulatorGroupType *wgt)
+static void MESH_GGT_spin(struct wmGizmoGroupType *gzgt)
{
- wgt->name = "Mesh Spin";
- wgt->idname = "MESH_WGT_spin";
+ gzgt->name = "Mesh Spin";
+ gzgt->idname = "MESH_GGT_spin";
- wgt->flag = WM_MANIPULATORGROUPTYPE_3D;
+ gzgt->flag = WM_GIZMOGROUPTYPE_3D;
- wgt->mmap_params.spaceid = SPACE_VIEW3D;
- wgt->mmap_params.regionid = RGN_TYPE_WINDOW;
+ gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
+ gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
- wgt->poll = manipulator_mesh_spin_poll;
- wgt->setup = manipulator_mesh_spin_setup;
- wgt->draw_prepare = manipulator_mesh_spin_draw_prepare;
+ gzgt->poll = gizmo_mesh_spin_poll;
+ gzgt->setup = gizmo_mesh_spin_setup;
+ gzgt->draw_prepare = gizmo_mesh_spin_draw_prepare;
}
/** \} */
-#endif /* USE_MANIPULATOR */
+#endif /* USE_GIZMO */
/* -------------------------------------------------------------------- */
/** \name Spin Operator
@@ -508,11 +508,11 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
int ret = edbm_spin_exec(C, op);
-#ifdef USE_MANIPULATOR
+#ifdef USE_GIZMO
if (ret & OPERATOR_FINISHED) {
- /* Setup manipulators */
- if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) {
- WM_manipulator_group_type_ensure("MESH_WGT_spin");
+ /* Setup gizmos */
+ if (v3d && ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0)) {
+ WM_gizmo_group_type_ensure("MESH_GGT_spin");
}
}
#endif
@@ -548,7 +548,7 @@ void MESH_OT_spin(wmOperatorType *ot)
"Center", "Center in global view space", -1e4f, 1e4f);
RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f);
-#ifdef USE_MANIPULATOR
- WM_manipulatorgrouptype_append(MESH_WGT_spin);
+#ifdef USE_GIZMO
+ WM_gizmogrouptype_append(MESH_GGT_spin);
#endif
}
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index 8758fa66a14..486203462a0 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -78,7 +78,7 @@ typedef struct {
/* modal only */
float mcenter[2];
void *draw_handle_pixel;
- short twflag;
+ short gizmo_flag;
} InsetData;
@@ -173,8 +173,8 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal)
ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL);
G.moving = G_TRANSFORM_EDIT;
if (v3d) {
- opdata->twflag = v3d->twflag;
- v3d->twflag = 0;
+ opdata->gizmo_flag = v3d->gizmo_flag;
+ v3d->gizmo_flag = V3D_GIZMO_HIDE;
}
}
@@ -196,7 +196,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op)
}
ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
if (v3d) {
- v3d->twflag = opdata->twflag;
+ v3d->gizmo_flag = opdata->gizmo_flag;
}
G.moving = 0;
}
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index a511100ff4e..99756269c1f 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1007,13 +1007,13 @@ static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd)
copy_v3_v3(v2, ray_hit_best[1]);
}
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformThemeColor(TH_TRANSFORM);
GPU_line_width(2.0);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex3fv(pos, v1);
immVertex3fv(pos, v2);
immEnd();
@@ -1037,19 +1037,18 @@ static void knife_init_colors(KnifeColors *colors)
}
/* modal loop selection drawing callback */
-static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
+static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
{
- View3D *v3d = CTX_wm_view3d(C);
const KnifeTool_OpData *kcd = arg;
- if (v3d->zbuf) GPU_depth_test(false);
+ GPU_depth_test(false);
glPolygonOffset(1.0f, 1.0f);
- gpuPushMatrix();
- gpuMultMatrix(kcd->ob->obmat);
+ GPU_matrix_push();
+ GPU_matrix_mul(kcd->ob->obmat);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -1060,7 +1059,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor3ubv(kcd->colors.line);
GPU_line_width(2.0);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex3fv(pos, kcd->prev.cage);
immVertex3fv(pos, kcd->curr.cage);
immEnd();
@@ -1070,7 +1069,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor3ubv(kcd->colors.point);
GPU_point_size(11);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex3fv(pos, kcd->prev.cage);
immEnd();
}
@@ -1079,7 +1078,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor3ubv(kcd->colors.curpoint);
GPU_point_size(9);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex3fv(pos, kcd->prev.cage);
immEnd();
}
@@ -1088,7 +1087,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor3ubv(kcd->colors.edge);
GPU_line_width(2.0);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex3fv(pos, kcd->curr.edge->v1->cageco);
immVertex3fv(pos, kcd->curr.edge->v2->cageco);
immEnd();
@@ -1097,7 +1096,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor3ubv(kcd->colors.point);
GPU_point_size(11);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex3fv(pos, kcd->curr.cage);
immEnd();
}
@@ -1106,7 +1105,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor3ubv(kcd->colors.curpoint);
GPU_point_size(9);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex3fv(pos, kcd->curr.cage);
immEnd();
}
@@ -1122,7 +1121,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor4ubv(kcd->colors.point_a);
GPU_point_size(11);
- immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit);
+ immBeginAtMost(GPU_PRIM_POINTS, kcd->totlinehit);
lh = kcd->linehits;
for (i = 0; i < kcd->totlinehit; i++, lh++) {
@@ -1137,7 +1136,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor4ubv(kcd->colors.curpoint_a);
GPU_point_size(7);
- immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit);
+ immBeginAtMost(GPU_PRIM_POINTS, kcd->totlinehit);
lh = kcd->linehits;
for (i = 0; i < kcd->totlinehit; i++, lh++) {
@@ -1158,7 +1157,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor3ubv(kcd->colors.line);
GPU_line_width(1.0);
- immBeginAtMost(GWN_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2);
+ immBeginAtMost(GPU_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2);
BLI_mempool_iternew(kcd->kedges, &iter);
for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) {
@@ -1179,7 +1178,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUniformColor3ubv(kcd->colors.point);
GPU_point_size(5.0);
- immBeginAtMost(GWN_PRIM_POINTS, BLI_mempool_len(kcd->kverts));
+ immBeginAtMost(GPU_PRIM_POINTS, BLI_mempool_len(kcd->kverts));
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
@@ -1194,9 +1193,10 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
- if (v3d->zbuf) GPU_depth_test(true);
+ /* Reset default */
+ GPU_depth_test(true);
}
/**
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 8493d15a3b1..95c94c146e4 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -106,25 +106,23 @@ typedef struct RingSelOpData {
} RingSelOpData;
/* modal loop selection drawing callback */
-static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
+static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
{
- View3D *v3d = CTX_wm_view3d(C);
RingSelOpData *lcd = arg;
if ((lcd->totedge > 0) || (lcd->totpoint > 0)) {
- if (v3d && v3d->zbuf)
- GPU_depth_test(false);
+ GPU_depth_test(false);
- gpuPushMatrix();
- gpuMultMatrix(lcd->ob->obmat);
+ GPU_matrix_push();
+ GPU_matrix_mul(lcd->ob->obmat);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3ub(255, 0, 255);
if (lcd->totedge > 0) {
- immBegin(GWN_PRIM_LINES, lcd->totedge * 2);
+ immBegin(GPU_PRIM_LINES, lcd->totedge * 2);
for (int i = 0; i < lcd->totedge; i++) {
immVertex3fv(pos, lcd->edges[i][0]);
@@ -137,7 +135,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
if (lcd->totpoint > 0) {
GPU_point_size(3.0f);
- immBegin(GWN_PRIM_POINTS, lcd->totpoint);
+ immBegin(GPU_PRIM_POINTS, lcd->totpoint);
for (int i = 0; i < lcd->totpoint; i++) {
immVertex3fv(pos, lcd->points[i]);
@@ -148,10 +146,10 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
- if (v3d && v3d->zbuf)
- GPU_depth_test(true);
+ /* Reset default */
+ GPU_depth_test(true);
}
}
diff --git a/source/blender/editors/mesh/editmesh_polybuild.c b/source/blender/editors/mesh/editmesh_polybuild.c
index e8bcfb5eb08..86c9fc0243b 100644
--- a/source/blender/editors/mesh/editmesh_polybuild.c
+++ b/source/blender/editors/mesh/editmesh_polybuild.c
@@ -390,7 +390,7 @@ void MESH_OT_polybuild_dissolve_at_cursor(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Cursor Manipulator
+/** \name Cursor Gizmo
*
* \note This may need its own file, for now not.
* \{ */
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 6cae7e8c1ee..fd87ba32653 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -565,8 +565,8 @@ UvVertMap *BM_uv_vert_map_create(
}
BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i) {
- buf->tfindex = i;
- buf->f = a;
+ buf->loop_of_poly_index = i;
+ buf->poly_index = a;
buf->separate = 0;
buf->next = vmap->vert[BM_elem_index_get(l->v)];
@@ -597,9 +597,9 @@ UvVertMap *BM_uv_vert_map_create(
v->next = newvlist;
newvlist = v;
- efa = BM_face_at_index(bm, v->f);
+ efa = BM_face_at_index(bm, v->poly_index);
- l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, v->tfindex);
+ l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, v->loop_of_poly_index);
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
uv = luv->uv;
@@ -608,15 +608,15 @@ UvVertMap *BM_uv_vert_map_create(
while (iterv) {
next = iterv->next;
- efa = BM_face_at_index(bm, iterv->f);
- l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, iterv->tfindex);
+ efa = BM_face_at_index(bm, iterv->poly_index);
+ l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, iterv->loop_of_poly_index);
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
uv2 = luv->uv;
sub_v2_v2v2(uvdiff, uv2, uv);
if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1] &&
- (!use_winding || winding[iterv->f] == winding[v->f]))
+ (!use_winding || winding[iterv->poly_index] == winding[v->poly_index]))
{
if (lastv) lastv->next = next;
else vlist = next;
@@ -713,7 +713,7 @@ UvElementMap *BM_uv_element_map_create(
buf->l = l;
buf->separate = 0;
buf->island = INVALID_ISLAND;
- buf->tfindex = i;
+ buf->loop_of_poly_index = i;
buf->next = element_map->vert[BM_elem_index_get(l->v)];
element_map->vert[BM_elem_index_get(l->v)] = buf;
@@ -826,7 +826,7 @@ UvElementMap *BM_uv_element_map_create(
map[element - element_map->buf] = islandbufsize;
islandbuf[islandbufsize].l = element->l;
islandbuf[islandbufsize].separate = element->separate;
- islandbuf[islandbufsize].tfindex = element->tfindex;
+ islandbuf[islandbufsize].loop_of_poly_index = element->loop_of_poly_index;
islandbuf[islandbufsize].island = nislands;
islandbufsize++;
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index 2a9ad4bd3d8..4a67dea9d4b 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -92,8 +92,8 @@ void MESH_OT_primitive_monkey_add(struct wmOperatorType *ot);
void MESH_OT_primitive_uv_sphere_add(struct wmOperatorType *ot);
void MESH_OT_primitive_ico_sphere_add(struct wmOperatorType *ot);
-/* *** editmesh_add_manipulator.c *** */
-void MESH_OT_primitive_cube_add_manipulator(struct wmOperatorType *ot);
+/* *** editmesh_add_gizmo.c *** */
+void MESH_OT_primitive_cube_add_gizmo(struct wmOperatorType *ot);
/* *** editmesh_bevel.c *** */
void MESH_OT_bevel(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 09d6ea7226a..d8441ab8bf6 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -78,7 +78,7 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_primitive_uv_sphere_add);
WM_operatortype_append(MESH_OT_primitive_ico_sphere_add);
- WM_operatortype_append(MESH_OT_primitive_cube_add_manipulator);
+ WM_operatortype_append(MESH_OT_primitive_cube_add_gizmo);
WM_operatortype_append(MESH_OT_duplicate);
WM_operatortype_append(MESH_OT_remove_doubles);
@@ -345,23 +345,21 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "vertex_only", true);
/* selecting */
-
- kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX);
- kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE);
- kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE);
-
- kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, KM_SHIFT, 0);
- RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX);
- RNA_boolean_set(kmi->ptr, "use_extend", true);
- kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, KM_SHIFT, 0);
- RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE);
- RNA_boolean_set(kmi->ptr, "use_extend", true);
- kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, KM_SHIFT, 0);
- RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE);
- RNA_boolean_set(kmi->ptr, "use_extend", true);
+ for (int i = 0; i < 4; i++) {
+ const bool is_extend = (i & 1);
+ const bool is_expand = (i & 2);
+ const int key_modifier = (is_extend ? KM_SHIFT : 0) | (is_expand ? KM_CTRL : 0);
+ for (int j = 0; j < 3; j++) {
+ kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY + j, KM_PRESS, key_modifier, 0);
+ RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX << j);
+ if (is_extend) {
+ RNA_boolean_set(kmi->ptr, "use_extend", true);
+ }
+ if (is_expand) {
+ RNA_boolean_set(kmi->ptr, "use_expand", true);
+ }
+ }
+ }
/* standard mouse selection goes via space_view3d */
kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
@@ -389,7 +387,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "use_fill", true);
kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
@@ -413,6 +413,8 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
#endif
+ WM_keymap_add_item(keymap, "MESH_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
/* hide */
@@ -521,7 +523,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_vertices", VKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0);
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "OBJECT_OT_vertex_group_remove_from", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
#ifdef USE_WM_KEYMAP_27X
/* useful stuff from object-mode */
diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c
index 567ef3150bf..ab7098eeb53 100644
--- a/source/blender/editors/metaball/mball_ops.c
+++ b/source/blender/editors/metaball/mball_ops.c
@@ -89,7 +89,9 @@ void ED_keymap_metaball(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MBALL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index a8c3c905dd4..8c60dd01e89 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -120,12 +120,12 @@
/* this is an exact copy of the define in rna_lamp.c
* kept here because of linking order.
* Icons are only defined here */
-const EnumPropertyItem rna_enum_lamp_type_items[] = {
- {LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source"},
- {LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source"},
- {LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source"},
- {LA_HEMI, "HEMI", ICON_LAMP_HEMI, "Hemi", "180 degree constant light source"},
- {LA_AREA, "AREA", ICON_LAMP_AREA, "Area", "Directional area light source"},
+const EnumPropertyItem rna_enum_light_type_items[] = {
+ {LA_LOCAL, "POINT", ICON_LIGHT_POINT, "Point", "Omnidirectional point light source"},
+ {LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"},
+ {LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"},
+ {LA_HEMI, "HEMI", ICON_LIGHT_HEMI, "Hemi", "180 degree constant light source"},
+ {LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"},
{0, NULL, 0, NULL, NULL}
};
@@ -985,9 +985,9 @@ void OBJECT_OT_drop_named_image(wmOperatorType *ot)
ED_object_add_generic_props(ot, false);
}
-/********************* Add Lamp Operator ********************/
+/********************* Add Light Operator ********************/
-static const char *get_lamp_defname(int type)
+static const char *get_light_defname(int type)
{
switch (type) {
case LA_LOCAL: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Point");
@@ -996,11 +996,11 @@ static const char *get_lamp_defname(int type)
case LA_HEMI: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Hemi");
case LA_AREA: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Area");
default:
- return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Lamp");
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Light");
}
}
-static int object_lamp_add_exec(bContext *C, wmOperator *op)
+static int object_light_add_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob;
@@ -1013,10 +1013,10 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &layer, NULL))
return OPERATOR_CANCELLED;
- ob = ED_object_add_type(C, OB_LAMP, get_lamp_defname(type), loc, rot, false, layer);
+ ob = ED_object_add_type(C, OB_LAMP, get_light_defname(type), loc, rot, false, layer);
float size = RNA_float_get(op->ptr, "radius");
- /* Better defaults for lamp size. */
+ /* Better defaults for light size. */
switch (type) {
case LA_LOCAL:
case LA_SPOT:
@@ -1041,23 +1041,23 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void OBJECT_OT_lamp_add(wmOperatorType *ot)
+void OBJECT_OT_light_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Add Lamp";
- ot->description = "Add a lamp object to the scene";
- ot->idname = "OBJECT_OT_lamp_add";
+ ot->name = "Add Light";
+ ot->description = "Add a light object to the scene";
+ ot->idname = "OBJECT_OT_light_add";
/* api callbacks */
ot->invoke = WM_menu_invoke;
- ot->exec = object_lamp_add_exec;
+ ot->exec = object_light_add_exec;
ot->poll = ED_operator_objectmode;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_lamp_type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_light_type_items, 0, "Type", "");
RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_LAMP);
ED_object_add_unit_props(ot);
@@ -2222,7 +2222,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer
ID_NEW_REMAP_US2(obn->data)
else {
obn->data = ID_NEW_SET(obn->data, BKE_armature_copy(bmain, obn->data));
- BKE_pose_rebuild(obn, obn->data);
+ BKE_pose_rebuild(bmain, obn, obn->data);
didit = 1;
}
id_us_min(id);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 0ca797e43b6..a6c3c86922d 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -709,7 +709,9 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
- WM_toolsystem_update_from_context_view3d(C);
+ if (G.background == false) {
+ WM_toolsystem_update_from_context_view3d(C);
+ }
return OPERATOR_FINISHED;
}
@@ -809,7 +811,9 @@ static int posemode_exec(bContext *C, wmOperator *op)
WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
- WM_toolsystem_update_from_context_view3d(C);
+ if (G.background == false) {
+ WM_toolsystem_update_from_context_view3d(C);
+ }
return OPERATOR_FINISHED;
}
@@ -1046,10 +1050,8 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
DEG_relations_tag_update(bmain);
}
else if (event == 23) {
- base->object->softflag = ob->softflag;
- if (base->object->soft) sbFree(base->object->soft);
-
- base->object->soft = copy_softbody(ob->soft, 0);
+ sbFree(base->object);
+ BKE_object_copy_softbody(base->object, ob, 0);
if (!modifiers_findByType(base->object, eModifierType_Softbody)) {
BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody));
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index b1ea6d72346..1b5c6df2632 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -115,7 +115,7 @@ void OBJECT_OT_armature_add(struct wmOperatorType *ot);
void OBJECT_OT_empty_add(struct wmOperatorType *ot);
void OBJECT_OT_lightprobe_add(struct wmOperatorType *ot);
void OBJECT_OT_drop_named_image(struct wmOperatorType *ot);
-void OBJECT_OT_lamp_add(struct wmOperatorType *ot);
+void OBJECT_OT_light_add(struct wmOperatorType *ot);
void OBJECT_OT_effector_add(struct wmOperatorType *ot);
void OBJECT_OT_camera_add(struct wmOperatorType *ot);
void OBJECT_OT_speaker_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 2889f798dd8..11d0fd9f9d5 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -293,9 +293,8 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
}
else if (md->type == eModifierType_Softbody) {
if (ob->soft) {
- sbFree(ob->soft);
- ob->soft = NULL;
- ob->softflag = 0;
+ sbFree(ob);
+ ob->softflag = 0; /* TODO(Sybren): this should probably be moved into sbFree() */
}
}
else if (md->type == eModifierType_Collision) {
@@ -692,23 +691,29 @@ int ED_object_modifier_apply(
if (md != ob->modifiers.first)
BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected");
+ /* Get evaluated modifier, so object links pointer to evaluated data,
+ * but still use original object it is applied to the original mesh. */
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ ModifierData *md_eval = (ob_eval) ? modifiers_findByName(ob_eval, md->name) : md;
+
/* allow apply of a not-realtime modifier, by first re-enabling realtime. */
- prev_mode = md->mode;
- md->mode |= eModifierMode_Realtime;
+ prev_mode = md_eval->mode;
+ md_eval->mode |= eModifierMode_Realtime;
if (mode == MODIFIER_APPLY_SHAPE) {
- if (!modifier_apply_shape(bmain, reports, depsgraph, scene, ob, md)) {
- md->mode = prev_mode;
+ if (!modifier_apply_shape(bmain, reports, depsgraph, scene, ob, md_eval)) {
+ md_eval->mode = prev_mode;
return 0;
}
}
else {
- if (!modifier_apply_obdata(reports, depsgraph, scene, ob, md)) {
- md->mode = prev_mode;
+ if (!modifier_apply_obdata(reports, depsgraph, scene, ob, md_eval)) {
+ md_eval->mode = prev_mode;
return 0;
}
}
+ md_eval->mode = prev_mode;
BLI_remlink(&ob->modifiers, md);
modifier_free(md);
@@ -2063,28 +2068,9 @@ static bool ocean_bake_poll(bContext *C)
return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0);
}
-/* copied from init_ocean_modifier, MOD_ocean.c */
-static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData *omd)
-{
- int do_heightfield, do_chop, do_normals, do_jacobian;
-
- if (!omd || !oc) return;
-
- do_heightfield = true;
- do_chop = (omd->chop_amount > 0);
- do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS);
- do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
-
- BKE_ocean_init(oc, omd->resolution * omd->resolution, omd->resolution * omd->resolution, omd->spatial_size, omd->spatial_size,
- omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
- omd->depth, omd->time,
- do_heightfield, do_chop, do_normals, do_jacobian,
- omd->seed);
-}
-
typedef struct OceanBakeJob {
/* from wmJob */
- void *owner;
+ struct Object *owner;
short *stop, *do_update;
float *progress;
int current_frame;
@@ -2150,6 +2136,9 @@ static void oceanbake_endjob(void *customdata)
oj->omd->oceancache = oj->och;
oj->omd->cached = true;
+
+ Object *ob = oj->owner;
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
}
static int ocean_bake_exec(bContext *C, wmOperator *op)
@@ -2170,8 +2159,8 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
if (free) {
- omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ BKE_ocean_free_modifier_cache(omd);
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
}
@@ -2211,7 +2200,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
/* make a copy of ocean to use for baking - threadsafety */
ocean = BKE_ocean_add();
- init_ocean_modifier_bake(ocean, omd);
+ BKE_ocean_init_from_modifier(ocean, omd);
#if 0
BKE_ocean_bake(ocean, och);
@@ -2233,6 +2222,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation",
WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN);
oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job");
+ oj->owner = ob;
oj->ocean = ocean;
oj->och = och;
oj->omd = omd;
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index b52ef7a1abc..5a83d085aee 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -114,7 +114,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_empty_add);
WM_operatortype_append(OBJECT_OT_lightprobe_add);
WM_operatortype_append(OBJECT_OT_drop_named_image);
- WM_operatortype_append(OBJECT_OT_lamp_add);
+ WM_operatortype_append(OBJECT_OT_light_add);
WM_operatortype_append(OBJECT_OT_camera_add);
WM_operatortype_append(OBJECT_OT_speaker_add);
WM_operatortype_append(OBJECT_OT_add);
@@ -293,11 +293,15 @@ void ED_keymap_object(wmKeyConfig *keyconf)
keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
/* modes */
- kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_CLICK, 0, 0);
+ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
RNA_boolean_set(kmi->ptr, "toggle", true);
- kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_object_mode_pie", TABKEY, KM_CLICK_DRAG, 0, 0);
+#if 0
+ WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_object_mode_pie", TABKEY, KM_PRESS, KM_CTRL, 0);
+#else
+ WM_keymap_add_item(keymap, "VIEW3D_OT_object_mode_pie_or_toggle", TABKEY, KM_PRESS, KM_CTRL, 0);
+#endif
#ifdef USE_WM_KEYMAP_27X
WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0);
@@ -313,7 +317,9 @@ void ED_keymap_object(wmKeyConfig *keyconf)
ED_keymap_proportional_obmode(keyconf, keymap);
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 324b6eca34a..2c3ff8b6afe 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -360,7 +360,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
newob = BKE_object_add_from(bmain, scene, view_layer, OB_EMPTY, name, gob ? gob : ob);
/* set layers OK */
- BKE_object_make_proxy(newob, ob, gob);
+ BKE_object_make_proxy(bmain, newob, ob, gob);
/* Set back pointer immediately so dependency graph knows that this is
* is a proxy and will act accordingly. Otherwise correctness of graph
@@ -1809,7 +1809,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer
case OB_ARMATURE:
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
ob->data = ID_NEW_SET(ob->data, BKE_armature_copy(bmain, ob->data));
- BKE_pose_rebuild(ob, ob->data);
+ BKE_pose_rebuild(bmain, ob, ob->data);
break;
case OB_SPEAKER:
ob->data = ID_NEW_SET(ob->data, BKE_speaker_copy(bmain, ob->data));
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index b1dee812f45..d5f7a93cc6e 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -485,7 +485,7 @@ enum {
OBJECT_GRPSEL_PASS = 8,
OBJECT_GRPSEL_COLOR = 9,
OBJECT_GRPSEL_KEYINGSET = 10,
- OBJECT_GRPSEL_LAMP_TYPE = 11,
+ OBJECT_GRPSEL_LIGHT_TYPE = 11,
};
static const EnumPropertyItem prop_select_grouped_types[] = {
@@ -499,7 +499,7 @@ static const EnumPropertyItem prop_select_grouped_types[] = {
{OBJECT_GRPSEL_PASS, "PASS", 0, "Pass", "Render pass Index"},
{OBJECT_GRPSEL_COLOR, "COLOR", 0, "Color", "Object Color"},
{OBJECT_GRPSEL_KEYINGSET, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"},
- {OBJECT_GRPSEL_LAMP_TYPE, "LAMP_TYPE", 0, "Lamp Type", "Matching lamp types"},
+ {OBJECT_GRPSEL_LIGHT_TYPE, "LIGHT_TYPE", 0, "Light Type", "Matching light types"},
{0, NULL, 0, NULL, NULL}
};
@@ -803,9 +803,9 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
case OBJECT_GRPSEL_KEYINGSET:
changed |= select_grouped_keyingset(C, ob, op->reports);
break;
- case OBJECT_GRPSEL_LAMP_TYPE:
+ case OBJECT_GRPSEL_LIGHT_TYPE:
if (ob->type != OB_LAMP) {
- BKE_report(op->reports, RPT_ERROR, "Active object must be a lamp");
+ BKE_report(op->reports, RPT_ERROR, "Active object must be a light");
break;
}
changed |= select_grouped_lamptype(C, ob);
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 721d248ae4c..d2a0879464b 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -485,7 +485,7 @@ static int apply_objects_internal(
if (la->type == LA_AREA) {
if (apply_rot || apply_loc) {
BKE_reportf(reports, RPT_ERROR,
- "Area Lamps can only have scale applied: \"%s\"",
+ "Area Lights can only have scale applied: \"%s\"",
ob->id.name + 2);
changed = false;
}
@@ -1540,8 +1540,8 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
void OBJECT_OT_transform_axis_target(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Interactive Lamp Track to Cursor";
- ot->description = "Interactively point cameras and lamps to a location (Ctrl translates)";
+ ot->name = "Interactive Light Track to Cursor";
+ ot->description = "Interactively point cameras and lights to a location (Ctrl translates)";
ot->idname = "OBJECT_OT_transform_axis_target";
/* api callbacks */
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index e637a58e8c6..1b82e60b986 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -2892,7 +2892,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
brush = &pset->brush[pset->brushtype];
if (brush) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(255, 255, 255, 128);
@@ -4809,8 +4809,6 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
}
- // ED_workspace_object_mode_sync_from_object(wm, workspace, ob);
-
DEG_id_tag_update(&ob->id, OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE);
WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode);
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 6cc9b9b8e4d..108b9e3437b 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -434,7 +434,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
Object *ob = fobj->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
- float active= (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) > 0 ? 1 : 0);
+ float active = (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) ? 1 : 0);
float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 73bb2d14505..a1a61b08dc9 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -117,7 +117,9 @@ static void keymap_particle(wmKeyConfig *keyconf)
keymap->poll = PE_poll;
kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h
index 77bf16f5e22..585a7999290 100644
--- a/source/blender/editors/render/render_intern.h
+++ b/source/blender/editors/render/render_intern.h
@@ -56,6 +56,9 @@ void MATERIAL_OT_paste(struct wmOperatorType *ot);
void SCENE_OT_view_layer_add(struct wmOperatorType *ot);
void SCENE_OT_view_layer_remove(struct wmOperatorType *ot);
+void SCENE_OT_light_cache_bake(struct wmOperatorType *ot);
+void SCENE_OT_light_cache_free(struct wmOperatorType *ot);
+
void SCENE_OT_render_view_add(struct wmOperatorType *ot);
void SCENE_OT_render_view_remove(struct wmOperatorType *ot);
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 1385baa51ad..d6a968d993c 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -66,7 +66,6 @@
#include "BKE_screen.h"
#include "BKE_scene.h"
#include "BKE_undo_system.h"
-#include "BKE_workspace.h"
#include "DEG_depsgraph.h"
@@ -263,7 +262,7 @@ static void image_buffer_rect_update(RenderJob *rj, RenderResult *rr, ImBuf *ibu
/* set callbacks, exported to sequence render too.
* Only call in foreground (UI) renders. */
-static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpace *workspace, Scene **scene, ViewLayer **single_layer)
+static void screen_render_single_layer_set(wmOperator *op, Main *mainp, ViewLayer *active_layer, Scene **scene, ViewLayer **single_layer)
{
/* single layer re-render */
if (RNA_struct_property_is_set(op->ptr, "scene")) {
@@ -292,8 +291,8 @@ static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpac
if (rl)
*single_layer = rl;
}
- else if (((*scene)->r.scemode & R_SINGLE_LAYER) && workspace) {
- *single_layer = BKE_view_layer_from_workspace_get(*scene, workspace);
+ else if (((*scene)->r.scemode & R_SINGLE_LAYER) && active_layer) {
+ *single_layer = active_layer;
}
}
@@ -302,12 +301,12 @@ static int screen_render_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
RenderEngineType *re_type = RE_engines_find(scene->r.engine);
+ ViewLayer *active_layer = CTX_data_view_layer(C);
ViewLayer *single_layer = NULL;
Render *re;
Image *ima;
View3D *v3d = CTX_wm_view3d(C);
Main *mainp = CTX_data_main(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
unsigned int lay_override;
const bool is_animation = RNA_boolean_get(op->ptr, "animation");
const bool is_write_still = RNA_boolean_get(op->ptr, "write_still");
@@ -319,7 +318,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
}
/* custom scene and single layer re-render */
- screen_render_single_layer_set(op, mainp, workspace, &scene, &single_layer);
+ screen_render_single_layer_set(op, mainp, active_layer, &scene, &single_layer);
if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {
BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected");
@@ -428,7 +427,7 @@ static void make_renderinfo_string(const RenderStats *rs,
if (rs->totface) spos += sprintf(spos, IFACE_("Fa:%d "), rs->totface);
if (rs->tothalo) spos += sprintf(spos, IFACE_("Ha:%d "), rs->tothalo);
if (rs->totstrand) spos += sprintf(spos, IFACE_("St:%d "), rs->totstrand);
- if (rs->totlamp) spos += sprintf(spos, IFACE_("La:%d "), rs->totlamp);
+ if (rs->totlamp) spos += sprintf(spos, IFACE_("Li:%d "), rs->totlamp);
if (rs->mem_peak == 0.0f)
spos += sprintf(spos, IFACE_("| Mem:%.2fM (%.2fM, Peak %.2fM) "),
@@ -846,8 +845,7 @@ static void clean_viewport_memory(Main *bmain, Scene *scene)
/* Go over all the visible objects. */
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
for (wmWindow *win = wm->windows.first; win; win = win->next) {
- WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
for (base = view_layer->object_bases.first; base; base = base->next) {
clean_viewport_memory_base(base);
@@ -865,8 +863,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
{
/* new render clears all callbacks */
Main *bmain = CTX_data_main(C);
- ViewLayer *single_layer = NULL;
Scene *scene = CTX_data_scene(C);
+ ViewLayer *active_layer = CTX_data_view_layer(C);
+ ViewLayer *single_layer = NULL;
RenderEngineType *re_type = RE_engines_find(scene->r.engine);
Render *re;
wmJob *wm_job;
@@ -877,7 +876,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
const bool is_write_still = RNA_boolean_get(op->ptr, "write_still");
const bool use_viewport = RNA_boolean_get(op->ptr, "use_viewport");
View3D *v3d = use_viewport ? CTX_wm_view3d(C) : NULL;
- WorkSpace *workspace = CTX_wm_workspace(C);
struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
const char *name;
ScrArea *sa;
@@ -888,7 +886,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
}
/* custom scene and single layer re-render */
- screen_render_single_layer_set(op, bmain, workspace, &scene, &single_layer);
+ screen_render_single_layer_set(op, bmain, active_layer, &scene, &single_layer);
/* only one render job at a time */
if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER))
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index b5c1ffc64dd..22000bd2a03 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -326,7 +326,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
wmOrtho2(0, sizex, 0, sizey);
- gpuTranslate2f(sizex / 2, sizey / 2);
+ GPU_matrix_translate_2f(sizex / 2, sizey / 2);
G.f |= G_RENDER_OGL;
ED_gpencil_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
@@ -355,7 +355,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
if (view_context) {
ibuf_view = ED_view3d_draw_offscreen_imbuf(
- depsgraph, scene, v3d->drawtype,
+ depsgraph, scene, v3d->shading.type,
v3d, ar, sizex, sizey,
IB_rectfloat, draw_flags, alpha_mode, oglrender->ofs_samples, viewname,
oglrender->ofs, err_out);
diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c
index fd534dd9129..7961ea27fdc 100644
--- a/source/blender/editors/render/render_ops.c
+++ b/source/blender/editors/render/render_ops.c
@@ -62,6 +62,9 @@ void ED_operatortypes_render(void)
WM_operatortype_append(SCENE_OT_render_view_add);
WM_operatortype_append(SCENE_OT_render_view_remove);
+ WM_operatortype_append(SCENE_OT_light_cache_bake);
+ WM_operatortype_append(SCENE_OT_light_cache_free);
+
#ifdef WITH_FREESTYLE
WM_operatortype_append(SCENE_OT_freestyle_module_add);
WM_operatortype_append(SCENE_OT_freestyle_module_remove);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 04632838cf3..3423eedf7ca 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -158,7 +158,7 @@ typedef struct ShaderPreview {
Scene *scene;
Depsgraph *depsgraph;
- ID *id;
+ ID *id, *id_copy;
ID *parent;
MTex *slot;
@@ -173,6 +173,7 @@ typedef struct ShaderPreview {
int sizex, sizey;
unsigned int *pr_rect;
int pr_method;
+ bool own_id_copy;
Main *bmain;
Main *pr_main;
@@ -189,7 +190,7 @@ typedef struct IconPreview {
Scene *scene;
Depsgraph *depsgraph;
void *owner;
- ID *id;
+ ID *id, *id_copy;
ListBase sizes;
} IconPreview;
@@ -312,6 +313,38 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world)
return sp->worldcopy;
}
+static ID *duplicate_ids(ID *id, Depsgraph *depsgraph)
+{
+ if (id == NULL) {
+ /* Non-ID preview render. */
+ return NULL;
+ }
+
+ ID *id_eval = id;
+
+ if (depsgraph) {
+ id_eval = DEG_get_evaluated_id(depsgraph, id);
+ }
+
+ switch (GS(id->name)) {
+ case ID_MA:
+ return (ID *)BKE_material_localize((Material *)id_eval);
+ case ID_TE:
+ return (ID *)BKE_texture_localize((Tex *)id_eval);
+ case ID_LA:
+ return (ID *)BKE_lamp_localize((Lamp *)id_eval);
+ case ID_WO:
+ return (ID *)BKE_world_localize((World *)id_eval);
+ case ID_IM:
+ case ID_BR:
+ case ID_SCR:
+ return NULL;
+ default:
+ BLI_assert(!"ID type preview not supported.");
+ return NULL;
+ }
+}
+
/* call this with a pointer to initialize preview scene */
/* call this with NULL to restore assigned ID pointers in preview scene */
static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_type, ShaderPreview *sp)
@@ -373,8 +406,9 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
if (origmat) {
/* work on a copy */
- mat = BKE_material_localize(origmat);
- sp->matcopy = mat;
+ BLI_assert(sp->id_copy != NULL);
+ mat = sp->matcopy = (Material *)sp->id_copy;
+ sp->id_copy = NULL;
BLI_addtail(&pr_main->mat, mat);
/* use current scene world to light sphere */
@@ -400,13 +434,13 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
if (mat->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
BKE_node_preview_init_tree(mat->nodetree, sp->sizex, sp->sizey, true);
+ /* WATCH: Accessing origmat is not safe! */
BKE_node_preview_init_tree(origmat->nodetree, sp->sizex, sp->sizey, true);
}
}
}
else {
sce->r.mode &= ~(R_OSA);
-
}
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
@@ -432,16 +466,18 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
Tex *tex = NULL, *origtex = (Tex *)id;
if (origtex) {
- tex = BKE_texture_localize(origtex);
- sp->texcopy = tex;
+ BLI_assert(sp->id_copy != NULL);
+ tex = sp->texcopy = (Tex *)sp->id_copy;
+ sp->id_copy = NULL;
BLI_addtail(&pr_main->tex, tex);
}
set_preview_collection(sce, view_layer, MA_TEXTURE);
if (tex && tex->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
- BKE_node_preview_init_tree(origtex->nodetree, sp->sizex, sp->sizey, true);
BKE_node_preview_init_tree(tex->nodetree, sp->sizex, sp->sizey, true);
+ /* WATCH: Accessing origtex is not safe! */
+ BKE_node_preview_init_tree(origtex->nodetree, sp->sizex, sp->sizey, true);
}
}
else if (id_type == ID_LA) {
@@ -449,8 +485,9 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
/* work on a copy */
if (origla) {
- la = BKE_lamp_localize(origla);
- sp->lampcopy = la;
+ BLI_assert(sp->id_copy != NULL);
+ la = sp->lampcopy = (Lamp *)sp->id_copy;
+ sp->id_copy = NULL;
BLI_addtail(&pr_main->lamp, la);
}
@@ -473,16 +510,18 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
if (la && la->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
- BKE_node_preview_init_tree(origla->nodetree, sp->sizex, sp->sizey, true);
BKE_node_preview_init_tree(la->nodetree, sp->sizex, sp->sizey, true);
+ /* WATCH: Accessing origla is not safe! */
+ BKE_node_preview_init_tree(origla->nodetree, sp->sizex, sp->sizey, true);
}
}
else if (id_type == ID_WO) {
World *wrld = NULL, *origwrld = (World *)id;
if (origwrld) {
- wrld = BKE_world_localize(origwrld);
- sp->worldcopy = wrld;
+ BLI_assert(sp->id_copy != NULL);
+ wrld = sp->worldcopy = (World *)sp->id_copy;
+ sp->id_copy = NULL;
BLI_addtail(&pr_main->world, wrld);
}
@@ -492,6 +531,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
if (wrld && wrld->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
BKE_node_preview_init_tree(wrld->nodetree, sp->sizex, sp->sizey, true);
+ /* WATCH: Accessing origwrld is not safe! */
BKE_node_preview_init_tree(origwrld->nodetree, sp->sizex, sp->sizey, true);
}
}
@@ -685,7 +725,11 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
char name[32];
int sizex;
Main *pr_main = sp->pr_main;
- ID *id_eval = DEG_get_evaluated_id(sp->depsgraph, id);
+ ID *id_eval = id;
+
+ if (sp->depsgraph) {
+ id_eval = DEG_get_evaluated_id(sp->depsgraph, id);
+ }
/* in case of split preview, use border render */
if (split) {
@@ -795,70 +839,51 @@ static void shader_preview_free(void *customdata)
Main *pr_main = sp->pr_main;
if (sp->matcopy) {
- struct IDProperty *properties;
-
- /* node previews */
- shader_preview_updatejob(sp);
-
- /* get rid of copied material */
+ sp->id_copy = (ID *)sp->matcopy;
BLI_remlink(&pr_main->mat, sp->matcopy);
-
- BKE_material_free(sp->matcopy);
-
- properties = IDP_GetProperties((ID *)sp->matcopy, false);
- if (properties) {
- IDP_FreeProperty(properties);
- MEM_freeN(properties);
- }
- MEM_freeN(sp->matcopy);
}
if (sp->texcopy) {
- struct IDProperty *properties;
- /* node previews */
- shader_preview_updatejob(sp);
-
- /* get rid of copied texture */
+ sp->id_copy = (ID *)sp->texcopy;
BLI_remlink(&pr_main->tex, sp->texcopy);
- BKE_texture_free(sp->texcopy);
-
- properties = IDP_GetProperties((ID *)sp->texcopy, false);
- if (properties) {
- IDP_FreeProperty(properties);
- MEM_freeN(properties);
- }
- MEM_freeN(sp->texcopy);
}
if (sp->worldcopy) {
- struct IDProperty *properties;
- /* node previews */
- shader_preview_updatejob(sp);
-
- /* get rid of copied world */
+ sp->id_copy = (ID *)sp->worldcopy;
BLI_remlink(&pr_main->world, sp->worldcopy);
- BKE_world_free(sp->worldcopy);
-
- properties = IDP_GetProperties((ID *)sp->worldcopy, false);
- if (properties) {
- IDP_FreeProperty(properties);
- MEM_freeN(properties);
- }
- MEM_freeN(sp->worldcopy);
}
if (sp->lampcopy) {
- struct IDProperty *properties;
+ sp->id_copy = (ID *)sp->lampcopy;
+ BLI_remlink(&pr_main->lamp, sp->lampcopy);
+ }
+ if (sp->id_copy) {
/* node previews */
shader_preview_updatejob(sp);
-
- /* get rid of copied lamp */
- BLI_remlink(&pr_main->lamp, sp->lampcopy);
- BKE_lamp_free(sp->lampcopy);
-
- properties = IDP_GetProperties((ID *)sp->lampcopy, false);
+ }
+ if (sp->id_copy && sp->own_id_copy) {
+ struct IDProperty *properties;
+ /* get rid of copied ID */
+ properties = IDP_GetProperties(sp->id_copy, false);
if (properties) {
IDP_FreeProperty(properties);
MEM_freeN(properties);
}
- MEM_freeN(sp->lampcopy);
+ switch (GS(sp->id_copy->name)) {
+ case ID_MA:
+ BKE_material_free((Material *)sp->id_copy);
+ break;
+ case ID_TE:
+ BKE_texture_free((Tex *)sp->id_copy);
+ break;
+ case ID_LA:
+ BKE_lamp_free((Lamp *)sp->id_copy);
+ break;
+ case ID_WO:
+ BKE_world_free((World *)sp->id_copy);
+ break;
+ default:
+ BLI_assert(!"ID type preview not supported.");
+ break;
+ }
+ MEM_freeN(sp->id_copy);
}
MEM_freeN(sp);
@@ -1074,7 +1099,9 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short
sp->pr_method = is_render ? PR_ICON_RENDER : PR_ICON_DEFERRED;
sp->pr_rect = cur_size->rect;
sp->id = ip->id;
+ sp->id_copy = ip->id_copy;
sp->bmain = ip->bmain;
+ sp->own_id_copy = false;
if (is_render) {
BLI_assert(ip->id);
@@ -1133,6 +1160,15 @@ static void icon_preview_free(void *customdata)
{
IconPreview *ip = (IconPreview *)customdata;
+ if (ip->id_copy) {
+ /* Feels a bit hacky just to reuse shader_preview_free() */
+ ShaderPreview *sp = MEM_callocN(sizeof(ShaderPreview), "Icon ShaderPreview");
+ sp->id_copy = ip->id_copy;
+ sp->own_id_copy = true;
+ shader_preview_free(sp);
+ ip->id_copy = NULL;
+ }
+
BLI_freelistN(&ip->sizes);
MEM_freeN(ip);
}
@@ -1149,6 +1185,7 @@ void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, unsigned int *rec
ip.scene = scene;
ip.owner = BKE_previewimg_id_ensure(id);
ip.id = id;
+ ip.id_copy = duplicate_ids(id, NULL);
icon_preview_add_size(&ip, rect, sizex, sizey);
@@ -1183,6 +1220,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
ip->depsgraph = CTX_data_depsgraph(C);
ip->owner = owner;
ip->id = id;
+ ip->id_copy = duplicate_ids(id, ip->depsgraph);
icon_preview_add_size(ip, rect, sizex, sizey);
@@ -1231,6 +1269,8 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
sp->sizey = sizey;
sp->pr_method = method;
sp->id = id;
+ sp->id_copy = duplicate_ids(id, sp->depsgraph);
+ sp->own_id_copy = true;
sp->parent = parent;
sp->slot = slot;
sp->bmain = CTX_data_main(C);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 31f25720f8d..8077079a9b5 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -33,6 +33,7 @@
#include "DNA_curve_types.h"
#include "DNA_lamp_types.h"
+#include "DNA_lightprobe_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
@@ -94,6 +95,8 @@
#include "RE_pipeline.h"
+#include "engines/eevee/eevee_lightcache.h"
+
#include "render_intern.h" // own include
/********************** material slot operators *********************/
@@ -615,12 +618,12 @@ void WORLD_OT_new(wmOperatorType *ot)
static int view_layer_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- WorkSpace *workspace = CTX_wm_workspace(C);
+ wmWindow *win = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = BKE_view_layer_add(scene, NULL);
- if (workspace) {
- BKE_workspace_view_layer_set(workspace, view_layer, scene);
+ if (win) {
+ WM_window_set_active_view_layer(win, view_layer);
}
DEG_id_tag_update(&scene->id, 0);
@@ -673,6 +676,184 @@ void SCENE_OT_view_layer_remove(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
}
+/********************** light cache operators *********************/
+enum {
+ LIGHTCACHE_SUBSET_ALL = 0,
+ LIGHTCACHE_SUBSET_DIRTY,
+ LIGHTCACHE_SUBSET_CUBE,
+};
+
+static void light_cache_bake_tag_cache(Scene *scene, wmOperator *op)
+{
+ if (scene->eevee.light_cache != NULL) {
+ int subset = RNA_enum_get(op->ptr, "subset");
+ switch (subset) {
+ case LIGHTCACHE_SUBSET_ALL:
+ scene->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_GRID | LIGHTCACHE_UPDATE_CUBE;
+ break;
+ case LIGHTCACHE_SUBSET_CUBE:
+ scene->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_CUBE;
+ break;
+ case LIGHTCACHE_SUBSET_DIRTY:
+ /* Leave tag untouched. */
+ break;
+ }
+ }
+}
+
+/* catch esc */
+static int light_cache_bake_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Scene *scene = (Scene *) op->customdata;
+
+ /* no running blender, remove handler and pass through */
+ if (0 == WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) {
+ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
+
+ /* running render */
+ switch (event->type) {
+ case ESCKEY:
+ return OPERATOR_RUNNING_MODAL;
+ }
+ return OPERATOR_PASS_THROUGH;
+}
+
+static void light_cache_bake_cancel(bContext *C, wmOperator *op)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ Scene *scene = (Scene *) op->customdata;
+
+ /* kill on cancel, because job is using op->reports */
+ WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER);
+}
+
+/* executes blocking render */
+static int light_cache_bake_exec(bContext *C, wmOperator *op)
+{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+
+ G.is_break = false;
+
+ /* TODO abort if selected engine is not eevee. */
+ void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, false);
+
+ light_cache_bake_tag_cache(scene, op);
+
+ short stop = 0, do_update; float progress; /* Not actually used. */
+ EEVEE_lightbake_job(rj, &stop, &do_update, &progress);
+ EEVEE_lightbake_job_data_free(rj);
+
+ // no redraw needed, we leave state as we entered it
+ ED_update_for_newframe(bmain, CTX_data_depsgraph(C));
+
+ WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+static int light_cache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win = CTX_wm_window(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ int delay = RNA_int_get(op->ptr, "delay");
+
+ wmJob *wm_job = EEVEE_lightbake_job_create(wm, win, bmain, view_layer, scene, delay);
+
+ if (!wm_job) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* add modal handler for ESC */
+ WM_event_add_modal_handler(C, op);
+
+ light_cache_bake_tag_cache(scene, op);
+
+ /* store actual owner of job, so modal operator could check for it,
+ * the reason of this is that active scene could change when rendering
+ * several layers from compositor [#31800]
+ */
+ op->customdata = scene;
+
+ WM_jobs_start(wm, wm_job);
+
+ WM_cursor_wait(0);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void SCENE_OT_light_cache_bake(wmOperatorType *ot)
+{
+ static const EnumPropertyItem light_cache_subset_items[] = {
+ {LIGHTCACHE_SUBSET_ALL, "ALL", 0, "All LightProbes", "Bake both irradiance grids and reflection cubemaps"},
+ {LIGHTCACHE_SUBSET_DIRTY, "DIRTY", 0, "Dirty Only", "Only bake lightprobes that are marked as dirty"},
+ {LIGHTCACHE_SUBSET_CUBE, "CUBEMAPS", 0, "Cubemaps Only", "Try to only bake reflection cubemaps if irradiance "
+ "grids are up to date"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Bake Light Cache";
+ ot->idname = "SCENE_OT_light_cache_bake";
+ ot->description = "Bake the active view layer lighting";
+
+ /* api callbacks */
+ ot->invoke = light_cache_bake_invoke;
+ ot->modal = light_cache_bake_modal;
+ ot->cancel = light_cache_bake_cancel;
+ ot->exec = light_cache_bake_exec;
+
+ ot->prop = RNA_def_int(ot->srna, "delay", 0, 0, 2000, "Delay", "Delay in millisecond before baking starts", 0, 2000);
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
+
+ ot->prop = RNA_def_enum(ot->srna, "subset", light_cache_subset_items, 0, "Subset", "Subset of probes to update");
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
+}
+
+static bool light_cache_free_poll(bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+
+ return scene->eevee.light_cache;
+}
+
+static int light_cache_free_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+
+ if (!scene->eevee.light_cache) {
+ return OPERATOR_CANCELLED;
+ }
+
+ EEVEE_lightcache_free(scene->eevee.light_cache);
+ scene->eevee.light_cache = NULL;
+
+ EEVEE_lightcache_info_update(&scene->eevee);
+
+ DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_light_cache_free(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Free Light Cache";
+ ot->idname = "SCENE_OT_light_cache_free";
+ ot->description = "Free cached indirect lighting";
+
+ /* api callbacks */
+ ot->exec = light_cache_free_exec;
+ ot->poll = light_cache_free_poll;
+}
+
/********************** render view operators *********************/
static bool render_view_remove_poll(bContext *C)
@@ -1654,7 +1835,7 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
if (id == NULL) {
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
- Lamp *la = CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
+ Lamp *la = CTX_data_pointer_get_type(C, "light", &RNA_Light).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;
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 97fd7295a7b..09d89e3b90f 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -144,7 +144,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
}
else {
RenderEngineType *engine_type =
- ED_view3d_engine_type(scene, v3d->drawtype);
+ ED_view3d_engine_type(scene, v3d->shading.type);
if (updated) {
DRW_notify_view_update(
(&(DRWUpdateContext){
@@ -294,9 +294,6 @@ static void world_changed(Main *UNUSED(bmain), World *wo)
/* icons */
BKE_icon_changed(BKE_icon_id_ensure(&wo->id));
- /* XXX temporary flag waiting for depsgraph proper tagging */
- wo->update_flag = 1;
-
/* glsl */
if (wo->id.recalc & ID_RECALC) {
if (!BLI_listbase_is_empty(&defmaterial.gpumaterial)) {
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index 677fc0a068e..1f4e86f89ab 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -23,9 +23,11 @@
*/
#include <stdio.h>
+#include <string.h>
#include "BLI_compiler_attrs.h"
#include "BLI_listbase.h"
+#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -80,7 +82,7 @@ Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod me
}
}
- WM_window_change_active_scene(bmain, C, win, scene_new);
+ WM_window_set_active_scene(bmain, C, win, scene_new);
WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, scene_new);
@@ -95,6 +97,10 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene)
{
Scene *scene_new;
+ /* kill running jobs */
+ wmWindowManager *wm = bmain->wm.first;
+ WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_ANY);
+
if (scene->id.prev)
scene_new = scene->id.prev;
else if (scene->id.next)
@@ -102,7 +108,7 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene)
else
return false;
- WM_window_change_active_scene(bmain, C, win, scene_new);
+ WM_window_set_active_scene(bmain, C, win, scene_new);
BKE_libblock_remap(bmain, scene, scene_new, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE);
@@ -114,43 +120,17 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene)
return true;
}
-static ViewLayer *scene_change_get_new_view_layer(const WorkSpace *workspace, const Scene *scene_new)
+/* Depsgraph updates after scene becomes active in a window. */
+void ED_scene_change_update(Main *bmain, Scene *scene, ViewLayer *layer)
{
- ViewLayer *layer_new = BKE_workspace_view_layer_exists(workspace, scene_new);
- return layer_new ? layer_new : BKE_view_layer_default_view(scene_new);
-}
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, layer, true);
-void ED_scene_change_update(
- Main *bmain, bContext *C,
- wmWindow *win, const bScreen *screen, Scene *UNUSED(scene_old), Scene *scene_new)
-{
- WorkSpace *workspace = CTX_wm_workspace(C);
- ViewLayer *layer_new = scene_change_get_new_view_layer(workspace, scene_new);
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene_new, layer_new, true);
- Object *obact_new = OBACT(layer_new);
- UNUSED_VARS(obact_new);
-
-#if 0
- /* mode syncing */
- eObjectMode object_mode_old = workspace->object_mode;
- ViewLayer *layer_old = BKE_view_layer_from_workspace_get(scene_old, workspace);
- Object *obact_old = OBACT(layer_old);
- UNUSED_VARS(obact_old, object_mode_old);
-#endif
-
- win->scene = scene_new;
- CTX_data_scene_set(C, scene_new);
- BKE_workspace_view_layer_set(workspace, layer_new, scene_new);
- BKE_scene_set_background(bmain, scene_new);
- DEG_graph_relations_update(depsgraph, bmain, scene_new, layer_new);
+ BKE_scene_set_background(bmain, scene);
+ DEG_graph_relations_update(depsgraph, bmain, scene, layer);
DEG_on_visible_update(bmain, false);
- ED_screen_update_after_scene_change(screen, scene_new, layer_new);
ED_render_engine_changed(bmain);
ED_update_for_newframe(bmain, depsgraph);
-
- /* complete redraw */
- WM_event_add_notifier(C, NC_WINDOW, NULL);
}
static bool view_layer_remove_poll(
@@ -201,12 +181,17 @@ bool ED_scene_view_layer_delete(
BLI_remlink(&scene->view_layers, layer);
BLI_assert(BLI_listbase_is_empty(&scene->view_layers) == false);
- ED_workspace_view_layer_unset(bmain, scene, layer, scene->view_layers.first);
+ /* Remove from windows. */
+ wmWindowManager *wm = bmain->wm.first;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ if (win->scene == scene && STREQ(win->view_layer_name, layer->name)) {
+ ViewLayer *first_layer = BKE_view_layer_default_view(scene);
+ STRNCPY(win->view_layer_name, first_layer->name);
+ }
+ }
BKE_view_layer_free(layer);
- BKE_workspace_view_layer_remove(bmain, layer);
-
DEG_id_tag_update(&scene->id, 0);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER | NA_REMOVED, scene);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 46bbc0fdf4f..1a63bc1cd53 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -105,12 +105,12 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides)
float color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
- immBeginAtMost(GWN_PRIM_LINES, 8);
+ immBeginAtMost(GPU_PRIM_LINES, 8);
/* right */
if (sides & REGION_EMBOSS_RIGHT) {
@@ -146,11 +146,11 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides)
void ED_region_pixelspace(ARegion *ar)
{
wmOrtho2_region_pixelspace(ar);
- gpuLoadIdentity();
+ GPU_matrix_identity_set();
}
/* only exported for WM */
-void ED_region_do_listen(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *note, const Scene *scene)
+void ED_region_do_listen(wmWindow *win, ScrArea *sa, ARegion *ar, wmNotifier *note, const Scene *scene)
{
/* generic notes first */
switch (note->category) {
@@ -164,15 +164,15 @@ void ED_region_do_listen(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *note
}
if (ar->type && ar->type->listener)
- ar->type->listener(sc, sa, ar, note, scene);
+ ar->type->listener(win, sa, ar, note, scene);
}
/* only exported for WM */
-void ED_area_do_listen(bScreen *sc, ScrArea *sa, wmNotifier *note, Scene *scene, WorkSpace *workspace)
+void ED_area_do_listen(wmWindow *win, ScrArea *sa, wmNotifier *note, Scene *scene)
{
/* no generic notes? */
if (sa->type && sa->type->listener) {
- sa->type->listener(sc, sa, note, scene, workspace);
+ sa->type->listener(win, sa, note, scene);
}
}
@@ -262,8 +262,8 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -271,7 +271,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
imm_draw_box_wire_2d(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax);
immUniformColor4f(0.0f, 1.0f, 1.0f, alpha);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, click_rect.xmin, click_rect.ymin);
immVertex2f(pos, click_rect.xmax, click_rect.ymax);
immVertex2f(pos, click_rect.xmin, click_rect.ymax);
@@ -295,8 +295,8 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2)
float width = 0.1f * U.widget_unit;
float pad = 0.2f * U.widget_unit;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPU_blend(true);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -352,8 +352,8 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- gpuPushMatrix();
- gpuTranslate2f(-ar->winrct.xmin, -ar->winrct.ymin);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(-ar->winrct.xmin, -ar->winrct.ymin);
for (az = sa->actionzones.first; az; az = az->next) {
/* test if action zone is over this region */
@@ -388,7 +388,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
}
}
- gpuPopMatrix();
+ GPU_matrix_pop();
GPU_blend(false);
}
@@ -500,8 +500,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
/* for debugging unneeded area redraws and partial redraw */
#if 0
GPU_blend(true);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(drand48(), drand48(), drand48(), 0.1f);
immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin,
@@ -1482,7 +1482,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
{
WorkSpace *workspace = WM_window_get_active_workspace(win);
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
ARegion *ar;
rcti rect, overlap_rect;
rcti window_rect;
@@ -1542,7 +1542,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV);
}
- WM_toolsystem_refresh_screen_area(workspace, scene, sa);
+ WM_toolsystem_refresh_screen_area(workspace, view_layer, sa);
}
static void region_update_rect(ARegion *ar)
@@ -2472,8 +2472,8 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(fill_color);
immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1);
@@ -2674,11 +2674,11 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
return;
/* find window pixel coordinates of origin */
- gpuPushMatrix();
+ GPU_matrix_push();
/* offset and zoom using ogl */
- gpuTranslate2f(x, y);
- gpuScale2f(zoomx, zoomy);
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_scale_2f(zoomx, zoomy);
BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi);
@@ -2691,8 +2691,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
/* set up rect */
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y);
/* draw top box */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_METADATA_BG);
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
@@ -2716,8 +2716,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
/* set up box rect */
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin);
/* draw top box */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_METADATA_BG);
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
@@ -2732,7 +2732,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
BLF_disable(blf_mono_font, BLF_CLIPPING);
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
@@ -2745,8 +2745,8 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
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);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShade(TH_BACK, 20);
@@ -2778,12 +2778,12 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
int count_large = 1.0f / (4.0f * gridstep);
if (count_fine > 0) {
- GWN_vertformat_clear(format);
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPU_vertformat_clear(format);
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ unsigned color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, 4 * count_fine + 4 * count_large);
+ immBegin(GPU_PRIM_LINES, 4 * count_fine + 4 * count_large);
float theme_color[3];
UI_GetThemeColorShade3fv(TH_BACK, (int)(20.0f * (1.0f - blendfac)), theme_color);
@@ -2877,7 +2877,7 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect)
void ED_region_cache_draw_background(const ARegion *ar)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(128, 128, 255, 64);
immRecti(pos, 0, 0, ar->winx, 8 * UI_DPI_FAC);
@@ -2897,7 +2897,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f
BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_CFRAME);
immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);
@@ -2911,7 +2911,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f
void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segments, const int *points, const int sfra, const int efra)
{
if (num_segments) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(128, 128, 255, 128);
@@ -2936,8 +2936,8 @@ void ED_region_message_subscribe(
struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
struct wmMsgBus *mbus)
{
- if (ar->manipulator_map != NULL) {
- WM_manipulatormap_message_subscribe(C, ar->manipulator_map, ar, mbus);
+ if (ar->gizmo_map != NULL) {
+ WM_gizmomap_message_subscribe(C, ar->gizmo_map, ar, mbus);
}
if (BLI_listbase_is_empty(&ar->uiblocks)) {
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 6cff82295f0..7fa093106df 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -140,9 +140,9 @@ static int get_cached_work_texture(int *r_w, int *r_h)
static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state)
{
- Gwn_VertFormat *vert_format = immVertexFormat();
- state->pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- state->texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *vert_format = immVertexFormat();
+ state->pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ state->texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
/* To be used before calling immDrawPixelsTex
@@ -297,7 +297,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_UNSIGNED_BYTE, &uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
}
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texco, (float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h);
immVertex2f(pos, rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * yzoom);
@@ -364,7 +364,7 @@ void bglPolygonOffset(float viewdist, float dist)
// glPolygonOffset(-1.0, -1.0);
/* hack below is to mimic polygon offset */
- gpuGetProjectionMatrix(winmat);
+ GPU_matrix_projection_get(winmat);
/* dist is from camera to center point */
@@ -401,7 +401,7 @@ void bglPolygonOffset(float viewdist, float dist)
offset = 0.0;
}
- gpuLoadProjectionMatrix(winmat);
+ GPU_matrix_projection_set(winmat);
}
/* **** Color management helper functions for GLSL display/transform ***** */
@@ -551,28 +551,28 @@ void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, flo
delta_y = min_ff(delta_y, border->ymax - border->ymin);
/* left bottom corner */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, border->xmin, border->ymin + delta_y);
immVertex2f(pos, border->xmin, border->ymin);
immVertex2f(pos, border->xmin + delta_x, border->ymin);
immEnd();
/* left top corner */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, border->xmin, border->ymax - delta_y);
immVertex2f(pos, border->xmin, border->ymax);
immVertex2f(pos, border->xmin + delta_x, border->ymax);
immEnd();
/* right bottom corner */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, border->xmax - delta_x, border->ymin);
immVertex2f(pos, border->xmax, border->ymin);
immVertex2f(pos, border->xmax, border->ymin + delta_y);
immEnd();
/* right top corner */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, border->xmax - delta_x, border->ymax);
immVertex2f(pos, border->xmax, border->ymax);
immVertex2f(pos, border->xmax, border->ymax - delta_y);
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index fa18826005e..17b1af29010 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -91,8 +91,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
bScreen *sc = CTX_wm_screen(C);
ScrArea *sa = CTX_wm_area(C);
Scene *scene = WM_window_get_active_scene(win);
- WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Object *obact = (view_layer && view_layer->basact) ? view_layer->basact->object : NULL;
Object *obedit = view_layer ? OBEDIT_FROM_VIEW_LAYER(view_layer) : NULL;
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index b5b0d16f6a7..10d72d74b22 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -99,7 +99,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
}
}
- immBegin(GWN_PRIM_TRI_FAN, 5);
+ immBegin(GPU_PRIM_TRI_FAN, 5);
for (i = 0; i < 5; i++) {
immVertex2f(pos, points[i].x, points[i].y);
@@ -107,7 +107,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
immEnd();
- immBegin(GWN_PRIM_TRI_FAN, 5);
+ immBegin(GPU_PRIM_TRI_FAN, 5);
for (i = 4; i < 8; i++) {
immVertex2f(pos, points[i].x, points[i].y);
@@ -180,7 +180,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
}
}
- immBegin(GWN_PRIM_TRI_FAN, 5);
+ immBegin(GPU_PRIM_TRI_FAN, 5);
for (i = 0; i < 5; i++) {
immVertex2f(pos, points[i].x, points[i].y);
@@ -188,7 +188,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
immEnd();
- immBegin(GWN_PRIM_TRI_FAN, 5);
+ immBegin(GPU_PRIM_TRI_FAN, 5);
for (i = 4; i < 8; i++) {
immVertex2f(pos, points[i].x, points[i].y);
@@ -323,11 +323,11 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey)
/* Wrap up the corners with a nice embossing. */
rcti rect = sa->totrct;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
- immBeginAtMost(GWN_PRIM_LINES, 8);
+ immBeginAtMost(GPU_PRIM_LINES, 8);
/* Right. */
immVertex2f(pos, rect.xmax, rect.ymax);
@@ -386,7 +386,7 @@ static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, shor
return;
}
- immBegin(GWN_PRIM_LINES, count);
+ immBegin(GPU_PRIM_LINES, count);
/* right border area */
if (x2 < sizex - 1) {
@@ -439,7 +439,7 @@ void ED_screen_draw_edges(wmWindow *win)
ScrArea *sa;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* Note: first loop only draws if U.pixelsize > 1, skip otherwise */
@@ -477,7 +477,7 @@ void ED_screen_draw_edges(wmWindow *win)
*/
void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_line_width(1);
@@ -518,14 +518,14 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2)
void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* splitpoint */
GPU_blend(true);
immUniformColor4ub(255, 255, 255, 100);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
if (dir == 'h') {
const float y = (1 - fac) * sa->totrct.ymin + fac * sa->totrct.ymax;
@@ -537,7 +537,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
immUniformColor4ub(0, 0, 0, 100);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, sa->totrct.xmin, y + 1);
immVertex2f(pos, sa->totrct.xmax, y + 1);
@@ -555,7 +555,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
immUniformColor4ub(0, 0, 0, 100);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, x + 1, sa->totrct.ymin);
immVertex2f(pos, x + 1, sa->totrct.ymax);
@@ -594,7 +594,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2
const float ofs_between_areas)
{
const float ofs_h = ofs_between_areas * 0.5f;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(col);
@@ -607,7 +607,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2
.ymax = sa->totrct.ymax * scale[1] - ofs_h
};
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immVertex2f(pos, rect.xmin, rect.ymin);
immVertex2f(pos, rect.xmax, rect.ymin);
immVertex2f(pos, rect.xmax, rect.ymax);
@@ -627,14 +627,14 @@ static void screen_preview_draw(const bScreen *screen, int size_x, int size_y)
wmOrtho2(0.0f, size_x, 0.0f, size_y);
/* center */
- gpuPushMatrix();
- gpuLoadIdentity();
- gpuTranslate2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f);
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
+ GPU_matrix_translate_2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f);
screen_preview_scale_get(screen, size_x, size_y, asp, scale);
screen_preview_draw_areas(screen, scale, col, 1.5f);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/**
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 6bc8a6c10cf..1d14940085b 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -381,8 +381,8 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar == screen->active_region) {
if (swin_changed || (ar->type && ar->type->event_cursor)) {
- if (ar->manipulator_map != NULL) {
- if (WM_manipulatormap_cursor_set(ar->manipulator_map, win)) {
+ if (ar->gizmo_map != NULL) {
+ if (WM_gizmomap_cursor_set(ar->gizmo_map, win)) {
return;
}
}
@@ -477,8 +477,8 @@ void ED_screens_initialize(Main *bmain, wmWindowManager *wm)
wmWindow *win;
for (win = wm->windows.first; win; win = win->next) {
- if (WM_window_get_active_workspace(win) == NULL) {
- WM_window_set_active_workspace(win, bmain->workspaces.first);
+ if (BKE_workspace_active_get(win->workspace_hook) == NULL) {
+ BKE_workspace_active_set(win->workspace_hook, bmain->workspaces.first);
}
if (BLI_listbase_is_empty(&win->global_areas.areabase)) {
@@ -792,11 +792,19 @@ static void screen_global_statusbar_area_create(wmWindow *win)
void ED_screen_global_areas_create(wmWindow *win)
{
+ /* Don't create global areas for child windows. */
+ if (win->parent) {
+ return;
+ }
+
+ /* Don't create global area for temporary windows. */
bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- if (screen->temp == 0) {
- screen_global_topbar_area_create(win);
- screen_global_statusbar_area_create(win);
+ if (screen->temp) {
+ return;
}
+
+ screen_global_topbar_area_create(win);
+ screen_global_statusbar_area_create(win);
}
@@ -936,13 +944,41 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre
}
}
-void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new, ViewLayer *view_layer)
+void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene)
{
+#if 0
+ ViewLayer *view_layer_old = WM_window_get_active_view_layer(win);
+#endif
+
+ /* Switch scene. */
+ win->scene = scene;
+ if (CTX_wm_window(C) == win) {
+ CTX_data_scene_set(C, scene);
+ }
+
+ /* Ensure the view layer name is updated. */
+ WM_window_ensure_active_view_layer(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+#if 0
+ /* Mode Syncing. */
+ if (view_layer_old) {
+ WorkSpace *workspace = CTX_wm_workspace(C);
+ Object *obact_new = OBACT(view_layer);
+ UNUSED_VARS(obact_new);
+ eObjectMode object_mode_old = workspace->object_mode;
+ Object *obact_old = OBACT(view_layer_old);
+ UNUSED_VARS(obact_old, object_mode_old);
+ }
+#endif
+
+ /* Update 3D view cameras. */
+ const bScreen *screen = WM_window_get_active_screen(win);
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- screen_set_3dview_camera(scene_new, view_layer, sa, v3d);
+ screen_set_3dview_camera(scene, view_layer, sa, v3d);
}
}
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index fb269740109..e2d6a9aa6ca 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -753,7 +753,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
if (az->direction == AZ_SCROLL_HOR) {
az->alpha = 1.0f;
v2d->alpha_hor = 255;
- v2d->size_hor = V2D_SCROLL_HEIGHT;
redraw = true;
}
}
@@ -761,7 +760,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
if (az->direction == AZ_SCROLL_VERT) {
az->alpha = 1.0f;
v2d->alpha_vert = 255;
- v2d->size_vert = V2D_SCROLL_WIDTH;
redraw = true;
}
}
@@ -775,9 +773,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
alpha = 1.0f - dist_fac;
v2d->alpha_hor = alpha * 255;
- v2d->size_hor = round_fl_to_int(
- V2D_SCROLL_HEIGHT -
- ((V2D_SCROLL_HEIGHT - V2D_SCROLL_HEIGHT_MIN) * dist_fac));
}
else if (az->direction == AZ_SCROLL_VERT) {
dist_fac = BLI_rcti_length_x(&v2d->vert, local_xy[0]) / AZONEFADEIN;
@@ -785,9 +780,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
alpha = 1.0f - dist_fac;
v2d->alpha_vert = alpha * 255;
- v2d->size_vert = round_fl_to_int(
- V2D_SCROLL_WIDTH -
- ((V2D_SCROLL_WIDTH - V2D_SCROLL_WIDTH_MIN) * dist_fac));
}
az->alpha = alpha;
redraw = true;
@@ -1140,7 +1132,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
newwin->scene = scene;
- WM_window_set_active_workspace(newwin, workspace);
+ BKE_workspace_active_set(newwin->workspace_hook, workspace);
/* allocs new screen and adds to newly created window, using window size */
layout_new = ED_workspace_layout_add(bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old));
newsc = BKE_workspace_layout_screen_get(layout_new);
@@ -1219,11 +1211,11 @@ typedef struct sAreaMoveData {
SNAP_NONE = 0,
/* Snap to an invisible grid with a unit defined in AREAGRID */
SNAP_AREAGRID,
- /* Snap to mid-point and adjacent edges. */
- SNAP_MIDPOINT_AND_ADJACENT,
+ /* Snap to fraction (half, third.. etc) and adjacent edges. */
+ SNAP_FRACTION_AND_ADJACENT,
/* Snap to either bigger or smaller, nothing in-between (used for
* global areas). This has priority over other snap types, if it is
- * used, toggling SNAP_MIDPOINT_AND_ADJACENT doesn't work. */
+ * used, toggling SNAP_FRACTION_AND_ADJACENT doesn't work. */
SNAP_BIGGER_SMALLER_ONLY,
} snap_type;
} sAreaMoveData;
@@ -1368,32 +1360,50 @@ static int area_snap_calc_location(
const int bigger, const int smaller)
{
BLI_assert(snap_type != SNAP_NONE);
- int final_loc = -1;
- const int m_loc = origval + delta;
+ int m_cursor_final = -1;
+ const int m_cursor = origval + delta;
+ const int m_span = (float)(bigger + smaller);
+ const int m_min = origval - smaller;
+ // const int axis_max = axis_min + m_span;
switch (snap_type) {
case SNAP_AREAGRID:
- final_loc = m_loc;
+ m_cursor_final = m_cursor;
if (delta != bigger && delta != -smaller) {
- final_loc -= (m_loc % AREAGRID);
- CLAMP(final_loc, origval - smaller, origval + bigger);
+ m_cursor_final -= (m_cursor % AREAGRID);
+ CLAMP(m_cursor_final, origval - smaller, origval + bigger);
}
break;
case SNAP_BIGGER_SMALLER_ONLY:
- final_loc = (m_loc >= bigger) ? bigger : smaller;
+ m_cursor_final = (m_cursor >= bigger) ? bigger : smaller;
break;
- case SNAP_MIDPOINT_AND_ADJACENT:
+ case SNAP_FRACTION_AND_ADJACENT:
{
const int axis = (dir == 'v') ? 0 : 1;
- int snap_dist;
- int dist;
+ int snap_dist_best = INT_MAX;
{
- /* Test the snap to middle. */
- int middle = origval + (bigger - smaller) / 2;
- snap_dist = abs(m_loc - middle);
- final_loc = middle;
+ const float div_array[] = {
+ /* Middle. */
+ 1.0f / 2.0f,
+ /* Thirds. */
+ 1.0f / 3.0f, 2.0f / 3.0f,
+ /* Quaters. */
+ 1.0f / 4.0f, 3.0f / 4.0f,
+ /* Eighth. */
+ 1.0f / 8.0f, 3.0f / 8.0f,
+ 5.0f / 8.0f, 7.0f / 8.0f,
+ };
+ /* Test the snap to the best division. */
+ for (int i = 0; i < ARRAY_SIZE(div_array); i++) {
+ const int m_cursor_test = m_min + round_fl_to_int(m_span * div_array[i]);
+ const int snap_dist_test = abs(m_cursor - m_cursor_test);
+ if (snap_dist_best >= snap_dist_test) {
+ snap_dist_best = snap_dist_test;
+ m_cursor_final = m_cursor_test;
+ }
+ }
}
for (const ScrVert *v1 = sc->vertbase.first; v1; v1 = v1->next) {
@@ -1410,10 +1420,10 @@ static int area_snap_calc_location(
const int v_loc2 = (&v2->vec.x)[axis];
/* Do not snap to the vertices at the ends. */
if ((origval - smaller) < v_loc2 && v_loc2 < (origval + bigger)) {
- dist = abs(m_loc - v_loc2);
- if (dist <= snap_dist) {
- snap_dist = dist;
- final_loc = v_loc2;
+ const int snap_dist_test = abs(m_cursor - v_loc2);
+ if (snap_dist_best >= snap_dist_test) {
+ snap_dist_best = snap_dist_test;
+ m_cursor_final = v_loc2;
}
}
}
@@ -1426,9 +1436,9 @@ static int area_snap_calc_location(
}
BLI_assert(ELEM(snap_type, SNAP_BIGGER_SMALLER_ONLY) ||
- IN_RANGE_INCL(final_loc, origval - smaller, origval + bigger));
+ IN_RANGE_INCL(m_cursor_final, origval - smaller, origval + bigger));
- return final_loc;
+ return m_cursor_final;
}
/* moves selected screen edge amount of delta, used by split & move */
@@ -1580,7 +1590,7 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
case KM_MODAL_SNAP_ON:
if (md->snap_type != SNAP_BIGGER_SMALLER_ONLY) {
- md->snap_type = SNAP_MIDPOINT_AND_ADJACENT;
+ md->snap_type = SNAP_FRACTION_AND_ADJACENT;
}
break;
@@ -2062,7 +2072,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (sd->previewmode == 0) {
if (sd->do_snap) {
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ CTX_wm_screen(C), SNAP_FRACTION_AND_ADJACENT, sd->delta, sd->origval, dir,
sd->bigger, sd->smaller);
sd->delta = snap_loc - sd->origval;
}
@@ -2090,7 +2100,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1;
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ CTX_wm_screen(C), SNAP_FRACTION_AND_ADJACENT, sd->delta, sd->origval, dir,
sd->origmin + sd->origsize, -sd->origmin);
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0;
@@ -3669,27 +3679,38 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
/** \name Header Tools Operator
* \{ */
+static bool header_context_menu_poll(bContext *C)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ return (sa && sa->spacetype != SPACE_STATUSBAR);
+}
+
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : IFACE_("Flip to Top");
- uiItemO(layout, IFACE_("Toggle Header"), ICON_NONE, "SCREEN_OT_header");
+ if (!ELEM(sa->spacetype, SPACE_TOPBAR)) {
+ uiItemO(layout, IFACE_("Toggle Header"), ICON_NONE, "SCREEN_OT_header");
+ }
/* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
- uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
+ if (!ELEM(sa->spacetype, SPACE_TOPBAR)) {
+ uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
+ }
+
uiItemO(layout, IFACE_("Collapse Menus"),
(sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
"SCREEN_OT_header_toggle_menus");
- uiItemS(layout);
-
/* file browser should be fullscreen all the time, topbar should
* never be. But other regions can be maximized/restored... */
if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
+ uiItemS(layout);
+
const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area");
}
@@ -3718,6 +3739,7 @@ static void SCREEN_OT_header_context_menu(wmOperatorType *ot)
ot->idname = "SCREEN_OT_header_context_menu";
/* api callbacks */
+ ot->poll = header_context_menu_poll;
ot->invoke = header_context_menu_invoke;
}
@@ -4866,8 +4888,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
#endif
- WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
- kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "use_hide_panels", true);
#ifdef USE_WM_KEYMAP_27X
@@ -4886,9 +4908,11 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
/* tests */
WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
+
+ WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0);
+
#ifdef USE_WM_KEYMAP_27X
WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", RKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
- WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "SCRIPT_OT_reload", F8KEY, KM_PRESS, 0, 0);
@@ -4966,9 +4990,19 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "next", false);
+#ifdef USE_WM_KEYMAP_27X
/* play (forward and backwards) */
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0);
- RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, "reverse", true);
+ RNA_boolean_set(
+ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr,
+ "reverse", true);
+#else
+ /* play (forward and backwards) */
+ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(
+ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr,
+ "reverse", true);
+#endif
WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", MEDIAPLAY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 9d329355500..e54a764faa7 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -75,55 +75,33 @@
* \brief API for managing workspaces and their data.
* \{ */
-WorkSpace *ED_workspace_add(
- Main *bmain, const char *name, Scene *scene,
- ViewLayer *act_view_layer)
+WorkSpace *ED_workspace_add(Main *bmain, const char *name)
{
- WorkSpace *workspace = BKE_workspace_add(bmain, name);
-
- BKE_workspace_view_layer_set(workspace, act_view_layer, scene);
-
- return workspace;
+ return BKE_workspace_add(bmain, name);
}
/**
* Changes the object mode (if needed) to the one set in \a workspace_new.
* Object mode is still stored on object level. In future it should all be workspace level instead.
*/
-static void workspace_change_update_mode(
- const WorkSpace *workspace_old, const WorkSpace *workspace_new,
- bContext *C, Object *ob_act, ReportList *reports)
+static void workspace_change_update(
+ WorkSpace *workspace_new, const WorkSpace *workspace_old,
+ bContext *C, wmWindowManager *wm)
{
- UNUSED_VARS(workspace_old, workspace_new, C, ob_act, reports);
+ /* needs to be done before changing mode! (to ensure right context) */
+ UNUSED_VARS(workspace_old, workspace_new, C, wm);
#if 0
+ Object *ob_act = CTX_data_active_object(C)
eObjectMode mode_old = workspace_old->object_mode;
eObjectMode mode_new = workspace_new->object_mode;
if (mode_old != mode_new) {
- ED_object_mode_compat_set(C, ob_act, mode_new, reports);
+ ED_object_mode_compat_set(C, ob_act, mode_new, &wm->reports);
ED_object_mode_toggle(C, mode_new);
}
#endif
}
-static void workspace_change_update_view_layer(
- WorkSpace *workspace_new, const WorkSpace *workspace_old,
- Scene *scene)
-{
- if (!BKE_workspace_view_layer_exists(workspace_new, scene)) {
- BKE_workspace_view_layer_set(workspace_new, BKE_workspace_view_layer_get(workspace_old, scene), scene);
- }
-}
-
-static void workspace_change_update(
- WorkSpace *workspace_new, const WorkSpace *workspace_old,
- bContext *C, wmWindowManager *wm)
-{
- /* needs to be done before changing mode! (to ensure right context) */
- workspace_change_update_view_layer(workspace_new, workspace_old, CTX_data_scene(C));
- workspace_change_update_mode(workspace_old, workspace_new, C, CTX_data_active_object(C), &wm->reports);
-}
-
static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, void *UNUSED(arg))
{
/* return false to stop the iterator if we've found a layout that can be activated */
@@ -134,6 +112,7 @@ static WorkSpaceLayout *workspace_change_get_new_layout(
Main *bmain, WorkSpace *workspace_new, wmWindow *win)
{
/* ED_workspace_duplicate may have stored a layout to activate once the workspace gets activated. */
+ WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
WorkSpaceLayout *layout_new;
bScreen *screen_new;
@@ -154,8 +133,8 @@ static WorkSpaceLayout *workspace_change_get_new_layout(
workspace_new, layout_new, workspace_change_find_new_layout_cb,
NULL, false);
if (!layout_temp) {
- /* fallback solution: duplicate layout */
- layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_new, win);
+ /* fallback solution: duplicate layout from old workspace */
+ layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_old, win);
}
layout_new = layout_temp;
}
@@ -191,15 +170,14 @@ bool ED_workspace_change(
BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new);
if (screen_new) {
- WM_window_set_active_layout(win, workspace_new, layout_new);
- WM_window_set_active_workspace(win, workspace_new);
+ BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new);
+ BKE_workspace_active_set(win->workspace_hook, workspace_new);
/* update screen *after* changing workspace - which also causes the
* actual screen change and updates context (including CTX_wm_workspace) */
screen_change_update(C, win, screen_new);
workspace_change_update(workspace_new, workspace_old, C, wm);
- BLI_assert(BKE_workspace_view_layer_exists(workspace_new, CTX_data_scene(C)) != NULL);
BLI_assert(CTX_wm_workspace(C) == workspace_new);
WM_toolsystem_unlink_all(C, workspace_old);
@@ -220,10 +198,7 @@ WorkSpace *ED_workspace_duplicate(
{
WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook);
ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old);
- Scene *scene = WM_window_get_active_scene(win);
- WorkSpace *workspace_new = ED_workspace_add(
- bmain, workspace_old->id.name + 2, scene,
- BKE_workspace_view_layer_get(workspace_old, scene));
+ WorkSpace *workspace_new = ED_workspace_add(bmain, workspace_old->id.name + 2);
/* TODO(campbell): tools */
@@ -271,17 +246,6 @@ void ED_workspace_scene_data_sync(
BKE_screen_view3d_scene_sync(screen, scene);
}
-void ED_workspace_view_layer_unset(
- const Main *bmain, Scene *scene,
- const ViewLayer *layer_unset, ViewLayer *layer_new)
-{
- for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
- if (BKE_workspace_view_layer_get(workspace, scene) == layer_unset) {
- BKE_workspace_view_layer_set(workspace, layer_new, scene);
- }
- }
-}
-
/** \} Workspace API */
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 815bcd8a050..997fe1282f9 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -618,19 +618,19 @@ static void paint_draw_tex_overlay(
glDepthFunc(GL_ALWAYS);
if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
- gpuPushMatrix();
+ GPU_matrix_push();
/* brush rotation */
- gpuTranslate2f(x, y);
- gpuRotate2D(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec));
- gpuTranslate2f(-x, -y);
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_rotate_2d(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec));
+ GPU_matrix_translate_2f(-x, -y);
/* scale based on tablet pressure */
if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
const float scale = ups->size_pressure_value;
- gpuTranslate2f(x, y);
- gpuScale2f(scale, scale);
- gpuTranslate2f(-x, -y);
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_scale_2f(scale, scale);
+ GPU_matrix_translate_2f(-x, -y);
}
if (ups->draw_anchored) {
@@ -671,18 +671,18 @@ static void paint_draw_tex_overlay(
quad.xmax = brush->mask_stencil_dimension[0];
quad.ymax = brush->mask_stencil_dimension[1];
}
- gpuPushMatrix();
+ GPU_matrix_push();
if (primary)
- gpuTranslate2fv(brush->stencil_pos);
+ GPU_matrix_translate_2fv(brush->stencil_pos);
else
- gpuTranslate2fv(brush->mask_stencil_pos);
- gpuRotate2D(RAD2DEGF(mtex->rot));
+ GPU_matrix_translate_2fv(brush->mask_stencil_pos);
+ GPU_matrix_rotate_2d(RAD2DEGF(mtex->rot));
}
/* set quad color. Colored overlay does not get blending */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (col) {
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
@@ -696,7 +696,7 @@ static void paint_draw_tex_overlay(
/* draw textured quad */
immUniform1i("image", GL_TEXTURE0);
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texCoord, 0.0f, 0.0f);
immVertex2f(pos, quad.xmin, quad.ymin);
immAttrib2f(texCoord, 1.0f, 0.0f);
@@ -710,7 +710,7 @@ static void paint_draw_tex_overlay(
immUnbindProgram();
if (ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_VIEW)) {
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
}
@@ -762,16 +762,16 @@ static void paint_draw_cursor_overlay(
/* scale based on tablet pressure */
if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
do_pop = true;
- gpuPushMatrix();
- gpuLoadIdentity();
- gpuTranslate2fv(center);
- gpuScaleUniform(ups->size_pressure_value);
- gpuTranslate2f(-center[0], -center[1]);
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
+ GPU_matrix_translate_2fv(center);
+ GPU_matrix_scale_1f(ups->size_pressure_value);
+ GPU_matrix_translate_2f(-center[0], -center[1]);
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
@@ -782,7 +782,7 @@ static void paint_draw_cursor_overlay(
/* draw textured quad */
immUniform1i("image", 0);
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texCoord, 0.0f, 0.0f);
immVertex2f(pos, quad.xmin, quad.ymin);
immAttrib2f(texCoord, 1.0f, 0.0f);
@@ -796,7 +796,7 @@ static void paint_draw_cursor_overlay(
immUnbindProgram();
if (do_pop)
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
@@ -844,7 +844,7 @@ BLI_INLINE void draw_tri_point(
{co[0] + w, co[1] - w},
};
- immBegin(GWN_PRIM_LINE_LOOP, 3);
+ immBegin(GPU_PRIM_LINE_LOOP, 3);
immVertex2fv(pos, tri[0]);
immVertex2fv(pos, tri[1]);
immVertex2fv(pos, tri[2]);
@@ -853,7 +853,7 @@ BLI_INLINE void draw_tri_point(
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
GPU_line_width(1.0f);
- immBegin(GWN_PRIM_LINE_LOOP, 3);
+ immBegin(GPU_PRIM_LINE_LOOP, 3);
immVertex2fv(pos, tri[0]);
immVertex2fv(pos, tri[1]);
immVertex2fv(pos, tri[2]);
@@ -888,7 +888,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
GPU_line_width(3.0f);
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2fv(pos, bez->vec[0]);
immVertex2fv(pos, bez->vec[1]);
immVertex2fv(pos, bez->vec[2]);
@@ -902,7 +902,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez
else {
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
}
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(pos, bez->vec[0]);
immVertex2fv(pos, bez->vec[1]);
immEnd();
@@ -913,7 +913,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez
else {
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
}
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(pos, bez->vec[1]);
immVertex2fv(pos, bez->vec[2]);
immEnd();
@@ -930,7 +930,7 @@ static void paint_draw_curve_cursor(Brush *brush)
GPU_blend(true);
/* draw the bezier handles and the curve segment between the current and next point */
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -961,7 +961,7 @@ static void paint_draw_curve_cursor(Brush *brush)
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
GPU_line_width(3.0f);
- immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) {
immVertex2fv(pos, v[j]);
}
@@ -969,7 +969,7 @@ static void paint_draw_curve_cursor(Brush *brush)
immUniformColor4f(0.9f, 0.9f, 1.0f, 0.5f);
GPU_line_width(1.0f);
- immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) {
immVertex2fv(pos, v[j]);
}
@@ -1118,7 +1118,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
GPU_blend(true); /* TODO: also set blend mode? */
GPU_line_smooth(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* set brush color */
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 7f71270c52d..897a74eb497 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -419,15 +419,15 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda
GPU_line_smooth(true);
GPU_blend(true);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_line_width(4.0);
immUniformColor4ub(0, 0, 0, 255);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2i(pos, x, y);
immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]);
immEnd();
@@ -435,7 +435,7 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda
GPU_line_width(2.0);
immUniformColor4ub(255, 255, 255, 255);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2i(pos, x, y);
immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]);
immEnd();
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 04329697b54..7badd30e6d0 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5442,7 +5442,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (h > maxsize) h = maxsize;
ibuf = ED_view3d_draw_offscreen_imbuf(
- depsgraph, scene, v3d->drawtype,
+ depsgraph, scene, v3d->shading.type,
v3d, CTX_wm_region(C),
w, h, IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL,
NULL, err_out);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 9f14a821613..0f796020d9e 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -1393,7 +1393,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap = WM_keymap_find(keyconf, "Weight Paint Vertex Selection", 0, 0);
keymap->poll = vert_paint_poll;
kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
@@ -1436,7 +1438,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap->poll = facemask_paint_poll;
kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 8db78a41252..fc008213ae0 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -155,11 +155,11 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata
ARegion *ar = stroke->vc.ar;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv(paint->paint_cursor_col);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, x, y);
immVertex2f(pos,
stroke->last_mouse_position[0] + ar->winrct.xmin,
@@ -181,7 +181,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
GPU_line_smooth(true);
- uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -194,7 +194,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
immUniformArray4fv("colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2);
immUniform1f("dash_width", 6.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
ARegion *ar = stroke->vc.ar;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 697ffc32759..e914a24092e 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -299,8 +299,8 @@ static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, unsig
/* get the needed opengl matrices */
GPU_viewport_size_get_i(view);
- gpuGetModelViewMatrix(matrix);
- gpuGetProjectionMatrix(proj);
+ GPU_matrix_model_view_get(matrix);
+ GPU_matrix_projection_get(proj);
view[0] = view[1] = 0;
mul_m4_m4m4(matrix, matrix, ob_eval->obmat);
mul_m4_m4m4(matrix, proj, matrix);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index a5871c90d56..77f4da2d16b 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3522,13 +3522,16 @@ static void sculpt_topology_update(Sculpt *sd, Object *ob, Brush *brush, Unified
PBVHTopologyUpdateMode mode = 0;
float location[3];
- if (sd->flags & SCULPT_DYNTOPO_SUBDIVIDE)
- mode |= PBVH_Subdivide;
+ if (!(sd->flags & SCULPT_DYNTOPO_DETAIL_MANUAL)) {
+ if (sd->flags & SCULPT_DYNTOPO_SUBDIVIDE) {
+ mode |= PBVH_Subdivide;
+ }
- if ((sd->flags & SCULPT_DYNTOPO_COLLAPSE) ||
- (brush->sculpt_tool == SCULPT_TOOL_SIMPLIFY))
- {
- mode |= PBVH_Collapse;
+ if ((sd->flags & SCULPT_DYNTOPO_COLLAPSE) ||
+ (brush->sculpt_tool == SCULPT_TOOL_SIMPLIFY))
+ {
+ mode |= PBVH_Collapse;
+ }
}
for (n = 0; n < totnode; n++) {
@@ -4867,6 +4870,8 @@ static void sculpt_flush_update(bContext *C)
if (mmd)
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ DEG_id_tag_update(&ob->id, DEG_TAG_SHADING_UPDATE);
+
if (ss->kb || ss->modifiers_active) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
ED_region_tag_redraw(ar);
@@ -4952,7 +4957,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
sculpt_update_cache_variants(C, sd, ob, itemptr);
sculpt_restore_mesh(sd, ob);
- if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) {
+ if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) {
BKE_pbvh_bmesh_detail_size_set(ss->pbvh, 1.0f / sd->constant_detail);
}
else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
@@ -5733,8 +5738,6 @@ void ED_object_sculptmode_enter_ex(
}
}
- // ED_workspace_object_mode_sync_from_object(bmain->wm.first, workspace, ob);
-
/* Flush object mode. */
DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
}
@@ -5785,8 +5788,6 @@ void ED_object_sculptmode_exit_ex(
/* Leave sculptmode */
ob->mode &= ~mode_flag;
- // ED_workspace_object_mode_sync_from_object(G_MAIN->wm.first, workspace, ob);
-
BKE_sculptsession_free(ob);
paint_cursor_delete_textures();
@@ -5852,13 +5853,13 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
-static bool sculpt_and_dynamic_topology_constant_detail_poll(bContext *C)
+static bool sculpt_and_constant_or_manual_detail_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- return sculpt_mode_poll(C) && ob->sculpt->bm && (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT);
+ return sculpt_mode_poll(C) && ob->sculpt->bm &&
+ (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL));
}
static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
@@ -5920,7 +5921,7 @@ static void SCULPT_OT_detail_flood_fill(wmOperatorType *ot)
/* api callbacks */
ot->exec = sculpt_detail_flood_fill_exec;
- ot->poll = sculpt_and_dynamic_topology_constant_detail_poll;
+ ot->poll = sculpt_and_constant_or_manual_detail_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -6018,7 +6019,7 @@ static void SCULPT_OT_sample_detail_size(wmOperatorType *ot)
ot->invoke = sculpt_sample_detail_size_invoke;
ot->exec = sculpt_sample_detail_size_exec;
ot->modal = sculpt_sample_detail_size_modal;
- ot->poll = sculpt_and_dynamic_topology_constant_detail_poll;
+ ot->poll = sculpt_and_constant_or_manual_detail_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -6036,7 +6037,7 @@ static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op))
WM_operator_properties_create_ptr(&props_ptr, ot);
- if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) {
+ if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) {
set_brush_rc_props(&props_ptr, "sculpt", "constant_detail_resolution", NULL, 0);
RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.constant_detail_resolution");
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index bc22147b15d..b78d030407b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -493,7 +493,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
}
}
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, DEG_TAG_SHADING_UPDATE);
BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask);
@@ -931,9 +931,10 @@ SculptUndoNode *sculpt_undo_push_node(
unode = sculpt_undo_alloc_node(ob, node, type);
- BLI_thread_unlock(LOCK_CUSTOM1);
-
- /* copy threaded, hopefully this is the performance critical part */
+ /* NOTE: If this ever becomes a bottleneck, make a lock inside of the node.
+ * so we release global lock sooner, but keep data locked for until it is
+ * fully initialized.
+ */
if (unode->grids) {
int totgrid, *grids;
@@ -970,6 +971,8 @@ SculptUndoNode *sculpt_undo_push_node(
if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name));
else unode->shapeName[0] = '\0';
+ BLI_thread_unlock(LOCK_CUSTOM1);
+
return unode;
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 29b258fc80d..8fafc545fa9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -215,7 +215,7 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu
alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
}
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fvAlpha(brush->add_col, alpha);
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 6105652a4c7..e679688f887 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -211,8 +211,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* first backdrop strips */
y = (float)(-ACHANNEL_HEIGHT(ac));
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -326,7 +326,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
if (saction->flag & SACTION_MOVING) {
immUniformColor3f(0.0f, 0.0f, 0.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD);
immVertex2f(pos, saction->timeslide, v2d->cur.ymax);
immEnd();
@@ -404,7 +404,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* iterate over pointcaches on the active object, and draw each one's range */
@@ -436,9 +436,9 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
if (pid->cache->cached_frames == NULL)
continue;
- gpuPushMatrix();
- gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT_TEXT + yoffs);
- gpuScale2f(1.0, cache_draw_height);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(0.0, (float)V2D_SCROLL_HEIGHT_TEXT + yoffs);
+ GPU_matrix_scale_2f(1.0, cache_draw_height);
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
@@ -492,7 +492,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
immUniformColor4fv(col);
if (len > 0) {
- immBeginAtMost(GWN_PRIM_TRIS, len);
+ immBeginAtMost(GPU_PRIM_TRIS, len);
/* draw a quad for each cached frame */
for (int i = sta; i <= end; i++) {
@@ -512,7 +512,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
GPU_blend(false);
- gpuPopMatrix();
+ GPU_matrix_pop();
yoffs += cache_draw_height;
}
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index fc1f40cdb5a..bb8de677b57 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -62,7 +62,7 @@ void timeline_draw_cache(struct SpaceAction *saction, struct Object *ob, struct
/* ***************************************** */
/* action_select.c */
-void ACTION_OT_select_all_toggle(struct wmOperatorType *ot);
+void ACTION_OT_select_all(struct wmOperatorType *ot);
void ACTION_OT_select_border(struct wmOperatorType *ot);
void ACTION_OT_select_lasso(struct wmOperatorType *ot);
void ACTION_OT_select_circle(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index bf7f75db95c..a4b96e76066 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -39,6 +39,7 @@
#include "ED_anim_api.h"
#include "ED_markers.h"
#include "ED_transform.h"
+#include "ED_object.h"
#include "action_intern.h"
@@ -57,7 +58,7 @@ void action_operatortypes(void)
/* keyframes */
/* selection */
WM_operatortype_append(ACTION_OT_clickselect);
- WM_operatortype_append(ACTION_OT_select_all_toggle);
+ WM_operatortype_append(ACTION_OT_select_all);
WM_operatortype_append(ACTION_OT_select_border);
WM_operatortype_append(ACTION_OT_select_lasso);
WM_operatortype_append(ACTION_OT_select_circle);
@@ -169,10 +170,12 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
/* deselect all */
- kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
- RNA_boolean_set(kmi->ptr, "invert", false);
- kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
- RNA_boolean_set(kmi->ptr, "invert", true);
+ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", AKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
+ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
/* borderselect */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0);
@@ -208,7 +211,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
/* menu + single-step transform */
WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0);
/* menu + set setting */
WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0);
@@ -220,7 +223,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
WM_keymap_add_menu(keymap, "DOPESHEET_MT_specials", WKEY, KM_PRESS, 0, 0);
/* destructive */
- WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", DELKEY, KM_PRESS, 0, 0);
@@ -264,6 +267,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_action");
+ ED_keymap_proportional_cycle(keyconf, keymap);
/* special markers hotkeys for anim editors: see note in definition of this function */
ED_marker_keymap_animedit_conflictfree(keymap);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 11145e29627..c46d0fdb035 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -157,10 +157,24 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
/* 'standard' behavior - check if selected, then apply relevant selection */
- if (RNA_boolean_get(op->ptr, "invert"))
- deselect_action_keys(&ac, 0, SELECT_INVERT);
- else
- deselect_action_keys(&ac, 1, SELECT_ADD);
+ const int action = RNA_enum_get(op->ptr, "action");
+ switch (action) {
+ case SEL_TOGGLE:
+ deselect_action_keys(&ac, 1, SELECT_ADD);
+ break;
+ case SEL_SELECT:
+ deselect_action_keys(&ac, 0, SELECT_ADD);
+ break;
+ case SEL_DESELECT:
+ deselect_action_keys(&ac, 0, SELECT_SUBTRACT);
+ break;
+ case SEL_INVERT:
+ deselect_action_keys(&ac, 0, SELECT_INVERT);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
@@ -168,11 +182,11 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void ACTION_OT_select_all_toggle(wmOperatorType *ot)
+void ACTION_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Select All";
- ot->idname = "ACTION_OT_select_all_toggle";
+ ot->idname = "ACTION_OT_select_all";
ot->description = "Toggle selection of all keyframes";
/* api callbacks */
@@ -182,9 +196,8 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* props */
- ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
- RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
+ /* properties */
+ WM_operator_properties_select_all(ot);
}
/* ******************** Border Select Operator **************************** */
@@ -1356,7 +1369,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
rctf rectf;
/* get dopesheet info */
- if (ac->datatype == ANIMCONT_DOPESHEET)
+ if (ELEM(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE))
ads = ac->data;
/* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */
@@ -1477,7 +1490,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
deselect_action_keys(ac, 0, SELECT_SUBTRACT);
/* highlight channel clicked on */
- if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) {
+ if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) {
/* deselect all other channels first */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 876b73a4a76..363c30427db 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -341,7 +341,7 @@ static void action_header_region_draw(const bContext *C, ARegion *ar)
}
static void action_channel_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -432,7 +432,7 @@ static void saction_channel_region_message_subscribe(
}
static void action_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -531,8 +531,7 @@ static void saction_main_region_message_subscribe(
/* editor level listener */
static void action_listener(
- bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+ wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
@@ -686,7 +685,7 @@ static void action_listener(
}
static void action_header_region_listener(
- bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
@@ -760,7 +759,7 @@ static void action_buttons_area_draw(const bContext *C, ARegion *ar)
}
static void action_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 2ee791e81d6..7246812dc82 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -67,7 +67,7 @@
#include "ED_clip.h"
#include "ED_mask.h"
#include "ED_sequencer.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "io_ops.h"
@@ -129,22 +129,22 @@ void ED_spacetypes_init(void)
ED_screen_user_menu_register();
- /* manipulator types */
- ED_manipulatortypes_button_2d();
- ED_manipulatortypes_dial_3d();
- ED_manipulatortypes_grab_3d();
- ED_manipulatortypes_arrow_2d();
- ED_manipulatortypes_arrow_3d();
- ED_manipulatortypes_primitive_3d();
- ED_manipulatortypes_cage_2d();
- ED_manipulatortypes_cage_3d();
-
- /* register types for operators and manipulators */
+ /* gizmo types */
+ ED_gizmotypes_button_2d();
+ ED_gizmotypes_dial_3d();
+ ED_gizmotypes_grab_3d();
+ ED_gizmotypes_arrow_2d();
+ ED_gizmotypes_arrow_3d();
+ ED_gizmotypes_primitive_3d();
+ ED_gizmotypes_cage_2d();
+ ED_gizmotypes_cage_3d();
+
+ /* register types for operators and gizmos */
spacetypes = BKE_spacetypes_list();
for (type = spacetypes->first; type; type = type->next) {
- /* init manipulator types first, operator-types need them */
- if (type->manipulators) {
- type->manipulators();
+ /* init gizmo types first, operator-types need them */
+ if (type->gizmos) {
+ type->gizmos();
}
if (type->operatortypes) {
type->operatortypes();
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index dd943e7988d..faee9c2b7ac 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -47,6 +47,7 @@
#include "DNA_world_types.h"
#include "DNA_brush_types.h"
#include "DNA_linestyle_types.h"
+#include "DNA_windowmanager_types.h"
#include "BKE_context.h"
#include "BKE_action.h"
@@ -70,6 +71,8 @@
#include "UI_interface.h"
#include "UI_resources.h"
+#include "WM_api.h"
+
#include "buttons_intern.h" // own include
static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
@@ -114,11 +117,13 @@ static int buttons_context_path_scene(ButsContextPath *path)
return RNA_struct_is_a(ptr->type, &RNA_Scene);
}
-static int buttons_context_path_view_layer(ButsContextPath *path, WorkSpace *workspace)
+static int buttons_context_path_view_layer(ButsContextPath *path, wmWindow *win)
{
if (buttons_context_path_scene(path)) {
Scene *scene = path->ptr[path->len - 1].data;
- ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
+ ViewLayer *view_layer = (win->scene == scene) ?
+ WM_window_get_active_view_layer(win) :
+ BKE_view_layer_default_view(scene);
RNA_pointer_create(&scene->id, &RNA_ViewLayer, view_layer, &path->ptr[path->len]);
path->len++;
@@ -159,7 +164,7 @@ static int buttons_context_path_world(ButsContextPath *path)
return 0;
}
-static int buttons_context_path_linestyle(ButsContextPath *path, WorkSpace *workspace)
+static int buttons_context_path_linestyle(ButsContextPath *path, wmWindow *window)
{
FreestyleLineStyle *linestyle;
PointerRNA *ptr = &path->ptr[path->len - 1];
@@ -169,7 +174,7 @@ static int buttons_context_path_linestyle(ButsContextPath *path, WorkSpace *work
return 1;
}
/* if we have a view layer, use the lineset's linestyle */
- else if (buttons_context_path_view_layer(path, workspace)) {
+ else if (buttons_context_path_view_layer(path, window)) {
ViewLayer *view_layer = path->ptr[path->len - 1].data;
linestyle = BKE_linestyle_active_from_view_layer(view_layer);
if (linestyle) {
@@ -199,6 +204,9 @@ static int buttons_context_path_object(ButsContextPath *path)
if (RNA_struct_is_a(ptr->type, &RNA_Object)) {
return 1;
}
+ if (!RNA_struct_is_a(ptr->type, &RNA_ViewLayer)) {
+ return 0;
+ }
ViewLayer *view_layer = ptr->data;
Object *ob = (view_layer->basact) ? view_layer->basact->object : NULL;
@@ -226,7 +234,7 @@ static int buttons_context_path_data(ButsContextPath *path, int type)
else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_Lamp) && (type == -1 || type == OB_LAMP)) return 1;
+ else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) return 1;
else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1;
else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) return 1;
/* try to get an object in the path, no pinning supported here */
@@ -432,7 +440,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *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, CTX_wm_workspace(C));
+ buttons_context_path_linestyle(path, CTX_wm_window(C));
}
if (ct->texture) {
@@ -472,8 +480,9 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
{
SpaceButs *sbuts = CTX_wm_space_buts(C);
Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ wmWindow *window = CTX_wm_window(C);
WorkSpace *workspace = CTX_wm_workspace(C);
- ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
ID *id;
int found;
@@ -514,13 +523,13 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
case BCONTEXT_VIEW_LAYER:
#ifdef WITH_FREESTYLE
if (buttons_context_linestyle_pinnable(C, view_layer)) {
- found = buttons_context_path_linestyle(path, workspace);
+ found = buttons_context_path_linestyle(path, window);
if (found) {
break;
}
}
#endif
- found = buttons_context_path_view_layer(path, workspace);
+ found = buttons_context_path_view_layer(path, window);
break;
case BCONTEXT_WORLD:
found = buttons_context_path_world(path);
@@ -670,7 +679,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
const char *buttons_context_dir[] = {
"texture_slot", "scene", "world", "object", "mesh", "armature", "lattice", "curve",
- "meta_ball", "lamp", "speaker", "lightprobe", "camera", "material", "material_slot",
+ "meta_ball", "light", "speaker", "lightprobe", "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",
@@ -727,8 +736,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
set_pointer_type(path, result, &RNA_MetaBall);
return 1;
}
- else if (CTX_data_equals(member, "lamp")) {
- set_pointer_type(path, result, &RNA_Lamp);
+ else if (CTX_data_equals(member, "light")) {
+ set_pointer_type(path, result, &RNA_Light);
return 1;
}
else if (CTX_data_equals(member, "camera")) {
@@ -1003,10 +1012,10 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
if (name) {
- if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER) && ptr->type == &RNA_Scene)) {
+ if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD) && ptr->type == &RNA_Scene)) {
uiItemLDrag(row, ptr, "", icon); /* save some space */
}
- else if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER) && ptr->type == &RNA_ViewLayer)) {
+ else if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD) && ptr->type == &RNA_ViewLayer)) {
uiItemLDrag(row, ptr, "", icon); /* save some space */
}
else {
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 93670919d4c..fb2907983c8 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -64,17 +64,9 @@
static int context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
{
- bScreen *sc = CTX_wm_screen(C);
- SpaceButs *sbuts = CTX_wm_space_buts(C);
- PointerRNA ptr;
- uiPopupMenu *pup;
- uiLayout *layout;
-
- RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr);
-
- pup = UI_popup_menu_begin(C, IFACE_("Align"), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
- uiItemsEnumR(layout, &ptr, "align");
+ uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Context Menu"), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
+ uiItemM(layout, "INFO_MT_area", NULL, ICON_NONE);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
@@ -84,7 +76,7 @@ void BUTTONS_OT_context_menu(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Context Menu";
- ot->description = "Display button panel context_menu";
+ ot->description = "Display properties editor context_menu";
ot->idname = "BUTTONS_OT_context_menu";
/* api callbacks */
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 5feb74edef7..66684de18ac 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -49,6 +49,7 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_linestyle_types.h"
+#include "DNA_windowmanager_types.h"
#include "BKE_context.h"
#include "BKE_layer.h"
@@ -72,6 +73,8 @@
#include "ED_node.h"
#include "ED_screen.h"
+#include "WM_api.h"
+
#include "../interface/interface_intern.h"
#include "buttons_intern.h" // own include
@@ -176,8 +179,10 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
const ID_Type id_type = pinid != NULL ? GS(pinid->name) : -1;
if (!pinid || id_type == ID_SCE) {
- WorkSpace *workspace = CTX_wm_workspace(C);
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
+ wmWindow *win = CTX_wm_window(C);
+ ViewLayer *view_layer = (win->scene == scene) ?
+ WM_window_get_active_view_layer(win) :
+ BKE_view_layer_default_view(scene);
brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
linestyle = BKE_linestyle_active_from_view_layer(view_layer);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index a951c2a8524..6f7a4ca971a 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -65,7 +65,6 @@ static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
sbuts = MEM_callocN(sizeof(SpaceButs), "initbuts");
sbuts->spacetype = SPACE_BUTS;
- sbuts->align = BUT_VERTICAL;
sbuts->mainb = sbuts->mainbuser = BCONTEXT_OBJECT;
@@ -109,17 +108,8 @@ static void buttons_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
+static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
{
- SpaceButs *sbuts = sa->spacedata.first;
-
- /* auto-align based on size */
- if (sbuts->align == BUT_AUTO || !sbuts->align) {
- if (sa->winx > sa->winy)
- sbuts->align = BUT_HORIZONTAL;
- else
- sbuts->align = BUT_VERTICAL;
- }
}
static SpaceLink *buttons_duplicate(SpaceLink *sl)
@@ -146,8 +136,6 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *ar)
static void buttons_main_region_layout_properties(const bContext *C, SpaceButs *sbuts, ARegion *ar)
{
- const bool vertical = (sbuts->align == BUT_VERTICAL);
-
buttons_context_compute(C, sbuts);
const char *contexts[2] = {NULL, NULL};
@@ -203,12 +191,12 @@ static void buttons_main_region_layout_properties(const bContext *C, SpaceButs *
break;
}
+ const bool vertical = true;
ED_region_panels_layout_ex(C, ar, contexts, sbuts->mainb, vertical);
}
-static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts, ARegion *ar)
+static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
{
- const bool vertical = (sbuts->align == BUT_VERTICAL);
const char *contexts[3] = {NULL};
const WorkSpace *workspace = CTX_wm_workspace(C);
@@ -225,16 +213,16 @@ static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts,
ARRAY_SET_ITEMS(contexts, ".curve_edit");
break;
case CTX_MODE_EDIT_TEXT:
- ARRAY_SET_ITEMS(contexts, ".todo");
+ ARRAY_SET_ITEMS(contexts, ".text_edit");
break;
case CTX_MODE_EDIT_ARMATURE:
ARRAY_SET_ITEMS(contexts, ".armature_edit");
break;
case CTX_MODE_EDIT_METABALL:
- ARRAY_SET_ITEMS(contexts, ".todo");
+ ARRAY_SET_ITEMS(contexts, ".mball_edit");
break;
case CTX_MODE_EDIT_LATTICE:
- ARRAY_SET_ITEMS(contexts, ".todo");
+ ARRAY_SET_ITEMS(contexts, ".lattice_edit");
break;
case CTX_MODE_POSE:
ARRAY_SET_ITEMS(contexts, ".posemode");
@@ -255,7 +243,7 @@ static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts,
ARRAY_SET_ITEMS(contexts, ".particlemode");
break;
case CTX_MODE_OBJECT:
- ARRAY_SET_ITEMS(contexts, ".todo");
+ ARRAY_SET_ITEMS(contexts, ".objectmode");
break;
}
}
@@ -263,6 +251,7 @@ static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts,
/* TODO */
}
+ const bool vertical = true;
ED_region_panels_layout_ex(C, ar, contexts, -1, vertical);
}
@@ -272,18 +261,17 @@ static void buttons_main_region_layout(const bContext *C, ARegion *ar)
SpaceButs *sbuts = CTX_wm_space_buts(C);
if (sbuts->mainb == BCONTEXT_TOOL) {
- buttons_main_region_layout_tool(C, sbuts, ar);
+ buttons_main_region_layout_tool(C, ar);
}
else {
buttons_main_region_layout_properties(C, sbuts, ar);
}
- sbuts->re_align = 0;
sbuts->mainbo = sbuts->mainb;
}
static void buttons_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn,
const Scene *UNUSED(scene))
{
/* context changes */
@@ -361,8 +349,7 @@ static void buttons_area_redraw(ScrArea *sa, short buttons)
/* reused! */
static void buttons_area_listener(
- bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+ wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
SpaceButs *sbuts = sa->spacedata.first;
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index d50d10d5cc3..2aa0a3e2b9a 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -128,10 +128,10 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
float strip[4], selected_strip[4];
float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT);
- unsigned int keyframe_ct = 0;
+ uint keyframe_len = 0;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* don't use totrect set, as the width stays the same
@@ -186,10 +186,10 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
if (start_frame != end_frame) {
immRectf(pos_id, start_frame, (float) y - STRIP_HEIGHT_HALF,
end_frame, (float) y + STRIP_HEIGHT_HALF);
- keyframe_ct += 2;
+ keyframe_len += 2;
}
else {
- keyframe_ct++;
+ keyframe_len++;
}
}
@@ -199,7 +199,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
MovieTrackingMarker *marker = &track->markers[i];
if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0) {
- keyframe_ct++;
+ keyframe_len++;
}
i++;
@@ -212,17 +212,17 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
immUnbindProgram();
- if (keyframe_ct > 0) {
+ if (keyframe_len > 0) {
/* draw keyframe markers */
format = immVertexFormat();
- pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
- unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
GPU_enable_program_point_size();
- immBegin(GWN_PRIM_POINTS, keyframe_ct);
+ immBegin(GPU_PRIM_POINTS, keyframe_len);
/* all same size with black outline */
immAttrib1f(size_id, 2.0f * STRIP_HEIGHT_HALF);
@@ -315,8 +315,8 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
*/
float y = (float) CHANNEL_FIRST;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 909f0a55c1c..ebdf5342172 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -80,7 +80,7 @@ static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int wid
int x = (frame - sfra) * framelen;
if (width == 1) {
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2i(pos, x, 0);
immVertex2i(pos, x, height * UI_DPI_FAC);
immEnd();
@@ -167,7 +167,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points);
ED_region_cache_draw_cached_segments(ar, totseg, points, sfra, efra);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* track */
@@ -248,7 +248,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
ED_region_cache_draw_curfra_label(sc->user.framenr, x, 8.0f * UI_DPI_FAC);
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* solver keyframes */
@@ -290,7 +290,7 @@ static void draw_movieclip_muted(ARegion *ar, int width, int height, float zoomx
{
int x, y;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* find window pixel coordinates of origin */
@@ -349,18 +349,18 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
/* draw boundary border for frame if stabilization is enabled */
if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
/* Exclusive OR allows to get orig value when second operand is 0,
* and negative of orig value when second operand is 1. */
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
- gpuPushMatrix();
- gpuTranslate2f(x, y);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(x, y);
- gpuScale2f(zoomx, zoomy);
- gpuMultMatrix(sc->stabmat);
+ GPU_matrix_scale_2f(zoomx, zoomy);
+ GPU_matrix_mul(sc->stabmat);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -377,7 +377,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
glDisable(GL_COLOR_LOGIC_OP);
}
@@ -452,7 +452,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
i++;
}
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -463,7 +463,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if ((b - a - 1) >= 1) {
GPU_point_size(5.0f);
- immBegin(GWN_PRIM_POINTS, b - a - 1);
+ immBegin(GPU_PRIM_POINTS, b - a - 1);
for (i = a; i < b; i++) {
if (i != curindex) {
@@ -478,7 +478,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if ((b - a) >= 2) {
GPU_line_width(3.0f);
- immBegin(GWN_PRIM_LINE_STRIP, b - a);
+ immBegin(GPU_PRIM_LINE_STRIP, b - a);
for (i = a; i < b; i++) {
immVertex2f(pos, path[i][0], path[i][1]);
@@ -494,7 +494,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if ((curindex - a) >= 1) {
immUniformThemeColor(TH_PATH_BEFORE);
- immBegin(GWN_PRIM_POINTS, curindex - a);
+ immBegin(GPU_PRIM_POINTS, curindex - a);
for (i = a; i < curindex; i++) {
immVertex2f(pos, path[i][0], path[i][1]);
@@ -506,7 +506,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if ((b - curindex - 1) >= 1) {
immUniformThemeColor(TH_PATH_AFTER);
- immBegin(GWN_PRIM_POINTS, b - curindex - 1);
+ immBegin(GPU_PRIM_POINTS, b - curindex - 1);
for (i = curindex + 1; i < b; i++) {
immVertex2f(pos, path[i][0], path[i][1]);
@@ -521,7 +521,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if ((curindex - a + 1) >= 2) {
immUniformThemeColor(TH_PATH_BEFORE);
- immBegin(GWN_PRIM_LINE_STRIP, curindex - a + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, curindex - a + 1);
for (i = a; i <= curindex; i++) {
immVertex2f(pos, path[i][0], path[i][1]);
@@ -533,7 +533,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if ((b - curindex) >= 2) {
immUniformThemeColor(TH_PATH_AFTER);
- immBegin(GWN_PRIM_LINE_STRIP, b - curindex);
+ immBegin(GPU_PRIM_LINE_STRIP, b - curindex);
for (i = curindex; i < b; i++) {
immVertex2f(pos, path[i][0], path[i][1]);
@@ -579,12 +579,12 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
{
GPU_point_size(tiny ? 3.0f : 4.0f);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2f(position, pos[0], pos[1]);
immEnd();
}
else {
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
immVertex2f(position, pos[0] + px[0] * 2, pos[1]);
immVertex2f(position, pos[0] + px[0] * 8, pos[1]);
@@ -603,11 +603,11 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
}
/* pattern and search outline */
- gpuPushMatrix();
- gpuTranslate2fv(marker_pos);
+ GPU_matrix_push();
+ GPU_matrix_translate_2fv(marker_pos);
if (sc->flag & SC_SHOW_MARKER_PATTERN) {
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2fv(position, marker->pattern_corners[0]);
immVertex2fv(position, marker->pattern_corners[1]);
immVertex2fv(position, marker->pattern_corners[2]);
@@ -625,7 +625,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
marker->search_max[1]);
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3])
@@ -705,14 +705,14 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
immUniform1f("dash_factor", 2.0f); /* Solid "line" */
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2f(shdr_pos, pos[0], pos[1]);
immEnd();
}
else {
immUniform1f("dash_factor", 2.0f); /* Solid line */
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
immVertex2f(shdr_pos, pos[0] + px[0] * 3, pos[1]);
immVertex2f(shdr_pos, pos[0] + px[0] * 7, pos[1]);
@@ -735,7 +735,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(shdr_pos, pos);
immVertex2fv(shdr_pos, marker_pos);
immEnd();
@@ -745,8 +745,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
/* pattern */
- gpuPushMatrix();
- gpuTranslate2fv(marker_pos);
+ GPU_matrix_push();
+ GPU_matrix_translate_2fv(marker_pos);
if (track->flag & TRACK_LOCKED) {
if (act) {
@@ -783,7 +783,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2fv(shdr_pos, marker->pattern_corners[0]);
immVertex2fv(shdr_pos, marker->pattern_corners[1]);
immVertex2fv(shdr_pos, marker->pattern_corners[2]);
@@ -800,12 +800,12 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
marker->search_max[0], marker->search_max[1]);
}
- gpuPopMatrix();
+ GPU_matrix_pop();
/* Restore default shader */
immUnbindProgram();
- const uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
BLI_assert(pos == shdr_pos);
UNUSED_VARS_NDEBUG(pos);
@@ -857,7 +857,7 @@ static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int
tdy += px[1];
}
- immBegin(GWN_PRIM_TRIS, 3);
+ immBegin(GPU_PRIM_TRIS, 3);
immVertex2f(pos, x, y);
immVertex2f(pos, x - tdx, y);
immVertex2f(pos, x, y + tdy);
@@ -884,8 +884,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
immUniformThemeColor(TH_MARKER_OUTLINE);
}
- gpuPushMatrix();
- gpuTranslate2fv(marker_pos);
+ GPU_matrix_push();
+ GPU_matrix_translate_2fv(marker_pos);
dx = 6.0f / width / sc->zoom;
dy = 6.0f / height / sc->zoom;
@@ -935,7 +935,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
GPU_line_width(outline ? 3.0f : 1.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, 0.0f, 0.0f);
immVertex2fv(pos, tilt_ctrl);
immEnd();
@@ -944,7 +944,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px, pos);
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
@@ -1141,18 +1141,18 @@ static void draw_plane_marker_image(Scene *scene,
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA,
GL_UNSIGNED_BYTE, display_buffer);
- gpuPushMatrix();
- gpuMultMatrix(gl_matrix);
+ GPU_matrix_push();
+ GPU_matrix_mul(gl_matrix);
- Gwn_VertFormat *imm_format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *imm_format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint texCoord = GPU_vertformat_attr_add(imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
immUniformColor4f(1.0f, 1.0f, 1.0f, plane_track->image_opacity);
immUniform1i("image", 0);
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texCoord, 0.0f, 0.0f);
immVertex2f(pos, 0.0f, 0.0f);
@@ -1170,7 +1170,7 @@ static void draw_plane_marker_image(Scene *scene,
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
glBindTexture(GL_TEXTURE_2D, 0);
@@ -1206,7 +1206,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
}
if (draw_plane_quad || is_selected_track) {
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -1239,7 +1239,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
}
/* Draw rectangle itself. */
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2fv(shdr_pos, plane_marker->corners[0]);
immVertex2fv(shdr_pos, plane_marker->corners[1]);
immVertex2fv(shdr_pos, plane_marker->corners[2]);
@@ -1252,7 +1252,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
immUniformColor3f(1.0f, 0.0f, 0.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point);
immVertex2fv(shdr_pos, plane_marker->corners[0]);
@@ -1262,7 +1262,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
immUniformColor3f(0.0f, 1.0f, 0.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point);
immVertex2fv(shdr_pos, plane_marker->corners[0]);
@@ -1342,13 +1342,13 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
- gpuPushMatrix();
- gpuTranslate2f(x, y);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(x, y);
- gpuPushMatrix();
- gpuScale2f(zoomx, zoomy);
- gpuMultMatrix(sc->stabmat);
- gpuScale2f(width, height);
+ GPU_matrix_push();
+ GPU_matrix_scale_2f(zoomx, zoomy);
+ GPU_matrix_mul(sc->stabmat);
+ GPU_matrix_scale_2f(width, height);
act_track = BKE_tracking_track_get_active(tracking);
@@ -1414,7 +1414,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
}
}
- unsigned int position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint position = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1519,7 +1519,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
immUniformColor3f(1.0f, 0.0f, 0.0f);
}
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
if (undistort) {
immVertex2f(position, pos[0] / width, pos[1] / (height * aspy));
@@ -1539,7 +1539,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
if (sc->flag & SC_SHOW_NAMES) {
/* scaling should be cleared before drawing texts, otherwise font would also be scaled */
@@ -1565,7 +1565,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
}
}
- gpuPopMatrix();
+ GPU_matrix_pop();
if (marker_pos)
MEM_freeN(marker_pos);
@@ -1592,13 +1592,13 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
- gpuPushMatrix();
- gpuTranslate2f(x, y);
- gpuScale2f(zoomx, zoomy);
- gpuMultMatrix(sc->stabmat);
- gpuScale2f(width, height);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_scale_2f(zoomx, zoomy);
+ GPU_matrix_mul(sc->stabmat);
+ GPU_matrix_scale_2f(width, height);
- unsigned int position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint position = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1675,7 +1675,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
immUniformColor3f(1.0f, 0.0f, 0.0f);
for (i = 0; i <= n; i++) {
- immBegin(GWN_PRIM_LINE_STRIP, n + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, n + 1);
for (j = 0; j <= n; j++) {
immVertex2fv(position, grid[i][j]);
@@ -1685,7 +1685,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
}
for (j = 0; j <= n; j++) {
- immBegin(GWN_PRIM_LINE_STRIP, n + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, n + 1);
for (i = 0; i <= n; i++) {
immVertex2fv(position, grid[i][j]);
@@ -1743,7 +1743,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
sub_v2_v2v2(dpos, npos, pos);
mul_v2_fl(dpos, 1.0f / steps);
- immBegin(GWN_PRIM_LINE_STRIP, steps + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, steps + 1);
for (j = 0; j <= steps; j++) {
BKE_tracking_distort_v2(tracking, pos, tpos);
@@ -1756,7 +1756,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
}
}
else if (stroke->totpoints == 1) {
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2f(position, stroke->points[0].x + offsx, stroke->points[0].y + offsy);
immEnd();
}
@@ -1774,7 +1774,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
}
void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
@@ -1871,8 +1871,8 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
* associated with the clip is already drawn in draw_distortion
*/
if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) {
- gpuPushMatrix();
- gpuMultMatrix(sc->unistabmat);
+ GPU_matrix_push();
+ GPU_matrix_mul(sc->unistabmat);
if (is_track_source) {
MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking);
@@ -1881,13 +1881,13 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
int framenr = ED_space_clip_get_clip_frame_number(sc);
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
- gpuTranslate2fv(marker->pos);
+ GPU_matrix_translate_2fv(marker->pos);
}
}
ED_gpencil_draw_2dimage(C);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
else {
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index d463f585470..cc8541d9fd7 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -91,11 +91,11 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track,
immUniformColor4fv(col);
if (is_point) {
- immBeginAtMost(GWN_PRIM_POINTS, 1);
+ immBeginAtMost(GPU_PRIM_POINTS, 1);
}
else {
/* Graph can be composed of smaller segments, if any marker is disabled */
- immBeginAtMost(GWN_PRIM_LINE_STRIP, track->markersnr);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, track->markersnr);
}
}
@@ -119,13 +119,13 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
if (sel == data->sel) {
immUniformThemeColor(sel ? TH_HANDLE_VERTEX_SELECT : TH_HANDLE_VERTEX);
- gpuPushMatrix();
- gpuTranslate2f(scene_framenr, val);
- gpuScale2f(1.0f / data->xscale * data->hsize, 1.0f / data->yscale * data->hsize);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(scene_framenr, val);
+ GPU_matrix_scale_2f(1.0f / data->xscale * data->hsize, 1.0f / data->yscale * data->hsize);
imm_draw_circle_wire_2d(data->pos, 0, 0, 0.7, 8);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
@@ -237,11 +237,11 @@ static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack *
immUniformColor4fv(col);
if (is_point) { /* This probably never happens here, but just in case... */
- immBeginAtMost(GWN_PRIM_POINTS, 1);
+ immBeginAtMost(GPU_PRIM_POINTS, 1);
}
else {
/* Graph can be composed of smaller segments, if any marker is disabled */
- immBeginAtMost(GWN_PRIM_LINE_STRIP, track->markersnr);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, track->markersnr);
}
}
}
@@ -300,7 +300,7 @@ static void draw_frame_curves(SpaceClip *sc, unsigned int pos)
}
if (!lines) {
- immBeginAtMost(GWN_PRIM_LINE_STRIP, reconstruction->camnr);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, reconstruction->camnr);
lines = 1;
}
@@ -328,7 +328,7 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
UI_view2d_grid_free(grid);
if (clip) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_point_size(3.0f);
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index c3208260b3b..19d321a53bf 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -273,7 +273,7 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
@@ -287,7 +287,7 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
/* thin lines where the actual frames are */
GPU_line_width(1.0f);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, (float)SFRA, v2d->cur.ymin);
immVertex2f(pos, (float)SFRA, v2d->cur.ymax);
immVertex2f(pos, (float)EFRA, v2d->cur.ymin);
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index c66a9a42292..2b98ff43c5f 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -323,8 +323,7 @@ static SpaceLink *clip_duplicate(SpaceLink *sl)
return (SpaceLink *)scn;
}
-static void clip_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
/* context changes */
switch (wmn->category) {
@@ -645,8 +644,11 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "extend", false);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", true);
+
kmi = WM_keymap_add_item(keymap, "CLIP_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "CLIP_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
WM_keymap_add_item(keymap, "CLIP_OT_select_border", BKEY, KM_PRESS, 0, 0);
@@ -763,7 +765,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "extend", true);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select_all_markers", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select_all_markers", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select_all_markers", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
@@ -781,7 +785,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
#ifdef WITH_INPUT_NDOF
WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
#endif
- WM_keymap_add_item(keymap, "CLIP_OT_graph_center_current_frame", PADPERIOD, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "CLIP_OT_graph_center_current_frame", PAD0, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.lock_time_cursor");
@@ -1181,13 +1185,13 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
show_cursor |= sc->around == V3D_AROUND_CURSOR;
if (show_cursor) {
- gpuPushMatrix();
- gpuTranslate2f(x, y);
- gpuScale2f(zoomx, zoomy);
- gpuMultMatrix(sc->stabmat);
- gpuScale2f(width, height);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_scale_2f(zoomx, zoomy);
+ GPU_matrix_mul(sc->stabmat);
+ GPU_matrix_scale_2f(width, height);
ED_image_draw_cursor(ar, sc->cursor);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
clip_draw_cache_and_notes(C, sc, ar);
@@ -1207,7 +1211,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
}
static void clip_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -1338,7 +1342,7 @@ static void clip_preview_region_draw(const bContext *C, ARegion *ar)
}
static void clip_preview_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
{
}
@@ -1381,7 +1385,7 @@ static void clip_channels_region_draw(const bContext *C, ARegion *ar)
}
static void clip_channels_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
{
}
@@ -1400,7 +1404,7 @@ static void clip_header_region_draw(const bContext *C, ARegion *ar)
}
static void clip_header_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -1442,7 +1446,7 @@ static void clip_tools_region_draw(const bContext *C, ARegion *ar)
/****************** tool properties region ******************/
static void clip_props_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -1489,7 +1493,7 @@ static void clip_properties_region_draw(const bContext *C, ARegion *ar)
}
static void clip_properties_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index 66b203ff612..789194c21b9 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -158,8 +158,8 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
int offl = 0, offc = 0;
int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN};
int pen[2];
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
xy[1] += tvc->lheight / 6;
console_cursor_wrap_offset(sc->prompt, tvc->console_width, &offl, &offc, NULL);
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 4b577a7cb7e..3a48d5ad7dd 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -333,7 +333,6 @@ static void console_keymap(struct wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "interactive", true);
- //WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", TABKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */
WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */
#endif
@@ -370,7 +369,7 @@ static void console_header_region_draw(const bContext *C, ARegion *ar)
}
static void console_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
// SpaceInfo *sinfo = sa->spacedata.first;
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 4d4845c41b9..4a71afbcf4a 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -402,8 +402,8 @@ static void file_draw_preview(
/* border */
if (use_dropshadow) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
@@ -466,7 +466,7 @@ static void draw_background(FileLayout *layout, View2D *v2d)
int i;
int sy;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShade(TH_BACK, -7);
@@ -486,14 +486,14 @@ static void draw_dividers(FileLayout *layout, View2D *v2d)
const int step = (layout->tile_w + 2 * layout->tile_border_x);
- unsigned int vertex_ct = 0;
+ unsigned int vertex_len = 0;
int sx = (int)v2d->tot.xmin;
while (sx < v2d->cur.xmax) {
sx += step;
- vertex_ct += 4; /* vertex_count = 2 points per line * 2 lines per divider */
+ vertex_len += 4; /* vertex_count = 2 points per line * 2 lines per divider */
}
- if (vertex_ct > 0) {
+ if (vertex_len > 0) {
int v1[2], v2[2];
unsigned char col_hi[3], col_lo[3];
@@ -503,12 +503,12 @@ static void draw_dividers(FileLayout *layout, View2D *v2d)
v1[1] = v2d->cur.ymax - layout->tile_border_y;
v2[1] = v2d->cur.ymin;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, vertex_ct);
+ immBegin(GPU_PRIM_LINES, vertex_len);
sx = (int)v2d->tot.xmin;
while (sx < v2d->cur.xmax) {
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index 6eaf2dda084..48acbdb137d 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -72,7 +72,7 @@ typedef enum WalkSelectDirection {
void FILE_OT_highlight(struct wmOperatorType *ot);
void FILE_OT_select(struct wmOperatorType *ot);
void FILE_OT_select_walk(struct wmOperatorType *ot);
-void FILE_OT_select_all_toggle(struct wmOperatorType *ot);
+void FILE_OT_select_all(struct wmOperatorType *ot);
void FILE_OT_select_border(struct wmOperatorType *ot);
void FILE_OT_select_bookmark(struct wmOperatorType *ot);
void FILE_OT_bookmark_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 7c080044aee..b19b2ff6cd5 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -808,12 +808,12 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-void FILE_OT_select_all_toggle(wmOperatorType *ot)
+void FILE_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "(De)select All Files";
ot->description = "Select or deselect all files";
- ot->idname = "FILE_OT_select_all_toggle";
+ ot->idname = "FILE_OT_select_all";
/* api callbacks */
ot->exec = file_select_all_exec;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 09e2660a762..968757bc637 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -2357,7 +2357,7 @@ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist)
filelist->filelist.entries[9].entry->relpath = BLI_strdup("Ika");
filelist->filelist.entries[10].entry->relpath = BLI_strdup("Wave");
filelist->filelist.entries[11].entry->relpath = BLI_strdup("Lattice");
- filelist->filelist.entries[12].entry->relpath = BLI_strdup("Lamp");
+ filelist->filelist.entries[12].entry->relpath = BLI_strdup("Light");
filelist->filelist.entries[13].entry->relpath = BLI_strdup("Camera");
filelist->filelist.entries[14].entry->relpath = BLI_strdup("Ipo");
filelist->filelist.entries[15].entry->relpath = BLI_strdup("World");
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 853d31edebf..116cd700cc0 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -298,8 +298,7 @@ static void file_refresh(const bContext *C, ScrArea *sa)
ED_area_tag_redraw(sa);
}
-static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+static void file_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
@@ -339,7 +338,7 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *ar)
}
static void file_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -462,7 +461,7 @@ static void file_operatortypes(void)
{
WM_operatortype_append(FILE_OT_select);
WM_operatortype_append(FILE_OT_select_walk);
- WM_operatortype_append(FILE_OT_select_all_toggle);
+ WM_operatortype_append(FILE_OT_select_all);
WM_operatortype_append(FILE_OT_select_border);
WM_operatortype_append(FILE_OT_select_bookmark);
WM_operatortype_append(FILE_OT_highlight);
@@ -588,7 +587,7 @@ static void file_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "FILE_OT_previous", BUTTON4MOUSE, KM_CLICK, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_next", BUTTON5MOUSE, KM_CLICK, 0, 0);
- WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "FILE_OT_select_all", AKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_select_border", EVT_TWEAK_L, KM_ANY, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
@@ -642,7 +641,7 @@ static void file_tools_region_draw(const bContext *C, ARegion *ar)
}
static void file_tools_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
{
#if 0
@@ -706,7 +705,7 @@ static void file_ui_region_draw(const bContext *C, ARegion *ar)
}
static void file_ui_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index b08ff8dcfa1..ad9af8cb948 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -86,7 +86,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
int i;
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPU_line_width(1.0f);
@@ -103,7 +103,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
/* draw two black lines showing the standard reference levels */
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(shdr_pos, v2d->cur.xmin, env->midval + env->min);
immVertex2f(shdr_pos, v2d->cur.xmax, env->midval + env->min);
@@ -122,7 +122,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
/* for now, point color is fixed, and is white */
immUniformColor3f(1.0f, 1.0f, 1.0f);
- immBeginAtMost(GWN_PRIM_POINTS, env->totvert * 2);
+ immBeginAtMost(GPU_PRIM_POINTS, env->totvert * 2);
for (i = 0, fed = env->data; i < env->totvert; i++, fed++) {
/* only draw if visible
@@ -148,21 +148,27 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
/* helper func - set color to draw F-Curve data with */
static void set_fcurve_vertex_color(FCurve *fcu, bool sel)
{
- /* Fade the 'intensity' of the vertices based on the selection of the curves too */
- int alphaOffset = (int)((fcurve_display_alpha(fcu) - 1.0f) * 255);
-
float color[4];
+ float diff;
/* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */
if ((fcu->flag & FCURVE_PROTECTED) == 0) {
/* Curve's points ARE BEING edited */
- UI_GetThemeColorShadeAlpha4fv(sel ? TH_VERTEX_SELECT : TH_VERTEX, 0, alphaOffset, color);
+ UI_GetThemeColor3fv(sel ? TH_VERTEX_SELECT : TH_VERTEX, color);
}
else {
/* Curve's points CANNOT BE edited */
- UI_GetThemeColorShadeAlpha4fv(sel ? TH_TEXT_HI : TH_TEXT, 0, alphaOffset, color);
+ UI_GetThemeColor3fv(sel ? TH_TEXT_HI : TH_TEXT, color);
}
+ /* Fade the 'intensity' of the vertices based on the selection of the curves too
+ * - Only fade by 50% the amount the curves were faded by, so that the points
+ * still stand out for easier selection
+ */
+ diff = 1.0f - fcurve_display_alpha(fcu);
+ color[3] = 1.0f - (diff * 0.5f);
+ CLAMP(color[3], 0.2f, 1.0f);
+
immUniformColor4fv(color);
}
@@ -172,7 +178,7 @@ static void draw_fcurve_selected_keyframe_vertices(FCurve *fcu, View2D *v2d, boo
set_fcurve_vertex_color(fcu, sel);
- immBeginAtMost(GWN_PRIM_POINTS, fcu->totvert);
+ immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert);
BezTriple *bezt = fcu->bezt;
for (int i = 0; i < fcu->totvert; i++, bezt++) {
@@ -224,7 +230,7 @@ static void draw_fcurve_selected_handle_vertices(FCurve *fcu, View2D *v2d, bool
immUniform4f("outlineColor", hcolor[0], hcolor[1], hcolor[2], 1.0f);
immUniformColor3fvAlpha(hcolor, 0.01f); /* almost invisible - only keep for smoothness */
- immBeginAtMost(GWN_PRIM_POINTS, fcu->totvert * 2);
+ immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert * 2);
BezTriple *bezt = fcu->bezt;
BezTriple *prevbezt = NULL;
@@ -280,7 +286,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool
* - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users)
*/
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPU_blend(true);
GPU_enable_program_point_size();
@@ -324,12 +330,12 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
{
int sel, b;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBeginAtMost(GWN_PRIM_LINES, 4 * 2 * fcu->totvert);
+ immBeginAtMost(GPU_PRIM_LINES, 4 * 2 * fcu->totvert);
/* slightly hacky, but we want to draw unselected points before selected ones
* so that selected points are clearly visible
@@ -416,12 +422,12 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize, unsigned int pos)
{
/* adjust view transform before starting */
- gpuPushMatrix();
- gpuTranslate2f(x, y);
- gpuScale2f(1.0f / xscale * hsize, 1.0f / yscale * hsize);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_scale_2f(1.0f / xscale * hsize, 1.0f / yscale * hsize);
/* draw X shape */
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, -0.7f, -0.7f);
immVertex2f(pos, +0.7f, +0.7f);
@@ -430,7 +436,7 @@ static void draw_fcurve_sample_control(float x, float y, float xscale, float ysc
immEnd();
/* restore view transform */
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/* helper func - draw keyframe vertices only for an F-Curve */
@@ -453,7 +459,7 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) GPU_line_smooth(true);
GPU_blend(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor((fcu->flag & FCURVE_SELECTED) ? TH_TEXT_HI : TH_TEXT);
@@ -545,7 +551,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
n = (etime - stime) / samplefreq + 0.5f;
if (n > 0) {
- immBegin(GWN_PRIM_LINE_STRIP, (n + 1));
+ immBegin(GPU_PRIM_LINE_STRIP, (n + 1));
for (i = 0; i <= n; i++) {
float ctime = stime + i * samplefreq;
@@ -579,12 +585,12 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
}
/* apply unit mapping */
- gpuPushMatrix();
+ GPU_matrix_push();
unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
- gpuScale2f(1.0f, unit_scale);
- gpuTranslate2f(0.0f, offset);
+ GPU_matrix_scale_2f(1.0f, unit_scale);
+ GPU_matrix_translate_2f(0.0f, offset);
- immBegin(GWN_PRIM_LINE_STRIP, count);
+ immBegin(GPU_PRIM_LINE_STRIP, count);
/* extrapolate to left? - left-side of view comes before first keyframe? */
if (prevfpt->vec[0] > v2d->cur.xmin) {
@@ -639,7 +645,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
immEnd();
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/* helper func - check if the F-Curve only contains easily drawable segments
@@ -673,15 +679,15 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
short mapping_flag = ANIM_get_normalization_flags(ac);
/* apply unit mapping */
- gpuPushMatrix();
+ GPU_matrix_push();
unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
- gpuScale2f(1.0f, unit_scale);
- gpuTranslate2f(0.0f, offset);
+ GPU_matrix_scale_2f(1.0f, unit_scale);
+ GPU_matrix_translate_2f(0.0f, offset);
/* For now, this assumes the worst case scenario, where all the keyframes have
* bezier interpolation, and are drawn at full res.
* This is tricky to optimize, but maybe can be improved at some point... */
- immBeginAtMost(GWN_PRIM_LINE_STRIP, (b * 32 + 3));
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, (b * 32 + 3));
/* extrapolate to left? */
if (prevbezt->vec[1][0] > v2d->cur.xmin) {
@@ -821,7 +827,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
immEnd();
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/* Debugging -------------------------------- */
@@ -843,7 +849,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
//if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
// return;
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
@@ -868,7 +874,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
/* draw 1-1 line, stretching just past the screen limits
* NOTE: we need to scale the y-values to be valid for the units
*/
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
t = v2d->cur.xmin;
immVertex2f(shdr_pos, t, (t + offset) * unitfac);
@@ -894,7 +900,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
immUniform1f("dash_width", 10.0f);
immUniform1f("dash_factor", 0.5f);
- immBegin(GWN_PRIM_LINES, (y >= v2d->cur.ymin) ? 4 : 2);
+ immBegin(GPU_PRIM_LINES, (y >= v2d->cur.ymin) ? 4 : 2);
/* x-axis lookup */
co[0] = x;
@@ -920,7 +926,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
immUnbindProgram();
- /* GWN_PRIM_POINTS do not survive dashed line geometry shader... */
+ /* GPU_PRIM_POINTS do not survive dashed line geometry shader... */
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* x marks the spot .................................................... */
@@ -928,7 +934,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
immUniformColor3f(0.9f, 0.9f, 0.9f);
GPU_point_size(7.0);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2f(shdr_pos, x, y);
immEnd();
@@ -936,7 +942,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
immUniformColor3f(0.9f, 0.0f, 0.0f);
GPU_point_size(3.0);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex2f(shdr_pos, x, y);
immEnd();
}
@@ -963,7 +969,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
}
GPU_blend(true);
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -1049,7 +1055,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
}
GPU_blend(true);
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -1130,9 +1136,9 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
/* apply unit-scaling to all values via OpenGL */
- gpuPushMatrix();
- gpuScale2f(1.0f, unit_scale);
- gpuTranslate2f(0.0f, offset);
+ GPU_matrix_push();
+ GPU_matrix_scale_2f(1.0f, unit_scale);
+ GPU_matrix_translate_2f(0.0f, offset);
/* set this once and for all - all handles and handle-verts should use the same thickness */
GPU_line_width(1.0);
@@ -1154,7 +1160,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
draw_fcurve_samples(sipo, ar, fcu);
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index c50e0497519..398561927dd 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -58,7 +58,7 @@ void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, str
void deselect_graph_keys(struct bAnimContext *ac, bool test, short sel, bool do_channels);
-void GRAPH_OT_select_all_toggle(struct wmOperatorType *ot);
+void GRAPH_OT_select_all(struct wmOperatorType *ot);
void GRAPH_OT_select_border(struct wmOperatorType *ot);
void GRAPH_OT_select_lasso(struct wmOperatorType *ot);
void GRAPH_OT_select_circle(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 8ac2c61b8e9..54b35b6acb6 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -49,6 +49,7 @@
#include "ED_markers.h"
#include "ED_screen.h"
#include "ED_transform.h"
+#include "ED_object.h"
#include "graph_intern.h"
@@ -427,7 +428,7 @@ void graphedit_operatortypes(void)
/* keyframes */
/* selection */
WM_operatortype_append(GRAPH_OT_clickselect);
- WM_operatortype_append(GRAPH_OT_select_all_toggle);
+ WM_operatortype_append(GRAPH_OT_select_all);
WM_operatortype_append(GRAPH_OT_select_border);
WM_operatortype_append(GRAPH_OT_select_lasso);
WM_operatortype_append(GRAPH_OT_select_circle);
@@ -550,10 +551,12 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
/* deselect all */
- kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
- RNA_boolean_set(kmi->ptr, "invert", false);
- kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
- RNA_boolean_set(kmi->ptr, "invert", true);
+ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", AKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
+ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
/* borderselect */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0);
@@ -598,7 +601,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
/* menu + single-step transform */
WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_handle_type", VKEY, KM_PRESS, 0, 0);
@@ -607,7 +610,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
/* destructive */
WM_keymap_add_item(keymap, "GRAPH_OT_smooth", OKEY, KM_PRESS, KM_ALT, 0);
- WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_bake", CKEY, KM_PRESS, KM_ALT, 0);
@@ -662,6 +665,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_fcurve");
+ ED_keymap_proportional_cycle(keyconf, keymap);
/* pivot point settings */
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 9a6b733a5ff..e91bb192d3c 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -162,10 +162,24 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op)
ale_active = get_active_fcurve_channel(&ac);
/* 'standard' behavior - check if selected, then apply relevant selection */
- if (RNA_boolean_get(op->ptr, "invert"))
- deselect_graph_keys(&ac, 0, SELECT_INVERT, true);
- else
- deselect_graph_keys(&ac, 1, SELECT_ADD, true);
+ const int action = RNA_enum_get(op->ptr, "action");
+ switch (action) {
+ case SEL_TOGGLE:
+ deselect_graph_keys(&ac, 1, SELECT_ADD, true);
+ break;
+ case SEL_SELECT:
+ deselect_graph_keys(&ac, 0, SELECT_ADD, true);
+ break;
+ case SEL_DESELECT:
+ deselect_graph_keys(&ac, 0, SELECT_SUBTRACT, true);
+ break;
+ case SEL_INVERT:
+ deselect_graph_keys(&ac, 0, SELECT_INVERT, true);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
/* restore active F-Curve... */
if (ale_active) {
@@ -186,11 +200,11 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void GRAPH_OT_select_all_toggle(wmOperatorType *ot)
+void GRAPH_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Select All";
- ot->idname = "GRAPH_OT_select_all_toggle";
+ ot->idname = "GRAPH_OT_select_all";
ot->description = "Toggle selection of all keyframes";
/* api callbacks */
@@ -200,8 +214,8 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* props */
- ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
+ /* properties */
+ WM_operator_properties_select_all(ot);
}
/* ******************** Border Select Operator **************************** */
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 878c4815f73..fa57df0393a 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -279,7 +279,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_grid_free(grid);
if (((sipo->flag & SIPO_NODRAWCURSOR) == 0) || (sipo->mode == SIPO_MODE_DRIVERS)) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -292,7 +292,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
GPU_blend(true);
GPU_line_width(2.0);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, v2d->cur.xmin, y);
immVertex2f(pos, v2d->cur.xmax, y);
immEnd();
@@ -310,7 +310,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
GPU_blend(true);
GPU_line_width(2.0);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, x, v2d->cur.ymin);
immVertex2f(pos, x, v2d->cur.ymax);
immEnd();
@@ -430,7 +430,7 @@ static void graph_buttons_region_draw(const bContext *C, ARegion *ar)
}
static void graph_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -568,8 +568,7 @@ static void graph_region_message_subscribe(
}
/* editor level listener */
-static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+static void graph_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 191f57961c9..1d8c6721b64 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -1000,25 +1000,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
col = uiLayoutColumn(layout, false);
uiItemR(col, &imaptr, "use_deinterlace", 0, IFACE_("Deinterlace"), ICON_NONE);
}
-
- split = uiLayoutSplit(layout, 0.0f, false);
-
- col = uiLayoutColumn(split, false);
- /* XXX Why only display fields_per_frame only for video image types?
- * And why allow fields for non-video image types at all??? */
- if (BKE_image_is_animated(ima)) {
- uiLayout *subsplit = uiLayoutSplit(col, 0.0f, false);
- uiLayout *subcol = uiLayoutColumn(subsplit, false);
- uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE);
- subcol = uiLayoutColumn(subsplit, false);
- uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields"));
- uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE);
- }
- else
- uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE);
- row = uiLayoutRow(col, false);
- uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields"));
- uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
}
}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index f70efa00244..4cbe25462af 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -117,17 +117,17 @@ static void draw_render_info(const bContext *C,
int x, y;
UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
- gpuPushMatrix();
- gpuTranslate2f(x, y);
- gpuScale2f(zoomx, zoomy);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_scale_2f(zoomx, zoomy);
if (rd->mode & R_BORDER) {
/* TODO: round or floor instead of casting to int */
- gpuTranslate2f((int)(-rd->border.xmin * rd->xsch * rd->size * 0.01f),
+ GPU_matrix_translate_2f((int)(-rd->border.xmin * rd->xsch * rd->size * 0.01f),
(int)(-rd->border.ymin * rd->ysch * rd->size * 0.01f));
}
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_FACE_SELECT);
@@ -144,7 +144,7 @@ static void draw_render_info(const bContext *C,
MEM_freeN(tiles);
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
}
@@ -174,7 +174,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* noisy, high contrast make impossible to read if lower alpha is used. */
@@ -330,7 +330,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
BLI_rcti_init(&color_rect, dx, dx + (1.5f * UI_UNIT_X), 0.15f * UI_UNIT_Y, 0.85f * UI_UNIT_Y);
/* BLF uses immediate mode too, so we must reset our vertex format */
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
if (channels == 4) {
@@ -367,7 +367,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
immUnbindProgram();
/* draw outline */
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ub(128, 128, 128);
imm_draw_box_wire_2d(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
@@ -573,8 +573,8 @@ void draw_image_sample_line(SpaceImage *sima)
if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) {
Histogram *hist = &sima->sample_line_hist;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int shdr_dashed_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint shdr_dashed_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -586,7 +586,7 @@ void draw_image_sample_line(SpaceImage *sima)
immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
immUniform1f("dash_width", 2.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(shdr_dashed_pos, hist->co[0]);
immVertex2fv(shdr_dashed_pos, hist->co[1]);
immEnd();
@@ -779,7 +779,7 @@ void draw_image_cache(const bContext *C, ARegion *ar)
/* Draw current frame. */
x = (cfra - sfra) / (efra - sfra + 1) * ar->winx;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_CFRAME);
immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 3efdce3ea6d..29d63493a3c 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1231,7 +1231,6 @@ static int image_open_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
ImageUser *iuser = NULL;
ImageOpenData *iod = op->customdata;
- PointerRNA idptr;
Image *ima = NULL;
char filepath[FILE_MAX];
int frame_seq_len = 0;
@@ -1297,8 +1296,9 @@ static int image_open_exec(bContext *C, wmOperator *op)
* pointer use also increases user, so this compensates it */
id_us_min(&ima->id);
- RNA_id_pointer_create(&ima->id, &idptr);
- RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, idptr);
+ PointerRNA imaptr;
+ RNA_id_pointer_create(&ima->id, &imaptr);
+ RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, imaptr);
RNA_property_update(C, &iod->pprop.ptr, iod->pprop.prop);
}
@@ -1340,7 +1340,6 @@ static int image_open_exec(bContext *C, wmOperator *op)
else {
iuser->offset = frame_ofs - 1;
}
- iuser->fie_ima = 2;
iuser->scene = scene;
BKE_image_init_imageuser(ima, iuser);
}
@@ -2382,6 +2381,30 @@ enum {
GEN_CONTEXT_PAINT_STENCIL = 2
};
+typedef struct ImageNewData {
+ PropertyPointerRNA pprop;
+} ImageNewData;
+
+static ImageNewData *image_new_init(bContext *C, wmOperator *op)
+{
+ if (op->customdata) {
+ return op->customdata;
+ }
+
+ ImageNewData *data = MEM_callocN(sizeof(ImageNewData), __func__);
+ UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop);
+ op->customdata = data;
+ return data;
+}
+
+static void image_new_free(wmOperator *op)
+{
+ if (op->customdata) {
+ MEM_freeN(op->customdata);
+ op->customdata = NULL;
+ }
+}
+
static int image_new_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima;
@@ -2389,13 +2412,11 @@ static int image_new_exec(bContext *C, wmOperator *op)
Object *obedit;
Image *ima;
Main *bmain;
- PointerRNA ptr, idptr;
PropertyRNA *prop;
char name_buffer[MAX_ID_NAME - 2];
const char *name;
float color[4];
int width, height, floatbuf, gen_type, alpha;
- int gen_context;
int stereo3d;
/* retrieve state */
@@ -2419,7 +2440,6 @@ static int image_new_exec(bContext *C, wmOperator *op)
gen_type = RNA_enum_get(op->ptr, "generated_type");
RNA_float_get_array(op->ptr, "color", color);
alpha = RNA_boolean_get(op->ptr, "alpha");
- gen_context = RNA_enum_get(op->ptr, "gen_context");
stereo3d = RNA_boolean_get(op->ptr, "use_stereo_3d");
if (!alpha)
@@ -2427,79 +2447,44 @@ static int image_new_exec(bContext *C, wmOperator *op)
ima = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d);
- if (!ima)
+ if (!ima) {
+ image_new_free(op);
return OPERATOR_CANCELLED;
+ }
/* hook into UI */
- UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
+ ImageNewData *data = image_new_init(C, op);
- if (prop) {
+ if (data->pprop.prop) {
/* when creating new ID blocks, use is already 1, but RNA
* pointer use also increases user, so this compensates it */
id_us_min(&ima->id);
- RNA_id_pointer_create(&ima->id, &idptr);
- RNA_property_pointer_set(&ptr, prop, idptr);
- RNA_property_update(C, &ptr, prop);
+ PointerRNA imaptr;
+ RNA_id_pointer_create(&ima->id, &imaptr);
+ RNA_property_pointer_set(&data->pprop.ptr, data->pprop.prop, imaptr);
+ RNA_property_update(C, &data->pprop.ptr, data->pprop.prop);
}
else if (sima) {
ED_space_image_set(bmain, sima, scene, obedit, ima);
}
- else if (gen_context == GEN_CONTEXT_PAINT_CANVAS) {
- bScreen *sc;
- Object *ob = CTX_data_active_object(C);
-
- if (scene->toolsettings->imapaint.canvas)
- id_us_min(&scene->toolsettings->imapaint.canvas->id);
- scene->toolsettings->imapaint.canvas = ima;
-
- for (sc = bmain->screen.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima_other = (SpaceImage *)sl;
-
- if (!sima_other->pin) {
- ED_space_image_set(bmain, sima_other, scene, obedit, ima);
- }
- }
- }
- }
- }
- BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
- WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
- }
- else if (gen_context == GEN_CONTEXT_PAINT_STENCIL) {
- Object *ob = CTX_data_active_object(C);
- if (scene->toolsettings->imapaint.stencil)
- id_us_min(&scene->toolsettings->imapaint.stencil->id);
- scene->toolsettings->imapaint.stencil = ima;
- BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
- WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
- }
- else {
- Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
- if (tex && tex->type == TEX_IMAGE) {
- if (tex->ima)
- id_us_min(&tex->ima->id);
- tex->ima = ima;
- ED_area_tag_redraw(CTX_wm_area(C));
- }
- }
BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima);
+ image_new_free(op);
+
return OPERATOR_FINISHED;
}
-/* XXX, Ton is not a fan of OK buttons but using this function to avoid undo/redo bug while in mesh-editmode, - campbell */
-/* XXX Note: the WM_operator_props_dialog_popup() doesn't work for UI_context_active_but_prop_get_templateID(), image is not being that way */
static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
+ /* Get property in advance, it doesn't work after WM_operator_props_dialog_popup. */
+ ImageNewData *data;
+ op->customdata = data = MEM_callocN(sizeof(ImageNewData), __func__);
+ UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop);
+
/* Better for user feedback. */
RNA_string_set(op->ptr, "name", DATA_(IMA_DEF_NAME));
return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, 5 * UI_UNIT_Y);
@@ -2552,18 +2537,16 @@ static void image_new_draw(bContext *UNUSED(C), wmOperator *op)
#endif
}
+static void image_new_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ image_new_free(op);
+}
+
void IMAGE_OT_new(wmOperatorType *ot)
{
PropertyRNA *prop;
static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- static const EnumPropertyItem gen_context_items[] = {
- {GEN_CONTEXT_NONE, "NONE", 0, "None", ""},
- {GEN_CONTEXT_PAINT_CANVAS, "PAINT_CANVAS", 0, "Paint Canvas", ""},
- {GEN_CONTEXT_PAINT_STENCIL, "PAINT_STENCIL", 0, "Paint Stencil", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
/* identifiers */
ot->name = "New Image";
ot->description = "Create a new image";
@@ -2573,6 +2556,7 @@ void IMAGE_OT_new(wmOperatorType *ot)
ot->exec = image_new_exec;
ot->invoke = image_new_invoke;
ot->ui = image_new_draw;
+ ot->cancel = image_new_cancel;
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -2590,7 +2574,6 @@ void IMAGE_OT_new(wmOperatorType *ot)
RNA_def_enum(ot->srna, "generated_type", rna_enum_image_generated_type_items, IMA_GENTYPE_BLANK,
"Generated Type", "Fill the image with a grid for UV map testing");
RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth");
- prop = RNA_def_enum(ot->srna, "gen_context", gen_context_items, 0, "Gen Context", "Generation context");
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_boolean(ot->srna, "use_stereo_3d", 0, "Stereo 3D", "Create an image with left and right views");
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
@@ -3716,7 +3699,7 @@ static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
void IMAGE_OT_read_viewlayers(wmOperatorType *ot)
{
- ot->name = "Read View Layers";
+ ot->name = "Open Cached Render";
ot->idname = "IMAGE_OT_read_viewlayers";
ot->description = "Read all the current scene's view layers from cache, as needed";
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 907b7e51c42..d87bfbe00ce 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -51,6 +51,7 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_material.h"
+#include "BKE_workspace.h"
#include "DEG_depsgraph.h"
@@ -176,7 +177,6 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce
simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA | SI_COORDFLOATS;
simage->iuser.ok = true;
- simage->iuser.fie_ima = 2;
simage->iuser.frames = 100;
simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS;
@@ -434,8 +434,7 @@ static void image_refresh(const bContext *C, ScrArea *sa)
}
}
-static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene,
- WorkSpace *workspace)
+static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
@@ -529,7 +528,7 @@ static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc
case ND_TRANSFORM:
case ND_MODIFIER:
{
- ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Object *ob = OBACT(view_layer);
if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) {
if (sima->lock && (sima->flag & SI_DRAWSHADOW)) {
@@ -582,25 +581,25 @@ static int image_context(const bContext *C, const char *member, bContextDataResu
return 0;
}
-static void IMAGE_WGT_manipulator2d(wmManipulatorGroupType *wgt)
+static void IMAGE_GGT_gizmo2d(wmGizmoGroupType *gzgt)
{
- wgt->name = "UV Transform Manipulator";
- wgt->idname = "IMAGE_WGT_manipulator2d";
+ gzgt->name = "UV Transform Gizmo";
+ gzgt->idname = "IMAGE_GGT_gizmo2d";
- wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
+ gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
- wgt->poll = ED_widgetgroup_manipulator2d_poll;
- wgt->setup = ED_widgetgroup_manipulator2d_setup;
- wgt->refresh = ED_widgetgroup_manipulator2d_refresh;
- wgt->draw_prepare = ED_widgetgroup_manipulator2d_draw_prepare;
+ gzgt->poll = ED_widgetgroup_gizmo2d_poll;
+ gzgt->setup = ED_widgetgroup_gizmo2d_setup;
+ gzgt->refresh = ED_widgetgroup_gizmo2d_refresh;
+ gzgt->draw_prepare = ED_widgetgroup_gizmo2d_draw_prepare;
}
static void image_widgets(void)
{
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(
- &(const struct wmManipulatorMapType_Params){SPACE_IMAGE, RGN_TYPE_WINDOW});
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(
+ &(const struct wmGizmoMapType_Params){SPACE_IMAGE, RGN_TYPE_WINDOW});
- WM_manipulatorgrouptype_append_and_link(mmap_type, IMAGE_WGT_manipulator2d);
+ WM_gizmogrouptype_append_and_link(gzmap_type, IMAGE_GGT_gizmo2d);
}
/************************** main region ***************************/
@@ -666,15 +665,15 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar)
// image space manages own v2d
// UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
- /* manipulators */
- if (ar->manipulator_map == NULL) {
- const struct wmManipulatorMapType_Params wmap_params = {
+ /* gizmos */
+ if (ar->gizmo_map == NULL) {
+ const struct wmGizmoMapType_Params wmap_params = {
.spaceid = SPACE_IMAGE,
.regionid = RGN_TYPE_WINDOW,
};
- ar->manipulator_map = WM_manipulatormap_new_from_type(&wmap_params);
+ ar->gizmo_map = WM_gizmomap_new_from_type(&wmap_params);
}
- WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
+ WM_gizmomap_add_handlers(ar, ar->gizmo_map);
/* mask polls mode */
keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0);
@@ -808,7 +807,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
}
- WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_2D);
+ WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
draw_image_cache(C, ar);
@@ -821,14 +820,14 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
}
static void image_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
switch (wmn->category) {
case NC_GEOM:
if (ELEM(wmn->data, ND_DATA, ND_SELECT))
- WM_manipulatormap_tag_refresh(ar->manipulator_map);
+ WM_gizmomap_tag_refresh(ar->gizmo_map);
break;
case NC_GPENCIL:
if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
@@ -839,7 +838,7 @@ static void image_main_region_listener(
case NC_IMAGE:
if (wmn->action == NA_PAINTING)
ED_region_tag_redraw(ar);
- WM_manipulatormap_tag_refresh(ar->manipulator_map);
+ WM_gizmomap_tag_refresh(ar->gizmo_map);
break;
case NC_MATERIAL:
if (wmn->data == ND_SHADING_LINKS) {
@@ -877,7 +876,7 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar)
}
static void image_buttons_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -952,7 +951,7 @@ static void image_tools_region_draw(const bContext *C, ARegion *ar)
}
static void image_tools_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -1020,7 +1019,7 @@ static void image_header_region_draw(const bContext *C, ARegion *ar)
}
static void image_header_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -1090,7 +1089,7 @@ void ED_spacetype_image(void)
st->refresh = image_refresh;
st->listener = image_listener;
st->context = image_context;
- st->manipulators = image_widgets;
+ st->gizmos = image_widgets;
st->id_remap = image_id_remap;
/* regions: main window */
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 5f9de037409..7f4d2a7f6c7 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -243,7 +243,7 @@ static void info_header_region_draw(const bContext *C, ARegion *ar)
}
static void info_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
// SpaceInfo *sinfo = sa->spacedata.first;
@@ -260,7 +260,7 @@ static void info_main_region_listener(
}
static void info_header_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index a1e3842f887..c94aaf6e861 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -85,8 +85,8 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2],
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv(bg_sel);
@@ -191,8 +191,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
cdc->sel[1] = str_len - sel_orig[0];
if (bg) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv(bg);
@@ -242,8 +242,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
else { /* simple, no wrap */
if (bg) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv(bg);
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index a21a62dc8e8..7dd8c7f2eed 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -120,8 +120,8 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa
nla_action_get_color(adt, act, color);
color[3] *= 2.5f;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -138,17 +138,17 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa
/* count keys before drawing */
/* Note: It's safe to cast DLRBT_Tree, as it's designed to degrade down to a ListBase */
- unsigned int key_ct = BLI_listbase_count((ListBase *)&keys);
+ uint key_len = BLI_listbase_count((ListBase *)&keys);
- if (key_ct > 0) {
+ if (key_len > 0) {
format = immVertexFormat();
- pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
- unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
- unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
GPU_enable_program_point_size();
- immBegin(GWN_PRIM_POINTS, key_ct);
+ immBegin(GPU_PRIM_POINTS, key_len);
/* - disregard the selection status of keyframes so they draw a certain way
* - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction
@@ -177,7 +177,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
if (ELEM(NULL, act, act->markers.first))
return;
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (dashed) {
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -194,7 +194,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
}
immUniformThemeColorShade(TH_STRIP_SELECT, shade);
- immBeginAtMost(GWN_PRIM_LINES, BLI_listbase_count(&act->markers) * 2);
+ immBeginAtMost(GPU_PRIM_LINES, BLI_listbase_count(&act->markers) * 2);
for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) {
float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP);
@@ -318,7 +318,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
/* plot the curve (over the strip's main region) */
if (fcu) {
- immBegin(GWN_PRIM_LINE_STRIP, abs((int)(strip->end - strip->start) + 1));
+ immBegin(GPU_PRIM_LINE_STRIP, abs((int)(strip->end - strip->start) + 1));
/* sample at 1 frame intervals, and draw
* - min y-val is yminc, max is y-maxc, so clamp in those regions
@@ -335,7 +335,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
else {
/* use blend in/out values only if both aren't zero */
if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f)) == 0) {
- immBeginAtMost(GWN_PRIM_LINE_STRIP, 4);
+ immBeginAtMost(GPU_PRIM_LINE_STRIP, 4);
/* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */
if (IS_EQF(strip->blendin, 0.0f) == 0) {
@@ -366,7 +366,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
static uint nla_draw_use_dashed_outlines(float color[4], bool muted)
{
/* Note that we use dashed shader here, and make it draw solid lines if not muted... */
- uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
@@ -403,7 +403,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
/* get color of strip */
nla_strip_get_color_inside(adt, strip, color);
- shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* draw extrapolation info first (as backdrop)
@@ -456,7 +456,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
UI_draw_roundbox_shade_x(true, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1, color);
/* restore current vertex format & program (roundbox trashes it) */
- shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
}
else {
@@ -512,13 +512,13 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
}
/* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */
- if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f) == 0) {
+ if ((strip->type == NLASTRIP_TYPE_CLIP) && strip->repeat > 1.0f) {
float repeatLen = (strip->actend - strip->actstart) * strip->scale;
/* only draw lines for whole-numbered repeats, starting from the first full-repeat
* up to the last full repeat (but not if it lies on the end of the strip)
*/
- immBeginAtMost(GWN_PRIM_LINES, 2 * (strip->repeat - 1));
+ immBeginAtMost(GPU_PRIM_LINES, 2 * floorf(strip->repeat));
for (int i = 1; i < strip->repeat; i++) {
float repeatPos = strip->start + (repeatLen * i);
@@ -534,7 +534,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) {
const float y = (ymaxc - yminc) * 0.5f + yminc;
- immBeginAtMost(GWN_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* up to 2 lines per strip */
+ immBeginAtMost(GPU_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* up to 2 lines per strip */
/* only draw first-level of child-strips, but don't draw any lines on the endpoints */
for (NlaStrip *cs = strip->strips.first; cs; cs = cs->next) {
@@ -706,7 +706,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
{
AnimData *adt = ale->adt;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* just draw a semi-shaded rect spanning the width of the viewable area if there's data,
@@ -729,7 +729,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* white base-lines */
GPU_line_width(2.0f);
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3f);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP);
immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP);
@@ -739,7 +739,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* black top-lines */
GPU_line_width(1.0f);
immUniformColor3f(0.0f, 0.0f, 0.0f);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP);
immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP);
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index a00e71a192d..e59395cac6b 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -65,7 +65,7 @@ enum eNlaEdit_LeftRightSelect_Mode {
/* --- */
-void NLA_OT_select_all_toggle(wmOperatorType *ot);
+void NLA_OT_select_all(wmOperatorType *ot);
void NLA_OT_select_border(wmOperatorType *ot);
void NLA_OT_select_leftright(wmOperatorType *ot);
void NLA_OT_click_select(wmOperatorType *ot);
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index 5bfd73b8163..8a776ad32e9 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -124,7 +124,7 @@ void nla_operatortypes(void)
/* select */
WM_operatortype_append(NLA_OT_click_select);
WM_operatortype_append(NLA_OT_select_border);
- WM_operatortype_append(NLA_OT_select_all_toggle);
+ WM_operatortype_append(NLA_OT_select_all);
WM_operatortype_append(NLA_OT_select_leftright);
/* view */
@@ -223,13 +223,13 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT);
-
/* deselect all */
- /* TODO: uniformize with other select_all ops? */
- kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
- RNA_boolean_set(kmi->ptr, "invert", false);
- kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
- RNA_boolean_set(kmi->ptr, "invert", true);
+ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", AKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
+ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
/* borderselect */
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0);
@@ -256,8 +256,8 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
WM_keymap_add_item(keymap, "NLA_OT_soundclip_add", KKEY, KM_PRESS, KM_SHIFT, 0);
/* meta-strips */
- WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
/* duplicate */
kmi = WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index f22c211af64..5d32b23ad67 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -167,10 +167,24 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
/* 'standard' behavior - check if selected, then apply relevant selection */
- if (RNA_boolean_get(op->ptr, "invert"))
- deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_INVERT);
- else
- deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD);
+ const int action = RNA_enum_get(op->ptr, "action");
+ switch (action) {
+ case SEL_TOGGLE:
+ deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD);
+ break;
+ case SEL_SELECT:
+ deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_ADD);
+ break;
+ case SEL_DESELECT:
+ deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_SUBTRACT);
+ break;
+ case SEL_INVERT:
+ deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_INVERT);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
@@ -178,11 +192,11 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void NLA_OT_select_all_toggle(wmOperatorType *ot)
+void NLA_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "(De)select All";
- ot->idname = "NLA_OT_select_all_toggle";
+ ot->idname = "NLA_OT_select_all";
ot->description = "Select or deselect all NLA-Strips";
/* api callbacks */
@@ -192,9 +206,8 @@ void NLA_OT_select_all_toggle(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/;
- /* props */
- ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
- RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
+ /* properties */
+ WM_operator_properties_select_all(ot);
}
/* ******************** Border Select Operator **************************** */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 62144db0577..6633dbdf08e 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -365,7 +365,7 @@ static void nla_buttons_region_draw(const bContext *C, ARegion *ar)
}
static void nla_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -400,7 +400,7 @@ static void nla_region_listener(
static void nla_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -493,7 +493,7 @@ static void nla_main_region_message_subscribe(
}
static void nla_channel_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -564,8 +564,7 @@ static void nla_channel_region_message_subscribe(
}
/* editor level listener */
-static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+static void nla_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
/* context changes */
switch (wmn->category) {
diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt
index 77b1351435b..06a00945452 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -48,7 +48,7 @@ set(SRC
node_draw.c
node_edit.c
node_group.c
- node_manipulators.c
+ node_gizmo.c
node_ops.c
node_relationships.c
node_select.c
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 12da5086c52..d1ad8cb396c 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -54,6 +54,7 @@
#include "GPU_draw.h"
#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
@@ -743,7 +744,7 @@ static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA
PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
- uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
+ uiTemplateID(layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
uiItemR(layout, ptr, "interpolation", 0, "", ICON_NONE);
uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
@@ -774,7 +775,7 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin
uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
uiTemplateID(
layout, C, ptr, "image",
- NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
+ "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr, false);
@@ -792,7 +793,7 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
uiTemplateID(
layout, C, ptr, "image",
- ima ? NULL : "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
+ "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
if (!ima)
return;
@@ -874,6 +875,8 @@ static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C),
static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
+ uiItemR(layout, ptr, "distance", 0, "", ICON_NONE);
+ uiItemR(layout, ptr, "feature", 0, "", ICON_NONE);
}
static void node_shader_buts_tex_pointdensity(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -1022,6 +1025,11 @@ static void node_shader_buts_hair(uiLayout *layout, bContext *UNUSED(C), Pointer
uiItemR(layout, ptr, "component", 0, "", ICON_NONE);
}
+static void node_shader_buts_principled_hair(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "parametrization", 0, "", ICON_NONE);
+}
+
static void node_shader_buts_ies(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *row;
@@ -1066,6 +1074,11 @@ static void node_shader_buts_script_ex(uiLayout *layout, bContext *C, PointerRNA
#endif
}
+static void node_buts_output_shader(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "target", 0, "", ICON_NONE);
+}
+
static void node_buts_output_linestyle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *row, *col;
@@ -1199,6 +1212,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_BSDF_HAIR:
ntype->draw_buttons = node_shader_buts_hair;
break;
+ case SH_NODE_BSDF_HAIR_PRINCIPLED:
+ ntype->draw_buttons = node_shader_buts_principled_hair;
+ break;
case SH_NODE_SCRIPT:
ntype->draw_buttons = node_shader_buts_script;
ntype->draw_buttons_ex = node_shader_buts_script_ex;
@@ -1209,6 +1225,11 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_UVALONGSTROKE:
ntype->draw_buttons = node_shader_buts_uvalongstroke;
break;
+ case SH_NODE_OUTPUT_MATERIAL:
+ case SH_NODE_OUTPUT_LIGHT:
+ case SH_NODE_OUTPUT_WORLD:
+ ntype->draw_buttons = node_buts_output_shader;
+ break;
case SH_NODE_OUTPUT_LINESTYLE:
ntype->draw_buttons = node_buts_output_linestyle;
break;
@@ -1253,7 +1274,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *
uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
uiTemplateID(
layout, C, ptr, "image",
- NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
+ "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
if (!node->id) return;
imaptr = RNA_pointer_get(ptr, "image");
@@ -2171,14 +2192,14 @@ static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNo
const float cy = y + snode->zoom * backdropHeight * node->custom4;
const float cross_size = 12 * U.pixelsize;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(1.0f, 1.0f, 1.0f);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, cx - cross_size, cy - cross_size);
immVertex2f(pos, cx + cross_size, cy + cross_size);
immVertex2f(pos, cx + cross_size, cy - cross_size);
@@ -2216,14 +2237,14 @@ static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bN
y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(1.0f, 1.0f, 1.0f);
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y2);
immVertex2f(pos, x3, y3);
@@ -2260,14 +2281,14 @@ static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop
y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(1.0f, 1.0f, 1.0f);
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y2);
immVertex2f(pos, x3, y3);
@@ -2460,6 +2481,25 @@ static void node_composit_buts_sunbeams(uiLayout *layout, bContext *UNUSED(C), P
uiItemR(layout, ptr, "ray_length", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
}
+static void node_composit_buts_cryptomatte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *col = uiLayoutColumn(layout, true);
+
+ uiItemL(col, IFACE_("Matte Objects:"), ICON_NONE);
+
+ uiLayout *row = uiLayoutRow(col, true);
+ uiTemplateCryptoPicker(row, ptr, "add");
+ uiTemplateCryptoPicker(row, ptr, "remove");
+
+ uiItemR(col, ptr, "matte_id", 0, "", ICON_NONE);
+}
+
+static void node_composit_buts_cryptomatte_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *UNUSED(ptr))
+{
+ uiItemO(layout, IFACE_("Add Crypto Layer"), ICON_ZOOMIN, "NODE_OT_cryptomatte_layer_add");
+ uiItemO(layout, IFACE_("Remove Crypto Layer"), ICON_ZOOMOUT, "NODE_OT_cryptomatte_layer_remove");
+}
+
static void node_composit_buts_brightcontrast(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "use_premultiply", 0, NULL, ICON_NONE);
@@ -2692,6 +2732,10 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_SUNBEAMS:
ntype->draw_buttons = node_composit_buts_sunbeams;
break;
+ case CMP_NODE_CRYPTOMATTE:
+ ntype->draw_buttons = node_composit_buts_cryptomatte;
+ ntype->draw_buttons_ex = node_composit_buts_cryptomatte_ex;
+ break;
case CMP_NODE_BRIGHTCONTRAST:
ntype->draw_buttons = node_composit_buts_brightcontrast;
}
@@ -2794,7 +2838,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe
static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
+ uiTemplateID(layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
}
static void node_texture_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
@@ -3180,8 +3224,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
if (ibuf) {
float x, y;
- gpuPushProjectionMatrix();
- gpuPushMatrix();
+ GPU_matrix_push_projection();
+ GPU_matrix_push();
/* somehow the offset has to be calculated inverse */
wmOrtho2_region_pixelspace(ar);
@@ -3254,7 +3298,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
y + snode->zoom * viewer_border->ymin * ibuf->y,
y + snode->zoom * viewer_border->ymax * ibuf->y);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_ACTIVE);
@@ -3264,8 +3308,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
}
}
- gpuPopProjectionMatrix();
- gpuPopMatrix();
+ GPU_matrix_pop_projection();
+ GPU_matrix_pop();
}
BKE_image_release_ibuf(ima, ibuf, lock);
@@ -3379,50 +3423,50 @@ static float arrow_verts[3][2] = {{-1.0f, 1.0f}, {0.0f, 0.0f}, {-1.0f, -1.0f}};
static float arrow_expand_axis[3][2] = {{0.7071f, 0.7071f}, {M_SQRT2, 0.0f}, {0.7071f, -0.7071f}};
struct {
- Gwn_Batch *batch; /* for batching line together */
- Gwn_Batch *batch_single; /* for single line */
- Gwn_VertBuf *inst_vbo;
+ GPUBatch *batch; /* for batching line together */
+ GPUBatch *batch_single; /* for single line */
+ GPUVertBuf *inst_vbo;
unsigned int p0_id, p1_id, p2_id, p3_id;
unsigned int colid_id;
- Gwn_VertBufRaw p0_step, p1_step, p2_step, p3_step;
- Gwn_VertBufRaw colid_step;
+ GPUVertBufRaw p0_step, p1_step, p2_step, p3_step;
+ GPUVertBufRaw colid_step;
unsigned int count;
bool enabled;
} g_batch_link = {0};
static void nodelink_batch_reset(void)
{
- GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p0_id, &g_batch_link.p0_step);
- GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p1_id, &g_batch_link.p1_step);
- GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p2_id, &g_batch_link.p2_step);
- GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p3_id, &g_batch_link.p3_step);
- GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p0_id, &g_batch_link.p0_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p1_id, &g_batch_link.p1_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p2_id, &g_batch_link.p2_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p3_id, &g_batch_link.p3_step);
+ GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step);
g_batch_link.count = 0;
}
static void set_nodelink_vertex(
- Gwn_VertBuf *vbo,
+ GPUVertBuf *vbo,
unsigned int uv_id, unsigned int pos_id, unsigned int exp_id, unsigned int v,
const unsigned char uv[2], const float pos[2], const float exp[2])
{
- GWN_vertbuf_attr_set(vbo, uv_id, v, uv);
- GWN_vertbuf_attr_set(vbo, pos_id, v, pos);
- GWN_vertbuf_attr_set(vbo, exp_id, v, exp);
+ GPU_vertbuf_attr_set(vbo, uv_id, v, uv);
+ GPU_vertbuf_attr_set(vbo, pos_id, v, pos);
+ GPU_vertbuf_attr_set(vbo, exp_id, v, exp);
}
static void nodelink_batch_init(void)
{
- Gwn_VertFormat format = {0};
- unsigned int uv_id = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_U8, 2, GWN_FETCH_INT_TO_FLOAT_UNIT);
- unsigned int pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int expand_id = GWN_vertformat_attr_add(&format, "expand", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC);
+ GPUVertFormat format = {0};
+ uint uv_id = GPU_vertformat_attr_add(&format, "uv", GPU_COMP_U8, 2, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint expand_id = GPU_vertformat_attr_add(&format, "expand", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC);
int vcount = LINK_RESOL * 2; /* curve */
vcount += 2; /* restart strip */
vcount += 3 * 2; /* arrow */
vcount *= 2; /* shadow */
vcount += 2; /* restart strip */
- GWN_vertbuf_data_alloc(vbo, vcount);
+ GPU_vertbuf_data_alloc(vbo, vcount);
int v = 0;
for (int k = 0; k < 2; ++k) {
@@ -3466,23 +3510,23 @@ static void nodelink_batch_init(void)
set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
}
- g_batch_link.batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ g_batch_link.batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
gpu_batch_presets_register(g_batch_link.batch);
- g_batch_link.batch_single = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, 0);
+ g_batch_link.batch_single = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, 0);
gpu_batch_presets_register(g_batch_link.batch_single);
/* Instances data */
- Gwn_VertFormat format_inst = {0};
- g_batch_link.p0_id = GWN_vertformat_attr_add(&format_inst, "P0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- g_batch_link.p1_id = GWN_vertformat_attr_add(&format_inst, "P1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- g_batch_link.p2_id = GWN_vertformat_attr_add(&format_inst, "P2", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- g_batch_link.p3_id = GWN_vertformat_attr_add(&format_inst, "P3", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- g_batch_link.colid_id = GWN_vertformat_attr_add(&format_inst, "colid_doarrow", GWN_COMP_U8, 4, GWN_FETCH_INT);
- g_batch_link.inst_vbo = GWN_vertbuf_create_with_format_ex(&format_inst, GWN_USAGE_STREAM);
- GWN_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); /* Alloc max count but only draw the range we need. */
+ GPUVertFormat format_inst = {0};
+ g_batch_link.p0_id = GPU_vertformat_attr_add(&format_inst, "P0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ g_batch_link.p1_id = GPU_vertformat_attr_add(&format_inst, "P1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ g_batch_link.p2_id = GPU_vertformat_attr_add(&format_inst, "P2", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ g_batch_link.p3_id = GPU_vertformat_attr_add(&format_inst, "P3", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ g_batch_link.colid_id = GPU_vertformat_attr_add(&format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT);
+ g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM);
+ GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); /* Alloc max count but only draw the range we need. */
- GWN_batch_instbuf_set(g_batch_link.batch, g_batch_link.inst_vbo, true);
+ GPU_batch_instbuf_set(g_batch_link.batch, g_batch_link.inst_vbo, true);
nodelink_batch_reset();
}
@@ -3513,14 +3557,14 @@ static void nodelink_batch_draw(SpaceNode *snode)
UI_GetThemeColor4fv(TH_EDGE_SELECT, colors[nodelink_get_color_id(TH_EDGE_SELECT)]);
UI_GetThemeColor4fv(TH_REDALERT, colors[nodelink_get_color_id(TH_REDALERT)]);
- GWN_vertbuf_vertex_count_set(g_batch_link.inst_vbo, g_batch_link.count);
- GWN_vertbuf_use(g_batch_link.inst_vbo); /* force update. */
+ GPU_vertbuf_vertex_count_set(g_batch_link.inst_vbo, g_batch_link.count);
+ GPU_vertbuf_use(g_batch_link.inst_vbo); /* force update. */
- GWN_batch_program_set_builtin(g_batch_link.batch, GPU_SHADER_2D_NODELINK_INST);
- GWN_batch_uniform_4fv_array(g_batch_link.batch, "colors", 6, (float *)colors);
- GWN_batch_uniform_1f(g_batch_link.batch, "expandSize", snode->aspect * LINK_WIDTH);
- GWN_batch_uniform_1f(g_batch_link.batch, "arrowSize", ARROW_SIZE);
- GWN_batch_draw(g_batch_link.batch);
+ GPU_batch_program_set_builtin(g_batch_link.batch, GPU_SHADER_2D_NODELINK_INST);
+ GPU_batch_uniform_4fv_array(g_batch_link.batch, "colors", 6, (float *)colors);
+ GPU_batch_uniform_1f(g_batch_link.batch, "expandSize", snode->aspect * LINK_WIDTH);
+ GPU_batch_uniform_1f(g_batch_link.batch, "arrowSize", ARROW_SIZE);
+ GPU_batch_draw(g_batch_link.batch);
nodelink_batch_reset();
@@ -3549,11 +3593,11 @@ static void nodelink_batch_add_link(
BLI_assert(ELEM(th_col3, TH_WIRE, -1));
g_batch_link.count++;
- copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p0_step), p0);
- copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p1_step), p1);
- copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p2_step), p2);
- copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p3_step), p3);
- char *colid = GWN_vertbuf_raw_step(&g_batch_link.colid_step);
+ copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p0_step), p0);
+ copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p1_step), p1);
+ copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p2_step), p2);
+ copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p3_step), p3);
+ char *colid = GPU_vertbuf_raw_step(&g_batch_link.colid_step);
colid[0] = nodelink_get_color_id(th_col1);
colid[1] = nodelink_get_color_id(th_col2);
colid[2] = nodelink_get_color_id(th_col3);
@@ -3591,14 +3635,14 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
UI_GetThemeColor4fv(th_col1, colors[1]);
UI_GetThemeColor4fv(th_col2, colors[2]);
- Gwn_Batch *batch = g_batch_link.batch_single;
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK);
- GWN_batch_uniform_2fv_array(batch, "bezierPts", 4, (float *)vec);
- GWN_batch_uniform_4fv_array(batch, "colors", 3, (float *)colors);
- GWN_batch_uniform_1f(batch, "expandSize", snode->aspect * LINK_WIDTH);
- GWN_batch_uniform_1f(batch, "arrowSize", ARROW_SIZE);
- GWN_batch_uniform_1i(batch, "doArrow", drawarrow);
- GWN_batch_draw(batch);
+ GPUBatch *batch = g_batch_link.batch_single;
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK);
+ GPU_batch_uniform_2fv_array(batch, "bezierPts", 4, (float *)vec);
+ GPU_batch_uniform_4fv_array(batch, "colors", 3, (float *)colors);
+ GPU_batch_uniform_1f(batch, "expandSize", snode->aspect * LINK_WIDTH);
+ GPU_batch_uniform_1f(batch, "arrowSize", ARROW_SIZE);
+ GPU_batch_uniform_1i(batch, "doArrow", drawarrow);
+ GPU_batch_draw(batch);
}
}
}
@@ -3647,7 +3691,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, unsigned pos)
{
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
if (border & (NODE_LEFT | NODE_RIGHT)) {
immVertex2f(pos, cent[0], v2d->cur.ymin);
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 01e22ec5245..4b3a3abc642 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -648,8 +648,8 @@ static void node_draw_preview_background(float tile, rctf *rect)
{
float x, y;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -721,7 +721,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
GPU_blend(false);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_BACK, -15, +100);
imm_draw_box_wire_2d(pos, draw_rect.xmin, draw_rect.ymin, draw_rect.xmax, draw_rect.ymax);
@@ -758,10 +758,10 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha)
void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *node, bool draw_outputs, bool select_all)
{
- const unsigned int total_input_ct = BLI_listbase_count(&node->inputs);
- const unsigned int total_output_ct = BLI_listbase_count(&node->outputs);
+ const uint total_input_len = BLI_listbase_count(&node->inputs);
+ const uint total_output_len = BLI_listbase_count(&node->outputs);
- if (total_input_ct + total_output_ct == 0) {
+ if (total_input_len + total_output_len == 0) {
return;
}
@@ -771,9 +771,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
float scale;
UI_view2d_scale_get(v2d, &scale, NULL);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
GPU_blend(true);
GPU_enable_program_point_size();
@@ -788,17 +788,17 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
immUniform1f("outlineWidth", 1.0f);
immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 0.6f);
- immBeginAtMost(GWN_PRIM_POINTS, total_input_ct + total_output_ct);
+ immBeginAtMost(GPU_PRIM_POINTS, total_input_len + total_output_len);
}
/* socket inputs */
- short selected_input_ct = 0;
+ short selected_input_len = 0;
bNodeSocket *sock;
for (sock = node->inputs.first; sock; sock = sock->next) {
if (nodeSocketIsHidden(sock))
continue;
if (select_all || (sock->flag & SELECT)) {
- ++selected_input_ct;
+ ++selected_input_len;
continue;
}
@@ -806,13 +806,13 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
}
/* socket outputs */
- short selected_output_ct = 0;
+ short selected_output_len = 0;
if (draw_outputs) {
for (sock = node->outputs.first; sock; sock = sock->next) {
if (nodeSocketIsHidden(sock))
continue;
if (select_all || (sock->flag & SELECT)) {
- ++selected_output_ct;
+ ++selected_output_len;
continue;
}
@@ -825,36 +825,36 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
}
/* go back and draw selected sockets */
- if (selected_input_ct + selected_output_ct > 0) {
+ if (selected_input_len + selected_output_len > 0) {
/* outline for selected sockets */
float c[3];
UI_GetThemeColor3fv(TH_TEXT_HI, c);
immUniform4f("outlineColor", c[0], c[1], c[2], 1.0f);
immUniform1f("outlineWidth", 1.5f);
- immBegin(GWN_PRIM_POINTS, selected_input_ct + selected_output_ct);
+ immBegin(GPU_PRIM_POINTS, selected_input_len + selected_output_len);
- if (selected_input_ct) {
+ if (selected_input_len) {
/* socket inputs */
for (sock = node->inputs.first; sock; sock = sock->next) {
if (nodeSocketIsHidden(sock))
continue;
if (select_all || (sock->flag & SELECT)) {
node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col);
- if (--selected_input_ct == 0)
+ if (--selected_input_len == 0)
break; /* stop as soon as last one is drawn */
}
}
}
- if (selected_output_ct) {
+ if (selected_output_len) {
/* socket outputs */
for (sock = node->outputs.first; sock; sock = sock->next) {
if (nodeSocketIsHidden(sock))
continue;
if (select_all || (sock->flag & SELECT)) {
node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col);
- if (--selected_output_ct == 0)
+ if (--selected_output_len == 0)
break; /* stop as soon as last one is drawn */
}
}
@@ -960,6 +960,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
UI_block_emboss_set(node->block, UI_EMBOSS);
+ UI_GetThemeColor4fv(TH_TEXT, color);
/* custom draw function for this button */
UI_draw_icon_tri(rct->xmin + 0.5f * U.widget_unit, rct->ymax - NODE_DY / 2.0f, 'v', color);
}
@@ -1079,6 +1080,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
UI_block_emboss_set(node->block, UI_EMBOSS);
+ UI_GetThemeColor4fv(TH_TEXT, color);
/* custom draw function for this button */
UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h', color);
}
@@ -1100,13 +1102,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
}
/* scale widget thing */
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShade(color_id, -10);
dx = 10.0f;
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, rct->xmax - dx, centy - 4.0f);
immVertex2f(pos, rct->xmax - dx, centy + 4.0f);
@@ -1117,7 +1119,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
immUniformThemeColorShade(color_id, 30);
dx -= snode->aspect;
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, rct->xmax - dx, centy - 4.0f);
immVertex2f(pos, rct->xmax - dx, centy + 4.0f);
@@ -1403,17 +1405,17 @@ void drawnodespace(const bContext *C, ARegion *ar)
{
float original_proj[4][4];
- gpuGetProjectionMatrix(original_proj);
+ GPU_matrix_projection_get(original_proj);
- gpuPushMatrix();
- gpuLoadIdentity();
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
wmOrtho2_pixelspace(ar->winx, ar->winy);
- WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_2D);
+ WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
- gpuPopMatrix();
- gpuLoadProjectionMatrix(original_proj);
+ GPU_matrix_pop();
+ GPU_matrix_projection_set(original_proj);
}
draw_nodetree(C, ar, ntree, path->parent_key);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index cc32e5ef499..edab76cd7e1 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -424,7 +424,7 @@ void ED_node_shader_default(const bContext *C, ID *id)
Lamp *la = (Lamp *)id;
la->nodetree = ntree;
- output_type = SH_NODE_OUTPUT_LAMP;
+ output_type = SH_NODE_OUTPUT_LIGHT;
shader_type = SH_NODE_EMISSION;
copy_v3_v3(color, &la->r);
@@ -628,7 +628,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
nodeClearActiveID(ntree, ID_TE);
if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL,
- SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LAMP, SH_NODE_OUTPUT_LINESTYLE))
+ SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT, SH_NODE_OUTPUT_LINESTYLE))
{
bNode *tnode;
@@ -2548,3 +2548,93 @@ void NODE_OT_clear_viewer_border(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+/* ****************** Cryptomatte Add Socket ******************* */
+
+static int node_cryptomatte_add_socket_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ PointerRNA ptr = CTX_data_pointer_get(C, "node");
+ bNodeTree *ntree = NULL;
+ bNode *node = NULL;
+
+ if (ptr.data) {
+ node = ptr.data;
+ ntree = ptr.id.data;
+ }
+ else if (snode && snode->edittree) {
+ ntree = snode->edittree;
+ node = nodeGetActive(snode->edittree);
+ }
+
+ if (!node || node->type != CMP_NODE_CRYPTOMATTE) {
+ return OPERATOR_CANCELLED;
+ }
+
+ ntreeCompositCryptomatteAddSocket(ntree, node);
+
+ snode_notify(C, snode);
+
+ return OPERATOR_FINISHED;
+}
+
+void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Cryptomatte Socket";
+ ot->description = "Add a new input layer to a Cryptomatte node";
+ ot->idname = "NODE_OT_cryptomatte_layer_add";
+
+ /* callbacks */
+ ot->exec = node_cryptomatte_add_socket_exec;
+ ot->poll = composite_node_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/* ****************** Cryptomatte Remove Socket ******************* */
+
+static int node_cryptomatte_remove_socket_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ PointerRNA ptr = CTX_data_pointer_get(C, "node");
+ bNodeTree *ntree = NULL;
+ bNode *node = NULL;
+
+ if (ptr.data) {
+ node = ptr.data;
+ ntree = ptr.id.data;
+ }
+ else if (snode && snode->edittree) {
+ ntree = snode->edittree;
+ node = nodeGetActive(snode->edittree);
+ }
+
+ if (!node || node->type != CMP_NODE_CRYPTOMATTE) {
+ return OPERATOR_CANCELLED;
+ }
+
+ if (!ntreeCompositCryptomatteRemoveSocket(ntree, node)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ snode_notify(C, snode);
+
+ return OPERATOR_FINISHED;
+}
+
+void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Remove Cryptomatte Socket";
+ ot->description = "Remove layer from a Crytpomatte node";
+ ot->idname = "NODE_OT_cryptomatte_layer_remove";
+
+ /* callbacks */
+ ot->exec = node_cryptomatte_remove_socket_exec;
+ ot->poll = composite_node_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/space_node/node_manipulators.c b/source/blender/editors/space_node/node_gizmo.c
index 851e3973288..b265d95c06a 100644
--- a/source/blender/editors/space_node/node_manipulators.c
+++ b/source/blender/editors/space_node/node_gizmo.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/space_node/node_manipulators.c
+/** \file blender/editors/space_node/node_gizmo.c
* \ingroup spnode
*/
@@ -34,7 +34,7 @@
#include "BKE_main.h"
#include "ED_screen.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "IMB_imbuf_types.h"
@@ -53,7 +53,7 @@
/** \name Local Utilities
* \{ */
-static void node_manipulator_calc_matrix_space(
+static void node_gizmo_calc_matrix_space(
const SpaceNode *snode, const ARegion *ar, float matrix_space[4][4])
{
unit_m4(matrix_space);
@@ -63,7 +63,7 @@ static void node_manipulator_calc_matrix_space(
matrix_space[3][1] = (ar->winy / 2) + snode->yof;
}
-static void node_manipulator_calc_matrix_space_with_image_dims(
+static void node_gizmo_calc_matrix_space_with_image_dims(
const SpaceNode *snode, const ARegion *ar, const float image_dims[2], float matrix_space[4][4])
{
unit_m4(matrix_space);
@@ -79,36 +79,36 @@ static void node_manipulator_calc_matrix_space_with_image_dims(
/* -------------------------------------------------------------------- */
-/** \name Backdrop Manipulator
+/** \name Backdrop Gizmo
* \{ */
-static void manipulator_node_backdrop_prop_matrix_get(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void gizmo_node_backdrop_prop_matrix_get(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
void *value_p)
{
float (*matrix)[4] = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- const SpaceNode *snode = mpr_prop->custom_func.user_data;
+ BLI_assert(gz_prop->type->array_length == 16);
+ const SpaceNode *snode = gz_prop->custom_func.user_data;
matrix[0][0] = snode->zoom;
matrix[1][1] = snode->zoom;
matrix[3][0] = snode->xof;
matrix[3][1] = snode->yof;
}
-static void manipulator_node_backdrop_prop_matrix_set(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void gizmo_node_backdrop_prop_matrix_set(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
const void *value_p)
{
const float (*matrix)[4] = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- SpaceNode *snode = mpr_prop->custom_func.user_data;
+ BLI_assert(gz_prop->type->array_length == 16);
+ SpaceNode *snode = gz_prop->custom_func.user_data;
snode->zoom = matrix[0][0];
snode->zoom = matrix[1][1];
snode->xof = matrix[3][0];
snode->yof = matrix[3][1];
}
-static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -127,22 +127,22 @@ static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmManipulatorGrou
return false;
}
-static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
- wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
+ wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__);
- wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
+ wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL);
- RNA_enum_set(wwrapper->manipulator->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM);
+ RNA_enum_set(wwrapper->gizmo->ptr, "transform",
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM);
- mgroup->customdata = wwrapper;
+ gzgroup->customdata = wwrapper;
}
-static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
Main *bmain = CTX_data_main(C);
- wmManipulator *cage = ((wmManipulatorWrapper *)mgroup->customdata)->manipulator;
+ wmGizmo *cage = ((wmGizmoWrapper *)gzgroup->customdata)->gizmo;
const ARegion *ar = CTX_wm_region(C);
/* center is always at the origin */
const float origin[3] = {ar->winx / 2, ar->winy / 2};
@@ -158,55 +158,55 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorG
};
RNA_float_set_array(cage->ptr, "dimensions", dims);
- WM_manipulator_set_matrix_location(cage, origin);
- WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, false);
+ WM_gizmo_set_matrix_location(cage, origin);
+ WM_gizmo_set_flag(cage, WM_GIZMO_HIDDEN, false);
/* need to set property here for undo. TODO would prefer to do this in _init */
SpaceNode *snode = CTX_wm_space_node(C);
#if 0
PointerRNA nodeptr;
RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr);
- WM_manipulator_target_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1);
- WM_manipulator_target_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1);
+ WM_gizmo_target_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1);
+ WM_gizmo_target_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1);
#endif
- WM_manipulator_target_property_def_func(
+ WM_gizmo_target_property_def_func(
cage, "matrix",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_node_backdrop_prop_matrix_get,
- .value_set_fn = manipulator_node_backdrop_prop_matrix_set,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_node_backdrop_prop_matrix_get,
+ .value_set_fn = gizmo_node_backdrop_prop_matrix_set,
.range_get_fn = NULL,
.user_data = snode,
});
}
else {
- WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(cage, WM_GIZMO_HIDDEN, true);
}
BKE_image_release_ibuf(ima, ibuf, lock);
}
-void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt)
+void NODE_GGT_backdrop_transform(wmGizmoGroupType *gzgt)
{
- wgt->name = "Backdrop Transform Widget";
- wgt->idname = "NODE_WGT_backdrop_transform";
+ gzgt->name = "Backdrop Transform Widget";
+ gzgt->idname = "NODE_GGT_backdrop_transform";
- wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
+ gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
- wgt->poll = WIDGETGROUP_node_transform_poll;
- wgt->setup = WIDGETGROUP_node_transform_setup;
- wgt->refresh = WIDGETGROUP_node_transform_refresh;
+ gzgt->poll = WIDGETGROUP_node_transform_poll;
+ gzgt->setup = WIDGETGROUP_node_transform_setup;
+ gzgt->refresh = WIDGETGROUP_node_transform_refresh;
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Crop Manipulator
+/** \name Crop Gizmo
* \{ */
struct NodeCropWidgetGroup {
- wmManipulator *border;
+ wmGizmo *border;
struct {
float dims[2];
@@ -219,7 +219,7 @@ struct NodeCropWidgetGroup {
} update_data;
};
-static void manipulator_node_crop_update(struct NodeCropWidgetGroup *crop_group)
+static void gizmo_node_crop_update(struct NodeCropWidgetGroup *crop_group)
{
RNA_property_update(crop_group->update_data.context, &crop_group->update_data.ptr, crop_group->update_data.prop);
}
@@ -257,15 +257,15 @@ static void two_xy_from_rect(NodeTwoXYs *nxy, const rctf *rect, const float dims
}
/* scale callbacks */
-static void manipulator_node_crop_prop_matrix_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_node_crop_prop_matrix_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
float (*matrix)[4] = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata;
+ BLI_assert(gz_prop->type->array_length == 16);
+ struct NodeCropWidgetGroup *crop_group = gz->parent_gzgroup->customdata;
const float *dims = crop_group->state.dims;
- const bNode *node = mpr_prop->custom_func.user_data;
+ const bNode *node = gz_prop->custom_func.user_data;
const NodeTwoXYs *nxy = node->storage;
bool is_relative = (bool)node->custom2;
rctf rct;
@@ -276,15 +276,15 @@ static void manipulator_node_crop_prop_matrix_get(
matrix[3][1] = (BLI_rctf_cent_y(&rct) - 0.5f) * dims[1];
}
-static void manipulator_node_crop_prop_matrix_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_node_crop_prop_matrix_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value_p)
{
const float (*matrix)[4] = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata;
+ BLI_assert(gz_prop->type->array_length == 16);
+ struct NodeCropWidgetGroup *crop_group = gz->parent_gzgroup->customdata;
const float *dims = crop_group->state.dims;
- bNode *node = mpr_prop->custom_func.user_data;
+ bNode *node = gz_prop->custom_func.user_data;
NodeTwoXYs *nxy = node->storage;
bool is_relative = (bool)node->custom2;
rctf rct;
@@ -293,10 +293,10 @@ static void manipulator_node_crop_prop_matrix_set(
BLI_rctf_recenter(&rct, (matrix[3][0] / dims[0]) + 0.5f, (matrix[3][1] / dims[1]) + 0.5f);
BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, &rct, &rct);
two_xy_from_rect(nxy, &rct, dims, is_relative);
- manipulator_node_crop_update(crop_group);
+ gizmo_node_crop_update(crop_group);
}
-static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -318,33 +318,33 @@ static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmManipulatorGroupType
return false;
}
-static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
struct NodeCropWidgetGroup *crop_group = MEM_mallocN(sizeof(struct NodeCropWidgetGroup), __func__);
- crop_group->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
+ crop_group->border = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL);
RNA_enum_set(crop_group->border->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE);
- mgroup->customdata = crop_group;
+ gzgroup->customdata = crop_group;
}
-static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
ARegion *ar = CTX_wm_region(C);
- wmManipulator *mpr = mgroup->manipulators.first;
+ wmGizmo *gz = gzgroup->gizmos.first;
SpaceNode *snode = CTX_wm_space_node(C);
- node_manipulator_calc_matrix_space(snode, ar, mpr->matrix_space);
+ node_gizmo_calc_matrix_space(snode, ar, gz->matrix_space);
}
-static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
Main *bmain = CTX_data_main(C);
- struct NodeCropWidgetGroup *crop_group = mgroup->customdata;
- wmManipulator *mpr = crop_group->border;
+ struct NodeCropWidgetGroup *crop_group = gzgroup->customdata;
+ wmGizmo *gz = crop_group->border;
void *lock;
Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
@@ -354,8 +354,8 @@ static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup
crop_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f;
crop_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f;
- RNA_float_set_array(mpr->ptr, "dimensions", crop_group->state.dims);
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ RNA_float_set_array(gz->ptr, "dimensions", crop_group->state.dims);
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node = nodeGetActive(snode->edittree);
@@ -364,33 +364,33 @@ static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup
RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeCrop, node, &crop_group->update_data.ptr);
crop_group->update_data.prop = RNA_struct_find_property(&crop_group->update_data.ptr, "relative");
- WM_manipulator_target_property_def_func(
- mpr, "matrix",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_node_crop_prop_matrix_get,
- .value_set_fn = manipulator_node_crop_prop_matrix_set,
+ WM_gizmo_target_property_def_func(
+ gz, "matrix",
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_node_crop_prop_matrix_get,
+ .value_set_fn = gizmo_node_crop_prop_matrix_set,
.range_get_fn = NULL,
.user_data = node,
});
}
else {
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true);
}
BKE_image_release_ibuf(ima, ibuf, lock);
}
-void NODE_WGT_backdrop_crop(wmManipulatorGroupType *wgt)
+void NODE_GGT_backdrop_crop(wmGizmoGroupType *gzgt)
{
- wgt->name = "Backdrop Crop Widget";
- wgt->idname = "NODE_WGT_backdrop_crop";
+ gzgt->name = "Backdrop Crop Widget";
+ gzgt->idname = "NODE_GGT_backdrop_crop";
- wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
+ gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
- wgt->poll = WIDGETGROUP_node_crop_poll;
- wgt->setup = WIDGETGROUP_node_crop_setup;
- wgt->draw_prepare = WIDGETGROUP_node_crop_draw_prepare;
- wgt->refresh = WIDGETGROUP_node_crop_refresh;
+ gzgt->poll = WIDGETGROUP_node_crop_poll;
+ gzgt->setup = WIDGETGROUP_node_crop_setup;
+ gzgt->draw_prepare = WIDGETGROUP_node_crop_draw_prepare;
+ gzgt->refresh = WIDGETGROUP_node_crop_refresh;
}
/** \} */
@@ -401,14 +401,14 @@ void NODE_WGT_backdrop_crop(wmManipulatorGroupType *wgt)
* \{ */
struct NodeSunBeamsWidgetGroup {
- wmManipulator *manipulator;
+ wmGizmo *gizmo;
struct {
float dims[2];
} state;
};
-static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -427,36 +427,36 @@ static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmManipulatorGroupTyp
return false;
}
-static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
struct NodeSunBeamsWidgetGroup *sbeam_group = MEM_mallocN(sizeof(struct NodeSunBeamsWidgetGroup), __func__);
- sbeam_group->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL);
- wmManipulator *mpr = sbeam_group->manipulator;
+ sbeam_group->gizmo = WM_gizmo_new("GIZMO_GT_grab_3d", gzgroup, NULL);
+ wmGizmo *gz = sbeam_group->gizmo;
- RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D);
+ RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_CROSS_2D);
- mpr->scale_basis = 0.05f;
+ gz->scale_basis = 0.05f;
- mgroup->customdata = sbeam_group;
+ gzgroup->customdata = sbeam_group;
}
-static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
- struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata;
+ struct NodeSunBeamsWidgetGroup *sbeam_group = gzgroup->customdata;
ARegion *ar = CTX_wm_region(C);
- wmManipulator *mpr = mgroup->manipulators.first;
+ wmGizmo *gz = gzgroup->gizmos.first;
SpaceNode *snode = CTX_wm_space_node(C);
- node_manipulator_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, mpr->matrix_space);
+ node_gizmo_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, gz->matrix_space);
}
-static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
Main *bmain = CTX_data_main(C);
- struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata;
- wmManipulator *mpr = sbeam_group->manipulator;
+ struct NodeSunBeamsWidgetGroup *sbeam_group = gzgroup->customdata;
+ wmGizmo *gz = sbeam_group->gizmo;
void *lock;
Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
@@ -472,28 +472,28 @@ static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup
/* need to set property here for undo. TODO would prefer to do this in _init */
PointerRNA nodeptr;
RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeSunBeams, node, &nodeptr);
- WM_manipulator_target_property_def_rna(mpr, "offset", &nodeptr, "source", -1);
+ WM_gizmo_target_property_def_rna(gz, "offset", &nodeptr, "source", -1);
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true);
+ WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_MODAL, true);
}
else {
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true);
}
BKE_image_release_ibuf(ima, ibuf, lock);
}
-void NODE_WGT_backdrop_sun_beams(wmManipulatorGroupType *wgt)
+void NODE_GGT_backdrop_sun_beams(wmGizmoGroupType *gzgt)
{
- wgt->name = "Sun Beams Widget";
- wgt->idname = "NODE_WGT_sbeam";
+ gzgt->name = "Sun Beams Widget";
+ gzgt->idname = "NODE_GGT_sbeam";
- wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
+ gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
- wgt->poll = WIDGETGROUP_node_sbeam_poll;
- wgt->setup = WIDGETGROUP_node_sbeam_setup;
- wgt->draw_prepare = WIDGETGROUP_node_sbeam_draw_prepare;
- wgt->refresh = WIDGETGROUP_node_sbeam_refresh;
+ gzgt->poll = WIDGETGROUP_node_sbeam_poll;
+ gzgt->setup = WIDGETGROUP_node_sbeam_setup;
+ gzgt->draw_prepare = WIDGETGROUP_node_sbeam_draw_prepare;
+ gzgt->refresh = WIDGETGROUP_node_sbeam_refresh;
}
/** \} */
@@ -506,14 +506,14 @@ void NODE_WGT_backdrop_sun_beams(wmManipulatorGroupType *wgt)
* \{ */
struct NodeCornerPinWidgetGroup {
- wmManipulator *manipulators[4];
+ wmGizmo *gizmos[4];
struct {
float dims[2];
} state;
};
-static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -532,43 +532,43 @@ static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmManipulatorGro
return false;
}
-static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
struct NodeCornerPinWidgetGroup *cpin_group = MEM_mallocN(sizeof(struct NodeCornerPinWidgetGroup), __func__);
- const wmManipulatorType *wt_grab_3d = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", false);
+ const wmGizmoType *gzt_grab_3d = WM_gizmotype_find("GIZMO_GT_grab_3d", false);
for (int i = 0; i < 4; i++) {
- cpin_group->manipulators[i] = WM_manipulator_new_ptr(wt_grab_3d, mgroup, NULL);
- wmManipulator *mpr = cpin_group->manipulators[i];
+ cpin_group->gizmos[i] = WM_gizmo_new_ptr(gzt_grab_3d, gzgroup, NULL);
+ wmGizmo *gz = cpin_group->gizmos[i];
- RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D);
+ RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_CROSS_2D);
- mpr->scale_basis = 0.01f;
+ gz->scale_basis = 0.01f;
}
- mgroup->customdata = cpin_group;
+ gzgroup->customdata = cpin_group;
}
-static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
- struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata;
+ struct NodeCornerPinWidgetGroup *cpin_group = gzgroup->customdata;
ARegion *ar = CTX_wm_region(C);
SpaceNode *snode = CTX_wm_space_node(C);
float matrix_space[4][4];
- node_manipulator_calc_matrix_space_with_image_dims(snode, ar, cpin_group->state.dims, matrix_space);
+ node_gizmo_calc_matrix_space_with_image_dims(snode, ar, cpin_group->state.dims, matrix_space);
for (int i = 0; i < 4; i++) {
- wmManipulator *mpr = cpin_group->manipulators[i];
- copy_m4_m4(mpr->matrix_space, matrix_space);
+ wmGizmo *gz = cpin_group->gizmos[i];
+ copy_m4_m4(gz->matrix_space, matrix_space);
}
}
-static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
Main *bmain = CTX_data_main(C);
- struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata;
+ struct NodeCornerPinWidgetGroup *cpin_group = gzgroup->customdata;
void *lock;
Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
@@ -585,37 +585,37 @@ static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulator
int i = 0;
for (bNodeSocket *sock = node->inputs.first; sock && i < 4; sock = sock->next) {
if (sock->type == SOCK_VECTOR) {
- wmManipulator *mpr = cpin_group->manipulators[i++];
+ wmGizmo *gz = cpin_group->gizmos[i++];
PointerRNA sockptr;
RNA_pointer_create((ID *)snode->edittree, &RNA_NodeSocket, sock, &sockptr);
- WM_manipulator_target_property_def_rna(mpr, "offset", &sockptr, "default_value", -1);
+ WM_gizmo_target_property_def_rna(gz, "offset", &sockptr, "default_value", -1);
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true);
+ WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_MODAL, true);
}
}
}
else {
for (int i = 0; i < 4; i++) {
- wmManipulator *mpr = cpin_group->manipulators[i];
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ wmGizmo *gz = cpin_group->gizmos[i];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true);
}
}
BKE_image_release_ibuf(ima, ibuf, lock);
}
-void NODE_WGT_backdrop_corner_pin(wmManipulatorGroupType *wgt)
+void NODE_GGT_backdrop_corner_pin(wmGizmoGroupType *gzgt)
{
- wgt->name = "Corner Pin Widget";
- wgt->idname = "NODE_WGT_backdrop_corner_pin";
+ gzgt->name = "Corner Pin Widget";
+ gzgt->idname = "NODE_GGT_backdrop_corner_pin";
- wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
+ gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
- wgt->poll = WIDGETGROUP_node_corner_pin_poll;
- wgt->setup = WIDGETGROUP_node_corner_pin_setup;
- wgt->draw_prepare = WIDGETGROUP_node_corner_pin_draw_prepare;
- wgt->refresh = WIDGETGROUP_node_corner_pin_refresh;
+ gzgt->poll = WIDGETGROUP_node_corner_pin_poll;
+ gzgt->setup = WIDGETGROUP_node_corner_pin_setup;
+ gzgt->draw_prepare = WIDGETGROUP_node_corner_pin_draw_prepare;
+ gzgt->refresh = WIDGETGROUP_node_corner_pin_refresh;
}
/** \} */
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index d7a43bda461..ed7379acca9 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -224,11 +224,13 @@ void NODE_OT_viewer_border(struct wmOperatorType *ot);
void NODE_OT_clear_viewer_border(struct wmOperatorType *ot);
/* node_widgets.c */
-void NODE_WGT_backdrop_transform(struct wmManipulatorGroupType *wgt);
-void NODE_WGT_backdrop_crop(struct wmManipulatorGroupType *wgt);
-void NODE_WGT_backdrop_sun_beams(struct wmManipulatorGroupType *wgt);
-void NODE_WGT_backdrop_corner_pin(struct wmManipulatorGroupType *wgt);
+void NODE_GGT_backdrop_transform(struct wmGizmoGroupType *gzgt);
+void NODE_GGT_backdrop_crop(struct wmGizmoGroupType *gzgt);
+void NODE_GGT_backdrop_sun_beams(struct wmGizmoGroupType *gzgt);
+void NODE_GGT_backdrop_corner_pin(struct wmGizmoGroupType *gzgt);
+void NODE_OT_cryptomatte_layer_add(struct wmOperatorType *ot);
+void NODE_OT_cryptomatte_layer_remove(struct wmOperatorType *ot);
extern const char *node_context_dir[];
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 069d8a500ca..dccc999b2d1 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -129,6 +129,9 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_tree_socket_add);
WM_operatortype_append(NODE_OT_tree_socket_remove);
WM_operatortype_append(NODE_OT_tree_socket_move);
+
+ WM_operatortype_append(NODE_OT_cryptomatte_layer_add);
+ WM_operatortype_append(NODE_OT_cryptomatte_layer_remove);
}
void ED_operatormacros_node(void)
@@ -311,7 +314,9 @@ void node_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "NODE_OT_delete_reconnect", DELKEY, KM_PRESS, KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
@@ -331,7 +336,7 @@ void node_keymap(struct wmKeyConfig *keyconf)
/* node group operators */
WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "NODE_OT_group_separate", PKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "NODE_OT_group_edit", TABKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "exit", false);
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index b884db1ced4..8667056a687 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -446,18 +446,13 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
uiBut *but;
NodeLinkArg *argN;
int first = 1;
- int compatibility = 0;
-
- if (ntree->type == NTREE_SHADER) {
- compatibility = NODE_NEW_SHADING;
- }
/* generate array of node types sorted by UI name */
bNodeType **sorted_ntypes = NULL;
BLI_array_declare(sorted_ntypes);
NODE_TYPES_BEGIN(ntype) {
- if (compatibility && !(ntype->compatibility & compatibility)) {
+ if (!(ntype->poll && ntype->poll(ntype, ntree))) {
continue;
}
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index fa6fa02cdc5..10f337440d4 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -384,8 +384,7 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
}
-static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
/* note, ED_area_tag_refresh will re-execute compositor */
SpaceNode *snode = sa->spacedata.first;
@@ -647,13 +646,13 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar)
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
- /* manipulators stay in the background for now - quick patchjob to make sure nodes themselves work */
- if (ar->manipulator_map == NULL) {
- ar->manipulator_map = WM_manipulatormap_new_from_type(
- &(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW});
+ /* gizmos stay in the background for now - quick patchjob to make sure nodes themselves work */
+ if (ar->gizmo_map == NULL) {
+ ar->gizmo_map = WM_gizmomap_new_from_type(
+ &(const struct wmGizmoMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW});
}
- WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
+ WM_gizmomap_add_handlers(ar, ar->gizmo_map);
/* own keymaps */
keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0);
@@ -750,10 +749,10 @@ static void node_header_region_draw(const bContext *C, ARegion *ar)
/* used for header + main region */
static void node_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
- wmManipulatorMap *mmap = ar->manipulator_map;
+ wmGizmoMap *gzmap = ar->gizmo_map;
/* context changes */
switch (wmn->category) {
@@ -763,13 +762,13 @@ static void node_region_listener(
ED_region_tag_redraw(ar);
break;
case ND_SPACE_NODE_VIEW:
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
break;
}
break;
case NC_SCREEN:
if (wmn->data == ND_LAYOUTSET || wmn->action == NA_EDITED) {
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
}
switch (wmn->data) {
case ND_ANIMPLAY:
@@ -785,13 +784,13 @@ static void node_region_listener(
case NC_SCENE:
ED_region_tag_redraw(ar);
if (wmn->data == ND_RENDER_RESULT) {
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
}
break;
case NC_NODE:
ED_region_tag_redraw(ar);
if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
}
break;
case NC_MATERIAL:
@@ -864,12 +863,12 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
static void node_widgets(void)
{
/* create the widgetmap for the area here */
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(
- &(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW});
- WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_transform);
- WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_crop);
- WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_sun_beams);
- WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_corner_pin);
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(
+ &(const struct wmGizmoMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW});
+ WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_transform);
+ WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_crop);
+ WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_sun_beams);
+ WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_corner_pin);
}
static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
@@ -988,7 +987,7 @@ void ED_spacetype_node(void)
st->refresh = node_area_refresh;
st->context = node_context;
st->dropboxes = node_dropboxes;
- st->manipulators = node_widgets;
+ st->gizmos = node_widgets;
st->id_remap = node_id_remap;
st->space_subtype_item_extend = node_space_subtype_item_extend;
st->space_subtype_get = node_space_subtype_get;
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 75349ce99c5..87f7e1e4fb8 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -742,11 +742,11 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex)
GPU_line_width(1.0f);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_BACK, -15, -200);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, sizex, v2d->cur.ymax);
immVertex2f(pos, sizex, miny);
@@ -1142,7 +1142,7 @@ static void tselem_draw_icon(
ICON_DRAW(ICON_RENDER_RESULT);
break;
case TSE_LINKED_LAMP:
- ICON_DRAW(ICON_LAMP_DATA);
+ ICON_DRAW(ICON_LIGHT_DATA);
break;
case TSE_LINKED_MAT:
ICON_DRAW(ICON_MATERIAL_DATA);
@@ -1201,7 +1201,7 @@ static void tselem_draw_icon(
Object *ob = (Object *)tselem->id;
switch (ob->type) {
case OB_LAMP:
- ICON_CLICK_DRAW(ICON_OUTLINER_OB_LAMP); break;
+ ICON_CLICK_DRAW(ICON_OUTLINER_OB_LIGHT); break;
case OB_MESH:
ICON_CLICK_DRAW(ICON_OUTLINER_OB_MESH); break;
case OB_CAMERA:
@@ -1252,17 +1252,17 @@ static void tselem_draw_icon(
Lamp *la = (Lamp *)tselem->id;
switch (la->type) {
case LA_LOCAL:
- tselem_draw_icon_uibut(&arg, ICON_LAMP_POINT); break;
+ tselem_draw_icon_uibut(&arg, ICON_LIGHT_POINT); break;
case LA_SUN:
- tselem_draw_icon_uibut(&arg, ICON_LAMP_SUN); break;
+ tselem_draw_icon_uibut(&arg, ICON_LIGHT_SUN); break;
case LA_SPOT:
- tselem_draw_icon_uibut(&arg, ICON_LAMP_SPOT); break;
+ tselem_draw_icon_uibut(&arg, ICON_LIGHT_SPOT); break;
case LA_HEMI:
- tselem_draw_icon_uibut(&arg, ICON_LAMP_HEMI); break;
+ tselem_draw_icon_uibut(&arg, ICON_LIGHT_HEMI); break;
case LA_AREA:
- tselem_draw_icon_uibut(&arg, ICON_LAMP_AREA); break;
+ tselem_draw_icon_uibut(&arg, ICON_LIGHT_AREA); break;
default:
- tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LAMP); break;
+ tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LIGHT); break;
}
break;
}
@@ -1740,8 +1740,8 @@ static void outliner_draw_tree_element(
/* divider */
{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
unsigned char col[4];
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1798,7 +1798,7 @@ static void outliner_draw_tree_element_floating(
const TreeElement *te_insert = te_floating->drag_data->insert_handle;
const int line_width = 2;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
int coord_y = te_insert->ys;
int coord_x = te_insert->xs;
float col[4];
@@ -1819,7 +1819,7 @@ static void outliner_draw_tree_element_floating(
immUniformColor4fv(col);
GPU_line_width(line_width);
- immBegin(GWN_PRIM_LINE_STRIP, 2);
+ immBegin(GPU_PRIM_LINE_STRIP, 2);
immVertex2f(pos, coord_x, coord_y);
immVertex2f(pos, ar->v2d.cur.xmax, coord_y);
immEnd();
@@ -1828,7 +1828,7 @@ static void outliner_draw_tree_element_floating(
BLI_assert(te_floating->drag_data->insert_type == TE_INSERT_INTO);
immUniformColor3fvAlpha(col, col[3] * 0.5f);
- immBegin(GWN_PRIM_TRI_STRIP, 4);
+ immBegin(GPU_PRIM_TRI_STRIP, 4);
immVertex2f(pos, coord_x, coord_y + UI_UNIT_Y);
immVertex2f(pos, coord_x, coord_y);
immVertex2f(pos, ar->v2d.cur.xmax, coord_y + UI_UNIT_Y);
@@ -1902,8 +1902,8 @@ static void outliner_draw_hierarchy_lines_recursive(
static void outliner_draw_hierarchy_lines(SpaceOops *soops, ListBase *lb, int startx, int *starty)
{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
unsigned char col[4];
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1925,8 +1925,8 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
/* selection status */
if (TSELEM_OPEN(tselem, soops)) {
if (tselem->type == TSE_RNA_STRUCT) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immThemeColorShadeAlpha(TH_BACK, -15, -200);
immRecti(pos, 0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1);
@@ -1938,12 +1938,12 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
if (TSELEM_OPEN(tselem, soops)) {
outliner_draw_struct_marks(ar, soops, &te->subtree, starty);
if (tselem->type == TSE_RNA_STRUCT) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immThemeColorShadeAlpha(TH_BACK, -15, -200);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, 0, (float)*starty + UI_UNIT_Y);
immVertex2f(pos, ar->v2d.cur.xmax, (float)*starty + UI_UNIT_Y);
immEnd();
@@ -2008,8 +2008,8 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx,
col_searchmatch[3] = 0.5f;
GPU_blend(true);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
outliner_draw_highlights_recursive(
pos, ar, soops, &soops->tree, col_selection, col_highlight, col_searchmatch,
@@ -2083,8 +2083,8 @@ static void outliner_back(ARegion *ar)
ystart = (int)ar->v2d.tot.ymax;
ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShade(TH_BACK, 6);
@@ -2094,7 +2094,7 @@ static void outliner_back(ARegion *ar)
int tot = (int)floor(ystart - ar->v2d.cur.ymin + 2 * UI_UNIT_Y) / (2 * UI_UNIT_Y);
if (tot > 0) {
- immBegin(GWN_PRIM_TRIS, 6 * tot);
+ immBegin(GPU_PRIM_TRIS, 6 * tot);
while (tot--) {
y1 -= 2 * UI_UNIT_Y;
y2 = y1 + UI_UNIT_Y;
@@ -2115,10 +2115,10 @@ static void outliner_draw_restrictcols(ARegion *ar)
{
GPU_line_width(1.0f);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_BACK, -15, -200);
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymax);
immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymin);
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 1c78931b449..d9bcf05fa29 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -165,7 +165,7 @@ static int outliner_highlight_update(bContext *C, wmOperator *UNUSED(op), const
bool changed = false;
if (!hovered_te || !(hovered_te->store_elem->flag & TSE_HIGHLIGHTED)) {
- changed = outliner_set_flag(&soops->tree, TSE_HIGHLIGHTED, false);
+ changed = outliner_flag_set(&soops->tree, TSE_HIGHLIGHTED, false);
if (hovered_te) {
hovered_te->store_elem->flag |= TSE_HIGHLIGHTED;
changed = true;
@@ -201,7 +201,7 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement
/* all below close/open? */
if (all) {
tselem->flag &= ~TSE_CLOSED;
- outliner_set_flag(&te->subtree, TSE_CLOSED, !outliner_has_one_flag(&te->subtree, TSE_CLOSED, 1));
+ outliner_flag_set(&te->subtree, TSE_CLOSED, !outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1));
}
else {
if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED;
@@ -834,7 +834,7 @@ static int outliner_count_levels(ListBase *lb, const int curlevel)
return level;
}
-int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel)
+int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel)
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -844,7 +844,7 @@ int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel)
tselem = TREESTORE(te);
if (tselem->flag & flag) return curlevel;
- level = outliner_has_one_flag(&te->subtree, flag, curlevel + 1);
+ level = outliner_flag_is_any_test(&te->subtree, flag, curlevel + 1);
if (level) return level;
}
return 0;
@@ -854,7 +854,7 @@ int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel)
* Set or unset \a flag for all outliner elements in \a lb and sub-trees.
* \return if any flag was modified.
*/
-bool outliner_set_flag(ListBase *lb, short flag, short set)
+bool outliner_flag_set(ListBase *lb, short flag, short set)
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -874,7 +874,22 @@ bool outliner_set_flag(ListBase *lb, short flag, short set)
tselem->flag |= flag;
changed = true;
}
- changed |= outliner_set_flag(&te->subtree, flag, set);
+ changed |= outliner_flag_set(&te->subtree, flag, set);
+ }
+
+ return changed;
+}
+
+bool outliner_flag_flip(ListBase *lb, short flag)
+{
+ TreeElement *te;
+ TreeStoreElem *tselem;
+ bool changed = false;
+
+ for (te = lb->first; te; te = te->next) {
+ tselem = TREESTORE(te);
+ tselem->flag ^= flag;
+ changed |= outliner_flag_flip(&te->subtree, flag);
}
return changed;
@@ -914,10 +929,10 @@ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op))
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
- if (outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1))
- outliner_set_flag(&soops->tree, TSE_CLOSED, 0);
+ if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1))
+ outliner_flag_set(&soops->tree, TSE_CLOSED, 0);
else
- outliner_set_flag(&soops->tree, TSE_CLOSED, 1);
+ outliner_flag_set(&soops->tree, TSE_CLOSED, 1);
ED_region_tag_redraw(ar);
@@ -940,16 +955,27 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot)
/* Toggle Selected (Outliner) ---------------------------------------- */
-static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op))
+static int outliner_select_all_exec(bContext *C, wmOperator *op)
{
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
+ int action = RNA_enum_get(op->ptr, "action");
+ if (action == SEL_TOGGLE) {
+ action = outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1) ? SEL_DESELECT : SEL_SELECT;
+ }
- if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1))
- outliner_set_flag(&soops->tree, TSE_SELECTED, 0);
- else
- outliner_set_flag(&soops->tree, TSE_SELECTED, 1);
+ switch (action) {
+ case SEL_SELECT:
+ outliner_flag_set(&soops->tree, TSE_SELECTED, 1);
+ break;
+ case SEL_DESELECT:
+ outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
+ break;
+ case SEL_INVERT:
+ outliner_flag_flip(&soops->tree, TSE_SELECTED);
+ break;
+ }
DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -958,18 +984,21 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-void OUTLINER_OT_selected_toggle(wmOperatorType *ot)
+void OUTLINER_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Toggle Selected";
- ot->idname = "OUTLINER_OT_selected_toggle";
+ ot->idname = "OUTLINER_OT_select_all";
ot->description = "Toggle the Outliner selection of items";
/* callbacks */
- ot->exec = outliner_toggle_selected_exec;
+ ot->exec = outliner_select_all_exec;
ot->poll = ED_operator_outliner_active;
- /* no undo or registry, UI option */
+ /* no undo or registry */
+
+ /* rna */
+ WM_operator_properties_select_all(ot);
}
/* ************************************************************** */
@@ -1211,7 +1240,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
outliner_set_coordinates(ar, soops);
/* deselect all visible, and select found element */
- outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0);
+ outliner_flag_set(soops, &soops->tree, TSE_SELECTED, 0);
tselem->flag |= TSE_SELECTED;
/* make te->ys center of view */
@@ -1271,7 +1300,7 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op)
const bool add = RNA_boolean_get(op->ptr, "open");
int level;
- level = outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1);
+ level = outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1);
if (add == 1) {
if (level) outliner_openclose_level(&soops->tree, 1, level, 1);
}
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 0ab22208841..093ad9361c2 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -245,8 +245,9 @@ void outliner_do_object_operation(
int common_restrict_check(struct bContext *C, struct Object *ob);
-int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel);
-bool outliner_set_flag(ListBase *lb, short flag, short set);
+int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel);
+bool outliner_flag_set(ListBase *lb, short flag, short set);
+bool outliner_flag_flip(ListBase *lb, short flag);
void object_toggle_visibility_cb(
struct bContext *C, struct ReportList *reports, struct Scene *scene,
@@ -305,7 +306,7 @@ void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot);
void OUTLINER_OT_select_border(struct wmOperatorType *ot);
-void OUTLINER_OT_selected_toggle(struct wmOperatorType *ot);
+void OUTLINER_OT_select_all(struct wmOperatorType *ot);
void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot);
void OUTLINER_OT_scroll_page(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 4d8c0c5bd38..0dd492839c9 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -370,7 +370,7 @@ static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *op, const wmE
/* by default we don't change the item position */
te_dragged->drag_data->insert_handle = te_dragged;
/* unset highlighted tree element, dragged one will be highlighted instead */
- outliner_set_flag(&soops->tree, TSE_HIGHLIGHTED, false);
+ outliner_flag_set(&soops->tree, TSE_HIGHLIGHTED, false);
ED_region_tag_redraw_no_rebuild(ar);
@@ -431,7 +431,7 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_show_hierarchy);
WM_operatortype_append(OUTLINER_OT_scroll_page);
- WM_operatortype_append(OUTLINER_OT_selected_toggle);
+ WM_operatortype_append(OUTLINER_OT_select_all);
WM_operatortype_append(OUTLINER_OT_expanded_toggle);
WM_operatortype_append(OUTLINER_OT_keyingset_add_selected);
@@ -467,7 +467,7 @@ static wmKeyMap *outliner_item_drag_drop_modal_keymap(wmKeyConfig *keyconf)
{OUTLINER_ITEM_DRAG_CONFIRM, "CONFIRM", 0, "Confirm/Drop", ""},
{0, NULL, 0, NULL, NULL}
};
- const char *map_name = "Outliner Item Drap & Drop Modal Map";
+ const char *map_name = "Outliner Item Drag & Drop Modal Map";
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, map_name);
@@ -542,26 +542,33 @@ void outliner_keymap(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "open", false); /* close */
- WM_keymap_verify_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0);
+ kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", AKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
+ kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
+
+ WM_keymap_add_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0);
/* keying sets - only for databrowse */
- WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_remove_selected", KKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "OUTLINER_OT_keyingset_remove_selected", KKEY, KM_PRESS, KM_ALT, 0);
- WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete", IKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "ANIM_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "ANIM_OT_keyframe_delete", IKEY, KM_PRESS, KM_ALT, 0);
- WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0);
+ /* Note: was D, Alt-D, keep these free for duplicate. */
+ WM_keymap_add_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
- WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_new", CKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "OUTLINER_OT_collection_new", CKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_delete", XKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_delete", DELKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "OUTLINER_OT_collection_delete", XKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "OUTLINER_OT_collection_delete", DELKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0);
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "select", false);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 6668ea1faeb..7ab13f36953 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -173,24 +173,25 @@ void outliner_object_mode_toggle(
/* Outliner Element Selection/Activation on Click */
static eOLDrawState active_viewlayer(
- bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
+ bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, const eOLSetState set)
{
- Scene *sce;
-
/* paranoia check */
if (te->idcode != ID_SCE)
return OL_DRAWSEL_NONE;
- sce = (Scene *)tselem->id;
- WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = te->directdata;
if (set != OL_SETSEL_NONE) {
- BKE_workspace_view_layer_set(workspace, view_layer, sce);
- WM_event_add_notifier(C, NC_SCREEN | ND_LAYER, NULL);
+ wmWindow *win = CTX_wm_window(C);
+ Scene *scene = WM_window_get_active_scene(win);
+
+ if (BLI_findindex(&scene->view_layers, view_layer) != -1) {
+ WM_window_set_active_view_layer(win, view_layer);
+ WM_event_add_notifier(C, NC_SCREEN | ND_LAYER, NULL);
+ }
}
else {
- return BKE_workspace_view_layer_get(workspace, sce) == view_layer;
+ return CTX_data_view_layer(C) == view_layer;
}
return OL_DRAWSEL_NONE;
}
@@ -262,7 +263,7 @@ static eOLDrawState tree_element_set_active_object(
sce = (Scene *)outliner_search_back(soops, te, ID_SCE);
if (sce && scene != sce) {
- WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce);
+ WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce);
scene = sce;
}
@@ -431,7 +432,7 @@ static eOLDrawState tree_element_active_world(
if (set != OL_SETSEL_NONE) {
/* make new scene active */
if (sce && scene != sce) {
- WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce);
+ WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce);
}
}
@@ -895,7 +896,7 @@ eOLDrawState tree_element_type_active(
case TSE_CONSTRAINT:
return tree_element_active_constraint(C, scene, view_layer, te, tselem, set);
case TSE_R_LAYER:
- return active_viewlayer(C, scene, view_layer, te, tselem, set);
+ return active_viewlayer(C, scene, view_layer, te, set);
case TSE_POSEGRP:
return tree_element_active_posegroup(C, scene, view_layer, te, tselem, set);
case TSE_SEQUENCE:
@@ -950,7 +951,7 @@ static void do_outliner_item_activate_tree_element(
/* editmode? */
if (te->idcode == ID_SCE) {
if (scene != (Scene *)tselem->id) {
- WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), (Scene *)tselem->id);
+ WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), (Scene *)tselem->id);
}
}
else if (te->idcode == ID_GR) {
@@ -1027,7 +1028,7 @@ void outliner_item_select(SpaceOops *soops, const TreeElement *te, const bool ex
const short new_flag = toggle ? (tselem->flag ^ TSE_SELECTED) : (tselem->flag | TSE_SELECTED);
if (extend == false) {
- outliner_set_flag(&soops->tree, TSE_SELECTED, false);
+ outliner_flag_set(&soops->tree, TSE_SELECTED, false);
}
tselem->flag = new_flag;
}
@@ -1038,8 +1039,8 @@ static void outliner_item_toggle_closed(TreeElement *te, const bool toggle_child
if (toggle_children) {
tselem->flag &= ~TSE_CLOSED;
- const bool all_opened = !outliner_has_one_flag(&te->subtree, TSE_CLOSED, 1);
- outliner_set_flag(&te->subtree, TSE_CLOSED, all_opened);
+ const bool all_opened = !outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1);
+ outliner_flag_set(&te->subtree, TSE_CLOSED, all_opened);
}
else {
tselem->flag ^= TSE_CLOSED;
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 9952db5e652..190ef9fa229 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -580,7 +580,7 @@ void outliner_do_object_operation_ex(
// when objects selected in other scenes... dunno if that should be allowed
Scene *scene_owner = (Scene *)outliner_search_back(soops, te, ID_SCE);
if (scene_owner && scene_act != scene_owner) {
- WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), scene_owner);
+ WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), scene_owner);
}
/* important to use 'scene_owner' not scene_act else deleting objects can crash.
* only use 'scene_act' when 'scene_owner' is NULL, which can happen when the
@@ -956,7 +956,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
Scene *sce = scene; // to be able to delete, scenes are set...
outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_select_cb);
if (scene != sce) {
- WM_window_change_active_scene(bmain, C, win, sce);
+ WM_window_set_active_scene(bmain, C, win, sce);
}
str = "Select Objects";
@@ -967,7 +967,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
Scene *sce = scene; // to be able to delete, scenes are set...
outliner_do_object_operation_ex(C, op->reports, scene, soops, &soops->tree, object_select_hierarchy_cb, false);
if (scene != sce) {
- WM_window_change_active_scene(bmain, C, win, sce);
+ WM_window_set_active_scene(bmain, C, win, sce);
}
str = "Select Object Hierarchy";
DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
@@ -1817,8 +1817,8 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop
/* select object that's clicked on and popup context menu */
if (!(tselem->flag & TSE_SELECTED)) {
- if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1))
- outliner_set_flag(&soops->tree, TSE_SELECTED, 0);
+ if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1))
+ outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
tselem->flag |= TSE_SELECTED;
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 9f6c944c914..28890e42139 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -2160,28 +2160,30 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
}
/* make hierarchy */
ten = soops->tree.first;
- ten = ten->next; /* first one is main */
- while (ten) {
- TreeElement *nten = ten->next, *par;
- tselem = TREESTORE(ten);
- lib = (Library *)tselem->id;
- if (lib && lib->parent) {
- par = (TreeElement *)lib->parent->id.newid;
- if (tselem->id->tag & LIB_TAG_INDIRECT) {
- /* Only remove from 'first level' if lib is not also directly used. */
- BLI_remlink(&soops->tree, ten);
- BLI_addtail(&par->subtree, ten);
- ten->parent = par;
- }
- else {
- /* Else, make a new copy of the libtree for our parent. */
- TreeElement *dupten = outliner_add_library_contents(mainvar, soops, &par->subtree, lib);
- if (dupten) {
- dupten->parent = par;
+ if (ten != NULL) {
+ ten = ten->next; /* first one is main */
+ while (ten) {
+ TreeElement *nten = ten->next, *par;
+ tselem = TREESTORE(ten);
+ lib = (Library *)tselem->id;
+ if (lib && lib->parent) {
+ par = (TreeElement *)lib->parent->id.newid;
+ if (tselem->id->tag & LIB_TAG_INDIRECT) {
+ /* Only remove from 'first level' if lib is not also directly used. */
+ BLI_remlink(&soops->tree, ten);
+ BLI_addtail(&par->subtree, ten);
+ ten->parent = par;
+ }
+ else {
+ /* Else, make a new copy of the libtree for our parent. */
+ TreeElement *dupten = outliner_add_library_contents(mainvar, soops, &par->subtree, lib);
+ if (dupten) {
+ dupten->parent = par;
+ }
}
}
+ ten = nten;
}
- ten = nten;
}
/* restore newid pointers */
for (lib = mainvar->library.first; lib; lib = lib->id.next)
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index e1baaf54163..e4e99f88bf4 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -310,7 +310,7 @@ static void outliner_main_region_free(ARegion *UNUSED(ar))
}
static void outliner_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -459,7 +459,7 @@ static void outliner_header_region_free(ARegion *UNUSED(ar))
}
static void outliner_header_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index 8b6100cd9e0..fe7261f7bbd 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -178,7 +178,7 @@ static void script_header_region_draw(const bContext *C, ARegion *ar)
}
static void script_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index a8688b26280..5d2ceced904 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -879,6 +879,8 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
strip = seq->strip;
se = strip->stripdata;
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
+
if (use_placeholders) {
sequencer_image_seq_reserve_frames(op, se, seq_load.len, minframe, numdigits);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 7da20131069..864609e4157 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -232,9 +232,9 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
BLI_spin_lock(sound->spinlock);
if (!sound->waveform) {
- if (!(sound->flags & SOUND_FLAGS_WAVEFORM_LOADING)) {
+ if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) {
/* prevent sounds from reloading */
- sound->flags |= SOUND_FLAGS_WAVEFORM_LOADING;
+ sound->tags |= SOUND_TAGS_WAVEFORM_LOADING;
BLI_spin_unlock(sound->spinlock);
sequencer_preview_add_sound(C, seq);
}
@@ -267,7 +267,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
GPU_blend(true);
- immBegin(GWN_PRIM_TRI_STRIP, length * 2);
+ immBegin(GPU_PRIM_TRI_STRIP, length * 2);
for (i = 0; i < length; i++) {
float sampleoffset = startsample + ((x1_offset - x1) / stepsize + i) * samplestep;
@@ -343,7 +343,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
col[3] = 196; /* alpha, used for all meta children */
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -457,7 +457,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
immUniformColor4ub(0, 0, 0, 50);
}
- immBegin(GWN_PRIM_TRIS, 3);
+ immBegin(GPU_PRIM_TRIS, 3);
immVertex2fv(pos, v1);
immVertex2fv(pos, v2);
immVertex2fv(pos, v3);
@@ -719,7 +719,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -781,7 +781,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
if (seq->flag & SEQ_LOCK) {
GPU_blend(true);
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES);
immUniform4f("color1", 1.0f, 1.0f, 1.0f, 0.125f);
@@ -799,7 +799,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
if (!BKE_sequence_is_valid_check(seq)) {
GPU_blend(true);
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES);
immUniform4f("color1", 1.0f, 0.0f, 0.0f, 1.0f);
@@ -834,7 +834,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
drawmeta_contents(scene, seq, x1, y1, x2, y2);
}
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
/* TODO: add back stippled line for muted strips? */
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1040,7 +1040,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
GPU_line_width(1.0f);
/* border */
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -1230,9 +1230,9 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
/* Format needs to be created prior to any immBindProgram call.
* Do it here because OCIO binds it's own shader.
*/
- Gwn_VertFormat *imm_format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *imm_format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint texCoord = GPU_vertformat_attr_add(imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (scope) {
IMB_freeImBuf(ibuf);
@@ -1308,8 +1308,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (draw_backdrop) {
/* XXX: need to load identity projection too? */
- gpuPushMatrix();
- gpuLoadIdentity();
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
}
glGenTextures(1, (GLuint *)&texid);
@@ -1331,7 +1331,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
immUniform1i("image", 0);
}
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
if (draw_overlay) {
if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
@@ -1439,7 +1439,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
}
if (draw_backdrop) {
- gpuPopMatrix();
+ GPU_matrix_pop();
return;
}
@@ -1514,7 +1514,7 @@ static void draw_seq_backdrop(View2D *v2d)
{
int i;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* darker gray overlay over the view backdrop */
@@ -1539,10 +1539,10 @@ static void draw_seq_backdrop(View2D *v2d)
/* Darker lines separating the horizontal bands */
i = max_ii(1, ((int)v2d->cur.ymin) - 1);
- int line_ct = (int)v2d->cur.ymax - i + 1;
+ int line_len = (int)v2d->cur.ymax - i + 1;
immUniformThemeColor(TH_GRID);
- immBegin(GWN_PRIM_LINES, line_ct * 2);
- while (line_ct--) {
+ immBegin(GPU_PRIM_LINES, line_len * 2);
+ while (line_len--) {
immVertex2f(pos, v2d->cur.xmax, i);
immVertex2f(pos, v2d->cur.xmin, i);
}
@@ -1593,7 +1593,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
const Sequence *seq = special_seq_update;
GPU_blend(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(255, 255, 255, 48);
@@ -1613,7 +1613,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
GPU_blend(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* draw darkened area outside of active timeline
@@ -1631,7 +1631,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
immUniformThemeColorShade(TH_BACK, -60);
/* thin lines where the actual frames are */
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, frame_sta, v2d->cur.ymin);
immVertex2f(pos, frame_sta, v2d->cur.ymax);
@@ -1649,7 +1649,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
immUniformThemeColorShade(TH_BACK, -40);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, ms->disp_range[0], v2d->cur.ymin);
immVertex2f(pos, ms->disp_range[0], v2d->cur.ymax);
@@ -1735,12 +1735,12 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(0.2f, 0.2f, 0.2f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, cfra_over, v2d->cur.ymin);
immVertex2f(pos, cfra_over, v2d->cur.ymax);
immEnd();
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index 234989ef244..f60bd98c4d6 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -151,7 +151,9 @@ void sequencer_keymap(wmKeyConfig *keyconf)
keymap = WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
@@ -198,7 +200,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_toggle", TABKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_make", GKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", GKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
#ifdef WITH_INPUT_NDOF
diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c
index c58c05b67c0..ae011e48538 100644
--- a/source/blender/editors/space_sequencer/sequencer_preview.c
+++ b/source/blender/editors/space_sequencer/sequencer_preview.c
@@ -96,7 +96,7 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p
/* make sure we cleanup the loading flag! */
BLI_spin_lock(sound->spinlock);
- sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+ sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
BLI_spin_unlock(sound->spinlock);
BLI_mutex_lock(pj->mutex);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 1ec9ea53e33..c440d12e444 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -829,7 +829,7 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot)
/* identifiers */
ot->name = "Select Handles";
ot->idname = "SEQUENCER_OT_select_handles";
- ot->description = "Select manipulator handles on the sides of the selected strip";
+ ot->description = "Select gizmo handles on the sides of the selected strip";
/* api callbacks */
ot->exec = sequencer_select_handles_exec;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 04be1f82a60..8fb526bf502 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -340,8 +340,7 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
}
static void sequencer_listener(
- bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+ wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
/* context changes */
switch (wmn->category) {
@@ -496,7 +495,7 @@ static void sequencer_main_region_draw(const bContext *C, ARegion *ar)
}
static void sequencer_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -644,7 +643,7 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *ar)
}
static void sequencer_preview_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -712,7 +711,7 @@ static void sequencer_buttons_region_draw(const bContext *C, ARegion *ar)
}
static void sequencer_buttons_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c
index 5ff32b98f90..35eb6c69585 100644
--- a/source/blender/editors/space_statusbar/space_statusbar.c
+++ b/source/blender/editors/space_statusbar/space_statusbar.c
@@ -109,7 +109,7 @@ static void statusbar_keymap(struct wmKeyConfig *UNUSED(keyconf))
}
static void statusbar_header_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index c3e2945f3ff..ac43d7de408 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -126,8 +126,7 @@ static SpaceLink *text_duplicate(SpaceLink *sl)
return (SpaceLink *)stextn;
}
-static void text_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+static void text_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
{
SpaceText *st = sa->spacedata.first;
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 21cd24cf84c..aa499d52589 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -913,7 +913,7 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back)
float rad;
/* background so highlights don't go behind the scrollbar */
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_BACK);
immRecti(pos, back->xmin, back->ymin, back->xmax, back->ymax);
@@ -967,24 +967,24 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
boxh = (DOC_HEIGHT + 1) * (st->lheight_dpi + TXT_LINE_SPACING);
/* Draw panel */
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_BACK);
immRecti(pos, x, y, x + boxw, y - boxh);
immUniformThemeColor(TH_SHADE1);
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2i(pos, x, y);
immVertex2i(pos, x + boxw, y);
immVertex2i(pos, x + boxw, y - boxh);
immVertex2i(pos, x, y - boxh);
immEnd();
- immBegin(GWN_PRIM_LINE_LOOP, 3);
+ immBegin(GPU_PRIM_LINE_LOOP, 3);
immVertex2i(pos, x + boxw - 10, y - 7);
immVertex2i(pos, x + boxw - 4, y - 7);
immVertex2i(pos, x + boxw - 7, y - 2);
immEnd();
- immBegin(GWN_PRIM_LINE_LOOP, 3);
+ immBegin(GPU_PRIM_LINE_LOOP, 3);
immVertex2i(pos, x + boxw - 10, y - boxh + 7);
immVertex2i(pos, x + boxw - 4, y - boxh + 7);
immVertex2i(pos, x + boxw - 7, y - boxh + 2);
@@ -1066,7 +1066,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
/* not needed but stands out nicer */
UI_draw_box_shadow(220, x, y - boxh, x + boxw, y);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_SHADE1);
@@ -1089,7 +1089,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
w = st->cwidth * text_get_char_pos(st, str, len);
if (item == sel) {
- unsigned int posi = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint posi = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_SHADE2);
@@ -1130,7 +1130,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
return;
}
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* Draw the selection */
@@ -1443,7 +1443,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
if (st->showlinenrs) {
x = TXT_OFFSET + TEXTXLOC;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_GRID);
immRecti(pos, (TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2);
@@ -1502,7 +1502,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
margin_column_x = x + st->cwidth * (st->margin_column - st->left);
if (margin_column_x >= x) {
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -1515,7 +1515,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
immUniform1f("dash_width", 2.0f);
immUniform1f("dash_factor", 0.5f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2i(shdr_pos, margin_column_x, 0);
immVertex2i(shdr_pos, margin_column_x, ar->winy - 2);
immEnd();
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
index c7ef6591c0d..e45159124e8 100644
--- a/source/blender/editors/space_topbar/space_topbar.c
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -151,7 +151,7 @@ static void topbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
ED_region_header_init(ar);
}
-static void topbar_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+static void topbar_main_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -171,7 +171,7 @@ static void topbar_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa)
}
}
-static void topbar_header_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+static void topbar_header_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index fc5182fcb4f..06c6e612f13 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -137,14 +137,14 @@ static void userpref_header_region_draw(const bContext *C, ARegion *ar)
}
static void userpref_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
{
/* context changes */
}
static void userpref_header_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
{
/* context changes */
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index f8e38587117..b85525dd2ee 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -55,14 +55,14 @@ set(SRC
view3d_walk.c
view3d_header.c
view3d_iterators.c
- view3d_manipulator_armature.c
- view3d_manipulator_camera.c
- view3d_manipulator_empty.c
- view3d_manipulator_forcefield.c
- view3d_manipulator_lamp.c
- view3d_manipulator_navigate.c
- view3d_manipulator_navigate_type.c
- view3d_manipulator_ruler.c
+ view3d_gizmo_armature.c
+ view3d_gizmo_camera.c
+ view3d_gizmo_empty.c
+ view3d_gizmo_forcefield.c
+ view3d_gizmo_lamp.c
+ view3d_gizmo_navigate.c
+ view3d_gizmo_navigate_type.c
+ view3d_gizmo_ruler.c
view3d_ops.c
view3d_project.c
view3d_ruler.c
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index bca5faa314a..c0abbe636c3 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -121,10 +121,10 @@
int view3d_effective_drawtype(const struct View3D *v3d)
{
- if (v3d->drawtype == OB_RENDER) {
- return v3d->prev_drawtype;
+ if (v3d->shading.type == OB_RENDER) {
+ return v3d->shading.prev_type;
}
- return v3d->drawtype;
+ return v3d->shading.type;
}
static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
@@ -139,10 +139,10 @@ static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
return true;
/* if its drawing textures with zbuf sel, then don't draw dots */
- if (dt == OB_TEXTURE && vd->drawtype == OB_TEXTURE)
+ if (dt == OB_TEXTURE && vd->shading.type == OB_TEXTURE)
return false;
- if ((vd->drawtype >= OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX))
+ if ((vd->shading.type >= OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX))
return false;
return true;
@@ -244,7 +244,7 @@ void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], un
circball_array_fill(verts, cent, rad, tmat);
- immBegin(GWN_PRIM_LINE_LOOP, CIRCLE_RESOL);
+ immBegin(GPU_PRIM_LINE_LOOP, CIRCLE_RESOL);
for (int i = 0; i < CIRCLE_RESOL; ++i) {
immVertex3fv(pos, verts[i]);
}
@@ -285,15 +285,15 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
if (imm_len == 0) return;
- Gwn_VertFormat *format = immVertexFormat();
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ GPUVertFormat *format = immVertexFormat();
+ data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE));
- immBeginAtMost(GWN_PRIM_POINTS, imm_len);
+ immBeginAtMost(GPU_PRIM_POINTS, imm_len);
dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data, DM_FOREACH_NOP);
immEnd();
@@ -303,9 +303,9 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *UNUSED(dm), int offset)
{
Mesh *me = ob->data;
- Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
- GWN_batch_draw(batch);
+ GPUBatch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GPU_batch_draw(batch);
}
#endif
@@ -328,15 +328,15 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
drawBMOffset_userData data;
data.bm = em->bm;
data.offset = offset;
- Gwn_VertFormat *format = immVertexFormat();
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ GPUVertFormat *format = immVertexFormat();
+ data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE));
- immBeginAtMost(GWN_PRIM_POINTS, em->bm->totvert);
+ immBeginAtMost(GPU_PRIM_POINTS, em->bm->totvert);
dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, &data, DM_FOREACH_NOP);
immEnd();
@@ -348,9 +348,9 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset)
GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE));
Mesh *me = em->ob->data;
- Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
- GWN_batch_draw(batch);
+ GPUBatch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GPU_batch_draw(batch);
}
#endif
@@ -375,20 +375,20 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
data.bm = em->bm;
data.offset = offset;
- Gwn_VertFormat *format = immVertexFormat();
+ GPUVertFormat *format = immVertexFormat();
const int imm_len = dm->getNumEdges(dm) * 2;
if (imm_len == 0) return;
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
GPU_line_width(1.0f);
- immBeginAtMost(GWN_PRIM_LINES, imm_len);
+ immBeginAtMost(GPU_PRIM_LINES, imm_len);
dm->foreachMappedEdge(dm, bbs_mesh_wire__mapFunc, &data);
immEnd();
@@ -400,9 +400,9 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset)
GPU_line_width(1.0f);
Mesh *me = em->ob->data;
- Gwn_Batch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
- GWN_batch_draw(batch);
+ GPUBatch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GPU_batch_draw(batch);
}
#endif
@@ -420,13 +420,13 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select
if (imm_len == 0) return;
- Gwn_VertFormat *format = immVertexFormat();
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ GPUVertFormat *format = immVertexFormat();
+ data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
- immBeginAtMost(GWN_PRIM_TRIS, imm_len);
+ immBeginAtMost(GPU_PRIM_TRIS, imm_len);
if (use_select == false) {
int selcol;
@@ -463,20 +463,20 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select
static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *UNUSED(dm), const bool use_select)
{
Mesh *me = em->ob->data;
- Gwn_Batch *batch;
+ GPUBatch *batch;
if (use_select) {
batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
- GWN_batch_draw(batch);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GPU_batch_draw(batch);
}
else {
int selcol;
GPU_select_index_get(0, &selcol);
batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32);
- GWN_batch_uniform_1ui(batch, "color", selcol);
- GWN_batch_draw(batch);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32);
+ GPU_batch_uniform_1ui(batch, "color", selcol);
+ GPU_batch_draw(batch);
}
}
#endif
@@ -499,15 +499,15 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm)
{
drawBMOffset_userData data; /* don't use offset */
data.bm = em->bm;
- Gwn_VertFormat *format = immVertexFormat();
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ GPUVertFormat *format = immVertexFormat();
+ data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
GPU_point_size(UI_GetThemeValuef(TH_FACEDOT_SIZE));
- immBeginAtMost(GWN_PRIM_POINTS, em->bm->totface);
+ immBeginAtMost(GPU_PRIM_POINTS, em->bm->totface);
dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, &data, DM_FOREACH_NOP);
immEnd();
@@ -517,9 +517,9 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm)
static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *UNUSED(dm))
{
Mesh *me = em->ob->data;
- Gwn_Batch *batch = DRW_mesh_batch_cache_get_facedots_with_select_id(me, 1);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
- GWN_batch_draw(batch);
+ GPUBatch *batch = DRW_mesh_batch_cache_get_facedots_with_select_id(me, 1);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GPU_batch_draw(batch);
}
#endif
@@ -583,12 +583,12 @@ static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(sce
{
int selcol;
- Gwn_Batch *batch;
+ GPUBatch *batch;
GPU_select_index_get(0, &selcol);
batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32);
- GWN_batch_uniform_1ui(batch, "color", selcol);
- GWN_batch_draw(batch);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32);
+ GPU_batch_uniform_1ui(batch, "color", selcol);
+ GPU_batch_draw(batch);
}
G.f |= (G_f_orig & G_BACKBUFSEL);
@@ -601,15 +601,15 @@ static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(sce
static void bbs_mesh_solid_faces(Scene *UNUSED(scene), Object *ob)
{
Mesh *me = ob->data;
- Gwn_Batch *batch;
+ GPUBatch *batch;
if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) {
batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1);
}
else {
batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, false, 1);
}
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
- GWN_batch_draw(batch);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GPU_batch_draw(batch);
}
void draw_object_backbufsel(
@@ -621,7 +621,7 @@ void draw_object_backbufsel(
select_mode = ts->selectmode;
}
- gpuMultMatrix(ob->obmat);
+ GPU_matrix_mul(ob->obmat);
glClearDepth(1.0); GPU_clear(GPU_DEPTH_BIT);
GPU_depth_test(true);
@@ -688,7 +688,7 @@ void draw_object_backbufsel(
break;
}
- gpuLoadMatrix(rv3d->viewmat);
+ GPU_matrix_set(rv3d->viewmat);
}
@@ -747,8 +747,8 @@ void ED_draw_object_facemap(
Mesh *me = ob->data;
const int *facemap_data = CustomData_get_layer(&me->pdata, CD_FACEMAP);
if (facemap_data) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor4fv(col);
@@ -788,7 +788,7 @@ void ED_draw_object_facemap(
/* use gawain immediate mode fore now */
const int looptris_len = poly_to_tri_count(mpoly_len, mloop_len);
- immBeginAtMost(GWN_PRIM_TRIS, looptris_len * 3);
+ immBeginAtMost(GPU_PRIM_TRIS, looptris_len * 3);
MPoly *mp;
int i;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 4660255cc6c..71bdd2e20c2 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -32,6 +32,7 @@
#include <string.h>
#include <stdio.h>
+#include "DNA_lightprobe_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -250,7 +251,7 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d)
/* we have to multiply instead of loading viewmatob to make
* it work with duplis using displists, otherwise it will
* override the dupli-matrix */
- gpuMultMatrix(ob->obmat);
+ GPU_matrix_mul(ob->obmat);
}
#ifdef DEBUG
@@ -292,7 +293,7 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa)
{
wmWindowManager *wm = bmain->wm.first;
- if (v3d->drawtype != OB_RENDER) {
+ if (v3d->shading.type != OB_RENDER) {
ARegion *ar;
for (ar = sa->regionbase.first; ar; ar = ar->next) {
@@ -323,18 +324,10 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->grid = 1.0f;
v3d->gridlines = 16;
v3d->gridsubdiv = 10;
- v3d->drawtype = OB_SOLID;
- v3d->shading.flag = V3D_SHADING_SPECULAR_HIGHLIGHT;
- v3d->shading.light = V3D_LIGHTING_STUDIO;
- v3d->shading.shadow_intensity = 0.5f;
- v3d->shading.xray_alpha = 0.5f;
- v3d->shading.cavity_valley_factor = 1.0f;
- v3d->shading.cavity_ridge_factor = 1.0f;
- copy_v3_fl(v3d->shading.single_color, 0.8f);
-
- v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV;
+ BKE_screen_view3d_shading_init(&v3d->shading);
+
v3d->overlay.wireframe_threshold = 0.5f;
- v3d->overlay.bone_selection_alpha = 0.5f;
+ v3d->overlay.bone_select_alpha = 0.5f;
v3d->overlay.texture_paint_mode_opacity = 0.8;
v3d->overlay.weight_paint_mode_opacity = 0.8;
v3d->overlay.vertex_paint_mode_opacity = 0.8;
@@ -348,8 +341,6 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->near = 0.01f;
v3d->far = 1000.0f;
- v3d->twflag |= U.manipulator_flag & V3D_MANIPULATOR_DRAW;
-
v3d->bundle_size = 0.2f;
v3d->bundle_drawtype = OB_PLAINAXES;
@@ -433,8 +424,8 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
v3dn->lay = v3do->localvd->lay & 0xFFFFFF;
}
- if (v3dn->drawtype == OB_RENDER)
- v3dn->drawtype = OB_SOLID;
+ if (v3dn->shading.type == OB_RENDER)
+ v3dn->shading.type = OB_SOLID;
/* copy or clear inside new stuff */
@@ -453,12 +444,12 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar)
ListBase *lb;
wmKeyMap *keymap;
- if (ar->manipulator_map == NULL) {
- ar->manipulator_map = WM_manipulatormap_new_from_type(
- &(const struct wmManipulatorMapType_Params) {SPACE_VIEW3D, RGN_TYPE_WINDOW});
+ if (ar->gizmo_map == NULL) {
+ ar->gizmo_map = WM_gizmomap_new_from_type(
+ &(const struct wmGizmoMapType_Params) {SPACE_VIEW3D, RGN_TYPE_WINDOW});
}
- WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
+ WM_gizmomap_add_handlers(ar, ar->gizmo_map);
/* object ops. */
@@ -596,10 +587,23 @@ static bool view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEven
return 0;
}
+static bool view3d_ima_bg_is_camera_view(bContext *C)
+{
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ if ((rv3d && (rv3d->persp == RV3D_CAMOB))) {
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d && v3d->camera && v3d->camera->type == OB_CAMERA) {
+ return true;
+ }
+ }
+ return false;
+}
+
static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
{
- if (event->ctrl)
- return false;
+ if (view3d_ima_bg_is_camera_view(C)) {
+ return true;
+ }
if (!ED_view3d_give_base_under_cursor(C, event->mval)) {
return view3d_ima_drop_poll(C, drag, event);
@@ -609,10 +613,14 @@ static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *ev
static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
{
+ if (!view3d_ima_bg_is_camera_view(C)) {
+ return true;
+ }
+
Base *base = ED_view3d_give_base_under_cursor(C, event->mval);
/* either holding and ctrl and no object, or dropping to empty */
- if (((base == NULL) && event->ctrl) ||
+ if ((base == NULL) ||
((base != NULL) && base->object->type == OB_EMPTY))
{
return view3d_ima_drop_poll(C, drag, event);
@@ -666,6 +674,25 @@ static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop)
}
}
+static void view3d_lightcache_update(bContext *C)
+{
+ PointerRNA op_ptr;
+
+ Scene *scene = CTX_data_scene(C);
+
+ if (strcmp(scene->r.engine, RE_engine_id_BLENDER_EEVEE) != 0) {
+ /* Only do auto bake if eevee is the active engine */
+ return;
+ }
+
+ WM_operator_properties_create(&op_ptr, "SCENE_OT_light_cache_bake");
+ RNA_int_set(&op_ptr, "delay", 200);
+ RNA_enum_set_identifier(C, &op_ptr, "subset", "DIRTY");
+
+ WM_operator_name_call(C, "SCENE_OT_light_cache_bake", WM_OP_INVOKE_DEFAULT, &op_ptr);
+
+ WM_operator_properties_free(&op_ptr);
+}
/* region dropbox definition */
static void view3d_dropboxes(void)
@@ -682,26 +709,26 @@ static void view3d_dropboxes(void)
static void view3d_widgets(void)
{
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(
- &(const struct wmManipulatorMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW});
-
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot);
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area);
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target);
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field);
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera);
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera_view);
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_empty_image);
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_armature_spline);
-
- WM_manipulatorgrouptype_append(TRANSFORM_WGT_manipulator);
- WM_manipulatorgrouptype_append(VIEW3D_WGT_xform_cage);
-
- WM_manipulatorgrouptype_append(VIEW3D_WGT_ruler);
- WM_manipulatortype_append(VIEW3D_WT_ruler_item);
-
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_navigate);
- WM_manipulatortype_append(VIEW3D_WT_navigate_rotate);
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(
+ &(const struct wmGizmoMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW});
+
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_lamp_spot);
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_lamp_area);
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_lamp_target);
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_force_field);
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_camera);
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_camera_view);
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_empty_image);
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_armature_spline);
+
+ WM_gizmogrouptype_append(TRANSFORM_GGT_gizmo);
+ WM_gizmogrouptype_append(VIEW3D_GGT_xform_cage);
+
+ WM_gizmogrouptype_append(VIEW3D_GGT_ruler);
+ WM_gizmotype_append(VIEW3D_GT_ruler_item);
+
+ WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_navigate);
+ WM_gizmotype_append(VIEW3D_GT_navigate_rotate);
}
@@ -776,18 +803,18 @@ static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, const Scene
}
static void view3d_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar,
wmNotifier *wmn, const Scene *scene)
{
View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
- wmManipulatorMap *mmap = ar->manipulator_map;
+ wmGizmoMap *gzmap = ar->gizmo_map;
/* context changes */
switch (wmn->category) {
case NC_WM:
if (ELEM(wmn->data, ND_UNDO)) {
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
}
break;
case NC_ANIMATION:
@@ -814,14 +841,14 @@ static void view3d_main_region_listener(
if (wmn->reference)
view3d_recalc_used_layers(ar, wmn, wmn->reference);
ED_region_tag_redraw(ar);
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
break;
case ND_LAYER:
if (wmn->reference) {
BKE_screen_view3d_sync(v3d, wmn->reference);
}
ED_region_tag_redraw(ar);
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
break;
case ND_OB_ACTIVE:
case ND_OB_SELECT:
@@ -833,7 +860,7 @@ static void view3d_main_region_listener(
case ND_MARKERS:
case ND_MODE:
ED_region_tag_redraw(ar);
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
break;
case ND_WORLD:
/* handled by space_view3d_listener() for v3d access */
@@ -865,7 +892,7 @@ static void view3d_main_region_listener(
case ND_POINTCACHE:
case ND_LOD:
ED_region_tag_redraw(ar);
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
break;
}
switch (wmn->action) {
@@ -878,7 +905,7 @@ static void view3d_main_region_listener(
switch (wmn->data) {
case ND_SELECT:
{
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
ATTR_FALLTHROUGH;
}
case ND_DATA:
@@ -959,10 +986,13 @@ static void view3d_main_region_listener(
break;
case ND_LIGHTING_DRAW:
ED_region_tag_redraw(ar);
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
break;
}
break;
+ case NC_LIGHTPROBE:
+ ED_area_tag_refresh(sa);
+ break;
case NC_IMAGE:
/* this could be more fine grained checks if we had
* more context than just the region */
@@ -982,7 +1012,7 @@ static void view3d_main_region_listener(
rv3d->rflag |= RV3D_GPULIGHT_UPDATE;
}
ED_region_tag_redraw(ar);
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
}
break;
case NC_ID:
@@ -998,7 +1028,7 @@ static void view3d_main_region_listener(
case ND_LAYOUTBROWSE:
case ND_LAYOUTDELETE:
case ND_LAYOUTSET:
- WM_manipulatormap_tag_refresh(mmap);
+ WM_gizmomap_tag_refresh(gzmap);
ED_region_tag_redraw(ar);
break;
case ND_LAYER:
@@ -1033,11 +1063,11 @@ static void view3d_main_region_message_subscribe(
&RNA_Window,
/* These object have properties that impact drawing. */
- &RNA_AreaLamp,
+ &RNA_AreaLight,
&RNA_Camera,
- &RNA_Lamp,
+ &RNA_Light,
&RNA_Speaker,
- &RNA_SunLamp,
+ &RNA_SunLight,
/* General types the 3D view depends on. */
&RNA_Object,
@@ -1150,7 +1180,7 @@ static void view3d_header_region_draw(const bContext *C, ARegion *ar)
}
static void view3d_header_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -1228,7 +1258,7 @@ static void view3d_buttons_region_draw(const bContext *C, ARegion *ar)
}
static void view3d_buttons_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
@@ -1358,8 +1388,7 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *ar)
/* area (not region) level listener */
static void space_view3d_listener(
- bScreen *UNUSED(sc), ScrArea *sa, struct wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
+ wmWindow *UNUSED(win), ScrArea *sa, struct wmNotifier *wmn, Scene *UNUSED(scene))
{
View3D *v3d = sa->spacedata.first;
@@ -1385,7 +1414,7 @@ static void space_view3d_listener(
case NC_MATERIAL:
switch (wmn->data) {
case ND_NODES:
- if (v3d->drawtype == OB_TEXTURE)
+ if (v3d->shading.type == OB_TEXTURE)
ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
break;
}
@@ -1393,6 +1422,17 @@ static void space_view3d_listener(
}
}
+static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(sa))
+{
+ Scene *scene = CTX_data_scene(C);
+ LightCache *lcache = scene->eevee.light_cache;
+
+ if (lcache && (lcache->flag & LIGHTCACHE_UPDATE_AUTO) != 0) {
+ lcache->flag &= ~LIGHTCACHE_UPDATE_AUTO;
+ view3d_lightcache_update((bContext *)C);
+ }
+}
+
const char *view3d_context_dir[] = {
"active_base", "active_object", NULL
};
@@ -1493,11 +1533,12 @@ void ED_spacetype_view3d(void)
st->free = view3d_free;
st->init = view3d_init;
st->listener = space_view3d_listener;
+ st->refresh = space_view3d_refresh;
st->duplicate = view3d_duplicate;
st->operatortypes = view3d_operatortypes;
st->keymap = view3d_keymap;
st->dropboxes = view3d_dropboxes;
- st->manipulators = view3d_widgets;
+ st->gizmos = view3d_widgets;
st->context = view3d_context;
st->id_remap = view3d_id_remap;
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index f5e8bf10817..8fa327d8782 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -1222,3 +1222,29 @@ void VIEW3D_OT_properties(wmOperatorType *ot)
/* flags */
ot->flag = 0;
}
+
+static int view3d_object_mode_menu(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *ob = CTX_data_active_object(C);
+ if (ob && ((ob->mode & OB_MODE_EDIT) == 0) && (ELEM(ob->type, OB_ARMATURE))) {
+ ED_object_mode_toggle(C, OB_MODE_POSE);
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ UI_pie_menu_invoke(C, "VIEW3D_MT_object_mode_pie", CTX_wm_window(C)->eventstate);
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void VIEW3D_OT_object_mode_pie_or_toggle(wmOperatorType *ot)
+{
+ ot->name = "Object Mode Menu";
+ ot->description = "";
+ ot->idname = "VIEW3D_OT_object_mode_pie_or_toggle";
+
+ ot->exec = view3d_object_mode_menu;
+ ot->poll = ED_operator_view3d_active;
+
+ /* flags */
+ ot->flag = 0;
+}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 0d5240d8e86..552d84ebb39 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -74,6 +74,7 @@
#include "DEG_depsgraph_query.h"
#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
#include "GPU_draw.h"
#include "GPU_matrix.h"
#include "GPU_immediate.h"
@@ -183,8 +184,8 @@ static void view3d_main_region_setup_view(
ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, viewmat, winmat, rect);
/* set for opengl */
- gpuLoadProjectionMatrix(rv3d->winmat);
- gpuLoadMatrix(rv3d->viewmat);
+ GPU_matrix_projection_set(rv3d->winmat);
+ GPU_matrix_set(rv3d->viewmat);
}
static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d)
@@ -364,7 +365,7 @@ static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, fl
x4 = x1 + (1.0f - fac) * (x2 - x1);
y4 = y1 + (1.0f - fac) * (y2 - y1);
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
immVertex2f(shdr_pos, x1, y3);
immVertex2f(shdr_pos, x2, y3);
@@ -389,7 +390,7 @@ static void drawviewborder_triangle(
float w = x2 - x1;
float h = y2 - y1;
- immBegin(GWN_PRIM_LINES, 6);
+ immBegin(GPU_PRIM_LINES, 6);
if (w > h) {
if (golden) {
@@ -466,7 +467,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
x2i = (int)(x2 + (1.0f - 0.0001f));
y2i = (int)(y2 + (1.0f - 0.0001f));
- uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
/* First, solid lines. */
{
@@ -558,7 +559,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
x3 = x1 + 0.5f * (x2 - x1);
y3 = y1 + 0.5f * (y2 - y1);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(shdr_pos, x1, y3);
immVertex2f(shdr_pos, x2, y3);
@@ -570,7 +571,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
}
if (ca->dtx & CAM_DTX_CENTER_DIAG) {
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(shdr_pos, x1, y1);
immVertex2f(shdr_pos, x2, y2);
@@ -673,7 +674,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
static void drawrenderborder(ARegion *ar, View3D *v3d)
{
/* use the same program for everything */
- uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPU_line_width(1.0f);
@@ -703,7 +704,6 @@ void ED_view3d_draw_depth(
Scene *scene = DEG_get_evaluated_scene(depsgraph);
RegionView3D *rv3d = ar->regiondata;
- short zbuf = v3d->zbuf;
short flag = v3d->flag;
float glalphaclip = U.glalphaclip;
int obcenter_dia = U.obcenter_dia;
@@ -727,7 +727,6 @@ void ED_view3d_draw_depth(
/* get surface depth without bias */
rv3d->rflag |= RV3D_ZOFFSET_DISABLED;
- v3d->zbuf = true;
GPU_depth_test(true);
DRW_draw_depth_loop(depsgraph, ar, v3d);
@@ -737,8 +736,8 @@ void ED_view3d_draw_depth(
}
rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED;
- v3d->zbuf = zbuf;
- if (!v3d->zbuf) GPU_depth_test(false);
+ /* Reset default for UI */
+ GPU_depth_test(false);
U.glalphaclip = glalphaclip;
v3d->flag = flag;
@@ -815,12 +814,12 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, 6);
+ immBegin(GPU_PRIM_LINES, 6);
for (int axis_i = 0; axis_i < 3; axis_i++) {
int i = axis_order[axis_i];
@@ -860,9 +859,9 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d)
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
glDepthMask(GL_FALSE); /* don't overwrite zbuf */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
@@ -873,7 +872,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d)
mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale);
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
color[3] = 0; /* more transparent toward the ends */
immAttrib4ubv(col, color);
add_v3_v3v3(end, o, scaled_axis);
@@ -912,7 +911,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d)
axis_angle_to_quat(q, vis_axis, vis_angle);
}
- immBegin(GWN_PRIM_LINE_LOOP, ROT_AXIS_DETAIL);
+ immBegin(GPU_PRIM_LINE_LOOP, ROT_AXIS_DETAIL);
color[3] = 63; /* somewhat faint */
immAttrib4ubv(col, color);
float angle = 0.0f;
@@ -941,7 +940,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d)
/* -- draw rotation center -- */
immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
GPU_point_size(5.0f);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immAttrib4ubv(col, color);
immVertex3fv(pos, o);
immEnd();
@@ -1205,11 +1204,14 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(of
BLF_batch_draw_begin();
- if (((U.uiflag & USER_SHOW_ROTVIEWICON) != 0) &&
- ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
- /* No need to display manipulator and this info. */
- ((U.manipulator_flag & USER_MANIPULATOR_DRAW_NAVIGATE) == 0))
+ if ((U.uiflag & USER_SHOW_GIZMO_AXIS) ||
+ (v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ /* No need to display gizmo and this info. */
+ (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE)))
{
+ /* pass */
+ }
+ else {
draw_view_axis(rv3d, &rect);
}
@@ -1353,10 +1355,10 @@ void ED_view3d_draw_offscreen(
GPU_free_images_anim(G.main); /* XXX :((( */
}
- gpuPushProjectionMatrix();
- gpuLoadIdentity();
- gpuPushMatrix();
- gpuLoadIdentity();
+ GPU_matrix_push_projection();
+ GPU_matrix_identity_set();
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera)
view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname);
@@ -1373,8 +1375,8 @@ void ED_view3d_draw_offscreen(
ar->winy = bwiny;
ar->winrct = brect;
- gpuPopProjectionMatrix();
- gpuPopMatrix();
+ GPU_matrix_pop_projection();
+ GPU_matrix_pop();
UI_Theme_Restore(&theme_state);
@@ -1587,7 +1589,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
v3d.camera = camera;
v3d.lay = scene->lay;
- v3d.drawtype = drawtype;
+ v3d.shading.type = drawtype;
v3d.flag2 = V3D_RENDER_OVERRIDE;
if (draw_flags & V3D_OFSDRAW_USE_GPENCIL) {
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 06cdba3f537..94cd4dfc73d 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -179,7 +179,7 @@ static void backdrawview3d(
}
/* texture paint mode sampling */
else if (obact_eval && (obact_eval->mode & OB_MODE_TEXTURE_PAINT) &&
- (v3d->drawtype > OB_WIRE))
+ (v3d->shading.type > OB_WIRE))
{
/* do nothing */
}
@@ -210,7 +210,9 @@ static void backdrawview3d(
}
#endif
- if (v3d->drawtype > OB_WIRE) v3d->zbuf = true;
+#if 0 /* v3d->zbuf deprecated */
+ if (v3d->shading.type > OB_WIRE) v3d->zbuf = true;
+#endif
/* dithering and AA break color coding, so disable */
glDisable(GL_DITHER);
@@ -249,14 +251,8 @@ static void backdrawview3d(
GPU_scissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
GPU_clear_color(0.0, 0.0, 0.0, 0.0);
- if (v3d->zbuf) {
- GPU_depth_test(true);
- GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
- }
- else {
- GPU_clear(GPU_COLOR_BIT);
- GPU_depth_test(false);
- }
+ GPU_depth_test(true);
+ GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
if (rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_set(rv3d);
@@ -273,7 +269,6 @@ static void backdrawview3d(
v3d->flag &= ~V3D_INVALID_BACKBUF;
G.f &= ~G_BACKBUFSEL;
- v3d->zbuf = false;
GPU_depth_test(false);
glEnable(GL_DITHER);
@@ -684,19 +679,19 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
ibuf = ibuf->mipmap[mip - 1];
}
- if (v3d->zbuf) GPU_depth_test(false);
+ GPU_depth_test(false);
glDepthMask(GL_FALSE);
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- gpuPushProjectionMatrix();
- gpuPushMatrix();
+ GPU_matrix_push_projection();
+ GPU_matrix_push();
ED_region_pixelspace(ar);
- gpuTranslate2f(centx, centy);
- gpuScaleUniform(bgpic->scale);
- gpuRotate2D(RAD2DEGF(-bgpic->rotation));
+ GPU_matrix_translate_2f(centx, centy);
+ GPU_matrix_scale_1f(bgpic->scale);
+ GPU_matrix_rotate_2d(RAD2DEGF(-bgpic->rotation));
if (bgpic->flag & CAM_BGIMG_FLAG_FLIP_X) {
zoomx *= -1.0f;
@@ -712,13 +707,13 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
immDrawPixelsTex(&state, x1 - centx, y1 - centy, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect,
zoomx, zoomy, col);
- gpuPopProjectionMatrix();
- gpuPopMatrix();
+ GPU_matrix_pop_projection();
+ GPU_matrix_pop();
GPU_blend(false);
glDepthMask(GL_TRUE);
- if (v3d->zbuf) GPU_depth_test(true);
+ GPU_depth_test(true);
if (freeibuf)
IMB_freeImBuf(freeibuf);
@@ -878,22 +873,19 @@ void ED_view3d_draw_depth_gpencil(
Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d)
{
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
- bool zbuf = v3d->zbuf;
/* Setup view matrix. */
ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL);
GPU_clear(GPU_DEPTH_BIT);
- v3d->zbuf = true;
GPU_depth_test(true);
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
ED_gpencil_draw_view3d(NULL, scene, view_layer, depsgraph, v3d, ar, true);
}
- v3d->zbuf = zbuf;
- if (!zbuf) GPU_depth_test(false);
+ GPU_depth_test(false);
}
/* *********************** customdata **************** */
@@ -1041,7 +1033,7 @@ bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View
bool use_border;
/* test if there is a 3d view rendering */
- if (v3d->drawtype != OB_RENDER || !view3d_main_region_do_render_draw(scene))
+ if (v3d->shading.type != OB_RENDER || !view3d_main_region_do_render_draw(scene))
return false;
/* test if there is a border render */
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index cc30375255d..2cc1236e5c6 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -567,8 +567,8 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf)
static const EnumPropertyItem modal_items[] = {
{VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
- {VIEWROT_MODAL_AXIS_SNAP_ENABLE, "AXIS_SNAP_ENABLE", 0, "Enable Axis Snap", ""},
- {VIEWROT_MODAL_AXIS_SNAP_DISABLE, "AXIS_SNAP_DISABLE", 0, "Disable Axis Snap", ""},
+ {VIEWROT_MODAL_AXIS_SNAP_ENABLE, "AXIS_SNAP_ENABLE", 0, "Axis Snap", ""},
+ {VIEWROT_MODAL_AXIS_SNAP_DISABLE, "AXIS_SNAP_DISABLE", 0, "Axis Snap (Off)", ""},
{VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"},
{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
@@ -2812,8 +2812,8 @@ static int viewselected_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
- const bool is_face_map = ((is_gp_edit == false) && ar->manipulator_map &&
- WM_manipulatormap_is_any_selected(ar->manipulator_map));
+ const bool is_face_map = ((is_gp_edit == false) && ar->gizmo_map &&
+ WM_gizmomap_is_any_selected(ar->gizmo_map));
Object *ob_eval = OBACT(view_layer_eval);
Object *obedit = CTX_data_edit_object(C);
float min[3], max[3];
@@ -2858,7 +2858,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
}
else if (is_face_map) {
- ok = WM_manipulatormap_minmax(ar->manipulator_map, true, true, min, max);
+ ok = WM_gizmomap_minmax(ar->gizmo_map, true, true, min, max);
}
else if (obedit) {
/* only selected */
@@ -3223,7 +3223,6 @@ void VIEW3D_OT_view_center_lock(wmOperatorType *ot)
static int render_border_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
@@ -3233,17 +3232,13 @@ static int render_border_exec(bContext *C, wmOperator *op)
rcti rect;
rctf vb, border;
- const bool camera_only = RNA_boolean_get(op->ptr, "camera_only");
-
- if (camera_only && rv3d->persp != RV3D_CAMOB)
- return OPERATOR_PASS_THROUGH;
-
/* get border select values using rna */
WM_operator_properties_border_to_rcti(op, &rect);
/* calculate range */
if (rv3d->persp == RV3D_CAMOB) {
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false);
}
else {
@@ -3297,8 +3292,6 @@ static int render_border_exec(bContext *C, wmOperator *op)
void VIEW3D_OT_render_border(wmOperatorType *ot)
{
- PropertyRNA *prop;
-
/* identifiers */
ot->name = "Set Render Border";
ot->description = "Set the boundaries of the border render and enable border render";
@@ -3317,10 +3310,6 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
/* properties */
WM_operator_properties_border(ot);
-
- prop = RNA_def_boolean(ot->srna, "camera_only", false, "Camera Only",
- "Set render border for camera view and final render only");
- RNA_def_property_flag(prop, PROP_HIDDEN);
}
/** \} */
@@ -3501,6 +3490,13 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* clamp after because we may have been zooming out */
CLAMP(new_dist, dist_range[0], dist_range[1]);
+ /* TODO(campbell): 'is_camera_lock' not currently working well. */
+ const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d);
+ if ((rv3d->persp == RV3D_CAMOB) && (is_camera_lock == false)) {
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP);
+ }
+
ED_view3d_smooth_view(
C, v3d, ar, smooth_viewtx,
&(const V3D_SmoothParams) {.ofs = new_ofs, .dist = &new_dist});
@@ -3512,18 +3508,6 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int view3d_zoom_border_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
-
- /* if in camera view do not exec the operator so we do not conflict with set render border*/
- if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d))
- return WM_gesture_border_invoke(C, op, event);
- else
- return OPERATOR_PASS_THROUGH;
-}
-
void VIEW3D_OT_zoom_border(wmOperatorType *ot)
{
/* identifiers */
@@ -3532,7 +3516,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot)
ot->idname = "VIEW3D_OT_zoom_border";
/* api callbacks */
- ot->invoke = view3d_zoom_border_invoke;
+ ot->invoke = WM_gesture_border_invoke;
ot->exec = view3d_zoom_border_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
@@ -3602,7 +3586,7 @@ void VIEW3D_OT_zoom_camera_1_to_1(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name View Axis/Type Operator
+/** \name View Axis Operator
* \{ */
static const EnumPropertyItem prop_view_items[] = {
@@ -3612,17 +3596,20 @@ static const EnumPropertyItem prop_view_items[] = {
{RV3D_VIEW_TOP, "TOP", ICON_TRIA_UP, "Top", "View From the Top"},
{RV3D_VIEW_FRONT, "FRONT", 0, "Front", "View From the Front"},
{RV3D_VIEW_BACK, "BACK", 0, "Back", "View From the Back"},
- {RV3D_VIEW_CAMERA, "CAMERA", ICON_CAMERA_DATA, "Camera", "View From the Active Camera"},
{0, NULL, 0, NULL, NULL}
};
/* would like to make this a generic function - outside of transform */
+/**
+ * \param align_to_quat: When not NULL, set the axis relative to this rotation.
+ */
static void axis_set_view(
bContext *C, View3D *v3d, ARegion *ar,
const float quat_[4],
- short view, int perspo, bool align_active,
+ short view, int perspo,
+ const float *align_to_quat,
const int smooth_viewtx)
{
RegionView3D *rv3d = ar->regiondata; /* no NULL check is needed, poll checks */
@@ -3632,29 +3619,12 @@ static void axis_set_view(
normalize_qt_qt(quat, quat_);
- if (align_active) {
- /* align to active object */
- Object *obact = CTX_data_active_object(C);
- if (obact == NULL) {
- /* no active object, ignore this option */
- align_active = false;
- }
- else {
- float obact_quat[4];
- float twmat[3][3];
-
- /* same as transform manipulator when normal is set */
- ED_getTransformOrientationMatrix(C, twmat, V3D_AROUND_ACTIVE);
-
- mat3_to_quat(obact_quat, twmat);
- invert_qt_normalized(obact_quat);
- mul_qt_qtqt(quat, quat, obact_quat);
-
- rv3d->view = view = RV3D_VIEW_USER;
- }
+ if (align_to_quat) {
+ mul_qt_qtqt(quat, quat, align_to_quat);
+ rv3d->view = view = RV3D_VIEW_USER;
}
- if (align_active == false) {
+ if (align_to_quat == NULL) {
rv3d->view = view;
}
@@ -3710,14 +3680,13 @@ static void axis_set_view(
}
}
-static int viewnumpad_exec(bContext *C, wmOperator *op)
+static int view_axis_exec(bContext *C, wmOperator *op)
{
View3D *v3d;
ARegion *ar;
RegionView3D *rv3d;
static int perspo = RV3D_PERSP;
- int viewnum, nextperspo;
- bool align_active;
+ int viewnum;
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* no NULL check is needed, poll checks */
@@ -3727,121 +3696,209 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
ED_view3d_smooth_view_force_finish(C, v3d, ar);
viewnum = RNA_enum_get(op->ptr, "type");
- align_active = RNA_boolean_get(op->ptr, "align_active");
- /* Use this to test if we started out with a camera */
+ float align_quat_buf[4];
+ float *align_quat = NULL;
- if (rv3d->persp == RV3D_CAMOB) {
- nextperspo = rv3d->lpersp;
- }
- else {
- nextperspo = perspo;
+ if (RNA_boolean_get(op->ptr, "align_active")) {
+ /* align to active object */
+ Object *obact = CTX_data_active_object(C);
+ if (obact != NULL) {
+ float twmat[3][3];
+ /* same as transform gizmo when normal is set */
+ ED_getTransformOrientationMatrix(C, twmat, V3D_AROUND_ACTIVE);
+ align_quat = align_quat_buf;
+ mat3_to_quat(align_quat, twmat);
+ invert_qt_normalized(align_quat);
+ }
}
- if (RV3D_VIEW_IS_AXIS(viewnum)) {
- float quat[4];
+ if (RNA_boolean_get(op->ptr, "relative")) {
+ float z_rel[3];
- ED_view3d_quat_from_axis_view(viewnum, quat);
- axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_active, smooth_viewtx);
+ if (viewnum == RV3D_VIEW_RIGHT) {
+ negate_v3_v3(z_rel, rv3d->viewinv[0]);
+ }
+ else if (viewnum == RV3D_VIEW_LEFT) {
+ copy_v3_v3(z_rel, rv3d->viewinv[0]);
+ }
+ else if (viewnum == RV3D_VIEW_TOP) {
+ negate_v3_v3(z_rel, rv3d->viewinv[1]);
+ }
+ else if (viewnum == RV3D_VIEW_BOTTOM) {
+ copy_v3_v3(z_rel, rv3d->viewinv[1]);
+ }
+ else if (viewnum == RV3D_VIEW_FRONT) {
+ negate_v3_v3(z_rel, rv3d->viewinv[2]);
+ }
+ else if (viewnum == RV3D_VIEW_BACK) {
+ copy_v3_v3(z_rel, rv3d->viewinv[2]);
+ }
+ else {
+ BLI_assert(0);
+ }
+
+ float angle_max = FLT_MAX;
+ int view_closest = -1;
+ for (int i = RV3D_VIEW_FRONT; i <= RV3D_VIEW_BOTTOM; i++) {
+ float quat[4];
+ float mat[3][3];
+ ED_view3d_quat_from_axis_view(i, quat);
+ quat[0] *= -1.0f;
+ quat_to_mat3(mat, quat);
+ if (align_quat) {
+ mul_qt_qtqt(quat, quat, align_quat);
+ }
+ const float angle_test = angle_normalized_v3v3(z_rel, mat[2]);
+ if (angle_max > angle_test) {
+ angle_max = angle_test;
+ view_closest = i;
+ }
+ }
+ if (view_closest == -1) {
+ view_closest = RV3D_VIEW_FRONT;
+ }
+ viewnum = view_closest;
}
- else if (viewnum == RV3D_VIEW_CAMERA) {
- if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
- /* lastview - */
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Scene *scene = CTX_data_scene(C);
+ /* Use this to test if we started out with a camera */
+ const int nextperspo = (rv3d->persp == RV3D_CAMOB) ? rv3d->lpersp : perspo;
+ float quat[4];
+ ED_view3d_quat_from_axis_view(viewnum, quat);
+ axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_quat, smooth_viewtx);
+
+ perspo = rv3d->persp;
+
+ return OPERATOR_FINISHED;
+}
- if (rv3d->persp != RV3D_CAMOB) {
- Object *ob = OBACT(view_layer);
- if (!rv3d->smooth_timer) {
- /* store settings of current view before allowing overwriting with camera view
- * only if we're not currently in a view transition */
+void VIEW3D_OT_view_axis(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
- ED_view3d_lastview_store(rv3d);
- }
+ /* identifiers */
+ ot->name = "View Axis";
+ ot->description = "Use a preset viewpoint";
+ ot->idname = "VIEW3D_OT_view_axis";
+
+ /* api callbacks */
+ ot->exec = view_axis_exec;
+ ot->poll = ED_operator_rv3d_user_region_poll;
+
+ /* flags */
+ ot->flag = 0;
+
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "Preset viewpoint to use");
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "align_active", 0, "Align Active", "Align to the active object's axis");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "relative", 0, "Relative", "Rotate relative to the current orientation");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name View Camera Operator
+ * \{ */
+
+static int view_camera_exec(bContext *C, wmOperator *op)
+{
+ View3D *v3d;
+ ARegion *ar;
+ RegionView3D *rv3d;
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+
+ /* no NULL check is needed, poll checks */
+ ED_view3d_context_user_region(C, &v3d, &ar);
+ rv3d = ar->regiondata;
+
+ ED_view3d_smooth_view_force_finish(C, v3d, ar);
+
+ if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
+ /* lastview - */
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Scene *scene = CTX_data_scene(C);
+
+ if (rv3d->persp != RV3D_CAMOB) {
+ Object *ob = OBACT(view_layer);
+
+ if (!rv3d->smooth_timer) {
+ /* store settings of current view before allowing overwriting with camera view
+ * only if we're not currently in a view transition */
+
+ ED_view3d_lastview_store(rv3d);
+ }
#if 0
- if (G.qual == LR_ALTKEY) {
- if (oldcamera && is_an_active_object(oldcamera)) {
- v3d->camera = oldcamera;
- }
- handle_view3d_lock();
+ if (G.qual == LR_ALTKEY) {
+ if (oldcamera && is_an_active_object(oldcamera)) {
+ v3d->camera = oldcamera;
}
+ handle_view3d_lock();
+ }
#endif
- /* first get the default camera for the view lock type */
- if (v3d->scenelock) {
- /* sets the camera view if available */
+ /* first get the default camera for the view lock type */
+ if (v3d->scenelock) {
+ /* sets the camera view if available */
+ v3d->camera = scene->camera;
+ }
+ else {
+ /* use scene camera if one is not set (even though we're unlocked) */
+ if (v3d->camera == NULL) {
v3d->camera = scene->camera;
}
- else {
- /* use scene camera if one is not set (even though we're unlocked) */
- if (v3d->camera == NULL) {
- v3d->camera = scene->camera;
- }
- }
+ }
- /* if the camera isn't found, check a number of options */
- if (v3d->camera == NULL && ob && ob->type == OB_CAMERA)
- v3d->camera = ob;
+ /* if the camera isn't found, check a number of options */
+ if (v3d->camera == NULL && ob && ob->type == OB_CAMERA)
+ v3d->camera = ob;
- if (v3d->camera == NULL)
- v3d->camera = BKE_view_layer_camera_find(view_layer);
+ if (v3d->camera == NULL)
+ v3d->camera = BKE_view_layer_camera_find(view_layer);
- /* couldnt find any useful camera, bail out */
- if (v3d->camera == NULL)
- return OPERATOR_CANCELLED;
+ /* couldnt find any useful camera, bail out */
+ if (v3d->camera == NULL)
+ return OPERATOR_CANCELLED;
- /* important these don't get out of sync for locked scenes */
- if (v3d->scenelock)
- scene->camera = v3d->camera;
+ /* important these don't get out of sync for locked scenes */
+ if (v3d->scenelock)
+ scene->camera = v3d->camera;
- /* finally do snazzy view zooming */
- rv3d->persp = RV3D_CAMOB;
- ED_view3d_smooth_view(
- C, v3d, ar, smooth_viewtx,
- &(const V3D_SmoothParams) {
- .camera = v3d->camera, .ofs = rv3d->ofs, .quat = rv3d->viewquat,
- .dist = &rv3d->dist, .lens = &v3d->lens});
- }
- else {
- /* return to settings of last view */
- /* does view3d_smooth_view too */
- axis_set_view(C, v3d, ar,
- rv3d->lviewquat,
- rv3d->lview, rv3d->lpersp, 0,
- smooth_viewtx);
- }
+ /* finally do snazzy view zooming */
+ rv3d->persp = RV3D_CAMOB;
+ ED_view3d_smooth_view(
+ C, v3d, ar, smooth_viewtx,
+ &(const V3D_SmoothParams) {
+ .camera = v3d->camera, .ofs = rv3d->ofs, .quat = rv3d->viewquat,
+ .dist = &rv3d->dist, .lens = &v3d->lens});
+ }
+ else {
+ /* return to settings of last view */
+ /* does view3d_smooth_view too */
+ axis_set_view(C, v3d, ar, rv3d->lviewquat, rv3d->lview, rv3d->lpersp, NULL, smooth_viewtx);
}
}
- if (rv3d->persp != RV3D_CAMOB) perspo = rv3d->persp;
-
return OPERATOR_FINISHED;
}
-
-void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
+void VIEW3D_OT_view_camera(wmOperatorType *ot)
{
- PropertyRNA *prop;
-
/* identifiers */
- ot->name = "View Numpad";
- ot->description = "Use a preset viewpoint";
- ot->idname = "VIEW3D_OT_viewnumpad";
+ ot->name = "View Camera";
+ ot->description = "Toggle the camera view";
+ ot->idname = "VIEW3D_OT_view_camera";
/* api callbacks */
- ot->exec = viewnumpad_exec;
+ ot->exec = view_camera_exec;
ot->poll = ED_operator_rv3d_user_region_poll;
/* flags */
ot->flag = 0;
-
- ot->prop = RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "Preset viewpoint to use");
- RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
- prop = RNA_def_boolean(ot->srna, "align_active", 0, "Align Active", "Align to the active object's axis");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/** \} */
@@ -4354,30 +4411,40 @@ void VIEW3D_OT_navigate(wmOperatorType *ot)
/** \name Background Image Add Operator
* \{ */
-static CameraBGImage *background_image_add(bContext *C)
-{
- Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
- return BKE_camera_background_image_new(cam);
+static Camera *background_image_camera_from_context(bContext *C)
+{
+ /* Needed to support drag-and-drop & camera buttons context. */
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d != NULL) {
+ if (v3d->camera && v3d->camera->data && v3d->camera->type == OB_CAMERA) {
+ return v3d->camera->data;
+ }
+ return NULL;
+ }
+ else {
+ return CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
+ }
}
static int background_image_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- background_image_add(C);
+ Camera *cam = background_image_camera_from_context(C);
+ BKE_camera_background_image_new(cam);
return OPERATOR_FINISHED;
}
static int background_image_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
+ Camera *cam = background_image_camera_from_context(C);
Image *ima;
CameraBGImage *bgpic;
ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM);
/* may be NULL, continue anyway */
- bgpic = background_image_add(C);
+ bgpic = BKE_camera_background_image_new(cam);
bgpic->ima = ima;
cam->flag |= CAM_SHOW_BG_IMAGE;
@@ -4387,19 +4454,24 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, const wmEven
return OPERATOR_FINISHED;
}
+static bool background_image_add_poll(bContext *C)
+{
+ return background_image_camera_from_context(C) != NULL;
+}
+
void VIEW3D_OT_background_image_add(wmOperatorType *ot)
{
/* identifiers */
/* note: having key shortcut here is bad practice,
* but for now keep because this displays when dragging an image over the 3D viewport */
- ot->name = "Add Background Image (Ctrl for Empty Object)";
- ot->description = "Add a new background image (Ctrl for Empty Object)";
+ ot->name = "Add Background Image";
+ ot->description = "Add a new background image";
ot->idname = "VIEW3D_OT_background_image_add";
/* api callbacks */
ot->invoke = background_image_add_invoke;
ot->exec = background_image_add_exec;
- ot->poll = ED_operator_camera;
+ ot->poll = background_image_add_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -4783,34 +4855,77 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Toggle Render Shading Operator
+/** \name Toggle Shading Operator
* \{ */
-static int toggle_render_exec(bContext *C, wmOperator *UNUSED(op))
+static const EnumPropertyItem prop_shading_type_items[] = {
+ {OB_SOLID, "SOLID", 0, "Solid and X-Ray", "Toggle solid and X-ray shading"},
+ {OB_MATERIAL, "MATERIAL", 0, "LookDev", "Toggle lookdev shading"},
+ {OB_RENDER, "RENDERED", 0, "Rendered", "Toggle rendered shading"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+static int toggle_shading_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
View3D *v3d = CTX_wm_view3d(C);
- if (v3d->drawtype == OB_RENDER) {
- v3d->drawtype = v3d->prev_drawtype;
+ ScrArea *sa = CTX_wm_area(C);
+ int type = RNA_enum_get(op->ptr, "type");
+
+ if (type == OB_SOLID) {
+ if (v3d->shading.type == OB_SOLID) {
+ /* Toggle X-Ray if already in solid mode. */
+ if (ED_operator_posemode(C) || ED_operator_editmesh(C)) {
+ v3d->flag ^= V3D_ZBUF_SELECT;
+ }
+ else {
+ v3d->shading.flag ^= V3D_SHADING_XRAY;
+ }
+ }
+ else {
+ /* Go to solid mode. */
+ v3d->shading.type = OB_SOLID;
+ }
}
- else {
- v3d->prev_drawtype = v3d->drawtype;
- v3d->drawtype = OB_RENDER;
+ else if (type == OB_MATERIAL) {
+ if (v3d->shading.type == OB_MATERIAL) {
+ v3d->shading.type = OB_SOLID;
+ }
+ else {
+ v3d->shading.type = OB_MATERIAL;
+ }
}
- ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C));
+ else if (type == OB_RENDER) {
+ if (v3d->shading.type == OB_RENDER) {
+ v3d->shading.type = v3d->shading.prev_type;
+ }
+ else {
+ v3d->shading.prev_type = v3d->shading.type;
+ v3d->shading.type = OB_RENDER;
+ }
+ }
+
+ ED_view3d_shade_update(bmain, v3d, sa);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+
return OPERATOR_FINISHED;
}
-void VIEW3D_OT_toggle_render(wmOperatorType *ot)
+void VIEW3D_OT_toggle_shading(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
- ot->name = "Toggle Rendered Shading";
- ot->description = "Toggle rendered shading mode of the viewport";
- ot->idname = "VIEW3D_OT_toggle_render";
+ ot->name = "Toggle Shading Type";
+ ot->description = "Toggle shading type in 3D viewport";
+ ot->idname = "VIEW3D_OT_toggle_shading";
/* api callbacks */
- ot->exec = toggle_render_exec;
+ ot->exec = toggle_shading_exec;
ot->poll = ED_operator_view3d_active;
+
+ prop = RNA_def_enum(ot->srna, "type", prop_shading_type_items, 0, "Type", "Shading type to toggle");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index f9fdf8c2cc0..3cf036e1ce1 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -102,29 +102,30 @@ typedef enum eFlyPanState {
void fly_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
- {FLY_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
{FLY_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
- {FLY_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""},
- {FLY_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""},
+ {FLY_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
- {FLY_MODAL_PAN_ENABLE, "PAN_ENABLE", 0, "Pan Enable", ""},
- {FLY_MODAL_PAN_DISABLE, "PAN_DISABLE", 0, "Pan Disable", ""},
+ {FLY_MODAL_DIR_FORWARD, "FORWARD", 0, "Forward", ""},
+ {FLY_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Backward", ""},
+ {FLY_MODAL_DIR_LEFT, "LEFT", 0, "Left", ""},
+ {FLY_MODAL_DIR_RIGHT, "RIGHT", 0, "Right", ""},
+ {FLY_MODAL_DIR_UP, "UP", 0, "Up", ""},
+ {FLY_MODAL_DIR_DOWN, "DOWN", 0, "Down", ""},
- {FLY_MODAL_DIR_FORWARD, "FORWARD", 0, "Fly Forward", ""},
- {FLY_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Fly Backward", ""},
- {FLY_MODAL_DIR_LEFT, "LEFT", 0, "Fly Left", ""},
- {FLY_MODAL_DIR_RIGHT, "RIGHT", 0, "Fly Right", ""},
- {FLY_MODAL_DIR_UP, "UP", 0, "Fly Up", ""},
- {FLY_MODAL_DIR_DOWN, "DOWN", 0, "Fly Down", ""},
+ {FLY_MODAL_PAN_ENABLE, "PAN_ENABLE", 0, "Pan", ""},
+ {FLY_MODAL_PAN_DISABLE, "PAN_DISABLE", 0, "Pan (Off)", ""},
+
+ {FLY_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""},
+ {FLY_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""},
{FLY_MODAL_AXIS_LOCK_X, "AXIS_LOCK_X", 0, "X Axis Correction", "X axis correction (toggle)"},
{FLY_MODAL_AXIS_LOCK_Z, "AXIS_LOCK_Z", 0, "X Axis Correction", "Z axis correction (toggle)"},
- {FLY_MODAL_PRECISION_ENABLE, "PRECISION_ENABLE", 0, "Precision Enable", ""},
- {FLY_MODAL_PRECISION_DISABLE, "PRECISION_DISABLE", 0, "Precision Disable", ""},
+ {FLY_MODAL_PRECISION_ENABLE, "PRECISION_ENABLE", 0, "Precision", ""},
+ {FLY_MODAL_PRECISION_DISABLE, "PRECISION_DISABLE", 0, "Precision (Off)", ""},
- {FLY_MODAL_FREELOOK_ENABLE, "FREELOOK_ENABLE", 0, "Rotation Enable", ""},
- {FLY_MODAL_FREELOOK_DISABLE, "FREELOOK_DISABLE", 0, "Rotation Disable", ""},
+ {FLY_MODAL_FREELOOK_ENABLE, "FREELOOK_ENABLE", 0, "Rotation", ""},
+ {FLY_MODAL_FREELOOK_DISABLE, "FREELOOK_DISABLE", 0, "Rotation (Off)", ""},
{0, NULL, 0, NULL, NULL}};
@@ -137,8 +138,8 @@ void fly_modal_keymap(wmKeyConfig *keyconf)
keymap = WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items);
/* items for modal map */
- WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CANCEL);
WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, FLY_MODAL_CANCEL);
+ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CANCEL);
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, FLY_MODAL_CONFIRM);
WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CONFIRM);
@@ -262,14 +263,14 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar),
x2 = xoff + 0.55f * fly->width;
y2 = yoff + 0.55f * fly->height;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_VIEW_OVERLAY);
- immBegin(GWN_PRIM_LINES, 16);
+ immBegin(GPU_PRIM_LINES, 16);
/* bottom left */
immVertex2f(pos, x1, y1);
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c
index abbd6c888b2..88a95e89bd8 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_armature.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/space_view3d/view3d_manipulator_armature.c
+/** \file blender/editors/space_view3d/view3d_gizmo_armature.c
* \ingroup spview3d
*/
@@ -36,7 +36,7 @@
#include "ED_armature.h"
#include "ED_screen.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "UI_resources.h"
@@ -52,7 +52,7 @@
/* -------------------------------------------------------------------- */
-/** \name Armature Spline Manipulator
+/** \name Armature Spline Gizmo
*
* \{ */
@@ -68,7 +68,7 @@
#define BBONE_SCALE_Y 3.0f
struct BoneSplineHandle {
- wmManipulator *manipulator;
+ wmGizmo *gizmo;
bPoseChannel *pchan;
/* We could remove, keep since at the moment for checking the conversion. */
float co[3];
@@ -79,15 +79,15 @@ struct BoneSplineWidgetGroup {
struct BoneSplineHandle handles[2];
};
-static void manipulator_bbone_offset_get(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void gizmo_bbone_offset_get(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
void *value_p)
{
- struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data;
+ struct BoneSplineHandle *bh = gz_prop->custom_func.user_data;
bPoseChannel *pchan = bh->pchan;
float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 3);
+ BLI_assert(gz_prop->type->array_length == 3);
if (bh->index == 0) {
bh->co[1] = pchan->bone->ease1 / BBONE_SCALE_Y;
@@ -102,16 +102,16 @@ static void manipulator_bbone_offset_get(
copy_v3_v3(value, bh->co);
}
-static void manipulator_bbone_offset_set(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void gizmo_bbone_offset_set(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
const void *value_p)
{
- struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data;
+ struct BoneSplineHandle *bh = gz_prop->custom_func.user_data;
bPoseChannel *pchan = bh->pchan;
const float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 3);
+ BLI_assert(gz_prop->type->array_length == 3);
copy_v3_v3(bh->co, value);
if (bh->index == 0) {
@@ -127,7 +127,7 @@ static void manipulator_bbone_offset_set(
}
-static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
if (ob != NULL) {
@@ -135,7 +135,12 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGro
if (arm->drawtype == ARM_B_BONE) {
if (arm->act_bone && arm->act_bone->segments > 1) {
View3D *v3d = CTX_wm_view3d(C);
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
+ {
+ /* pass */
+ }
+ else {
return true;
}
}
@@ -145,79 +150,79 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGro
}
-static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bPoseChannel *pchan = BKE_pose_channel_active(ob);
- const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true);
+ const wmGizmoType *gzt_grab = WM_gizmotype_find("GIZMO_GT_grab_3d", true);
struct BoneSplineWidgetGroup *bspline_group = MEM_callocN(sizeof(struct BoneSplineWidgetGroup), __func__);
- mgroup->customdata = bspline_group;
+ gzgroup->customdata = bspline_group;
/* Handles */
for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) {
- wmManipulator *mpr;
- mpr = bspline_group->handles[i].manipulator = WM_manipulator_new_ptr(wt_grab, mgroup, NULL);
- RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D);
- RNA_enum_set(mpr->ptr, "draw_options",
- ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW);
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_VALUE, true);
+ wmGizmo *gz;
+ gz = bspline_group->handles[i].gizmo = WM_gizmo_new_ptr(gzt_grab, gzgroup, NULL);
+ RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_RING_2D);
+ RNA_enum_set(gz->ptr, "draw_options",
+ ED_GIZMO_GRAB_DRAW_FLAG_FILL | ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW);
+ WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_VALUE, true);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
- mpr->scale_basis = 0.06f;
+ gz->scale_basis = 0.06f;
if (i == 0) {
- copy_v3_v3(mpr->matrix_basis[3], pchan->loc);
+ copy_v3_v3(gz->matrix_basis[3], pchan->loc);
}
}
}
-static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- if (!mgroup->customdata)
+ if (!gzgroup->customdata)
return;
- struct BoneSplineWidgetGroup *bspline_group = mgroup->customdata;
+ struct BoneSplineWidgetGroup *bspline_group = gzgroup->customdata;
bPoseChannel *pchan = BKE_pose_channel_active(ob);
/* Handles */
for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) {
- wmManipulator *mpr = bspline_group->handles[i].manipulator;
+ wmGizmo *gz = bspline_group->handles[i].gizmo;
bspline_group->handles[i].pchan = pchan;
bspline_group->handles[i].index = i;
float mat[4][4];
mul_m4_m4m4(mat, ob->obmat, (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat);
- copy_m4_m4(mpr->matrix_space, mat);
+ copy_m4_m4(gz->matrix_space, mat);
/* need to set property here for undo. TODO would prefer to do this in _init */
- WM_manipulator_target_property_def_func(
- mpr, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_bbone_offset_get,
- .value_set_fn = manipulator_bbone_offset_set,
+ WM_gizmo_target_property_def_func(
+ gz, "offset",
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_bbone_offset_get,
+ .value_set_fn = gizmo_bbone_offset_set,
.range_get_fn = NULL,
.user_data = &bspline_group->handles[i],
});
}
}
-void VIEW3D_WGT_armature_spline(wmManipulatorGroupType *wgt)
+void VIEW3D_GGT_armature_spline(wmGizmoGroupType *gzgt)
{
- wgt->name = "Armature Spline Widgets";
- wgt->idname = "VIEW3D_WGT_armature_spline";
+ gzgt->name = "Armature Spline Widgets";
+ gzgt->idname = "VIEW3D_GGT_armature_spline";
- wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D);
+ gzgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_3D);
- wgt->poll = WIDGETGROUP_armature_spline_poll;
- wgt->setup = WIDGETGROUP_armature_spline_setup;
- wgt->refresh = WIDGETGROUP_armature_spline_refresh;
+ gzgt->poll = WIDGETGROUP_armature_spline_poll;
+ gzgt->setup = WIDGETGROUP_armature_spline_setup;
+ gzgt->refresh = WIDGETGROUP_armature_spline_refresh;
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c
index 023e16c070e..87b11f5d7a3 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/space_view3d/view3d_manipulator_camera.c
+/** \file blender/editors/space_view3d/view3d_gizmo_camera.c
* \ingroup spview3d
*/
@@ -35,7 +35,7 @@
#include "ED_armature.h"
#include "ED_screen.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "UI_resources.h"
@@ -52,19 +52,21 @@
/* -------------------------------------------------------------------- */
-/** \name Camera Manipulators
+/** \name Camera Gizmos
* \{ */
struct CameraWidgetGroup {
- wmManipulator *dop_dist;
- wmManipulator *focal_len;
- wmManipulator *ortho_scale;
+ wmGizmo *dop_dist;
+ wmGizmo *focal_len;
+ wmGizmo *ortho_scale;
};
-static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
View3D *v3d = CTX_wm_view3d(C);
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
+ {
return false;
}
@@ -79,57 +81,57 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *U
return false;
}
-static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
Object *ob = CTX_data_active_object(C);
float dir[3];
- const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true);
+ const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true);
- struct CameraWidgetGroup *camgroup = MEM_callocN(sizeof(struct CameraWidgetGroup), __func__);
- mgroup->customdata = camgroup;
+ struct CameraWidgetGroup *cagzgroup = MEM_callocN(sizeof(struct CameraWidgetGroup), __func__);
+ gzgroup->customdata = cagzgroup;
negate_v3_v3(dir, ob->obmat[2]);
/* dof distance */
{
- wmManipulator *mpr;
- mpr = camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
- RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CROSS);
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true);
+ wmGizmo *gz;
+ gz = cagzgroup->dop_dist = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL);
+ RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CROSS);
+ WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_HOVER, true);
- UI_GetThemeColor3fv(TH_MANIPULATOR_A, mpr->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+ UI_GetThemeColor3fv(TH_GIZMO_A, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
}
/* focal length
* - logic/calculations are similar to BKE_camera_view_frame_ex, better keep in sync */
{
- wmManipulator *mpr;
- mpr = camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
- mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE;
- RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE);
- RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED);
-
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
-
- mpr = camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
- mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE;
- RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE);
- RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED);
-
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+ wmGizmo *gz;
+ gz = cagzgroup->focal_len = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL);
+ gz->flag |= WM_GIZMO_DRAW_NO_SCALE;
+ RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CONE);
+ RNA_enum_set(gz->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED);
+
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
+
+ gz = cagzgroup->ortho_scale = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL);
+ gz->flag |= WM_GIZMO_DRAW_NO_SCALE;
+ RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CONE);
+ RNA_enum_set(gz->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED);
+
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
}
}
-static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- if (!mgroup->customdata)
+ if (!gzgroup->customdata)
return;
- struct CameraWidgetGroup *camgroup = mgroup->customdata;
+ struct CameraWidgetGroup *cagzgroup = gzgroup->customdata;
Object *ob = CTX_data_active_object(C);
Camera *ca = ob->data;
PointerRNA camera_ptr;
@@ -147,16 +149,16 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
negate_v3_v3(dir, ob->obmat[2]);
if (ca->flag & CAM_SHOWLIMITS) {
- WM_manipulator_set_matrix_location(camgroup->dop_dist, ob->obmat[3]);
- WM_manipulator_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob->obmat[1], dir);
- WM_manipulator_set_scale(camgroup->dop_dist, ca->drawsize);
- WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false);
+ WM_gizmo_set_matrix_location(cagzgroup->dop_dist, ob->obmat[3]);
+ WM_gizmo_set_matrix_rotation_from_yz_axis(cagzgroup->dop_dist, ob->obmat[1], dir);
+ WM_gizmo_set_scale(cagzgroup->dop_dist, ca->drawsize);
+ WM_gizmo_set_flag(cagzgroup->dop_dist, WM_GIZMO_HIDDEN, false);
/* need to set property here for undo. TODO would prefer to do this in _init */
- WM_manipulator_target_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1);
+ WM_gizmo_target_property_def_rna(cagzgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1);
}
else {
- WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(cagzgroup->dop_dist, WM_GIZMO_HIDDEN, true);
}
/* TODO - make focal length/ortho ob_scale_inv widget optional */
@@ -165,14 +167,14 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
const float aspy = (float)scene->r.ysch * scene->r.yasp;
const bool is_ortho = (ca->type == CAM_ORTHO);
const int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, aspx, aspy);
- wmManipulator *widget = is_ortho ? camgroup->ortho_scale : camgroup->focal_len;
+ wmGizmo *widget = is_ortho ? cagzgroup->ortho_scale : cagzgroup->focal_len;
float scale_matrix;
if (true) {
float offset[3];
float aspect[2];
- WM_manipulator_set_flag(widget, WM_MANIPULATOR_HIDDEN, false);
- WM_manipulator_set_flag(is_ortho ? camgroup->focal_len : camgroup->ortho_scale, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(widget, WM_GIZMO_HIDDEN, false);
+ WM_gizmo_set_flag(is_ortho ? cagzgroup->focal_len : cagzgroup->ortho_scale, WM_GIZMO_HIDDEN, true);
/* account for lens shifting */
@@ -185,8 +187,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f;
unit_m4(widget->matrix_basis);
- WM_manipulator_set_matrix_location(widget, ob->obmat[3]);
- WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir);
+ WM_gizmo_set_matrix_location(widget, ob->obmat[3]);
+ WM_gizmo_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir);
if (is_ortho) {
scale_matrix = ca->ortho_scale * 0.5f;
@@ -199,16 +201,16 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
RNA_float_set_array(widget->ptr, "aspect", aspect);
- WM_manipulator_set_matrix_offset_location(widget, offset);
+ WM_gizmo_set_matrix_offset_location(widget, offset);
}
/* define & update properties */
{
const char *propname = is_ortho ? "ortho_scale" : "lens";
PropertyRNA *prop = RNA_struct_find_property(&camera_ptr, propname);
- const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(widget->type, "offset");
+ const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(widget->type, "offset");
- WM_manipulator_target_property_clear_rna_ptr(widget, mpr_prop_type);
+ WM_gizmo_target_property_clear_rna_ptr(widget, gz_prop_type);
float min, max, range;
float step, precision;
@@ -217,29 +219,29 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
RNA_property_float_ui_range(&camera_ptr, prop, &min, &max, &step, &precision);
range = max - min;
- ED_manipulator_arrow3d_set_range_fac(
+ ED_gizmo_arrow3d_set_range_fac(
widget, is_ortho ?
(ca->drawsize * range) :
(scale_matrix * range /
/* Half sensor, intentionally use sensor from camera and not calculated above. */
(0.5f * ((ca->sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_x))));
- WM_manipulator_target_property_def_rna_ptr(widget, mpr_prop_type, &camera_ptr, prop, -1);
+ WM_gizmo_target_property_def_rna_ptr(widget, gz_prop_type, &camera_ptr, prop, -1);
}
}
static void WIDGETGROUP_camera_message_subscribe(
- const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus)
+ const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus)
{
ARegion *ar = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C);
Camera *ca = ob->data;
- wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = {
+ wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = {
.owner = ar,
- .user_data = mgroup->parent_mmap,
- .notify = WM_manipulator_do_msg_notify_tag_refresh,
+ .user_data = gzgroup->parent_gzmap,
+ .notify = WM_gizmo_do_msg_notify_tag_refresh,
};
{
@@ -268,43 +270,43 @@ static void WIDGETGROUP_camera_message_subscribe(
RNA_id_pointer_create(&ca->id, &idptr);
for (int i = 0; i < ARRAY_SIZE(props); i++) {
- WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
+ WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_gz_tag_refresh, __func__);
}
}
/* Subscribe to render settings */
{
- WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_x, &msg_sub_value_mpr_tag_refresh);
- WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_y, &msg_sub_value_mpr_tag_refresh);
- WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_x, &msg_sub_value_mpr_tag_refresh);
- WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_y, &msg_sub_value_mpr_tag_refresh);
+ WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_x, &msg_sub_value_gz_tag_refresh);
+ WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_y, &msg_sub_value_gz_tag_refresh);
+ WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_x, &msg_sub_value_gz_tag_refresh);
+ WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_y, &msg_sub_value_gz_tag_refresh);
}
}
-void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt)
+void VIEW3D_GGT_camera(wmGizmoGroupType *gzgt)
{
- wgt->name = "Camera Widgets";
- wgt->idname = "VIEW3D_WGT_camera";
+ gzgt->name = "Camera Widgets";
+ gzgt->idname = "VIEW3D_GGT_camera";
- wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D |
- WM_MANIPULATORGROUPTYPE_DEPTH_3D);
+ gzgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_3D |
+ WM_GIZMOGROUPTYPE_DEPTH_3D);
- wgt->poll = WIDGETGROUP_camera_poll;
- wgt->setup = WIDGETGROUP_camera_setup;
- wgt->refresh = WIDGETGROUP_camera_refresh;
- wgt->message_subscribe = WIDGETGROUP_camera_message_subscribe;
+ gzgt->poll = WIDGETGROUP_camera_poll;
+ gzgt->setup = WIDGETGROUP_camera_setup;
+ gzgt->refresh = WIDGETGROUP_camera_refresh;
+ gzgt->message_subscribe = WIDGETGROUP_camera_message_subscribe;
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name CameraView Manipulators
+/** \name CameraView Gizmos
* \{ */
struct CameraViewWidgetGroup {
- wmManipulator *border;
+ wmGizmo *border;
struct {
rctf *edit_border;
@@ -313,13 +315,13 @@ struct CameraViewWidgetGroup {
};
/* scale callbacks */
-static void manipulator_render_border_prop_matrix_get(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void gizmo_render_border_prop_matrix_get(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
void *value_p)
{
float (*matrix)[4] = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data;
+ BLI_assert(gz_prop->type->array_length == 16);
+ struct CameraViewWidgetGroup *viewgroup = gz_prop->custom_func.user_data;
const rctf *border = viewgroup->state.edit_border;
unit_m4(matrix);
@@ -329,21 +331,21 @@ static void manipulator_render_border_prop_matrix_get(
matrix[3][1] = BLI_rctf_cent_y(border);
}
-static void manipulator_render_border_prop_matrix_set(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void gizmo_render_border_prop_matrix_set(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
const void *value_p)
{
const float (*matrix)[4] = value_p;
- struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data;
+ struct CameraViewWidgetGroup *viewgroup = gz_prop->custom_func.user_data;
rctf *border = viewgroup->state.edit_border;
- BLI_assert(mpr_prop->type->array_length == 16);
+ BLI_assert(gz_prop->type->array_length == 16);
BLI_rctf_resize(border, len_v3(matrix[0]), len_v3(matrix[1]));
BLI_rctf_recenter(border, matrix[3][0], matrix[3][1]);
BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, border, border);
}
-static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
Scene *scene = CTX_data_scene(C);
@@ -358,7 +360,9 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupTy
}
View3D *v3d = CTX_wm_view3d(C);
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
+ {
return false;
}
@@ -378,24 +382,24 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupTy
return false;
}
-static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
struct CameraViewWidgetGroup *viewgroup = MEM_mallocN(sizeof(struct CameraViewWidgetGroup), __func__);
- viewgroup->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
+ viewgroup->border = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL);
RNA_enum_set(viewgroup->border->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE);
/* Box style is more subtle in this case. */
- RNA_enum_set(viewgroup->border->ptr, "draw_style", ED_MANIPULATOR_CAGE2D_STYLE_BOX);
+ RNA_enum_set(viewgroup->border->ptr, "draw_style", ED_GIZMO_CAGE2D_STYLE_BOX);
- mgroup->customdata = viewgroup;
+ gzgroup->customdata = viewgroup;
}
-static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
- struct CameraViewWidgetGroup *viewgroup = mgroup->customdata;
+ struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata;
ARegion *ar = CTX_wm_region(C);
struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
@@ -409,17 +413,17 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulato
viewgroup->state.view_border = (rctf){.xmin = 0, .ymin = 0, .xmax = ar->winx, .ymax = ar->winy};
}
- wmManipulator *mpr = viewgroup->border;
- unit_m4(mpr->matrix_space);
- mul_v3_fl(mpr->matrix_space[0], BLI_rctf_size_x(&viewgroup->state.view_border));
- mul_v3_fl(mpr->matrix_space[1], BLI_rctf_size_y(&viewgroup->state.view_border));
- mpr->matrix_space[3][0] = viewgroup->state.view_border.xmin;
- mpr->matrix_space[3][1] = viewgroup->state.view_border.ymin;
+ wmGizmo *gz = viewgroup->border;
+ unit_m4(gz->matrix_space);
+ mul_v3_fl(gz->matrix_space[0], BLI_rctf_size_x(&viewgroup->state.view_border));
+ mul_v3_fl(gz->matrix_space[1], BLI_rctf_size_y(&viewgroup->state.view_border));
+ gz->matrix_space[3][0] = viewgroup->state.view_border.xmin;
+ gz->matrix_space[3][1] = viewgroup->state.view_border.ymin;
}
-static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- struct CameraViewWidgetGroup *viewgroup = mgroup->customdata;
+ struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata;
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
@@ -427,11 +431,11 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGrou
Scene *scene = CTX_data_scene(C);
{
- wmManipulator *mpr = viewgroup->border;
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ wmGizmo *gz = viewgroup->border;
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
RNA_enum_set(viewgroup->border->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE);
if (rv3d->persp == RV3D_CAMOB) {
viewgroup->state.edit_border = &scene->r.border;
@@ -440,11 +444,11 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGrou
viewgroup->state.edit_border = &v3d->render_border;
}
- WM_manipulator_target_property_def_func(
- mpr, "matrix",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_render_border_prop_matrix_get,
- .value_set_fn = manipulator_render_border_prop_matrix_set,
+ WM_gizmo_target_property_def_func(
+ gz, "matrix",
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_render_border_prop_matrix_get,
+ .value_set_fn = gizmo_render_border_prop_matrix_set,
.range_get_fn = NULL,
.user_data = viewgroup,
});
@@ -452,18 +456,18 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGrou
}
-void VIEW3D_WGT_camera_view(wmManipulatorGroupType *wgt)
+void VIEW3D_GGT_camera_view(wmGizmoGroupType *gzgt)
{
- wgt->name = "Camera View Widgets";
- wgt->idname = "VIEW3D_WGT_camera_view";
+ gzgt->name = "Camera View Widgets";
+ gzgt->idname = "VIEW3D_GGT_camera_view";
- wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_SCALE);
+ gzgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_SCALE);
- wgt->poll = WIDGETGROUP_camera_view_poll;
- wgt->setup = WIDGETGROUP_camera_view_setup;
- wgt->draw_prepare = WIDGETGROUP_camera_view_draw_prepare;
- wgt->refresh = WIDGETGROUP_camera_view_refresh;
+ gzgt->poll = WIDGETGROUP_camera_view_poll;
+ gzgt->setup = WIDGETGROUP_camera_view_setup;
+ gzgt->draw_prepare = WIDGETGROUP_camera_view_draw_prepare;
+ gzgt->refresh = WIDGETGROUP_camera_view_refresh;
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_empty.c b/source/blender/editors/space_view3d/view3d_gizmo_empty.c
index 75e4a9e3314..2913ba245e7 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_empty.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/space_view3d/view3d_manipulator_empty.c
+/** \file blender/editors/space_view3d/view3d_gizmo_empty.c
* \ingroup spview3d
*/
@@ -35,7 +35,7 @@
#include "DNA_lamp_types.h"
#include "ED_screen.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "UI_resources.h"
@@ -50,11 +50,11 @@
/* -------------------------------------------------------------------- */
-/** \name Empty Image Manipulators
+/** \name Empty Image Gizmos
* \{ */
struct EmptyImageWidgetGroup {
- wmManipulator *manipulator;
+ wmGizmo *gizmo;
struct {
Object *ob;
float dims[2];
@@ -62,21 +62,21 @@ struct EmptyImageWidgetGroup {
};
/* translate callbacks */
-static void manipulator_empty_image_prop_matrix_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_empty_image_prop_matrix_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
void *value_p)
{
float (*matrix)[4] = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data;
- const Object *ob = imgroup->state.ob;
+ BLI_assert(gz_prop->type->array_length == 16);
+ struct EmptyImageWidgetGroup *igzgroup = gz_prop->custom_func.user_data;
+ const Object *ob = igzgroup->state.ob;
unit_m4(matrix);
matrix[0][0] = ob->empty_drawsize;
matrix[1][1] = ob->empty_drawsize;
float dims[2] = {0.0f, 0.0f};
- RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ RNA_float_get_array(gz->ptr, "dimensions", dims);
dims[0] *= ob->empty_drawsize;
dims[1] *= ob->empty_drawsize;
@@ -84,19 +84,19 @@ static void manipulator_empty_image_prop_matrix_get(
matrix[3][1] = (ob->ima_ofs[1] * dims[1]) + (0.5f * dims[1]);
}
-static void manipulator_empty_image_prop_matrix_set(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+static void gizmo_empty_image_prop_matrix_set(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
const void *value_p)
{
const float (*matrix)[4] = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data;
- Object *ob = imgroup->state.ob;
+ BLI_assert(gz_prop->type->array_length == 16);
+ struct EmptyImageWidgetGroup *igzgroup = gz_prop->custom_func.user_data;
+ Object *ob = igzgroup->state.ob;
ob->empty_drawsize = matrix[0][0];
float dims[2];
- RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ RNA_float_get_array(gz->ptr, "dimensions", dims);
dims[0] *= ob->empty_drawsize;
dims[1] *= ob->empty_drawsize;
@@ -104,10 +104,13 @@ static void manipulator_empty_image_prop_matrix_set(
ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1];
}
-static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
View3D *v3d = CTX_wm_view3d(C);
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
+ {
return false;
}
@@ -119,36 +122,36 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupTy
return false;
}
-static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
- struct EmptyImageWidgetGroup *imgroup = MEM_mallocN(sizeof(struct EmptyImageWidgetGroup), __func__);
- imgroup->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
- wmManipulator *mpr = imgroup->manipulator;
- RNA_enum_set(mpr->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+ struct EmptyImageWidgetGroup *igzgroup = MEM_mallocN(sizeof(struct EmptyImageWidgetGroup), __func__);
+ igzgroup->gizmo = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL);
+ wmGizmo *gz = igzgroup->gizmo;
+ RNA_enum_set(gz->ptr, "transform",
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE);
- mgroup->customdata = imgroup;
+ gzgroup->customdata = igzgroup;
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true);
+ WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_HOVER, true);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
}
-static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- struct EmptyImageWidgetGroup *imgroup = mgroup->customdata;
+ struct EmptyImageWidgetGroup *igzgroup = gzgroup->customdata;
Object *ob = CTX_data_active_object(C);
- wmManipulator *mpr = imgroup->manipulator;
+ wmGizmo *gz = igzgroup->gizmo;
- copy_m4_m4(mpr->matrix_basis, ob->obmat);
+ copy_m4_m4(gz->matrix_basis, ob->obmat);
- RNA_enum_set(mpr->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE |
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE |
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM);
+ RNA_enum_set(gz->ptr, "transform",
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE |
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE |
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM);
- imgroup->state.ob = ob;
+ igzgroup->state.ob = ob;
/* Use dimensions for aspect. */
if (ob->data != NULL) {
@@ -166,36 +169,36 @@ static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGrou
}
const float dims_max = max_ff(size[0], size[1]);
- imgroup->state.dims[0] = size[0] / dims_max;
- imgroup->state.dims[1] = size[1] / dims_max;
+ igzgroup->state.dims[0] = size[0] / dims_max;
+ igzgroup->state.dims[1] = size[1] / dims_max;
}
else {
- copy_v2_fl(imgroup->state.dims, 1.0f);
+ copy_v2_fl(igzgroup->state.dims, 1.0f);
}
- RNA_float_set_array(mpr->ptr, "dimensions", imgroup->state.dims);
+ RNA_float_set_array(gz->ptr, "dimensions", igzgroup->state.dims);
- WM_manipulator_target_property_def_func(
- mpr, "matrix",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_empty_image_prop_matrix_get,
- .value_set_fn = manipulator_empty_image_prop_matrix_set,
+ WM_gizmo_target_property_def_func(
+ gz, "matrix",
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_empty_image_prop_matrix_get,
+ .value_set_fn = gizmo_empty_image_prop_matrix_set,
.range_get_fn = NULL,
- .user_data = imgroup,
+ .user_data = igzgroup,
});
}
-void VIEW3D_WGT_empty_image(wmManipulatorGroupType *wgt)
+void VIEW3D_GGT_empty_image(wmGizmoGroupType *gzgt)
{
- wgt->name = "Area Lamp Widgets";
- wgt->idname = "VIEW3D_WGT_empty_image";
+ gzgt->name = "Area Light Widgets";
+ gzgt->idname = "VIEW3D_GGT_empty_image";
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D |
- WM_MANIPULATORGROUPTYPE_DEPTH_3D);
+ gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_3D |
+ WM_GIZMOGROUPTYPE_DEPTH_3D);
- wgt->poll = WIDGETGROUP_empty_image_poll;
- wgt->setup = WIDGETGROUP_empty_image_setup;
- wgt->refresh = WIDGETGROUP_empty_image_refresh;
+ gzgt->poll = WIDGETGROUP_empty_image_poll;
+ gzgt->setup = WIDGETGROUP_empty_image_setup;
+ gzgt->refresh = WIDGETGROUP_empty_image_refresh;
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c
index b42f49e6d1c..e2a8d2802e7 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/space_view3d/view3d_manipulator_forcefield.c
+/** \file blender/editors/space_view3d/view3d_gizmo_forcefield.c
* \ingroup spview3d
*/
@@ -34,7 +34,7 @@
#include "DNA_object_force_types.h"
#include "ED_screen.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "UI_resources.h"
@@ -49,13 +49,16 @@
/* -------------------------------------------------------------------- */
-/** \name Force Field Manipulators
+/** \name Force Field Gizmos
* \{ */
-static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
View3D *v3d = CTX_wm_view3d(C);
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
+ {
return false;
}
@@ -64,26 +67,26 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupTyp
return (ob && ob->pd && ob->pd->forcefield);
}
-static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
/* only wind effector for now */
- wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
- mgroup->customdata = wwrapper;
+ wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__);
+ gzgroup->customdata = wwrapper;
- wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL);
- wmManipulator *mpr = wwrapper->manipulator;
- RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED);
- ED_manipulator_arrow3d_set_ui_range(mpr, -200.0f, 200.0f);
- ED_manipulator_arrow3d_set_range_fac(mpr, 6.0f);
+ wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_arrow_3d", gzgroup, NULL);
+ wmGizmo *gz = wwrapper->gizmo;
+ RNA_enum_set(gz->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED);
+ ED_gizmo_arrow3d_set_ui_range(gz, -200.0f, 200.0f);
+ ED_gizmo_arrow3d_set_range_fac(gz, 6.0f);
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
}
-static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- wmManipulatorWrapper *wwrapper = mgroup->customdata;
- wmManipulator *mpr = wwrapper->manipulator;
+ wmGizmoWrapper *wwrapper = gzgroup->customdata;
+ wmGizmo *gz = wwrapper->gizmo;
Object *ob = CTX_data_active_object(C);
PartDeflect *pd = ob->pd;
@@ -93,30 +96,30 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup
PointerRNA field_ptr;
RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd, &field_ptr);
- WM_manipulator_set_matrix_location(mpr, ob->obmat[3]);
- WM_manipulator_set_matrix_rotation_from_z_axis(mpr, ob->obmat[2]);
- WM_manipulator_set_matrix_offset_location(mpr, ofs);
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
- WM_manipulator_target_property_def_rna(mpr, "offset", &field_ptr, "strength", -1);
+ WM_gizmo_set_matrix_location(gz, ob->obmat[3]);
+ WM_gizmo_set_matrix_rotation_from_z_axis(gz, ob->obmat[2]);
+ WM_gizmo_set_matrix_offset_location(gz, ofs);
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
+ WM_gizmo_target_property_def_rna(gz, "offset", &field_ptr, "strength", -1);
}
else {
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true);
}
}
-void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt)
+void VIEW3D_GGT_force_field(wmGizmoGroupType *gzgt)
{
- wgt->name = "Force Field Widgets";
- wgt->idname = "VIEW3D_WGT_force_field";
+ gzgt->name = "Force Field Widgets";
+ gzgt->idname = "VIEW3D_GGT_force_field";
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D |
- WM_MANIPULATORGROUPTYPE_SCALE |
- WM_MANIPULATORGROUPTYPE_DEPTH_3D);
+ gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_3D |
+ WM_GIZMOGROUPTYPE_SCALE |
+ WM_GIZMOGROUPTYPE_DEPTH_3D);
- wgt->poll = WIDGETGROUP_forcefield_poll;
- wgt->setup = WIDGETGROUP_forcefield_setup;
- wgt->refresh = WIDGETGROUP_forcefield_refresh;
+ gzgt->poll = WIDGETGROUP_forcefield_poll;
+ gzgt->setup = WIDGETGROUP_forcefield_setup;
+ gzgt->refresh = WIDGETGROUP_forcefield_refresh;
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_lamp.c b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c
new file mode 100644
index 00000000000..057c085b69d
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c
@@ -0,0 +1,307 @@
+/*
+ * ***** 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/editors/space_view3d/view3d_gizmo_lamp.c
+ * \ingroup spview3d
+ */
+
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_object.h"
+
+#include "DNA_object_types.h"
+#include "DNA_lamp_types.h"
+
+#include "ED_screen.h"
+#include "ED_gizmo_library.h"
+
+#include "UI_resources.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "view3d_intern.h" /* own include */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Spot Lamp Gizmos
+ * \{ */
+
+static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
+ {
+ return false;
+ }
+
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob && ob->type == OB_LAMP) {
+ Lamp *la = ob->data;
+ return (la->type == LA_SPOT);
+ }
+ return false;
+}
+
+static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
+{
+ wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__);
+
+ wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_arrow_3d", gzgroup, NULL);
+ wmGizmo *gz = wwrapper->gizmo;
+ RNA_enum_set(gz->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_INVERTED);
+
+ gzgroup->customdata = wwrapper;
+
+ ED_gizmo_arrow3d_set_range_fac(gz, 4.0f);
+
+ UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, gz->color);
+}
+
+static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmGizmoGroup *gzgroup)
+{
+ wmGizmoWrapper *wwrapper = gzgroup->customdata;
+ wmGizmo *gz = wwrapper->gizmo;
+ Object *ob = CTX_data_active_object(C);
+ Lamp *la = ob->data;
+ float dir[3];
+
+ negate_v3_v3(dir, ob->obmat[2]);
+
+ WM_gizmo_set_matrix_rotation_from_z_axis(gz, dir);
+ WM_gizmo_set_matrix_location(gz, ob->obmat[3]);
+
+ /* need to set property here for undo. TODO would prefer to do this in _init */
+ PointerRNA lamp_ptr;
+ const char *propname = "spot_size";
+ RNA_pointer_create(&la->id, &RNA_Light, la, &lamp_ptr);
+ WM_gizmo_target_property_def_rna(gz, "offset", &lamp_ptr, propname, -1);
+}
+
+void VIEW3D_GGT_lamp_spot(wmGizmoGroupType *gzgt)
+{
+ gzgt->name = "Spot Light Widgets";
+ gzgt->idname = "VIEW3D_GGT_lamp_spot";
+
+ gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_3D |
+ WM_GIZMOGROUPTYPE_DEPTH_3D);
+
+ gzgt->poll = WIDGETGROUP_lamp_spot_poll;
+ gzgt->setup = WIDGETGROUP_lamp_spot_setup;
+ gzgt->refresh = WIDGETGROUP_lamp_spot_refresh;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Area Lamp Gizmos
+ * \{ */
+
+/* scale callbacks */
+static void gizmo_area_lamp_prop_matrix_get(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
+ void *value_p)
+{
+ BLI_assert(gz_prop->type->array_length == 16);
+ float (*matrix)[4] = value_p;
+ const Lamp *la = gz_prop->custom_func.user_data;
+
+ matrix[0][0] = la->area_size;
+ matrix[1][1] = ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE) ? la->area_sizey : la->area_size;
+}
+
+static void gizmo_area_lamp_prop_matrix_set(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
+ const void *value_p)
+{
+ const float (*matrix)[4] = value_p;
+ BLI_assert(gz_prop->type->array_length == 16);
+ Lamp *la = gz_prop->custom_func.user_data;
+
+ if (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE)) {
+ la->area_size = len_v3(matrix[0]);
+ la->area_sizey = len_v3(matrix[1]);
+ }
+ else {
+ la->area_size = len_v3(matrix[0]);
+ }
+}
+
+static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
+ Object *ob = CTX_data_active_object(C);
+ if (ob && ob->type == OB_LAMP) {
+ Lamp *la = ob->data;
+ return (la->type == LA_AREA);
+ }
+ return false;
+}
+
+static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
+{
+ wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__);
+ wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL);
+ wmGizmo *gz = wwrapper->gizmo;
+ RNA_enum_set(gz->ptr, "transform",
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE);
+
+ gzgroup->customdata = wwrapper;
+
+ WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_HOVER, true);
+
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
+}
+
+static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmGizmoGroup *gzgroup)
+{
+ wmGizmoWrapper *wwrapper = gzgroup->customdata;
+ Object *ob = CTX_data_active_object(C);
+ Lamp *la = ob->data;
+ wmGizmo *gz = wwrapper->gizmo;
+
+ copy_m4_m4(gz->matrix_basis, ob->obmat);
+
+ int flag = ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE;
+ if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) {
+ flag |= ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM;
+ }
+ RNA_enum_set(gz->ptr, "transform", flag);
+
+ /* need to set property here for undo. TODO would prefer to do this in _init */
+ WM_gizmo_target_property_def_func(
+ gz, "matrix",
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = gizmo_area_lamp_prop_matrix_get,
+ .value_set_fn = gizmo_area_lamp_prop_matrix_set,
+ .range_get_fn = NULL,
+ .user_data = la,
+ });
+}
+
+void VIEW3D_GGT_lamp_area(wmGizmoGroupType *gzgt)
+{
+ gzgt->name = "Area Light Widgets";
+ gzgt->idname = "VIEW3D_GGT_lamp_area";
+
+ gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_3D |
+ WM_GIZMOGROUPTYPE_DEPTH_3D);
+
+ gzgt->poll = WIDGETGROUP_lamp_area_poll;
+ gzgt->setup = WIDGETGROUP_lamp_area_setup;
+ gzgt->refresh = WIDGETGROUP_lamp_area_refresh;
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Lamp Target Gizmo
+ * \{ */
+
+static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob != NULL) {
+ if (ob->type == OB_LAMP) {
+ Lamp *la = ob->data;
+ return (ELEM(la->type, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA));
+ }
+#if 0
+ else if (ob->type == OB_CAMERA) {
+ return true;
+ }
+#endif
+ }
+ return false;
+}
+
+static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
+{
+ wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__);
+ wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_grab_3d", gzgroup, NULL);
+ wmGizmo *gz = wwrapper->gizmo;
+
+ gzgroup->customdata = wwrapper;
+
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
+
+ gz->scale_basis = 0.06f;
+
+ wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_transform_axis_target", true);
+
+ RNA_enum_set(gz->ptr, "draw_options",
+ ED_GIZMO_GRAB_DRAW_FLAG_FILL | ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW);
+
+ WM_gizmo_operator_set(gz, 0, ot, NULL);
+}
+
+static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
+{
+ wmGizmoWrapper *wwrapper = gzgroup->customdata;
+ Object *ob = CTX_data_active_object(C);
+ wmGizmo *gz = wwrapper->gizmo;
+
+ copy_m4_m4(gz->matrix_basis, ob->obmat);
+ unit_m4(gz->matrix_offset);
+ gz->matrix_offset[3][2] = -2.4f / gz->scale_basis;
+ WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_OFFSET_SCALE, true);
+}
+
+void VIEW3D_GGT_lamp_target(wmGizmoGroupType *gzgt)
+{
+ gzgt->name = "Target Light Widgets";
+ gzgt->idname = "VIEW3D_GGT_lamp_target";
+
+ gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_3D);
+
+ gzgt->poll = WIDGETGROUP_lamp_target_poll;
+ gzgt->setup = WIDGETGROUP_lamp_target_setup;
+ gzgt->draw_prepare = WIDGETGROUP_lamp_target_draw_prepare;
+}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
index 22b7af48de6..388d9a29eff 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/space_view3d/view3d_manipulator_navigate.c
+/** \file blender/editors/space_view3d/view3d_gizmo_navigate.c
* \ingroup spview3d
*/
@@ -32,7 +32,7 @@
#include "DNA_object_types.h"
#include "ED_screen.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -47,17 +47,17 @@
#include "view3d_intern.h" /* own include */
/* -------------------------------------------------------------------- */
-/** \name View3D Navigation Manipulator Group
+/** \name View3D Navigation Gizmo Group
* \{ */
/* Offset from screen edge. */
-#define MANIPULATOR_OFFSET_FAC 1.5f
+#define GIZMO_OFFSET_FAC 1.5f
/* Size of main icon. */
-#define MANIPULATOR_SIZE 64
+#define GIZMO_SIZE 80
/* Factor for size of smaller button. */
-#define MANIPULATOR_MINI_FAC 0.35f
+#define GIZMO_MINI_FAC 0.35f
/* How much mini buttons offset from the primary. */
-#define MANIPULATOR_MINI_OFFSET_FAC 0.42f
+#define GIZMO_MINI_OFFSET_FAC 0.42f
enum {
@@ -122,40 +122,40 @@ static const uchar shape_zoom[] = {
};
-struct NavigateManipulatorInfo {
+struct NavigateGizmoInfo {
const char *opname;
- const char *manipulator;
+ const char *gizmo;
const unsigned char *shape;
uint shape_size;
};
#define SHAPE_VARS(shape_id) shape = shape_id, .shape_size = ARRAY_SIZE(shape_id)
-struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = {
+struct NavigateGizmoInfo g_navigate_params[MPR_TOTAL] = {
{
.opname = "VIEW3D_OT_move",
- .manipulator = "MANIPULATOR_WT_button_2d",
+ .gizmo = "GIZMO_GT_button_2d",
.SHAPE_VARS(shape_pan),
}, {
.opname = "VIEW3D_OT_rotate",
- .manipulator = "VIEW3D_WT_navigate_rotate",
+ .gizmo = "VIEW3D_GT_navigate_rotate",
.shape = NULL,
.shape_size = 0,
}, {
.opname = "VIEW3D_OT_zoom",
- .manipulator = "MANIPULATOR_WT_button_2d",
+ .gizmo = "GIZMO_GT_button_2d",
.SHAPE_VARS(shape_zoom),
}, {
.opname = "VIEW3D_OT_view_persportho",
- .manipulator = "MANIPULATOR_WT_button_2d",
+ .gizmo = "GIZMO_GT_button_2d",
.SHAPE_VARS(shape_persp),
}, {
.opname = "VIEW3D_OT_view_persportho",
- .manipulator = "MANIPULATOR_WT_button_2d",
+ .gizmo = "GIZMO_GT_button_2d",
.SHAPE_VARS(shape_ortho),
}, {
- .opname = "VIEW3D_OT_viewnumpad",
- .manipulator = "MANIPULATOR_WT_button_2d",
+ .opname = "VIEW3D_OT_view_camera",
+ .gizmo = "GIZMO_GT_button_2d",
.SHAPE_VARS(shape_camera),
},
};
@@ -163,7 +163,7 @@ struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = {
#undef SHAPE_VARS
struct NavigateWidgetGroup {
- wmManipulator *mpr_array[MPR_TOTAL];
+ wmGizmo *gz_array[MPR_TOTAL];
/* Store the view state to check for changes. */
struct {
rcti rect_visible;
@@ -176,79 +176,78 @@ struct NavigateWidgetGroup {
int region_size[2];
};
-static bool WIDGETGROUP_navigate_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
View3D *v3d = CTX_wm_view3d(C);
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ if (((U.uiflag & USER_SHOW_GIZMO_AXIS) == 0) ||
+ (v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE)))
+ {
return false;
}
-
- if (U.manipulator_flag & USER_MANIPULATOR_DRAW_NAVIGATE) {
- return true;
- }
- return false;
+ return true;
}
-static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
struct NavigateWidgetGroup *navgroup = MEM_callocN(sizeof(struct NavigateWidgetGroup), __func__);
navgroup->region_size[0] = -1;
navgroup->region_size[1] = -1;
- wmOperatorType *ot_viewnumpad = WM_operatortype_find("VIEW3D_OT_viewnumpad", true);
+ wmOperatorType *ot_view_axis = WM_operatortype_find("VIEW3D_OT_view_axis", true);
+ wmOperatorType *ot_view_camera = WM_operatortype_find("VIEW3D_OT_view_camera", true);
for (int i = 0; i < MPR_TOTAL; i++) {
- const struct NavigateManipulatorInfo *info = &g_navigate_params[i];
- navgroup->mpr_array[i] = WM_manipulator_new(info->manipulator, mgroup, NULL);
- wmManipulator *mpr = navgroup->mpr_array[i];
- mpr->flag |= WM_MANIPULATOR_GRAB_CURSOR | WM_MANIPULATOR_DRAW_MODAL;
- mpr->color[3] = 0.2f;
- mpr->color_hi[3] = 0.4f;
+ const struct NavigateGizmoInfo *info = &g_navigate_params[i];
+ navgroup->gz_array[i] = WM_gizmo_new(info->gizmo, gzgroup, NULL);
+ wmGizmo *gz = navgroup->gz_array[i];
+ gz->flag |= WM_GIZMO_GRAB_CURSOR | WM_GIZMO_DRAW_MODAL;
+ gz->color[3] = 0.2f;
+ gz->color_hi[3] = 0.4f;
/* may be overwritten later */
- mpr->scale_basis = (MANIPULATOR_SIZE * MANIPULATOR_MINI_FAC) / 2;
+ gz->scale_basis = (GIZMO_SIZE * GIZMO_MINI_FAC) / 2;
if (info->shape != NULL) {
- PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "shape");
+ PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "shape");
RNA_property_string_set_bytes(
- mpr->ptr, prop,
+ gz->ptr, prop,
(const char *)info->shape, info->shape_size);
- RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_BUTTON_SHOW_OUTLINE);
+ RNA_enum_set(gz->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_OUTLINE);
}
wmOperatorType *ot = WM_operatortype_find(info->opname, true);
- WM_manipulator_operator_set(mpr, 0, ot, NULL);
+ WM_gizmo_operator_set(gz, 0, ot, NULL);
}
{
- wmManipulator *mpr = navgroup->mpr_array[MPR_CAMERA];
- PointerRNA *ptr = WM_manipulator_operator_set(mpr, 0, ot_viewnumpad, NULL);
- RNA_enum_set(ptr, "type", RV3D_VIEW_CAMERA);
+ wmGizmo *gz = navgroup->gz_array[MPR_CAMERA];
+ WM_gizmo_operator_set(gz, 0, ot_view_camera, NULL);
}
/* Click only buttons (not modal). */
{
- int mpr_ids[] = {MPR_PERSP, MPR_ORTHO, MPR_CAMERA};
- for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) {
- wmManipulator *mpr = navgroup->mpr_array[mpr_ids[i]];
- RNA_boolean_set(mpr->ptr, "show_drag", false);
+ int gz_ids[] = {MPR_PERSP, MPR_ORTHO, MPR_CAMERA};
+ for (int i = 0; i < ARRAY_SIZE(gz_ids); i++) {
+ wmGizmo *gz = navgroup->gz_array[gz_ids[i]];
+ RNA_boolean_set(gz->ptr, "show_drag", false);
}
}
/* Modal operators, don't use initial mouse location since we're clicking on a button. */
{
- int mpr_ids[] = {MPR_MOVE, MPR_ROTATE, MPR_ZOOM};
- for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) {
- wmManipulator *mpr = navgroup->mpr_array[mpr_ids[i]];
- wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, 0);
+ int gz_ids[] = {MPR_MOVE, MPR_ROTATE, MPR_ZOOM};
+ for (int i = 0; i < ARRAY_SIZE(gz_ids); i++) {
+ wmGizmo *gz = navgroup->gz_array[gz_ids[i]];
+ wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, 0);
RNA_boolean_set(&mpop->ptr, "use_mouse_init", false);
}
}
{
- wmManipulator *mpr = navgroup->mpr_array[MPR_ROTATE];
- mpr->scale_basis = MANIPULATOR_SIZE / 2;
+ wmGizmo *gz = navgroup->gz_array[MPR_ROTATE];
+ gz->scale_basis = GIZMO_SIZE / 2;
char mapping[6] = {
RV3D_VIEW_LEFT,
RV3D_VIEW_RIGHT,
@@ -259,25 +258,25 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG
};
for (int part_index = 0; part_index < 6; part_index += 1) {
- PointerRNA *ptr = WM_manipulator_operator_set(mpr, part_index + 1, ot_viewnumpad, NULL);
+ PointerRNA *ptr = WM_gizmo_operator_set(gz, part_index + 1, ot_view_axis, NULL);
RNA_enum_set(ptr, "type", mapping[part_index]);
}
/* When dragging an axis, use this instead. */
- mpr->drag_part = 0;
+ gz->drag_part = 0;
}
- mgroup->customdata = navgroup;
+ gzgroup->customdata = navgroup;
}
-static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
- struct NavigateWidgetGroup *navgroup = mgroup->customdata;
+ struct NavigateWidgetGroup *navgroup = gzgroup->customdata;
ARegion *ar = CTX_wm_region(C);
const RegionView3D *rv3d = ar->regiondata;
for (int i = 0; i < 3; i++) {
- copy_v3_v3(navgroup->mpr_array[MPR_ROTATE]->matrix_offset[i], rv3d->viewmat[i]);
+ copy_v3_v3(navgroup->gz_array[MPR_ROTATE]->matrix_offset[i], rv3d->viewmat[i]);
}
rcti rect_visible;
@@ -301,9 +300,9 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
((rv3d->viewlock & RV3D_LOCKED) == 0) &&
(navgroup->state.rv3d.is_camera == false));
const bool show_fixed_offset = navgroup->state.rv3d.is_camera;
- const float icon_size = MANIPULATOR_SIZE;
- const float icon_offset = (icon_size * 0.52f) * MANIPULATOR_OFFSET_FAC * UI_DPI_FAC;
- const float icon_offset_mini = icon_size * MANIPULATOR_MINI_OFFSET_FAC * UI_DPI_FAC;
+ const float icon_size = GIZMO_SIZE;
+ const float icon_offset = (icon_size * 0.52f) * GIZMO_OFFSET_FAC * UI_DPI_FAC;
+ const float icon_offset_mini = icon_size * GIZMO_MINI_OFFSET_FAC * UI_DPI_FAC;
const float co_rotate[2] = {
rect_visible.xmax - icon_offset,
rect_visible.ymax - icon_offset,
@@ -313,60 +312,60 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
rect_visible.ymax - icon_offset_mini * 0.75f,
};
- wmManipulator *mpr;
+ wmGizmo *gz;
- for (uint i = 0; i < ARRAY_SIZE(navgroup->mpr_array); i++) {
- mpr = navgroup->mpr_array[i];
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ for (uint i = 0; i < ARRAY_SIZE(navgroup->gz_array); i++) {
+ gz = navgroup->gz_array[i];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true);
}
/* RV3D_LOCKED or Camera: only show supported buttons. */
if (show_rotate) {
- mpr = navgroup->mpr_array[MPR_ROTATE];
- mpr->matrix_basis[3][0] = co_rotate[0];
- mpr->matrix_basis[3][1] = co_rotate[1];
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ gz = navgroup->gz_array[MPR_ROTATE];
+ gz->matrix_basis[3][0] = co_rotate[0];
+ gz->matrix_basis[3][1] = co_rotate[1];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
}
int icon_mini_slot = 0;
- mpr = navgroup->mpr_array[MPR_ZOOM];
- mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
- mpr->matrix_basis[3][1] = co[1];
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ gz = navgroup->gz_array[MPR_ZOOM];
+ gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
+ gz->matrix_basis[3][1] = co[1];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
- mpr = navgroup->mpr_array[MPR_MOVE];
- mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
- mpr->matrix_basis[3][1] = co[1];
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ gz = navgroup->gz_array[MPR_MOVE];
+ gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
+ gz->matrix_basis[3][1] = co[1];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
- mpr = navgroup->mpr_array[MPR_CAMERA];
- mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
- mpr->matrix_basis[3][1] = co[1];
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ gz = navgroup->gz_array[MPR_CAMERA];
+ gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
+ gz->matrix_basis[3][1] = co[1];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
if (navgroup->state.rv3d.is_camera == false) {
- mpr = navgroup->mpr_array[rv3d->is_persp ? MPR_PERSP : MPR_ORTHO];
- mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
- mpr->matrix_basis[3][1] = co[1];
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ gz = navgroup->gz_array[rv3d->is_persp ? MPR_PERSP : MPR_ORTHO];
+ gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
+ gz->matrix_basis[3][1] = co[1];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
}
}
}
-void VIEW3D_WGT_navigate(wmManipulatorGroupType *wgt)
+void VIEW3D_GGT_navigate(wmGizmoGroupType *gzgt)
{
- wgt->name = "View3D Navigate";
- wgt->idname = "VIEW3D_WGT_navigate";
+ gzgt->name = "View3D Navigate";
+ gzgt->idname = "VIEW3D_GGT_navigate";
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_SCALE |
- WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL);
+ gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT |
+ WM_GIZMOGROUPTYPE_SCALE |
+ WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL);
- wgt->poll = WIDGETGROUP_navigate_poll;
- wgt->setup = WIDGETGROUP_navigate_setup;
- wgt->draw_prepare = WIDGETGROUP_navigate_draw_prepare;
+ gzgt->poll = WIDGETGROUP_navigate_poll;
+ gzgt->setup = WIDGETGROUP_navigate_setup;
+ gzgt->draw_prepare = WIDGETGROUP_navigate_draw_prepare;
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
new file mode 100644
index 00000000000..93617f22490
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
@@ -0,0 +1,417 @@
+/*
+ * ***** 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 view3d_gizmo_navigate_type.c
+ * \ingroup wm
+ *
+ * \name Custom Orientation/Navigation Gizmo for the 3D View
+ *
+ * \brief Simple gizmo to axis and translate.
+ *
+ * - scale_basis: used for the size.
+ * - matrix_basis: used for the location.
+ * - matrix_offset: used to store the orientation.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_sort_utils.h"
+
+#include "BKE_context.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_matrix.h"
+#include "GPU_state.h"
+#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_screen.h"
+
+#include "view3d_intern.h"
+
+#define DIAL_RESOLUTION 32
+
+#define HANDLE_SIZE 0.33
+
+/**
+ * \param viewmat_local_unit is typically the 'rv3d->viewmatob'
+ * copied into a 3x3 matrix and normalized.
+ */
+static void draw_xyz_wire(
+ uint pos_id, const float viewmat_local_unit[3][3], const float c[3], float size, int axis)
+{
+ int line_type;
+ float buffer[4][3];
+ int n = 0;
+
+ float v1[3] = {0.0f, 0.0f, 0.0f}, v2[3] = {0.0f, 0.0f, 0.0f};
+ float dim = size * 0.1f;
+ float dx[3], dy[3];
+
+ dx[0] = dim; dx[1] = 0.0f; dx[2] = 0.0f;
+ dy[0] = 0.0f; dy[1] = dim; dy[2] = 0.0f;
+
+ switch (axis) {
+ case 0: /* x axis */
+ line_type = GPU_PRIM_LINES;
+
+ /* bottom left to top right */
+ negate_v3_v3(v1, dx);
+ sub_v3_v3(v1, dy);
+ copy_v3_v3(v2, dx);
+ add_v3_v3(v2, dy);
+
+ copy_v3_v3(buffer[n++], v1);
+ copy_v3_v3(buffer[n++], v2);
+
+ /* top left to bottom right */
+ mul_v3_fl(dy, 2.0f);
+ add_v3_v3(v1, dy);
+ sub_v3_v3(v2, dy);
+
+ copy_v3_v3(buffer[n++], v1);
+ copy_v3_v3(buffer[n++], v2);
+
+ break;
+ case 1: /* y axis */
+ line_type = GPU_PRIM_LINES;
+
+ /* bottom left to top right */
+ mul_v3_fl(dx, 0.75f);
+ negate_v3_v3(v1, dx);
+ sub_v3_v3(v1, dy);
+ copy_v3_v3(v2, dx);
+ add_v3_v3(v2, dy);
+
+ copy_v3_v3(buffer[n++], v1);
+ copy_v3_v3(buffer[n++], v2);
+
+ /* top left to center */
+ mul_v3_fl(dy, 2.0f);
+ add_v3_v3(v1, dy);
+ zero_v3(v2);
+
+ copy_v3_v3(buffer[n++], v1);
+ copy_v3_v3(buffer[n++], v2);
+
+ break;
+ case 2: /* z axis */
+ line_type = GPU_PRIM_LINE_STRIP;
+
+ /* start at top left */
+ negate_v3_v3(v1, dx);
+ add_v3_v3(v1, dy);
+
+ copy_v3_v3(buffer[n++], v1);
+
+ mul_v3_fl(dx, 2.0f);
+ add_v3_v3(v1, dx);
+
+ copy_v3_v3(buffer[n++], v1);
+
+ mul_v3_fl(dy, 2.0f);
+ sub_v3_v3(v1, dx);
+ sub_v3_v3(v1, dy);
+
+ copy_v3_v3(buffer[n++], v1);
+
+ add_v3_v3(v1, dx);
+
+ copy_v3_v3(buffer[n++], v1);
+
+ break;
+ default:
+ BLI_assert(0);
+ return;
+ }
+
+ for (int i = 0; i < n; i++) {
+ mul_transposed_m3_v3((float (*)[3])viewmat_local_unit, buffer[i]);
+ add_v3_v3(buffer[i], c);
+ }
+
+ immBegin(line_type, n);
+ for (int i = 0; i < n; i++) {
+ immVertex3fv(pos_id, buffer[i]);
+ }
+ immEnd();
+}
+
+static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool UNUSED(select))
+{
+ GPU_line_width(gz->line_width);
+
+ GPUVertFormat *format = immVertexFormat();
+ const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+
+ struct {
+ float depth;
+ char index;
+ char axis;
+ char is_pos;
+ } axis_order[6] = {
+ {-gz->matrix_offset[0][2], 0, 0, false},
+ {+gz->matrix_offset[0][2], 1, 0, true},
+ {-gz->matrix_offset[1][2], 2, 1, false},
+ {+gz->matrix_offset[1][2], 3, 1, true},
+ {-gz->matrix_offset[2][2], 4, 2, false},
+ {+gz->matrix_offset[2][2], 5, 2, true},
+ };
+ qsort(&axis_order, ARRAY_SIZE(axis_order), sizeof(axis_order[0]), BLI_sortutil_cmp_float);
+
+ const float scale_axis = 0.25f;
+ static const float axis_highlight[4] = {1, 1, 1, 1};
+ static const float axis_black[4] = {0, 0, 0, 1};
+ static float axis_color[3][4];
+ GPU_matrix_push();
+ GPU_matrix_mul(gz->matrix_offset);
+
+ bool draw_center_done = false;
+
+ int axis_align = -1;
+ for (int axis = 0; axis < 3; axis++) {
+ if (len_squared_v2(gz->matrix_offset[axis]) < 1e-6f) {
+ axis_align = axis;
+ break;
+ }
+ }
+
+ for (int axis_index = 0; axis_index < ARRAY_SIZE(axis_order); axis_index++) {
+ const int index = axis_order[axis_index].index;
+ const int axis = axis_order[axis_index].axis;
+ const bool is_pos = axis_order[axis_index].is_pos;
+ const bool is_highlight = index + 1 == gz->highlight_part;
+
+ /* Draw slightly before, so axis aligned arrows draw ontop. */
+ if ((draw_center_done == false) && (axis_order[axis_index].depth > -0.01f)) {
+
+ /* Circle defining active area (revert back to 2D space). */
+ {
+ GPU_matrix_pop();
+ immUniformColor4fv(color);
+ imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION);
+ GPU_matrix_push();
+ GPU_matrix_mul(gz->matrix_offset);
+ }
+ draw_center_done = true;
+ }
+ UI_GetThemeColor3fv(TH_AXIS_X + axis, axis_color[axis]);
+ axis_color[axis][3] = 1.0f;
+
+ const int index_z = axis;
+ const int index_y = (axis + 1) % 3;
+ const int index_x = (axis + 2) % 3;
+
+ bool ok = true;
+
+ /* skip view align axis */
+ if ((axis_align == axis) && (gz->matrix_offset[axis][2] > 0.0f) == is_pos) {
+ ok = false;
+ }
+ if (ok) {
+ /* Check aligned, since the front axis won't display in this case,
+ * and we want to make sure all 3 axes have a character at all times. */
+ const bool show_axis_char = (is_pos || (axis == axis_align));
+ const float v[3] = {0, 0, 3 * (is_pos ? 1 : -1)};
+ const float v_final[3] = {
+ v[index_x] * scale_axis,
+ v[index_y] * scale_axis,
+ v[index_z] * scale_axis,
+ };
+ const float *color_current = is_highlight ? axis_highlight : axis_color[axis];
+ float color_current_fade[4];
+ copy_v4_v4(color_current_fade, color_current);
+ color_current_fade[3] *= 0.2;
+
+ /* Axis Line. */
+ if (is_pos) {
+ float v_start[3];
+ GPU_line_width(2.0f);
+ immUniformColor4fv(color_current);
+ immBegin(GPU_PRIM_LINES, 2);
+ if (axis_align == -1) {
+ zero_v3(v_start);
+ }
+ else {
+ /* When axis aligned we don't draw the front most axis
+ * (allowing us to switch to the opposite side).
+ * In this case don't draw lines over axis pointing away from us
+ * because it obscures character and looks noisy.
+ */
+ mul_v3_v3fl(v_start, v_final, 0.3f);
+ }
+ immVertex3fv(pos_id, v_start);
+ immVertex3fv(pos_id, v_final);
+ immEnd();
+ }
+
+ /* Axis Ball. */
+ {
+ GPU_matrix_push();
+ GPU_matrix_translate_3fv(v_final);
+ GPU_matrix_scale_1f(show_axis_char ? 0.22f : 0.18f);
+
+ GPUBatch *sphere = GPU_batch_preset_sphere(0);
+ GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
+ GPU_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade);
+ GPU_batch_draw(sphere);
+ GPU_matrix_pop();
+ }
+
+ /* Axis XYZ Character. */
+ if (show_axis_char) {
+ GPU_line_width(1.0f);
+ float m3[3][3];
+ copy_m3_m4(m3, gz->matrix_offset);
+ immUniformColor4fv(is_highlight ? axis_black : axis_highlight);
+ draw_xyz_wire(pos_id, m3, v_final, 1.0, axis);
+ }
+ }
+ }
+
+ GPU_matrix_pop();
+ immUnbindProgram();
+}
+
+static void axis3d_draw_intern(
+ const bContext *UNUSED(C), wmGizmo *gz,
+ const bool select, const bool highlight)
+{
+ const float *color = highlight ? gz->color_hi : gz->color;
+ float matrix_final[4][4];
+ float matrix_unit[4][4];
+
+ unit_m4(matrix_unit);
+
+ WM_gizmo_calc_matrix_final_params(
+ gz,
+ &((struct WM_GizmoMatrixParams) {
+ .matrix_offset = matrix_unit,
+ }), matrix_final);
+
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
+
+ GPU_blend(true);
+ axis_geom_draw(gz, color, select);
+ GPU_blend(false);
+ GPU_matrix_pop();
+}
+
+static void gizmo_axis_draw(const bContext *C, wmGizmo *gz)
+{
+ const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL;
+ const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
+
+ (void)is_modal;
+
+ GPU_blend(true);
+ axis3d_draw_intern(C, gz, false, is_highlight);
+ GPU_blend(false);
+}
+
+static int gizmo_axis_test_select(
+ bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
+{
+ float point_local[2] = {UNPACK2(event->mval)};
+ sub_v2_v2(point_local, gz->matrix_basis[3]);
+ mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC));
+
+ const float len_sq = len_squared_v2(point_local);
+ if (len_sq > 1.0) {
+ return -1;
+ }
+
+ int part_best = -1;
+ int part_index = 1;
+ /* Use 'SQUARE(HANDLE_SIZE)' if we want to be able to _not_ focus on one of the axis. */
+ float i_best_len_sq = FLT_MAX;
+ for (int i = 0; i < 3; i++) {
+ for (int is_pos = 0; is_pos < 2; is_pos++) {
+ float co[2] = {
+ gz->matrix_offset[i][0] * (is_pos ? 1 : -1),
+ gz->matrix_offset[i][1] * (is_pos ? 1 : -1),
+ };
+
+ bool ok = true;
+
+ /* Check if we're viewing on an axis, there is no point to clicking on the current axis so show the reverse. */
+ if (len_squared_v2(co) < 1e-6f && (gz->matrix_offset[i][2] > 0.0f) == is_pos) {
+ ok = false;
+ }
+
+ if (ok) {
+ const float len_axis_sq = len_squared_v2v2(co, point_local);
+ if (len_axis_sq < i_best_len_sq) {
+ part_best = part_index;
+ i_best_len_sq = len_axis_sq;
+ }
+ }
+ part_index += 1;
+ }
+ }
+
+ if (part_best != -1) {
+ return part_best;
+ }
+
+ /* The 'gz->scale_final' is already applied when projecting. */
+ if (len_sq < 1.0f) {
+ return 0;
+ }
+
+ return -1;
+}
+
+static int gizmo_axis_cursor_get(wmGizmo *gz)
+{
+ if (gz->highlight_part > 0) {
+ return CURSOR_EDIT;
+ }
+ return BC_NSEW_SCROLLCURSOR;
+}
+
+void VIEW3D_GT_navigate_rotate(wmGizmoType *gzt)
+{
+ /* identifiers */
+ gzt->idname = "VIEW3D_GT_navigate_rotate";
+
+ /* api callbacks */
+ gzt->draw = gizmo_axis_draw;
+ gzt->test_select = gizmo_axis_test_select;
+ gzt->cursor_get = gizmo_axis_cursor_get;
+
+ gzt->struct_size = sizeof(wmGizmo);
+}
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index c33f15c0493..c716692eb9b 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/space_view3d/view3d_manipulator_ruler.c
+/** \file blender/editors/space_view3d/view3d_gizmo_ruler.c
* \ingroup spview3d
*/
@@ -68,7 +68,7 @@
#include "BLF_api.h"
-static const char *view3d_wgt_ruler_id = "VIEW3D_WGT_ruler";
+static const char *view3d_gzgt_ruler_id = "VIEW3D_GGT_ruler";
#define MVAL_MAX_PX_DIST 12.0f
@@ -93,7 +93,7 @@ enum {
#define PART_LINE 0xff
/* -------------------------------------------------------------------- */
-/* Ruler Info (wmManipulatorGroup customdata) */
+/* Ruler Info (wmGizmoGroup customdata) */
enum {
RULER_STATE_NORMAL = 0,
@@ -123,7 +123,7 @@ typedef struct RulerInfo {
/* Ruler Item (two or three points) */
typedef struct RulerItem {
- wmManipulator mpr;
+ wmGizmo gz;
/* worldspace coords, middle being optional */
float co[3][3];
@@ -143,18 +143,18 @@ typedef struct RulerInteraction {
/** \name Internal Ruler Utilities
* \{ */
-static RulerItem *ruler_item_add(wmManipulatorGroup *mgroup)
+static RulerItem *ruler_item_add(wmGizmoGroup *gzgroup)
{
/* could pass this as an arg */
- const wmManipulatorType *wt_ruler = WM_manipulatortype_find("VIEW3D_WT_ruler_item", true);
- RulerItem *ruler_item = (RulerItem *)WM_manipulator_new_ptr(wt_ruler, mgroup, NULL);
- WM_manipulator_set_flag(&ruler_item->mpr, WM_MANIPULATOR_DRAW_MODAL, true);
+ const wmGizmoType *gzt_ruler = WM_gizmotype_find("VIEW3D_GT_ruler_item", true);
+ RulerItem *ruler_item = (RulerItem *)WM_gizmo_new_ptr(gzt_ruler, gzgroup, NULL);
+ WM_gizmo_set_flag(&ruler_item->gz, WM_GIZMO_DRAW_MODAL, true);
return ruler_item;
}
-static void ruler_item_remove(bContext *C, wmManipulatorGroup *mgroup, RulerItem *ruler_item)
+static void ruler_item_remove(bContext *C, wmGizmoGroup *gzgroup, RulerItem *ruler_item)
{
- WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, &ruler_item->mpr, C);
+ WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, &ruler_item->gz, C);
}
static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit,
@@ -192,10 +192,10 @@ static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit,
}
static bool view3d_ruler_pick(
- wmManipulatorGroup *mgroup, RulerItem *ruler_item, const float mval[2],
+ wmGizmoGroup *gzgroup, RulerItem *ruler_item, const float mval[2],
int *r_co_index)
{
- RulerInfo *ruler_info = mgroup->customdata;
+ RulerInfo *ruler_info = gzgroup->customdata;
ARegion *ar = ruler_info->ar;
bool found = false;
@@ -304,7 +304,7 @@ static bool view3d_ruler_item_mousemove(
RulerInfo *ruler_info, RulerItem *ruler_item, const int mval[2],
const bool do_thickness, const bool do_snap)
{
- RulerInteraction *inter = ruler_item->mpr.interaction_data;
+ RulerInteraction *inter = ruler_item->gz.interaction_data;
const float eps_bias = 0.0002f;
float dist_px = MVAL_MAX_PX_DIST * U.pixelsize; /* snap dist */
@@ -380,9 +380,9 @@ static bool view3d_ruler_item_mousemove(
* \{ */
#define RULER_ID "RulerData3D"
-static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup)
+static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup)
{
- // RulerInfo *ruler_info = mgroup->customdata;
+ // RulerInfo *ruler_info = gzgroup->customdata;
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
bGPDlayer *gpl;
@@ -419,7 +419,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup)
gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true);
BKE_gpencil_free_strokes(gpf);
- for (ruler_item = mgroup->manipulators.first; ruler_item; ruler_item = (RulerItem *)ruler_item->mpr.next) {
+ for (ruler_item = gzgroup->gizmos.first; ruler_item; ruler_item = (RulerItem *)ruler_item->gz.next) {
bGPDspoint *pt;
int j;
@@ -457,7 +457,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup)
return changed;
}
-static bool view3d_ruler_from_gpencil(const bContext *C, wmManipulatorGroup *mgroup)
+static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *gzgroup)
{
Scene *scene = CTX_data_scene(C);
bool changed = false;
@@ -476,7 +476,7 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmManipulatorGroup *mgr
int j;
RulerItem *ruler_item = NULL;
if (gps->totpoints == 3) {
- ruler_item = ruler_item_add(mgroup);
+ ruler_item = ruler_item_add(gzgroup);
for (j = 0; j < 3; j++) {
copy_v3_v3(ruler_item->co[j], &pt->x);
pt++;
@@ -485,7 +485,7 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmManipulatorGroup *mgr
changed = true;
}
else if (gps->totpoints == 2) {
- ruler_item = ruler_item_add(mgroup);
+ ruler_item = ruler_item_add(gzgroup);
for (j = 0; j < 3; j += 2) {
copy_v3_v3(ruler_item->co[j], &pt->x);
pt++;
@@ -503,15 +503,15 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmManipulatorGroup *mgr
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Ruler Item Manipulator Type
+/** \name Ruler Item Gizmo Type
* \{ */
-static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
+static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz)
{
Scene *scene = CTX_data_scene(C);
UnitSettings *unit = &scene->unit;
- RulerInfo *ruler_info = mpr->parent_mgroup->customdata;
- RulerItem *ruler_item = (RulerItem *)mpr;
+ RulerInfo *ruler_info = gz->parent_gzgroup->customdata;
+ RulerItem *ruler_item = (RulerItem *)gz;
ARegion *ar = ruler_info->ar;
RegionView3D *rv3d = ar->regiondata;
const float cap_size = 4.0f;
@@ -536,7 +536,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
UI_GetThemeColor3ubv(TH_TEXT, color_text);
UI_GetThemeColor3ubv(TH_WIRE, color_wire);
- const bool is_act = (mpr->flag & WM_MANIPULATOR_DRAW_HOVER);
+ const bool is_act = (gz->flag & WM_GIZMO_DRAW_HOVER);
float dir_ruler[2];
float co_ss[3][2];
int j;
@@ -548,7 +548,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
GPU_blend(true);
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (ruler_item->flag & RULERITEM_USE_ANGLE) {
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -562,7 +562,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2);
immUniform1f("dash_width", 6.0f);
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2fv(shdr_pos, co_ss[0]);
immVertex2fv(shdr_pos, co_ss[1]);
@@ -604,7 +604,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
immUniformColor3ubv(color_wire);
- immBegin(GWN_PRIM_LINE_STRIP, arc_steps + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, arc_steps + 1);
for (j = 0; j <= arc_steps; j++) {
madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale);
@@ -637,7 +637,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
immUniformColor3ubv(color_wire);
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size);
immVertex2fv(shdr_pos, cap);
@@ -702,7 +702,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2);
immUniform1f("dash_width", 6.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(shdr_pos, co_ss[0]);
immVertex2fv(shdr_pos, co_ss[2]);
@@ -726,7 +726,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
immUniformColor3ubv(color_wire);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size);
immVertex2fv(shdr_pos, cap);
@@ -785,15 +785,15 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
/* draw snap */
if ((ruler_info->snap_flag & RULER_SNAP_OK) &&
(ruler_info->state == RULER_STATE_DRAG) &&
- (ruler_item->mpr.interaction_data != NULL))
+ (ruler_item->gz.interaction_data != NULL))
{
- RulerInteraction *inter = ruler_item->mpr.interaction_data;
+ RulerInteraction *inter = ruler_item->gz.interaction_data;
/* size from drawSnapping */
const float size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
float co_ss_snap[3];
ED_view3d_project_float_global(ar, ruler_item->co[inter->co_index], co_ss_snap, V3D_PROJ_TEST_NOP);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color_act);
@@ -804,15 +804,15 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
}
}
-static int manipulator_ruler_test_select(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
+static int gizmo_ruler_test_select(
+ bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
{
- RulerItem *ruler_item_pick = (RulerItem *)mpr;
+ RulerItem *ruler_item_pick = (RulerItem *)gz;
float mval_fl[2] = {UNPACK2(event->mval)};
int co_index;
/* select and drag */
- if (view3d_ruler_pick(mpr->parent_mgroup, ruler_item_pick, mval_fl, &co_index)) {
+ if (view3d_ruler_pick(gz->parent_gzgroup, ruler_item_pick, mval_fl, &co_index)) {
if (co_index == -1) {
if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) {
return PART_LINE;
@@ -825,15 +825,15 @@ static int manipulator_ruler_test_select(
return -1;
}
-static int manipulator_ruler_modal(
- bContext *C, wmManipulator *mpr, const wmEvent *event,
- eWM_ManipulatorTweak UNUSED(tweak_flag))
+static int gizmo_ruler_modal(
+ bContext *C, wmGizmo *gz, const wmEvent *event,
+ eWM_GizmoFlagTweak UNUSED(tweak_flag))
{
bool do_draw = false;
int exit_code = OPERATOR_RUNNING_MODAL;
- RulerInfo *ruler_info = mpr->parent_mgroup->customdata;
- RulerItem *ruler_item = (RulerItem *)mpr;
- RulerInteraction *inter = ruler_item->mpr.interaction_data;
+ RulerInfo *ruler_info = gz->parent_gzgroup->customdata;
+ RulerItem *ruler_item = (RulerItem *)gz;
+ RulerInteraction *inter = ruler_item->gz.interaction_data;
ARegion *ar = CTX_wm_region(C);
ruler_info->ar = ar;
@@ -859,21 +859,21 @@ static int manipulator_ruler_modal(
return exit_code;
}
-static int manipulator_ruler_invoke(
- bContext *C, wmManipulator *mpr, const wmEvent *event)
+static int gizmo_ruler_invoke(
+ bContext *C, wmGizmo *gz, const wmEvent *event)
{
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- RulerInfo *ruler_info = mgroup->customdata;
- RulerItem *ruler_item_pick = (RulerItem *)mpr;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ RulerInfo *ruler_info = gzgroup->customdata;
+ RulerItem *ruler_item_pick = (RulerItem *)gz;
RulerInteraction *inter = MEM_callocN(sizeof(RulerInteraction), __func__);
- mpr->interaction_data = inter;
+ gz->interaction_data = inter;
ARegion *ar = ruler_info->ar;
const float mval_fl[2] = {UNPACK2(event->mval)};
/* select and drag */
- if (mpr->highlight_part == PART_LINE) {
+ if (gz->highlight_part == PART_LINE) {
if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) {
/* Add Center Point */
ruler_item_pick->flag |= RULERITEM_USE_ANGLE;
@@ -903,7 +903,7 @@ static int manipulator_ruler_invoke(
}
}
else {
- inter->co_index = mpr->highlight_part;
+ inter->co_index = gz->highlight_part;
ruler_state_set(C, ruler_info, RULER_STATE_DRAG);
/* store the initial depth */
@@ -913,15 +913,15 @@ static int manipulator_ruler_invoke(
return OPERATOR_RUNNING_MODAL;
}
-static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool cancel)
+static void gizmo_ruler_exit(bContext *C, wmGizmo *gz, const bool cancel)
{
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- RulerInfo *ruler_info = mgroup->customdata;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ RulerInfo *ruler_info = gzgroup->customdata;
if (!cancel) {
if (ruler_info->state == RULER_STATE_DRAG) {
- RulerItem *ruler_item = (RulerItem *)mpr;
- RulerInteraction *inter = mpr->interaction_data;
+ RulerItem *ruler_item = (RulerItem *)gz;
+ RulerInteraction *inter = gz->interaction_data;
/* rubber-band angle removal */
if (!inter->inside_region) {
if ((inter->co_index == 1) && (ruler_item->flag & RULERITEM_USE_ANGLE)) {
@@ -930,9 +930,9 @@ static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool c
else {
/* Not ideal, since the ruler isn't a mode and we don't want to override delete key
* use dragging out of the view for removal. */
- ruler_item_remove(C, mgroup, ruler_item);
+ ruler_item_remove(C, gzgroup, ruler_item);
ruler_item = NULL;
- mpr = NULL;
+ gz = NULL;
inter = NULL;
}
}
@@ -941,64 +941,64 @@ static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool c
}
ruler_state_set(C, ruler_info, RULER_STATE_NORMAL);
}
- /* We could convert only the current manipulator, for now just re-generate. */
- view3d_ruler_to_gpencil(C, mgroup);
+ /* We could convert only the current gizmo, for now just re-generate. */
+ view3d_ruler_to_gpencil(C, gzgroup);
}
- if (mpr) {
- MEM_SAFE_FREE(mpr->interaction_data);
+ if (gz) {
+ MEM_SAFE_FREE(gz->interaction_data);
}
ruler_state_set(C, ruler_info, RULER_STATE_NORMAL);
}
-static int manipulator_ruler_cursor_get(wmManipulator *mpr)
+static int gizmo_ruler_cursor_get(wmGizmo *gz)
{
- if (mpr->highlight_part == PART_LINE) {
+ if (gz->highlight_part == PART_LINE) {
return BC_CROSSCURSOR;
}
return BC_NSEW_SCROLLCURSOR;
}
-void VIEW3D_WT_ruler_item(wmManipulatorType *wt)
+void VIEW3D_GT_ruler_item(wmGizmoType *gzt)
{
/* identifiers */
- wt->idname = "VIEW3D_WT_ruler_item";
+ gzt->idname = "VIEW3D_GT_ruler_item";
/* api callbacks */
- wt->draw = manipulator_ruler_draw;
- wt->test_select = manipulator_ruler_test_select;
- wt->modal = manipulator_ruler_modal;
- wt->invoke = manipulator_ruler_invoke;
- wt->exit = manipulator_ruler_exit;
- wt->cursor_get = manipulator_ruler_cursor_get;
-
- wt->struct_size = sizeof(RulerItem);
+ gzt->draw = gizmo_ruler_draw;
+ gzt->test_select = gizmo_ruler_test_select;
+ gzt->modal = gizmo_ruler_modal;
+ gzt->invoke = gizmo_ruler_invoke;
+ gzt->exit = gizmo_ruler_exit;
+ gzt->cursor_get = gizmo_ruler_cursor_get;
+
+ gzt->struct_size = sizeof(RulerItem);
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Ruler Manipulator Group
+/** \name Ruler Gizmo Group
* \{ */
-static bool WIDGETGROUP_ruler_poll(const bContext *C, wmManipulatorGroupType *wgt)
+static bool WIDGETGROUP_ruler_poll(const bContext *C, wmGizmoGroupType *gzgt)
{
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
if ((tref_rt == NULL) ||
- !STREQ(wgt->idname, tref_rt->manipulator_group))
+ !STREQ(gzgt->idname, tref_rt->gizmo_group))
{
- WM_manipulator_group_type_unlink_delayed_ptr(wgt);
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
return false;
}
return true;
}
-static void WIDGETGROUP_ruler_setup(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
RulerInfo *ruler_info = MEM_callocN(sizeof(RulerInfo), __func__);
- if (view3d_ruler_from_gpencil(C, mgroup)) {
+ if (view3d_ruler_from_gpencil(C, gzgroup)) {
/* nop */
}
@@ -1009,21 +1009,21 @@ static void WIDGETGROUP_ruler_setup(const bContext *C, wmManipulatorGroup *mgrou
ruler_info->sa = sa;
ruler_info->ar = ar;
- mgroup->customdata = ruler_info;
+ gzgroup->customdata = ruler_info;
}
-void VIEW3D_WGT_ruler(wmManipulatorGroupType *wgt)
+void VIEW3D_GGT_ruler(wmGizmoGroupType *gzgt)
{
- wgt->name = "Ruler Widgets";
- wgt->idname = view3d_wgt_ruler_id;
+ gzgt->name = "Ruler Widgets";
+ gzgt->idname = view3d_gzgt_ruler_id;
- wgt->flag |= WM_MANIPULATORGROUPTYPE_SCALE | WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL;
+ gzgt->flag |= WM_GIZMOGROUPTYPE_SCALE | WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL;
- wgt->mmap_params.spaceid = SPACE_VIEW3D;
- wgt->mmap_params.regionid = RGN_TYPE_WINDOW;
+ gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
+ gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
- wgt->poll = WIDGETGROUP_ruler_poll;
- wgt->setup = WIDGETGROUP_ruler_setup;
+ gzgt->poll = WIDGETGROUP_ruler_poll;
+ gzgt->setup = WIDGETGROUP_ruler_setup;
}
/** \} */
@@ -1036,7 +1036,7 @@ static bool view3d_ruler_poll(bContext *C)
{
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
if ((tref_rt == NULL) ||
- !STREQ(view3d_wgt_ruler_id, tref_rt->manipulator_group) ||
+ !STREQ(view3d_gzgt_ruler_id, tref_rt->gizmo_group) ||
CTX_wm_region_view3d(C) == NULL)
{
return false;
@@ -1050,22 +1050,22 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wm
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ar->regiondata;
- wmManipulatorMap *mmap = ar->manipulator_map;
- wmManipulatorGroup *mgroup = WM_manipulatormap_group_find(mmap, view3d_wgt_ruler_id);
- const bool use_depth = (v3d->drawtype >= OB_SOLID);
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
+ const bool use_depth = (v3d->shading.type >= OB_SOLID);
/* Create new line */
RulerItem *ruler_item;
- ruler_item = ruler_item_add(mgroup);
+ ruler_item = ruler_item_add(gzgroup);
/* This is a little weak, but there is no real good way to tweak directly. */
- WM_manipulator_highlight_set(mmap, &ruler_item->mpr);
+ WM_gizmo_highlight_set(gzmap, &ruler_item->gz);
if (WM_operator_name_call(
- C, "MANIPULATORGROUP_OT_manipulator_tweak",
+ C, "GIZMOGROUP_OT_gizmo_tweak",
WM_OP_INVOKE_REGION_WIN, NULL) == OPERATOR_RUNNING_MODAL)
{
- RulerInfo *ruler_info = mgroup->customdata;
- RulerInteraction *inter = ruler_item->mpr.interaction_data;
+ RulerInfo *ruler_info = gzgroup->customdata;
+ RulerInteraction *inter = ruler_item->gz.interaction_data;
if (use_depth) {
/* snap the first point added, not essential but handy */
inter->co_index = 0;
@@ -1079,7 +1079,7 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wm
}
copy_v3_v3(ruler_item->co[2], ruler_item->co[0]);
- ruler_item->mpr.highlight_part = inter->co_index = 2;
+ ruler_item->gz.highlight_part = inter->co_index = 2;
}
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index eeddacee808..c9277235d50 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -221,46 +221,10 @@ void VIEW3D_OT_layers(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer");
}
-/* -------------------------------------------------------------------- */
-/** \name Toggle Bone selection Overlay Operator
- * \{ */
-
-static int toggle_show_xray(bContext *C, wmOperator *UNUSED(op))
-{
- View3D *v3d = CTX_wm_view3d(C);
- v3d->shading.flag ^= V3D_SHADING_XRAY;
- ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C));
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
- return OPERATOR_FINISHED;
-}
-
-static bool toggle_show_xray_poll(bContext *C)
-{
- bool result = (ED_operator_view3d_active(C) && !ED_operator_posemode(C) && !ED_operator_editmesh(C));
- if (result) {
- // Additional test for SOLID or TEXTURE mode
- View3D *v3d = CTX_wm_view3d(C);
- result = (v3d->drawtype & (OB_SOLID | OB_TEXTURE)) > 0;
- }
- return result;
-}
-
-void VIEW3D_OT_toggle_xray_draw_option(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Toggle Show X-Ray";
- ot->description = "Toggle show X-Ray";
- ot->idname = "VIEW3D_OT_toggle_xray_draw_option";
-
- /* api callbacks */
- ot->exec = toggle_show_xray;
- ot->poll = toggle_show_xray_poll;
-}
-
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Toggle Bone selection Overlay Operator
+/** \name Toggle Matcap Flip Operator
* \{ */
static int toggle_matcap_flip(bContext *C, wmOperator *UNUSED(op))
@@ -281,7 +245,6 @@ void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot)
/* api callbacks */
ot->exec = toggle_matcap_flip;
- // ot->poll = toggle_show_xray_poll;
}
/** \} */
@@ -345,7 +308,7 @@ static void uiTemplatePaintModeSelection(uiLayout *layout, struct bContext *C)
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
- /* Manipulators aren't used in paint modes */
+ /* Gizmos aren't used in paint modes */
if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) {
/* masks aren't used for sculpt and particle painting */
PointerRNA meshptr;
@@ -428,9 +391,9 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
else {
/* Moved to popover and topbar. */
#if 0
- /* Transform widget / manipulators */
+ /* Transform widget / gizmos */
row = uiLayoutRow(layout, true);
- uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
+ uiItemR(row, &v3dptr, "show_gizmo", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
uiItemR(row, &sceneptr, "transform_orientation", 0, "", ICON_NONE);
#endif
}
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 8263d1d892c..855ee7bb9fc 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -39,7 +39,7 @@ struct ARegion;
struct ARegionType;
struct Base;
struct BoundBox;
-struct Gwn_Batch;
+struct GPUBatch;
struct Depsgraph;
struct Object;
struct SmokeDomainSettings;
@@ -51,8 +51,8 @@ struct Mesh;
struct ViewLayer;
struct wmOperatorType;
struct wmKeyConfig;
-struct wmManipulatorGroupType;
-struct wmManipulatorType;
+struct wmGizmoGroupType;
+struct wmGizmoType;
struct wmWindowManager;
/* drawing flags: */
@@ -64,7 +64,6 @@ enum {
/* view3d_header.c */
void VIEW3D_OT_layers(struct wmOperatorType *ot);
-void VIEW3D_OT_toggle_xray_draw_option(struct wmOperatorType *ot);
void VIEW3D_OT_toggle_matcap_flip(struct wmOperatorType *ot);
/* view3d_ops.c */
@@ -83,7 +82,8 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot);
void VIEW3D_OT_ndof_all(struct wmOperatorType *ot);
#endif /* WITH_INPUT_NDOF */
void VIEW3D_OT_view_all(struct wmOperatorType *ot);
-void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot);
+void VIEW3D_OT_view_axis(struct wmOperatorType *ot);
+void VIEW3D_OT_view_camera(struct wmOperatorType *ot);
void VIEW3D_OT_view_selected(struct wmOperatorType *ot);
void VIEW3D_OT_view_lock_clear(struct wmOperatorType *ot);
void VIEW3D_OT_view_lock_to_active(struct wmOperatorType *ot);
@@ -103,7 +103,7 @@ void VIEW3D_OT_cursor3d(struct wmOperatorType *ot);
void VIEW3D_OT_render_border(struct wmOperatorType *ot);
void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot);
void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
-void VIEW3D_OT_toggle_render(struct wmOperatorType *ot);
+void VIEW3D_OT_toggle_shading(struct wmOperatorType *ot);
void view3d_boxview_copy(ScrArea *sa, ARegion *ar);
void view3d_boxview_sync(ScrArea *sa, ARegion *ar);
@@ -216,6 +216,7 @@ void viewdolly_modal_keymap(struct wmKeyConfig *keyconf);
/* view3d_buttons.c */
void VIEW3D_OT_properties(struct wmOperatorType *ot);
+void VIEW3D_OT_object_mode_pie_or_toggle(struct wmOperatorType *ot);
void view3d_buttons_register(struct ARegionType *art);
/* view3d_camera_control.c */
@@ -253,21 +254,21 @@ ARegion *view3d_has_tools_region(ScrArea *sa);
extern const char *view3d_context_dir[]; /* doc access */
/* view3d_widgets.c */
-void VIEW3D_WGT_lamp_spot(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_lamp_area(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_lamp_target(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_camera(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_camera_view(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_force_field(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_empty_image(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_armature_spline(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_navigate(struct wmManipulatorGroupType *wgt);
-
-void VIEW3D_WGT_ruler(struct wmManipulatorGroupType *wgt);
-void VIEW3D_WT_ruler_item(struct wmManipulatorType *wt);
+void VIEW3D_GGT_lamp_spot(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_lamp_area(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_lamp_target(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_camera(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_camera_view(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_force_field(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_empty_image(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_armature_spline(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GGT_navigate(struct wmGizmoGroupType *gzgt);
+
+void VIEW3D_GGT_ruler(struct wmGizmoGroupType *gzgt);
+void VIEW3D_GT_ruler_item(struct wmGizmoType *gzt);
void VIEW3D_OT_ruler_add(struct wmOperatorType *ot);
-void VIEW3D_WT_navigate_rotate(struct wmManipulatorType *wt);
+void VIEW3D_GT_navigate_rotate(struct wmGizmoType *gzt);
/* draw_volume.c */
void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob,
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
deleted file mode 100644
index f98a2f336bc..00000000000
--- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
+++ /dev/null
@@ -1,305 +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/editors/space_view3d/view3d_manipulator_lamp.c
- * \ingroup spview3d
- */
-
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_context.h"
-#include "BKE_object.h"
-
-#include "DNA_object_types.h"
-#include "DNA_lamp_types.h"
-
-#include "ED_screen.h"
-#include "ED_manipulator_library.h"
-
-#include "UI_resources.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "RNA_access.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "view3d_intern.h" /* own include */
-
-/* -------------------------------------------------------------------- */
-
-/** \name Spot Lamp Manipulators
- * \{ */
-
-static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
-{
- View3D *v3d = CTX_wm_view3d(C);
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
- return false;
- }
-
- Object *ob = CTX_data_active_object(C);
-
- if (ob && ob->type == OB_LAMP) {
- Lamp *la = ob->data;
- return (la->type == LA_SPOT);
- }
- return false;
-}
-
-static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
-{
- wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
-
- wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL);
- wmManipulator *mpr = wwrapper->manipulator;
- RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED);
-
- mgroup->customdata = wwrapper;
-
- ED_manipulator_arrow3d_set_range_fac(mpr, 4.0f);
-
- UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, mpr->color);
-}
-
-static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup *mgroup)
-{
- wmManipulatorWrapper *wwrapper = mgroup->customdata;
- wmManipulator *mpr = wwrapper->manipulator;
- Object *ob = CTX_data_active_object(C);
- Lamp *la = ob->data;
- float dir[3];
-
- negate_v3_v3(dir, ob->obmat[2]);
-
- WM_manipulator_set_matrix_rotation_from_z_axis(mpr, dir);
- WM_manipulator_set_matrix_location(mpr, ob->obmat[3]);
-
- /* need to set property here for undo. TODO would prefer to do this in _init */
- PointerRNA lamp_ptr;
- const char *propname = "spot_size";
- RNA_pointer_create(&la->id, &RNA_Lamp, la, &lamp_ptr);
- WM_manipulator_target_property_def_rna(mpr, "offset", &lamp_ptr, propname, -1);
-}
-
-void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt)
-{
- wgt->name = "Spot Lamp Widgets";
- wgt->idname = "VIEW3D_WGT_lamp_spot";
-
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D |
- WM_MANIPULATORGROUPTYPE_DEPTH_3D);
-
- wgt->poll = WIDGETGROUP_lamp_spot_poll;
- wgt->setup = WIDGETGROUP_lamp_spot_setup;
- wgt->refresh = WIDGETGROUP_lamp_spot_refresh;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-
-/** \name Area Lamp Manipulators
- * \{ */
-
-/* scale callbacks */
-static void manipulator_area_lamp_prop_matrix_get(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
- void *value_p)
-{
- BLI_assert(mpr_prop->type->array_length == 16);
- float (*matrix)[4] = value_p;
- const Lamp *la = mpr_prop->custom_func.user_data;
-
- matrix[0][0] = la->area_size;
- matrix[1][1] = ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE) ? la->area_sizey : la->area_size;
-}
-
-static void manipulator_area_lamp_prop_matrix_set(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
- const void *value_p)
-{
- const float (*matrix)[4] = value_p;
- BLI_assert(mpr_prop->type->array_length == 16);
- Lamp *la = mpr_prop->custom_func.user_data;
-
- if (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE)) {
- la->area_size = len_v3(matrix[0]);
- la->area_sizey = len_v3(matrix[1]);
- }
- else {
- la->area_size = len_v3(matrix[0]);
- }
-}
-
-static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
-{
- View3D *v3d = CTX_wm_view3d(C);
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
- return false;
- }
-
- Object *ob = CTX_data_active_object(C);
- if (ob && ob->type == OB_LAMP) {
- Lamp *la = ob->data;
- return (la->type == LA_AREA);
- }
- return false;
-}
-
-static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
-{
- wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
- wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
- wmManipulator *mpr = wwrapper->manipulator;
- RNA_enum_set(mpr->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
-
- mgroup->customdata = wwrapper;
-
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true);
-
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
-}
-
-static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup *mgroup)
-{
- wmManipulatorWrapper *wwrapper = mgroup->customdata;
- Object *ob = CTX_data_active_object(C);
- Lamp *la = ob->data;
- wmManipulator *mpr = wwrapper->manipulator;
-
- copy_m4_m4(mpr->matrix_basis, ob->obmat);
-
- int flag = ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE;
- if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) {
- flag |= ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM;
- }
- RNA_enum_set(mpr->ptr, "transform", flag);
-
- /* need to set property here for undo. TODO would prefer to do this in _init */
- WM_manipulator_target_property_def_func(
- mpr, "matrix",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_area_lamp_prop_matrix_get,
- .value_set_fn = manipulator_area_lamp_prop_matrix_set,
- .range_get_fn = NULL,
- .user_data = la,
- });
-}
-
-void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt)
-{
- wgt->name = "Area Lamp Widgets";
- wgt->idname = "VIEW3D_WGT_lamp_area";
-
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D |
- WM_MANIPULATORGROUPTYPE_DEPTH_3D);
-
- wgt->poll = WIDGETGROUP_lamp_area_poll;
- wgt->setup = WIDGETGROUP_lamp_area_setup;
- wgt->refresh = WIDGETGROUP_lamp_area_refresh;
-}
-
-/** \} */
-
-
-/* -------------------------------------------------------------------- */
-
-/** \name Lamp Target Manipulator
- * \{ */
-
-static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
-{
- View3D *v3d = CTX_wm_view3d(C);
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
- return false;
- }
-
- Object *ob = CTX_data_active_object(C);
-
- if (ob != NULL) {
- if (ob->type == OB_LAMP) {
- Lamp *la = ob->data;
- return (ELEM(la->type, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA));
- }
-#if 0
- else if (ob->type == OB_CAMERA) {
- return true;
- }
-#endif
- }
- return false;
-}
-
-static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
-{
- wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
- wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL);
- wmManipulator *mpr = wwrapper->manipulator;
-
- mgroup->customdata = wwrapper;
-
- UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
- UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
-
- mpr->scale_basis = 0.06f;
-
- wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_transform_axis_target", true);
-
- RNA_enum_set(mpr->ptr, "draw_options",
- ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW);
-
- WM_manipulator_operator_set(mpr, 0, ot, NULL);
-}
-
-static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
-{
- wmManipulatorWrapper *wwrapper = mgroup->customdata;
- Object *ob = CTX_data_active_object(C);
- wmManipulator *mpr = wwrapper->manipulator;
-
- copy_m4_m4(mpr->matrix_basis, ob->obmat);
- unit_m4(mpr->matrix_offset);
- mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis;
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true);
-}
-
-void VIEW3D_WGT_lamp_target(wmManipulatorGroupType *wgt)
-{
- wgt->name = "Target Lamp Widgets";
- wgt->idname = "VIEW3D_WGT_lamp_target";
-
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D);
-
- wgt->poll = WIDGETGROUP_lamp_target_poll;
- wgt->setup = WIDGETGROUP_lamp_target_setup;
- wgt->draw_prepare = WIDGETGROUP_lamp_target_draw_prepare;
-}
-
-/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
deleted file mode 100644
index 996da2a1475..00000000000
--- a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
+++ /dev/null
@@ -1,310 +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 view3d_manipulator_navigate_type.c
- * \ingroup wm
- *
- * \name Custom Orientation/Navigation Manipulator for the 3D View
- *
- * \brief Simple manipulator to axis and translate.
- *
- * - scale_basis: used for the size.
- * - matrix_basis: used for the location.
- * - matrix_offset: used to store the orientation.
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_sort_utils.h"
-
-#include "BKE_context.h"
-
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
-#include "GPU_immediate.h"
-#include "GPU_immediate_util.h"
-#include "GPU_matrix.h"
-#include "GPU_state.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "UI_interface.h"
-#include "UI_resources.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_screen.h"
-
-#include "view3d_intern.h"
-
-#define DIAL_RESOLUTION 32
-
-#define HANDLE_SIZE 0.33
-
-static void axis_geom_draw(
- const wmManipulator *mpr, const float color[4], const bool UNUSED(select))
-{
- GPU_line_width(mpr->line_width);
-
- Gwn_VertFormat *format = immVertexFormat();
- const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- /* flip z for reverse */
- const float cone_coords[5][3] = {
- {-1, -1, 4},
- {-1, +1, 4},
- {+1, +1, 4},
- {+1, -1, 4},
- {0, 0, 2},
- };
-
- struct {
- float depth;
- char index;
- char axis;
- char is_pos;
- } axis_order[6] = {
- {-mpr->matrix_offset[0][2], 0, 0, false},
- {+mpr->matrix_offset[0][2], 1, 0, true},
- {-mpr->matrix_offset[1][2], 2, 1, false},
- {+mpr->matrix_offset[1][2], 3, 1, true},
- {-mpr->matrix_offset[2][2], 4, 2, false},
- {+mpr->matrix_offset[2][2], 5, 2, true},
- };
- qsort(&axis_order, ARRAY_SIZE(axis_order), sizeof(axis_order[0]), BLI_sortutil_cmp_float);
-
- const float scale_axis = 0.25f;
- static const float axis_highlight[4] = {1, 1, 1, 1};
- static const float axis_nop[4] = {1, 1, 1, 0};
- static const float axis_black[4] = {0, 0, 0, 1};
- static float axis_color[3][4];
- gpuPushMatrix();
- gpuMultMatrix(mpr->matrix_offset);
-
- bool draw_center_done = false;
-
- for (int axis_index = 0; axis_index < ARRAY_SIZE(axis_order); axis_index++) {
- const int index = axis_order[axis_index].index;
- const int axis = axis_order[axis_index].axis;
- const bool is_pos = axis_order[axis_index].is_pos;
-
- /* Draw slightly before, so axis aligned arrows draw ontop. */
- if ((draw_center_done == false) && (axis_order[axis_index].depth > -0.01f)) {
-
- /* Circle defining active area (revert back to 2D space). */
- {
- gpuPopMatrix();
- immUniformColor4fv(color);
- imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION);
- gpuPushMatrix();
- gpuMultMatrix(mpr->matrix_offset);
- }
-
- /* Center cube. */
- {
- float center[3], size[3];
-
- zero_v3(center);
- copy_v3_fl(size, HANDLE_SIZE);
-
- GPU_depth_test(true);
- glDepthMask(GL_TRUE);
- glDepthFunc(GL_LEQUAL);
- GPU_blend_set_func(GPU_ONE, GPU_ZERO);
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-
- GPU_line_smooth(true);
- GPU_blend(true);
- GPU_line_width(1.0f);
- /* Just draw depth values. */
- immUniformColor4fv(axis_nop);
- imm_draw_cube_fill_3d(pos_id, center, size);
- immUniformColor4fv(axis_black);
- madd_v3_v3fl(
- center,
- (float[3]){
- mpr->matrix_offset[0][2],
- mpr->matrix_offset[1][2],
- mpr->matrix_offset[2][2],
- },
- 0.08f);
- imm_draw_cube_wire_3d(pos_id, center, size);
- GPU_blend(false);
- GPU_line_smooth(false);
- GPU_depth_test(false);
- }
-
- draw_center_done = true;
- }
- UI_GetThemeColor3fv(TH_AXIS_X + axis, axis_color[axis]);
- axis_color[axis][3] = 1.0f;
-
- const int index_z = axis;
- const int index_y = (axis + 1) % 3;
- const int index_x = (axis + 2) % 3;
-
-#define ROTATED_VERT(v_orig) \
- { \
- float v[3]; \
- copy_v3_v3(v, v_orig); \
- if (is_pos == 0) { \
- v[2] *= -1.0f; \
- } \
- immVertex3f(pos_id, v[index_x] * scale_axis, v[index_y] * scale_axis, v[index_z] * scale_axis); \
- } ((void)0)
-
- bool ok = true;
-
- /* skip view align axis */
- if (len_squared_v2(mpr->matrix_offset[axis]) < 1e-6f && (mpr->matrix_offset[axis][2] > 0.0f) == is_pos) {
- ok = false;
- }
- if (ok) {
- immUniformColor4fv(index + 1 == mpr->highlight_part ? axis_highlight : axis_color[axis]);
- immBegin(GWN_PRIM_TRI_FAN, 6);
- ROTATED_VERT(cone_coords[4]);
- for (int j = 0; j <= 4; j++) {
- ROTATED_VERT(cone_coords[j % 4]);
- }
- immEnd();
- }
-
-#undef ROTATED_VERT
- }
-
- gpuPopMatrix();
- immUnbindProgram();
-}
-
-static void axis3d_draw_intern(
- const bContext *UNUSED(C), wmManipulator *mpr,
- const bool select, const bool highlight)
-{
- const float *color = highlight ? mpr->color_hi : mpr->color;
- float matrix_final[4][4];
- float matrix_unit[4][4];
-
- unit_m4(matrix_unit);
-
- WM_manipulator_calc_matrix_final_params(
- mpr,
- &((struct WM_ManipulatorMatrixParams) {
- .matrix_offset = matrix_unit,
- }), matrix_final);
-
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
-
- GPU_blend(true);
- axis_geom_draw(mpr, color, select);
- GPU_blend(false);
- gpuPopMatrix();
-}
-
-static void manipulator_axis_draw(const bContext *C, wmManipulator *mpr)
-{
- const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL;
- const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
-
- (void)is_modal;
-
- GPU_blend(true);
- axis3d_draw_intern(C, mpr, false, is_highlight);
- GPU_blend(false);
-}
-
-static int manipulator_axis_test_select(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
-{
- float point_local[2] = {UNPACK2(event->mval)};
- sub_v2_v2(point_local, mpr->matrix_basis[3]);
- mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC));
-
- const float len_sq = len_squared_v2(point_local);
- if (len_sq > 1.0) {
- return -1;
- }
-
- int part_best = -1;
- int part_index = 1;
- /* Use 'SQUARE(HANDLE_SIZE)' if we want to be able to _not_ focus on one of the axis. */
- float i_best_len_sq = FLT_MAX;
- for (int i = 0; i < 3; i++) {
- for (int is_pos = 0; is_pos < 2; is_pos++) {
- float co[2] = {
- mpr->matrix_offset[i][0] * (is_pos ? 1 : -1),
- mpr->matrix_offset[i][1] * (is_pos ? 1 : -1),
- };
-
- bool ok = true;
-
- /* Check if we're viewing on an axis, there is no point to clicking on the current axis so show the reverse. */
- if (len_squared_v2(co) < 1e-6f && (mpr->matrix_offset[i][2] > 0.0f) == is_pos) {
- ok = false;
- }
-
- if (ok) {
- const float len_axis_sq = len_squared_v2v2(co, point_local);
- if (len_axis_sq < i_best_len_sq) {
- part_best = part_index;
- i_best_len_sq = len_axis_sq;
- }
- }
- part_index += 1;
- }
- }
-
- if (part_best != -1) {
- return part_best;
- }
-
- /* The 'mpr->scale_final' is already applied when projecting. */
- if (len_sq < 1.0f) {
- return 0;
- }
-
- return -1;
-}
-
-static int manipulator_axis_cursor_get(wmManipulator *mpr)
-{
- if (mpr->highlight_part > 0) {
- return CURSOR_EDIT;
- }
- return BC_NSEW_SCROLLCURSOR;
-}
-
-void VIEW3D_WT_navigate_rotate(wmManipulatorType *wt)
-{
- /* identifiers */
- wt->idname = "VIEW3D_WT_navigate_rotate";
-
- /* api callbacks */
- wt->draw = manipulator_axis_draw;
- wt->test_select = manipulator_axis_test_select;
- wt->cursor_get = manipulator_axis_cursor_get;
-
- wt->struct_size = sizeof(wmManipulator);
-}
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index b16327d2a4a..cf9b8afe8e5 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -174,7 +174,8 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_ndof_all);
#endif /* WITH_INPUT_NDOF */
WM_operatortype_append(VIEW3D_OT_view_all);
- WM_operatortype_append(VIEW3D_OT_viewnumpad);
+ WM_operatortype_append(VIEW3D_OT_view_axis);
+ WM_operatortype_append(VIEW3D_OT_view_camera);
WM_operatortype_append(VIEW3D_OT_view_orbit);
WM_operatortype_append(VIEW3D_OT_view_roll);
WM_operatortype_append(VIEW3D_OT_view_pan);
@@ -211,6 +212,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_pastebuffer);
WM_operatortype_append(VIEW3D_OT_properties);
+ WM_operatortype_append(VIEW3D_OT_object_mode_pie_or_toggle);
WM_operatortype_append(VIEW3D_OT_toolshelf);
WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid);
@@ -221,8 +223,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected);
WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active);
- WM_operatortype_append(VIEW3D_OT_toggle_render);
- WM_operatortype_append(VIEW3D_OT_toggle_xray_draw_option);
+ WM_operatortype_append(VIEW3D_OT_toggle_shading);
WM_operatortype_append(VIEW3D_OT_toggle_matcap_flip);
WM_operatortype_append(VIEW3D_OT_ruler_add);
@@ -310,22 +311,23 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "center", true);
#endif
- WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_view_pie", ACCENTGRAVEKEY, KM_CLICK_DRAG, 0, 0);
+ WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_view_pie", ACCENTGRAVEKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "VIEW3D_OT_navigate", ACCENTGRAVEKEY, KM_PRESS, KM_SHIFT, 0);
/* numpad view hotkeys*/
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_CAMERA);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
+ WM_keymap_add_item(keymap, "VIEW3D_OT_view_camera", PAD0, KM_PRESS, 0, 0);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD2, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPDOWN);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD4, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
WM_keymap_add_item(keymap, "VIEW3D_OT_view_persportho", PAD5, KM_PRESS, 0, 0);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD6, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD8, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPUP);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BACK);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_LEFT);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BACK);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_LEFT);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD2, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANDOWN);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD4, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT);
@@ -352,25 +354,38 @@ void view3d_keymap(wmKeyConfig *keyconf)
#endif
/* active aligned, replaces '*' key in 2.4x */
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD1, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT);
RNA_boolean_set(kmi->ptr, "align_active", true);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD3, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT);
RNA_boolean_set(kmi->ptr, "align_active", true);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD7, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
RNA_boolean_set(kmi->ptr, "align_active", true);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD1, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BACK);
RNA_boolean_set(kmi->ptr, "align_active", true);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD3, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT);
RNA_boolean_set(kmi->ptr, "align_active", true);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD7, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM);
RNA_boolean_set(kmi->ptr, "align_active", true);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", EVT_TWEAK_M, EVT_GESTURE_N, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
+ RNA_boolean_set(kmi->ptr, "relative", true);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", EVT_TWEAK_M, EVT_GESTURE_S, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM);
+ RNA_boolean_set(kmi->ptr, "relative", true);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", EVT_TWEAK_M, EVT_GESTURE_E, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT);
+ RNA_boolean_set(kmi->ptr, "relative", true);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", EVT_TWEAK_M, EVT_GESTURE_W, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT);
+ RNA_boolean_set(kmi->ptr, "relative", true);
+
#ifdef WITH_INPUT_NDOF
/* note: positioned here so keymaps show keyboard keys if assigned */
/* 3D mouse */
@@ -383,36 +398,32 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", NDOF_BUTTON_ROLL_CCW, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", NDOF_BUTTON_ROLL_CCW, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_LEFT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_LEFT);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
- RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BOTTOM, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_LEFT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_LEFT);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_RIGHT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_TOP, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_BOTTOM, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
/* 3D mouse align */
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, KM_SHIFT, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_FRONT, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT);
RNA_boolean_set(kmi->ptr, "align_active", true);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, KM_SHIFT, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_RIGHT, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT);
RNA_boolean_set(kmi->ptr, "align_active", true);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, KM_SHIFT, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_TOP, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
RNA_boolean_set(kmi->ptr, "align_active", true);
#endif /* WITH_INPUT_NDOF */
/* drawtype */
- kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0);
- RNA_string_set(kmi->ptr, "data_path", "space_data.shading.type");
- RNA_string_set(kmi->ptr, "value_1", "SOLID");
- RNA_string_set(kmi->ptr, "value_2", "TEXTURED");
-
- WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_render", ZKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_xray_draw_option", ZKEY, KM_PRESS, 0, 0);
-
- kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ZKEY, KM_PRESS, 0, 0);
- RNA_string_set(kmi->ptr, "data_path", "space_data.use_occlude_geometry");
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "type", OB_SOLID);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "type", OB_MATERIAL);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "type", OB_RENDER);
/* selection*/
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
@@ -484,10 +495,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
- RNA_boolean_set(kmi->ptr, "camera_only", true);
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_CTRL, 0);
- RNA_boolean_set(kmi->ptr, "camera_only", false);
WM_keymap_add_item(keymap, "VIEW3D_OT_clear_render_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
@@ -528,8 +536,12 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_string_set(kmi->ptr, "data_path", "tool_settings.transform_pivot_point");
RNA_string_set(kmi->ptr, "value", "ACTIVE_ELEMENT");
+#ifdef USE_WM_KEYMAP_27X
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* new in 2.5 */
- RNA_string_set(kmi->ptr, "data_path", "space_data.show_manipulator");
+#else
+ kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
+#endif
+ RNA_string_set(kmi->ptr, "data_path", "space_data.show_gizmo_tool");
transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D);
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index 30b91c1a8ee..91e255aec82 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -677,7 +677,7 @@ void ED_view3d_project(const struct ARegion *ar, const float world[3], float reg
RegionView3D *rv3d = ar->regiondata;
int viewport[4] = {0, 0, ar->winx, ar->winy};
- gpuProject(world, rv3d->viewmat, rv3d->winmat, viewport, region);
+ GPU_matrix_project(world, rv3d->viewmat, rv3d->winmat, viewport, region);
}
bool ED_view3d_unproject(const struct ARegion *ar, float regionx, float regiony, float regionz, float world[3])
@@ -686,5 +686,5 @@ bool ED_view3d_unproject(const struct ARegion *ar, float regionx, float regiony,
int viewport[4] = {0, 0, ar->winx, ar->winy};
float region[3] = {regionx, regiony, regionz};
- return gpuUnProject(region, rv3d->viewmat, rv3d->winmat, viewport, world);
+ return GPU_matrix_unproject(region, rv3d->viewmat, rv3d->winmat, viewport, world);
}
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index 5911c8224be..690fc5e3bdb 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -461,7 +461,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
GPU_blend(true);
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (ruler_item->flag & RULERITEM_USE_ANGLE) {
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -475,7 +475,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2);
immUniform1f("dash_width", 6.0f);
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2fv(shdr_pos, co_ss[0]);
immVertex2fv(shdr_pos, co_ss[1]);
@@ -517,7 +517,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
immUniformColor3ubv(color_wire);
- immBegin(GWN_PRIM_LINE_STRIP, arc_steps + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, arc_steps + 1);
for (j = 0; j <= arc_steps; j++) {
madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale);
@@ -550,7 +550,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
immUniformColor3ubv(color_wire);
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size);
immVertex2fv(shdr_pos, cap);
@@ -614,7 +614,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2);
immUniform1f("dash_width", 6.0f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(shdr_pos, co_ss[0]);
immVertex2fv(shdr_pos, co_ss[2]);
@@ -638,7 +638,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
immUniformColor3ubv(color_wire);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size);
immVertex2fv(shdr_pos, cap);
@@ -703,7 +703,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
float co_ss[3];
ED_view3d_project_float_global(ar, ruler_item->co[ruler_item->co_index], co_ss, V3D_PROJ_TEST_NOP);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color_act);
@@ -911,7 +911,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
BLI_listbase_is_empty(&ruler_info->items))
{
View3D *v3d = CTX_wm_view3d(C);
- const bool use_depth = (v3d->drawtype >= OB_SOLID);
+ const bool use_depth = (v3d->shading.type >= OB_SOLID);
/* Create new line */
RulerItem *ruler_item_prev = ruler_item_active_get(ruler_info);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index b7dbb09e1a4..7da69c5b2d5 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -510,7 +510,7 @@ static void do_lasso_select_mesh(
/* for non zbuf projections, don't change the GL state */
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- gpuLoadMatrix(vc->rv3d->viewmat);
+ GPU_matrix_set(vc->rv3d->viewmat);
bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) {
@@ -1062,6 +1062,8 @@ static Base *object_mouse_select_menu(
short baseCount = 0;
bool ok;
LinkNode *linklist = NULL;
+ const int object_type_exclude_select = (
+ vc->v3d->object_type_exclude_viewport | vc->v3d->object_type_exclude_select);
/* handle base->object->select_color */
CTX_DATA_BEGIN (C, Base *, base, selectable_bases)
@@ -1079,6 +1081,9 @@ static Base *object_mouse_select_menu(
}
}
else {
+ if (object_type_exclude_select & (1 << base->object->type)) {
+ continue;
+ }
const int dist = 15 * U.pixelsize;
if (ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) {
const int delta_px[2] = {base->sx - mval[0], base->sy - mval[1]};
@@ -1184,7 +1189,7 @@ static int mixed_bones_object_selectbuffer(
/* define if we use solid nearest select or not */
if (use_cycle) {
- if (v3d->drawtype > OB_WIRE) {
+ if (v3d->shading.type > OB_WIRE) {
do_nearest = true;
if (len_manhattan_v2v2_int(mval, last_mval) < 3) {
do_nearest = false;
@@ -1193,7 +1198,7 @@ static int mixed_bones_object_selectbuffer(
copy_v2_v2_int(last_mval, mval);
}
else {
- if (v3d->drawtype > OB_WIRE) {
+ if (v3d->shading.type > OB_WIRE) {
do_nearest = true;
}
}
@@ -1447,9 +1452,13 @@ static bool ed_object_select_pick(
basact = object_mouse_select_menu(C, &vc, NULL, 0, mval, toggle);
}
else {
+ const int object_type_exclude_select = (
+ vc.v3d->object_type_exclude_viewport | vc.v3d->object_type_exclude_select);
base = startbase;
while (base) {
- if (BASE_SELECTABLE(base)) {
+ if (BASE_SELECTABLE(base) &&
+ ((object_type_exclude_select & (1 << base->object->type)) == 0))
+ {
float screen_co[2];
if (ED_view3d_project_float_global(
ar, base->object->obmat[3], screen_co,
@@ -1927,7 +1936,7 @@ static int do_mesh_box_select(
/* for non zbuf projections, don't change the GL state */
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- gpuLoadMatrix(vc->rv3d->viewmat);
+ GPU_matrix_set(vc->rv3d->viewmat);
bbsel = EDBM_backbuf_border_init(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) {
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 606c07cd1fa..7799854db49 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -92,15 +92,6 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
obedit = objects[ob_index];
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
-
- if ((em->bm->totvertsel == 0) &&
- (em->bm->totedgesel == 0) &&
- (em->bm->totfacesel == 0))
- {
- continue;
- }
-
if (ED_transverts_check_obedit(obedit)) {
ED_transverts_create_from_obedit(&tvs, obedit, 0);
}
@@ -811,7 +802,7 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Snap Cursor to Center";
- ot->description = "Snap cursor to the Center";
+ ot->description = "Snap cursor to world origin";
ot->idname = "VIEW3D_OT_snap_cursor_to_center";
/* api callbacks */
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index ca5375b6b54..9b006bf4d9b 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -189,8 +189,8 @@ void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *ar)
RegionView3D *rv3d = ar->regiondata;
wmViewport(&ar->winrct); // TODO: bad
- gpuLoadProjectionMatrix(rv3d->winmat);
- gpuLoadMatrix(rv3d->viewmat);
+ GPU_matrix_projection_set(rv3d->winmat);
+ GPU_matrix_set(rv3d->viewmat);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index aad2ac7284f..8a4a0efad2a 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -184,7 +184,7 @@ void ED_view3d_smooth_view_ex(
}
/* skip smooth viewing for render engine draw */
- if (smooth_viewtx && v3d->drawtype != OB_RENDER) {
+ if (smooth_viewtx && v3d->shading.type != OB_RENDER) {
bool changed = false; /* zero means no difference */
if (sview->camera_old != sview->camera)
@@ -721,14 +721,14 @@ void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *ar, const View3D *v3d,
}
if (is_ortho) {
- gpuOrtho(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
+ GPU_matrix_ortho_set(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
}
else {
- gpuFrustum(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
+ GPU_matrix_frustum_set(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
}
/* update matrix in 3d view region */
- gpuGetProjectionMatrix(rv3d->winmat);
+ GPU_matrix_projection_get(rv3d->winmat);
}
static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
@@ -1003,8 +1003,7 @@ int view3d_opengl_select(
* the object & bone view locking takes 'rect' into account, see: T51629. */
ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect);
- if (v3d->drawtype > OB_WIRE) {
- v3d->zbuf = true;
+ if (v3d->shading.type > OB_WIRE) {
GPU_depth_test(true);
}
@@ -1049,8 +1048,7 @@ int view3d_opengl_select(
G.f &= ~G_PICKSEL;
ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL);
- if (v3d->drawtype > OB_WIRE) {
- v3d->zbuf = 0;
+ if (v3d->shading.type > OB_WIRE) {
GPU_depth_test(false);
}
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index e3e82e8b9c2..e4e12cc3686 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -134,18 +134,15 @@ typedef enum eWalkGravityState {
void walk_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
- {WALK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
{WALK_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
+ {WALK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
- {WALK_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""},
- {WALK_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""},
-
- {WALK_MODAL_DIR_FORWARD, "FORWARD", 0, "Move Forward", ""},
- {WALK_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Move Backward", ""},
- {WALK_MODAL_DIR_LEFT, "LEFT", 0, "Move Left (Strafe)", ""},
- {WALK_MODAL_DIR_RIGHT, "RIGHT", 0, "Move Right (Strafe)", ""},
- {WALK_MODAL_DIR_UP, "UP", 0, "Move Up", ""},
- {WALK_MODAL_DIR_DOWN, "DOWN", 0, "Move Down", ""},
+ {WALK_MODAL_DIR_FORWARD, "FORWARD", 0, "Forward", ""},
+ {WALK_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Backward", ""},
+ {WALK_MODAL_DIR_LEFT, "LEFT", 0, "Left (Strafe)", ""},
+ {WALK_MODAL_DIR_RIGHT, "RIGHT", 0, "Right (Strafe)", ""},
+ {WALK_MODAL_DIR_UP, "UP", 0, "Up", ""},
+ {WALK_MODAL_DIR_DOWN, "DOWN", 0, "Down", ""},
{WALK_MODAL_DIR_FORWARD_STOP, "FORWARD_STOP", 0, "Stop Move Forward", ""},
{WALK_MODAL_DIR_BACKWARD_STOP, "BACKWARD_STOP", 0, "Stop Mode Backward", ""},
@@ -156,14 +153,17 @@ void walk_modal_keymap(wmKeyConfig *keyconf)
{WALK_MODAL_TELEPORT, "TELEPORT", 0, "Teleport", "Move forward a few units at once"},
- {WALK_MODAL_FAST_ENABLE, "FAST_ENABLE", 0, "Fast Enable", "Move faster (walk or fly)"},
- {WALK_MODAL_FAST_DISABLE, "FAST_DISABLE", 0, "Fast Disable", "Resume regular speed"},
+ {WALK_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""},
+ {WALK_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""},
+
+ {WALK_MODAL_FAST_ENABLE, "FAST_ENABLE", 0, "Fast", "Move faster (walk or fly)"},
+ {WALK_MODAL_FAST_DISABLE, "FAST_DISABLE", 0, "Fast (Off)", "Resume regular speed"},
- {WALK_MODAL_SLOW_ENABLE, "SLOW_ENABLE", 0, "Slow Enable", "Move slower (walk or fly)"},
- {WALK_MODAL_SLOW_DISABLE, "SLOW_DISABLE", 0, "Slow Disable", "Resume regular speed"},
+ {WALK_MODAL_SLOW_ENABLE, "SLOW_ENABLE", 0, "Slow", "Move slower (walk or fly)"},
+ {WALK_MODAL_SLOW_DISABLE, "SLOW_DISABLE", 0, "Slow (Off)", "Resume regular speed"},
{WALK_MODAL_JUMP, "JUMP", 0, "Jump", "Jump when in walk mode"},
- {WALK_MODAL_JUMP_STOP, "JUMP_STOP", 0, "Jump Stop", "Stop pushing jump"},
+ {WALK_MODAL_JUMP_STOP, "JUMP_STOP", 0, "Jump (Off)", "Stop pushing jump"},
{WALK_MODAL_TOGGLE, "GRAVITY_TOGGLE", 0, "Toggle Gravity", "Toggle gravity effect"},
@@ -178,8 +178,8 @@ void walk_modal_keymap(wmKeyConfig *keyconf)
keymap = WM_modalkeymap_add(keyconf, "View3D Walk Modal", modal_items);
/* items for modal map */
- WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_CANCEL);
WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, WALK_MODAL_CANCEL);
+ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_CANCEL);
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, WALK_MODAL_CONFIRM);
WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_CONFIRM);
@@ -343,14 +343,14 @@ static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *a
yoff = walk->ar->winy / 2;
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_VIEW_OVERLAY);
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
/* North */
immVertex2i(pos, xoff, yoff + inner_length);
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 3e132192875..45055eb1225 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -46,8 +46,8 @@ set(SRC
transform_conversions.c
transform_generics.c
transform_input.c
- transform_manipulator_2d.c
- transform_manipulator_3d.c
+ transform_gizmo_2d.c
+ transform_gizmo_3d.c
transform_ops.c
transform_orientations.c
transform_snap.c
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 9a52127b201..28c59ea387f 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -820,25 +820,100 @@ enum {
TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27,
};
+static bool transform_modal_item_poll(const wmOperator *op, int value)
+{
+ const TransInfo *t = op->customdata;
+ switch (value) {
+ case TFM_MODAL_PROPSIZE:
+ case TFM_MODAL_PROPSIZE_UP:
+ case TFM_MODAL_PROPSIZE_DOWN:
+ {
+ if ((t->flag & T_PROP_EDIT) == 0) {
+ return false;
+ }
+ break;
+ }
+ case TFM_MODAL_ADD_SNAP:
+ case TFM_MODAL_REMOVE_SNAP:
+ {
+ if (t->spacetype != SPACE_VIEW3D) {
+ return false;
+ }
+ else if (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) {
+ return false;
+ }
+ else if (!validSnap(t)) {
+ return false;
+ }
+ break;
+ }
+ case TFM_MODAL_AXIS_X:
+ case TFM_MODAL_AXIS_Y:
+ case TFM_MODAL_AXIS_Z:
+ case TFM_MODAL_PLANE_X:
+ case TFM_MODAL_PLANE_Y:
+ case TFM_MODAL_PLANE_Z:
+ {
+ if (t->flag & T_NO_CONSTRAINT) {
+ return false;
+ }
+ if (!ELEM(value, TFM_MODAL_AXIS_X, TFM_MODAL_AXIS_Y)) {
+ if (t->flag & T_2D_EDIT) {
+ return false;
+ }
+ }
+ break;
+ }
+ case TFM_MODAL_CONS_OFF:
+ {
+ if ((t->con.mode & CON_APPLY) == 0) {
+ return false;
+ }
+ break;
+ }
+ case TFM_MODAL_EDGESLIDE_UP:
+ case TFM_MODAL_EDGESLIDE_DOWN:
+ {
+ if (t->mode != TFM_EDGE_SLIDE) {
+ return false;
+ }
+ break;
+ }
+ case TFM_MODAL_INSERTOFS_TOGGLE_DIR:
+ {
+ if (t->spacetype != SPACE_NODE) {
+ return false;
+ }
+ break;
+ }
+ case TFM_MODAL_AUTOIK_LEN_INC:
+ case TFM_MODAL_AUTOIK_LEN_DEC:
+ {
+ if ((t->flag & T_AUTOIK) == 0) {
+ return false;
+ }
+ break;
+ }
+ }
+ return true;
+}
+
/* called in transform_ops.c, on each regeneration of keymaps */
wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
- {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
{TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
- {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
- {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
- {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
- {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap On", ""},
- {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""},
+ {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
+ {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X axis", ""},
+ {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y axis", ""},
+ {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z axis", ""},
+ {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X plane", ""},
+ {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y plane", ""},
+ {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z plane", ""},
+ {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""},
+ {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""},
+ {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Snap Invert (Off)", ""},
{TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""},
- {TFM_MODAL_AXIS_X, "AXIS_X", 0, "Orientation X axis", ""},
- {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Orientation Y axis", ""},
- {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Orientation Z axis", ""},
- {TFM_MODAL_PLANE_X, "PLANE_X", 0, "Orientation X plane", ""},
- {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Orientation Y plane", ""},
- {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Orientation Z plane", ""},
- {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""},
{TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""},
{TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""},
{NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
@@ -851,6 +926,9 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
{TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""},
{TFM_MODAL_PROPSIZE, "PROPORTIONAL_SIZE", 0, "Adjust Proportional Influence", ""},
{TFM_MODAL_INSERTOFS_TOGGLE_DIR, "INSERTOFS_TOGGLE_DIR", 0, "Toggle Direction for Node Auto-offset", ""},
+ {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
+ {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
+ {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -860,12 +938,24 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
if (keymap && keymap->modal_items) return NULL;
keymap = WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items);
+ keymap->poll_modal_item = transform_modal_item_poll;
/* items for modal map */
- WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL);
- WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
- WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
- WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL);
+ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL);
+
+ WM_modalkeymap_add_item(keymap, XKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_X);
+ WM_modalkeymap_add_item(keymap, YKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_Y);
+ WM_modalkeymap_add_item(keymap, ZKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_Z);
+
+ WM_modalkeymap_add_item(keymap, XKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_X);
+ WM_modalkeymap_add_item(keymap, YKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_Y);
+ WM_modalkeymap_add_item(keymap, ZKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_Z);
+
+ WM_modalkeymap_add_item(keymap, CKEY, KM_PRESS, 0, 0, TFM_MODAL_CONS_OFF);
WM_modalkeymap_add_item(keymap, GKEY, KM_PRESS, 0, 0, TFM_MODAL_TRANSLATE);
WM_modalkeymap_add_item(keymap, RKEY, KM_PRESS, 0, 0, TFM_MODAL_ROTATE);
@@ -906,7 +996,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
return keymap;
}
-static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode)
+static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode, bool is_plane)
{
if (!(t->flag & T_NO_CONSTRAINT)) {
int constraint_axis, constraint_plane;
@@ -959,17 +1049,21 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
else {
short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ?
t->current_orientation : V3D_MANIP_LOCAL);
- if (!(t->modifiers & MOD_CONSTRAINT_PLANE))
+ if (is_plane == false) {
setUserConstraint(t, orientation, constraint_axis, msg2);
- else if (t->modifiers & MOD_CONSTRAINT_PLANE)
+ }
+ else {
setUserConstraint(t, orientation, constraint_plane, msg3);
+ }
}
}
else {
- if (!(t->modifiers & MOD_CONSTRAINT_PLANE))
+ if (is_plane == false) {
setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2);
- else if (t->modifiers & MOD_CONSTRAINT_PLANE)
+ }
+ else {
setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3);
+ }
}
}
t->redraw |= TREDRAW_HARD;
@@ -1149,57 +1243,42 @@ int transformEvent(TransInfo *t, const wmEvent *event)
break;
case TFM_MODAL_AXIS_X:
if (!(t->flag & T_NO_CONSTRAINT)) {
- transform_event_xyz_constraint(t, XKEY, cmode);
+ transform_event_xyz_constraint(t, XKEY, cmode, false);
t->redraw |= TREDRAW_HARD;
handled = true;
}
break;
case TFM_MODAL_AXIS_Y:
if ((t->flag & T_NO_CONSTRAINT) == 0) {
- transform_event_xyz_constraint(t, YKEY, cmode);
+ transform_event_xyz_constraint(t, YKEY, cmode, false);
t->redraw |= TREDRAW_HARD;
handled = true;
}
break;
case TFM_MODAL_AXIS_Z:
if ((t->flag & (T_NO_CONSTRAINT)) == 0) {
- transform_event_xyz_constraint(t, ZKEY, cmode);
+ transform_event_xyz_constraint(t, ZKEY, cmode, false);
t->redraw |= TREDRAW_HARD;
handled = true;
}
break;
case TFM_MODAL_PLANE_X:
if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
- if (cmode == 'X') {
- stopConstraint(t);
- }
- else {
- setUserConstraint(t, t->current_orientation, (CON_AXIS1 | CON_AXIS2), IFACE_("locking %s X"));
- }
+ transform_event_xyz_constraint(t, XKEY, cmode, true);
t->redraw |= TREDRAW_HARD;
handled = true;
}
break;
case TFM_MODAL_PLANE_Y:
if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
- if (cmode == 'Y') {
- stopConstraint(t);
- }
- else {
- setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS2), IFACE_("locking %s Y"));
- }
+ transform_event_xyz_constraint(t, YKEY, cmode, true);
t->redraw |= TREDRAW_HARD;
handled = true;
}
break;
case TFM_MODAL_PLANE_Z:
if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
- if (cmode == 'Z') {
- stopConstraint(t);
- }
- else {
- setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS1), IFACE_("locking %s Z"));
- }
+ transform_event_xyz_constraint(t, ZKEY, cmode, true);
t->redraw |= TREDRAW_HARD;
handled = true;
}
@@ -1417,21 +1496,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
}
- else {
- if (!(t->flag & T_NO_CONSTRAINT)) {
- stopConstraint(t);
- t->redraw |= TREDRAW_HARD;
- handled = true;
- }
- }
- break;
- case XKEY:
- case YKEY:
- case ZKEY:
- if (!(t->flag & T_NO_CONSTRAINT)) {
- transform_event_xyz_constraint(t, event->type, cmode);
- handled = true;
- }
break;
case OKEY:
if (t->flag & T_PROP_EDIT && event->shift) {
@@ -1570,6 +1634,12 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
+ if (t->redraw &&
+ !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE))
+ {
+ WM_window_status_area_tag_redraw(CTX_wm_window(t->context));
+ }
+
if (handled || t->redraw) {
return 0;
}
@@ -1638,13 +1708,13 @@ typedef enum {
} ArrowDirection;
#define POS_INDEX 0
-/* NOTE: this --^ is a bit hackish, but simplifies Gwn_VertFormat usage among functions
+/* NOTE: this --^ is a bit hackish, but simplifies GPUVertFormat usage among functions
* private to this file - merwin
*/
static void drawArrow(ArrowDirection d, short offset, short length, short size)
{
- immBegin(GWN_PRIM_LINES, 6);
+ immBegin(GPU_PRIM_LINES, 6);
switch (d) {
case LEFT:
@@ -1681,7 +1751,7 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size)
static void drawArrowHead(ArrowDirection d, short size)
{
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
switch (d) {
case LEFT:
@@ -1714,7 +1784,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
float angle;
int a;
- immBegin(GWN_PRIM_LINE_STRIP, segments + 1);
+ immBegin(GPU_PRIM_LINE_STRIP, segments + 1);
for (angle = angle_start, a = 0; a < segments; angle += delta, a++) {
immVertex2f(POS_INDEX, cosf(angle) * size, sinf(angle) * size);
@@ -1762,11 +1832,11 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
tmval[i] += offset[i];
}
- gpuPushMatrix();
+ GPU_matrix_push();
/* Dashed lines first. */
if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE)) {
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
UNUSED_VARS_NDEBUG(shdr_pos); /* silence warning */
BLI_assert(shdr_pos == POS_INDEX);
@@ -1784,7 +1854,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
immUniform1f("dash_width", 6.0f);
immUniform1f("dash_factor", 0.5f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(POS_INDEX, cent);
immVertex2f(POS_INDEX, tmval[0], tmval[1]);
immEnd();
@@ -1793,7 +1863,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
}
/* And now, solid lines. */
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
UNUSED_VARS_NDEBUG(pos); /* silence warning */
BLI_assert(pos == POS_INDEX);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1802,8 +1872,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
case HLP_SPRING:
immUniformThemeColor(TH_VIEW_OVERLAY);
- gpuTranslate3fv(mval);
- gpuRotateAxis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z');
+ GPU_matrix_translate_3fv(mval);
+ GPU_matrix_rotate_axis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z');
GPU_line_width(3.0f);
drawArrow(UP, 5, 10, 5);
@@ -1811,7 +1881,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
break;
case HLP_HARROW:
immUniformThemeColor(TH_VIEW_OVERLAY);
- gpuTranslate3fv(mval);
+ GPU_matrix_translate_3fv(mval);
GPU_line_width(3.0f);
drawArrow(RIGHT, 5, 10, 5);
@@ -1820,7 +1890,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
case HLP_VARROW:
immUniformThemeColor(TH_VIEW_OVERLAY);
- gpuTranslate3fv(mval);
+ GPU_matrix_translate_3fv(mval);
GPU_line_width(3.0f);
drawArrow(UP, 5, 10, 5);
@@ -1836,23 +1906,23 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
immUniformThemeColor(TH_VIEW_OVERLAY);
- gpuTranslate3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0);
+ GPU_matrix_translate_3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0);
GPU_line_width(3.0f);
drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
- gpuPushMatrix();
+ GPU_matrix_push();
- gpuTranslate3f(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
- gpuRotateAxis(RAD2DEGF(angle - delta_angle), 'Z');
+ GPU_matrix_translate_3f(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
+ GPU_matrix_rotate_axis(RAD2DEGF(angle - delta_angle), 'Z');
drawArrowHead(DOWN, 5);
- gpuPopMatrix();
+ GPU_matrix_pop();
- gpuTranslate3f(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
- gpuRotateAxis(RAD2DEGF(angle + delta_angle), 'Z');
+ GPU_matrix_translate_3f(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
+ GPU_matrix_rotate_axis(RAD2DEGF(angle + delta_angle), 'Z');
drawArrowHead(UP, 5);
break;
@@ -1862,7 +1932,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
unsigned char col[3], col2[3];
UI_GetThemeColor3ubv(TH_GRID, col);
- gpuTranslate3fv(mval);
+ GPU_matrix_translate_3fv(mval);
GPU_line_width(3.0f);
@@ -1882,7 +1952,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
}
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
@@ -2164,7 +2234,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->launch_event = event ? WM_userdef_event_type_from_keymap_type(event->type) : -1;
// XXX Remove this when wm_operator_call_internal doesn't use window->eventstate (which can have type = 0)
- // For manipulator only, so assume LEFTMOUSE
+ // For gizmo only, so assume LEFTMOUSE
if (t->launch_event == 0) {
t->launch_event = LEFTMOUSE;
}
@@ -2216,10 +2286,10 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* keymap for shortcut header prints */
t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap);
- /* Stupid code to have Ctrl-Click on manipulator work ok
+ /* Stupid code to have Ctrl-Click on gizmo work ok
*
* do this only for translation/rotation/resize due to only this
- * moded are available from manipulator and doing such check could
+ * moded are available from gizmo and doing such check could
* lead to keymap conflicts for other modes (see #31584)
*/
if (ELEM(mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) {
@@ -3581,7 +3651,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
t->con.applySize(t, NULL, NULL, mat);
}
- copy_m3_m3(t->mat, mat); // used in manipulator
+ copy_m3_m3(t->mat, mat); // used in gizmo
headerResize(t, t->values, str);
@@ -4301,7 +4371,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2]))
mul_m3_m3m3(mat, smat, totmat);
// TRANSFORM_FIX_ME
- //copy_m3_m3(t->mat, mat); // used in manipulator
+ //copy_m3_m3(t->mat, mat); // used in gizmo
#endif
applyTrackballValue(t, axis1, axis2, phi);
@@ -5573,7 +5643,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
t->con.applySize(t, NULL, NULL, mat);
}
- copy_m3_m3(t->mat, mat); // used in manipulator
+ copy_m3_m3(t->mat, mat); // used in gizmo
headerBoneSize(t, size, str);
@@ -6774,7 +6844,7 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
if (t->spacetype == SPACE_VIEW3D) {
v3d = t->sa ? t->sa->spacedata.first : NULL;
rv3d = t->ar ? t->ar->regiondata : NULL;
- use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE);
+ use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->shading.type > OB_WIRE);
}
calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, true);
@@ -6969,7 +7039,7 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t
if (t->spacetype == SPACE_VIEW3D) {
v3d = t->sa ? t->sa->spacedata.first : NULL;
rv3d = t->ar ? t->ar->regiondata : NULL;
- use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE);
+ use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->shading.type > OB_WIRE);
}
calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, false);
@@ -7162,19 +7232,17 @@ static void drawEdgeSlide(TransInfo *t)
/* Even mode */
if ((slp->use_even == true) || (is_clamp == false)) {
- View3D *v3d = t->view;
const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
- if (v3d && v3d->zbuf)
- GPU_depth_test(false);
+ GPU_depth_test(false);
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- gpuPushMatrix();
- gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
+ GPU_matrix_push();
+ GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -7191,7 +7259,7 @@ static void drawEdgeSlide(TransInfo *t)
GPU_line_width(line_size);
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
- immBeginAtMost(GWN_PRIM_LINES, 4);
+ immBeginAtMost(GPU_PRIM_LINES, 4);
if (curr_sv->v_side[0]) {
immVertex3fv(pos, curr_sv->v_side[0]->co);
immVertex3fv(pos, curr_sv->v_co_orig);
@@ -7204,7 +7272,7 @@ static void drawEdgeSlide(TransInfo *t)
immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade);
GPU_point_size(ctrl_size);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
if (slp->flipped) {
if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co);
}
@@ -7215,7 +7283,7 @@ static void drawEdgeSlide(TransInfo *t)
immUniformThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade);
GPU_point_size(guide_size);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac);
immVertex3fv(pos, co_mark);
immEnd();
@@ -7229,7 +7297,7 @@ static void drawEdgeSlide(TransInfo *t)
GPU_line_width(line_size);
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
- immBegin(GWN_PRIM_LINES, sld->totsv * 2);
+ immBegin(GPU_PRIM_LINES, sld->totsv * 2);
/* TODO(campbell): Loop over all verts */
sv = sld->sv;
@@ -7260,12 +7328,11 @@ static void drawEdgeSlide(TransInfo *t)
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
GPU_blend(false);
- if (v3d && v3d->zbuf)
- GPU_depth_test(true);
+ GPU_depth_test(true);
}
}
}
@@ -7793,7 +7860,6 @@ static void drawVertSlide(TransInfo *t)
/* Non-Prop mode */
{
- View3D *v3d = t->view;
TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
TransDataVertSlideVert *sv;
const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
@@ -7801,23 +7867,22 @@ static void drawVertSlide(TransInfo *t)
const int alpha_shade = -160;
int i;
- if (v3d && v3d->zbuf)
- GPU_depth_test(false);
+ GPU_depth_test(false);
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- gpuPushMatrix();
- gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
+ GPU_matrix_push();
+ GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
GPU_line_width(line_size);
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
- immBegin(GWN_PRIM_LINES, sld->totsv * 2);
+ immBegin(GPU_PRIM_LINES, sld->totsv * 2);
if (is_clamp) {
sv = sld->sv;
for (i = 0; i < sld->totsv; i++, sv++) {
@@ -7843,7 +7908,7 @@ static void drawVertSlide(TransInfo *t)
GPU_point_size(ctrl_size);
- immBegin(GWN_PRIM_POINTS, 1);
+ immBegin(GPU_PRIM_POINTS, 1);
immVertex3fv(shdr_pos, (slp->flipped && slp->use_even) ?
curr_sv->co_link_orig_3d[curr_sv->co_link_curr] :
curr_sv->co_orig_3d);
@@ -7886,7 +7951,7 @@ static void drawVertSlide(TransInfo *t)
immUniform1f("dash_width", 6.0f);
immUniform1f("dash_factor", 0.5f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex3fv(shdr_pos, curr_sv->co_orig_3d);
immVertex3fv(shdr_pos, co_dest_3d);
immEnd();
@@ -7894,10 +7959,9 @@ static void drawVertSlide(TransInfo *t)
immUnbindProgram();
}
- gpuPopMatrix();
+ GPU_matrix_pop();
- if (v3d && v3d->zbuf)
- GPU_depth_test(true);
+ GPU_depth_test(true);
}
}
}
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index b9fbb37722c..dfcd3e4cfd6 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -491,7 +491,7 @@ typedef struct TransInfo {
short persp;
short around;
char spacetype; /* spacetype where transforming is */
- char helpline; /* Choice of custom cursor with or without a help line from the manipulator to the mouse position. */
+ char helpline; /* Choice of custom cursor with or without a help line from the gizmo to the mouse position. */
short obedit_type; /* Avoid looking inside TransDataContainer obedit. */
float vec[3]; /* translation, to show for widget */
@@ -505,7 +505,7 @@ typedef struct TransInfo {
short current_orientation;
TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */
- short twflag; /* backup from view3d, to restore on end */
+ short gizmo_flag; /* backup from view3d, to restore on end */
short prop_mode;
@@ -712,9 +712,9 @@ void flushTransMasking(TransInfo *t);
void flushTransPaintCurve(TransInfo *t);
void restoreBones(TransDataContainer *tc);
-/*********************** transform_manipulator.c ********** */
+/*********************** transform_gizmo.c ********** */
-#define MANIPULATOR_AXIS_LINE_WIDTH 2.0f
+#define GIZMO_AXIS_LINE_WIDTH 2.0f
/* return 0 when no gimbal for selection */
bool gimbal_axis(struct Object *ob, float gmat[3][3]);
@@ -774,8 +774,8 @@ void snapGridIncrementAction(TransInfo *t, float *val, GearsType action);
void snapSequenceBounds(TransInfo *t, const int mval[2]);
-bool activeSnap(TransInfo *t);
-bool validSnap(TransInfo *t);
+bool activeSnap(const TransInfo *t);
+bool validSnap(const TransInfo *t);
void initSnapping(struct TransInfo *t, struct wmOperator *op);
void freeSnapping(struct TransInfo *t);
@@ -785,10 +785,10 @@ void applySnapping(TransInfo *t, float *vec);
void resetSnapping(TransInfo *t);
eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event);
void drawSnapping(const struct bContext *C, TransInfo *t);
-bool usingSnappingNormal(TransInfo *t);
-bool validSnappingNormal(TransInfo *t);
+bool usingSnappingNormal(const TransInfo *t);
+bool validSnappingNormal(const TransInfo *t);
-void getSnapPoint(TransInfo *t, float vec[3]);
+void getSnapPoint(const TransInfo *t, float vec[3]);
void addSnapPoint(TransInfo *t);
eRedrawFlag updateSelectedSnapPoint(TransInfo *t);
void removeSnapPoint(TransInfo *t);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 9df8264cc76..c8f74cbcd4f 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -747,7 +747,7 @@ void drawConstraint(TransInfo *t)
if (depth_test_enabled)
GPU_depth_test(false);
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
@@ -760,7 +760,7 @@ void drawConstraint(TransInfo *t)
immUniform1f("dash_width", 2.0f);
immUniform1f("dash_factor", 0.5f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex3fv(shdr_pos, t->center_global);
immVertex3fv(shdr_pos, vec);
immEnd();
@@ -800,13 +800,13 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
unit_m4(imat);
}
- gpuPushMatrix();
+ GPU_matrix_push();
if (t->spacetype == SPACE_VIEW3D) {
/* pass */
}
else if (t->spacetype == SPACE_IMAGE) {
- gpuScale2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]);
+ GPU_matrix_scale_2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]);
}
else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) {
/* only scale y */
@@ -816,14 +816,14 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
float ysize = BLI_rctf_size_y(datamask);
float xmask = BLI_rcti_size_x(mask);
float ymask = BLI_rcti_size_y(mask);
- gpuScale2f(1.0f, (ysize / xsize) * (xmask / ymask));
+ GPU_matrix_scale_2f(1.0f, (ysize / xsize) * (xmask / ymask));
}
depth_test_enabled = GPU_depth_test_enabled();
if (depth_test_enabled)
GPU_depth_test(false);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformThemeColor(TH_GRID);
@@ -837,7 +837,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
if (depth_test_enabled)
GPU_depth_test(true);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index c622a50ff11..a5706f4a003 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -5463,10 +5463,6 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
MEM_freeN(custom_data->data);
custom_data->data = NULL;
}
- if (tc->data) {
- MEM_freeN(tc->data); // XXX postTrans usually does this
- tc->data = NULL;
- }
}
static void createTransSeqData(bContext *C, TransInfo *t)
@@ -6688,7 +6684,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
BKE_pose_where_is(t->depsgraph, t->scene, pose_ob);
}
- /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */
+ /* set BONE_TRANSFORM flags for autokey, gizmo draw might have changed them */
if (!canceled && (t->mode != TFM_DUMMY)) {
count_set_pose_transflags(ob, t->mode, t->around, NULL);
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index db8bbe05c69..3618d57b3ed 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -463,13 +463,13 @@ static void recalcData_graphedit(TransInfo *t)
/* helper for recalcData() - for NLA Editor transforms */
static void recalcData_nla(TransInfo *t)
{
- TransDataNla *tdn = t->custom.type.data;
SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
Scene *scene = t->scene;
double secf = FPS;
int i;
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+ TransDataNla *tdn = tc->custom.type.data;
/* for each strip we've got, perform some additional validation of the values that got set before
* using RNA to set the value (which does some special operations when setting these values to make
@@ -1116,7 +1116,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis
if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = t->view;
- gpuPushMatrix();
+ GPU_matrix_push();
copy_v3_v3(v3, dir);
mul_v3_fl(v3, v3d->far);
@@ -1132,19 +1132,19 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis
}
UI_make_axis_color(col, col2, axis);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3ubv(col2);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex3fv(pos, v1);
immVertex3fv(pos, v2);
immEnd();
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
@@ -1348,10 +1348,10 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->view = v3d;
t->animtimer = (animscreen) ? animscreen->animtimer : NULL;
- /* turn manipulator off during transform */
+ /* turn gizmo off during transform */
if (t->flag & T_MODAL) {
- t->twflag = v3d->twflag;
- v3d->twflag = 0;
+ t->gizmo_flag = v3d->gizmo_flag;
+ v3d->gizmo_flag = V3D_GIZMO_HIDE;
}
if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) {
@@ -1688,9 +1688,9 @@ void postTrans(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = t->sa->spacedata.first;
- /* restore manipulator */
+ /* restore gizmo */
if (t->flag & T_MODAL) {
- v3d->twflag = t->twflag;
+ v3d->gizmo_flag = t->gizmo_flag;
}
}
diff --git a/source/blender/editors/transform/transform_manipulator_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index fd6e7ed5442..ff69c2859fc 100644
--- a/source/blender/editors/transform/transform_manipulator_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -18,10 +18,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/transform/transform_manipulator_2d.c
+/** \file blender/editors/transform/transform_gizmo_2d.c
* \ingroup edtransform
*
- * \name 2D Transform Manipulator
+ * \name 2D Transform Gizmo
*
* Used for UV/Image Editor
*/
@@ -52,7 +52,7 @@
#include "ED_image.h"
#include "ED_screen.h"
#include "ED_uvedit.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "transform.h" /* own include */
@@ -64,18 +64,18 @@ enum {
MAN2D_AXIS_LAST,
};
-typedef struct ManipulatorGroup2D {
- wmManipulator *translate_x,
+typedef struct GizmoGroup2D {
+ wmGizmo *translate_x,
*translate_y;
- wmManipulator *cage;
+ wmGizmo *cage;
/* Current origin in view space, used to update widget origin for possible view changes */
float origin[2];
float min[2];
float max[2];
-} ManipulatorGroup2D;
+} GizmoGroup2D;
/* **************** Utilities **************** */
@@ -83,16 +83,16 @@ typedef struct ManipulatorGroup2D {
/* loop over axes */
#define MAN2D_ITER_AXES_BEGIN(axis, axis_idx) \
{ \
- wmManipulator *axis; \
+ wmGizmo *axis; \
int axis_idx; \
for (axis_idx = 0; axis_idx < MAN2D_AXIS_LAST; axis_idx++) { \
- axis = manipulator2d_get_axis_from_index(man, axis_idx);
+ axis = gizmo2d_get_axis_from_index(man, axis_idx);
#define MAN2D_ITER_AXES_END \
} \
} ((void)0)
-static wmManipulator *manipulator2d_get_axis_from_index(const ManipulatorGroup2D *man, const short axis_idx)
+static wmGizmo *gizmo2d_get_axis_from_index(const GizmoGroup2D *man, const short axis_idx)
{
BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN2D_AXIS_TRANS_X, (float)MAN2D_AXIS_TRANS_Y));
@@ -106,7 +106,7 @@ static wmManipulator *manipulator2d_get_axis_from_index(const ManipulatorGroup2D
return NULL;
}
-static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float *r_col_hi)
+static void gizmo2d_get_axis_color(const int axis_idx, float *r_col, float *r_col_hi)
{
const float alpha = 0.6f;
const float alpha_hi = 1.0f;
@@ -128,29 +128,29 @@ static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float
r_col_hi[3] *= alpha_hi;
}
-static ManipulatorGroup2D *manipulatorgroup2d_init(wmManipulatorGroup *mgroup)
+static GizmoGroup2D *gizmogroup2d_init(wmGizmoGroup *gzgroup)
{
- const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_2d", true);
- const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_2d", true);
+ const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_2d", true);
+ const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_2d", true);
- ManipulatorGroup2D *man = MEM_callocN(sizeof(ManipulatorGroup2D), __func__);
+ GizmoGroup2D *man = MEM_callocN(sizeof(GizmoGroup2D), __func__);
- man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
- man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
- man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL);
+ man->translate_x = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL);
+ man->translate_y = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL);
+ man->cage = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL);
RNA_enum_set(man->cage->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE |
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE |
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE);
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE |
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE |
+ ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE);
return man;
}
/**
- * Calculates origin in view space, use with #manipulator2d_origin_to_region.
+ * Calculates origin in view space, use with #gizmo2d_origin_to_region.
*/
-static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max)
+static void gizmo2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max)
{
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = ED_space_image(sima);
@@ -173,56 +173,56 @@ static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float
/**
* Convert origin (or any other point) from view to region space.
*/
-BLI_INLINE void manipulator2d_origin_to_region(ARegion *ar, float *r_origin)
+BLI_INLINE void gizmo2d_origin_to_region(ARegion *ar, float *r_origin)
{
UI_view2d_view_to_region_fl(&ar->v2d, r_origin[0], r_origin[1], &r_origin[0], &r_origin[1]);
}
/**
- * Custom handler for manipulator widgets
+ * Custom handler for gizmo widgets
*/
-static int manipulator2d_modal(
- bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event),
- eWM_ManipulatorTweak UNUSED(tweak_flag))
+static int gizmo2d_modal(
+ bContext *C, wmGizmo *widget, const wmEvent *UNUSED(event),
+ eWM_GizmoFlagTweak UNUSED(tweak_flag))
{
ARegion *ar = CTX_wm_region(C);
float origin[3];
- manipulator2d_calc_bounds(C, origin, NULL, NULL);
- manipulator2d_origin_to_region(ar, origin);
- WM_manipulator_set_matrix_location(widget, origin);
+ gizmo2d_calc_bounds(C, origin, NULL, NULL);
+ gizmo2d_origin_to_region(ar, origin);
+ WM_gizmo_set_matrix_location(widget, origin);
ED_region_tag_redraw(ar);
return OPERATOR_RUNNING_MODAL;
}
-void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
wmOperatorType *ot_translate = WM_operatortype_find("TRANSFORM_OT_translate", true);
- ManipulatorGroup2D *man = manipulatorgroup2d_init(mgroup);
- mgroup->customdata = man;
+ GizmoGroup2D *man = gizmogroup2d_init(gzgroup);
+ gzgroup->customdata = man;
MAN2D_ITER_AXES_BEGIN(axis, axis_idx)
{
const float offset[3] = {0.0f, 0.2f};
float color[4], color_hi[4];
- manipulator2d_get_axis_color(axis_idx, color, color_hi);
+ gizmo2d_get_axis_color(axis_idx, color, color_hi);
/* custom handler! */
- WM_manipulator_set_fn_custom_modal(axis, manipulator2d_modal);
+ WM_gizmo_set_fn_custom_modal(axis, gizmo2d_modal);
/* set up widget data */
RNA_float_set(axis->ptr, "angle", -M_PI_2 * axis_idx);
RNA_float_set(axis->ptr, "length", 0.8f);
- WM_manipulator_set_matrix_offset_location(axis, offset);
- WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH);
- WM_manipulator_set_scale(axis, U.manipulator_size);
- WM_manipulator_set_color(axis, color);
- WM_manipulator_set_color_highlight(axis, color_hi);
+ WM_gizmo_set_matrix_offset_location(axis, offset);
+ WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH);
+ WM_gizmo_set_scale(axis, U.gizmo_size);
+ WM_gizmo_set_color(axis, color);
+ WM_gizmo_set_color_highlight(axis, color_hi);
/* assign operator */
- PointerRNA *ptr = WM_manipulator_operator_set(axis, 0, ot_translate, NULL);
+ PointerRNA *ptr = WM_gizmo_operator_set(axis, 0, ot_translate, NULL);
bool constraint[3] = {0};
constraint[(axis_idx + 1) % 2] = 1;
if (RNA_struct_find_property(ptr, "constraint_axis"))
@@ -237,107 +237,107 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator
PointerRNA *ptr;
/* assign operator */
- ptr = WM_manipulator_operator_set(man->cage, 0, ot_translate, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, 0, ot_translate, NULL);
RNA_boolean_set(ptr, "release_confirm", 1);
bool constraint_x[3] = {1, 0, 0};
bool constraint_y[3] = {0, 1, 0};
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL);
PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm");
PropertyRNA *prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis");
RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL);
RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL);
RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL);
RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
- ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE, ot_rotate, NULL);
+ ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_ROTATE, ot_rotate, NULL);
RNA_property_boolean_set(ptr, prop_release_confirm, true);
}
}
-void ED_widgetgroup_manipulator2d_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+void ED_widgetgroup_gizmo2d_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- ManipulatorGroup2D *man = mgroup->customdata;
+ GizmoGroup2D *man = gzgroup->customdata;
float origin[3];
- manipulator2d_calc_bounds(C, origin, man->min, man->max);
+ gizmo2d_calc_bounds(C, origin, man->min, man->max);
copy_v2_v2(man->origin, origin);
bool show_cage = !equals_v2v2(man->min, man->max);
if (show_cage) {
- man->cage->flag &= ~WM_MANIPULATOR_HIDDEN;
- man->translate_x->flag |= WM_MANIPULATOR_HIDDEN;
- man->translate_y->flag |= WM_MANIPULATOR_HIDDEN;
+ man->cage->flag &= ~WM_GIZMO_HIDDEN;
+ man->translate_x->flag |= WM_GIZMO_HIDDEN;
+ man->translate_y->flag |= WM_GIZMO_HIDDEN;
}
else {
- man->cage->flag |= WM_MANIPULATOR_HIDDEN;
- man->translate_x->flag &= ~WM_MANIPULATOR_HIDDEN;
- man->translate_y->flag &= ~WM_MANIPULATOR_HIDDEN;
+ man->cage->flag |= WM_GIZMO_HIDDEN;
+ man->translate_x->flag &= ~WM_GIZMO_HIDDEN;
+ man->translate_y->flag &= ~WM_GIZMO_HIDDEN;
}
if (show_cage) {
- wmManipulatorOpElem *mpop;
+ wmGizmoOpElem *mpop;
float mid[2];
const float *min = man->min;
const float *max = man->max;
mid_v2_v2v2(mid, min, max);
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X);
PropertyRNA *prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override");
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], mid[1], 0.0f});
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], mid[1], 0.0f});
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], max[1], 0.0f});
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], min[1], 0.0f});
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], max[1], 0.0f});
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], min[1], 0.0f});
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], max[1], 0.0f});
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], min[1], 0.0f});
- mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE);
+ mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_ROTATE);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], mid[1], 0.0f});
}
}
-void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+void ED_widgetgroup_gizmo2d_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
ARegion *ar = CTX_wm_region(C);
- ManipulatorGroup2D *man = mgroup->customdata;
+ GizmoGroup2D *man = gzgroup->customdata;
float origin[3] = {UNPACK2(man->origin), 0.0f};
float origin_aa[3] = {UNPACK2(man->origin), 0.0f};
- manipulator2d_origin_to_region(ar, origin);
+ gizmo2d_origin_to_region(ar, origin);
MAN2D_ITER_AXES_BEGIN(axis, axis_idx)
{
- WM_manipulator_set_matrix_location(axis, origin);
+ WM_gizmo_set_matrix_location(axis, origin);
}
MAN2D_ITER_AXES_END;
UI_view2d_view_to_region_m4(&ar->v2d, man->cage->matrix_space);
- WM_manipulator_set_matrix_offset_location(man->cage, origin_aa);
+ WM_gizmo_set_matrix_offset_location(man->cage, origin_aa);
man->cage->matrix_offset[0][0] = (man->max[0] - man->min[0]);
man->cage->matrix_offset[1][1] = (man->max[1] - man->min[1]);
}
@@ -346,9 +346,9 @@ void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorG
* - Called on every redraw, better to do a more simple poll and check for selection in _refresh
* - UV editing only, could be expanded for other things.
*/
-bool ED_widgetgroup_manipulator2d_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+bool ED_widgetgroup_gizmo2d_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
- if ((U.manipulator_flag & USER_MANIPULATOR_DRAW) == 0) {
+ if ((U.gizmo_flag & USER_GIZMO_DRAW) == 0) {
return false;
}
diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 8f547fb7451..cbc2b312512 100644
--- a/source/blender/editors/transform/transform_manipulator_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -18,10 +18,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/transform/transform_manipulator_3d.c
+/** \file blender/editors/transform/transform_gizmo_3d.c
* \ingroup edtransform
*
- * \name 3D Transform Manipulator
+ * \name 3D Transform Gizmo
*
* Used for 3D View
*/
@@ -74,7 +74,7 @@
#include "ED_view3d.h"
#include "ED_gpencil.h"
#include "ED_screen.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
#include "UI_resources.h"
@@ -106,7 +106,7 @@
#define MAN_SCALE_Z (1 << 10)
#define MAN_SCALE_C (MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z)
-/* threshold for testing view aligned manipulator axis */
+/* threshold for testing view aligned gizmo axis */
struct {
float min, max;
} g_tw_axis_range[2] = {
@@ -159,17 +159,17 @@ enum {
MAN_AXES_SCALE,
};
-typedef struct ManipulatorGroup {
+typedef struct GizmoGroup {
bool all_hidden;
int twtype;
- /* Users may change the twtype, detect changes to re-setup manipulator options. */
+ /* Users may change the twtype, detect changes to re-setup gizmo options. */
int twtype_init;
int twtype_prev;
int use_twtype_refresh;
- struct wmManipulator *manipulators[MAN_AXIS_LAST];
-} ManipulatorGroup;
+ struct wmGizmo *gizmos[MAN_AXIS_LAST];
+} GizmoGroup;
/* -------------------------------------------------------------------- */
/** \name Utilities
@@ -178,22 +178,22 @@ typedef struct ManipulatorGroup {
/* loop over axes */
#define MAN_ITER_AXES_BEGIN(axis, axis_idx) \
{ \
- wmManipulator *axis; \
+ wmGizmo *axis; \
int axis_idx; \
for (axis_idx = 0; axis_idx < MAN_AXIS_LAST; axis_idx++) { \
- axis = manipulator_get_axis_from_index(man, axis_idx);
+ axis = gizmo_get_axis_from_index(man, axis_idx);
#define MAN_ITER_AXES_END \
} \
} ((void)0)
-static wmManipulator *manipulator_get_axis_from_index(const ManipulatorGroup *man, const short axis_idx)
+static wmGizmo *gizmo_get_axis_from_index(const GizmoGroup *man, const short axis_idx)
{
BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN_AXIS_TRANS_X, (float)MAN_AXIS_LAST));
- return man->manipulators[axis_idx];
+ return man->gizmos[axis_idx];
}
-static short manipulator_get_axis_type(const int axis_idx)
+static short gizmo_get_axis_type(const int axis_idx)
{
if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) {
return MAN_AXES_TRANSLATE;
@@ -208,7 +208,7 @@ static short manipulator_get_axis_type(const int axis_idx)
return -1;
}
-static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane)
+static uint gizmo_orientation_axis(const int axis_idx, bool *r_is_plane)
{
switch (axis_idx) {
case MAN_AXIS_TRANS_YZ:
@@ -247,13 +247,13 @@ static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane)
return 3;
}
-static bool manipulator_is_axis_visible(
+static bool gizmo_is_axis_visible(
const RegionView3D *rv3d, const int twtype,
const float idot[3], const int axis_type, const int axis_idx)
{
if ((axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) == 0) {
bool is_plane = false;
- const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
+ const uint aidx_norm = gizmo_orientation_axis(axis_idx, &is_plane);
/* don't draw axis perpendicular to the view */
if (aidx_norm < 3) {
float idot_axis = idot[aidx_norm];
@@ -330,7 +330,7 @@ static bool manipulator_is_axis_visible(
return false;
}
-static void manipulator_get_axis_color(
+static void gizmo_get_axis_color(
const int axis_idx, const float idot[3],
float r_col[4], float r_col_hi[4])
{
@@ -346,7 +346,7 @@ static void manipulator_get_axis_color(
}
else {
bool is_plane = false;
- const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
+ const int axis_idx_norm = gizmo_orientation_axis(axis_idx, &is_plane);
/* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */
if (axis_idx_norm < 3) {
const float idot_min = g_tw_axis_range[is_plane].min;
@@ -401,7 +401,7 @@ static void manipulator_get_axis_color(
r_col_hi[3] = alpha_hi * alpha_fac;
}
-static void manipulator_get_axis_constraint(const int axis_idx, bool r_axis[3])
+static void gizmo_get_axis_constraint(const int axis_idx, bool r_axis[3])
{
ARRAY_SET_ITEMS(r_axis, 0, 0, 0);
@@ -596,7 +596,7 @@ bool gimbal_axis(Object *ob, float gmat[3][3])
/* centroid, boundbox, of selection */
/* returns total items selected */
-int ED_transform_calc_manipulator_stats(
+int ED_transform_calc_gizmo_stats(
const bContext *C,
const struct TransformCalcParams *params,
struct TransformBounds *tbounds)
@@ -952,7 +952,7 @@ int ED_transform_calc_manipulator_stats(
}
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 mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the gizmo mode, could be mixed
bool ok = false;
if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) {
@@ -1061,7 +1061,7 @@ int ED_transform_calc_manipulator_stats(
return totsel;
}
-static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3])
+static void gizmo_get_idot(RegionView3D *rv3d, float r_idot[3])
{
float view_vec[3], axis_vec[3];
ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], view_vec);
@@ -1071,7 +1071,7 @@ static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3])
}
}
-static void manipulator_prepare_mat(
+static void gizmo_prepare_mat(
const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds)
{
Scene *scene = CTX_data_scene(C);
@@ -1108,9 +1108,9 @@ static void manipulator_prepare_mat(
/**
* Sets up \a r_start and \a r_len to define arrow line range.
- * Needed to adjust line drawing for combined manipulator axis types.
+ * Needed to adjust line drawing for combined gizmo axis types.
*/
-static void manipulator_line_range(const int twtype, const short axis_type, float *r_start, float *r_len)
+static void gizmo_line_range(const int twtype, const short axis_type, float *r_start, float *r_len)
{
const float ofs = 0.2f;
@@ -1136,15 +1136,15 @@ static void manipulator_line_range(const int twtype, const short axis_type, floa
*r_len -= *r_start;
}
-static void manipulator_xform_message_subscribe(
- wmManipulatorGroup *mgroup, struct wmMsgBus *mbus,
+static void gizmo_xform_message_subscribe(
+ wmGizmoGroup *gzgroup, struct wmMsgBus *mbus,
Scene *scene, bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar, const void *type_fn)
{
/* Subscribe to view properties */
- wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = {
+ wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = {
.owner = ar,
- .user_data = mgroup->parent_mmap,
- .notify = WM_manipulator_do_msg_notify_tag_refresh,
+ .user_data = gzgroup->parent_gzmap,
+ .notify = WM_gizmo_do_msg_notify_tag_refresh,
};
PointerRNA scene_ptr;
@@ -1159,7 +1159,7 @@ static void manipulator_xform_message_subscribe(
};
for (int i = 0; i < ARRAY_SIZE(props); i++) {
if (props[i]) {
- WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
+ WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__);
}
}
}
@@ -1167,96 +1167,98 @@ static void manipulator_xform_message_subscribe(
PointerRNA toolsettings_ptr;
RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr);
- if (type_fn == TRANSFORM_WGT_manipulator) {
+ if (type_fn == TRANSFORM_GGT_gizmo) {
extern PropertyRNA rna_ToolSettings_transform_pivot_point;
- extern PropertyRNA rna_ToolSettings_use_manipulator_mode;
+ extern PropertyRNA rna_ToolSettings_use_gizmo_mode;
const PropertyRNA *props[] = {
&rna_ToolSettings_transform_pivot_point,
- &rna_ToolSettings_use_manipulator_mode,
+ &rna_ToolSettings_use_gizmo_mode,
};
for (int i = 0; i < ARRAY_SIZE(props); i++) {
- WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
+ WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__);
}
}
- else if (type_fn == VIEW3D_WGT_xform_cage) {
+ else if (type_fn == VIEW3D_GGT_xform_cage) {
/* pass */
}
else {
BLI_assert(0);
}
- WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_mpr_tag_refresh);
+ WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_gz_tag_refresh);
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Transform Manipulator
+/** \name Transform Gizmo
* \{ */
-static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup)
+static GizmoGroup *gizmogroup_init(wmGizmoGroup *gzgroup)
{
- ManipulatorGroup *man;
+ GizmoGroup *man;
- man = MEM_callocN(sizeof(ManipulatorGroup), "manipulator_data");
+ man = MEM_callocN(sizeof(GizmoGroup), "gizmo_data");
- const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true);
- const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true);
- const wmManipulatorType *wt_prim = WM_manipulatortype_find("MANIPULATOR_WT_primitive_3d", true);
+ const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true);
+ const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true);
+ const wmGizmoType *gzt_prim = WM_gizmotype_find("GIZMO_GT_primitive_3d", true);
-#define MANIPULATOR_NEW_ARROW(v, draw_style) { \
- man->manipulators[v] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); \
- RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \
+#define GIZMO_NEW_ARROW(v, draw_style) { \
+ man->gizmos[v] = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); \
+ RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \
} ((void)0)
-#define MANIPULATOR_NEW_DIAL(v, draw_options) { \
- man->manipulators[v] = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); \
- RNA_enum_set(man->manipulators[v]->ptr, "draw_options", draw_options); \
+#define GIZMO_NEW_DIAL(v, draw_options) { \
+ man->gizmos[v] = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); \
+ RNA_enum_set(man->gizmos[v]->ptr, "draw_options", draw_options); \
} ((void)0)
-#define MANIPULATOR_NEW_PRIM(v, draw_style) { \
- man->manipulators[v] = WM_manipulator_new_ptr(wt_prim, mgroup, NULL); \
- RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \
+#define GIZMO_NEW_PRIM(v, draw_style) { \
+ man->gizmos[v] = WM_gizmo_new_ptr(gzt_prim, gzgroup, NULL); \
+ RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \
} ((void)0)
/* add/init widgets - order matters! */
- MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_T, ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL);
+ GIZMO_NEW_DIAL(MAN_AXIS_ROT_T, ED_GIZMO_DIAL_DRAW_FLAG_FILL);
- MANIPULATOR_NEW_DIAL(MAN_AXIS_SCALE_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
+ GIZMO_NEW_DIAL(MAN_AXIS_SCALE_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP);
- MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_X, ED_MANIPULATOR_ARROW_STYLE_BOX);
- MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_MANIPULATOR_ARROW_STYLE_BOX);
- MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_MANIPULATOR_ARROW_STYLE_BOX);
+ GIZMO_NEW_ARROW(MAN_AXIS_SCALE_X, ED_GIZMO_ARROW_STYLE_BOX);
+ GIZMO_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_GIZMO_ARROW_STYLE_BOX);
+ GIZMO_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_GIZMO_ARROW_STYLE_BOX);
- MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
+ GIZMO_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_GIZMO_PRIMITIVE_STYLE_PLANE);
+ GIZMO_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_GIZMO_PRIMITIVE_STYLE_PLANE);
+ GIZMO_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_GIZMO_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_X, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
- MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Y, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
- MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Z, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
+ GIZMO_NEW_DIAL(MAN_AXIS_ROT_X, ED_GIZMO_DIAL_DRAW_FLAG_CLIP);
+ GIZMO_NEW_DIAL(MAN_AXIS_ROT_Y, ED_GIZMO_DIAL_DRAW_FLAG_CLIP);
+ GIZMO_NEW_DIAL(MAN_AXIS_ROT_Z, ED_GIZMO_DIAL_DRAW_FLAG_CLIP);
/* init screen aligned widget last here, looks better, behaves better */
- MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
+ GIZMO_NEW_DIAL(MAN_AXIS_ROT_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP);
- MANIPULATOR_NEW_DIAL(MAN_AXIS_TRANS_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
+ GIZMO_NEW_DIAL(MAN_AXIS_TRANS_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP);
- MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_X, ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_MANIPULATOR_ARROW_STYLE_NORMAL);
+ GIZMO_NEW_ARROW(MAN_AXIS_TRANS_X, ED_GIZMO_ARROW_STYLE_NORMAL);
+ GIZMO_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_GIZMO_ARROW_STYLE_NORMAL);
+ GIZMO_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_GIZMO_ARROW_STYLE_NORMAL);
- MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
+ GIZMO_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_GIZMO_PRIMITIVE_STYLE_PLANE);
+ GIZMO_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_GIZMO_PRIMITIVE_STYLE_PLANE);
+ GIZMO_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_GIZMO_PRIMITIVE_STYLE_PLANE);
+
+ man->gizmos[MAN_AXIS_ROT_T]->flag |= WM_GIZMO_SELECT_BACKGROUND;
return man;
}
/**
- * Custom handler for manipulator widgets
+ * Custom handler for gizmo widgets
*/
-static int manipulator_modal(
- bContext *C, wmManipulator *widget, const wmEvent *event,
- eWM_ManipulatorTweak UNUSED(tweak_flag))
+static int gizmo_modal(
+ bContext *C, wmGizmo *widget, const wmEvent *event,
+ eWM_GizmoFlagTweak UNUSED(tweak_flag))
{
/* Avoid unnecessary updates, partially address: T55458. */
if (ELEM(event->type, TIMER, INBETWEEN_MOUSEMOVE)) {
@@ -1270,13 +1272,13 @@ static int manipulator_modal(
struct TransformBounds tbounds;
- if (ED_transform_calc_manipulator_stats(
+ if (ED_transform_calc_gizmo_stats(
C, &(struct TransformCalcParams){
.use_only_center = true,
}, &tbounds))
{
- manipulator_prepare_mat(C, v3d, rv3d, &tbounds);
- WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]);
+ gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
+ WM_gizmo_set_matrix_location(widget, rv3d->twmat[3]);
}
ED_region_tag_redraw(ar);
@@ -1284,22 +1286,22 @@ static int manipulator_modal(
return OPERATOR_RUNNING_MODAL;
}
-static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgroup)
+static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *gzgroup)
{
struct {
wmOperatorType *translate, *rotate, *trackball, *resize;
} ot_store = {NULL};
- ManipulatorGroup *man = mgroup->customdata;
+ GizmoGroup *man = gzgroup->customdata;
MAN_ITER_AXES_BEGIN(axis, axis_idx)
{
- const short axis_type = manipulator_get_axis_type(axis_idx);
+ const short axis_type = gizmo_get_axis_type(axis_idx);
bool constraint_axis[3] = {1, 0, 0};
PointerRNA *ptr;
- manipulator_get_axis_constraint(axis_idx, constraint_axis);
+ gizmo_get_axis_constraint(axis_idx, constraint_axis);
/* custom handler! */
- WM_manipulator_set_fn_custom_modal(axis, manipulator_modal);
+ WM_gizmo_set_fn_custom_modal(axis, gizmo_modal);
switch (axis_idx) {
case MAN_AXIS_TRANS_X:
@@ -1311,19 +1313,19 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr
if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) {
int draw_options = 0;
if ((man->twtype & (SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) {
- draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM;
+ draw_options |= ED_GIZMO_ARROW_DRAW_FLAG_STEM;
}
RNA_enum_set(axis->ptr, "draw_options", draw_options);
}
- WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH);
+ WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH);
break;
case MAN_AXIS_ROT_X:
case MAN_AXIS_ROT_Y:
case MAN_AXIS_ROT_Z:
/* increased line width for better display */
- WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH + 1.0f);
- WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true);
+ WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH + 1.0f);
+ WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_VALUE, true);
break;
case MAN_AXIS_TRANS_XY:
case MAN_AXIS_TRANS_YZ:
@@ -1334,25 +1336,25 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr
{
const float ofs_ax = 7.0f;
const float ofs[3] = {ofs_ax, ofs_ax, 0.0f};
- WM_manipulator_set_scale(axis, 0.07f);
- WM_manipulator_set_matrix_offset_location(axis, ofs);
- WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true);
+ WM_gizmo_set_scale(axis, 0.07f);
+ WM_gizmo_set_matrix_offset_location(axis, ofs);
+ WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_OFFSET_SCALE, true);
break;
}
case MAN_AXIS_TRANS_C:
case MAN_AXIS_ROT_C:
case MAN_AXIS_SCALE_C:
case MAN_AXIS_ROT_T:
- WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH);
+ WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH);
if (axis_idx == MAN_AXIS_ROT_T) {
- WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_HOVER, true);
+ WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_HOVER, true);
}
else if (axis_idx == MAN_AXIS_ROT_C) {
- WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true);
- WM_manipulator_set_scale(axis, 1.2f);
+ WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_VALUE, true);
+ WM_gizmo_set_scale(axis, 1.2f);
}
else {
- WM_manipulator_set_scale(axis, 0.2f);
+ WM_gizmo_set_scale(axis, 0.2f);
}
break;
}
@@ -1362,7 +1364,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr
if (ot_store.translate == NULL) {
ot_store.translate = WM_operatortype_find("TRANSFORM_OT_translate", true);
}
- ptr = WM_manipulator_operator_set(axis, 0, ot_store.translate, NULL);
+ ptr = WM_gizmo_operator_set(axis, 0, ot_store.translate, NULL);
break;
case MAN_AXES_ROTATE:
{
@@ -1379,7 +1381,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr
}
ot_rotate = ot_store.rotate;
}
- ptr = WM_manipulator_operator_set(axis, 0, ot_rotate, NULL);
+ ptr = WM_gizmo_operator_set(axis, 0, ot_rotate, NULL);
break;
}
case MAN_AXES_SCALE:
@@ -1387,7 +1389,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr
if (ot_store.resize == NULL) {
ot_store.resize = WM_operatortype_find("TRANSFORM_OT_resize", true);
}
- ptr = WM_manipulator_operator_set(axis, 0, ot_store.resize, NULL);
+ ptr = WM_gizmo_operator_set(axis, 0, ot_store.resize, NULL);
break;
}
}
@@ -1404,11 +1406,11 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr
MAN_ITER_AXES_END;
}
-static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
- ManipulatorGroup *man = manipulatorgroup_init(mgroup);
+ GizmoGroup *man = gizmogroup_init(gzgroup);
- mgroup->customdata = man;
+ gzgroup->customdata = man;
{
man->twtype = 0;
@@ -1416,11 +1418,11 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup
const bToolRef *tref = sa->runtime.tool;
if (tref == NULL || STREQ(tref->idname, "Transform")) {
- /* Setup all manipulators, they can be toggled via 'ToolSettings.manipulator_flag' */
+ /* Setup all gizmos, they can be toggled via 'ToolSettings.gizmo_flag' */
man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE;
man->use_twtype_refresh = true;
}
- else if (STREQ(tref->idname, "Move")) {
+ else if (STREQ(tref->idname, "Grab")) {
man->twtype |= SCE_MANIP_TRANSLATE;
}
else if (STREQ(tref->idname, "Rotate")) {
@@ -1434,12 +1436,12 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup
}
/* *** set properties for axes *** */
- manipulatorgroup_init_properties_from_twtype(mgroup);
+ gizmogroup_init_properties_from_twtype(gzgroup);
}
-static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- ManipulatorGroup *man = mgroup->customdata;
+ GizmoGroup *man = gzgroup->customdata;
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = sa->spacedata.first;
@@ -1448,16 +1450,16 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
if (man->use_twtype_refresh) {
Scene *scene = CTX_data_scene(C);
- man->twtype = scene->toolsettings->manipulator_flag & man->twtype_init;
+ man->twtype = scene->toolsettings->gizmo_flag & man->twtype_init;
if (man->twtype != man->twtype_prev) {
man->twtype_prev = man->twtype;
- manipulatorgroup_init_properties_from_twtype(mgroup);
+ gizmogroup_init_properties_from_twtype(gzgroup);
}
}
/* skip, we don't draw anything anyway */
if ((man->all_hidden =
- (ED_transform_calc_manipulator_stats(
+ (ED_transform_calc_gizmo_stats(
C, &(struct TransformCalcParams){
.use_only_center = true,
}, &tbounds) == 0)))
@@ -1465,16 +1467,16 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
return;
}
- manipulator_prepare_mat(C, v3d, rv3d, &tbounds);
+ gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
/* *** set properties for axes *** */
MAN_ITER_AXES_BEGIN(axis, axis_idx)
{
- const short axis_type = manipulator_get_axis_type(axis_idx);
- const int aidx_norm = manipulator_orientation_axis(axis_idx, NULL);
+ const short axis_type = gizmo_get_axis_type(axis_idx);
+ const int aidx_norm = gizmo_orientation_axis(axis_idx, NULL);
- WM_manipulator_set_matrix_location(axis, rv3d->twmat[3]);
+ WM_gizmo_set_matrix_location(axis, rv3d->twmat[3]);
switch (axis_idx) {
case MAN_AXIS_TRANS_X:
@@ -1487,9 +1489,9 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
float start_co[3] = {0.0f, 0.0f, 0.0f};
float len;
- manipulator_line_range(man->twtype, axis_type, &start_co[2], &len);
+ gizmo_line_range(man->twtype, axis_type, &start_co[2], &len);
- WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]);
+ WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]);
RNA_float_set(axis->ptr, "length", len);
if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) {
@@ -1498,14 +1500,14 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
start_co[2] += 0.215f;
}
}
- WM_manipulator_set_matrix_offset_location(axis, start_co);
- WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true);
+ WM_gizmo_set_matrix_offset_location(axis, start_co);
+ WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_OFFSET_SCALE, true);
break;
}
case MAN_AXIS_ROT_X:
case MAN_AXIS_ROT_Y:
case MAN_AXIS_ROT_Z:
- WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]);
+ WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]);
break;
case MAN_AXIS_TRANS_XY:
case MAN_AXIS_TRANS_YZ:
@@ -1516,7 +1518,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
{
const float *y_axis = rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1];
const float *z_axis = rv3d->twmat[aidx_norm];
- WM_manipulator_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis);
+ WM_gizmo_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis);
break;
}
}
@@ -1524,134 +1526,139 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
MAN_ITER_AXES_END;
}
-static void WIDGETGROUP_manipulator_message_subscribe(
- const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus)
+static void WIDGETGROUP_gizmo_message_subscribe(
+ const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus)
{
Scene *scene = CTX_data_scene(C);
bScreen *screen = CTX_wm_screen(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, TRANSFORM_WGT_manipulator);
+ gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, ar, TRANSFORM_GGT_gizmo);
}
-static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
- ManipulatorGroup *man = mgroup->customdata;
+ GizmoGroup *man = gzgroup->customdata;
// ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
// View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
float idot[3];
- /* when looking through a selected camera, the manipulator can be at the
+ /* when looking through a selected camera, the gizmo can be at the
* exact same position as the view, skip so we don't break selection */
if (man->all_hidden || fabsf(ED_view3d_pixel_size(rv3d, rv3d->twmat[3])) < 1e-6f) {
MAN_ITER_AXES_BEGIN(axis, axis_idx)
{
- WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, true);
}
MAN_ITER_AXES_END;
return;
}
- manipulator_get_idot(rv3d, idot);
+ gizmo_get_idot(rv3d, idot);
/* *** set properties for axes *** */
MAN_ITER_AXES_BEGIN(axis, axis_idx)
{
- const short axis_type = manipulator_get_axis_type(axis_idx);
+ const short axis_type = gizmo_get_axis_type(axis_idx);
/* XXX maybe unset _HIDDEN flag on redraw? */
- if (manipulator_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) {
- WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, false);
+ if (gizmo_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) {
+ WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, false);
}
else {
- WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, true);
continue;
}
float color[4], color_hi[4];
- manipulator_get_axis_color(axis_idx, idot, color, color_hi);
- WM_manipulator_set_color(axis, color);
- WM_manipulator_set_color_highlight(axis, color_hi);
+ gizmo_get_axis_color(axis_idx, idot, color, color_hi);
+ WM_gizmo_set_color(axis, color);
+ WM_gizmo_set_color_highlight(axis, color_hi);
switch (axis_idx) {
case MAN_AXIS_TRANS_C:
case MAN_AXIS_ROT_C:
case MAN_AXIS_SCALE_C:
case MAN_AXIS_ROT_T:
- WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]);
+ WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]);
break;
}
}
MAN_ITER_AXES_END;
}
-static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt)
+static bool WIDGETGROUP_gizmo_poll(const struct bContext *C, struct wmGizmoGroupType *gzgt)
{
/* it's a given we only use this in 3D view */
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
if ((tref_rt == NULL) ||
- !STREQ(wgt->idname, tref_rt->manipulator_group))
+ !STREQ(gzgt->idname, tref_rt->gizmo_group))
{
- WM_manipulator_group_type_unlink_delayed_ptr(wgt);
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
+ return false;
+ }
+
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) {
return false;
}
return true;
}
-void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt)
+void TRANSFORM_GGT_gizmo(wmGizmoGroupType *gzgt)
{
- wgt->name = "Transform Manipulator";
- wgt->idname = "TRANSFORM_WGT_manipulator";
+ gzgt->name = "Transform Gizmo";
+ gzgt->idname = "TRANSFORM_GGT_gizmo";
- wgt->flag |= WM_MANIPULATORGROUPTYPE_3D;
+ gzgt->flag |= WM_GIZMOGROUPTYPE_3D;
- wgt->mmap_params.spaceid = SPACE_VIEW3D;
- wgt->mmap_params.regionid = RGN_TYPE_WINDOW;
+ gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
+ gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
- wgt->poll = WIDGETGROUP_manipulator_poll;
- wgt->setup = WIDGETGROUP_manipulator_setup;
- wgt->refresh = WIDGETGROUP_manipulator_refresh;
- wgt->message_subscribe = WIDGETGROUP_manipulator_message_subscribe;
- wgt->draw_prepare = WIDGETGROUP_manipulator_draw_prepare;
+ gzgt->poll = WIDGETGROUP_gizmo_poll;
+ gzgt->setup = WIDGETGROUP_gizmo_setup;
+ gzgt->refresh = WIDGETGROUP_gizmo_refresh;
+ gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe;
+ gzgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare;
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Scale Cage Manipulator
+/** \name Scale Cage Gizmo
* \{ */
struct XFormCageWidgetGroup {
- wmManipulator *manipulator;
+ wmGizmo *gizmo;
};
-static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupType *wgt)
+static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmGizmoGroupType *gzgt)
{
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
- if (!STREQ(wgt->idname, tref_rt->manipulator_group)) {
- WM_manipulator_group_type_unlink_delayed_ptr(wgt);
+ if (!STREQ(gzgt->idname, tref_rt->gizmo_group)) {
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
return false;
}
return true;
}
-static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
- struct XFormCageWidgetGroup *xmgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__);
- const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true);
- xmgroup->manipulator = WM_manipulator_new_ptr(wt_cage, mgroup, NULL);
- wmManipulator *mpr = xmgroup->manipulator;
+ struct XFormCageWidgetGroup *xgzgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__);
+ const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_3d", true);
+ xgzgroup->gizmo = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL);
+ wmGizmo *gz = xgzgroup->gizmo;
- RNA_enum_set(mpr->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE |
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE);
+ RNA_enum_set(gz->ptr, "transform",
+ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE |
+ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE);
- mpr->color[0] = 1;
- mpr->color_hi[0] = 1;
+ gz->color[0] = 1;
+ gz->color_hi[0] = 1;
- mgroup->customdata = xmgroup;
+ gzgroup->customdata = xgzgroup;
{
wmOperatorType *ot_resize = WM_operatortype_find("TRANSFORM_OT_resize", true);
@@ -1661,12 +1668,12 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulato
PropertyRNA *prop_release_confirm = NULL;
PropertyRNA *prop_constraint_axis = NULL;
- int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z;
+ int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z;
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
for (int z = 0; z < 3; z++) {
bool constraint[3] = {x != 1, y != 1, z != 1};
- ptr = WM_manipulator_operator_set(mpr, i, ot_resize, NULL);
+ ptr = WM_gizmo_operator_set(gz, i, ot_resize, NULL);
if (prop_release_confirm == NULL) {
prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm");
prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis");
@@ -1680,56 +1687,56 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulato
}
}
-static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
- struct XFormCageWidgetGroup *xmgroup = mgroup->customdata;
- wmManipulator *mpr = xmgroup->manipulator;
+ struct XFormCageWidgetGroup *xgzgroup = gzgroup->customdata;
+ wmGizmo *gz = xgzgroup->gizmo;
struct TransformBounds tbounds;
- if ((ED_transform_calc_manipulator_stats(
+ if ((ED_transform_calc_gizmo_stats(
C, &(struct TransformCalcParams) {
.use_local_axis = true,
}, &tbounds) == 0) ||
equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max))
{
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true);
}
else {
- manipulator_prepare_mat(C, v3d, rv3d, &tbounds);
+ gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
- WM_manipulator_set_flag(mpr, WM_MANIPULATOR_GRAB_CURSOR, true);
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
+ WM_gizmo_set_flag(gz, WM_GIZMO_GRAB_CURSOR, true);
float dims[3];
sub_v3_v3v3(dims, rv3d->tw_axis_max, rv3d->tw_axis_min);
- RNA_float_set_array(mpr->ptr, "dimensions", dims);
+ RNA_float_set_array(gz->ptr, "dimensions", dims);
mul_v3_fl(dims, 0.5f);
- copy_m4_m3(mpr->matrix_offset, rv3d->tw_axis_matrix);
- mid_v3_v3v3(mpr->matrix_offset[3], rv3d->tw_axis_max, rv3d->tw_axis_min);
- mul_m3_v3(rv3d->tw_axis_matrix, mpr->matrix_offset[3]);
+ copy_m4_m3(gz->matrix_offset, rv3d->tw_axis_matrix);
+ mid_v3_v3v3(gz->matrix_offset[3], rv3d->tw_axis_max, rv3d->tw_axis_min);
+ mul_m3_v3(rv3d->tw_axis_matrix, gz->matrix_offset[3]);
PropertyRNA *prop_center_override = NULL;
float center[3];
float center_global[3];
- int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z;
+ int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z;
for (int x = 0; x < 3; x++) {
center[0] = (float)(1 - x) * dims[0];
for (int y = 0; y < 3; y++) {
center[1] = (float)(1 - y) * dims[1];
for (int z = 0; z < 3; z++) {
center[2] = (float)(1 - z) * dims[2];
- struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, i);
+ struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, i);
if (prop_center_override == NULL) {
prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override");
}
- mul_v3_m4v3(center_global, mpr->matrix_offset, center);
+ mul_v3_m4v3(center_global, gz->matrix_offset, center);
RNA_property_float_set_array(&mpop->ptr, prop_center_override, center_global);
i++;
}
@@ -1739,45 +1746,45 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup
}
static void WIDGETGROUP_xform_cage_message_subscribe(
- const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus)
+ const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus)
{
Scene *scene = CTX_data_scene(C);
bScreen *screen = CTX_wm_screen(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, VIEW3D_WGT_xform_cage);
+ gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, ar, VIEW3D_GGT_xform_cage);
}
-static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
- struct XFormCageWidgetGroup *xmgroup = mgroup->customdata;
- wmManipulator *mpr = xmgroup->manipulator;
+ struct XFormCageWidgetGroup *xgzgroup = gzgroup->customdata;
+ wmGizmo *gz = xgzgroup->gizmo;
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
if (ob && ob->mode & OB_MODE_EDIT) {
- copy_m4_m4(mpr->matrix_space, ob->obmat);
+ copy_m4_m4(gz->matrix_space, ob->obmat);
}
else {
- unit_m4(mpr->matrix_space);
+ unit_m4(gz->matrix_space);
}
}
-void VIEW3D_WGT_xform_cage(wmManipulatorGroupType *wgt)
+void VIEW3D_GGT_xform_cage(wmGizmoGroupType *gzgt)
{
- wgt->name = "Transform Cage";
- wgt->idname = "VIEW3D_WGT_xform_cage";
+ gzgt->name = "Transform Cage";
+ gzgt->idname = "VIEW3D_GGT_xform_cage";
- wgt->flag |= WM_MANIPULATORGROUPTYPE_3D;
+ gzgt->flag |= WM_GIZMOGROUPTYPE_3D;
- wgt->mmap_params.spaceid = SPACE_VIEW3D;
- wgt->mmap_params.regionid = RGN_TYPE_WINDOW;
+ gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
+ gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
- wgt->poll = WIDGETGROUP_xform_cage_poll;
- wgt->setup = WIDGETGROUP_xform_cage_setup;
- wgt->refresh = WIDGETGROUP_xform_cage_refresh;
- wgt->message_subscribe = WIDGETGROUP_xform_cage_message_subscribe;
- wgt->draw_prepare = WIDGETGROUP_xform_cage_draw_prepare;
+ gzgt->poll = WIDGETGROUP_xform_cage_poll;
+ gzgt->setup = WIDGETGROUP_xform_cage_setup;
+ gzgt->refresh = WIDGETGROUP_xform_cage_refresh;
+ gzgt->message_subscribe = WIDGETGROUP_xform_cage_message_subscribe;
+ gzgt->draw_prepare = WIDGETGROUP_xform_cage_draw_prepare;
}
/** \} */
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index cfac908f976..9a9526537d1 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -496,7 +496,7 @@ static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* add temp handler */
WM_event_add_modal_handler(C, op);
- op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the manipulator only?
+ op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the gizmo only?
/* Use when modal input has some transformation to begin with. */
{
@@ -588,7 +588,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
}
if (flags & P_CENTER) {
- /* For manipulators that define their own center. */
+ /* For gizmos that define their own center. */
prop = RNA_def_property(ot->srna, "center_override", PROP_FLOAT, PROP_XYZ);
RNA_def_property_array(prop, 3);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
@@ -1137,14 +1137,18 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac
WM_keymap_add_item(keymap, "TRANSFORM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
+#ifdef USE_WM_KEYMAP_27X
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "use", true);
+#endif
WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
+ WM_keymap_add_panel(keymap, "VIEW3D_PT_snapping", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+
/* Will fall-through to texture-space transform. */
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_transform_axis_target", TKEY, KM_PRESS, KM_SHIFT, 0);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 48ec664d634..b67fd22dbff 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -124,13 +124,13 @@ int BIF_snappingSupported(Object *obedit)
}
#endif
-bool validSnap(TransInfo *t)
+bool validSnap(const TransInfo *t)
{
return (t->tsnap.status & (POINT_INIT | TARGET_INIT)) == (POINT_INIT | TARGET_INIT) ||
(t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT);
}
-bool activeSnap(TransInfo *t)
+bool activeSnap(const TransInfo *t)
{
return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) ||
((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT);
@@ -155,7 +155,6 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
if (validSnap(t)) {
TransSnapPoint *p;
- View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
float imat[4][4];
float size;
@@ -166,7 +165,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
invert_m4_m4(imat, rv3d->viewmat);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -191,7 +190,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
if (usingSnappingNormal(t) && validSnappingNormal(t)) {
immUniformColor4ubv(activeCol);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex3f(pos, t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
immVertex3f(pos, t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0],
t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1],
@@ -201,8 +200,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
immUnbindProgram();
- if (v3d->zbuf)
- GPU_depth_test(true);
+ GPU_depth_test(true);
}
}
else if (t->spacetype == SPACE_IMAGE) {
@@ -221,7 +219,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
GPU_blend(true);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -453,12 +451,12 @@ void resetSnapping(TransInfo *t)
t->tsnap.snapNodeBorder = 0;
}
-bool usingSnappingNormal(TransInfo *t)
+bool usingSnappingNormal(const TransInfo *t)
{
return t->tsnap.align;
}
-bool validSnappingNormal(TransInfo *t)
+bool validSnappingNormal(const TransInfo *t)
{
if (validSnap(t)) {
if (!is_zero_v3(t->tsnap.snapNormal)) {
@@ -791,7 +789,7 @@ void removeSnapPoint(TransInfo *t)
}
}
-void getSnapPoint(TransInfo *t, float vec[3])
+void getSnapPoint(const TransInfo *t, float vec[3])
{
if (t->tsnap.points.first) {
TransSnapPoint *p;
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index c090414bc22..14592149579 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -39,6 +39,8 @@
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
+#include "BLI_callbacks.h"
+#include "BLI_listbase.h"
#include "BLT_translation.h"
@@ -121,17 +123,50 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
return ED_undo_gpencil_step(C, step, undoname);
}
+ UndoStep *step_data_from_name = NULL;
+ int step_for_callback = step;
+ if (undoname != NULL) {
+ step_data_from_name = BKE_undosys_step_find_by_name(wm->undo_stack, undoname);
+ if (step_data_from_name == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* TODO(campbell), could use simple optimization. */
+ /* Pointers match on redo. */
+ step_for_callback = (
+ BLI_findindex(&wm->undo_stack->steps, step_data_from_name) <
+ BLI_findindex(&wm->undo_stack->steps, wm->undo_stack->step_active)) ? 1 : -1;
+ }
+
+ /* App-Handlers (pre). */
+ {
+ /* Note: ignore grease pencil for now. */
+ Main *bmain = CTX_data_main(C);
+ wm->op_undo_depth++;
+ BLI_callback_exec(bmain, &scene->id, (step_for_callback > 0) ? BLI_CB_EVT_UNDO_PRE : BLI_CB_EVT_REDO_PRE);
+ wm->op_undo_depth--;
+ }
+
+
/* Undo System */
{
if (undoname) {
- UndoStep *step_data = BKE_undosys_step_find_by_name(wm->undo_stack, undoname);
- BKE_undosys_step_undo_with_data(wm->undo_stack, C, step_data);
+ BKE_undosys_step_undo_with_data(wm->undo_stack, C, step_data_from_name);
}
else {
BKE_undosys_step_undo_compat_only(wm->undo_stack, C, step);
}
}
+ /* App-Handlers (post). */
+ {
+ Main *bmain = CTX_data_main(C);
+ scene = CTX_data_scene(C);
+ wm->op_undo_depth++;
+ BLI_callback_exec(bmain, &scene->id, step_for_callback > 0 ? BLI_CB_EVT_UNDO_PRE : BLI_CB_EVT_REDO_PRE);
+ wm->op_undo_depth--;
+ }
+
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL);
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index fa21facefc2..97ea0da6007 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -63,7 +63,7 @@ set(SRC
../include/ED_lattice.h
../include/ED_logic.h
../include/ED_markers.h
- ../include/ED_manipulator_library.h
+ ../include/ED_gizmo_library.h
../include/ED_mask.h
../include/ED_mball.h
../include/ED_mesh.h
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 65147d53b5d..35a77fcd4c0 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -342,7 +342,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
const float mval_dst[2] = {win->eventstate->x - ar->winrct.xmin,
win->eventstate->y - ar->winrct.ymin};
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -355,7 +355,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
immUniform1f("dash_width", 6.0f);
immUniform1f("dash_factor", 0.5f);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(shdr_pos, mval_src);
immVertex2fv(shdr_pos, mval_dst);
immEnd();
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index a139f0e3c87..f64182d2ad6 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -48,12 +48,16 @@
#include "ED_numinput.h"
#include "UI_interface.h"
+/* Numeric input which isn't allowing full numeric editing. */
+#define USE_FAKE_EDIT
/* NumInput.flag */
enum {
/* (1 << 8) and below are reserved for public flags! */
NUM_EDIT_FULL = (1 << 9), /* Enable full editing, with units and math operators support. */
+#ifdef USE_FAKE_EDIT
NUM_FAKE_EDITED = (1 << 10), /* Fake edited state (temp, avoids issue with backspace). */
+#endif
};
/* NumInput.val_flag[] */
@@ -61,8 +65,10 @@ enum {
/* (1 << 8) and below are reserved for public flags! */
NUM_EDITED = (1 << 9), /* User has edited this value somehow. */
NUM_INVALID = (1 << 10), /* Current expression for this value is invalid. */
+#ifdef USE_FAKE_EDIT
NUM_NEGATE = (1 << 11), /* Current expression's result has to be negated. */
NUM_INVERSE = (1 << 12), /* Current expression's result has to be inverted. */
+#endif
};
/* ************************** Functions *************************** */
@@ -109,6 +115,7 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings)
char before_cursor[NUM_STR_REP_LEN];
char val[16];
+#ifdef USE_FAKE_EDIT
if (n->val_flag[i] & NUM_NEGATE) {
heading_exp = (n->val_flag[i] & NUM_INVERSE) ? "-1/(" : "-(";
trailing_exp = ")";
@@ -117,6 +124,7 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings)
heading_exp = "1/(";
trailing_exp = ")";
}
+#endif
if (n->val_flag[i] & NUM_INVALID) {
BLI_strncpy(val, "Invalid", sizeof(val));
@@ -156,9 +164,11 @@ bool hasNumInput(const NumInput *n)
{
short i;
+#ifdef USE_FAKE_EDIT
if (n->flag & NUM_FAKE_EDITED) {
return true;
}
+#endif
for (i = 0; i <= n->idx_max; i++) {
if (n->val_flag[i] & NUM_EDITED) {
@@ -179,10 +189,13 @@ bool applyNumInput(NumInput *n, float *vec)
if (hasNumInput(n)) {
for (j = 0; j <= n->idx_max; j++) {
+#ifdef USE_FAKE_EDIT
if (n->flag & NUM_FAKE_EDITED) {
val = n->val[j];
}
- else {
+ else
+#endif
+ {
/* if AFFECTALL and no number typed and cursor not on number, use first number */
i = (n->flag & NUM_AFFECT_ALL && n->idx != j && !(n->val_flag[j] & NUM_EDITED)) ? 0 : j;
val = (!(n->val_flag[i] & NUM_EDITED) && n->val_flag[i] & NUM_NULL_ONE) ? 1.0f : n->val[i];
@@ -202,7 +215,9 @@ bool applyNumInput(NumInput *n, float *vec)
}
vec[j] = val;
}
+#ifdef USE_FAKE_EDIT
n->flag &= ~NUM_FAKE_EDITED;
+#endif
return true;
}
else {
@@ -261,6 +276,21 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
short dir = STRCUR_DIR_NEXT, mode = STRCUR_JUMP_NONE;
int cur;
+#ifdef USE_FAKE_EDIT
+ if (U.flag & USER_FLAG_NUMINPUT_ADVANCED)
+#endif
+ {
+ if ((event->ctrl == 0) && (event->alt == 0) && (event->ascii != '\0') &&
+ strchr("01234567890@%^&*-+/{}()[]<>.|", event->ascii))
+ {
+ if (!(n->flag & NUM_EDIT_FULL)) {
+ n->flag |= NUM_EDITED;
+ n->flag |= NUM_EDIT_FULL;
+ n->val_flag[idx] |= NUM_EDITED;
+ }
+ }
+ }
+
switch (event->type) {
case EVT_MODAL_MAP:
if (ELEM(event->val, NUM_MODAL_INCREMENT_UP, NUM_MODAL_INCREMENT_DOWN)) {
@@ -282,7 +312,11 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
n->val_flag[0] &= ~NUM_EDITED;
n->val_flag[1] &= ~NUM_EDITED;
n->val_flag[2] &= ~NUM_EDITED;
+#ifdef USE_FAKE_EDIT
n->flag |= NUM_FAKE_EDITED;
+#else
+ n->flag |= NUM_EDIT_FULL;
+#endif
updated = true;
break;
}
@@ -347,7 +381,9 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
}
return false;
case TABKEY:
+#ifdef USE_FAKE_EDIT
n->val_flag[idx] &= ~(NUM_NEGATE | NUM_INVERSE);
+#endif
idx = (idx + idx_max + (event->ctrl ? 0 : 2)) % (idx_max + 1);
n->idx = idx;
@@ -382,6 +418,8 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
}
break;
#endif
+
+#ifdef USE_FAKE_EDIT
case PADMINUS:
case MINUSKEY:
if (event->ctrl || !(n->flag & NUM_EDIT_FULL)) {
@@ -396,6 +434,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
updated = true;
}
break;
+#endif
case CKEY:
if (event->ctrl) {
/* Copy current str to the copypaste buffer. */
@@ -431,6 +470,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
ascii[0] = event->ascii;
}
+#ifdef USE_FAKE_EDIT
/* XXX Hack around keyboards without direct access to '=' nor '*'... */
if (ELEM(ascii[0], '=', '*')) {
if (!(n->flag & NUM_EDIT_FULL)) {
@@ -443,6 +483,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
return true;
}
}
+#endif
/* Up to this point, if we have a ctrl modifier, skip.
* This allows to still access most of modals' shortcuts even in numinput mode.
@@ -511,6 +552,8 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
UNUSED_VARS(C);
#endif /* WITH_PYTHON */
+
+#ifdef USE_FAKE_EDIT
if (n->val_flag[idx] & NUM_NEGATE) {
n->val[idx] = -n->val[idx];
}
@@ -526,6 +569,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
}
n->val[idx] = (float)val;
}
+#endif
if (UNLIKELY(!isfinite(n->val[idx]))) {
n->val[idx] = val_prev;
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 411c4838252..616f4eac2ad 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -90,9 +90,9 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
GPU_line_width(1.0f);
- gpuTranslate2fv(cursor);
+ GPU_matrix_translate_2fv(cursor);
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -104,7 +104,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
immUniform1f("dash_width", 8.0f);
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
immVertex2f(shdr_pos, -0.05f * x_fac, 0.0f);
immVertex2f(shdr_pos, 0.0f, 0.05f * y_fac);
@@ -123,7 +123,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
immUniform1f("dash_width", 2.0f);
- immBegin(GWN_PRIM_LINES, 8);
+ immBegin(GPU_PRIM_LINES, 8);
immVertex2f(shdr_pos, -0.020f * x_fac, 0.0f);
immVertex2f(shdr_pos, -0.1f * x_fac, 0.0f);
@@ -141,7 +141,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
immUnbindProgram();
- gpuTranslate2f(-cursor[0], -cursor[1]);
+ GPU_matrix_translate_2f(-cursor[0], -cursor[1]);
}
static int draw_uvs_face_check(Scene *scene)
@@ -168,7 +168,7 @@ static void draw_uvs_shadow(Object *obedit)
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -229,7 +229,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
}
}
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -241,7 +241,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
- immBegin(GWN_PRIM_TRI_FAN, efa->len);
+ immBegin(GPU_PRIM_TRI_FAN, efa->len);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -281,7 +281,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
immUniformColor3fv(col);
/* TODO: use editmesh tessface */
- immBegin(GWN_PRIM_TRI_FAN, efa->len);
+ immBegin(GPU_PRIM_TRI_FAN, efa->len);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -308,9 +308,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
col[3] = 0.5f; /* hard coded alpha, not that nice */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
@@ -353,7 +353,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
}
/* TODO: use editmesh tessface */
- immBegin(GWN_PRIM_TRI_FAN, efa->len);
+ immBegin(GPU_PRIM_TRI_FAN, efa->len);
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
a = fabsf(uvang[i] - ang[i]) / (float)M_PI;
@@ -393,7 +393,7 @@ static void draw_uvs_lineloop_bmfaces(BMesh *bm, const int cd_loop_uv_offset, co
MLoopUV *luv;
/* For more efficiency first transfer the entire buffer to vram. */
- Gwn_Batch *loop_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop);
+ GPUBatch *loop_batch = immBeginBatchAtMost(GPU_PRIM_LINE_LOOP, bm->totloop);
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
@@ -407,17 +407,17 @@ static void draw_uvs_lineloop_bmfaces(BMesh *bm, const int cd_loop_uv_offset, co
immEnd();
/* Then draw each face contour separately. */
- GWN_batch_program_use_begin(loop_batch);
+ GPU_batch_program_use_begin(loop_batch);
unsigned int index = 0;
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- GWN_batch_draw_range_ex(loop_batch, index, efa->len, false);
+ GPU_batch_draw_range_ex(loop_batch, index, efa->len, false);
index += efa->len;
}
- GWN_batch_program_use_end(loop_batch);
- GWN_batch_discard(loop_batch);
+ GPU_batch_program_use_end(loop_batch);
+ GPU_batch_discard(loop_batch);
}
static void draw_uvs_lineloop_mpoly(Mesh *me, MPoly *mpoly, unsigned int pos)
@@ -425,7 +425,7 @@ static void draw_uvs_lineloop_mpoly(Mesh *me, MPoly *mpoly, unsigned int pos)
MLoopUV *mloopuv;
int i;
- immBegin(GWN_PRIM_LINE_LOOP, mpoly->totloop);
+ immBegin(GPU_PRIM_LINE_LOOP, mpoly->totloop);
mloopuv = &me->mloopuv[mpoly->loopstart];
for (i = mpoly->totloop; i != 0; i--, mloopuv++) {
@@ -495,7 +495,7 @@ static void draw_uvs_other_mesh(Object *ob, const Image *curimage,
static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *curimage,
const int other_uv_filter)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -536,7 +536,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, ViewLayer *view_la
mloopuv = me->mloopuv;
}
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -548,7 +548,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, ViewLayer *view_la
if ((scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE) && mpoly->mat_nr != ob->actcol - 1)
continue;
- immBegin(GWN_PRIM_LINE_LOOP, mpoly->totloop);
+ immBegin(GPU_PRIM_LINE_LOOP, mpoly->totloop);
mloopuv = mloopuv_base + mpoly->loopstart;
for (b = 0; b < mpoly->totloop; b++, mloopuv++) {
@@ -658,13 +658,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
- Gwn_VertFormat *format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- Gwn_Batch *face_batch = immBeginBatch(GWN_PRIM_TRIS, tri_count * 3);
+ GPUBatch *face_batch = immBeginBatch(GPU_PRIM_TRIS, tri_count * 3);
for (unsigned int i = 0; i < em->tottri; i++) {
efa = em->looptris[i][0]->f;
if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
@@ -686,9 +686,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immEnd();
/* XXX performance: we should not create and throw away result. */
- GWN_batch_draw(face_batch);
- GWN_batch_program_use_end(face_batch);
- GWN_batch_discard(face_batch);
+ GPU_batch_draw(face_batch);
+ GPU_batch_program_use_end(face_batch);
+ GPU_batch_discard(face_batch);
immUnbindProgram();
@@ -712,7 +712,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
}
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
switch (sima->dt_uv) {
case SI_UVDT_DASH:
@@ -751,8 +751,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
/* For more efficiency first transfer the entire buffer to vram. */
- Gwn_Batch *loop_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop);
- Gwn_VertBuf *loop_vbo = loop_batch->verts[0];
+ GPUBatch *loop_batch = immBeginBatchAtMost(GPU_PRIM_LINE_LOOP, bm->totloop);
+ GPUVertBuf *loop_vbo = loop_batch->verts[0];
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
@@ -765,18 +765,18 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immEnd();
/* Then draw each face contour separately. */
- if (loop_vbo->vertex_ct != 0) {
- GWN_batch_program_use_begin(loop_batch);
+ if (loop_vbo->vertex_len != 0) {
+ GPU_batch_program_use_begin(loop_batch);
unsigned int index = 0, loop_vbo_count;
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- GWN_batch_draw_range_ex(loop_batch, index, efa->len, false);
+ GPU_batch_draw_range_ex(loop_batch, index, efa->len, false);
index += efa->len;
}
loop_vbo_count = index;
- GWN_batch_program_use_end(loop_batch);
+ GPU_batch_program_use_end(loop_batch);
immUnbindProgram();
@@ -790,14 +790,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
if (interpedges) {
/* Create a color buffer. */
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static uint shdr_col;
- if (format.attrib_ct == 0) {
- shdr_col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ shdr_col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
}
- Gwn_VertBuf *vbo_col = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo_col, loop_vbo_count);
+ GPUVertBuf *vbo_col = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo_col, loop_vbo_count);
index = 0;
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
@@ -806,36 +806,36 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
sel = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
- GWN_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2);
+ GPU_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2);
}
}
/* Reuse the UV buffer and add the color buffer. */
- GWN_batch_vertbuf_add_ex(loop_batch, vbo_col, true);
+ GPU_batch_vertbuf_add_ex(loop_batch, vbo_col, true);
/* Now draw each face contour separately with another builtin program. */
- GWN_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR);
- gpuBindMatrices(loop_batch->interface);
+ GPU_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR);
+ GPU_matrix_bind(loop_batch->interface);
- GWN_batch_program_use_begin(loop_batch);
+ GPU_batch_program_use_begin(loop_batch);
index = 0;
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- GWN_batch_draw_range_ex(loop_batch, index, efa->len, false);
+ GPU_batch_draw_range_ex(loop_batch, index, efa->len, false);
index += efa->len;
}
- GWN_batch_program_use_end(loop_batch);
+ GPU_batch_program_use_end(loop_batch);
}
else {
- Gwn_VertFormat *format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
/* Use batch here to avoid problems with `IMM_BUFFER_SIZE`. */
- Gwn_Batch *flat_edges_batch = immBeginBatchAtMost(GWN_PRIM_LINES, loop_vbo_count * 2);
+ GPUBatch *flat_edges_batch = immBeginBatchAtMost(GPU_PRIM_LINES, loop_vbo_count * 2);
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
@@ -852,27 +852,27 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
immEnd();
- GWN_batch_draw(flat_edges_batch);
- GWN_batch_discard(flat_edges_batch);
+ GPU_batch_draw(flat_edges_batch);
+ GPU_batch_discard(flat_edges_batch);
immUnbindProgram();
}
}
else {
- GWN_batch_uniform_4fv(loop_batch, "color", col2);
+ GPU_batch_uniform_4fv(loop_batch, "color", col2);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* no nice edges */
- GWN_batch_program_use_begin(loop_batch);
+ GPU_batch_program_use_begin(loop_batch);
index = 0;
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- GWN_batch_draw_range_ex(loop_batch, index, efa->len, false);
+ GPU_batch_draw_range_ex(loop_batch, index, efa->len, false);
index += efa->len;
}
- GWN_batch_program_use_end(loop_batch);
+ GPU_batch_program_use_end(loop_batch);
immUnbindProgram();
}
}
@@ -881,7 +881,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immUnbindProgram();
}
- GWN_batch_discard(loop_batch);
+ GPU_batch_discard(loop_batch);
if (sima->flag & SI_SMOOTH_UV) {
GPU_line_smooth(false);
@@ -894,16 +894,16 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
float cent[2];
bool col_set = false;
- Gwn_VertFormat *format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE);
GPU_point_size(pointsize);
- immBeginAtMost(GWN_PRIM_POINTS, bm->totface);
+ immBeginAtMost(GPU_PRIM_POINTS, bm->totface);
/* unselected faces */
@@ -955,7 +955,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
/* 6. draw uv vertices */
if (drawfaces != 2) { /* 2 means Mesh Face Mode */
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -964,7 +964,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
GPU_point_size(pointsize);
- immBeginAtMost(GWN_PRIM_POINTS, bm->totloop);
+ immBeginAtMost(GPU_PRIM_POINTS, bm->totloop);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
@@ -984,7 +984,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
GPU_point_size(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0));
imm_cpack(0xFF);
- immBeginAtMost(GWN_PRIM_POINTS, bm->totloop);
+ immBeginAtMost(GPU_PRIM_POINTS, bm->totloop);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
@@ -1004,7 +1004,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immUniformThemeColor(TH_VERTEX_SELECT);
GPU_point_size(pointsize);
- immBeginAtMost(GWN_PRIM_POINTS, bm->totloop);
+ immBeginAtMost(GPU_PRIM_POINTS, bm->totloop);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 8a00b542eed..51e2c1b6334 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -971,7 +971,7 @@ static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa
for (iterv = first; iterv; iterv = iterv->next) {
if (iterv->separate)
first = iterv;
- if (iterv->f == BM_elem_index_get(efa))
+ if (iterv->poly_index == BM_elem_index_get(efa))
return first;
}
@@ -993,9 +993,9 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1,
if (iterv2->separate && iterv2 != first2)
break;
- if (iterv1->f == iterv2->f) {
+ if (iterv1->poly_index == iterv2->poly_index) {
/* if face already tagged, don't do this edge */
- efa = BM_face_at_index(em->bm, iterv1->f);
+ efa = BM_face_at_index(em->bm, iterv1->poly_index);
if (BM_elem_flag_test(efa, BM_ELEM_TAG))
return false;
@@ -1019,8 +1019,8 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1,
if (iterv2->separate && iterv2 != first2)
break;
- if (iterv1->f == iterv2->f) {
- efa = BM_face_at_index(em->bm, iterv1->f);
+ if (iterv1->poly_index == iterv2->poly_index) {
+ efa = BM_face_at_index(em->bm, iterv1->poly_index);
BM_elem_flag_enable(efa, BM_ELEM_TAG);
break;
}
@@ -1231,18 +1231,19 @@ static void uv_select_linked_multi(
for (iterv = vlist; iterv; iterv = iterv->next) {
if (iterv->separate)
startv = iterv;
- if (iterv->f == a)
+ if (iterv->poly_index == a)
break;
}
for (iterv = startv; iterv; iterv = iterv->next) {
if ((startv != iterv) && (iterv->separate))
break;
- else if (!flag[iterv->f]) {
- flag[iterv->f] = 1;
- stack[stacksize] = iterv->f;
+ else if (!flag[iterv->poly_index]) {
+ flag[iterv->poly_index] = 1;
+ stack[stacksize] = iterv->poly_index;
stacksize++;
}
+
}
}
}
@@ -2742,7 +2743,7 @@ static void uv_select_flush_from_tag_sticky_loc_internal(
if (vlist_iter->separate)
start_vlist = vlist_iter;
- if (efa_index == vlist_iter->f)
+ if (efa_index == vlist_iter->poly_index)
break;
vlist_iter = vlist_iter->next;
@@ -2754,12 +2755,12 @@ static void uv_select_flush_from_tag_sticky_loc_internal(
if (vlist_iter != start_vlist && vlist_iter->separate)
break;
- if (efa_index != vlist_iter->f) {
+ if (efa_index != vlist_iter->poly_index) {
BMLoop *l_other;
- efa_vlist = BM_face_at_index(em->bm, vlist_iter->f);
+ efa_vlist = BM_face_at_index(em->bm, vlist_iter->poly_index);
/* tf_vlist = BM_ELEM_CD_GET_VOID_P(efa_vlist, cd_poly_tex_offset); */ /* UNUSED */
- l_other = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex);
+ l_other = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->loop_of_poly_index);
uvedit_uv_select_set(em, scene, l_other, select, false, cd_loop_uv_offset);
}
@@ -4178,14 +4179,14 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
v1coincident = 0;
separated2 = 0;
- efa1 = BM_face_at_index(bm, mv1->f);
+ efa1 = BM_face_at_index(bm, mv1->poly_index);
mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)];
for (mv2 = mvinit2; mv2; mv2 = mv2->next) {
if (mv2->separate)
mv2sep = mv2;
- efa2 = BM_face_at_index(bm, mv2->f);
+ efa2 = BM_face_at_index(bm, mv2->poly_index);
if (efa1 == efa2) {
/* if v1 is not coincident no point in comparing */
if (v1coincident) {
@@ -4445,7 +4446,9 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "UV_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "UV_OT_select_all", AKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+ kmi = WM_keymap_add_item(keymap, "UV_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "UV_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
@@ -4461,7 +4464,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "clear", true);
/* unwrap */
- WM_keymap_add_item(keymap, "UV_OT_unwrap", EKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "UV_OT_unwrap", UKEY, KM_PRESS, 0, 0);
#ifdef USE_WM_KEYMAP_27X
WM_keymap_add_item(keymap, "UV_OT_minimize_stretch", VKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "UV_OT_pack_islands", PKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 9091f3eff0b..18f1bc872c0 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -489,9 +489,10 @@ static void stitch_calculate_island_snapping(
int face_preview_pos = preview_position[BM_elem_index_get(element->l->f)].data_position;
stitch_uv_rotate(rotation_mat, island_stitch_data[i].medianPoint,
- preview->preview_polys + face_preview_pos + 2 * element->tfindex, state->aspect);
+ preview->preview_polys + face_preview_pos + 2 * element->loop_of_poly_index,
+ state->aspect);
- add_v2_v2(preview->preview_polys + face_preview_pos + 2 * element->tfindex,
+ add_v2_v2(preview->preview_polys + face_preview_pos + 2 * element->loop_of_poly_index,
island_stitch_data[i].translation);
}
}
@@ -907,7 +908,7 @@ static void stitch_propagate_uv_final_position(
else {
int face_preview_pos = preview_position[BM_elem_index_get(element_iter->l->f)].data_position;
if (face_preview_pos != STITCH_NO_PREVIEW) {
- copy_v2_v2(preview->preview_polys + face_preview_pos + 2 * element_iter->tfindex,
+ copy_v2_v2(preview->preview_polys + face_preview_pos + 2 * element_iter->loop_of_poly_index,
final_position[index].uv);
}
}
@@ -1546,13 +1547,13 @@ static void stitch_calculate_edge_normal(BMEditMesh *em, UvEdge *edge, float *no
/**
*/
-static void stitch_draw_vbo(Gwn_VertBuf *vbo, Gwn_PrimType prim_type, const float col[4])
+static void stitch_draw_vbo(GPUVertBuf *vbo, GPUPrimType prim_type, const float col[4])
{
- Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR);
- GWN_batch_uniform_4fv(batch, "color", col);
- GWN_batch_draw(batch);
- GWN_batch_discard(batch);
+ GPUBatch *batch = GPU_batch_create_ex(prim_type, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR);
+ GPU_batch_uniform_4fv(batch, "color", col);
+ GPU_batch_draw(batch);
+ GPU_batch_discard(batch);
}
/* TODO make things pretier : store batches inside StitchPreviewer instead of the bare verts pos */
@@ -1562,25 +1563,25 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
unsigned int num_line = 0, num_tri, tri_idx = 0, line_idx = 0;
StitchState *state = (StitchState *)arg;
StitchPreviewer *stitch_preview = state->stitch_preview;
- Gwn_VertBuf *vbo, *vbo_line;
+ GPUVertBuf *vbo, *vbo_line;
float col[4];
- static Gwn_VertFormat format = { 0 };
+ static GPUVertFormat format = { 0 };
static unsigned int pos_id;
- if (format.attrib_ct == 0) {
- pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ if (format.attr_len == 0) {
+ pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
GPU_blend(true);
/* Static Tris */
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_ACTIVE, col);
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, stitch_preview->num_static_tris * 3);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, stitch_preview->num_static_tris * 3);
for (int i = 0; i < stitch_preview->num_static_tris * 3; i++) {
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->static_tris[i * 2]);
+ GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->static_tris[i * 2]);
}
- stitch_draw_vbo(vbo, GWN_PRIM_TRIS, col);
+ stitch_draw_vbo(vbo, GPU_PRIM_TRIS, col);
/* Preview Polys */
@@ -1590,39 +1591,39 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
num_tri = num_line - 2 * stitch_preview->num_polys;
/* we need to convert the polys into triangles / lines */
- vbo = GWN_vertbuf_create_with_format(&format);
- vbo_line = GWN_vertbuf_create_with_format(&format);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ vbo_line = GPU_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, num_tri * 3);
- GWN_vertbuf_data_alloc(vbo_line, num_line * 2);
+ GPU_vertbuf_data_alloc(vbo, num_tri * 3);
+ GPU_vertbuf_data_alloc(vbo_line, num_line * 2);
for (int i = 0; i < stitch_preview->num_polys; i++) {
BLI_assert(stitch_preview->uvs_per_polygon[i] >= 3);
/* Start line */
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]);
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + 2]);
+ GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]);
+ GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + 2]);
for (j = 1; j < stitch_preview->uvs_per_polygon[i] - 1; ++j) {
- GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index]);
- GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]);
- GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]);
+ GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index]);
+ GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]);
+ GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]);
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]);
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]);
+ GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]);
+ GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]);
}
/* Closing line */
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]);
+ GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]);
/* j = uvs_per_polygon[i] - 1*/
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j * 2]);
+ GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j * 2]);
index += stitch_preview->uvs_per_polygon[i] * 2;
}
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_FACE, col);
- stitch_draw_vbo(vbo, GWN_PRIM_TRIS, col);
+ stitch_draw_vbo(vbo, GPU_PRIM_TRIS, col);
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_EDGE, col);
- stitch_draw_vbo(vbo_line, GWN_PRIM_LINES, col);
+ stitch_draw_vbo(vbo_line, GPU_PRIM_LINES, col);
GPU_blend(false);
@@ -1632,37 +1633,37 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE) * 2.0f);
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col);
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable);
for (int i = 0; i < stitch_preview->num_stitchable; i++) {
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]);
+ GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]);
}
- stitch_draw_vbo(vbo, GWN_PRIM_POINTS, col);
+ stitch_draw_vbo(vbo, GPU_PRIM_POINTS, col);
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_UNSTITCHABLE, col);
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable);
for (int i = 0; i < stitch_preview->num_unstitchable; i++) {
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]);
+ GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]);
}
- stitch_draw_vbo(vbo, GWN_PRIM_POINTS, col);
+ stitch_draw_vbo(vbo, GPU_PRIM_POINTS, col);
}
else {
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col);
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable * 2);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable * 2);
for (int i = 0; i < stitch_preview->num_stitchable * 2; i++) {
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]);
+ GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]);
}
- stitch_draw_vbo(vbo, GWN_PRIM_LINES, col);
+ stitch_draw_vbo(vbo, GPU_PRIM_LINES, col);
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_UNSTITCHABLE, col);
- vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable * 2);
+ vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable * 2);
for (int i = 0; i < stitch_preview->num_unstitchable * 2; i++) {
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]);
+ GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]);
}
- stitch_draw_vbo(vbo, GWN_PRIM_LINES, col);
+ stitch_draw_vbo(vbo, GPU_PRIM_LINES, col);
}
}
@@ -2083,7 +2084,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
RNA_collection_add(op->ptr, "selection", &itemptr);
RNA_int_set(&itemptr, "face_index", BM_elem_index_get(element->l->f));
- RNA_int_set(&itemptr, "element_index", element->tfindex);
+ RNA_int_set(&itemptr, "element_index", element->loop_of_poly_index);
}
uvedit_live_unwrap_update(sima, scene, obedit);
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 27977c16b51..8273f3f1992 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -23,7 +23,7 @@
#
# ***** END GPL LICENSE BLOCK *****
-# WITH_OPENGL limits the visibility of the opengl headers to just gawain and bg_gpu,
+# WITH_OPENGL limits the visibility of the opengl headers to just GPU and bg_gpu,
# to more easily highlight codepadths in other libraries that need to be refactored,
# bf_gpu is allowed to have opengl regardless of this option.
@@ -50,7 +50,6 @@ set(INC
../../../intern/glew-mx
../../../intern/guardedalloc
../../../intern/smoke/extern
- ../../../intern/gawain
)
set(INC_SYS
@@ -58,13 +57,17 @@ set(INC_SYS
)
set(SRC
+ intern/gpu_attr_binding.c
intern/gpu_basic_shader.c
intern/gpu_batch.c
intern/gpu_batch_presets.c
+ intern/gpu_batch_utils.c
intern/gpu_buffers.c
intern/gpu_codegen.c
+ intern/gpu_context.cpp
intern/gpu_debug.c
intern/gpu_draw.c
+ intern/gpu_element.c
intern/gpu_extensions.c
intern/gpu_framebuffer.c
intern/gpu_immediate.c
@@ -72,13 +75,17 @@ set(SRC
intern/gpu_init_exit.c
intern/gpu_material.c
intern/gpu_matrix.c
+ intern/gpu_primitive.c
intern/gpu_select.c
intern/gpu_select_pick.c
intern/gpu_select_sample_query.c
intern/gpu_shader.c
+ intern/gpu_shader_interface.c
intern/gpu_state.c
intern/gpu_texture.c
intern/gpu_uniformbuffer.c
+ intern/gpu_vertex_buffer.c
+ intern/gpu_vertex_format.c
intern/gpu_viewport.c
shaders/gpu_shader_fx_lib.glsl
@@ -102,11 +109,14 @@ set(SRC
shaders/gpu_shader_smoke_frag.glsl
shaders/gpu_shader_smoke_vert.glsl
+ GPU_attr_binding.h
GPU_basic_shader.h
GPU_batch.h
GPU_buffers.h
+ GPU_common.h
GPU_debug.h
GPU_draw.h
+ GPU_element.h
GPU_extensions.h
GPU_framebuffer.h
GPU_glew.h
@@ -116,17 +126,26 @@ set(SRC
GPU_legacy_stubs.h
GPU_material.h
GPU_matrix.h
+ GPU_primitive.h
GPU_select.h
GPU_shader.h
+ GPU_shader_interface.h
GPU_state.h
GPU_texture.h
GPU_uniformbuffer.h
+ GPU_vertex_buffer.h
+ GPU_vertex_format.h
GPU_viewport.h
+ intern/gpu_attr_binding_private.h
+ intern/gpu_batch_private.h
intern/gpu_codegen.h
+ intern/gpu_context_private.h
+ intern/gpu_primitive_private.h
intern/gpu_private.h
intern/gpu_select_private.h
intern/gpu_shader_private.h
+ intern/gpu_vertex_format_private.h
)
data_to_c_simple(shaders/gpu_shader_depth_only_frag.glsl SRC)
diff --git a/source/blender/gpu/GPU_attr_binding.h b/source/blender/gpu/GPU_attr_binding.h
new file mode 100644
index 00000000000..186acacb71d
--- /dev/null
+++ b/source/blender/gpu/GPU_attr_binding.h
@@ -0,0 +1,42 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_attr_binding.h
+ * \ingroup gpu
+ *
+ * GPU vertex attribute binding
+ */
+
+#ifndef __GPU_ATTR_BINDING_H__
+#define __GPU_ATTR_BINDING_H__
+
+#include "GPU_common.h"
+
+typedef struct GPUAttrBinding {
+ uint64_t loc_bits; /* store 4 bits for each of the 16 attribs */
+ uint16_t enabled_bits; /* 1 bit for each attrib */
+} GPUAttrBinding;
+
+#endif /* __GPU_ATTR_BINDING_H__ */
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index b706bdbf189..bb67a90d619 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -15,60 +15,185 @@
* 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) 2016 Blender Foundation.
+ * The Original Code is Copyright (C) 2016 by Mike Erwin.
* All rights reserved.
*
- *
- * Contributor(s): Mike Erwin
+ * Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
-/* Batched geometry rendering is powered by the Gawain library.
- * This file contains any additions or modifications specific to Blender.
+/** \file blender/gpu/GPU_batch.h
+ * \ingroup gpu
+ *
+ * GPU geometry batch
+ * Contains VAOs + VBOs + Shader representing a drawable entity.
*/
#ifndef __GPU_BATCH_H__
#define __GPU_BATCH_H__
-#include "../../../intern/gawain/gawain/gwn_batch.h"
-#include "../../../intern/gawain/gawain/gwn_batch_private.h"
+#include "GPU_vertex_buffer.h"
+#include "GPU_element.h"
+#include "GPU_shader_interface.h"
+#include "GPU_shader.h"
-struct rctf;
+typedef enum {
+ GPU_BATCH_READY_TO_FORMAT,
+ GPU_BATCH_READY_TO_BUILD,
+ GPU_BATCH_BUILDING,
+ GPU_BATCH_READY_TO_DRAW
+} GPUBatchPhase;
-// TODO: CMake magic to do this:
-// #include "gawain/batch.h"
+#define GPU_BATCH_VBO_MAX_LEN 3
+#define GPU_BATCH_VAO_STATIC_LEN 3
+#define GPU_BATCH_VAO_DYN_ALLOC_COUNT 16
-#include "BLI_compiler_attrs.h"
-#include "BLI_sys_types.h"
+typedef struct GPUBatch {
+ /* geometry */
+ GPUVertBuf *verts[GPU_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */
+ GPUVertBuf *inst; /* instance attribs */
+ GPUIndexBuf *elem; /* NULL if element list not needed */
+ uint32_t gl_prim_type;
-#include "GPU_shader.h"
+ /* cached values (avoid dereferencing later) */
+ uint32_t vao_id;
+ uint32_t program;
+ const struct GPUShaderInterface *interface;
+
+ /* book-keeping */
+ uint owns_flag;
+ struct GPUContext *context; /* used to free all vaos. this implies all vaos were created under the same context. */
+ GPUBatchPhase phase;
+ bool program_in_use;
+
+ /* Vao management: remembers all geometry state (vertex attrib bindings & element buffer)
+ * for each shader interface. Start with a static number of vaos and fallback to dynamic count
+ * if necessary. Once a batch goes dynamic it does not go back. */
+ bool is_dynamic_vao_count;
+ union {
+ /* Static handle count */
+ struct {
+ const struct GPUShaderInterface *interfaces[GPU_BATCH_VAO_STATIC_LEN];
+ uint32_t vao_ids[GPU_BATCH_VAO_STATIC_LEN];
+ } static_vaos;
+ /* Dynamic handle count */
+ struct {
+ uint count;
+ const struct GPUShaderInterface **interfaces;
+ uint32_t *vao_ids;
+ } dynamic_vaos;
+ };
+
+ /* XXX This is the only solution if we want to have some data structure using
+ * batches as key to identify nodes. We must destroy these nodes with this callback. */
+ void (*free_callback)(struct GPUBatch *, void *);
+ void *callback_data;
+} GPUBatch;
+
+enum {
+ GPU_BATCH_OWNS_VBO = (1 << 0),
+ /* each vbo index gets bit-shifted */
+ GPU_BATCH_OWNS_INSTANCES = (1 << 30),
+ GPU_BATCH_OWNS_INDEX = (1 << 31),
+};
+
+GPUBatch *GPU_batch_create_ex(GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag);
+void GPU_batch_init_ex(GPUBatch *, GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag);
+GPUBatch *GPU_batch_duplicate(GPUBatch *batch_src);
+
+#define GPU_batch_create(prim, verts, elem) \
+ GPU_batch_create_ex(prim, verts, elem, 0)
+#define GPU_batch_init(batch, prim, verts, elem) \
+ GPU_batch_init_ex(batch, prim, verts, elem, 0)
+
+void GPU_batch_discard(GPUBatch *); /* verts & elem are not discarded */
+
+void GPU_batch_vao_cache_clear(GPUBatch *);
+
+void GPU_batch_callback_free_set(GPUBatch *, void (*callback)(GPUBatch *, void *), void *);
+
+void GPU_batch_instbuf_set(GPUBatch *, GPUVertBuf *, bool own_vbo); /* Instancing */
+
+int GPU_batch_vertbuf_add_ex(GPUBatch *, GPUVertBuf *, bool own_vbo);
+
+#define GPU_batch_vertbuf_add(batch, verts) \
+ GPU_batch_vertbuf_add_ex(batch, verts, false)
+
+void GPU_batch_program_set_no_use(GPUBatch *, uint32_t program, const GPUShaderInterface *);
+void GPU_batch_program_set(GPUBatch *, uint32_t program, const GPUShaderInterface *);
+void GPU_batch_program_set_builtin(GPUBatch *batch, GPUBuiltinShader shader_id);
+/* Entire batch draws with one shader program, but can be redrawn later with another program. */
+/* Vertex shader's inputs must be compatible with the batch's vertex format. */
+
+void GPU_batch_program_use_begin(GPUBatch *); /* call before Batch_Uniform (temp hack?) */
+void GPU_batch_program_use_end(GPUBatch *);
+
+void GPU_batch_uniform_1ui(GPUBatch *, const char *name, int value);
+void GPU_batch_uniform_1i(GPUBatch *, const char *name, int value);
+void GPU_batch_uniform_1b(GPUBatch *, const char *name, bool value);
+void GPU_batch_uniform_1f(GPUBatch *, const char *name, float value);
+void GPU_batch_uniform_2f(GPUBatch *, const char *name, float x, float y);
+void GPU_batch_uniform_3f(GPUBatch *, const char *name, float x, float y, float z);
+void GPU_batch_uniform_4f(GPUBatch *, const char *name, float x, float y, float z, float w);
+void GPU_batch_uniform_2fv(GPUBatch *, const char *name, const float data[2]);
+void GPU_batch_uniform_3fv(GPUBatch *, const char *name, const float data[3]);
+void GPU_batch_uniform_4fv(GPUBatch *, const char *name, const float data[4]);
+void GPU_batch_uniform_2fv_array(GPUBatch *, const char *name, int len, const float *data);
+void GPU_batch_uniform_4fv_array(GPUBatch *, const char *name, int len, const float *data);
+void GPU_batch_uniform_mat4(GPUBatch *, const char *name, const float data[4][4]);
+
+void GPU_batch_draw(GPUBatch *);
+
+/* This does not bind/unbind shader and does not call GPU_matrix_bind() */
+void GPU_batch_draw_range_ex(GPUBatch *, int v_first, int v_count, bool force_instance);
+
+/* Does not even need batch */
+void GPU_draw_primitive(GPUPrimType, int v_count);
+
+#if 0 /* future plans */
+
+/* Can multiple batches share a GPUVertBuf? Use ref count? */
+
+
+/* We often need a batch with its own data, to be created and discarded together. */
+/* WithOwn variants reduce number of system allocations. */
+
+typedef struct BatchWithOwnVertexBuffer {
+ GPUBatch batch;
+ GPUVertBuf verts; /* link batch.verts to this */
+} BatchWithOwnVertexBuffer;
+
+typedef struct BatchWithOwnElementList {
+ GPUBatch batch;
+ GPUIndexBuf elem; /* link batch.elem to this */
+} BatchWithOwnElementList;
-/* Extend GWN_batch_program_set to use Blender’s library of built-in shader programs. */
+typedef struct BatchWithOwnVertexBufferAndElementList {
+ GPUBatch batch;
+ GPUIndexBuf elem; /* link batch.elem to this */
+ GPUVertBuf verts; /* link batch.verts to this */
+} BatchWithOwnVertexBufferAndElementList;
-/* gpu_batch.c */
-void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id) ATTR_NONNULL(1);
+GPUBatch *create_BatchWithOwnVertexBuffer(GPUPrimType, GPUVertFormat *, uint v_len, GPUIndexBuf *);
+GPUBatch *create_BatchWithOwnElementList(GPUPrimType, GPUVertBuf *, uint prim_len);
+GPUBatch *create_BatchWithOwnVertexBufferAndElementList(GPUPrimType, GPUVertFormat *, uint v_len, uint prim_len);
+/* verts: shared, own */
+/* elem: none, shared, own */
+GPUBatch *create_BatchInGeneral(GPUPrimType, VertexBufferStuff, ElementListStuff);
-Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded(
- const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
- ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded(
- const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
- ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+#endif /* future plans */
void gpu_batch_init(void);
void gpu_batch_exit(void);
-/* gpu_batch_presets.c */
-/* Only use by draw manager. Use the presets function instead for interface. */
-Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT;
-/* Replacement for gluSphere */
-Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT;
-Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT;
+/* Macros */
-void gpu_batch_presets_init(void);
-void gpu_batch_presets_register(Gwn_Batch *preset_batch);
-void gpu_batch_presets_reset(void);
-void gpu_batch_presets_exit(void);
+#define GPU_BATCH_DISCARD_SAFE(batch) do { \
+ if (batch != NULL) { \
+ GPU_batch_discard(batch); \
+ batch = NULL; \
+ } \
+} while (0)
-#endif /* __GPU_BATCH_H__ */
+#endif /* __GPU_BATCH_H__ */
diff --git a/source/blender/gpu/GPU_batch_presets.h b/source/blender/gpu/GPU_batch_presets.h
new file mode 100644
index 00000000000..a33b864c5b9
--- /dev/null
+++ b/source/blender/gpu/GPU_batch_presets.h
@@ -0,0 +1,52 @@
+/*
+ * ***** 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Mike Erwin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/* Batched geometry rendering is powered by the GPU library.
+ * This file contains any additions or modifications specific to Blender.
+ */
+
+#ifndef __GPU_BATCH_PRESETS_H__
+#define __GPU_BATCH_PRESETS_H__
+
+struct rctf;
+struct GPUVertFormat;
+
+#include "BLI_compiler_attrs.h"
+#include "BLI_sys_types.h"
+
+/* gpu_batch_presets.c */
+struct GPUVertFormat *GPU_batch_preset_format_3d(void);
+
+/* Replacement for gluSphere */
+struct GPUBatch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT;
+struct GPUBatch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT;
+
+void gpu_batch_presets_init(void);
+void gpu_batch_presets_register(struct GPUBatch *preset_batch);
+void gpu_batch_presets_reset(void);
+void gpu_batch_presets_exit(void);
+
+#endif /* __GPU_BATCH_PRESETS_H__ */
diff --git a/source/blender/gpu/GPU_batch_utils.h b/source/blender/gpu/GPU_batch_utils.h
new file mode 100644
index 00000000000..d558b7a1097
--- /dev/null
+++ b/source/blender/gpu/GPU_batch_utils.h
@@ -0,0 +1,40 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __GPU_BATCH_UTILS_H__
+#define __GPU_BATCH_UTILS_H__
+
+struct rctf;
+
+#include "BLI_compiler_attrs.h"
+#include "BLI_sys_types.h"
+
+/* gpu_batch_utils.c */
+struct GPUBatch *GPU_batch_tris_from_poly_2d_encoded(
+ const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
+ ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+struct GPUBatch *GPU_batch_wire_from_poly_2d_encoded(
+ const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
+ ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+
+/* Only use by draw manager. Use the presets function instead for interface. */
+struct GPUBatch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT;
+
+#endif /* __GPU_BATCH_UTILS_H__ */
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index f496c92f283..77801256463 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -91,7 +91,7 @@ void GPU_pbvh_grid_buffers_update(
const int update_flags);
/* draw */
-struct Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast);
+struct GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast);
/* debug PBVH draw */
void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos);
diff --git a/intern/opensubdiv/opensubdiv_intern.h b/source/blender/gpu/GPU_common.h
index ccb32f9d0ac..3acc7fad5c2 100644
--- a/intern/opensubdiv/opensubdiv_intern.h
+++ b/source/blender/gpu/GPU_common.h
@@ -15,32 +15,47 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2015 Blender Foundation.
+ * The Original Code is Copyright (C) 2016 by Mike Erwin.
* All rights reserved.
*
- * Contributor(s): Sergey Sharybin.
+ * Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __OPENSUBDIV_INTERN_H__
-#define __OPENSUBDIV_INTERN_H__
+/** \file blender/gpu/GPU_common.h
+ * \ingroup gpu
+ */
+
+#ifndef __GPU_COMMON_H__
+#define __GPU_COMMON_H__
+
+#define PROGRAM_NO_OPTI 0
-/* Perform full topology validation when exporting it to OpenSubdiv. */
-#ifdef NDEBUG
-# undef OPENSUBDIV_VALIDATE_TOPOLOGY
+#if defined(NDEBUG)
+# define TRUST_NO_ONE 0
#else
-/* TODO(sergey): Always disabled for now, the check doesn't handle
- * multiple non-manifolds from the OpenSubdiv side currently.
- */
-# undef OPENSUBDIV_VALIDATE_TOPOLOGY
+ /* strict error checking, enabled for debug builds during early development */
+# define TRUST_NO_ONE 1
#endif
-/* Currently OpenSubdiv expects topology to be oriented,
- * but sometimes it's handy to disable orientation code
- * to check whether it causes some weird issues by using
- * pre-oriented model.
- */
-#define OPENSUBDIV_ORIENT_TOPOLOGY
+#if defined(WITH_OPENGL)
+# include <GL/glew.h>
+#endif
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "BLI_sys_types.h"
+
+#if TRUST_NO_ONE
+# include <assert.h>
+#endif
+
+/* GPU_INLINE */
+#if defined(_MSC_VER)
+# define GPU_INLINE static __forceinline
+#else
+# define GPU_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
+#endif
-#endif /* __OPENSUBDIV_INTERN_H__ */
+#endif /* __GPU_COMMON_H__ */
diff --git a/source/blender/gpu/GPU_context.h b/source/blender/gpu/GPU_context.h
new file mode 100644
index 00000000000..3e32b64b281
--- /dev/null
+++ b/source/blender/gpu/GPU_context.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.
+ *
+ * The Original Code is Copyright (C) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_context.h
+ * \ingroup gpu
+ *
+ * This interface allow GPU to manage VAOs for mutiple context and threads.
+ */
+
+#ifndef __GPU_CONTEXT_H__
+#define __GPU_CONTEXT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "GPU_common.h"
+#include "GPU_batch.h"
+#include "GPU_shader_interface.h"
+
+typedef struct GPUContext GPUContext;
+
+GPUContext *GPU_context_create(void);
+void GPU_context_discard(GPUContext *);
+
+void GPU_context_active_set(GPUContext *);
+GPUContext *GPU_context_active_get(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GPU_CONTEXT_H__ */
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index ebce83d2a5f..028756bc739 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -101,7 +101,9 @@ void GPU_free_images_old(struct Main *bmain);
/* smoke drawing functions */
void GPU_free_smoke(struct SmokeModifierData *smd);
+void GPU_free_smoke_velocity(struct SmokeModifierData *smd);
void GPU_create_smoke(struct SmokeModifierData *smd, int highres);
+void GPU_create_smoke_velocity(struct SmokeModifierData *smd);
/* Delayed free of OpenGL buffers by main thread */
void GPU_free_unused_buffers(struct Main *bmain);
diff --git a/source/blender/gpu/GPU_element.h b/source/blender/gpu/GPU_element.h
new file mode 100644
index 00000000000..adc705ab641
--- /dev/null
+++ b/source/blender/gpu/GPU_element.h
@@ -0,0 +1,102 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_element.h
+ * \ingroup gpu
+ *
+ * GPU element list (AKA index buffer)
+ */
+
+#ifndef __GPU_ELEMENT_H__
+#define __GPU_ELEMENT_H__
+
+#include "GPU_primitive.h"
+
+#define GPU_TRACK_INDEX_RANGE 1
+
+#define GPU_PRIM_RESTART 0xFFFFFFFF
+
+typedef enum {
+ GPU_INDEX_U8, /* GL has this, Vulkan does not */
+ GPU_INDEX_U16,
+ GPU_INDEX_U32
+} GPUIndexBufType;
+
+typedef struct GPUIndexBuf {
+ uint index_len;
+#if GPU_TRACK_INDEX_RANGE
+ GPUIndexBufType index_type;
+ uint32_t gl_index_type;
+ uint min_index;
+ uint max_index;
+ uint base_index;
+#endif
+ uint32_t vbo_id; /* 0 indicates not yet sent to VRAM */
+ bool use_prim_restart;
+} GPUIndexBuf;
+
+void GPU_indexbuf_use(GPUIndexBuf *);
+uint GPU_indexbuf_size_get(const GPUIndexBuf *);
+
+typedef struct GPUIndexBufBuilder {
+ uint max_allowed_index;
+ uint max_index_len;
+ uint index_len;
+ GPUPrimType prim_type;
+ uint *data;
+ bool use_prim_restart;
+} GPUIndexBufBuilder;
+
+
+/* supports all primitive types. */
+void GPU_indexbuf_init_ex(GPUIndexBufBuilder *, GPUPrimType, uint index_len, uint vertex_len, bool use_prim_restart);
+
+/* supports only GPU_PRIM_POINTS, GPU_PRIM_LINES and GPU_PRIM_TRIS. */
+void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len);
+
+void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *, uint v);
+void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *);
+
+void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder *, uint v);
+void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder *, uint v1, uint v2);
+void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3);
+void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3, uint v4);
+
+GPUIndexBuf *GPU_indexbuf_build(GPUIndexBufBuilder *);
+void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *, GPUIndexBuf *);
+
+void GPU_indexbuf_discard(GPUIndexBuf *);
+
+
+/* Macros */
+
+#define GPU_INDEXBUF_DISCARD_SAFE(elem) do { \
+ if (elem != NULL) { \
+ GPU_indexbuf_discard(elem); \
+ elem = NULL; \
+ } \
+} while (0)
+
+#endif /* __GPU_ELEMENT_H__ */
diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h
index 084ee4c0459..04357d6a927 100644
--- a/source/blender/gpu/GPU_framebuffer.h
+++ b/source/blender/gpu/GPU_framebuffer.h
@@ -117,7 +117,7 @@ void GPU_framebuffer_texture_detach_slot(
GPU_framebuffer_config_array(*(_fb), config, (sizeof(config) / sizeof(GPUAttachment))); \
} while (0)
-void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_ct);
+void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len);
#define GPU_ATTACHMENT_NONE \
{.tex = NULL, .layer = -1, .mip = 0}
@@ -179,7 +179,8 @@ void GPU_framebuffer_recursive_downsample(
* - wrapper around framebuffer and texture for simple offscreen drawing
*/
-GPUOffScreen *GPU_offscreen_create(int width, int height, int samples,
+GPUOffScreen *GPU_offscreen_create(
+ int width, int height, int samples,
bool depth, bool high_bitdepth, char err_out[256]);
void GPU_offscreen_free(GPUOffScreen *ofs);
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save);
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 2a2692e6baf..c8a4ea6a837 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -24,29 +24,113 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/* Immediate mode rendering is powered by the Gawain library.
- * This file contains any additions or modifications specific to Blender.
+/** \file blender/gpu/GPU_immediate.h
+ * \ingroup gpu
+ *
+ * GPU immediate mode work-alike
*/
#ifndef __GPU_IMMEDIATE_H__
#define __GPU_IMMEDIATE_H__
-#include "../../../intern/gawain/gawain/gwn_immediate.h"
-#include "../../../intern/gawain/gawain/gwn_imm_util.h"
+#include "GPU_vertex_format.h"
+#include "GPU_primitive.h"
+#include "GPU_shader_interface.h"
+#include "GPU_batch.h"
+#include "GPU_immediate_util.h"
+#include "GPU_shader.h"
-// TODO: CMake magic to do this:
-// #include "gawain/gwn_immediate.h"
-// #include "gawain/gwn_imm_util.h"
+GPUVertFormat *immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */
-#include "GPU_shader.h"
+void immBindProgram(uint32_t program, const GPUShaderInterface *); /* every immBegin must have a program bound first. */
+void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */
+
+void immBegin(GPUPrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */
+void immBeginAtMost(GPUPrimType, uint max_vertex_len); /* can supply fewer vertices. */
+void immEnd(void); /* finishes and draws. */
+
+/* ImmBegin a batch, then use standard immFunctions as usual. */
+/* ImmEnd will finalize the batch instead of drawing. */
+/* Then you can draw it as many times as you like! Partially replaces the need for display lists. */
+GPUBatch *immBeginBatch(GPUPrimType, uint vertex_len);
+GPUBatch *immBeginBatchAtMost(GPUPrimType, uint vertex_len);
+
+/* Provide attribute values that can change per vertex. */
+/* First vertex after immBegin must have all its attributes specified. */
+/* Skipped attributes will continue using the previous value for that attrib_id. */
+void immAttrib1f(uint attrib_id, float x);
+void immAttrib2f(uint attrib_id, float x, float y);
+void immAttrib3f(uint attrib_id, float x, float y, float z);
+void immAttrib4f(uint attrib_id, float x, float y, float z, float w);
+
+void immAttrib2i(uint attrib_id, int x, int y);
+
+void immAttrib1u(uint attrib_id, uint x);
+
+void immAttrib2s(uint attrib_id, short x, short y);
+
+void immAttrib2fv(uint attrib_id, const float data[2]);
+void immAttrib3fv(uint attrib_id, const float data[3]);
+void immAttrib4fv(uint attrib_id, const float data[4]);
+
+void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b);
+void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
+
+void immAttrib3ubv(uint attrib_id, const unsigned char data[4]);
+void immAttrib4ubv(uint attrib_id, const unsigned char data[4]);
+
+/* Explicitly skip an attribute. */
+/* This advanced option kills automatic value copying for this attrib_id. */
+void immSkipAttrib(uint attrib_id);
+
+/* Provide one last attribute value & end the current vertex. */
+/* This is most often used for 2D or 3D position (similar to glVertex). */
+void immVertex2f(uint attrib_id, float x, float y);
+void immVertex3f(uint attrib_id, float x, float y, float z);
+void immVertex4f(uint attrib_id, float x, float y, float z, float w);
+
+void immVertex2i(uint attrib_id, int x, int y);
+
+void immVertex2s(uint attrib_id, short x, short y);
+
+void immVertex2fv(uint attrib_id, const float data[2]);
+void immVertex3fv(uint attrib_id, const float data[3]);
+
+void immVertex2iv(uint attrib_id, const int data[2]);
+
+/* Provide uniform values that don't change for the entire draw call. */
+void immUniform1i(const char *name, int x);
+void immUniform4iv(const char *name, const int data[4]);
+void immUniform1f(const char *name, float x);
+void immUniform2f(const char *name, float x, float y);
+void immUniform2fv(const char *name, const float data[2]);
+void immUniform3f(const char *name, float x, float y, float z);
+void immUniform3fv(const char *name, const float data[3]);
+void immUniformArray3fv(const char *name, const float *data, int count);
+void immUniform4f(const char *name, float x, float y, float z, float w);
+void immUniform4fv(const char *name, const float data[4]);
+void immUniformArray4fv(const char *bare_name, const float *data, int count);
+void immUniformMatrix4fv(const char *name, const float data[4][4]);
+
+/* Convenience functions for setting "uniform vec4 color". */
+/* The rgb functions have implicit alpha = 1.0. */
+void immUniformColor4f(float r, float g, float b, float a);
+void immUniformColor4fv(const float rgba[4]);
+void immUniformColor3f(float r, float g, float b);
+void immUniformColor3fv(const float rgb[3]);
+void immUniformColor3fvAlpha(const float rgb[3], float a);
+
+void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b);
+void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
+void immUniformColor3ubv(const unsigned char rgb[3]);
+void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a);
+void immUniformColor4ubv(const unsigned char rgba[4]);
/* Extend immBindProgram to use Blender’s library of built-in shader programs.
* Use immUnbindProgram() when done. */
void immBindBuiltinProgram(GPUBuiltinShader shader_id);
-/*
- * Extend immUniformColor to take Blender's themes
- */
+/* Extend immUniformColor to take Blender's themes */
void immUniformThemeColor(int color_id);
void immUniformThemeColor3(int color_id);
void immUniformThemeColorShade(int color_id, int offset);
@@ -55,4 +139,10 @@ void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int
void immUniformThemeColorBlend(int color_id1, int color_id2, float fac);
void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset);
+/* These are called by the system -- not part of drawing API. */
+void immInit(void);
+void immActivate(void);
+void immDeactivate(void);
+void immDestroy(void);
+
#endif /* __GPU_IMMEDIATE_H__ */
diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index c31d477ff5b..58555e287b0 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -27,6 +27,15 @@
#ifndef __GPU_IMMEDIATE_UTIL_H__
#define __GPU_IMMEDIATE_UTIL_H__
+/* Draw 2D rectangles (replaces glRect functions) */
+/* caller is reponsible for vertex format & shader */
+void immRectf(uint pos, float x1, float y1, float x2, float y2);
+void immRecti(uint pos, int x1, int y1, int x2, int y2);
+
+/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GPU_PRIM_TRIS. */
+void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]);
+void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]);
+
void imm_cpack(uint x);
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments);
@@ -35,7 +44,7 @@ void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int
void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments);
void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments);
-/* use this version when Gwn_VertFormat has a vec3 position */
+/* use this version when GPUVertFormat has a vec3 position */
void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments);
void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments);
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index a65c09152ee..f2c029f643e 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -104,7 +104,7 @@ typedef enum GPUBuiltin {
GPU_AUTO_BUMPSCALE = (1 << 7),
GPU_CAMERA_TEXCO_FACTORS = (1 << 8),
GPU_PARTICLE_SCALAR_PROPS = (1 << 9),
- GPU_PARTICLE_LOCATION = (1 << 10),
+ GPU_PARTICLE_LOCATION = (1 << 10),
GPU_PARTICLE_VELOCITY = (1 << 11),
GPU_PARTICLE_ANG_VELOCITY = (1 << 12),
GPU_LOC_TO_VIEW_MATRIX = (1 << 13),
@@ -241,7 +241,7 @@ GPUBuiltin GPU_get_material_builtins(GPUMaterial *material);
void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], short *falloff_type, float *sharpness);
struct GPUUniformBuffer *GPU_material_sss_profile_get(
- GPUMaterial *material, int sample_ct, struct GPUTexture **tex_profile);
+ GPUMaterial *material, int sample_len, struct GPUTexture **tex_profile);
/* High level functions to create and use GPU materials */
GPUMaterial *GPU_material_from_nodetree_find(
@@ -254,11 +254,6 @@ void GPU_material_free(struct ListBase *gpumaterial);
void GPU_materials_free(struct Main *bmain);
-void GPU_material_orphans_init(void);
-void GPU_material_orphans_exit(void);
-/* This has to be called from a thread with an ogl context bound. */
-void GPU_material_orphans_delete(void);
-
struct Scene *GPU_material_scene(GPUMaterial *material);
GPUMatType GPU_Material_get_type(GPUMaterial *material);
struct GPUPass *GPU_material_get_pass(GPUMaterial *material);
@@ -268,8 +263,9 @@ GPUMaterialStatus GPU_material_status(GPUMaterial *mat);
struct GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material);
void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs);
-void GPU_material_vertex_attributes(GPUMaterial *material,
- struct GPUVertexAttribs *attrib);
+void GPU_material_vertex_attributes(
+ GPUMaterial *material,
+ struct GPUVertexAttribs *attrib);
bool GPU_material_do_color_management(GPUMaterial *mat);
bool GPU_material_use_domain_surface(GPUMaterial *mat);
diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h
index f22c0cd5c4d..23f19ed19cd 100644
--- a/source/blender/gpu/GPU_matrix.h
+++ b/source/blender/gpu/GPU_matrix.h
@@ -38,81 +38,81 @@
extern "C" {
#endif
-struct Gwn_ShaderInterface;
+struct GPUShaderInterface;
-void gpuMatrixReset(void); /* to Identity transform & empty stack */
+void GPU_matrix_reset(void); /* to Identity transform & empty stack */
/* ModelView Matrix (2D or 3D) */
-void gpuPushMatrix(void); /* TODO: PushCopy vs PushIdentity? */
-void gpuPopMatrix(void);
+void GPU_matrix_push(void); /* TODO: PushCopy vs PushIdentity? */
+void GPU_matrix_pop(void);
-void gpuLoadIdentity(void);
+void GPU_matrix_identity_set(void);
-void gpuScaleUniform(float factor);
+void GPU_matrix_scale_1f(float factor);
/* 3D ModelView Matrix */
-void gpuLoadMatrix(const float m[4][4]);
-void gpuMultMatrix(const float m[4][4]);
+void GPU_matrix_set(const float m[4][4]);
+void GPU_matrix_mul(const float m[4][4]);
-void gpuTranslate3f(float x, float y, float z);
-void gpuTranslate3fv(const float vec[3]);
-void gpuScale3f(float x, float y, float z);
-void gpuScale3fv(const float vec[3]);
-void gpuRotate3f(float deg, float x, float y, float z); /* axis of rotation should be a unit vector */
-void gpuRotate3fv(float deg, const float axis[3]); /* axis of rotation should be a unit vector */
-void gpuRotateAxis(float deg, char axis); /* TODO: enum for axis? */
+void GPU_matrix_translate_3f(float x, float y, float z);
+void GPU_matrix_translate_3fv(const float vec[3]);
+void GPU_matrix_scale_3f(float x, float y, float z);
+void GPU_matrix_scale_3fv(const float vec[3]);
+void GPU_matrix_rotate_3f(float deg, float x, float y, float z); /* axis of rotation should be a unit vector */
+void GPU_matrix_rotate_3fv(float deg, const float axis[3]); /* axis of rotation should be a unit vector */
+void GPU_matrix_rotate_axis(float deg, char axis); /* TODO: enum for axis? */
-void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ);
+void GPU_matrix_look_at(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ);
/* TODO: variant that takes eye[3], center[3], up[3] */
/* 2D ModelView Matrix */
-void gpuTranslate2f(float x, float y);
-void gpuTranslate2fv(const float vec[2]);
-void gpuScale2f(float x, float y);
-void gpuScale2fv(const float vec[2]);
-void gpuRotate2D(float deg);
+void GPU_matrix_translate_2f(float x, float y);
+void GPU_matrix_translate_2fv(const float vec[2]);
+void GPU_matrix_scale_2f(float x, float y);
+void GPU_matrix_scale_2fv(const float vec[2]);
+void GPU_matrix_rotate_2d(float deg);
/* Projection Matrix (2D or 3D) */
-void gpuPushProjectionMatrix(void);
-void gpuPopProjectionMatrix(void);
+void GPU_matrix_push_projection(void);
+void GPU_matrix_pop_projection(void);
/* 3D Projection Matrix */
-void gpuLoadIdentityProjectionMatrix(void);
-void gpuLoadProjectionMatrix(const float m[4][4]);
+void GPU_matrix_identity_projection_set(void);
+void GPU_matrix_projection_set(const float m[4][4]);
-void gpuOrtho(float left, float right, float bottom, float top, float near, float far);
-void gpuFrustum(float left, float right, float bottom, float top, float near, float far);
-void gpuPerspective(float fovy, float aspect, float near, float far);
+void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far);
+void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far);
+void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far);
/* 3D Projection between Window and World Space */
-void gpuProject(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]);
-bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]);
+void GPU_matrix_project(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]);
+bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]);
/* 2D Projection Matrix */
-void gpuOrtho2D(float left, float right, float bottom, float top);
+void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top);
/* functions to get matrix values */
-const float (*gpuGetModelViewMatrix(float m[4][4]))[4];
-const float (*gpuGetProjectionMatrix(float m[4][4]))[4];
-const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4];
+const float (*GPU_matrix_model_view_get(float m[4][4]))[4];
+const float (*GPU_matrix_projection_get(float m[4][4]))[4];
+const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4];
-const float (*gpuGetNormalMatrix(float m[3][3]))[3];
-const float (*gpuGetNormalMatrixInverse(float m[3][3]))[3];
+const float (*GPU_matrix_normal_get(float m[3][3]))[3];
+const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3];
/* set uniform values for currently bound shader */
-void gpuBindMatrices(const struct Gwn_ShaderInterface *);
-bool gpuMatricesDirty(void); /* since last bind */
+void GPU_matrix_bind(const struct GPUShaderInterface *);
+bool GPU_matrix_dirty_get(void); /* since last bind */
/* Python API needs to be able to inspect the stack so errors raise exceptions instead of crashing. */
@@ -177,14 +177,14 @@ int GPU_matrix_stack_level_get_projection(void);
#endif /* C11 */
/* make matrix inputs generic, to avoid warnings */
-# define gpuMultMatrix(x) gpuMultMatrix(_GPU_MAT4_CONST_CAST(x))
-# define gpuLoadMatrix(x) gpuLoadMatrix(_GPU_MAT4_CONST_CAST(x))
-# define gpuLoadProjectionMatrix(x) gpuLoadProjectionMatrix(_GPU_MAT4_CONST_CAST(x))
-# define gpuGetModelViewMatrix(x) gpuGetModelViewMatrix(_GPU_MAT4_CAST(x))
-# define gpuGetProjectionMatrix(x) gpuGetProjectionMatrix(_GPU_MAT4_CAST(x))
-# define gpuGetModelViewProjectionMatrix(x) gpuGetModelViewProjectionMatrix(_GPU_MAT4_CAST(x))
-# define gpuGetNormalMatrix(x) gpuGetNormalMatrix(_GPU_MAT3_CAST(x))
-# define gpuGetNormalMatrixInverse(x) gpuGetNormalMatrixInverse(_GPU_MAT3_CAST(x))
+# define GPU_matrix_mul(x) GPU_matrix_mul(_GPU_MAT4_CONST_CAST(x))
+# define GPU_matrix_set(x) GPU_matrix_set(_GPU_MAT4_CONST_CAST(x))
+# define GPU_matrix_projection_set(x) GPU_matrix_projection_set(_GPU_MAT4_CONST_CAST(x))
+# define GPU_matrix_model_view_get(x) GPU_matrix_model_view_get(_GPU_MAT4_CAST(x))
+# define GPU_matrix_projection_get(x) GPU_matrix_projection_get(_GPU_MAT4_CAST(x))
+# define GPU_matrix_model_view_projection_get(x) GPU_matrix_model_view_projection_get(_GPU_MAT4_CAST(x))
+# define GPU_matrix_normal_get(x) GPU_matrix_normal_get(_GPU_MAT3_CAST(x))
+# define GPU_matrix_normal_inverse_get(x) GPU_matrix_normal_inverse_get(_GPU_MAT3_CAST(x))
#endif /* SUPPRESS_GENERIC_MATRIX_API */
#endif /* __GPU_MATRIX_H__ */
diff --git a/source/blender/gpu/GPU_primitive.h b/source/blender/gpu/GPU_primitive.h
new file mode 100644
index 00000000000..bcedfa56ab1
--- /dev/null
+++ b/source/blender/gpu/GPU_primitive.h
@@ -0,0 +1,65 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_primitive.h
+ * \ingroup gpu
+ *
+ * GPU geometric primitives
+ */
+
+#ifndef __GPU_PRIMITIVE_H__
+#define __GPU_PRIMITIVE_H__
+
+#include "GPU_common.h"
+
+typedef enum {
+ GPU_PRIM_POINTS,
+ GPU_PRIM_LINES,
+ GPU_PRIM_TRIS,
+ GPU_PRIM_LINE_STRIP,
+ GPU_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */
+ GPU_PRIM_TRI_STRIP,
+ GPU_PRIM_TRI_FAN,
+
+ GPU_PRIM_LINES_ADJ,
+ GPU_PRIM_TRIS_ADJ,
+ GPU_PRIM_LINE_STRIP_ADJ,
+
+ GPU_PRIM_NONE
+} GPUPrimType;
+
+/* what types of primitives does each shader expect? */
+typedef enum {
+ GPU_PRIM_CLASS_NONE = 0,
+ GPU_PRIM_CLASS_POINT = (1 << 0),
+ GPU_PRIM_CLASS_LINE = (1 << 1),
+ GPU_PRIM_CLASS_SURFACE = (1 << 2),
+ GPU_PRIM_CLASS_ANY = GPU_PRIM_CLASS_POINT | GPU_PRIM_CLASS_LINE | GPU_PRIM_CLASS_SURFACE
+} GPUPrimClass;
+
+GPUPrimClass GPU_primtype_class(GPUPrimType);
+bool GPU_primtype_belongs_to_class(GPUPrimType, GPUPrimClass);
+
+#endif /* __GPU_PRIMITIVE_H__ */
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index f831d495ad0..b1a05faf863 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -89,10 +89,12 @@ void *GPU_shader_get_interface(GPUShader *shader);
int GPU_shader_get_uniform(GPUShader *shader, const char *name);
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin);
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name);
-void GPU_shader_uniform_vector(GPUShader *shader, int location, int length,
- int arraysize, const float *value);
-void GPU_shader_uniform_vector_int(GPUShader *shader, int location, int length,
- int arraysize, const int *value);
+void GPU_shader_uniform_vector(
+ GPUShader *shader, int location, int length,
+ int arraysize, const float *value);
+void GPU_shader_uniform_vector_int(
+ GPUShader *shader, int location, int length,
+ int arraysize, const int *value);
void GPU_shader_uniform_buffer(GPUShader *shader, int location, struct GPUUniformBuffer *ubo);
void GPU_shader_uniform_texture(GPUShader *shader, int location, struct GPUTexture *tex);
@@ -375,7 +377,7 @@ typedef struct GPUVertexAttribs {
int glinfoindoex;
int gltexco;
int attribid;
- char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
+ char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
} layer[GPU_MAX_ATTRIB];
int totlayer;
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h
new file mode 100644
index 00000000000..458a49a366b
--- /dev/null
+++ b/source/blender/gpu/GPU_shader_interface.h
@@ -0,0 +1,104 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_shader_interface.h
+ * \ingroup gpu
+ *
+ * GPU shader interface (C --> GLSL)
+ */
+
+#ifndef __GPU_SHADER_INTERFACE_H__
+#define __GPU_SHADER_INTERFACE_H__
+
+#include "GPU_common.h"
+
+typedef enum {
+ GPU_UNIFORM_NONE = 0, /* uninitialized/unknown */
+
+ GPU_UNIFORM_MODEL, /* mat4 ModelMatrix */
+ GPU_UNIFORM_VIEW, /* mat4 ViewMatrix */
+ GPU_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */
+ GPU_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */
+ GPU_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */
+ GPU_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */
+
+ GPU_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */
+ GPU_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */
+ GPU_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */
+ GPU_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */
+ GPU_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */
+
+ GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */
+ GPU_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */
+ GPU_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */
+ GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */
+
+ GPU_UNIFORM_COLOR, /* vec4 color */
+ GPU_UNIFORM_EYE, /* vec3 eye */
+ GPU_UNIFORM_CALLID, /* int callId */
+
+ GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */
+
+ GPU_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */
+} GPUUniformBuiltin;
+
+typedef struct GPUShaderInput {
+ struct GPUShaderInput *next;
+ uint32_t name_offset;
+ uint name_hash;
+ GPUUniformBuiltin builtin_type; /* only for uniform inputs */
+ uint32_t gl_type; /* only for attrib inputs */
+ int32_t size; /* only for attrib inputs */
+ int32_t location;
+} GPUShaderInput;
+
+#define GPU_NUM_SHADERINTERFACE_BUCKETS 257
+#define GPU_SHADERINTERFACE_REF_ALLOC_COUNT 16
+
+typedef struct GPUShaderInterface {
+ int32_t program;
+ uint32_t name_buffer_offset;
+ GPUShaderInput *attrib_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS];
+ GPUShaderInput *uniform_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS];
+ GPUShaderInput *ubo_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS];
+ GPUShaderInput *builtin_uniforms[GPU_NUM_UNIFORMS];
+ char *name_buffer;
+ struct GPUBatch **batches; /* references to batches using this interface */
+ uint batches_len;
+} GPUShaderInterface;
+
+GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id);
+void GPU_shaderinterface_discard(GPUShaderInterface *);
+
+const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *, const char *name);
+const GPUShaderInput *GPU_shaderinterface_uniform_builtin(const GPUShaderInterface *, GPUUniformBuiltin);
+const GPUShaderInput *GPU_shaderinterface_ubo(const GPUShaderInterface *, const char *name);
+const GPUShaderInput *GPU_shaderinterface_attr(const GPUShaderInterface *, const char *name);
+
+/* keep track of batches using this interface */
+void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *, struct GPUBatch *);
+void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface *, struct GPUBatch *);
+
+#endif /* __GPU_SHADER_INTERFACE_H__ */
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index 2d7ab6cd54c..16627fec42b 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -27,7 +27,7 @@
#ifndef __GPU_STATE_H__
#define __GPU_STATE_H__
- /* These map directly to the GL_ blend functions, to minimize API add as needed*/
+/* These map directly to the GL_ blend functions, to minimize API add as needed*/
typedef enum GPUBlendFunction {
GPU_ONE,
GPU_SRC_ALPHA,
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 341abeba72f..1ddf801e166 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -41,7 +41,7 @@ extern "C" {
struct Image;
struct ImageUser;
struct PreviewImage;
-struct Gwn_VertBuf;
+struct GPUVertBuf;
struct GPUFrameBuffer;
typedef struct GPUTexture GPUTexture;
@@ -144,8 +144,23 @@ typedef enum GPUTextureFormat {
GPU_DEPTH_COMPONENT16,
} GPUTextureFormat;
+typedef enum GPUDataFormat {
+ GPU_DATA_FLOAT,
+ GPU_DATA_INT,
+ GPU_DATA_UNSIGNED_INT,
+ GPU_DATA_UNSIGNED_BYTE,
+ GPU_DATA_UNSIGNED_INT_24_8,
+ GPU_DATA_10_11_11_REV,
+} GPUDataFormat;
+
unsigned int GPU_texture_memory_usage_get(void);
+/* TODO make it static function again. (create function with GPUDataFormat exposed) */
+GPUTexture *GPU_texture_create_nD(
+ int w, int h, int d, int n, const void *pixels,
+ GPUTextureFormat tex_format, GPUDataFormat gpu_data_format, int samples,
+ const bool can_rescale, char err_out[256]);
+
GPUTexture *GPU_texture_create_1D(
int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
GPUTexture *GPU_texture_create_2D(
@@ -159,7 +174,7 @@ GPUTexture *GPU_texture_create_3D(
GPUTexture *GPU_texture_create_cube(
int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
GPUTexture *GPU_texture_create_from_vertbuf(
- struct Gwn_VertBuf *vert);
+ struct GPUVertBuf *vert);
GPUTexture *GPU_texture_create_buffer(
GPUTextureFormat data_type, const uint buffer);
@@ -168,22 +183,21 @@ GPUTexture *GPU_texture_from_blender(
struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time);
GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap);
-void GPU_texture_update(GPUTexture *tex, const void *pixels);
+void GPU_texture_add_mipmap(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl, const void *pixels);
+
+void GPU_texture_update(GPUTexture *tex, GPUDataFormat data_format, const void *pixels);
void GPU_texture_update_sub(
- GPUTexture *tex, const void *pixels,
+ GPUTexture *tex, GPUDataFormat gpu_data_format, const void *pixels,
int offset_x, int offset_y, int offset_z, int width, int height, int depth);
+void *GPU_texture_read(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl);
+
void GPU_invalid_tex_init(void);
void GPU_invalid_tex_bind(int mode);
void GPU_invalid_tex_free(void);
void GPU_texture_free(GPUTexture *tex);
-void GPU_texture_orphans_init(void);
-void GPU_texture_orphans_exit(void);
-/* This has to be called from a thread with an ogl context bound. */
-void GPU_texture_orphans_delete(void);
-
void GPU_texture_ref(GPUTexture *tex);
void GPU_texture_bind(GPUTexture *tex, int number);
void GPU_texture_unbind(GPUTexture *tex);
@@ -202,6 +216,7 @@ int GPU_texture_detach_framebuffer(GPUTexture *tex, struct GPUFrameBuffer *fb);
int GPU_texture_target(const GPUTexture *tex);
int GPU_texture_width(const GPUTexture *tex);
int GPU_texture_height(const GPUTexture *tex);
+int GPU_texture_layers(const GPUTexture *tex);
GPUTextureFormat GPU_texture_format(const GPUTexture *tex);
int GPU_texture_samples(const GPUTexture *tex);
bool GPU_texture_cube(const GPUTexture *tex);
@@ -210,6 +225,8 @@ bool GPU_texture_stencil(const GPUTexture *tex);
bool GPU_texture_integer(const GPUTexture *tex);
int GPU_texture_opengl_bindcode(const GPUTexture *tex);
+void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *size);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h
new file mode 100644
index 00000000000..db1309bcede
--- /dev/null
+++ b/source/blender/gpu/GPU_vertex_buffer.h
@@ -0,0 +1,144 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_vertex_buffer.h
+ * \ingroup gpu
+ *
+ * GPU vertex buffer
+ */
+
+#ifndef __GPU_VERTEX_BUFFER_H__
+#define __GPU_VERTEX_BUFFER_H__
+
+#include "GPU_vertex_format.h"
+
+#define VRAM_USAGE 1
+/* How to create a GPUVertBuf: */
+/* 1) verts = GPU_vertbuf_create() or GPU_vertbuf_init(verts) */
+/* 2) GPU_vertformat_attr_add(verts->format, ...) */
+/* 3) GPU_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format */
+/* 4) GPU_vertbuf_attr_fill(verts, pos, application_pos_buffer) */
+
+/* Is GPUVertBuf always used as part of a GPUBatch? */
+
+typedef enum {
+ /* can be extended to support more types */
+ GPU_USAGE_STREAM,
+ GPU_USAGE_STATIC, /* do not keep data in memory */
+ GPU_USAGE_DYNAMIC
+} GPUUsageType;
+
+typedef struct GPUVertBuf {
+ GPUVertFormat format;
+ uint vertex_len; /* number of verts we want to draw */
+ uint vertex_alloc; /* number of verts data */
+ bool dirty;
+ unsigned char *data; /* NULL indicates data in VRAM (unmapped) */
+ uint32_t vbo_id; /* 0 indicates not yet allocated */
+ GPUUsageType usage; /* usage hint for GL optimisation */
+} GPUVertBuf;
+
+GPUVertBuf *GPU_vertbuf_create(GPUUsageType);
+GPUVertBuf *GPU_vertbuf_create_with_format_ex(const GPUVertFormat *, GPUUsageType);
+
+#define GPU_vertbuf_create_with_format(format) \
+ GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_STATIC)
+
+void GPU_vertbuf_discard(GPUVertBuf *);
+
+void GPU_vertbuf_init(GPUVertBuf *, GPUUsageType);
+void GPU_vertbuf_init_with_format_ex(GPUVertBuf *, const GPUVertFormat *, GPUUsageType);
+
+#define GPU_vertbuf_init_with_format(verts, format) \
+ GPU_vertbuf_init_with_format_ex(verts, format, GPU_USAGE_STATIC)
+
+uint GPU_vertbuf_size_get(const GPUVertBuf *);
+void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len);
+void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len);
+void GPU_vertbuf_vertex_count_set(GPUVertBuf *, uint v_len);
+
+/* The most important set_attrib variant is the untyped one. Get it right first. */
+/* It takes a void* so the app developer is responsible for matching their app data types */
+/* to the vertex attribute's type and component count. They're in control of both, so this */
+/* should not be a problem. */
+
+void GPU_vertbuf_attr_set(GPUVertBuf *, uint a_idx, uint v_idx, const void *data);
+void GPU_vertbuf_attr_fill(GPUVertBuf *, uint a_idx, const void *data); /* tightly packed, non interleaved input data */
+void GPU_vertbuf_attr_fill_stride(GPUVertBuf *, uint a_idx, uint stride, const void *data);
+
+/* For low level access only */
+typedef struct GPUVertBufRaw {
+ uint size;
+ uint stride;
+ unsigned char *data;
+ unsigned char *data_init;
+#if TRUST_NO_ONE
+ /* Only for overflow check */
+ unsigned char *_data_end;
+#endif
+} GPUVertBufRaw;
+
+GPU_INLINE void *GPU_vertbuf_raw_step(GPUVertBufRaw *a)
+{
+ unsigned char *data = a->data;
+ a->data += a->stride;
+#if TRUST_NO_ONE
+ assert(data < a->_data_end);
+#endif
+ return (void *)data;
+}
+
+GPU_INLINE uint GPU_vertbuf_raw_used(GPUVertBufRaw *a)
+{
+ return ((a->data - a->data_init) / a->stride);
+}
+
+void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *, uint a_idx, GPUVertBufRaw *access);
+
+/* TODO: decide whether to keep the functions below */
+/* doesn't immediate mode satisfy these needs? */
+
+/* void setAttrib1f(uint a_idx, uint v_idx, float x); */
+/* void setAttrib2f(uint a_idx, unsigned v_idx, float x, float y); */
+/* void setAttrib3f(unsigned a_idx, unsigned v_idx, float x, float y, float z); */
+/* void setAttrib4f(unsigned a_idx, unsigned v_idx, float x, float y, float z, float w); */
+
+/* void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b); */
+/* void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a); */
+
+void GPU_vertbuf_use(GPUVertBuf *);
+
+/* Metrics */
+uint GPU_vertbuf_get_memory_usage(void);
+
+/* Macros */
+#define GPU_VERTBUF_DISCARD_SAFE(verts) do { \
+ if (verts != NULL) { \
+ GPU_vertbuf_discard(verts); \
+ verts = NULL; \
+ } \
+} while (0)
+
+#endif /* __GPU_VERTEX_BUFFER_H__ */
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h
new file mode 100644
index 00000000000..7e0038e3473
--- /dev/null
+++ b/source/blender/gpu/GPU_vertex_format.h
@@ -0,0 +1,103 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_vertex_format.h
+ * \ingroup gpu
+ *
+ * GPU vertex format
+ */
+
+#ifndef __GPU_VERTEX_FORMAT_H__
+#define __GPU_VERTEX_FORMAT_H__
+
+#include "GPU_common.h"
+
+#define GPU_VERT_ATTR_MAX_LEN 16
+#define GPU_VERT_ATTR_MAX_NAMES 3
+#define GPU_VERT_ATTR_NAME_AVERAGE_LEN 11
+#define GPU_VERT_ATTR_NAMES_BUF_LEN ((GPU_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GPU_VERT_ATTR_MAX_LEN)
+
+typedef enum {
+ GPU_COMP_I8,
+ GPU_COMP_U8,
+ GPU_COMP_I16,
+ GPU_COMP_U16,
+ GPU_COMP_I32,
+ GPU_COMP_U32,
+
+ GPU_COMP_F32,
+
+ GPU_COMP_I10
+} GPUVertCompType;
+
+typedef enum {
+ GPU_FETCH_FLOAT,
+ GPU_FETCH_INT,
+ GPU_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */
+ GPU_FETCH_INT_TO_FLOAT /* 127 (any int type) -> 127.0 */
+} GPUVertFetchMode;
+
+typedef struct GPUVertAttr {
+ GPUVertFetchMode fetch_mode;
+ GPUVertCompType comp_type;
+ uint gl_comp_type;
+ uint comp_len; /* 1 to 4 or 8 or 12 or 16 */
+ uint sz; /* size in bytes, 1 to 64 */
+ uint offset; /* from beginning of vertex, in bytes */
+ uint name_len; /* up to GPU_VERT_ATTR_MAX_NAMES */
+ const char *name[GPU_VERT_ATTR_MAX_NAMES];
+} GPUVertAttr;
+
+typedef struct GPUVertFormat {
+ uint attr_len; /* 0 to 16 (GPU_VERT_ATTR_MAX_LEN) */
+ uint name_len; /* total count of active vertex attrib */
+ uint stride; /* stride in bytes, 1 to 256 */
+ uint name_offset;
+ bool packed;
+ char names[GPU_VERT_ATTR_NAMES_BUF_LEN];
+ GPUVertAttr attribs[GPU_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */
+} GPUVertFormat;
+
+void GPU_vertformat_clear(GPUVertFormat *);
+void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src);
+
+uint GPU_vertformat_attr_add(
+ GPUVertFormat *, const char *name,
+ GPUVertCompType, uint comp_len, GPUVertFetchMode);
+void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias);
+
+/* format conversion */
+
+typedef struct GPUPackedNormal {
+ int x : 10;
+ int y : 10;
+ int z : 10;
+ int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */
+} GPUPackedNormal;
+
+GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3]);
+GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3]);
+
+#endif /* __GPU_VERTEX_FORMAT_H__ */
diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c
new file mode 100644
index 00000000000..398b97c7f9d
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_attr_binding.c
@@ -0,0 +1,85 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_attr_binding.c
+ * \ingroup gpu
+ *
+ * GPU vertex attribute binding
+ */
+
+#include "GPU_attr_binding.h"
+#include "gpu_attr_binding_private.h"
+#include <stddef.h>
+#include <stdlib.h>
+
+#if GPU_VERT_ATTR_MAX_LEN != 16
+# error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16"
+#endif
+
+void AttribBinding_clear(GPUAttrBinding *binding)
+{
+ binding->loc_bits = 0;
+ binding->enabled_bits = 0;
+}
+
+uint read_attrib_location(const GPUAttrBinding *binding, uint a_idx)
+{
+#if TRUST_NO_ONE
+ assert(a_idx < GPU_VERT_ATTR_MAX_LEN);
+ assert(binding->enabled_bits & (1 << a_idx));
+#endif
+ return (binding->loc_bits >> (4 * a_idx)) & 0xF;
+}
+
+static void write_attrib_location(GPUAttrBinding *binding, uint a_idx, uint location)
+{
+#if TRUST_NO_ONE
+ assert(a_idx < GPU_VERT_ATTR_MAX_LEN);
+ assert(location < GPU_VERT_ATTR_MAX_LEN);
+#endif
+ const uint shift = 4 * a_idx;
+ const uint64_t mask = ((uint64_t)0xF) << shift;
+ /* overwrite this attrib's previous location */
+ binding->loc_bits = (binding->loc_bits & ~mask) | (location << shift);
+ /* mark this attrib as enabled */
+ binding->enabled_bits |= 1 << a_idx;
+}
+
+void get_attrib_locations(const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface)
+{
+ AttribBinding_clear(binding);
+
+ for (uint a_idx = 0; a_idx < format->attr_len; ++a_idx) {
+ const GPUVertAttr *a = format->attribs + a_idx;
+ for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) {
+ const GPUShaderInput *input = GPU_shaderinterface_attr(shaderface, a->name[n_idx]);
+#if TRUST_NO_ONE
+ assert(input != NULL);
+ /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */
+#endif
+ write_attrib_location(binding, a_idx, input->location);
+ }
+ }
+}
diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h
new file mode 100644
index 00000000000..cb338b10aa4
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_attr_binding_private.h
@@ -0,0 +1,45 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_attr_binding_private.h
+ * \ingroup gpu
+ *
+ * GPU vertex attribute binding
+ */
+
+#ifndef __GPU_ATTR_BINDING_PRIVATE_H__
+#define __GPU_ATTR_BINDING_PRIVATE_H__
+
+#include "GPU_vertex_format.h"
+#include "GPU_shader_interface.h"
+
+void AttribBinding_clear(GPUAttrBinding *binding);
+
+void get_attrib_locations(
+ const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface);
+unsigned read_attrib_location(
+ const GPUAttrBinding *binding, unsigned a_idx);
+
+#endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_basic_shader.c b/source/blender/gpu/intern/gpu_basic_shader.c
index b720bed2d0c..61e8cf87038 100644
--- a/source/blender/gpu/intern/gpu_basic_shader.c
+++ b/source/blender/gpu/intern/gpu_basic_shader.c
@@ -82,7 +82,8 @@ const GLubyte stipple_halftone[128] = {
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55};
+ 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
+};
const GLubyte stipple_quarttone[128] = {
136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0,
@@ -92,7 +93,8 @@ const GLubyte stipple_quarttone[128] = {
136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0,
136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0,
136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0,
- 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0};
+ 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0,
+};
const GLubyte stipple_diag_stripes_pos[128] = {
0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe,
@@ -110,7 +112,8 @@ const GLubyte stipple_diag_stripes_pos[128] = {
0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01,
0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07,
0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f,
- 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f};
+ 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f,
+};
const GLubyte stipple_diag_stripes_neg[128] = {
0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01,
@@ -128,7 +131,8 @@ const GLubyte stipple_diag_stripes_neg[128] = {
0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe,
0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8,
0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0,
- 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80};
+ 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80,
+};
const GLubyte stipple_checker_8px[128] = {
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
@@ -138,7 +142,8 @@ const GLubyte stipple_checker_8px[128] = {
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255};
+ 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
+};
const GLubyte stipple_hexagon[128] = {
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
@@ -156,7 +161,8 @@ const GLubyte stipple_hexagon[128] = {
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22};
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+};
/* ********************************************* */
/* Init / exit */
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 59d88e81822..9b433a37a72 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -15,251 +15,646 @@
* 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) 2016 Blender Foundation.
+ * The Original Code is Copyright (C) 2016 by Mike Erwin.
* All rights reserved.
*
- * The Original Code is: all of this file.
- *
- * Contributor(s): Mike Erwin
+ * Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/gpu/intern/gpu_batch.c
* \ingroup gpu
+ *
+ * GPU geometry batch
+ * Contains VAOs + VBOs + Shader representing a drawable entity.
*/
-#include "MEM_guardedalloc.h"
+#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
+#include "GPU_matrix.h"
+#include "GPU_shader.h"
-#include "BLI_utildefines.h"
-#include "BLI_rect.h"
-#include "BLI_math.h"
-#include "BLI_polyfill_2d.h"
-#include "BLI_sort_utils.h"
+#include "gpu_batch_private.h"
+#include "gpu_context_private.h"
+#include "gpu_primitive_private.h"
+#include "gpu_shader_private.h"
+#include <stdlib.h>
+#include <string.h>
-#include "GPU_batch.h" /* own include */
-#include "gpu_shader_private.h"
+static void batch_update_program_bindings(GPUBatch *batch, uint v_first);
-/* -------------------------------------------------------------------- */
-/** \name Utilities
- * \{ */
+void GPU_batch_vao_cache_clear(GPUBatch *batch)
+{
+ if (batch->context == NULL) {
+ return;
+ }
+ if (batch->is_dynamic_vao_count) {
+ for (int i = 0; i < batch->dynamic_vaos.count; ++i) {
+ if (batch->dynamic_vaos.vao_ids[i]) {
+ GPU_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context);
+ }
+ if (batch->dynamic_vaos.interfaces[i]) {
+ GPU_shaderinterface_remove_batch_ref((GPUShaderInterface *)batch->dynamic_vaos.interfaces[i], batch);
+ }
+ }
+ free(batch->dynamic_vaos.interfaces);
+ free(batch->dynamic_vaos.vao_ids);
+ }
+ else {
+ for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) {
+ if (batch->static_vaos.vao_ids[i]) {
+ GPU_vao_free(batch->static_vaos.vao_ids[i], batch->context);
+ }
+ if (batch->static_vaos.interfaces[i]) {
+ GPU_shaderinterface_remove_batch_ref((GPUShaderInterface *)batch->static_vaos.interfaces[i], batch);
+ }
+ }
+ }
+ batch->is_dynamic_vao_count = false;
+ for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) {
+ batch->static_vaos.vao_ids[i] = 0;
+ batch->static_vaos.interfaces[i] = NULL;
+ }
+ gpu_context_remove_batch(batch->context, batch);
+ batch->context = NULL;
+}
-void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id)
+GPUBatch *GPU_batch_create_ex(
+ GPUPrimType prim_type, GPUVertBuf *verts, GPUIndexBuf *elem,
+ uint owns_flag)
{
- GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
- GWN_batch_program_set(batch, shader->program, shader->interface);
+ GPUBatch *batch = calloc(1, sizeof(GPUBatch));
+ GPU_batch_init_ex(batch, prim_type, verts, elem, owns_flag);
+ return batch;
}
-/** \} */
+void GPU_batch_init_ex(
+ GPUBatch *batch, GPUPrimType prim_type, GPUVertBuf *verts, GPUIndexBuf *elem,
+ uint owns_flag)
+{
+#if TRUST_NO_ONE
+ assert(verts != NULL);
+#endif
+ batch->verts[0] = verts;
+ for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; ++v) {
+ batch->verts[v] = NULL;
+ }
+ batch->inst = NULL;
+ batch->elem = elem;
+ batch->gl_prim_type = convert_prim_type_to_gl(prim_type);
+ batch->phase = GPU_BATCH_READY_TO_DRAW;
+ batch->is_dynamic_vao_count = false;
+ batch->owns_flag = owns_flag;
+ batch->free_callback = NULL;
+}
+/* This will share the VBOs with the new batch. */
+GPUBatch *GPU_batch_duplicate(GPUBatch *batch_src)
+{
+ GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0);
-/* -------------------------------------------------------------------- */
-/** \name Batch Creation
- * \{ */
+ batch->gl_prim_type = batch_src->gl_prim_type;
+ for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; ++v) {
+ batch->verts[v] = batch_src->verts[v];
+ }
+ return batch;
+}
-/**
- * Creates triangles from a byte-array of polygons.
- *
- * See 'make_shape_2d_from_blend.py' utility to create data to pass to this function.
- *
- * \param polys_flat: Pairs of X, Y coordinates (repeating to signify closing the polygon).
- * \param polys_flat_len: Length of the array (must be an even number).
- * \param rect: Optional region to map the byte 0..255 coords to. When not set use -1..1.
- */
-Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded(
- const uchar *polys_flat, uint polys_flat_len, const rctf *rect)
-{
- const uchar (*polys)[2] = (const void *)polys_flat;
- const uint polys_len = polys_flat_len / 2;
- BLI_assert(polys_flat_len == polys_len * 2);
-
- /* Over alloc in both cases */
- float (*verts)[2] = MEM_mallocN(sizeof(*verts) * polys_len, __func__);
- float (*verts_step)[2] = verts;
- uint (*tris)[3] = MEM_mallocN(sizeof(*tris) * polys_len, __func__);
- uint (*tris_step)[3] = tris;
-
- const float range_uchar[2] = {
- (rect ? (rect->xmax - rect->xmin) : 2.0f) / 255.0f,
- (rect ? (rect->ymax - rect->ymin) : 2.0f) / 255.0f,
- };
- const float min_uchar[2] = {
- (rect ? rect->xmin : -1.0f),
- (rect ? rect->ymin : -1.0f),
- };
-
- uint i_poly = 0;
- uint i_vert = 0;
- while (i_poly != polys_len) {
- for (uint j = 0; j < 2; j++) {
- verts[i_vert][j] = min_uchar[j] + ((float)polys[i_poly][j] * range_uchar[j]);
- }
- i_vert++;
- i_poly++;
- if (polys[i_poly - 1][0] == polys[i_poly][0] &&
- polys[i_poly - 1][1] == polys[i_poly][1])
- {
- const uint verts_step_len = (&verts[i_vert]) - verts_step;
- BLI_assert(verts_step_len >= 3);
- const uint tris_len = (verts_step_len - 2);
- BLI_polyfill_calc(verts_step, verts_step_len, -1, tris_step);
- /* offset indices */
- if (verts_step != verts) {
- uint *t = tris_step[0];
- const uint offset = (verts_step - verts);
- uint tot = tris_len * 3;
- while (tot--) {
- *t += offset;
- t++;
- }
- BLI_assert(t == tris_step[tris_len]);
+void GPU_batch_discard(GPUBatch *batch)
+{
+ if (batch->owns_flag & GPU_BATCH_OWNS_INDEX) {
+ GPU_indexbuf_discard(batch->elem);
+ }
+ if (batch->owns_flag & GPU_BATCH_OWNS_INSTANCES) {
+ GPU_vertbuf_discard(batch->inst);
+ }
+ if ((batch->owns_flag & ~GPU_BATCH_OWNS_INDEX) != 0) {
+ for (int v = 0; v < GPU_BATCH_VBO_MAX_LEN; ++v) {
+ if (batch->verts[v] == NULL) {
+ break;
+ }
+ if (batch->owns_flag & (1 << v)) {
+ GPU_vertbuf_discard(batch->verts[v]);
}
- verts_step += verts_step_len;
- tris_step += tris_len;
- i_poly++;
- /* ignore the duplicate point */
}
}
+ GPU_batch_vao_cache_clear(batch);
- /* We have vertices and tris, make a batch from this. */
- static Gwn_VertFormat format = {0};
- static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- }
-
- const uint verts_len = (verts_step - verts);
- const uint tris_len = (tris_step - tris);
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, verts_len);
-
- Gwn_VertBufRaw pos_step;
- GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
-
- for (uint i = 0; i < verts_len; i++) {
- copy_v2_v2(GWN_vertbuf_raw_step(&pos_step), verts[i]);
- }
-
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tris_len, verts_len);
- for (uint i = 0; i < tris_len; i++) {
- GWN_indexbuf_add_tri_verts(&elb, UNPACK3(tris[i]));
- }
- Gwn_IndexBuf *indexbuf = GWN_indexbuf_build(&elb);
-
- MEM_freeN(tris);
- MEM_freeN(verts);
-
- return GWN_batch_create_ex(
- GWN_PRIM_TRIS, vbo,
- indexbuf,
- GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
-}
-
-Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded(
- const uchar *polys_flat, uint polys_flat_len, const rctf *rect)
-{
- const uchar (*polys)[2] = (const void *)polys_flat;
- const uint polys_len = polys_flat_len / 2;
- BLI_assert(polys_flat_len == polys_len * 2);
-
- /* Over alloc */
- /* Lines are pairs of (x, y) byte locations packed into an int32_t. */
- int32_t *lines = MEM_mallocN(sizeof(*lines) * polys_len, __func__);
- int32_t *lines_step = lines;
-
- const float range_uchar[2] = {
- (rect ? (rect->xmax - rect->xmin) : 2.0f) / 255.0f,
- (rect ? (rect->ymax - rect->ymin) : 2.0f) / 255.0f,
- };
- const float min_uchar[2] = {
- (rect ? rect->xmin : -1.0f),
- (rect ? rect->ymin : -1.0f),
- };
-
- uint i_poly_prev = 0;
- uint i_poly = 0;
- while (i_poly != polys_len) {
- i_poly++;
- if (polys[i_poly - 1][0] == polys[i_poly][0] &&
- polys[i_poly - 1][1] == polys[i_poly][1])
- {
- const uchar (*polys_step)[2] = polys + i_poly_prev;
- const uint polys_step_len = i_poly - i_poly_prev;
- BLI_assert(polys_step_len >= 2);
- for (uint i_prev = polys_step_len - 1, i = 0; i < polys_step_len; i_prev = i++) {
- union {
- uint8_t as_u8[4];
- uint16_t as_u16[2];
- uint32_t as_u32;
- } data;
- data.as_u16[0] = *((const uint16_t *)polys_step[i_prev]);
- data.as_u16[1] = *((const uint16_t *)polys_step[i]);
- if (data.as_u16[0] > data.as_u16[1]) {
- SWAP(uint16_t, data.as_u16[0], data.as_u16[1]);
- }
- *lines_step = data.as_u32;
- lines_step++;
+ if (batch->free_callback) {
+ batch->free_callback(batch, batch->callback_data);
+ }
+ free(batch);
+}
+
+void GPU_batch_callback_free_set(GPUBatch *batch, void (*callback)(GPUBatch *, void *), void *user_data)
+{
+ batch->free_callback = callback;
+ batch->callback_data = user_data;
+}
+
+void GPU_batch_instbuf_set(GPUBatch *batch, GPUVertBuf *inst, bool own_vbo)
+{
+#if TRUST_NO_ONE
+ assert(inst != NULL);
+#endif
+ /* redo the bindings */
+ GPU_batch_vao_cache_clear(batch);
+
+ if (batch->inst != NULL && (batch->owns_flag & GPU_BATCH_OWNS_INSTANCES)) {
+ GPU_vertbuf_discard(batch->inst);
+ }
+ batch->inst = inst;
+
+ if (own_vbo) {
+ batch->owns_flag |= GPU_BATCH_OWNS_INSTANCES;
+ }
+ else {
+ batch->owns_flag &= ~GPU_BATCH_OWNS_INSTANCES;
+ }
+}
+
+/* Returns the index of verts in the batch. */
+int GPU_batch_vertbuf_add_ex(
+ GPUBatch *batch, GPUVertBuf *verts,
+ bool own_vbo)
+{
+ /* redo the bindings */
+ GPU_batch_vao_cache_clear(batch);
+
+ for (uint v = 0; v < GPU_BATCH_VBO_MAX_LEN; ++v) {
+ if (batch->verts[v] == NULL) {
+#if TRUST_NO_ONE
+ /* for now all VertexBuffers must have same vertex_len */
+ assert(verts->vertex_len == batch->verts[0]->vertex_len);
+#endif
+ batch->verts[v] = verts;
+ /* TODO: mark dirty so we can keep attrib bindings up-to-date */
+ if (own_vbo)
+ batch->owns_flag |= (1 << v);
+ return v;
+ }
+ }
+
+ /* we only make it this far if there is no room for another GPUVertBuf */
+#if TRUST_NO_ONE
+ assert(false);
+#endif
+ return -1;
+}
+
+static GLuint batch_vao_get(GPUBatch *batch)
+{
+ /* Search through cache */
+ if (batch->is_dynamic_vao_count) {
+ for (int i = 0; i < batch->dynamic_vaos.count; ++i)
+ if (batch->dynamic_vaos.interfaces[i] == batch->interface)
+ return batch->dynamic_vaos.vao_ids[i];
+ }
+ else {
+ for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i)
+ if (batch->static_vaos.interfaces[i] == batch->interface)
+ return batch->static_vaos.vao_ids[i];
+ }
+
+ /* Set context of this batch.
+ * It will be bound to it until GPU_batch_vao_cache_clear is called.
+ * Until then it can only be drawn with this context. */
+ if (batch->context == NULL) {
+ batch->context = GPU_context_active_get();
+ gpu_context_add_batch(batch->context, batch);
+ }
+#if TRUST_NO_ONE
+ else {
+ /* Make sure you are not trying to draw this batch in another context. */
+ assert(batch->context == GPU_context_active_get());
+ }
+#endif
+
+ /* Cache miss, time to add a new entry! */
+ GLuint new_vao = 0;
+ if (!batch->is_dynamic_vao_count) {
+ int i; /* find first unused slot */
+ for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i)
+ if (batch->static_vaos.vao_ids[i] == 0)
+ break;
+
+ if (i < GPU_BATCH_VAO_STATIC_LEN) {
+ batch->static_vaos.interfaces[i] = batch->interface;
+ batch->static_vaos.vao_ids[i] = new_vao = GPU_vao_alloc();
+ }
+ else {
+ /* Not enough place switch to dynamic. */
+ batch->is_dynamic_vao_count = true;
+ /* Erase previous entries, they will be added back if drawn again. */
+ for (int j = 0; j < GPU_BATCH_VAO_STATIC_LEN; ++j) {
+ GPU_shaderinterface_remove_batch_ref((GPUShaderInterface *)batch->static_vaos.interfaces[j], batch);
+ GPU_vao_free(batch->static_vaos.vao_ids[j], batch->context);
}
- i_poly++;
- i_poly_prev = i_poly;
- /* ignore the duplicate point */
+ /* Init dynamic arrays and let the branch below set the values. */
+ batch->dynamic_vaos.count = GPU_BATCH_VAO_DYN_ALLOC_COUNT;
+ batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(GPUShaderInterface *));
+ batch->dynamic_vaos.vao_ids = calloc(batch->dynamic_vaos.count, sizeof(GLuint));
+ }
+ }
+
+ if (batch->is_dynamic_vao_count) {
+ int i; /* find first unused slot */
+ for (i = 0; i < batch->dynamic_vaos.count; ++i)
+ if (batch->dynamic_vaos.vao_ids[i] == 0)
+ break;
+
+ if (i == batch->dynamic_vaos.count) {
+ /* Not enough place, realloc the array. */
+ i = batch->dynamic_vaos.count;
+ batch->dynamic_vaos.count += GPU_BATCH_VAO_DYN_ALLOC_COUNT;
+ batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(GPUShaderInterface *) * batch->dynamic_vaos.count);
+ batch->dynamic_vaos.vao_ids = realloc(batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count);
+ memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(GPUShaderInterface *) * GPU_BATCH_VAO_DYN_ALLOC_COUNT);
+ memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GPU_BATCH_VAO_DYN_ALLOC_COUNT);
}
+ batch->dynamic_vaos.interfaces[i] = batch->interface;
+ batch->dynamic_vaos.vao_ids[i] = new_vao = GPU_vao_alloc();
}
- uint lines_len = lines_step - lines;
+ GPU_shaderinterface_add_batch_ref((GPUShaderInterface *)batch->interface, batch);
+
+#if TRUST_NO_ONE
+ assert(new_vao != 0);
+#endif
+
+ /* We just got a fresh VAO we need to initialize it. */
+ glBindVertexArray(new_vao);
+ batch_update_program_bindings(batch, 0);
+ glBindVertexArray(0);
+
+ return new_vao;
+}
+
+void GPU_batch_program_set_no_use(GPUBatch *batch, uint32_t program, const GPUShaderInterface *shaderface)
+{
+#if TRUST_NO_ONE
+ assert(glIsProgram(shaderface->program));
+ assert(batch->program_in_use == 0);
+#endif
+ batch->interface = shaderface;
+ batch->program = program;
+ batch->vao_id = batch_vao_get(batch);
+}
- /* Hide Lines (we could make optional) */
- {
- qsort(lines, lines_len, sizeof(int32_t), BLI_sortutil_cmp_int);
- lines_step = lines;
+void GPU_batch_program_set(GPUBatch *batch, uint32_t program, const GPUShaderInterface *shaderface)
+{
+ GPU_batch_program_set_no_use(batch, program, shaderface);
+ GPU_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */
+}
- if (lines[0] != lines[1]) {
- *lines_step++ = lines[0];
+void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface)
+{
+ if (batch->is_dynamic_vao_count) {
+ for (int i = 0; i < batch->dynamic_vaos.count; ++i) {
+ if (batch->dynamic_vaos.interfaces[i] == interface) {
+ GPU_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context);
+ batch->dynamic_vaos.vao_ids[i] = 0;
+ batch->dynamic_vaos.interfaces[i] = NULL;
+ break; /* cannot have duplicates */
+ }
}
- for (uint i_prev = 0, i = 1; i < lines_len; i_prev = i++) {
- if (lines[i] != lines[i_prev]) {
- *lines_step++ = lines[i];
+ }
+ else {
+ int i;
+ for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) {
+ if (batch->static_vaos.interfaces[i] == interface) {
+ GPU_vao_free(batch->static_vaos.vao_ids[i], batch->context);
+ batch->static_vaos.vao_ids[i] = 0;
+ batch->static_vaos.interfaces[i] = NULL;
+ break; /* cannot have duplicates */
}
}
- lines_len = lines_step - lines;
}
+}
+
+static void create_bindings(
+ GPUVertBuf *verts, const GPUShaderInterface *interface,
+ uint v_first, const bool use_instancing)
+{
+ const GPUVertFormat *format = &verts->format;
+
+ const uint attr_len = format->attr_len;
+ const uint stride = format->stride;
+
+ GPU_vertbuf_use(verts);
- /* We have vertices and tris, make a batch from this. */
- static Gwn_VertFormat format = {0};
- static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ for (uint a_idx = 0; a_idx < attr_len; ++a_idx) {
+ const GPUVertAttr *a = format->attribs + a_idx;
+ const GLvoid *pointer = (const GLubyte *)0 + a->offset + v_first * stride;
+
+ for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) {
+ const GPUShaderInput *input = GPU_shaderinterface_attr(interface, a->name[n_idx]);
+
+ if (input == NULL) continue;
+
+ if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) {
+#if TRUST_NO_ONE
+ assert(a->fetch_mode == GPU_FETCH_FLOAT);
+ assert(a->gl_comp_type == GL_FLOAT);
+#endif
+ for (int i = 0; i < a->comp_len / 4; ++i) {
+ glEnableVertexAttribArray(input->location + i);
+ glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0);
+ glVertexAttribPointer(input->location + i, 4, a->gl_comp_type, GL_FALSE, stride,
+ (const GLubyte *)pointer + i * 16);
+ }
+ }
+ else {
+ glEnableVertexAttribArray(input->location);
+ glVertexAttribDivisor(input->location, (use_instancing) ? 1 : 0);
+
+ switch (a->fetch_mode) {
+ case GPU_FETCH_FLOAT:
+ case GPU_FETCH_INT_TO_FLOAT:
+ glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer);
+ break;
+ case GPU_FETCH_INT_TO_FLOAT_UNIT:
+ glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer);
+ break;
+ case GPU_FETCH_INT:
+ glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer);
+ break;
+ }
+ }
+ }
}
+}
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- const uint vbo_len_capacity = lines_len * 2;
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+static void batch_update_program_bindings(GPUBatch *batch, uint v_first)
+{
+ for (int v = 0; v < GPU_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) {
+ create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false);
+ }
+ if (batch->inst) {
+ create_bindings(batch->inst, batch->interface, v_first, true);
+ }
+ if (batch->elem) {
+ GPU_indexbuf_use(batch->elem);
+ }
+}
+
+void GPU_batch_program_use_begin(GPUBatch *batch)
+{
+ /* NOTE: use_program & done_using_program are fragile, depend on staying in sync with
+ * the GL context's active program. use_program doesn't mark other programs as "not used". */
+ /* TODO: make not fragile (somehow) */
+
+ if (!batch->program_in_use) {
+ glUseProgram(batch->program);
+ batch->program_in_use = true;
+ }
+}
+
+void GPU_batch_program_use_end(GPUBatch *batch)
+{
+ if (batch->program_in_use) {
+#if PROGRAM_NO_OPTI
+ glUseProgram(0);
+#endif
+ batch->program_in_use = false;
+ }
+}
+
+#if TRUST_NO_ONE
+# define GET_UNIFORM const GPUShaderInput *uniform = GPU_shaderinterface_uniform(batch->interface, name); assert(uniform);
+#else
+# define GET_UNIFORM const GPUShaderInput *uniform = GPU_shaderinterface_uniform(batch->interface, name);
+#endif
+
+void GPU_batch_uniform_1ui(GPUBatch *batch, const char *name, int value)
+{
+ GET_UNIFORM
+ glUniform1ui(uniform->location, value);
+}
+
+void GPU_batch_uniform_1i(GPUBatch *batch, const char *name, int value)
+{
+ GET_UNIFORM
+ glUniform1i(uniform->location, value);
+}
+
+void GPU_batch_uniform_1b(GPUBatch *batch, const char *name, bool value)
+{
+ GET_UNIFORM
+ glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE);
+}
+
+void GPU_batch_uniform_2f(GPUBatch *batch, const char *name, float x, float y)
+{
+ GET_UNIFORM
+ glUniform2f(uniform->location, x, y);
+}
+
+void GPU_batch_uniform_3f(GPUBatch *batch, const char *name, float x, float y, float z)
+{
+ GET_UNIFORM
+ glUniform3f(uniform->location, x, y, z);
+}
+
+void GPU_batch_uniform_4f(GPUBatch *batch, const char *name, float x, float y, float z, float w)
+{
+ GET_UNIFORM
+ glUniform4f(uniform->location, x, y, z, w);
+}
+
+void GPU_batch_uniform_1f(GPUBatch *batch, const char *name, float x)
+{
+ GET_UNIFORM
+ glUniform1f(uniform->location, x);
+}
+
+void GPU_batch_uniform_2fv(GPUBatch *batch, const char *name, const float data[2])
+{
+ GET_UNIFORM
+ glUniform2fv(uniform->location, 1, data);
+}
+
+void GPU_batch_uniform_3fv(GPUBatch *batch, const char *name, const float data[3])
+{
+ GET_UNIFORM
+ glUniform3fv(uniform->location, 1, data);
+}
+
+void GPU_batch_uniform_4fv(GPUBatch *batch, const char *name, const float data[4])
+{
+ GET_UNIFORM
+ glUniform4fv(uniform->location, 1, data);
+}
+
+void GPU_batch_uniform_2fv_array(GPUBatch *batch, const char *name, const int len, const float *data)
+{
+ GET_UNIFORM
+ glUniform2fv(uniform->location, len, data);
+}
+
+void GPU_batch_uniform_4fv_array(GPUBatch *batch, const char *name, const int len, const float *data)
+{
+ GET_UNIFORM
+ glUniform4fv(uniform->location, len, data);
+}
- Gwn_VertBufRaw pos_step;
- GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
+void GPU_batch_uniform_mat4(GPUBatch *batch, const char *name, const float data[4][4])
+{
+ GET_UNIFORM
+ glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (const float *)data);
+}
+
+static void primitive_restart_enable(const GPUIndexBuf *el)
+{
+ // TODO(fclem) Replace by GL_PRIMITIVE_RESTART_FIXED_INDEX when we have ogl 4.3
+ glEnable(GL_PRIMITIVE_RESTART);
+ GLuint restart_index = (GLuint)0xFFFFFFFF;
+
+#if GPU_TRACK_INDEX_RANGE
+ if (el->index_type == GPU_INDEX_U8)
+ restart_index = (GLuint)0xFF;
+ else if (el->index_type == GPU_INDEX_U16)
+ restart_index = (GLuint)0xFFFF;
+#endif
+
+ glPrimitiveRestartIndex(restart_index);
+}
+
+static void primitive_restart_disable(void)
+{
+ glDisable(GL_PRIMITIVE_RESTART);
+}
+
+void GPU_batch_draw(GPUBatch *batch)
+{
+#if TRUST_NO_ONE
+ assert(batch->phase == GPU_BATCH_READY_TO_DRAW);
+ assert(batch->verts[0]->vbo_id != 0);
+#endif
+ GPU_batch_program_use_begin(batch);
+ GPU_matrix_bind(batch->interface); // external call.
+
+ GPU_batch_draw_range_ex(batch, 0, 0, false);
+
+ GPU_batch_program_use_end(batch);
+}
+
+void GPU_batch_draw_range_ex(GPUBatch *batch, int v_first, int v_count, bool force_instance)
+{
+#if TRUST_NO_ONE
+ assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance
+#endif
+ const bool do_instance = (force_instance || batch->inst);
+
+ // If using offset drawing, use the default VAO and redo bindings.
+ if (v_first != 0 && (do_instance || batch->elem)) {
+ glBindVertexArray(GPU_vao_default());
+ batch_update_program_bindings(batch, v_first);
+ }
+ else {
+ glBindVertexArray(batch->vao_id);
+ }
+
+ if (do_instance) {
+ /* Infer length if vertex count is not given */
+ if (v_count == 0) {
+ v_count = batch->inst->vertex_len;
+ }
+
+ if (batch->elem) {
+ const GPUIndexBuf *el = batch->elem;
+
+ if (el->use_prim_restart) {
+ primitive_restart_enable(el);
+ }
+#if GPU_TRACK_INDEX_RANGE
+ glDrawElementsInstancedBaseVertex(batch->gl_prim_type,
+ el->index_len,
+ el->gl_index_type,
+ 0,
+ v_count,
+ el->base_index);
+#else
+ glDrawElementsInstanced(batch->gl_prim_type, el->index_len, GL_UNSIGNED_INT, 0, v_count);
+#endif
+ if (el->use_prim_restart) {
+ primitive_restart_disable();
+ }
+ }
+ else {
+ glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_len, v_count);
+ }
+ }
+ else {
+ /* Infer length if vertex count is not given */
+ if (v_count == 0) {
+ v_count = (batch->elem) ? batch->elem->index_len : batch->verts[0]->vertex_len;
+ }
+
+ if (batch->elem) {
+ const GPUIndexBuf *el = batch->elem;
+
+ if (el->use_prim_restart) {
+ primitive_restart_enable(el);
+ }
- for (uint i = 0; i < lines_len; i++) {
- union {
- uint8_t as_u8_pair[2][2];
- uint32_t as_u32;
- } data;
- data.as_u32 = lines[i];
- for (uint k = 0; k < 2; k++) {
- float *pos_v2 = GWN_vertbuf_raw_step(&pos_step);
- for (uint j = 0; j < 2; j++) {
- pos_v2[j] = min_uchar[j] + ((float)data.as_u8_pair[k][j] * range_uchar[j]);
+#if GPU_TRACK_INDEX_RANGE
+ if (el->base_index) {
+ glDrawRangeElementsBaseVertex(
+ batch->gl_prim_type,
+ el->min_index,
+ el->max_index,
+ v_count,
+ el->gl_index_type,
+ 0,
+ el->base_index);
}
+ else {
+ glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, v_count, el->gl_index_type, 0);
+ }
+#else
+ glDrawElements(batch->gl_prim_type, v_count, GL_UNSIGNED_INT, 0);
+#endif
+ if (el->use_prim_restart) {
+ primitive_restart_disable();
+ }
+ }
+ else {
+ glDrawArrays(batch->gl_prim_type, v_first, v_count);
}
}
- BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step));
- MEM_freeN(lines);
- return GWN_batch_create_ex(
- GWN_PRIM_LINES, vbo,
- NULL,
- GWN_BATCH_OWNS_VBO);
+
+ /* Performance hog if you are drawing with the same vao multiple time.
+ * Only activate for debugging. */
+ // glBindVertexArray(0);
+}
+
+/* just draw some vertices and let shader place them where we want. */
+void GPU_draw_primitive(GPUPrimType prim_type, int v_count)
+{
+ /* we cannot draw without vao ... annoying ... */
+ glBindVertexArray(GPU_vao_default());
+
+ GLenum type = convert_prim_type_to_gl(prim_type);
+ glDrawArrays(type, 0, v_count);
+
+ /* Performance hog if you are drawing with the same vao multiple time.
+ * Only activate for debugging.*/
+ // glBindVertexArray(0);
+}
+
+
+/* -------------------------------------------------------------------- */
+/** \name Utilities
+ * \{ */
+
+void GPU_batch_program_set_builtin(GPUBatch *batch, GPUBuiltinShader shader_id)
+{
+ GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
+ GPU_batch_program_set(batch, shader->program, shader->interface);
}
/** \} */
diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c
index 10cbd16490b..83287c57441 100644
--- a/source/blender/gpu/intern/gpu_batch_presets.c
+++ b/source/blender/gpu/intern/gpu_batch_presets.c
@@ -38,19 +38,21 @@
#include "UI_interface.h"
#include "GPU_batch.h"
+#include "GPU_batch_utils.h"
+#include "GPU_batch_presets.h" /* own include */
#include "gpu_shader_private.h"
/* Struct to store 3D Batches and their format */
static struct {
struct {
- Gwn_Batch *sphere_high;
- Gwn_Batch *sphere_med;
- Gwn_Batch *sphere_low;
- Gwn_Batch *sphere_wire_low;
- Gwn_Batch *sphere_wire_med;
+ GPUBatch *sphere_high;
+ GPUBatch *sphere_med;
+ GPUBatch *sphere_low;
+ GPUBatch *sphere_wire_low;
+ GPUBatch *sphere_wire_med;
} batch;
- Gwn_VertFormat format;
+ GPUVertFormat format;
struct {
uint pos, nor;
@@ -59,46 +61,81 @@ static struct {
static ListBase presets_list = {NULL, NULL};
+
/* -------------------------------------------------------------------- */
/** \name 3D Primitives
* \{ */
-static Gwn_VertFormat *preset_3D_format(void)
+static GPUVertFormat *preset_3d_format(void)
{
- if (g_presets_3d.format.attrib_ct == 0) {
- Gwn_VertFormat *format = &g_presets_3d.format;
- g_presets_3d.attr_id.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- g_presets_3d.attr_id.nor = GWN_vertformat_attr_add(format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ if (g_presets_3d.format.attr_len == 0) {
+ GPUVertFormat *format = &g_presets_3d.format;
+ g_presets_3d.attr_id.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ g_presets_3d.attr_id.nor = GPU_vertformat_attr_add(format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
return &g_presets_3d.format;
}
static void batch_sphere_lat_lon_vert(
- Gwn_VertBufRaw *pos_step, Gwn_VertBufRaw *nor_step,
+ GPUVertBufRaw *pos_step, GPUVertBufRaw *nor_step,
float lat, float lon)
{
float pos[3];
pos[0] = sinf(lat) * cosf(lon);
pos[1] = cosf(lat);
pos[2] = sinf(lat) * sinf(lon);
- copy_v3_v3(GWN_vertbuf_raw_step(pos_step), pos);
- copy_v3_v3(GWN_vertbuf_raw_step(nor_step), pos);
+ copy_v3_v3(GPU_vertbuf_raw_step(pos_step), pos);
+ copy_v3_v3(GPU_vertbuf_raw_step(nor_step), pos);
+}
+GPUBatch *GPU_batch_preset_sphere(int lod)
+{
+ BLI_assert(lod >= 0 && lod <= 2);
+ BLI_assert(BLI_thread_is_main());
+
+ if (lod == 0) {
+ return g_presets_3d.batch.sphere_low;
+ }
+ else if (lod == 1) {
+ return g_presets_3d.batch.sphere_med;
+ }
+ else {
+ return g_presets_3d.batch.sphere_high;
+ }
}
+GPUBatch *GPU_batch_preset_sphere_wire(int lod)
+{
+ BLI_assert(lod >= 0 && lod <= 1);
+ BLI_assert(BLI_thread_is_main());
+
+ if (lod == 0) {
+ return g_presets_3d.batch.sphere_wire_low;
+ }
+ else {
+ return g_presets_3d.batch.sphere_wire_med;
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Create Sphere (3D)
+ * \{ */
+
/* Replacement for gluSphere */
-Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res)
+GPUBatch *gpu_batch_sphere(int lat_res, int lon_res)
{
const float lon_inc = 2 * M_PI / lon_res;
const float lat_inc = M_PI / lat_res;
float lon, lat;
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3D_format());
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(preset_3d_format());
const uint vbo_len = (lat_res - 1) * lon_res * 6;
- GWN_vertbuf_data_alloc(vbo, vbo_len);
+ GPU_vertbuf_data_alloc(vbo, vbo_len);
- Gwn_VertBufRaw pos_step, nor_step;
- GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step);
- GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step);
+ GPUVertBufRaw pos_step, nor_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step);
+ GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step);
lon = 0.0f;
for (int i = 0; i < lon_res; i++, lon += lon_inc) {
@@ -118,25 +155,25 @@ Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res)
}
}
- BLI_assert(vbo_len == GWN_vertbuf_raw_used(&pos_step));
- BLI_assert(vbo_len == GWN_vertbuf_raw_used(&nor_step));
+ BLI_assert(vbo_len == GPU_vertbuf_raw_used(&pos_step));
+ BLI_assert(vbo_len == GPU_vertbuf_raw_used(&nor_step));
- return GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ return GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
-static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res)
+static GPUBatch *batch_sphere_wire(int lat_res, int lon_res)
{
const float lon_inc = 2 * M_PI / lon_res;
const float lat_inc = M_PI / lat_res;
float lon, lat;
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3D_format());
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(preset_3d_format());
const uint vbo_len = (lat_res * lon_res * 2) + ((lat_res - 1) * lon_res * 2);
- GWN_vertbuf_data_alloc(vbo, vbo_len);
+ GPU_vertbuf_data_alloc(vbo, vbo_len);
- Gwn_VertBufRaw pos_step, nor_step;
- GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step);
- GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step);
+ GPUVertBufRaw pos_step, nor_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step);
+ GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step);
lon = 0.0f;
for (int i = 0; i < lon_res; i++, lon += lon_inc) {
@@ -152,44 +189,14 @@ static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res)
}
}
- BLI_assert(vbo_len == GWN_vertbuf_raw_used(&pos_step));
- BLI_assert(vbo_len == GWN_vertbuf_raw_used(&nor_step));
-
- return GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
-}
-
-Gwn_Batch *GPU_batch_preset_sphere(int lod)
-{
- BLI_assert(lod >= 0 && lod <= 2);
- BLI_assert(BLI_thread_is_main());
-
- if (lod == 0) {
- return g_presets_3d.batch.sphere_low;
- }
- else if (lod == 1) {
- return g_presets_3d.batch.sphere_med;
- }
- else {
- return g_presets_3d.batch.sphere_high;
- }
-}
-
-Gwn_Batch *GPU_batch_preset_sphere_wire(int lod)
-{
- BLI_assert(lod >= 0 && lod <= 1);
- BLI_assert(BLI_thread_is_main());
+ BLI_assert(vbo_len == GPU_vertbuf_raw_used(&pos_step));
+ BLI_assert(vbo_len == GPU_vertbuf_raw_used(&nor_step));
- if (lod == 0) {
- return g_presets_3d.batch.sphere_wire_low;
- }
- else {
- return g_presets_3d.batch.sphere_wire_med;
- }
+ return GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
/** \} */
-
void gpu_batch_presets_init(void)
{
/* Hard coded resolution */
@@ -209,7 +216,7 @@ void gpu_batch_presets_init(void)
gpu_batch_presets_register(g_presets_3d.batch.sphere_wire_med);
}
-void gpu_batch_presets_register(Gwn_Batch *preset_batch)
+void gpu_batch_presets_register(GPUBatch *preset_batch)
{
BLI_addtail(&presets_list, BLI_genericNodeN(preset_batch));
}
@@ -220,8 +227,8 @@ void gpu_batch_presets_reset(void)
* This way they will draw correctly for each window. */
LinkData *link = presets_list.first;
for (link = presets_list.first; link; link = link->next) {
- Gwn_Batch *preset = link->data;
- gwn_batch_vao_cache_clear(preset);
+ GPUBatch *preset = link->data;
+ GPU_batch_vao_cache_clear(preset);
}
}
@@ -229,8 +236,8 @@ void gpu_batch_presets_exit(void)
{
LinkData *link;
while ((link = BLI_pophead(&presets_list))) {
- Gwn_Batch *preset = link->data;
- GWN_batch_discard(preset);
+ GPUBatch *preset = link->data;
+ GPU_batch_discard(preset);
MEM_freeN(link);
}
}
diff --git a/intern/opensubdiv/opensubdiv_topology_refiner.h b/source/blender/gpu/intern/gpu_batch_private.h
index b00f6a54201..3a05e243065 100644
--- a/intern/opensubdiv/opensubdiv_topology_refiner.h
+++ b/source/blender/gpu/intern/gpu_batch_private.h
@@ -15,27 +15,36 @@
* 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) 2016 Blender Foundation.
+ * The Original Code is Copyright (C) 2016 by Mike Erwin.
* All rights reserved.
*
- * Contributor(s): Sergey Sharybin.
+ * Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __OPENSUBDIV_TOPOLOGY_REFINER_H__
-#define __OPENSUBDIV_TOPOLOGY_REFINER_H__
+/** \file blender/gpu/intern/gpu_batch_private.h
+ * \ingroup gpu
+ *
+ * GPU geometry batch
+ * Contains VAOs + VBOs + Shader representing a drawable entity.
+ */
+
+#ifndef __GPU_BATCH_PRIVATE_H__
+#define __GPU_BATCH_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include <opensubdiv/far/topologyRefiner.h>
+#include "GPU_batch.h"
+#include "GPU_context.h"
+#include "GPU_shader_interface.h"
-typedef struct OpenSubdiv_TopologyRefinerDescr {
- OpenSubdiv::Far::TopologyRefiner *osd_refiner;
+void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface);
- /* TODO(sergey): For now only, need to find better place
- * after revisiting whole OSD drawing pipeline and Blender
- * integration.
- */
- std::vector<float> uvs;
-} OpenSubdiv_TopologyRefinerDescr;
+#ifdef __cplusplus
+}
+#endif
-#endif /* __OPENSUBDIV_TOPOLOGY_REFINER_H__ */
+#endif /* __GPU_BATCH_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_batch_utils.c b/source/blender/gpu/intern/gpu_batch_utils.c
new file mode 100644
index 00000000000..0a7f1ca901d
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_batch_utils.c
@@ -0,0 +1,243 @@
+/*
+ * ***** 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/gpu/intern/gpu_batch_utils.c
+ * \ingroup gpu
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_rect.h"
+#include "BLI_math.h"
+#include "BLI_polyfill_2d.h"
+#include "BLI_sort_utils.h"
+
+#include "GPU_batch.h"
+#include "GPU_batch_utils.h" /* own include */
+#include "gpu_shader_private.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Polygon Creation (2D)
+ * \{ */
+
+/**
+ * Creates triangles from a byte-array of polygons.
+ *
+ * See 'make_shape_2d_from_blend.py' utility to create data to pass to this function.
+ *
+ * \param polys_flat: Pairs of X, Y coordinates (repeating to signify closing the polygon).
+ * \param polys_flat_len: Length of the array (must be an even number).
+ * \param rect: Optional region to map the byte 0..255 coords to. When not set use -1..1.
+ */
+GPUBatch *GPU_batch_tris_from_poly_2d_encoded(
+ const uchar *polys_flat, uint polys_flat_len, const rctf *rect)
+{
+ const uchar (*polys)[2] = (const void *)polys_flat;
+ const uint polys_len = polys_flat_len / 2;
+ BLI_assert(polys_flat_len == polys_len * 2);
+
+ /* Over alloc in both cases */
+ float (*verts)[2] = MEM_mallocN(sizeof(*verts) * polys_len, __func__);
+ float (*verts_step)[2] = verts;
+ uint (*tris)[3] = MEM_mallocN(sizeof(*tris) * polys_len, __func__);
+ uint (*tris_step)[3] = tris;
+
+ const float range_uchar[2] = {
+ (rect ? (rect->xmax - rect->xmin) : 2.0f) / 255.0f,
+ (rect ? (rect->ymax - rect->ymin) : 2.0f) / 255.0f,
+ };
+ const float min_uchar[2] = {
+ (rect ? rect->xmin : -1.0f),
+ (rect ? rect->ymin : -1.0f),
+ };
+
+ uint i_poly = 0;
+ uint i_vert = 0;
+ while (i_poly != polys_len) {
+ for (uint j = 0; j < 2; j++) {
+ verts[i_vert][j] = min_uchar[j] + ((float)polys[i_poly][j] * range_uchar[j]);
+ }
+ i_vert++;
+ i_poly++;
+ if (polys[i_poly - 1][0] == polys[i_poly][0] &&
+ polys[i_poly - 1][1] == polys[i_poly][1])
+ {
+ const uint verts_step_len = (&verts[i_vert]) - verts_step;
+ BLI_assert(verts_step_len >= 3);
+ const uint tris_len = (verts_step_len - 2);
+ BLI_polyfill_calc(verts_step, verts_step_len, -1, tris_step);
+ /* offset indices */
+ if (verts_step != verts) {
+ uint *t = tris_step[0];
+ const uint offset = (verts_step - verts);
+ uint tot = tris_len * 3;
+ while (tot--) {
+ *t += offset;
+ t++;
+ }
+ BLI_assert(t == tris_step[tris_len]);
+ }
+ verts_step += verts_step_len;
+ tris_step += tris_len;
+ i_poly++;
+ /* ignore the duplicate point */
+ }
+ }
+
+ /* We have vertices and tris, make a batch from this. */
+ static GPUVertFormat format = {0};
+ static struct { uint pos; } attr_id;
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ }
+
+ const uint verts_len = (verts_step - verts);
+ const uint tris_len = (tris_step - tris);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ GPU_vertbuf_data_alloc(vbo, verts_len);
+
+ GPUVertBufRaw pos_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
+
+ for (uint i = 0; i < verts_len; i++) {
+ copy_v2_v2(GPU_vertbuf_raw_step(&pos_step), verts[i]);
+ }
+
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tris_len, verts_len);
+ for (uint i = 0; i < tris_len; i++) {
+ GPU_indexbuf_add_tri_verts(&elb, UNPACK3(tris[i]));
+ }
+ GPUIndexBuf *indexbuf = GPU_indexbuf_build(&elb);
+
+ MEM_freeN(tris);
+ MEM_freeN(verts);
+
+ return GPU_batch_create_ex(
+ GPU_PRIM_TRIS, vbo,
+ indexbuf,
+ GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
+}
+
+GPUBatch *GPU_batch_wire_from_poly_2d_encoded(
+ const uchar *polys_flat, uint polys_flat_len, const rctf *rect)
+{
+ const uchar (*polys)[2] = (const void *)polys_flat;
+ const uint polys_len = polys_flat_len / 2;
+ BLI_assert(polys_flat_len == polys_len * 2);
+
+ /* Over alloc */
+ /* Lines are pairs of (x, y) byte locations packed into an int32_t. */
+ int32_t *lines = MEM_mallocN(sizeof(*lines) * polys_len, __func__);
+ int32_t *lines_step = lines;
+
+ const float range_uchar[2] = {
+ (rect ? (rect->xmax - rect->xmin) : 2.0f) / 255.0f,
+ (rect ? (rect->ymax - rect->ymin) : 2.0f) / 255.0f,
+ };
+ const float min_uchar[2] = {
+ (rect ? rect->xmin : -1.0f),
+ (rect ? rect->ymin : -1.0f),
+ };
+
+ uint i_poly_prev = 0;
+ uint i_poly = 0;
+ while (i_poly != polys_len) {
+ i_poly++;
+ if (polys[i_poly - 1][0] == polys[i_poly][0] &&
+ polys[i_poly - 1][1] == polys[i_poly][1])
+ {
+ const uchar (*polys_step)[2] = polys + i_poly_prev;
+ const uint polys_step_len = i_poly - i_poly_prev;
+ BLI_assert(polys_step_len >= 2);
+ for (uint i_prev = polys_step_len - 1, i = 0; i < polys_step_len; i_prev = i++) {
+ union {
+ uint8_t as_u8[4];
+ uint16_t as_u16[2];
+ uint32_t as_u32;
+ } data;
+ data.as_u16[0] = *((const uint16_t *)polys_step[i_prev]);
+ data.as_u16[1] = *((const uint16_t *)polys_step[i]);
+ if (data.as_u16[0] > data.as_u16[1]) {
+ SWAP(uint16_t, data.as_u16[0], data.as_u16[1]);
+ }
+ *lines_step = data.as_u32;
+ lines_step++;
+ }
+ i_poly++;
+ i_poly_prev = i_poly;
+ /* ignore the duplicate point */
+ }
+ }
+
+ uint lines_len = lines_step - lines;
+
+ /* Hide Lines (we could make optional) */
+ {
+ qsort(lines, lines_len, sizeof(int32_t), BLI_sortutil_cmp_int);
+ lines_step = lines;
+ for (uint i_prev = 0, i = 1; i < lines_len; i_prev = i++) {
+ if (lines[i] != lines[i_prev]) {
+ *lines_step++ = lines[i_prev];
+ }
+ else {
+ i++;
+ }
+ }
+ lines_len = lines_step - lines;
+ }
+
+ /* We have vertices and tris, make a batch from this. */
+ static GPUVertFormat format = {0};
+ static struct { uint pos; } attr_id;
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ }
+
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ const uint vbo_len_capacity = lines_len * 2;
+ GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
+
+ GPUVertBufRaw pos_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
+
+ for (uint i = 0; i < lines_len; i++) {
+ union {
+ uint8_t as_u8_pair[2][2];
+ uint32_t as_u32;
+ } data;
+ data.as_u32 = lines[i];
+ for (uint k = 0; k < 2; k++) {
+ float *pos_v2 = GPU_vertbuf_raw_step(&pos_step);
+ for (uint j = 0; j < 2; j++) {
+ pos_v2[j] = min_uchar[j] + ((float)data.as_u8_pair[k][j] * range_uchar[j]);
+ }
+ }
+ }
+ BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step));
+ MEM_freeN(lines);
+ return GPU_batch_create_ex(
+ GPU_PRIM_LINES, vbo,
+ NULL,
+ GPU_BATCH_OWNS_VBO);
+}
+
+/** \} */
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 688386810ea..16590785af6 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -62,7 +62,7 @@ static ThreadMutex buffer_mutex = BLI_MUTEX_INITIALIZER;
/* multires global buffer, can be used for many grids having the same grid size */
typedef struct GridCommonGPUBuffer {
- Gwn_IndexBuf *mres_buffer;
+ GPUIndexBuf *mres_buffer;
int mres_prev_gridsize;
unsigned mres_prev_totquad;
} GridCommonGPUBuffer;
@@ -71,11 +71,11 @@ typedef struct GridCommonGPUBuffer {
* drawing and doesn't interact at all with the buffer code above */
struct GPU_PBVH_Buffers {
- Gwn_IndexBuf *index_buf, *index_buf_fast;
- Gwn_VertBuf *vert_buf;
+ GPUIndexBuf *index_buf, *index_buf_fast;
+ GPUVertBuf *vert_buf;
- Gwn_Batch *triangles;
- Gwn_Batch *triangles_fast;
+ GPUBatch *triangles;
+ GPUBatch *triangles_fast;
/* mesh pointers in case buffer allocation fails */
const MPoly *mpoly;
@@ -126,29 +126,29 @@ static void gpu_material_diffuse_get(int UNUSED(nr), float diff[4])
/* Allocates a non-initialized buffer to be sent to GPU.
* Return is false it indicates that the memory map failed. */
-static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int vert_ct)
+static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int vert_len)
{
if (buffers->vert_buf == NULL) {
/* Initialize vertex buffer */
/* match 'VertexBufferFormat' */
- static Gwn_VertFormat format = {0};
- if (format.attrib_ct == 0) {
- g_vbo_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- g_vbo_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- g_vbo_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ g_vbo_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ g_vbo_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ g_vbo_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
#if 0
- buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_DYNAMIC);
- GWN_vertbuf_data_alloc(buffers->vert_buf, vert_ct);
+ buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_DYNAMIC);
+ GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
}
- else if (vert_ct != buffers->vert_buf->vertex_ct) {
- GWN_vertbuf_data_resize(buffers->vert_buf, vert_ct);
+ else if (vert_len != buffers->vert_buf->vertex_len) {
+ GPU_vertbuf_data_resize(buffers->vert_buf, vert_len);
}
#else
- buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC);
+ buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC);
}
- GWN_vertbuf_data_alloc(buffers->vert_buf, vert_ct);
+ GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
#endif
return buffers->vert_buf->data != NULL;
}
@@ -157,19 +157,19 @@ static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers)
{
/* force flushing to the GPU */
if (buffers->vert_buf->data) {
- GWN_vertbuf_use(buffers->vert_buf);
+ GPU_vertbuf_use(buffers->vert_buf);
}
if (buffers->triangles == NULL) {
- buffers->triangles = GWN_batch_create(
- GWN_PRIM_TRIS, buffers->vert_buf,
+ buffers->triangles = GPU_batch_create(
+ GPU_PRIM_TRIS, buffers->vert_buf,
/* can be NULL */
buffers->index_buf);
}
if ((buffers->triangles_fast == NULL) && buffers->index_buf_fast) {
- buffers->triangles_fast = GWN_batch_create(
- GWN_PRIM_TRIS, buffers->vert_buf,
+ buffers->triangles_fast = GPU_batch_create(
+ GPU_PRIM_TRIS, buffers->vert_buf,
/* can be NULL */
buffers->index_buf_fast);
}
@@ -245,8 +245,8 @@ void GPU_pbvh_mesh_buffers_update(
if (buffers->smooth) {
for (uint i = 0; i < totvert; ++i) {
const MVert *v = &mvert[vert_indices[i]];
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, i, v->co);
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, i, v->co);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no);
}
for (uint i = 0; i < buffers->face_indices_len; i++) {
@@ -257,10 +257,10 @@ void GPU_pbvh_mesh_buffers_update(
int v_index = buffers->mloop[lt->tri[j]].v;
uchar color_ub[3];
gpu_color_from_mask_copy(vmask[v_index], diffuse_color, color_ub);
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, color_ub);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, color_ub);
}
else {
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, diffuse_color_ub);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, diffuse_color_ub);
}
}
}
@@ -303,9 +303,9 @@ void GPU_pbvh_mesh_buffers_update(
for (uint j = 0; j < 3; j++) {
const MVert *v = &mvert[vtri[j]];
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co);
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no);
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
vbo_index++;
}
@@ -367,8 +367,8 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(
if (buffers->smooth) {
/* Fill the triangle buffer */
buffers->index_buf = NULL;
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tottri, INT_MAX);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX);
for (i = 0; i < face_indices_len; ++i) {
const MLoopTri *lt = &looptri[face_indices[i]];
@@ -377,13 +377,13 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(
if (paint_is_face_hidden(lt, mvert, mloop))
continue;
- GWN_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
+ GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
}
- buffers->index_buf = GWN_indexbuf_build(&elb);
+ buffers->index_buf = GPU_indexbuf_build(&elb);
}
else {
if (!buffers->is_index_buf_global) {
- GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
}
buffers->index_buf = NULL;
buffers->is_index_buf_global = false;
@@ -438,12 +438,12 @@ void GPU_pbvh_grid_buffers_update(
for (y = 0; y < key->grid_size; y++) {
for (x = 0; x < key->grid_size; x++) {
CCGElem *elem = CCG_grid_elem(key, grid, x, y);
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem));
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem));
if (buffers->smooth) {
short no_short[3];
normal_float_to_short_v3(no_short, CCG_elem_no(key, elem));
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short);
if (has_mask) {
uchar color_ub[3];
@@ -454,7 +454,7 @@ void GPU_pbvh_grid_buffers_update(
else {
unit_float_to_uchar_clamp_v3(color_ub, diffuse_color);
}
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
}
}
vbo_index += 1;
@@ -481,7 +481,7 @@ void GPU_pbvh_grid_buffers_update(
vbo_index = vbo_index_offset + ((j + 1) * key->grid_size + k);
short no_short[3];
normal_float_to_short_v3(no_short, fno);
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short);
if (has_mask) {
uchar color_ub[3];
@@ -497,7 +497,7 @@ void GPU_pbvh_grid_buffers_update(
else {
unit_float_to_uchar_clamp_v3(color_ub, diffuse_color);
}
- GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
}
}
}
@@ -522,47 +522,47 @@ void GPU_pbvh_grid_buffers_update(
/* Build the element array buffer of grid indices using either
* unsigned shorts or unsigned ints. */
#define FILL_QUAD_BUFFER(max_vert_, tot_quad_, buffer_) \
- { \
- int offset = 0; \
- int i, j, k; \
+ { \
+ int offset = 0; \
+ int i, j, k; \
\
- Gwn_IndexBufBuilder elb; \
- GWN_indexbuf_init( \
- &elb, GWN_PRIM_TRIS, tot_quad_ * 2, max_vert_); \
+ GPUIndexBufBuilder elb; \
+ GPU_indexbuf_init( \
+ &elb, GPU_PRIM_TRIS, tot_quad_ * 2, max_vert_); \
\
- /* Fill the buffer */ \
- for (i = 0; i < totgrid; ++i) { \
- BLI_bitmap *gh = NULL; \
- if (grid_hidden) \
- gh = grid_hidden[(grid_indices)[i]]; \
+ /* Fill the buffer */ \
+ for (i = 0; i < totgrid; ++i) { \
+ BLI_bitmap *gh = NULL; \
+ if (grid_hidden) \
+ gh = grid_hidden[(grid_indices)[i]]; \
\
- for (j = 0; j < gridsize - 1; ++j) { \
- for (k = 0; k < gridsize - 1; ++k) { \
- /* Skip hidden grid face */ \
- if (gh && paint_is_grid_face_hidden( \
- gh, gridsize, k, j)) \
- { \
- continue; \
- } \
- GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \
- GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k); \
- GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \
- \
- GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k + 1); \
- GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \
- GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \
- } \
- } \
+ for (j = 0; j < gridsize - 1; ++j) { \
+ for (k = 0; k < gridsize - 1; ++k) { \
+ /* Skip hidden grid face */ \
+ if (gh && paint_is_grid_face_hidden( \
+ gh, gridsize, k, j)) \
+ { \
+ continue; \
+ } \
+ GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \
+ GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k); \
+ GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \
\
- offset += gridsize * gridsize; \
- } \
- buffer_ = GWN_indexbuf_build(&elb); \
- } (void)0
+ GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k + 1); \
+ GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \
+ GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \
+ } \
+ } \
+ \
+ offset += gridsize * gridsize; \
+ } \
+ buffer_ = GPU_indexbuf_build(&elb); \
+ } (void)0
/* end FILL_QUAD_BUFFER */
-static Gwn_IndexBuf *gpu_get_grid_buffer(
+static GPUIndexBuf *gpu_get_grid_buffer(
int gridsize, unsigned *totquad, GridCommonGPUBuffer **grid_common_gpu_buffer,
- /* remove this arg when gawain gets base-vertex support! */
+ /* remove this arg when GPU gets base-vertex support! */
int totgrid)
{
/* used in the FILL_QUAD_BUFFER macro */
@@ -586,7 +586,7 @@ static Gwn_IndexBuf *gpu_get_grid_buffer(
}
/* we can't reuse old, delete the existing buffer */
else if (gridbuff->mres_buffer) {
- GWN_indexbuf_discard(gridbuff->mres_buffer);
+ GPU_indexbuf_discard(gridbuff->mres_buffer);
gridbuff->mres_buffer = NULL;
}
@@ -603,17 +603,17 @@ static Gwn_IndexBuf *gpu_get_grid_buffer(
#define FILL_FAST_BUFFER() \
{ \
- Gwn_IndexBufBuilder elb; \
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, 6 * totgrid, INT_MAX); \
+ GPUIndexBufBuilder elb; \
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, 6 * totgrid, INT_MAX); \
for (int i = 0; i < totgrid; i++) { \
- GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \
- GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize); \
- GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \
- GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - 1); \
- GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \
- GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \
+ GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \
+ GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize); \
+ GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \
+ GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - 1); \
+ GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \
+ GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \
} \
- buffers->index_buf_fast = GWN_indexbuf_build(&elb); \
+ buffers->index_buf_fast = GPU_indexbuf_build(&elb); \
} (void)0
GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(
@@ -684,7 +684,7 @@ GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(
*/
static void gpu_bmesh_vert_to_buffer_copy__gwn(
BMVert *v,
- Gwn_VertBuf *vert_buf,
+ GPUVertBuf *vert_buf,
int *v_index,
const float fno[3],
const float *fmask,
@@ -695,12 +695,12 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn(
if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
/* Set coord, normal, and mask */
- GWN_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co);
+ GPU_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co);
{
short no_short[3];
normal_float_to_short_v3(no_short, fno ? fno : v->no);
- GWN_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short);
+ GPU_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short);
}
{
@@ -718,7 +718,7 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn(
effective_mask,
diffuse_color,
color_ub);
- GWN_vertbuf_attr_set(vert_buf, g_vbo_id.col, *v_index, color_ub);
+ GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col, *v_index, color_ub);
}
/* Assign index for use in the triangle index buffer */
@@ -792,7 +792,7 @@ void GPU_pbvh_bmesh_buffers_update(
if (buffers->smooth) {
/* Smooth needs to recreate index buffer, so we have to invalidate the batch. */
- GWN_BATCH_DISCARD_SAFE(buffers->triangles);
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles);
/* Count visible vertices */
totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts);
}
@@ -893,8 +893,8 @@ void GPU_pbvh_bmesh_buffers_update(
if (buffers->smooth) {
/* Fill the triangle buffer */
buffers->index_buf = NULL;
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tottri, maxvert);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, maxvert);
/* Initialize triangle index buffer */
buffers->is_index_buf_global = false;
@@ -911,24 +911,24 @@ void GPU_pbvh_bmesh_buffers_update(
BMVert *v[3];
BM_face_as_array_vert_tri(f, v);
- GWN_indexbuf_add_tri_verts(
- &elb, BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2]));
+ GPU_indexbuf_add_tri_verts(
+ &elb, BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2]));
}
}
buffers->tot_tri = tottri;
if (buffers->index_buf == NULL) {
- buffers->index_buf = GWN_indexbuf_build(&elb);
+ buffers->index_buf = GPU_indexbuf_build(&elb);
}
else {
- GWN_indexbuf_build_in_place(&elb, buffers->index_buf);
+ GPU_indexbuf_build_in_place(&elb, buffers->index_buf);
}
}
}
else if (buffers->index_buf) {
if (!buffers->is_index_buf_global) {
- GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
}
buffers->index_buf = NULL;
buffers->is_index_buf_global = false;
@@ -950,7 +950,7 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading)
return buffers;
}
-Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast)
+GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast)
{
return (fast && buffers->triangles_fast) ?
buffers->triangles_fast : buffers->triangles;
@@ -1003,13 +1003,13 @@ bool GPU_pbvh_buffers_mask_changed(GPU_PBVH_Buffers *buffers, bool show_mask)
void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
{
if (buffers) {
- GWN_BATCH_DISCARD_SAFE(buffers->triangles);
- GWN_BATCH_DISCARD_SAFE(buffers->triangles_fast);
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles);
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles_fast);
if (!buffers->is_index_buf_global) {
- GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
}
- GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast);
- GWN_VERTBUF_DISCARD_SAFE(buffers->vert_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast);
+ GPU_VERTBUF_DISCARD_SAFE(buffers->vert_buf);
#ifdef USE_BASE_ELEM
if (buffers->baseelemarray)
@@ -1029,7 +1029,7 @@ void GPU_pbvh_multires_buffers_free(GridCommonGPUBuffer **grid_common_gpu_buffer
if (gridbuff) {
if (gridbuff->mres_buffer) {
BLI_mutex_lock(&buffer_mutex);
- GWN_INDEXBUF_DISCARD_SAFE(gridbuff->mres_buffer);
+ GPU_INDEXBUF_DISCARD_SAFE(gridbuff->mres_buffer);
BLI_mutex_unlock(&buffer_mutex);
}
MEM_freeN(gridbuff);
@@ -1049,7 +1049,7 @@ void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos)
* could keep a static batch & index buffer, change the VBO contents per draw
*/
- immBegin(GWN_PRIM_LINES, 24);
+ immBegin(GPU_PRIM_LINES, 24);
/* top */
immVertex3f(pos, min[0], min[1], max[2]);
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index a450b551d4a..3b9d2e08769 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -615,10 +615,11 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds,
if ((input->source == GPU_SOURCE_TEX) || (input->source == GPU_SOURCE_TEX_PIXEL)) {
/* create exactly one sampler for each texture */
if (codegen_input_has_texture(input) && input->bindtex) {
- BLI_dynstr_appendf(ds, "uniform %s samp%d;\n",
- (input->textype == GPU_TEX2D) ? "sampler2D" :
- (input->textype == GPU_TEXCUBE) ? "samplerCube" : "sampler2DShadow",
- input->texid);
+ BLI_dynstr_appendf(
+ ds, "uniform %s samp%d;\n",
+ (input->textype == GPU_TEX2D) ? "sampler2D" :
+ (input->textype == GPU_TEXCUBE) ? "samplerCube" : "sampler2DShadow",
+ input->texid);
}
}
else if (input->source == GPU_SOURCE_BUILTIN) {
@@ -635,13 +636,15 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds,
}
}
else if (gpu_str_prefix(name, "unf")) {
- BLI_dynstr_appendf(ds, "uniform %s %s;\n",
- GPU_DATATYPE_STR[input->type], name);
+ BLI_dynstr_appendf(
+ ds, "uniform %s %s;\n",
+ GPU_DATATYPE_STR[input->type], name);
}
else {
- BLI_dynstr_appendf(ds, "%s %s %s;\n",
- GLEW_VERSION_3_0 ? "in" : "varying",
- GPU_DATATYPE_STR[input->type], name);
+ BLI_dynstr_appendf(
+ ds, "%s %s %s;\n",
+ GLEW_VERSION_3_0 ? "in" : "varying",
+ GPU_DATATYPE_STR[input->type], name);
}
}
}
@@ -658,12 +661,14 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds,
}
else if (input->dynamicvec) {
/* only create uniforms for dynamic vectors */
- BLI_dynstr_appendf(ds, "uniform %s unf%d;\n",
- GPU_DATATYPE_STR[input->type], input->id);
+ BLI_dynstr_appendf(
+ ds, "uniform %s unf%d;\n",
+ GPU_DATATYPE_STR[input->type], input->id);
}
else {
- BLI_dynstr_appendf(ds, "const %s cons%d = ",
- GPU_DATATYPE_STR[input->type], input->id);
+ BLI_dynstr_appendf(
+ ds, "const %s cons%d = ",
+ GPU_DATATYPE_STR[input->type], input->id);
codegen_print_datatype(ds, input->type, input->vec);
BLI_dynstr_append(ds, ";\n");
}
@@ -675,9 +680,10 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds,
BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n");
}
#endif
- BLI_dynstr_appendf(ds, "%s %s var%d;\n",
- GLEW_VERSION_3_0 ? "in" : "varying",
- GPU_DATATYPE_STR[input->type], input->attribid);
+ BLI_dynstr_appendf(
+ ds, "%s %s var%d;\n",
+ GLEW_VERSION_3_0 ? "in" : "varying",
+ GPU_DATATYPE_STR[input->type], input->attribid);
#ifdef WITH_OPENSUBDIV
if (skip_opensubdiv) {
BLI_dynstr_appendf(ds, "#endif\n");
@@ -696,8 +702,9 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds,
for (LinkData *link = ubo_inputs.first; link; link = link->next) {
input = link->data;
- BLI_dynstr_appendf(ds, "\t%s unf%d;\n",
- GPU_DATATYPE_STR[input->type], input->id);
+ BLI_dynstr_appendf(
+ ds, "\t%s unf%d;\n",
+ GPU_DATATYPE_STR[input->type], input->id);
}
BLI_dynstr_append(ds, "};\n");
BLI_freelistN(&ubo_inputs);
@@ -719,9 +726,11 @@ static void codegen_declare_tmps(DynStr *ds, ListBase *nodes)
for (input = node->inputs.first; input; input = input->next) {
if (input->source == GPU_SOURCE_TEX_PIXEL) {
if (codegen_input_has_texture(input) && input->definetex) {
- BLI_dynstr_appendf(ds, "\tvec4 tex%d = texture2D(", input->texid);
- BLI_dynstr_appendf(ds, "samp%d, gl_TexCoord[%d].st);\n",
- input->texid, input->texid);
+ BLI_dynstr_appendf(
+ ds, "\tvec4 tex%d = texture2D(", input->texid);
+ BLI_dynstr_appendf(
+ ds, "samp%d, gl_TexCoord[%d].st);\n",
+ input->texid, input->texid);
}
}
}
@@ -729,11 +738,13 @@ static void codegen_declare_tmps(DynStr *ds, ListBase *nodes)
/* declare temporary variables for node output storage */
for (output = node->outputs.first; output; output = output->next) {
if (output->type == GPU_CLOSURE) {
- BLI_dynstr_appendf(ds, "\tClosure tmp%d;\n", output->id);
+ BLI_dynstr_appendf(
+ ds, "\tClosure tmp%d;\n", output->id);
}
else {
- BLI_dynstr_appendf(ds, "\t%s tmp%d;\n",
- GPU_DATATYPE_STR[output->type], output->id);
+ BLI_dynstr_appendf(
+ ds, "\t%s tmp%d;\n",
+ GPU_DATATYPE_STR[output->type], output->id);
}
}
}
@@ -757,8 +768,9 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
BLI_dynstr_appendf(ds, ", gl_TexCoord[%d].st", input->texid);
}
else if (input->source == GPU_SOURCE_TEX_PIXEL) {
- codegen_convert_datatype(ds, input->link->output->type, input->type,
- "tmp", input->link->output->id);
+ codegen_convert_datatype(
+ ds, input->link->output->type, input->type,
+ "tmp", input->link->output->id);
}
else if (input->source == GPU_SOURCE_BUILTIN) {
if (input->builtin == GPU_INVERSE_VIEW_MATRIX)
@@ -862,10 +874,12 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO
for (input = node->inputs.first; input; input = input->next) {
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
if (input->attribtype == CD_TANGENT) {
- BLI_dynstr_appendf(ds, "#ifdef USE_OPENSUBDIV\n");
- BLI_dynstr_appendf(ds, "\t%s var%d;\n",
- GPU_DATATYPE_STR[input->type],
- input->attribid);
+ BLI_dynstr_appendf(
+ ds, "#ifdef USE_OPENSUBDIV\n");
+ BLI_dynstr_appendf(
+ ds, "\t%s var%d;\n",
+ GPU_DATATYPE_STR[input->type],
+ input->attribid);
if (has_tangent == false) {
BLI_dynstr_appendf(ds, "\tvec3 Q1 = dFdx(inpt.v.position.xyz);\n");
BLI_dynstr_appendf(ds, "\tvec3 Q2 = dFdy(inpt.v.position.xyz);\n");
@@ -917,7 +931,7 @@ static const char *attrib_prefix_get(CustomDataType type)
case CD_TANGENT: return "t";
case CD_MCOL: return "c";
case CD_AUTO_FROM_NAME: return "a";
- default: BLI_assert(false && "Gwn_VertAttr Prefix type not found : This should not happen!"); return "";
+ default: BLI_assert(false && "GPUVertAttr Prefix type not found : This should not happen!"); return "";
}
}
@@ -929,12 +943,13 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
char *code;
/* Hairs uv and col attribs are passed by bufferTextures. */
- BLI_dynstr_append(ds,
- "#ifdef HAIR_SHADER\n"
- "#define DEFINE_ATTRIB(type, attr) uniform samplerBuffer attr\n"
- "#else\n"
- "#define DEFINE_ATTRIB(type, attr) in type attr\n"
- "#endif\n"
+ BLI_dynstr_append(
+ ds,
+ "#ifdef HAIR_SHADER\n"
+ "#define DEFINE_ATTRIB(type, attr) uniform samplerBuffer attr\n"
+ "#else\n"
+ "#define DEFINE_ATTRIB(type, attr) in type attr\n"
+ "#endif\n"
);
for (node = nodes->first; node; node = node->next) {
@@ -952,10 +967,12 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
}
else {
unsigned int hash = BLI_ghashutil_strhash_p(input->attribname);
- BLI_dynstr_appendf(ds, "DEFINE_ATTRIB(%s, %s%u);\n",
- GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype), hash);
- BLI_dynstr_appendf(ds, "#define att%d %s%u\n",
- input->attribid, attrib_prefix_get(input->attribtype), hash);
+ BLI_dynstr_appendf(
+ ds, "DEFINE_ATTRIB(%s, %s%u);\n",
+ GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype), hash);
+ BLI_dynstr_appendf(
+ ds, "#define att%d %s%u\n",
+ input->attribid, attrib_prefix_get(input->attribtype), hash);
/* Auto attrib can be vertex color byte buffer.
* We need to know and convert them to linear space in VS. */
if (!use_geom && input->attribtype == CD_AUTO_FROM_NAME) {
@@ -963,33 +980,36 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_appendf(ds, "#define att%d_is_srgb ba%u\n", input->attribid, hash);
}
}
- BLI_dynstr_appendf(ds, "out %s var%d%s;\n",
- GPU_DATATYPE_STR[input->type], input->attribid, use_geom ? "g" : "");
+ BLI_dynstr_appendf(
+ ds, "out %s var%d%s;\n",
+ GPU_DATATYPE_STR[input->type], input->attribid, use_geom ? "g" : "");
}
}
}
BLI_dynstr_append(ds, "\n");
- BLI_dynstr_append(ds,
- "#define ATTRIB\n"
- "uniform mat3 NormalMatrix;\n"
- "uniform mat4 ModelMatrixInverse;\n"
- "vec3 srgb_to_linear_attrib(vec3 c) {\n"
- "\tc = max(c, vec3(0.0));\n"
- "\tvec3 c1 = c * (1.0 / 12.92);\n"
- "\tvec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4));\n"
- "\treturn mix(c1, c2, step(vec3(0.04045), c));\n"
- "}\n\n"
+ BLI_dynstr_append(
+ ds,
+ "#define ATTRIB\n"
+ "uniform mat3 NormalMatrix;\n"
+ "uniform mat4 ModelMatrixInverse;\n"
+ "vec3 srgb_to_linear_attrib(vec3 c) {\n"
+ "\tc = max(c, vec3(0.0));\n"
+ "\tvec3 c1 = c * (1.0 / 12.92);\n"
+ "\tvec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4));\n"
+ "\treturn mix(c1, c2, step(vec3(0.04045), c));\n"
+ "}\n\n"
);
/* Prototype because defined later. */
- BLI_dynstr_append(ds,
- "vec2 hair_get_customdata_vec2(const samplerBuffer);\n"
- "vec3 hair_get_customdata_vec3(const samplerBuffer);\n"
- "vec4 hair_get_customdata_vec4(const samplerBuffer);\n"
- "vec3 hair_get_strand_pos(void);\n"
- "\n"
+ BLI_dynstr_append(
+ ds,
+ "vec2 hair_get_customdata_vec2(const samplerBuffer);\n"
+ "vec3 hair_get_customdata_vec3(const samplerBuffer);\n"
+ "vec4 hair_get_customdata_vec4(const samplerBuffer);\n"
+ "vec3 hair_get_strand_pos(void);\n"
+ "\n"
);
BLI_dynstr_append(ds, "void pass_attrib(in vec3 position) {\n");
@@ -1001,16 +1021,19 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
if (input->attribtype == CD_TANGENT) {
/* Not supported by hairs */
- BLI_dynstr_appendf(ds, "\tvar%d%s = vec4(0.0);\n",
- input->attribid, use_geom ? "g" : "");
+ BLI_dynstr_appendf(
+ ds, "\tvar%d%s = vec4(0.0);\n",
+ input->attribid, use_geom ? "g" : "");
}
else if (input->attribtype == CD_ORCO) {
- BLI_dynstr_appendf(ds, "\tvar%d%s = OrcoTexCoFactors[0] + (ModelMatrixInverse * vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1];\n",
- input->attribid, use_geom ? "g" : "");
+ BLI_dynstr_appendf(
+ ds, "\tvar%d%s = OrcoTexCoFactors[0] + (ModelMatrixInverse * vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1];\n",
+ input->attribid, use_geom ? "g" : "");
}
else {
- BLI_dynstr_appendf(ds, "\tvar%d%s = hair_get_customdata_%s(att%d);\n",
- input->attribid, use_geom ? "g" : "", GPU_DATATYPE_STR[input->type], input->attribid);
+ BLI_dynstr_appendf(
+ ds, "\tvar%d%s = hair_get_customdata_%s(att%d);\n",
+ input->attribid, use_geom ? "g" : "", GPU_DATATYPE_STR[input->type], input->attribid);
}
}
}
@@ -1030,21 +1053,25 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
input->attribid, use_geom ? "g" : "", input->attribid);
}
else if (input->attribtype == CD_ORCO) {
- BLI_dynstr_appendf(ds, "\tvar%d%s = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n",
- input->attribid, use_geom ? "g" : "");
+ BLI_dynstr_appendf(
+ ds, "\tvar%d%s = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n",
+ input->attribid, use_geom ? "g" : "");
}
else if (input->attribtype == CD_MCOL) {
- BLI_dynstr_appendf(ds, "\tvar%d%s = srgb_to_linear_attrib(att%d);\n",
- input->attribid, use_geom ? "g" : "", input->attribid);
+ BLI_dynstr_appendf(
+ ds, "\tvar%d%s = srgb_to_linear_attrib(att%d);\n",
+ input->attribid, use_geom ? "g" : "", input->attribid);
}
else if (input->attribtype == CD_AUTO_FROM_NAME) {
- BLI_dynstr_appendf(ds, "\tvar%d%s = (att%d_is_srgb) ? srgb_to_linear_attrib(att%d) : att%d;\n",
- input->attribid, use_geom ? "g" : "",
- input->attribid, input->attribid, input->attribid);
+ BLI_dynstr_appendf(
+ ds, "\tvar%d%s = (att%d_is_srgb) ? srgb_to_linear_attrib(att%d) : att%d;\n",
+ input->attribid, use_geom ? "g" : "",
+ input->attribid, input->attribid, input->attribid);
}
else {
- BLI_dynstr_appendf(ds, "\tvar%d%s = att%d;\n",
- input->attribid, use_geom ? "g" : "", input->attribid);
+ BLI_dynstr_appendf(
+ ds, "\tvar%d%s = att%d;\n",
+ input->attribid, use_geom ? "g" : "", input->attribid);
}
}
}
@@ -1083,12 +1110,14 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code)
for (node = nodes->first; node; node = node->next) {
for (input = node->inputs.first; input; input = input->next) {
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
- BLI_dynstr_appendf(ds, "in %s var%dg[];\n",
- GPU_DATATYPE_STR[input->type],
- input->attribid);
- BLI_dynstr_appendf(ds, "out %s var%d;\n",
- GPU_DATATYPE_STR[input->type],
- input->attribid);
+ BLI_dynstr_appendf(
+ ds, "in %s var%dg[];\n",
+ GPU_DATATYPE_STR[input->type],
+ input->attribid);
+ BLI_dynstr_appendf(
+ ds, "out %s var%d;\n",
+ GPU_DATATYPE_STR[input->type],
+ input->attribid);
}
}
}
@@ -1382,8 +1411,8 @@ static const char *gpu_uniform_set_function_from_type(eNodeSocketDatatype type)
case SOCK_RGBA:
return "set_rgba";
default:
- BLI_assert(!"No gpu function for non-supported eNodeSocketDatatype");
- return NULL;
+ BLI_assert(!"No gpu function for non-supported eNodeSocketDatatype");
+ return NULL;
}
}
@@ -1553,8 +1582,9 @@ void GPU_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *attribs)
attribs->layer[a].type = input->attribtype;
attribs->layer[a].attribid = input->attribid;
- BLI_strncpy(attribs->layer[a].name, input->attribname,
- sizeof(attribs->layer[a].name));
+ BLI_strncpy(
+ attribs->layer[a].name, input->attribname,
+ sizeof(attribs->layer[a].name));
}
else {
input->attribid = attribs->layer[a].attribid;
@@ -1966,11 +1996,12 @@ GPUPass *GPU_generate_pass_new(
void GPU_pass_compile(GPUPass *pass)
{
if (!pass->compiled) {
- pass->shader = GPU_shader_create(pass->vertexcode,
- pass->fragmentcode,
- pass->geometrycode,
- NULL,
- pass->defines);
+ pass->shader = GPU_shader_create(
+ pass->vertexcode,
+ pass->fragmentcode,
+ pass->geometrycode,
+ NULL,
+ pass->defines);
pass->compiled = true;
}
}
diff --git a/source/blender/gpu/intern/gpu_context.cpp b/source/blender/gpu/intern/gpu_context.cpp
new file mode 100644
index 00000000000..3f2ce958332
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_context.cpp
@@ -0,0 +1,317 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, Clément Foucault
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_vertex_array_id.cpp
+ * \ingroup gpu
+ *
+ * Manage GL vertex array IDs in a thread-safe way
+ * Use these instead of glGenBuffers & its friends
+ * - alloc must be called from a thread that is bound
+ * to the context that will be used for drawing with
+ * this vao.
+ * - free can be called from any thread
+ */
+
+#include "BLI_assert.h"
+#include "BLI_utildefines.h"
+
+#include "GPU_context.h"
+#include "GPU_framebuffer.h"
+
+#include "gpu_batch_private.h"
+#include "gpu_context_private.h"
+
+#include <vector>
+#include <string.h>
+#include <pthread.h>
+#include <mutex>
+#include <unordered_set>
+
+#if TRUST_NO_ONE
+#if 0
+extern "C" {
+extern int BLI_thread_is_main(void); /* Blender-specific function */
+}
+
+static bool thread_is_main() {
+ /* "main" here means the GL context's thread */
+ return BLI_thread_is_main();
+}
+#endif
+#endif
+
+static std::vector<GLuint> orphaned_buffer_ids;
+static std::vector<GLuint> orphaned_texture_ids;
+
+static std::mutex orphans_mutex;
+
+struct GPUContext {
+ GLuint default_vao;
+ std::unordered_set<GPUBatch *> batches; /* Batches that have VAOs from this context */
+#ifdef DEBUG
+ std::unordered_set<GPUFrameBuffer *> framebuffers; /* Framebuffers that have FBO from this context */
+#endif
+ std::vector<GLuint> orphaned_vertarray_ids;
+ std::vector<GLuint> orphaned_framebuffer_ids;
+ std::mutex orphans_mutex; /* todo: try spinlock instead */
+#if TRUST_NO_ONE
+ pthread_t thread; /* Thread on which this context is active. */
+ bool thread_is_used;
+
+ GPUContext() {
+ thread_is_used = false;
+ }
+#endif
+};
+
+#if defined(_MSC_VER) && (_MSC_VER == 1800)
+#define thread_local __declspec(thread)
+thread_local GPUContext *active_ctx = NULL;
+#else
+static thread_local GPUContext *active_ctx = NULL;
+#endif
+
+static void orphans_add(GPUContext *ctx, std::vector<GLuint> *orphan_list, GLuint id)
+{
+ std::mutex *mutex = (ctx) ? &ctx->orphans_mutex : &orphans_mutex;
+
+ mutex->lock();
+ orphan_list->emplace_back(id);
+ mutex->unlock();
+}
+
+static void orphans_clear(GPUContext *ctx)
+{
+ BLI_assert(ctx); /* need at least an active context */
+ BLI_assert(pthread_equal(pthread_self(), ctx->thread)); /* context has been activated by another thread! */
+
+ ctx->orphans_mutex.lock();
+ if (!ctx->orphaned_vertarray_ids.empty()) {
+ uint orphan_len = (uint)ctx->orphaned_vertarray_ids.size();
+ glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data());
+ ctx->orphaned_vertarray_ids.clear();
+ }
+ if (!ctx->orphaned_framebuffer_ids.empty()) {
+ uint orphan_len = (uint)ctx->orphaned_framebuffer_ids.size();
+ glDeleteFramebuffers(orphan_len, ctx->orphaned_framebuffer_ids.data());
+ ctx->orphaned_framebuffer_ids.clear();
+ }
+
+ ctx->orphans_mutex.unlock();
+
+ orphans_mutex.lock();
+ if (!orphaned_buffer_ids.empty()) {
+ uint orphan_len = (uint)orphaned_buffer_ids.size();
+ glDeleteBuffers(orphan_len, orphaned_buffer_ids.data());
+ orphaned_buffer_ids.clear();
+ }
+ if (!orphaned_texture_ids.empty()) {
+ uint orphan_len = (uint)orphaned_texture_ids.size();
+ glDeleteTextures(orphan_len, orphaned_texture_ids.data());
+ orphaned_texture_ids.clear();
+ }
+ orphans_mutex.unlock();
+}
+
+GPUContext *GPU_context_create(void)
+{
+ /* BLI_assert(thread_is_main()); */
+ GPUContext *ctx = new GPUContext;
+ glGenVertexArrays(1, &ctx->default_vao);
+ GPU_context_active_set(ctx);
+ return ctx;
+}
+
+/* to be called after GPU_context_active_set(ctx_to_destroy) */
+void GPU_context_discard(GPUContext *ctx)
+{
+ /* Make sure no other thread has locked it. */
+ BLI_assert(ctx == active_ctx);
+ BLI_assert(pthread_equal(pthread_self(), ctx->thread));
+ BLI_assert(ctx->orphaned_vertarray_ids.empty());
+#ifdef DEBUG
+ /* For now don't allow GPUFrameBuffers to be reuse in another ctx. */
+ BLI_assert(ctx->framebuffers.empty());
+#endif
+ /* delete remaining vaos */
+ while (!ctx->batches.empty()) {
+ /* this removes the array entry */
+ GPU_batch_vao_cache_clear(*ctx->batches.begin());
+ }
+ glDeleteVertexArrays(1, &ctx->default_vao);
+ delete ctx;
+ active_ctx = NULL;
+}
+
+/* ctx can be NULL */
+void GPU_context_active_set(GPUContext *ctx)
+{
+#if TRUST_NO_ONE
+ if (active_ctx) {
+ active_ctx->thread_is_used = false;
+ }
+ /* Make sure no other context is already bound to this thread. */
+ if (ctx) {
+ /* Make sure no other thread has locked it. */
+ assert(ctx->thread_is_used == false);
+ ctx->thread = pthread_self();
+ ctx->thread_is_used = true;
+ }
+#endif
+ if (ctx) {
+ orphans_clear(ctx);
+ }
+ active_ctx = ctx;
+}
+
+GPUContext *GPU_context_active_get(void)
+{
+ return active_ctx;
+}
+
+GLuint GPU_vao_default(void)
+{
+ BLI_assert(active_ctx); /* need at least an active context */
+ BLI_assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */
+ return active_ctx->default_vao;
+}
+
+GLuint GPU_vao_alloc(void)
+{
+ GLuint new_vao_id = 0;
+ orphans_clear(active_ctx);
+ glGenVertexArrays(1, &new_vao_id);
+ return new_vao_id;
+}
+
+GLuint GPU_fbo_alloc(void)
+{
+ GLuint new_fbo_id = 0;
+ orphans_clear(active_ctx);
+ glGenFramebuffers(1, &new_fbo_id);
+ return new_fbo_id;
+}
+
+GLuint GPU_buf_alloc(void)
+{
+ GLuint new_buffer_id = 0;
+ orphans_clear(active_ctx);
+ glGenBuffers(1, &new_buffer_id);
+ return new_buffer_id;
+}
+
+GLuint GPU_tex_alloc(void)
+{
+ GLuint new_texture_id = 0;
+ orphans_clear(active_ctx);
+ glGenTextures(1, &new_texture_id);
+ return new_texture_id;
+}
+
+void GPU_vao_free(GLuint vao_id, GPUContext *ctx)
+{
+ BLI_assert(ctx);
+ if (ctx == active_ctx) {
+ glDeleteVertexArrays(1, &vao_id);
+ }
+ else {
+ orphans_add(ctx, &ctx->orphaned_vertarray_ids, vao_id);
+ }
+}
+
+void GPU_fbo_free(GLuint fbo_id, GPUContext *ctx)
+{
+ BLI_assert(ctx);
+ if (ctx == active_ctx) {
+ glDeleteFramebuffers(1, &fbo_id);
+ }
+ else {
+ orphans_add(ctx, &ctx->orphaned_framebuffer_ids, fbo_id);
+ }
+}
+
+void GPU_buf_free(GLuint buf_id)
+{
+ if (active_ctx) {
+ glDeleteBuffers(1, &buf_id);
+ }
+ else {
+ orphans_add(NULL, &orphaned_buffer_ids, buf_id);
+ }
+}
+
+void GPU_tex_free(GLuint tex_id)
+{
+ if (active_ctx) {
+ glDeleteTextures(1, &tex_id);
+ }
+ else {
+ orphans_add(NULL, &orphaned_texture_ids, tex_id);
+ }
+}
+
+/* GPUBatch & GPUFrameBuffer contains respectively VAO & FBO indices
+ * which are not shared across contexts. So we need to keep track of
+ * ownership. */
+
+void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch)
+{
+ BLI_assert(ctx);
+ ctx->orphans_mutex.lock();
+ ctx->batches.emplace(batch);
+ ctx->orphans_mutex.unlock();
+}
+
+void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch)
+{
+ BLI_assert(ctx);
+ ctx->orphans_mutex.lock();
+ ctx->batches.erase(batch);
+ ctx->orphans_mutex.unlock();
+}
+
+void gpu_context_add_framebuffer(GPUContext *ctx, GPUFrameBuffer *fb)
+{
+#ifdef DEBUG
+ BLI_assert(ctx);
+ ctx->orphans_mutex.lock();
+ ctx->framebuffers.emplace(fb);
+ ctx->orphans_mutex.unlock();
+#else
+ UNUSED_VARS(ctx, fb);
+#endif
+}
+
+void gpu_context_remove_framebuffer(GPUContext *ctx, GPUFrameBuffer *fb)
+{
+#ifdef DEBUG
+ BLI_assert(ctx);
+ ctx->orphans_mutex.lock();
+ ctx->framebuffers.erase(fb);
+ ctx->orphans_mutex.unlock();
+#else
+ UNUSED_VARS(ctx, fb);
+#endif
+}
diff --git a/source/blender/gpu/intern/gpu_context_private.h b/source/blender/gpu/intern/gpu_context_private.h
new file mode 100644
index 00000000000..4881a892e38
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_context_private.h
@@ -0,0 +1,68 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_context_private.h
+ * \ingroup gpu
+ *
+ * This interface allow GPU to manage GL objects for mutiple context and threads.
+ */
+
+#ifndef __GPU_CONTEXT_PRIVATE_H__
+#define __GPU_CONTEXT_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "GPU_context.h"
+
+struct GPUFrameBuffer;
+
+GLuint GPU_vao_default(void);
+
+/* These require a gl ctx bound. */
+GLuint GPU_buf_alloc(void);
+GLuint GPU_tex_alloc(void);
+GLuint GPU_vao_alloc(void);
+GLuint GPU_fbo_alloc(void);
+
+/* These can be called any threads even without gl ctx. */
+void GPU_buf_free(GLuint buf_id);
+void GPU_tex_free(GLuint tex_id);
+/* These two need the ctx the id was created with. */
+void GPU_vao_free(GLuint vao_id, GPUContext *ctx);
+void GPU_fbo_free(GLuint fbo_id, GPUContext *ctx);
+
+void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch);
+void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch);
+
+void gpu_context_add_framebuffer(GPUContext *ctx, struct GPUFrameBuffer *fb);
+void gpu_context_remove_framebuffer(GPUContext *ctx, struct GPUFrameBuffer *fb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GPU_CONTEXT_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 7383868843d..965caba0955 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -107,7 +107,7 @@ static bool is_over_resolution_limit(GLenum textarget, int w, int h)
int size = (textarget == GL_TEXTURE_2D) ?
GPU_max_texture_size() : GPU_max_cube_map_size();
int reslimit = (U.glreslimit != 0) ?
- min_ii(U.glreslimit, size) : size;
+ min_ii(U.glreslimit, size) : size;
return (w > reslimit || h > reslimit);
}
@@ -239,42 +239,48 @@ typedef struct VerifyThreadData {
float *srgb_frect;
} VerifyThreadData;
-static void gpu_verify_high_bit_srgb_buffer_slice(float *srgb_frect,
- ImBuf *ibuf,
- const int start_line,
- const int height)
+static void gpu_verify_high_bit_srgb_buffer_slice(
+ float *srgb_frect,
+ ImBuf *ibuf,
+ const int start_line,
+ const int height)
{
size_t offset = ibuf->channels * start_line * ibuf->x;
float *current_srgb_frect = srgb_frect + offset;
float *current_rect_float = ibuf->rect_float + offset;
- IMB_buffer_float_from_float(current_srgb_frect,
- current_rect_float,
- ibuf->channels,
- IB_PROFILE_SRGB,
- IB_PROFILE_LINEAR_RGB, true,
- ibuf->x, height,
- ibuf->x, ibuf->x);
+ IMB_buffer_float_from_float(
+ current_srgb_frect,
+ current_rect_float,
+ ibuf->channels,
+ IB_PROFILE_SRGB,
+ IB_PROFILE_LINEAR_RGB, true,
+ ibuf->x, height,
+ ibuf->x, ibuf->x);
IMB_buffer_float_unpremultiply(current_srgb_frect, ibuf->x, height);
}
-static void verify_thread_do(void *data_v,
- int start_scanline,
- int num_scanlines)
+static void verify_thread_do(
+ void *data_v,
+ int start_scanline,
+ int num_scanlines)
{
VerifyThreadData *data = (VerifyThreadData *)data_v;
- gpu_verify_high_bit_srgb_buffer_slice(data->srgb_frect,
- data->ibuf,
- start_scanline,
- num_scanlines);
+ gpu_verify_high_bit_srgb_buffer_slice(
+ data->srgb_frect,
+ data->ibuf,
+ start_scanline,
+ num_scanlines);
}
-static void gpu_verify_high_bit_srgb_buffer(float *srgb_frect,
- ImBuf *ibuf)
+static void gpu_verify_high_bit_srgb_buffer(
+ float *srgb_frect,
+ ImBuf *ibuf)
{
if (ibuf->y < 64) {
- gpu_verify_high_bit_srgb_buffer_slice(srgb_frect,
- ibuf,
- 0, ibuf->y);
+ gpu_verify_high_bit_srgb_buffer_slice(
+ srgb_frect,
+ ibuf,
+ 0, ibuf->y);
}
else {
VerifyThreadData data;
@@ -284,11 +290,12 @@ static void gpu_verify_high_bit_srgb_buffer(float *srgb_frect,
}
}
-GPUTexture *GPU_texture_from_blender(Image *ima,
- ImageUser *iuser,
- int textarget,
- bool is_data,
- double UNUSED(time))
+GPUTexture *GPU_texture_from_blender(
+ Image *ima,
+ ImageUser *iuser,
+ int textarget,
+ bool is_data,
+ double UNUSED(time))
{
if (ima == NULL) {
return NULL;
@@ -363,11 +370,14 @@ GPUTexture *GPU_texture_from_blender(Image *ima,
const bool mipmap = GPU_get_mipmap();
#ifdef WITH_DDS
- if (ibuf->ftype == IMB_FTYPE_DDS)
+ if (ibuf->ftype == IMB_FTYPE_DDS) {
GPU_create_gl_tex_compressed(&bindcode, rect, rectw, recth, textarget, mipmap, ima, ibuf);
+ }
else
#endif
+ {
GPU_create_gl_tex(&bindcode, rect, frect, rectw, recth, textarget, mipmap, use_high_bit_depth, ima);
+ }
/* mark as non-color data texture */
if (bindcode) {
@@ -556,8 +566,9 @@ void GPU_create_gl_tex(
if (mip_cube_map) {
for (int j = 0; j < 6; j++) {
- glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, i,
- informat, mipw, miph, 0, GL_RGBA, type, mip_cube_map[j]);
+ glTexImage2D(
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, i,
+ informat, mipw, miph, 0, GL_RGBA, type, mip_cube_map[j]);
}
}
gpu_del_cube_map(mip_cube_map);
@@ -639,8 +650,9 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf)
size = ((width + 3) / 4) * ((height + 3) / 4) * blocksize;
- glCompressedTexImage2D(GL_TEXTURE_2D, i, format, width, height,
- 0, size, ibuf->dds_data.data + offset);
+ glCompressedTexImage2D(
+ GL_TEXTURE_2D, i, format, width, height,
+ 0, size, ibuf->dds_data.data + offset);
offset += size;
width >>= 1;
@@ -755,8 +767,9 @@ static bool gpu_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x,
ImBuf *ibuf_scale = IMB_allocFromBuffer(NULL, frect, w, h);
IMB_scaleImBuf(ibuf_scale, rectw, recth);
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA,
- GL_FLOAT, ibuf_scale->rect_float);
+ glTexSubImage2D(
+ GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA,
+ GL_FLOAT, ibuf_scale->rect_float);
IMB_freeImBuf(ibuf_scale);
}
@@ -775,8 +788,9 @@ static bool gpu_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x,
}
}
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA,
- GL_UNSIGNED_BYTE, scalerect);
+ glTexSubImage2D(
+ GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA,
+ GL_UNSIGNED_BYTE, scalerect);
MEM_freeN(scalerect);
}
@@ -860,8 +874,9 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
- GL_UNSIGNED_BYTE, ibuf->rect);
+ glTexSubImage2D(
+ GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
+ GL_UNSIGNED_BYTE, ibuf->rect);
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
@@ -913,8 +928,9 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
}
/* density only */
else {
- sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2],
- GPU_R8, smoke_get_density(sds->fluid), NULL);
+ sds->tex = GPU_texture_create_3D(
+ sds->res[0], sds->res[1], sds->res[2],
+ GPU_R8, smoke_get_density(sds->fluid), NULL);
/* Swizzle the RGBA components to read the Red channel so
* that the shader stay the same for colored and non color
@@ -926,10 +942,12 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED);
GPU_texture_unbind(sds->tex);
}
- sds->tex_flame = (smoke_has_fuel(sds->fluid)) ?
- GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2],
- GPU_R8, smoke_get_flame(sds->fluid), NULL) :
- NULL;
+ sds->tex_flame = (
+ smoke_has_fuel(sds->fluid) ?
+ GPU_texture_create_3D(
+ sds->res[0], sds->res[1], sds->res[2],
+ GPU_R8, smoke_get_flame(sds->fluid), NULL) :
+ NULL);
}
else if (!sds->tex && highres) {
/* rgba texture for color + density */
@@ -941,8 +959,9 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
}
/* density only */
else {
- sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2],
- GPU_R8, smoke_turbulence_get_density(sds->wt), NULL);
+ sds->tex = GPU_texture_create_3D(
+ sds->res_wt[0], sds->res_wt[1], sds->res_wt[2],
+ GPU_R8, smoke_turbulence_get_density(sds->wt), NULL);
/* Swizzle the RGBA components to read the Red channel so
* that the shader stay the same for colored and non color
@@ -954,14 +973,17 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED);
GPU_texture_unbind(sds->tex);
}
- sds->tex_flame = (smoke_turbulence_has_fuel(sds->wt)) ?
- GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2],
- GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL) :
- NULL;
+ sds->tex_flame = (
+ smoke_turbulence_has_fuel(sds->wt) ?
+ GPU_texture_create_3D(
+ sds->res_wt[0], sds->res_wt[1], sds->res_wt[2],
+ GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL) :
+ NULL);
}
- sds->tex_shadow = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2],
- GPU_R8, sds->shadow, NULL);
+ sds->tex_shadow = GPU_texture_create_3D(
+ sds->res[0], sds->res[1], sds->res[2],
+ GPU_R8, sds->shadow, NULL);
}
#else // WITH_SMOKE
(void)highres;
@@ -971,6 +993,52 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
#endif // WITH_SMOKE
}
+void GPU_create_smoke_velocity(SmokeModifierData *smd)
+{
+#ifdef WITH_SMOKE
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
+ SmokeDomainSettings *sds = smd->domain;
+
+ const float *vel_x = smoke_get_velocity_x(sds->fluid);
+ const float *vel_y = smoke_get_velocity_y(sds->fluid);
+ const float *vel_z = smoke_get_velocity_z(sds->fluid);
+
+ if (ELEM(NULL, vel_x, vel_y, vel_z)) {
+ return;
+ }
+
+ if (!sds->tex_velocity_x) {
+ sds->tex_velocity_x = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_x, NULL);
+ sds->tex_velocity_y = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_y, NULL);
+ sds->tex_velocity_z = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_z, NULL);
+ }
+ }
+#else // WITH_SMOKE
+ smd->domain->tex_velocity_x = NULL;
+ smd->domain->tex_velocity_y = NULL;
+ smd->domain->tex_velocity_z = NULL;
+#endif // WITH_SMOKE
+}
+
+/* TODO Unify with the other GPU_free_smoke. */
+void GPU_free_smoke_velocity(SmokeModifierData *smd)
+{
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
+ if (smd->domain->tex_velocity_x)
+ GPU_texture_free(smd->domain->tex_velocity_x);
+
+ if (smd->domain->tex_velocity_y)
+ GPU_texture_free(smd->domain->tex_velocity_y);
+
+ if (smd->domain->tex_velocity_z)
+ GPU_texture_free(smd->domain->tex_velocity_z);
+
+ smd->domain->tex_velocity_x = NULL;
+ smd->domain->tex_velocity_y = NULL;
+ smd->domain->tex_velocity_z = NULL;
+ }
+}
+
static LinkNode *image_free_queue = NULL;
static void gpu_queue_image_for_free(Image *ima)
@@ -1255,10 +1323,10 @@ void GPU_select_to_index_array(unsigned int *col, const unsigned int size)
{
#define INDEX_BUF_ARRAY(INDEX_FROM_BUF_BITS) \
for (i = size; i--; col++) { \
- if ((c = *col)) { \
- *col = INDEX_FROM_BUF_BITS(c); \
- } \
- } ((void)0)
+ if ((c = *col)) { \
+ *col = INDEX_FROM_BUF_BITS(c); \
+ } \
+ } ((void)0)
if (size > 0) {
unsigned int i, c;
diff --git a/source/blender/gpu/intern/gpu_element.c b/source/blender/gpu/intern/gpu_element.c
new file mode 100644
index 00000000000..901e09443d1
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_element.c
@@ -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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_element.c
+ * \ingroup gpu
+ *
+ * GPU element list (AKA index buffer)
+ */
+
+#include "GPU_element.h"
+
+#include "gpu_context_private.h"
+
+#include <stdlib.h>
+
+#define KEEP_SINGLE_COPY 1
+
+static GLenum convert_index_type_to_gl(GPUIndexBufType type)
+{
+ static const GLenum table[] = {
+ [GPU_INDEX_U8] = GL_UNSIGNED_BYTE, /* GL has this, Vulkan does not */
+ [GPU_INDEX_U16] = GL_UNSIGNED_SHORT,
+ [GPU_INDEX_U32] = GL_UNSIGNED_INT
+ };
+ return table[type];
+}
+
+uint GPU_indexbuf_size_get(const GPUIndexBuf *elem)
+{
+#if GPU_TRACK_INDEX_RANGE
+ static const uint table[] = {
+ [GPU_INDEX_U8] = sizeof(GLubyte), /* GL has this, Vulkan does not */
+ [GPU_INDEX_U16] = sizeof(GLushort),
+ [GPU_INDEX_U32] = sizeof(GLuint)
+ };
+ return elem->index_len * table[elem->index_type];
+#else
+ return elem->index_len * sizeof(GLuint);
+#endif
+}
+
+void GPU_indexbuf_init_ex(
+ GPUIndexBufBuilder *builder, GPUPrimType prim_type,
+ uint index_len, uint vertex_len, bool use_prim_restart)
+{
+ builder->use_prim_restart = use_prim_restart;
+ builder->max_allowed_index = vertex_len - 1;
+ builder->max_index_len = index_len;
+ builder->index_len = 0; // start empty
+ builder->prim_type = prim_type;
+ builder->data = calloc(builder->max_index_len, sizeof(uint));
+}
+
+void GPU_indexbuf_init(GPUIndexBufBuilder *builder, GPUPrimType prim_type, uint prim_len, uint vertex_len)
+{
+ uint verts_per_prim = 0;
+ switch (prim_type) {
+ case GPU_PRIM_POINTS:
+ verts_per_prim = 1;
+ break;
+ case GPU_PRIM_LINES:
+ verts_per_prim = 2;
+ break;
+ case GPU_PRIM_TRIS:
+ verts_per_prim = 3;
+ break;
+ case GPU_PRIM_LINES_ADJ:
+ verts_per_prim = 4;
+ break;
+ default:
+#if TRUST_NO_ONE
+ assert(false);
+#endif
+ return;
+ }
+
+ GPU_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false);
+}
+
+void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *builder, uint v)
+{
+#if TRUST_NO_ONE
+ assert(builder->data != NULL);
+ assert(builder->index_len < builder->max_index_len);
+ assert(v <= builder->max_allowed_index);
+#endif
+ builder->data[builder->index_len++] = v;
+}
+
+void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *builder)
+{
+#if TRUST_NO_ONE
+ assert(builder->data != NULL);
+ assert(builder->index_len < builder->max_index_len);
+ assert(builder->use_prim_restart);
+#endif
+ builder->data[builder->index_len++] = GPU_PRIM_RESTART;
+}
+
+void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder *builder, uint v)
+{
+#if TRUST_NO_ONE
+ assert(builder->prim_type == GPU_PRIM_POINTS);
+#endif
+ GPU_indexbuf_add_generic_vert(builder, v);
+}
+
+void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder *builder, uint v1, uint v2)
+{
+#if TRUST_NO_ONE
+ assert(builder->prim_type == GPU_PRIM_LINES);
+ assert(v1 != v2);
+#endif
+ GPU_indexbuf_add_generic_vert(builder, v1);
+ GPU_indexbuf_add_generic_vert(builder, v2);
+}
+
+void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *builder, uint v1, uint v2, uint v3)
+{
+#if TRUST_NO_ONE
+ assert(builder->prim_type == GPU_PRIM_TRIS);
+ assert(v1 != v2 && v2 != v3 && v3 != v1);
+#endif
+ GPU_indexbuf_add_generic_vert(builder, v1);
+ GPU_indexbuf_add_generic_vert(builder, v2);
+ GPU_indexbuf_add_generic_vert(builder, v3);
+}
+
+void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder *builder, uint v1, uint v2, uint v3, uint v4)
+{
+#if TRUST_NO_ONE
+ assert(builder->prim_type == GPU_PRIM_LINES_ADJ);
+ assert(v2 != v3); /* only the line need diff indices */
+#endif
+ GPU_indexbuf_add_generic_vert(builder, v1);
+ GPU_indexbuf_add_generic_vert(builder, v2);
+ GPU_indexbuf_add_generic_vert(builder, v3);
+ GPU_indexbuf_add_generic_vert(builder, v4);
+}
+
+#if GPU_TRACK_INDEX_RANGE
+/* Everything remains 32 bit while building to keep things simple.
+ * Find min/max after, then convert to smallest index type possible. */
+
+static uint index_range(const uint values[], uint value_len, uint *min_out, uint *max_out)
+{
+ if (value_len == 0) {
+ *min_out = 0;
+ *max_out = 0;
+ return 0;
+ }
+ uint min_value = values[0];
+ uint max_value = values[0];
+ for (uint i = 1; i < value_len; ++i) {
+ const uint value = values[i];
+ if (value == GPU_PRIM_RESTART)
+ continue;
+ else if (value < min_value)
+ min_value = value;
+ else if (value > max_value)
+ max_value = value;
+ }
+ *min_out = min_value;
+ *max_out = max_value;
+ return max_value - min_value;
+}
+
+static void squeeze_indices_byte(GPUIndexBufBuilder *builder, GPUIndexBuf *elem)
+{
+ const uint *values = builder->data;
+ const uint index_len = elem->index_len;
+
+ /* data will never be *larger* than builder->data...
+ * converting in place to avoid extra allocation */
+ GLubyte *data = (GLubyte *)builder->data;
+
+ if (elem->max_index > 0xFF) {
+ const uint base = elem->min_index;
+ elem->base_index = base;
+ elem->min_index = 0;
+ elem->max_index -= base;
+ for (uint i = 0; i < index_len; ++i) {
+ data[i] = (values[i] == GPU_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base);
+ }
+ }
+ else {
+ elem->base_index = 0;
+ for (uint i = 0; i < index_len; ++i) {
+ data[i] = (GLubyte)(values[i]);
+ }
+ }
+}
+
+static void squeeze_indices_short(GPUIndexBufBuilder *builder, GPUIndexBuf *elem)
+{
+ const uint *values = builder->data;
+ const uint index_len = elem->index_len;
+
+ /* data will never be *larger* than builder->data...
+ * converting in place to avoid extra allocation */
+ GLushort *data = (GLushort *)builder->data;
+
+ if (elem->max_index > 0xFFFF) {
+ const uint base = elem->min_index;
+ elem->base_index = base;
+ elem->min_index = 0;
+ elem->max_index -= base;
+ for (uint i = 0; i < index_len; ++i) {
+ data[i] = (values[i] == GPU_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base);
+ }
+ }
+ else {
+ elem->base_index = 0;
+ for (uint i = 0; i < index_len; ++i) {
+ data[i] = (GLushort)(values[i]);
+ }
+ }
+}
+
+#endif /* GPU_TRACK_INDEX_RANGE */
+
+GPUIndexBuf *GPU_indexbuf_build(GPUIndexBufBuilder *builder)
+{
+ GPUIndexBuf *elem = calloc(1, sizeof(GPUIndexBuf));
+ GPU_indexbuf_build_in_place(builder, elem);
+ return elem;
+}
+
+void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *builder, GPUIndexBuf *elem)
+{
+#if TRUST_NO_ONE
+ assert(builder->data != NULL);
+#endif
+ elem->index_len = builder->index_len;
+ elem->use_prim_restart = builder->use_prim_restart;
+
+#if GPU_TRACK_INDEX_RANGE
+ uint range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index);
+
+ /* count the primitive restart index. */
+ if (elem->use_prim_restart) {
+ range += 1;
+ }
+
+ if (range <= 0xFF) {
+ elem->index_type = GPU_INDEX_U8;
+ squeeze_indices_byte(builder, elem);
+ }
+ else if (range <= 0xFFFF) {
+ elem->index_type = GPU_INDEX_U16;
+ squeeze_indices_short(builder, elem);
+ }
+ else {
+ elem->index_type = GPU_INDEX_U32;
+ elem->base_index = 0;
+ }
+ elem->gl_index_type = convert_index_type_to_gl(elem->index_type);
+#endif
+
+ if (elem->vbo_id == 0) {
+ elem->vbo_id = GPU_buf_alloc();
+ }
+ /* send data to GPU */
+ /* GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound,
+ * so we use the GL_ARRAY_BUFFER here to create a buffer without
+ * interfering in the VAO state. */
+ glBindBuffer(GL_ARRAY_BUFFER, elem->vbo_id);
+ glBufferData(GL_ARRAY_BUFFER, GPU_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW);
+
+ /* discard builder (one-time use) */
+ free(builder->data);
+ builder->data = NULL;
+ /* other fields are safe to leave */
+}
+
+void GPU_indexbuf_use(GPUIndexBuf *elem)
+{
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id);
+}
+
+void GPU_indexbuf_discard(GPUIndexBuf *elem)
+{
+ if (elem->vbo_id) {
+ GPU_buf_free(elem->vbo_id);
+ }
+ free(elem);
+}
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index eabd501f1d5..ba8dcb04269 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -42,7 +42,8 @@
#include "GPU_shader.h"
#include "GPU_texture.h"
-#include "intern/gpu_private.h"
+#include "gpu_private.h"
+#include "gpu_context_private.h"
static ThreadLocal(void *) g_currentfb;
@@ -69,6 +70,7 @@ typedef enum {
#define GPU_FB_ATTACHEMENT_SET_DIRTY(flag, type) (flag |= (1 << type))
struct GPUFrameBuffer {
+ GPUContext *ctx;
GLuint object;
GPUAttachment attachments[GPU_FB_MAX_ATTACHEMENT];
uint16_t dirty_flag;
@@ -121,7 +123,7 @@ static GPUTexture *framebuffer_get_depth_tex(GPUFrameBuffer *fb)
if (fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex)
return fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex;
else
- return fb->attachments[GPU_FB_DEPTH_STENCIL_ATTACHMENT].tex;;
+ return fb->attachments[GPU_FB_DEPTH_STENCIL_ATTACHMENT].tex;
}
static GPUTexture *framebuffer_get_color_tex(GPUFrameBuffer *fb, int slot)
@@ -167,12 +169,12 @@ static void gpu_print_framebuffer_error(GLenum status, char err_out[256])
void gpu_framebuffer_module_init(void)
{
- BLI_thread_local_create(g_currentfb);
+ BLI_thread_local_create(g_currentfb);
}
void gpu_framebuffer_module_exit(void)
{
- BLI_thread_local_delete(g_currentfb);
+ BLI_thread_local_delete(g_currentfb);
}
static uint gpu_framebuffer_current_get(void)
@@ -196,7 +198,9 @@ GPUFrameBuffer *GPU_framebuffer_create(void)
static void gpu_framebuffer_init(GPUFrameBuffer *fb)
{
- glGenFramebuffers(1, &fb->object);
+ fb->object = GPU_fbo_alloc();
+ fb->ctx = GPU_context_active_get();
+ gpu_context_add_framebuffer(fb->ctx, fb);
}
void GPU_framebuffer_free(GPUFrameBuffer *fb)
@@ -207,8 +211,11 @@ void GPU_framebuffer_free(GPUFrameBuffer *fb)
}
}
- /* This restores the framebuffer if it was bound */
- glDeleteFramebuffers(1, &fb->object);
+ if (fb->object != 0) {
+ /* This restores the framebuffer if it was bound */
+ GPU_fbo_free(fb->object, fb->ctx);
+ gpu_context_remove_framebuffer(fb->ctx, fb);
+ }
if (gpu_framebuffer_current_get() == fb->object) {
gpu_framebuffer_current_set(0);
@@ -300,7 +307,7 @@ void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, GPUTexture *tex)
* Setting GPUAttachment.mip to -1 will leave the texture in this slot.
* Setting GPUAttachment.tex to NULL will detach the texture in this slot.
**/
-void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_ct)
+void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len)
{
if (config[0].tex) {
BLI_assert(GPU_texture_depth(config[0].tex));
@@ -317,7 +324,7 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *confi
}
int slot = 0;
- for (int i = 1; i < config_ct; ++i, ++slot) {
+ for (int i = 1; i < config_len; ++i, ++slot) {
if (config[i].tex != NULL) {
BLI_assert(GPU_texture_depth(config[i].tex) == false);
gpu_framebuffer_texture_attach_ex(fb, config[i].tex, slot, config[i].layer, config[i].mip);
@@ -340,8 +347,9 @@ static void gpu_framebuffer_attachment_attach(GPUAttachment *attach, GPUAttachme
if (attach->layer > -1) {
if (GPU_texture_cube(attach->tex)) {
- glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + attach->layer,
- tex_bind, attach->mip);
+ glFramebufferTexture2D(
+ GL_FRAMEBUFFER, gl_attachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + attach->layer,
+ tex_bind, attach->mip);
}
else {
glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_attachment, tex_bind, attach->mip, attach->layer);
@@ -518,7 +526,7 @@ void GPU_framebuffer_read_color(
case 1: type = GL_RED; break;
case 2: type = GL_RG; break;
case 3: type = GL_RGB; break;
- case 4: type = GL_RGBA; break;
+ case 4: type = GL_RGBA; break;
default:
BLI_assert(false && "wrong number of read channels");
return;
@@ -549,12 +557,14 @@ void GPU_framebuffer_blit(
const bool do_depth = (blit_buffers & GPU_DEPTH_BIT);
const bool do_stencil = (blit_buffers & GPU_STENCIL_BIT);
- GPUTexture *read_tex = (do_depth || do_stencil)
- ? framebuffer_get_depth_tex(fb_read)
- : framebuffer_get_color_tex(fb_read, read_slot);
- GPUTexture *write_tex = (do_depth || do_stencil)
- ? framebuffer_get_depth_tex(fb_write)
- : framebuffer_get_color_tex(fb_write, read_slot);
+ GPUTexture *read_tex = (
+ (do_depth || do_stencil) ?
+ framebuffer_get_depth_tex(fb_read) :
+ framebuffer_get_color_tex(fb_read, read_slot));
+ GPUTexture *write_tex = (
+ (do_depth || do_stencil) ?
+ framebuffer_get_depth_tex(fb_write) :
+ framebuffer_get_color_tex(fb_write, read_slot));
if (do_depth) {
BLI_assert(GPU_texture_depth(read_tex) && GPU_texture_depth(write_tex));
@@ -585,9 +595,10 @@ void GPU_framebuffer_blit(
GLbitfield mask = convert_buffer_bits_to_gl(blit_buffers);
- glBlitFramebuffer(0, 0, fb_read->width, fb_read->height,
- 0, 0, fb_write->width, fb_write->height,
- mask, GL_NEAREST);
+ glBlitFramebuffer(
+ 0, 0, fb_read->width, fb_read->height,
+ 0, 0, fb_write->width, fb_write->height,
+ mask, GL_NEAREST);
/* Restore previous framebuffer */
if (fb_write->object == prev_fb) {
@@ -679,7 +690,8 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
ofs = MEM_callocN(sizeof(GPUOffScreen), "GPUOffScreen");
- ofs->color = GPU_texture_create_2D_multisample(width, height,
+ ofs->color = GPU_texture_create_2D_multisample(
+ width, height,
(high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, NULL, samples, err_out);
if (depth) {
@@ -776,14 +788,16 @@ void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels)
/* create texture for new 'fbo_blit' */
glGenTextures(1, &tex_blit);
glBindTexture(GL_TEXTURE_2D, tex_blit);
- glTexImage2D(GL_TEXTURE_2D, 0, (type == GL_FLOAT) ? GL_RGBA16F : GL_RGBA8,
- w, h, 0, GL_RGBA, type, 0);
+ glTexImage2D(
+ GL_TEXTURE_2D, 0, (type == GL_FLOAT) ? GL_RGBA16F : GL_RGBA8,
+ w, h, 0, GL_RGBA, type, 0);
/* write into new single-sample buffer */
glGenFramebuffers(1, &fbo_blit);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_blit);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, tex_blit, 0);
+ glFramebufferTexture2D(
+ GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, tex_blit, 0);
GLenum status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 5f22b7f9279..9674cf0b9f7 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -15,22 +15,144 @@
* 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) 2016 Blender Foundation.
+ * The Original Code is Copyright (C) 2016 by Mike Erwin.
* All rights reserved.
*
- * The Original Code is: all of this file.
- *
- * Contributor(s): Mike Erwin
+ * Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
-#include "GPU_immediate.h"
-#include "GPU_matrix.h"
+/** \file blender/gpu/intern/gpu_immediate.c
+ * \ingroup gpu
+ *
+ * GPU immediate mode work-alike
+ */
+
#include "UI_resources.h"
-#include "BLI_utildefines.h"
+#include "GPU_attr_binding.h"
+#include "GPU_immediate.h"
+
+#include "gpu_attr_binding_private.h"
+#include "gpu_context_private.h"
+#include "gpu_primitive_private.h"
#include "gpu_shader_private.h"
+#include "gpu_vertex_format_private.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+/* necessary functions from matrix API */
+extern void GPU_matrix_bind(const GPUShaderInterface *);
+extern bool GPU_matrix_dirty_get(void);
+
+typedef struct {
+ /* TODO: organize this struct by frequency of change (run-time) */
+
+ GPUBatch *batch;
+ GPUContext *context;
+
+ /* current draw call */
+ GLubyte *buffer_data;
+ uint buffer_offset;
+ uint buffer_bytes_mapped;
+ uint vertex_len;
+ bool strict_vertex_len;
+ GPUPrimType prim_type;
+
+ GPUVertFormat vertex_format;
+
+ /* current vertex */
+ uint vertex_idx;
+ GLubyte *vertex_data;
+ uint16_t unassigned_attrib_bits; /* which attributes of current vertex have not been given values? */
+
+ GLuint vbo_id;
+ GLuint vao_id;
+
+ GLuint bound_program;
+ const GPUShaderInterface *shader_interface;
+ GPUAttrBinding attrib_binding;
+ uint16_t prev_enabled_attrib_bits; /* <-- only affects this VAO, so we're ok */
+} Immediate;
+
+/* size of internal buffer -- make this adjustable? */
+#define IMM_BUFFER_SIZE (4 * 1024 * 1024)
+
+static bool initialized = false;
+static Immediate imm;
+
+void immInit(void)
+{
+#if TRUST_NO_ONE
+ assert(!initialized);
+#endif
+ memset(&imm, 0, sizeof(Immediate));
+
+ imm.vbo_id = GPU_buf_alloc();
+ glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id);
+ glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
+
+ imm.prim_type = GPU_PRIM_NONE;
+ imm.strict_vertex_len = true;
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ initialized = true;
+}
+
+void immActivate(void)
+{
+#if TRUST_NO_ONE
+ assert(initialized);
+ assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we're not between a Begin/End pair */
+ assert(imm.vao_id == 0);
+#endif
+ imm.vao_id = GPU_vao_alloc();
+ imm.context = GPU_context_active_get();
+}
+
+void immDeactivate(void)
+{
+#if TRUST_NO_ONE
+ assert(initialized);
+ assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we're not between a Begin/End pair */
+ assert(imm.vao_id != 0);
+#endif
+ GPU_vao_free(imm.vao_id, imm.context);
+ imm.vao_id = 0;
+ imm.prev_enabled_attrib_bits = 0;
+}
+
+void immDestroy(void)
+{
+ GPU_buf_free(imm.vbo_id);
+ initialized = false;
+}
+
+GPUVertFormat *immVertexFormat(void)
+{
+ GPU_vertformat_clear(&imm.vertex_format);
+ return &imm.vertex_format;
+}
+
+void immBindProgram(GLuint program, const GPUShaderInterface *shaderface)
+{
+#if TRUST_NO_ONE
+ assert(imm.bound_program == 0);
+ assert(glIsProgram(program));
+#endif
+
+ imm.bound_program = program;
+ imm.shader_interface = shaderface;
+
+ if (!imm.vertex_format.packed)
+ VertexFormat_pack(&imm.vertex_format);
+
+ glUseProgram(program);
+ get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface);
+ GPU_matrix_bind(shaderface);
+}
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
{
@@ -38,6 +160,718 @@ void immBindBuiltinProgram(GPUBuiltinShader shader_id)
immBindProgram(shader->program, shader->interface);
}
+void immUnbindProgram(void)
+{
+#if TRUST_NO_ONE
+ assert(imm.bound_program != 0);
+#endif
+#if PROGRAM_NO_OPTI
+ glUseProgram(0);
+#endif
+ imm.bound_program = 0;
+}
+
+#if TRUST_NO_ONE
+static bool vertex_count_makes_sense_for_primitive(uint vertex_len, GPUPrimType prim_type)
+{
+ /* does vertex_len make sense for this primitive type? */
+ if (vertex_len == 0) {
+ return false;
+ }
+
+ switch (prim_type) {
+ case GPU_PRIM_POINTS:
+ return true;
+ case GPU_PRIM_LINES:
+ return vertex_len % 2 == 0;
+ case GPU_PRIM_LINE_STRIP:
+ case GPU_PRIM_LINE_LOOP:
+ return vertex_len >= 2;
+ case GPU_PRIM_LINE_STRIP_ADJ:
+ return vertex_len >= 4;
+ case GPU_PRIM_TRIS:
+ return vertex_len % 3 == 0;
+ case GPU_PRIM_TRI_STRIP:
+ case GPU_PRIM_TRI_FAN:
+ return vertex_len >= 3;
+ default:
+ return false;
+ }
+}
+#endif
+
+void immBegin(GPUPrimType prim_type, uint vertex_len)
+{
+#if TRUST_NO_ONE
+ assert(initialized);
+ assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we haven't already begun */
+ assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type));
+#endif
+ imm.prim_type = prim_type;
+ imm.vertex_len = vertex_len;
+ imm.vertex_idx = 0;
+ imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
+
+ /* how many bytes do we need for this draw call? */
+ const uint bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_len);
+
+#if TRUST_NO_ONE
+ assert(bytes_needed <= IMM_BUFFER_SIZE);
+#endif
+
+ glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id);
+
+ /* does the current buffer have enough room? */
+ const uint available_bytes = IMM_BUFFER_SIZE - imm.buffer_offset;
+ /* ensure vertex data is aligned */
+ const uint pre_padding = padding(imm.buffer_offset, imm.vertex_format.stride); /* might waste a little space, but it's safe */
+ if ((bytes_needed + pre_padding) <= available_bytes) {
+ imm.buffer_offset += pre_padding;
+ }
+ else {
+ /* orphan this buffer & start with a fresh one */
+ /* this method works on all platforms, old & new */
+ glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
+
+ imm.buffer_offset = 0;
+ }
+
+/* printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1); */
+
+ imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, bytes_needed,
+ GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_len ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT));
+
+#if TRUST_NO_ONE
+ assert(imm.buffer_data != NULL);
+#endif
+
+ imm.buffer_bytes_mapped = bytes_needed;
+ imm.vertex_data = imm.buffer_data;
+}
+
+void immBeginAtMost(GPUPrimType prim_type, uint vertex_len)
+{
+#if TRUST_NO_ONE
+ assert(vertex_len > 0);
+#endif
+
+ imm.strict_vertex_len = false;
+ immBegin(prim_type, vertex_len);
+}
+
+
+GPUBatch *immBeginBatch(GPUPrimType prim_type, uint vertex_len)
+{
+#if TRUST_NO_ONE
+ assert(initialized);
+ assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we haven't already begun */
+ assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type));
+#endif
+ imm.prim_type = prim_type;
+ imm.vertex_len = vertex_len;
+ imm.vertex_idx = 0;
+ imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
+
+ GPUVertBuf *verts = GPU_vertbuf_create_with_format(&imm.vertex_format);
+ GPU_vertbuf_data_alloc(verts, vertex_len);
+
+ imm.buffer_bytes_mapped = GPU_vertbuf_size_get(verts);
+ imm.vertex_data = verts->data;
+
+ imm.batch = GPU_batch_create_ex(prim_type, verts, NULL, GPU_BATCH_OWNS_VBO);
+ imm.batch->phase = GPU_BATCH_BUILDING;
+
+ return imm.batch;
+}
+
+GPUBatch *immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len)
+{
+ imm.strict_vertex_len = false;
+ return immBeginBatch(prim_type, vertex_len);
+}
+
+static void immDrawSetup(void)
+{
+ /* set up VAO -- can be done during Begin or End really */
+ glBindVertexArray(imm.vao_id);
+
+ /* enable/disable vertex attribs as needed */
+ if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits) {
+ for (uint loc = 0; loc < GPU_VERT_ATTR_MAX_LEN; ++loc) {
+ bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc);
+ bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc);
+
+ if (is_enabled && !was_enabled) {
+ glEnableVertexAttribArray(loc);
+ }
+ else if (was_enabled && !is_enabled) {
+ glDisableVertexAttribArray(loc);
+ }
+ }
+
+ imm.prev_enabled_attrib_bits = imm.attrib_binding.enabled_bits;
+ }
+
+ const uint stride = imm.vertex_format.stride;
+
+ for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) {
+ const GPUVertAttr *a = imm.vertex_format.attribs + a_idx;
+
+ const uint offset = imm.buffer_offset + a->offset;
+ const GLvoid *pointer = (const GLubyte *)0 + offset;
+
+ const uint loc = read_attrib_location(&imm.attrib_binding, a_idx);
+
+ switch (a->fetch_mode) {
+ case GPU_FETCH_FLOAT:
+ case GPU_FETCH_INT_TO_FLOAT:
+ glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer);
+ break;
+ case GPU_FETCH_INT_TO_FLOAT_UNIT:
+ glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer);
+ break;
+ case GPU_FETCH_INT:
+ glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer);
+ }
+ }
+
+ if (GPU_matrix_dirty_get()) {
+ GPU_matrix_bind(imm.shader_interface);
+ }
+}
+
+void immEnd(void)
+{
+#if TRUST_NO_ONE
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+
+ uint buffer_bytes_used;
+ if (imm.strict_vertex_len) {
+#if TRUST_NO_ONE
+ assert(imm.vertex_idx == imm.vertex_len); /* with all vertices defined */
+#endif
+ buffer_bytes_used = imm.buffer_bytes_mapped;
+ }
+ else {
+#if TRUST_NO_ONE
+ assert(imm.vertex_idx <= imm.vertex_len);
+#endif
+ if (imm.vertex_idx == imm.vertex_len) {
+ buffer_bytes_used = imm.buffer_bytes_mapped;
+ }
+ else {
+#if TRUST_NO_ONE
+ assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type));
+#endif
+ imm.vertex_len = imm.vertex_idx;
+ buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_len);
+ /* unused buffer bytes are available to the next immBegin */
+ }
+ /* tell OpenGL what range was modified so it doesn't copy the whole mapped range */
+ glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, buffer_bytes_used);
+ }
+
+ if (imm.batch) {
+ if (buffer_bytes_used != imm.buffer_bytes_mapped) {
+ GPU_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len);
+ /* TODO: resize only if vertex count is much smaller */
+ }
+ GPU_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface);
+ imm.batch->phase = GPU_BATCH_READY_TO_DRAW;
+ imm.batch = NULL; /* don't free, batch belongs to caller */
+ }
+ else {
+ glUnmapBuffer(GL_ARRAY_BUFFER);
+ if (imm.vertex_len > 0) {
+ immDrawSetup();
+ glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_len);
+ }
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindVertexArray(0);
+ /* prep for next immBegin */
+ imm.buffer_offset += buffer_bytes_used;
+ }
+
+ /* prep for next immBegin */
+ imm.prim_type = GPU_PRIM_NONE;
+ imm.strict_vertex_len = true;
+}
+
+static void setAttribValueBit(uint attrib_id)
+{
+ uint16_t mask = 1 << attrib_id;
+#if TRUST_NO_ONE
+ assert(imm.unassigned_attrib_bits & mask); /* not already set */
+#endif
+ imm.unassigned_attrib_bits &= ~mask;
+}
+
+
+/* --- generic attribute functions --- */
+
+void immAttrib1f(uint attrib_id, float x)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_F32);
+ assert(attrib->comp_len == 1);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ float *data = (float *)(imm.vertex_data + attrib->offset);
+/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
+
+ data[0] = x;
+}
+
+void immAttrib2f(uint attrib_id, float x, float y)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_F32);
+ assert(attrib->comp_len == 2);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ float *data = (float *)(imm.vertex_data + attrib->offset);
+/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
+
+ data[0] = x;
+ data[1] = y;
+}
+
+void immAttrib3f(uint attrib_id, float x, float y, float z)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_F32);
+ assert(attrib->comp_len == 3);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ float *data = (float *)(imm.vertex_data + attrib->offset);
+/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
+
+ data[0] = x;
+ data[1] = y;
+ data[2] = z;
+}
+
+void immAttrib4f(uint attrib_id, float x, float y, float z, float w)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_F32);
+ assert(attrib->comp_len == 4);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ float *data = (float *)(imm.vertex_data + attrib->offset);
+/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
+
+ data[0] = x;
+ data[1] = y;
+ data[2] = z;
+ data[3] = w;
+}
+
+void immAttrib1u(uint attrib_id, uint x)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_U32);
+ assert(attrib->comp_len == 1);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ uint *data = (uint *)(imm.vertex_data + attrib->offset);
+
+ data[0] = x;
+}
+
+void immAttrib2i(uint attrib_id, int x, int y)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_I32);
+ assert(attrib->comp_len == 2);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ int *data = (int *)(imm.vertex_data + attrib->offset);
+
+ data[0] = x;
+ data[1] = y;
+}
+
+void immAttrib2s(uint attrib_id, short x, short y)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_I16);
+ assert(attrib->comp_len == 2);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ short *data = (short *)(imm.vertex_data + attrib->offset);
+
+ data[0] = x;
+ data[1] = y;
+}
+
+void immAttrib2fv(uint attrib_id, const float data[2])
+{
+ immAttrib2f(attrib_id, data[0], data[1]);
+}
+
+void immAttrib3fv(uint attrib_id, const float data[3])
+{
+ immAttrib3f(attrib_id, data[0], data[1], data[2]);
+}
+
+void immAttrib4fv(uint attrib_id, const float data[4])
+{
+ immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]);
+}
+
+void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_U8);
+ assert(attrib->comp_len == 3);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ GLubyte *data = imm.vertex_data + attrib->offset;
+/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */
+
+ data[0] = r;
+ data[1] = g;
+ data[2] = b;
+}
+
+void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+{
+ GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attrib->comp_type == GPU_COMP_U8);
+ assert(attrib->comp_len == 4);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+
+ GLubyte *data = imm.vertex_data + attrib->offset;
+/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */
+
+ data[0] = r;
+ data[1] = g;
+ data[2] = b;
+ data[3] = a;
+}
+
+void immAttrib3ubv(uint attrib_id, const unsigned char data[3])
+{
+ immAttrib3ub(attrib_id, data[0], data[1], data[2]);
+}
+
+void immAttrib4ubv(uint attrib_id, const unsigned char data[4])
+{
+ immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]);
+}
+
+void immSkipAttrib(uint attrib_id)
+{
+#if TRUST_NO_ONE
+ assert(attrib_id < imm.vertex_format.attr_len);
+ assert(imm.vertex_idx < imm.vertex_len);
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+#endif
+ setAttribValueBit(attrib_id);
+}
+
+static void immEndVertex(void) /* and move on to the next vertex */
+{
+#if TRUST_NO_ONE
+ assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
+ assert(imm.vertex_idx < imm.vertex_len);
+#endif
+
+ /* have all attribs been assigned values?
+ * if not, copy value from previous vertex */
+ if (imm.unassigned_attrib_bits) {
+#if TRUST_NO_ONE
+ assert(imm.vertex_idx > 0); /* first vertex must have all attribs specified */
+#endif
+ for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) {
+ if ((imm.unassigned_attrib_bits >> a_idx) & 1) {
+ const GPUVertAttr *a = imm.vertex_format.attribs + a_idx;
+
+/* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */
+
+ GLubyte *data = imm.vertex_data + a->offset;
+ memcpy(data, data - imm.vertex_format.stride, a->sz);
+ /* TODO: consolidate copy of adjacent attributes */
+ }
+ }
+ }
+
+ imm.vertex_idx++;
+ imm.vertex_data += imm.vertex_format.stride;
+ imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
+}
+
+void immVertex2f(uint attrib_id, float x, float y)
+{
+ immAttrib2f(attrib_id, x, y);
+ immEndVertex();
+}
+
+void immVertex3f(uint attrib_id, float x, float y, float z)
+{
+ immAttrib3f(attrib_id, x, y, z);
+ immEndVertex();
+}
+
+void immVertex4f(uint attrib_id, float x, float y, float z, float w)
+{
+ immAttrib4f(attrib_id, x, y, z, w);
+ immEndVertex();
+}
+
+void immVertex2i(uint attrib_id, int x, int y)
+{
+ immAttrib2i(attrib_id, x, y);
+ immEndVertex();
+}
+
+void immVertex2s(uint attrib_id, short x, short y)
+{
+ immAttrib2s(attrib_id, x, y);
+ immEndVertex();
+}
+
+void immVertex2fv(uint attrib_id, const float data[2])
+{
+ immAttrib2f(attrib_id, data[0], data[1]);
+ immEndVertex();
+}
+
+void immVertex3fv(uint attrib_id, const float data[3])
+{
+ immAttrib3f(attrib_id, data[0], data[1], data[2]);
+ immEndVertex();
+}
+
+void immVertex2iv(uint attrib_id, const int data[2])
+{
+ immAttrib2i(attrib_id, data[0], data[1]);
+ immEndVertex();
+}
+
+
+/* --- generic uniform functions --- */
+
+#if 0
+# if TRUST_NO_ONE
+# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform);
+# else
+# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name);
+# endif
+#else
+ /* NOTE: It is possible to have uniform fully optimized out from the shader.
+ * In this case we can't assert failure or allow NULL-pointer dereference.
+ * TODO(sergey): How can we detect existing-but-optimized-out uniform but still
+ * catch typos in uniform names passed to immUniform*() functions? */
+# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
+#endif
+
+void immUniform1f(const char *name, float x)
+{
+ GET_UNIFORM
+ glUniform1f(uniform->location, x);
+}
+
+void immUniform2f(const char *name, float x, float y)
+{
+ GET_UNIFORM
+ glUniform2f(uniform->location, x, y);
+}
+
+void immUniform2fv(const char *name, const float data[2])
+{
+ GET_UNIFORM
+ glUniform2fv(uniform->location, 1, data);
+}
+
+void immUniform3f(const char *name, float x, float y, float z)
+{
+ GET_UNIFORM
+ glUniform3f(uniform->location, x, y, z);
+}
+
+void immUniform3fv(const char *name, const float data[3])
+{
+ GET_UNIFORM
+ glUniform3fv(uniform->location, 1, data);
+}
+
+/* can increase this limit or move to another file */
+#define MAX_UNIFORM_NAME_LEN 60
+
+void immUniformArray3fv(const char *bare_name, const float *data, int count)
+{
+ /* look up "name[0]" when given "name" */
+ const size_t len = strlen(bare_name);
+#if TRUST_NO_ONE
+ assert(len <= MAX_UNIFORM_NAME_LEN);
+#endif
+ char name[MAX_UNIFORM_NAME_LEN];
+ strcpy(name, bare_name);
+ name[len + 0] = '[';
+ name[len + 1] = '0';
+ name[len + 2] = ']';
+ name[len + 3] = '\0';
+
+ GET_UNIFORM
+ glUniform3fv(uniform->location, count, data);
+}
+
+void immUniform4f(const char *name, float x, float y, float z, float w)
+{
+ GET_UNIFORM
+ glUniform4f(uniform->location, x, y, z, w);
+}
+
+void immUniform4fv(const char *name, const float data[4])
+{
+ GET_UNIFORM
+ glUniform4fv(uniform->location, 1, data);
+}
+
+void immUniformArray4fv(const char *bare_name, const float *data, int count)
+{
+ /* look up "name[0]" when given "name" */
+ const size_t len = strlen(bare_name);
+#if TRUST_NO_ONE
+ assert(len <= MAX_UNIFORM_NAME_LEN);
+#endif
+ char name[MAX_UNIFORM_NAME_LEN];
+ strcpy(name, bare_name);
+ name[len + 0] = '[';
+ name[len + 1] = '0';
+ name[len + 2] = ']';
+ name[len + 3] = '\0';
+
+ GET_UNIFORM
+ glUniform4fv(uniform->location, count, data);
+}
+
+void immUniformMatrix4fv(const char *name, const float data[4][4])
+{
+ GET_UNIFORM
+ glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (float *)data);
+}
+
+void immUniform1i(const char *name, int x)
+{
+ GET_UNIFORM
+ glUniform1i(uniform->location, x);
+}
+
+void immUniform4iv(const char *name, const int data[4])
+{
+ GET_UNIFORM
+ glUniform4iv(uniform->location, 1, data);
+}
+
+/* --- convenience functions for setting "uniform vec4 color" --- */
+
+void immUniformColor4f(float r, float g, float b, float a)
+{
+ const GPUShaderInput *uniform = GPU_shaderinterface_uniform_builtin(imm.shader_interface, GPU_UNIFORM_COLOR);
+#if TRUST_NO_ONE
+ assert(uniform != NULL);
+#endif
+ glUniform4f(uniform->location, r, g, b, a);
+}
+
+void immUniformColor4fv(const float rgba[4])
+{
+ immUniformColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
+}
+
+void immUniformColor3f(float r, float g, float b)
+{
+ immUniformColor4f(r, g, b, 1.0f);
+}
+
+void immUniformColor3fv(const float rgb[3])
+{
+ immUniformColor4f(rgb[0], rgb[1], rgb[2], 1.0f);
+}
+
+void immUniformColor3fvAlpha(const float rgb[3], float a)
+{
+ immUniformColor4f(rgb[0], rgb[1], rgb[2], a);
+}
+
+/* TODO: v-- treat as sRGB? --v */
+
+void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b)
+{
+ const float scale = 1.0f / 255.0f;
+ immUniformColor4f(scale * r, scale * g, scale * b, 1.0f);
+}
+
+void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+{
+ const float scale = 1.0f / 255.0f;
+ immUniformColor4f(scale * r, scale * g, scale * b, scale * a);
+}
+
+void immUniformColor3ubv(const unsigned char rgb[3])
+{
+ immUniformColor3ub(rgb[0], rgb[1], rgb[2]);
+}
+
+void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char alpha)
+{
+ immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha);
+}
+
+void immUniformColor4ubv(const unsigned char rgba[4])
+{
+ immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]);
+}
+
void immUniformThemeColor(int color_id)
{
float color[4];
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index bad878ef4bf..8384ef3b5d0 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -18,8 +18,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file source/blender/gpu/intern/gpu_immediate_util.c
+/** \file blender/gpu/intern/gpu_immediate_util.c
* \ingroup gpu
+ *
+ * GPU immediate mode drawing utilities
*/
#include <stdio.h>
@@ -66,6 +68,72 @@ static const int cube_line_index[12][2] = {
{6, 7},
};
+void immRectf(uint pos, float x1, float y1, float x2, float y2)
+{
+ immBegin(GPU_PRIM_TRI_FAN, 4);
+ immVertex2f(pos, x1, y1);
+ immVertex2f(pos, x2, y1);
+ immVertex2f(pos, x2, y2);
+ immVertex2f(pos, x1, y2);
+ immEnd();
+}
+
+void immRecti(uint pos, int x1, int y1, int x2, int y2)
+{
+ immBegin(GPU_PRIM_TRI_FAN, 4);
+ immVertex2i(pos, x1, y1);
+ immVertex2i(pos, x2, y1);
+ immVertex2i(pos, x2, y2);
+ immVertex2i(pos, x1, y2);
+ immEnd();
+}
+
+void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4])
+{
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x1, y1);
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x2, y1);
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x2, y2);
+
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x1, y1);
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x2, y2);
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x1, y2);
+}
+
+void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4])
+{
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x1, y1);
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x2, y1);
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x2, y2);
+
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x1, y1);
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x2, y2);
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x1, y2);
+}
+
+#if 0 /* more complete version in case we want that */
+void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
+{
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = add_attrib(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4fv(color);
+ immRecti(pos, x1, y1, x2, y2);
+ immUnbindProgram();
+}
+#endif
+
/**
* Pack color into 3 bytes
*
@@ -85,7 +153,7 @@ void imm_cpack(unsigned int x)
}
static void imm_draw_circle(
- Gwn_PrimType prim_type, const uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
+ GPUPrimType prim_type, const uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
{
immBegin(prim_type, nsegments);
for (int i = 0; i < nsegments; ++i) {
@@ -107,7 +175,7 @@ static void imm_draw_circle(
*/
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nsegments)
{
- imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad, rad, nsegments);
+ imm_draw_circle(GPU_PRIM_LINE_LOOP, shdr_pos, x, y, rad, rad, nsegments);
}
/**
@@ -122,23 +190,23 @@ void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nse
*/
void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float rad, int nsegments)
{
- imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad, rad, nsegments);
+ imm_draw_circle(GPU_PRIM_TRI_FAN, shdr_pos, x, y, rad, rad, nsegments);
}
void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
{
- imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad_x, rad_y, nsegments);
+ imm_draw_circle(GPU_PRIM_LINE_LOOP, shdr_pos, x, y, rad_x, rad_y, nsegments);
}
void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
{
- imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad_x, rad_y, nsegments);
+ imm_draw_circle(GPU_PRIM_TRI_FAN, shdr_pos, x, y, rad_x, rad_y, nsegments);
}
/**
* \note We could have `imm_draw_lined_disk_partial` but currently there is no need.
*/
static void imm_draw_disk_partial(
- Gwn_PrimType prim_type, unsigned pos, float x, float y,
+ GPUPrimType prim_type, unsigned pos, float x, float y,
float rad_inner, float rad_outer, int nsegments, float start, float sweep)
{
/* shift & reverse angle, increase 'nsegments' to match gluPartialDisk */
@@ -175,11 +243,11 @@ void imm_draw_disk_partial_fill_2d(
unsigned pos, float x, float y,
float rad_inner, float rad_outer, int nsegments, float start, float sweep)
{
- imm_draw_disk_partial(GWN_PRIM_TRI_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep);
+ imm_draw_disk_partial(GPU_PRIM_TRI_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep);
}
static void imm_draw_circle_3D(
- Gwn_PrimType prim_type, unsigned pos, float x, float y,
+ GPUPrimType prim_type, unsigned pos, float x, float y,
float rad, int nsegments)
{
immBegin(prim_type, nsegments);
@@ -192,26 +260,26 @@ static void imm_draw_circle_3D(
void imm_draw_circle_wire_3d(unsigned pos, float x, float y, float rad, int nsegments)
{
- imm_draw_circle_3D(GWN_PRIM_LINE_LOOP, pos, x, y, rad, nsegments);
+ imm_draw_circle_3D(GPU_PRIM_LINE_LOOP, pos, x, y, rad, nsegments);
}
void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nsegments)
{
- imm_draw_circle_3D(GWN_PRIM_TRI_FAN, pos, x, y, rad, nsegments);
+ imm_draw_circle_3D(GPU_PRIM_TRI_FAN, pos, x, y, rad, nsegments);
}
/**
-* Draw a lined box.
-*
-* \param pos The vertex attribute number for position.
-* \param x1 left.
-* \param y1 bottom.
-* \param x2 right.
-* \param y2 top.
-*/
+ * Draw a lined box.
+ *
+ * \param pos The vertex attribute number for position.
+ * \param x1 left.
+ * \param y1 bottom.
+ * \param x2 right.
+ * \param y2 top.
+ */
void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2)
{
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x1, y2);
immVertex2f(pos, x2, y2);
@@ -221,8 +289,8 @@ void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2)
void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2)
{
- /* use this version when Gwn_VertFormat has a vec3 position */
- immBegin(GWN_PRIM_LINE_LOOP, 4);
+ /* use this version when GPUVertFormat has a vec3 position */
+ immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex3f(pos, x1, y1, 0.0f);
immVertex3f(pos, x1, y2, 0.0f);
immVertex3f(pos, x2, y2, 0.0f);
@@ -235,7 +303,7 @@ void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2)
*/
void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
immUniform4f("color1", 0.15f, 0.15f, 0.15f, 1.0f);
@@ -255,7 +323,7 @@ void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3])
madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect);
}
- immBegin(GWN_PRIM_TRIS, ARRAY_SIZE(cube_quad_index) * 3 * 2);
+ immBegin(GPU_PRIM_TRIS, ARRAY_SIZE(cube_quad_index) * 3 * 2);
for (int i = 0; i < ARRAY_SIZE(cube_quad_index); i++) {
immVertex3fv(pos, coords[cube_quad_index[i][0]]);
immVertex3fv(pos, coords[cube_quad_index[i][1]]);
@@ -276,7 +344,7 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3])
madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect);
}
- immBegin(GWN_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 2);
+ immBegin(GPU_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 2);
for (int i = 0; i < ARRAY_SIZE(cube_line_index); i++) {
immVertex3fv(pos, coords[cube_line_index[i][0]]);
immVertex3fv(pos, coords[cube_line_index[i][1]]);
@@ -285,21 +353,21 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3])
}
/**
-* Draw a cylinder. Replacement for gluCylinder.
-* _warning_ : Slow, better use it only if you no other choices.
-*
-* \param pos The vertex attribute number for position.
-* \param nor The vertex attribute number for normal.
-* \param base Specifies the radius of the cylinder at z = 0.
-* \param top Specifies the radius of the cylinder at z = height.
-* \param height Specifies the height of the cylinder.
-* \param slices Specifies the number of subdivisions around the z axis.
-* \param stacks Specifies the number of subdivisions along the z axis.
-*/
+ * Draw a cylinder. Replacement for gluCylinder.
+ * _warning_ : Slow, better use it only if you no other choices.
+ *
+ * \param pos The vertex attribute number for position.
+ * \param nor The vertex attribute number for normal.
+ * \param base Specifies the radius of the cylinder at z = 0.
+ * \param top Specifies the radius of the cylinder at z = height.
+ * \param height Specifies the height of the cylinder.
+ * \param slices Specifies the number of subdivisions around the z axis.
+ * \param stacks Specifies the number of subdivisions along the z axis.
+ */
void imm_draw_cylinder_fill_normal_3d(
unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks)
{
- immBegin(GWN_PRIM_TRIS, 6 * slices * stacks);
+ immBegin(GPU_PRIM_TRIS, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {
const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices);
const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices);
@@ -316,10 +384,10 @@ void imm_draw_cylinder_fill_normal_3d(
float h1 = height * ((float)j / (float)stacks);
float h2 = height * ((float)(j + 1) / (float)stacks);
- float v1[3] = {r1 *cos2, r1 * sin2, h1};
- float v2[3] = {r2 *cos2, r2 * sin2, h2};
- float v3[3] = {r2 *cos1, r2 * sin1, h2};
- float v4[3] = {r1 *cos1, r1 * sin1, h1};
+ float v1[3] = {r1 * cos2, r1 * sin2, h1};
+ float v2[3] = {r2 * cos2, r2 * sin2, h2};
+ float v3[3] = {r2 * cos1, r2 * sin1, h2};
+ float v4[3] = {r1 * cos1, r1 * sin1, h1};
float n1[3], n2[3];
/* calc normals */
@@ -350,7 +418,7 @@ void imm_draw_cylinder_fill_normal_3d(
void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
{
- immBegin(GWN_PRIM_LINES, 6 * slices * stacks);
+ immBegin(GPU_PRIM_LINES, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {
const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices);
const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices);
@@ -387,7 +455,7 @@ void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float he
void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
{
- immBegin(GWN_PRIM_TRIS, 6 * slices * stacks);
+ immBegin(GPU_PRIM_TRIS, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {
const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices);
const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices);
diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c
index 78d4f491b66..55d0466c929 100644
--- a/source/blender/gpu/intern/gpu_init_exit.c
+++ b/source/blender/gpu/intern/gpu_init_exit.c
@@ -57,8 +57,6 @@ void GPU_init(void)
gpu_extensions_init(); /* must come first */
- GPU_texture_orphans_init();
- GPU_material_orphans_init();
gpu_codegen_init();
gpu_framebuffer_module_init();
@@ -84,9 +82,6 @@ void GPU_exit(void)
gpu_batch_exit();
- GPU_texture_orphans_exit();
- GPU_material_orphans_exit();
-
if (G.debug & G_DEBUG_GPU)
gpu_debug_exit();
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 9c776e64ba0..2264836f24a 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -36,32 +36,18 @@
#include "MEM_guardedalloc.h"
-#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
-#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_world_types.h"
#include "BLI_math.h"
-#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
-#include "BLI_rand.h"
-#include "BLI_threads.h"
-
-#include "BKE_anim.h"
-#include "BKE_colorband.h"
-#include "BKE_colortools.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_layer.h"
+
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_scene.h"
-#include "IMB_imbuf_types.h"
-
-#include "GPU_extensions.h"
-#include "GPU_framebuffer.h"
#include "GPU_material.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
@@ -75,9 +61,6 @@
# include "BKE_DerivedMesh.h"
#endif
-static ListBase g_orphaned_mat = {NULL, NULL};
-static ThreadMutex g_orphan_lock;
-
/* Structs */
struct GPUMaterial {
@@ -175,44 +158,12 @@ void GPU_material_free(ListBase *gpumaterial)
{
for (LinkData *link = gpumaterial->first; link; link = link->next) {
GPUMaterial *material = link->data;
-
- /* TODO(fclem): Check if the thread has an ogl context. */
- if (BLI_thread_is_main()) {
- gpu_material_free_single(material);
- MEM_freeN(material);
- }
- else {
- BLI_mutex_lock(&g_orphan_lock);
- BLI_addtail(&g_orphaned_mat, BLI_genericNodeN(material));
- BLI_mutex_unlock(&g_orphan_lock);
- }
+ gpu_material_free_single(material);
+ MEM_freeN(material);
}
BLI_freelistN(gpumaterial);
}
-void GPU_material_orphans_init(void)
-{
- BLI_mutex_init(&g_orphan_lock);
-}
-
-void GPU_material_orphans_delete(void)
-{
- BLI_mutex_lock(&g_orphan_lock);
- LinkData *link;
- while ((link = BLI_pophead(&g_orphaned_mat))) {
- gpu_material_free_single((GPUMaterial *)link->data);
- MEM_freeN(link->data);
- MEM_freeN(link);
- }
- BLI_mutex_unlock(&g_orphan_lock);
-}
-
-void GPU_material_orphans_exit(void)
-{
- GPU_material_orphans_delete();
- BLI_mutex_end(&g_orphan_lock);
-}
-
GPUBuiltin GPU_get_material_builtins(GPUMaterial *material)
{
return material->builtins;
@@ -354,7 +305,7 @@ static float eval_integral(float x0, float x1, short falloff_type, float sharpne
#undef INTEGRAL_RESOLUTION
static void compute_sss_kernel(
- GPUSssKernelData *kd, float radii[3], int sample_ct, int falloff_type, float sharpness)
+ GPUSssKernelData *kd, float radii[3], int sample_len, int falloff_type, float sharpness)
{
float rad[3];
/* Minimum radius */
@@ -390,13 +341,13 @@ static void compute_sss_kernel(
}
/* Compute samples locations on the 1d kernel [-1..1] */
- sss_calculate_offsets(kd, sample_ct, SSS_EXPONENT);
+ sss_calculate_offsets(kd, sample_len, SSS_EXPONENT);
/* Weights sum for normalization */
float sum[3] = {0.0f, 0.0f, 0.0f};
/* Compute integral of each sample footprint */
- for (int i = 0; i < sample_ct; i++) {
+ for (int i = 0; i < sample_len; i++) {
float x0, x1;
if (i == 0) {
@@ -406,8 +357,8 @@ static void compute_sss_kernel(
x0 = (kd->kernel[i - 1][3] + kd->kernel[i][3]) / 2.0f;
}
- if (i == sample_ct - 1) {
- x1 = kd->kernel[sample_ct - 1][3] + fabsf(kd->kernel[sample_ct - 2][3] - kd->kernel[sample_ct - 1][3]) / 2.0f;
+ if (i == sample_len - 1) {
+ x1 = kd->kernel[sample_len - 1][3] + fabsf(kd->kernel[sample_len - 2][3] - kd->kernel[sample_len - 1][3]) / 2.0f;
}
else {
x1 = (kd->kernel[i][3] + kd->kernel[i + 1][3]) / 2.0f;
@@ -428,25 +379,25 @@ static void compute_sss_kernel(
for (int i = 0; i < 3; ++i) {
if (sum[i] > 0.0f) {
/* Normalize */
- for (int j = 0; j < sample_ct; j++) {
+ for (int j = 0; j < sample_len; j++) {
kd->kernel[j][i] /= sum[i];
}
}
else {
/* Avoid 0 kernel sum. */
- kd->kernel[sample_ct / 2][i] = 1.0f;
+ kd->kernel[sample_len / 2][i] = 1.0f;
}
}
/* Put center sample at the start of the array (to sample first) */
float tmpv[4];
- copy_v4_v4(tmpv, kd->kernel[sample_ct / 2]);
- for (int i = sample_ct / 2; i > 0; i--) {
+ copy_v4_v4(tmpv, kd->kernel[sample_len / 2]);
+ for (int i = sample_len / 2; i > 0; i--) {
copy_v4_v4(kd->kernel[i], kd->kernel[i - 1]);
}
copy_v4_v4(kd->kernel[0], tmpv);
- kd->samples = sample_ct;
+ kd->samples = sample_len;
}
#define INTEGRAL_RESOLUTION 512
@@ -523,12 +474,12 @@ void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], shor
}
}
-struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_ct, GPUTexture **tex_profile)
+struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_len, GPUTexture **tex_profile)
{
if (!material->sss_enabled)
return NULL;
- if (material->sss_dirty || (material->sss_samples != sample_ct)) {
+ if (material->sss_dirty || (material->sss_samples != sample_len)) {
GPUSssKernelData kd;
float sharpness = material->sss_sharpness;
@@ -536,7 +487,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int
/* XXX Black magic but it seems to fit. Maybe because we integrate -1..1 */
sharpness *= 0.5f;
- compute_sss_kernel(&kd, material->sss_radii, sample_ct, material->sss_falloff, sharpness);
+ compute_sss_kernel(&kd, material->sss_radii, sample_len, material->sss_falloff, sharpness);
/* Update / Create UBO */
GPU_uniformbuffer_update(material->sss_profile, &kd);
@@ -553,7 +504,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int
MEM_freeN(translucence_profile);
- material->sss_samples = sample_ct;
+ material->sss_samples = sample_len;
material->sss_dirty = false;
}
@@ -644,8 +595,7 @@ GPUMaterial *GPU_material_from_nodetree(
mat->engine_type = engine_type;
mat->options = options;
- ntreeGPUMaterialNodes(ntree, mat, NODE_NEW_SHADING | NODE_NEWER_SHADING);
- ntreeGPUMaterialDomain(ntree, &has_surface_output, &has_volume_output);
+ ntreeGPUMaterialNodes(ntree, mat, &has_surface_output, &has_volume_output);
if (has_surface_output) {
mat->domain |= GPU_DOMAIN_SURFACE;
@@ -660,14 +610,15 @@ GPUMaterial *GPU_material_from_nodetree(
GPU_nodes_prune(&mat->nodes, mat->outlink);
GPU_nodes_get_vertex_attributes(&mat->nodes, &mat->attribs);
/* Create source code and search pass cache for an already compiled version. */
- mat->pass = GPU_generate_pass_new(mat,
- mat->outlink,
- &mat->attribs,
- &mat->nodes,
- vert_code,
- geom_code,
- frag_lib,
- defines);
+ mat->pass = GPU_generate_pass_new(
+ mat,
+ mat->outlink,
+ &mat->attribs,
+ &mat->nodes,
+ vert_code,
+ geom_code,
+ frag_lib,
+ defines);
if (mat->pass == NULL) {
/* We had a cache hit and the shader has already failed to compile. */
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c
index b6214f2778b..0fa4a158c00 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -29,7 +29,7 @@
* \ingroup gpu
*/
-#include "../../../intern/gawain/gawain/gwn_shader_interface.h"
+#include "GPU_shader_interface.h"
#define SUPPRESS_GENERIC_MATRIX_API
#define USE_GPU_PY_MATRIX_API /* only so values are declared */
@@ -86,7 +86,7 @@ static MatrixState state = {
#define ProjectionStack state.projection_stack
#define Projection ProjectionStack.stack[ProjectionStack.top]
-void gpuMatrixReset(void)
+void GPU_matrix_reset(void)
{
state.model_view_stack.top = 0;
state.projection_stack.top = 0;
@@ -110,7 +110,7 @@ static void checkmat(cosnt float *m)
}
}
-#define CHECKMAT(m) checkmat((const float*)m)
+#define CHECKMAT(m) checkmat((const float *)m)
#else
@@ -119,76 +119,76 @@ static void checkmat(cosnt float *m)
#endif
-void gpuPushMatrix(void)
+void GPU_matrix_push(void)
{
BLI_assert(ModelViewStack.top + 1 < MATRIX_STACK_DEPTH);
ModelViewStack.top++;
copy_m4_m4(ModelView, ModelViewStack.stack[ModelViewStack.top - 1]);
}
-void gpuPopMatrix(void)
+void GPU_matrix_pop(void)
{
BLI_assert(ModelViewStack.top > 0);
ModelViewStack.top--;
state.dirty = true;
}
-void gpuPushProjectionMatrix(void)
+void GPU_matrix_push_projection(void)
{
BLI_assert(ProjectionStack.top + 1 < MATRIX_STACK_DEPTH);
ProjectionStack.top++;
copy_m4_m4(Projection, ProjectionStack.stack[ProjectionStack.top - 1]);
}
-void gpuPopProjectionMatrix(void)
+void GPU_matrix_pop_projection(void)
{
BLI_assert(ProjectionStack.top > 0);
ProjectionStack.top--;
state.dirty = true;
}
-void gpuLoadMatrix(const float m[4][4])
+void GPU_matrix_set(const float m[4][4])
{
copy_m4_m4(ModelView, m);
CHECKMAT(ModelView3D);
state.dirty = true;
}
-void gpuLoadIdentityProjectionMatrix(void)
+void GPU_matrix_identity_projection_set(void)
{
unit_m4(Projection);
CHECKMAT(Projection3D);
state.dirty = true;
}
-void gpuLoadProjectionMatrix(const float m[4][4])
+void GPU_matrix_projection_set(const float m[4][4])
{
copy_m4_m4(Projection, m);
CHECKMAT(Projection3D);
state.dirty = true;
}
-void gpuLoadIdentity(void)
+void GPU_matrix_identity_set(void)
{
unit_m4(ModelView);
state.dirty = true;
}
-void gpuTranslate2f(float x, float y)
+void GPU_matrix_translate_2f(float x, float y)
{
Mat4 m;
unit_m4(m);
m[3][0] = x;
m[3][1] = y;
- gpuMultMatrix(m);
+ GPU_matrix_mul(m);
}
-void gpuTranslate2fv(const float vec[2])
+void GPU_matrix_translate_2fv(const float vec[2])
{
- gpuTranslate2f(vec[0], vec[1]);
+ GPU_matrix_translate_2f(vec[0], vec[1]);
}
-void gpuTranslate3f(float x, float y, float z)
+void GPU_matrix_translate_3f(float x, float y, float z)
{
#if 1
translate_m4(ModelView, x, y, z);
@@ -199,61 +199,61 @@ void gpuTranslate3f(float x, float y, float z)
m[3][0] = x;
m[3][1] = y;
m[3][2] = z;
- gpuMultMatrix(m);
+ GPU_matrix_mul(m);
#endif
state.dirty = true;
}
-void gpuTranslate3fv(const float vec[3])
+void GPU_matrix_translate_3fv(const float vec[3])
{
- gpuTranslate3f(vec[0], vec[1], vec[2]);
+ GPU_matrix_translate_3f(vec[0], vec[1], vec[2]);
}
-void gpuScaleUniform(float factor)
+void GPU_matrix_scale_1f(float factor)
{
Mat4 m;
scale_m4_fl(m, factor);
- gpuMultMatrix(m);
+ GPU_matrix_mul(m);
}
-void gpuScale2f(float x, float y)
+void GPU_matrix_scale_2f(float x, float y)
{
Mat4 m = {{0.0f}};
m[0][0] = x;
m[1][1] = y;
m[2][2] = 1.0f;
m[3][3] = 1.0f;
- gpuMultMatrix(m);
+ GPU_matrix_mul(m);
}
-void gpuScale2fv(const float vec[2])
+void GPU_matrix_scale_2fv(const float vec[2])
{
- gpuScale2f(vec[0], vec[1]);
+ GPU_matrix_scale_2f(vec[0], vec[1]);
}
-void gpuScale3f(float x, float y, float z)
+void GPU_matrix_scale_3f(float x, float y, float z)
{
Mat4 m = {{0.0f}};
m[0][0] = x;
m[1][1] = y;
m[2][2] = z;
m[3][3] = 1.0f;
- gpuMultMatrix(m);
+ GPU_matrix_mul(m);
}
-void gpuScale3fv(const float vec[3])
+void GPU_matrix_scale_3fv(const float vec[3])
{
- gpuScale3f(vec[0], vec[1], vec[2]);
+ GPU_matrix_scale_3f(vec[0], vec[1], vec[2]);
}
-void gpuMultMatrix(const float m[4][4])
+void GPU_matrix_mul(const float m[4][4])
{
mul_m4_m4_post(ModelView, m);
CHECKMAT(ModelView);
state.dirty = true;
}
-void gpuRotate2D(float deg)
+void GPU_matrix_rotate_2d(float deg)
{
/* essentially RotateAxis('Z')
* TODO: simpler math for 2D case
@@ -261,20 +261,20 @@ void gpuRotate2D(float deg)
rotate_m4(ModelView, 'Z', DEG2RADF(deg));
}
-void gpuRotate3f(float deg, float x, float y, float z)
+void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
{
const float axis[3] = {x, y, z};
- gpuRotate3fv(deg, axis);
+ GPU_matrix_rotate_3fv(deg, axis);
}
-void gpuRotate3fv(float deg, const float axis[3])
+void GPU_matrix_rotate_3fv(float deg, const float axis[3])
{
Mat4 m;
axis_angle_to_mat4(m, axis, DEG2RADF(deg));
- gpuMultMatrix(m);
+ GPU_matrix_mul(m);
}
-void gpuRotateAxis(float deg, char axis)
+void GPU_matrix_rotate_axis(float deg, char axis)
{
/* rotate_m4 works in place */
rotate_m4(ModelView, axis, DEG2RADF(deg));
@@ -398,14 +398,14 @@ static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3
state.dirty = true;
}
-void gpuOrtho(float left, float right, float bottom, float top, float near, float far)
+void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
{
mat4_ortho_set(Projection, left, right, bottom, top, near, far);
CHECKMAT(Projection);
state.dirty = true;
}
-void gpuOrtho2D(float left, float right, float bottom, float top)
+void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top)
{
Mat4 m;
mat4_ortho_set(m, left, right, bottom, top, -1.0f, 1.0f);
@@ -413,21 +413,21 @@ void gpuOrtho2D(float left, float right, float bottom, float top)
state.dirty = true;
}
-void gpuFrustum(float left, float right, float bottom, float top, float near, float far)
+void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far)
{
mat4_frustum_set(Projection, left, right, bottom, top, near, far);
CHECKMAT(Projection);
state.dirty = true;
}
-void gpuPerspective(float fovy, float aspect, float near, float far)
+void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far)
{
float half_height = tanf(fovy * (float)(M_PI / 360.0)) * near;
float half_width = half_height * aspect;
- gpuFrustum(-half_width, +half_width, -half_height, +half_height, near, far);
+ GPU_matrix_frustum_set(-half_width, +half_width, -half_height, +half_height, near, far);
}
-void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
+void GPU_matrix_look_at(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
{
Mat4 cm;
float lookdir[3];
@@ -439,11 +439,11 @@ void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY,
mat4_look_from_origin(cm, lookdir, camup);
- gpuMultMatrix(cm);
- gpuTranslate3f(-eyeX, -eyeY, -eyeZ);
+ GPU_matrix_mul(cm);
+ GPU_matrix_translate_3f(-eyeX, -eyeY, -eyeZ);
}
-void gpuProject(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3])
+void GPU_matrix_project(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3])
{
float v[4];
@@ -459,7 +459,7 @@ void gpuProject(const float world[3], const float model[4][4], const float proj[
win[2] = (v[2] + 1) * 0.5f;
}
-bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3])
+bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3])
{
float pm[4][4];
float in[4];
@@ -497,7 +497,7 @@ bool gpuUnProject(const float win[3], const float model[4][4], const float proj[
return true;
}
-const float (*gpuGetModelViewMatrix(float m[4][4]))[4]
+const float (*GPU_matrix_model_view_get(float m[4][4]))[4]
{
if (m) {
copy_m4_m4(m, ModelView);
@@ -508,7 +508,7 @@ const float (*gpuGetModelViewMatrix(float m[4][4]))[4]
}
}
-const float (*gpuGetProjectionMatrix(float m[4][4]))[4]
+const float (*GPU_matrix_projection_get(float m[4][4]))[4]
{
if (m) {
copy_m4_m4(m, Projection);
@@ -519,7 +519,7 @@ const float (*gpuGetProjectionMatrix(float m[4][4]))[4]
}
}
-const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4]
+const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]
{
if (m == NULL) {
static Mat4 temp;
@@ -530,14 +530,14 @@ const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4]
return m;
}
-const float (*gpuGetNormalMatrix(float m[3][3]))[3]
+const float (*GPU_matrix_normal_get(float m[3][3]))[3]
{
if (m == NULL) {
static Mat3 temp3;
m = temp3;
}
- copy_m3_m4(m, (const float (*)[4])gpuGetModelViewMatrix(NULL));
+ copy_m3_m4(m, (const float (*)[4])GPU_matrix_model_view_get(NULL));
invert_m3(m);
transpose_m3(m);
@@ -545,40 +545,40 @@ const float (*gpuGetNormalMatrix(float m[3][3]))[3]
return m;
}
-const float (*gpuGetNormalMatrixInverse(float m[3][3]))[3]
+const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]
{
if (m == NULL) {
static Mat3 temp3;
m = temp3;
}
- gpuGetNormalMatrix(m);
+ GPU_matrix_normal_get(m);
invert_m3(m);
return m;
}
-void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
+void GPU_matrix_bind(const GPUShaderInterface *shaderface)
{
/* set uniform values to matrix stack values
* call this before a draw call if desired matrices are dirty
* call glUseProgram before this, as glUniform expects program to be bound
*/
- const Gwn_ShaderInput *MV = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MODELVIEW);
- const Gwn_ShaderInput *P = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_PROJECTION);
- const Gwn_ShaderInput *MVP = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MVP);
+ const GPUShaderInput *MV = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MODELVIEW);
+ const GPUShaderInput *P = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_PROJECTION);
+ const GPUShaderInput *MVP = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MVP);
- const Gwn_ShaderInput *N = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_NORMAL);
- const Gwn_ShaderInput *MV_inv = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MODELVIEW_INV);
- const Gwn_ShaderInput *P_inv = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_PROJECTION_INV);
+ const GPUShaderInput *N = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_NORMAL);
+ const GPUShaderInput *MV_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MODELVIEW_INV);
+ const GPUShaderInput *P_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_PROJECTION_INV);
if (MV) {
#if DEBUG_MATRIX_BIND
puts("setting MV matrix");
#endif
- glUniformMatrix4fv(MV->location, 1, GL_FALSE, (const float *)gpuGetModelViewMatrix(NULL));
+ glUniformMatrix4fv(MV->location, 1, GL_FALSE, (const float *)GPU_matrix_model_view_get(NULL));
}
if (P) {
@@ -586,7 +586,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
puts("setting P matrix");
#endif
- glUniformMatrix4fv(P->location, 1, GL_FALSE, (const float *)gpuGetProjectionMatrix(NULL));
+ glUniformMatrix4fv(P->location, 1, GL_FALSE, (const float *)GPU_matrix_projection_get(NULL));
}
if (MVP) {
@@ -594,7 +594,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
puts("setting MVP matrix");
#endif
- glUniformMatrix4fv(MVP->location, 1, GL_FALSE, (const float *)gpuGetModelViewProjectionMatrix(NULL));
+ glUniformMatrix4fv(MVP->location, 1, GL_FALSE, (const float *)GPU_matrix_model_view_projection_get(NULL));
}
if (N) {
@@ -602,19 +602,19 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
puts("setting normal matrix");
#endif
- glUniformMatrix3fv(N->location, 1, GL_FALSE, (const float *)gpuGetNormalMatrix(NULL));
+ glUniformMatrix3fv(N->location, 1, GL_FALSE, (const float *)GPU_matrix_normal_get(NULL));
}
if (MV_inv) {
Mat4 m;
- gpuGetModelViewMatrix(m);
+ GPU_matrix_model_view_get(m);
invert_m4(m);
glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float *)m);
}
if (P_inv) {
Mat4 m;
- gpuGetProjectionMatrix(m);
+ GPU_matrix_projection_get(m);
invert_m4(m);
glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float *)m);
}
@@ -622,7 +622,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
state.dirty = false;
}
-bool gpuMatricesDirty(void)
+bool GPU_matrix_dirty_get(void)
{
return state.dirty;
}
diff --git a/source/blender/gpu/intern/gpu_primitive.c b/source/blender/gpu/intern/gpu_primitive.c
new file mode 100644
index 00000000000..189d17f2dd2
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_primitive.c
@@ -0,0 +1,84 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_primitive.c
+ * \ingroup gpu
+ *
+ * GPU geometric primitives
+ */
+
+#include "GPU_primitive.h"
+#include "gpu_primitive_private.h"
+
+GPUPrimClass GPU_primtype_class(GPUPrimType prim_type)
+{
+ static const GPUPrimClass classes[] = {
+ [GPU_PRIM_POINTS] = GPU_PRIM_CLASS_POINT,
+ [GPU_PRIM_LINES] = GPU_PRIM_CLASS_LINE,
+ [GPU_PRIM_LINE_STRIP] = GPU_PRIM_CLASS_LINE,
+ [GPU_PRIM_LINE_LOOP] = GPU_PRIM_CLASS_LINE,
+ [GPU_PRIM_TRIS] = GPU_PRIM_CLASS_SURFACE,
+ [GPU_PRIM_TRI_STRIP] = GPU_PRIM_CLASS_SURFACE,
+ [GPU_PRIM_TRI_FAN] = GPU_PRIM_CLASS_SURFACE,
+
+ [GPU_PRIM_LINES_ADJ] = GPU_PRIM_CLASS_LINE,
+ [GPU_PRIM_LINE_STRIP_ADJ] = GPU_PRIM_CLASS_LINE,
+ [GPU_PRIM_TRIS_ADJ] = GPU_PRIM_CLASS_SURFACE,
+
+ [GPU_PRIM_NONE] = GPU_PRIM_CLASS_NONE
+ };
+
+ return classes[prim_type];
+}
+
+bool GPU_primtype_belongs_to_class(GPUPrimType prim_type, GPUPrimClass prim_class)
+{
+ if (prim_class == GPU_PRIM_CLASS_NONE && prim_type == GPU_PRIM_NONE) {
+ return true;
+ }
+ return prim_class & GPU_primtype_class(prim_type);
+}
+
+GLenum convert_prim_type_to_gl(GPUPrimType prim_type)
+{
+#if TRUST_NO_ONE
+ assert(prim_type != GPU_PRIM_NONE);
+#endif
+ static const GLenum table[] = {
+ [GPU_PRIM_POINTS] = GL_POINTS,
+ [GPU_PRIM_LINES] = GL_LINES,
+ [GPU_PRIM_LINE_STRIP] = GL_LINE_STRIP,
+ [GPU_PRIM_LINE_LOOP] = GL_LINE_LOOP,
+ [GPU_PRIM_TRIS] = GL_TRIANGLES,
+ [GPU_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP,
+ [GPU_PRIM_TRI_FAN] = GL_TRIANGLE_FAN,
+
+ [GPU_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY,
+ [GPU_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY,
+ [GPU_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY,
+ };
+
+ return table[prim_type];
+}
diff --git a/source/blender/gpu/intern/gpu_primitive_private.h b/source/blender/gpu/intern/gpu_primitive_private.h
new file mode 100644
index 00000000000..d057f29fdc5
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_primitive_private.h
@@ -0,0 +1,37 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_primitive_private.h
+ * \ingroup gpu
+ *
+ * GPU geometric primitives
+ */
+
+#ifndef __GPU_PRIMITIVE_PRIVATE_H__
+#define __GPU_PRIMITIVE_PRIVATE_H__
+
+GLenum convert_prim_type_to_gl(GPUPrimType);
+
+#endif /* __GPU_PRIMITIVE_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_private.h b/source/blender/gpu/intern/gpu_private.h
index 996ba9c63a1..df55f7922b3 100644
--- a/source/blender/gpu/intern/gpu_private.h
+++ b/source/blender/gpu/intern/gpu_private.h
@@ -25,6 +25,9 @@
#ifndef __GPU_PRIVATE_H__
#define __GPU_PRIVATE_H__
+struct GPUContext;
+struct GPUFrameBuffer;
+
/* call this before running any of the functions below */
void gpu_extensions_init(void);
void gpu_extensions_exit(void);
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index 7023e44d289..1c0e7ed4c1c 100644
--- a/source/blender/gpu/intern/gpu_select.c
+++ b/source/blender/gpu/intern/gpu_select.c
@@ -242,7 +242,7 @@ bool GPU_select_is_cached(void)
const uint *GPU_select_buffer_near(const uint *buffer, int hits)
{
const uint *buffer_near = NULL;
- uint depth_min = (uint)-1;
+ uint depth_min = (uint) - 1;
for (int i = 0; i < hits; i++) {
if (buffer[1] < depth_min) {
BLI_assert(buffer[3] != -1);
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 8c978be81c1..04b43d03c83 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -38,6 +38,7 @@
#include "DNA_space_types.h"
#include "GPU_extensions.h"
+#include "GPU_context.h"
#include "GPU_matrix.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
@@ -214,8 +215,9 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH])
}
}
-static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH],
- bool use_opensubdiv)
+static void gpu_shader_standard_defines(
+ char defines[MAX_DEFINE_LENGTH],
+ bool use_opensubdiv)
{
/* some useful defines to detect GPU type */
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
@@ -244,11 +246,12 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH],
* a global typedef which we don't have better place to define
* in yet.
*/
- strcat(defines, "struct VertexData {\n"
- " vec4 position;\n"
- " vec3 normal;\n"
- " vec2 uv;"
- "};\n");
+ strcat(defines,
+ "struct VertexData {\n"
+ " vec4 position;\n"
+ " vec3 normal;\n"
+ " vec2 uv;"
+ "};\n");
}
#else
UNUSED_VARS(use_opensubdiv);
@@ -257,21 +260,23 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH],
return;
}
-GPUShader *GPU_shader_create(const char *vertexcode,
- const char *fragcode,
- const char *geocode,
- const char *libcode,
- const char *defines)
+GPUShader *GPU_shader_create(
+ const char *vertexcode,
+ const char *fragcode,
+ const char *geocode,
+ const char *libcode,
+ const char *defines)
{
- return GPU_shader_create_ex(vertexcode,
- fragcode,
- geocode,
- libcode,
- defines,
- GPU_SHADER_FLAGS_NONE,
- GPU_SHADER_TFB_NONE,
- NULL,
- 0);
+ return GPU_shader_create_ex(
+ vertexcode,
+ fragcode,
+ geocode,
+ libcode,
+ defines,
+ GPU_SHADER_FLAGS_NONE,
+ GPU_SHADER_TFB_NONE,
+ NULL,
+ 0);
}
#define DEBUG_SHADER_NONE ""
@@ -321,15 +326,16 @@ static void gpu_dump_shaders(const char **code, const int num_shaders, const cha
printf("Shader file written to disk: %s\n", shader_path);
}
-GPUShader *GPU_shader_create_ex(const char *vertexcode,
- const char *fragcode,
- const char *geocode,
- const char *libcode,
- const char *defines,
- const int flags,
- const GPUShaderTFBType tf_type,
- const char **tf_names,
- const int tf_count)
+GPUShader *GPU_shader_create_ex(
+ const char *vertexcode,
+ const char *fragcode,
+ const char *geocode,
+ const char *libcode,
+ const char *defines,
+ const int flags,
+ const GPUShaderTFBType tf_type,
+ const char **tf_names,
+ const int tf_count)
{
#ifdef WITH_OPENSUBDIV
bool use_opensubdiv = (flags & GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV) != 0;
@@ -366,8 +372,9 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
return NULL;
}
- gpu_shader_standard_defines(standard_defines,
- use_opensubdiv);
+ gpu_shader_standard_defines(
+ standard_defines,
+ use_opensubdiv);
gpu_shader_standard_extensions(standard_extensions);
if (vertexcode) {
@@ -410,12 +417,13 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
#ifdef WITH_OPENSUBDIV
/* TODO(sergey): Move to fragment shader source code generation. */
if (use_opensubdiv) {
- source[num_source++] =
+ source[num_source++] = (
"#ifdef USE_OPENSUBDIV\n"
"in block {\n"
" VertexData v;\n"
"} inpt;\n"
- "#endif\n";
+ "#endif\n"
+ );
}
#endif
@@ -496,24 +504,26 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
return NULL;
}
- shader->interface = GWN_shaderinterface_create(shader->program);
+ shader->interface = GPU_shaderinterface_create(shader->program);
#ifdef WITH_OPENSUBDIV
/* TODO(sergey): Find a better place for this. */
if (use_opensubdiv) {
if (GLEW_VERSION_4_1) {
- glProgramUniform1i(shader->program,
- GWN_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location,
- 30); /* GL_TEXTURE30 */
-
- glProgramUniform1i(shader->program,
- GWN_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location,
- 31); /* GL_TEXTURE31 */
+ glProgramUniform1i(
+ shader->program,
+ GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location,
+ 30); /* GL_TEXTURE30 */
+
+ glProgramUniform1i(
+ shader->program,
+ GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location,
+ 31); /* GL_TEXTURE31 */
}
else {
glUseProgram(shader->program);
- glUniform1i(GWN_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30);
- glUniform1i(GWN_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31);
+ glUniform1i(GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30);
+ glUniform1i(GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31);
glUseProgram(0);
}
}
@@ -532,7 +542,7 @@ void GPU_shader_bind(GPUShader *shader)
BLI_assert(shader && shader->program);
glUseProgram(shader->program);
- gpuBindMatrices(shader->interface);
+ GPU_matrix_bind(shader->interface);
}
void GPU_shader_unbind(void)
@@ -563,6 +573,7 @@ void GPU_shader_transform_feedback_disable(GPUShader *UNUSED(shader))
void GPU_shader_free(GPUShader *shader)
{
+ BLI_assert(GPU_context_active_get() != NULL);
BLI_assert(shader);
if (shader->vertex)
@@ -575,7 +586,7 @@ void GPU_shader_free(GPUShader *shader)
glDeleteProgram(shader->program);
if (shader->interface)
- GWN_shaderinterface_discard(shader->interface);
+ GPU_shaderinterface_discard(shader->interface);
MEM_freeN(shader);
}
@@ -583,14 +594,14 @@ void GPU_shader_free(GPUShader *shader)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
{
BLI_assert(shader && shader->program);
- const Gwn_ShaderInput *uniform = GWN_shaderinterface_uniform(shader->interface, name);
+ const GPUShaderInput *uniform = GPU_shaderinterface_uniform(shader->interface, name);
return uniform ? uniform->location : -1;
}
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
{
BLI_assert(shader && shader->program);
- const Gwn_ShaderInput *uniform = GWN_shaderinterface_uniform_builtin(shader->interface, builtin);
+ const GPUShaderInput *uniform = GPU_shaderinterface_uniform_builtin(shader->interface, builtin);
return uniform ? uniform->location : -1;
}
@@ -598,7 +609,7 @@ int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)
{
BLI_assert(shader && shader->program);
- const Gwn_ShaderInput *ubo = GWN_shaderinterface_ubo(shader->interface, name);
+ const GPUShaderInput *ubo = GPU_shaderinterface_ubo(shader->interface, name);
return ubo ? ubo->location : -1;
}
@@ -675,7 +686,7 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText
int GPU_shader_get_attribute(GPUShader *shader, const char *name)
{
BLI_assert(shader && shader->program);
- const Gwn_ShaderInput *attrib = GWN_shaderinterface_attr(shader->interface, name);
+ const GPUShaderInput *attrib = GPU_shaderinterface_attr(shader->interface, name);
return attrib ? attrib->location : -1;
}
@@ -903,17 +914,20 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
if (shader == GPU_SHADER_EDGES_FRONT_BACK_PERSP && !GLEW_VERSION_3_2) {
/* TODO: remove after switch to core profile (maybe) */
- static const GPUShaderStages legacy_fancy_edges =
- { datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl,
- datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl };
+ static const GPUShaderStages legacy_fancy_edges = {
+ datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl,
+ datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl,
+ };
stages = &legacy_fancy_edges;
}
if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR && !GLEW_VERSION_3_2) {
/* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */
/* TODO: remove after switch to core profile (maybe) */
- static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl,
- datatoc_gpu_shader_2D_line_dashed_frag_glsl };
+ static const GPUShaderStages legacy_dashed_lines = {
+ datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl,
+ datatoc_gpu_shader_2D_line_dashed_frag_glsl,
+ };
stages = &legacy_dashed_lines;
}
diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c
new file mode 100644
index 00000000000..54c5f41bbd3
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_shader_interface.c
@@ -0,0 +1,367 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_shader_interface.c
+ * \ingroup gpu
+ *
+ * GPU shader interface (C --> GLSL)
+ */
+
+#include "GPU_shader_interface.h"
+
+#include "gpu_batch_private.h"
+#include "gpu_context_private.h"
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+#define DEBUG_SHADER_INTERFACE 0
+
+#if DEBUG_SHADER_INTERFACE
+# include <stdio.h>
+#endif
+
+static const char *BuiltinUniform_name(GPUUniformBuiltin u)
+{
+ static const char *names[] = {
+ [GPU_UNIFORM_NONE] = NULL,
+
+ [GPU_UNIFORM_MODEL] = "ModelMatrix",
+ [GPU_UNIFORM_VIEW] = "ViewMatrix",
+ [GPU_UNIFORM_MODELVIEW] = "ModelViewMatrix",
+ [GPU_UNIFORM_PROJECTION] = "ProjectionMatrix",
+ [GPU_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix",
+ [GPU_UNIFORM_MVP] = "ModelViewProjectionMatrix",
+
+ [GPU_UNIFORM_MODEL_INV] = "ModelMatrixInverse",
+ [GPU_UNIFORM_VIEW_INV] = "ViewMatrixInverse",
+ [GPU_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse",
+ [GPU_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse",
+ [GPU_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse",
+
+ [GPU_UNIFORM_NORMAL] = "NormalMatrix",
+ [GPU_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix",
+ [GPU_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors",
+ [GPU_UNIFORM_ORCO] = "OrcoTexCoFactors",
+
+ [GPU_UNIFORM_COLOR] = "color",
+ [GPU_UNIFORM_EYE] = "eye",
+ [GPU_UNIFORM_CALLID] = "callId",
+
+ [GPU_UNIFORM_CUSTOM] = NULL,
+ [GPU_NUM_UNIFORMS] = NULL,
+ };
+
+ return names[u];
+}
+
+GPU_INLINE bool match(const char *a, const char *b)
+{
+ return strcmp(a, b) == 0;
+}
+
+GPU_INLINE uint hash_string(const char *str)
+{
+ uint i = 0, c;
+ while ((c = *str++)) {
+ i = i * 37 + c;
+ }
+ return i;
+}
+
+GPU_INLINE void set_input_name(
+ GPUShaderInterface *shaderface, GPUShaderInput *input,
+ const char *name, uint32_t name_len)
+{
+ input->name_offset = shaderface->name_buffer_offset;
+ input->name_hash = hash_string(name);
+ shaderface->name_buffer_offset += name_len + 1; /* include NULL terminator */
+}
+
+GPU_INLINE void shader_input_to_bucket(
+ GPUShaderInput *input,
+ GPUShaderInput *buckets[GPU_NUM_SHADERINTERFACE_BUCKETS])
+{
+ const uint bucket_index = input->name_hash % GPU_NUM_SHADERINTERFACE_BUCKETS;
+ input->next = buckets[bucket_index];
+ buckets[bucket_index] = input;
+}
+
+GPU_INLINE const GPUShaderInput *buckets_lookup(
+ GPUShaderInput *const buckets[GPU_NUM_SHADERINTERFACE_BUCKETS],
+ const char *name_buffer, const char *name)
+{
+ const uint name_hash = hash_string(name);
+ const uint bucket_index = name_hash % GPU_NUM_SHADERINTERFACE_BUCKETS;
+ const GPUShaderInput *input = buckets[bucket_index];
+ if (input == NULL) {
+ /* Requested uniform is not found at all. */
+ return NULL;
+ }
+ /* Optimization bit: if there is no hash collision detected when constructing shader interface
+ * it means we can only request the single possible uniform. Surely, it's possible we request
+ * uniform which causes hash collision, but that will be detected in debug builds. */
+ if (input->next == NULL) {
+ if (name_hash == input->name_hash) {
+#if TRUST_NO_ONE
+ assert(match(name_buffer + input->name_offset, name));
+#endif
+ return input;
+ }
+ return NULL;
+ }
+ /* Work through possible collisions. */
+ const GPUShaderInput *next = input;
+ while (next != NULL) {
+ input = next;
+ next = input->next;
+ if (input->name_hash != name_hash) {
+ continue;
+ }
+ if (match(name_buffer + input->name_offset, name)) {
+ return input;
+ }
+ }
+ return NULL; /* not found */
+}
+
+GPU_INLINE void buckets_free(GPUShaderInput *buckets[GPU_NUM_SHADERINTERFACE_BUCKETS])
+{
+ for (uint bucket_index = 0; bucket_index < GPU_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) {
+ GPUShaderInput *input = buckets[bucket_index];
+ while (input != NULL) {
+ GPUShaderInput *input_next = input->next;
+ free(input);
+ input = input_next;
+ }
+ }
+}
+
+static bool setup_builtin_uniform(GPUShaderInput *input, const char *name)
+{
+ /* TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types */
+
+ /* detect built-in uniforms (name must match) */
+ for (GPUUniformBuiltin u = GPU_UNIFORM_NONE + 1; u < GPU_UNIFORM_CUSTOM; ++u) {
+ const char *builtin_name = BuiltinUniform_name(u);
+ if (match(name, builtin_name)) {
+ input->builtin_type = u;
+ return true;
+ }
+ }
+ input->builtin_type = GPU_UNIFORM_CUSTOM;
+ return false;
+}
+
+static const GPUShaderInput *add_uniform(GPUShaderInterface *shaderface, const char *name)
+{
+ GPUShaderInput *input = malloc(sizeof(GPUShaderInput));
+
+ input->location = glGetUniformLocation(shaderface->program, name);
+
+ uint name_len = strlen(name);
+ shaderface->name_buffer = realloc(shaderface->name_buffer, shaderface->name_buffer_offset + name_len + 1); /* include NULL terminator */
+ char *name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset;
+ strcpy(name_buffer, name);
+
+ set_input_name(shaderface, input, name, name_len);
+ setup_builtin_uniform(input, name);
+
+ shader_input_to_bucket(input, shaderface->uniform_buckets);
+ if (input->builtin_type != GPU_UNIFORM_NONE &&
+ input->builtin_type != GPU_UNIFORM_CUSTOM)
+ {
+ shaderface->builtin_uniforms[input->builtin_type] = input;
+ }
+#if DEBUG_SHADER_INTERFACE
+ printf("GPUShaderInterface %p, program %d, uniform[] '%s' at location %d\n",
+ shaderface,
+ shaderface->program,
+ name,
+ input->location);
+#endif
+ return input;
+}
+
+GPUShaderInterface *GPU_shaderinterface_create(int32_t program)
+{
+ GPUShaderInterface *shaderface = calloc(1, sizeof(GPUShaderInterface));
+ shaderface->program = program;
+
+#if DEBUG_SHADER_INTERFACE
+ printf("%s {\n", __func__); /* enter function */
+ printf("GPUShaderInterface %p, program %d\n", shaderface, program);
+#endif
+
+ GLint max_attrib_name_len, attr_len;
+ glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len);
+ glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attr_len);
+
+ GLint max_ubo_name_len, ubo_len;
+ glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len);
+ glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_len);
+
+ const uint32_t name_buffer_len = attr_len * max_attrib_name_len + ubo_len * max_ubo_name_len;
+ shaderface->name_buffer = malloc(name_buffer_len);
+
+ /* Attributes */
+ for (uint32_t i = 0; i < attr_len; ++i) {
+ GPUShaderInput *input = malloc(sizeof(GPUShaderInput));
+ GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset;
+ char *name = shaderface->name_buffer + shaderface->name_buffer_offset;
+ GLsizei name_len = 0;
+
+ glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name);
+
+ /* remove "[0]" from array name */
+ if (name[name_len - 1] == ']') {
+ name[name_len - 3] = '\0';
+ name_len -= 3;
+ }
+
+ /* TODO: reject DOUBLE gl_types */
+
+ input->location = glGetAttribLocation(program, name);
+
+ set_input_name(shaderface, input, name, name_len);
+
+ shader_input_to_bucket(input, shaderface->attrib_buckets);
+
+#if DEBUG_SHADER_INTERFACE
+ printf("attrib[%u] '%s' at location %d\n", i, name, input->location);
+#endif
+ }
+ /* Uniform Blocks */
+ for (uint32_t i = 0; i < ubo_len; ++i) {
+ GPUShaderInput *input = malloc(sizeof(GPUShaderInput));
+ GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset;
+ char *name = shaderface->name_buffer + shaderface->name_buffer_offset;
+ GLsizei name_len = 0;
+
+ glGetActiveUniformBlockName(program, i, remaining_buffer, &name_len, name);
+
+ input->location = i;
+
+ set_input_name(shaderface, input, name, name_len);
+
+ shader_input_to_bucket(input, shaderface->ubo_buckets);
+
+#if DEBUG_SHADER_INTERFACE
+ printf("ubo '%s' at location %d\n", name, input->location);
+#endif
+ }
+ /* Builtin Uniforms */
+ for (GPUUniformBuiltin u = GPU_UNIFORM_NONE + 1; u < GPU_UNIFORM_CUSTOM; ++u) {
+ const char *builtin_name = BuiltinUniform_name(u);
+ if (glGetUniformLocation(program, builtin_name) != -1) {
+ add_uniform((GPUShaderInterface *)shaderface, builtin_name);
+ }
+ }
+ /* Batches ref buffer */
+ shaderface->batches_len = GPU_SHADERINTERFACE_REF_ALLOC_COUNT;
+ shaderface->batches = calloc(shaderface->batches_len, sizeof(GPUBatch *));
+
+ return shaderface;
+}
+
+void GPU_shaderinterface_discard(GPUShaderInterface *shaderface)
+{
+ /* Free memory used by buckets and has entries. */
+ buckets_free(shaderface->uniform_buckets);
+ buckets_free(shaderface->attrib_buckets);
+ buckets_free(shaderface->ubo_buckets);
+ /* Free memory used by name_buffer. */
+ free(shaderface->name_buffer);
+ /* Remove this interface from all linked Batches vao cache. */
+ for (int i = 0; i < shaderface->batches_len; ++i) {
+ if (shaderface->batches[i] != NULL) {
+ gpu_batch_remove_interface_ref(shaderface->batches[i], shaderface);
+ }
+ }
+ free(shaderface->batches);
+ /* Free memory used by shader interface by its self. */
+ free(shaderface);
+}
+
+const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *shaderface, const char *name)
+{
+ /* TODO: Warn if we find a matching builtin, since these can be looked up much quicker. */
+ const GPUShaderInput *input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name);
+ /* If input is not found add it so it's found next time. */
+ if (input == NULL) {
+ input = add_uniform((GPUShaderInterface *)shaderface, name);
+ }
+ return (input->location != -1) ? input : NULL;
+}
+
+const GPUShaderInput *GPU_shaderinterface_uniform_builtin(
+ const GPUShaderInterface *shaderface, GPUUniformBuiltin builtin)
+{
+#if TRUST_NO_ONE
+ assert(builtin != GPU_UNIFORM_NONE);
+ assert(builtin != GPU_UNIFORM_CUSTOM);
+ assert(builtin != GPU_NUM_UNIFORMS);
+#endif
+ return shaderface->builtin_uniforms[builtin];
+}
+
+const GPUShaderInput *GPU_shaderinterface_ubo(const GPUShaderInterface *shaderface, const char *name)
+{
+ return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name);
+}
+
+const GPUShaderInput *GPU_shaderinterface_attr(const GPUShaderInterface *shaderface, const char *name)
+{
+ return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name);
+}
+
+void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *shaderface, GPUBatch *batch)
+{
+ int i; /* find first unused slot */
+ for (i = 0; i < shaderface->batches_len; ++i) {
+ if (shaderface->batches[i] == NULL) {
+ break;
+ }
+ }
+ if (i == shaderface->batches_len) {
+ /* Not enough place, realloc the array. */
+ i = shaderface->batches_len;
+ shaderface->batches_len += GPU_SHADERINTERFACE_REF_ALLOC_COUNT;
+ shaderface->batches = realloc(shaderface->batches, sizeof(GPUBatch *) * shaderface->batches_len);
+ memset(shaderface->batches + i, 0, sizeof(GPUBatch *) * GPU_SHADERINTERFACE_REF_ALLOC_COUNT);
+ }
+ shaderface->batches[i] = batch;
+}
+
+void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface *shaderface, GPUBatch *batch)
+{
+ for (int i = 0; i < shaderface->batches_len; ++i) {
+ if (shaderface->batches[i] == batch) {
+ shaderface->batches[i] = NULL;
+ break; /* cannot have duplicates */
+ }
+ }
+}
diff --git a/source/blender/gpu/intern/gpu_shader_private.h b/source/blender/gpu/intern/gpu_shader_private.h
index de5439c5638..d16aae79aae 100644
--- a/source/blender/gpu/intern/gpu_shader_private.h
+++ b/source/blender/gpu/intern/gpu_shader_private.h
@@ -26,7 +26,7 @@
#define __GPU_SHADER_PRIVATE_H__
#include "GPU_glew.h"
-#include "gawain/gwn_shader_interface.h"
+#include "GPU_shader_interface.h"
struct GPUShader {
GLuint program; /* handle for full program (links shader stages below) */
@@ -35,7 +35,7 @@ struct GPUShader {
GLuint geometry; /* handle for geometry shader */
GLuint fragment; /* handle for fragment shader */
- Gwn_ShaderInterface *interface; /* cached uniform & attrib interface for shader */
+ GPUShaderInterface *interface; /* cached uniform & attrib interface for shader */
int feedback_transform_type;
};
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c
index 588d61640bd..68d846ccfba 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.c
@@ -66,10 +66,11 @@ void GPU_blend_set_func_separate(
GPUBlendFunction src_rgb, GPUBlendFunction dst_rgb,
GPUBlendFunction src_alpha, GPUBlendFunction dst_alpha)
{
- glBlendFuncSeparate(gpu_get_gl_blendfunction(src_rgb),
- gpu_get_gl_blendfunction(dst_rgb),
- gpu_get_gl_blendfunction(src_alpha),
- gpu_get_gl_blendfunction(dst_alpha));
+ glBlendFuncSeparate(
+ gpu_get_gl_blendfunction(src_rgb),
+ gpu_get_gl_blendfunction(dst_rgb),
+ gpu_get_gl_blendfunction(src_alpha),
+ gpu_get_gl_blendfunction(dst_alpha));
}
void GPU_depth_test(bool enable)
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index ae037ca442e..5ac746ec9c1 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -38,22 +38,22 @@
#include "BKE_global.h"
#include "GPU_batch.h"
+#include "GPU_context.h"
#include "GPU_debug.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
-#include "GPU_framebuffer.h"
#include "GPU_glew.h"
+#include "GPU_framebuffer.h"
#include "GPU_texture.h"
+#include "gpu_context_private.h"
+
static struct GPUTextureGlobal {
GPUTexture *invalid_tex_1D; /* texture used in place of invalid textures (not loaded correctly, missing) */
GPUTexture *invalid_tex_2D;
GPUTexture *invalid_tex_3D;
} GG = {NULL, NULL, NULL};
-static ListBase g_orphaned_tex = {NULL, NULL};
-static ThreadMutex g_orphan_lock;
-
/* Maximum number of FBOs a texture can be attached to. */
#define GPU_TEX_MAX_FBO_ATTACHED 8
@@ -134,73 +134,162 @@ unsigned int GPU_texture_memory_usage_get(void)
/* -------------------------------- */
-static GLenum gpu_texture_get_format(
- int components, GPUTextureFormat data_type,
- GLenum *format, GLenum *data_format, GPUTextureFormatFlag *format_flag, unsigned int *bytesize)
+static int gpu_get_component_count(GPUTextureFormat format)
{
- if (ELEM(data_type, GPU_DEPTH_COMPONENT24,
- GPU_DEPTH_COMPONENT16,
- GPU_DEPTH_COMPONENT32F))
+ switch (format) {
+ case GPU_RGBA8:
+ case GPU_RGBA16F:
+ case GPU_RGBA16:
+ case GPU_RGBA32F:
+ return 4;
+ case GPU_RGB16F:
+ case GPU_R11F_G11F_B10F:
+ return 3;
+ case GPU_RG8:
+ case GPU_RG16:
+ case GPU_RG16F:
+ case GPU_RG16I:
+ case GPU_RG16UI:
+ case GPU_RG32F:
+ return 2;
+ default:
+ return 1;
+ }
+}
+
+/* Definitely not complete, edit according to the gl specification. */
+static void gpu_validate_data_format(GPUTextureFormat tex_format, GPUDataFormat data_format)
+{
+ if (ELEM(tex_format,
+ GPU_DEPTH_COMPONENT24,
+ GPU_DEPTH_COMPONENT16,
+ GPU_DEPTH_COMPONENT32F))
{
- *format_flag |= GPU_FORMAT_DEPTH;
- *data_format = GL_FLOAT;
- *format = GL_DEPTH_COMPONENT;
+ BLI_assert(data_format == GPU_DATA_FLOAT);
}
- else if (data_type == GPU_DEPTH24_STENCIL8) {
- *format_flag |= GPU_FORMAT_DEPTH | GPU_FORMAT_STENCIL;
- *data_format = GL_UNSIGNED_INT_24_8;
- *format = GL_DEPTH_STENCIL;
+ else if (tex_format == GPU_DEPTH24_STENCIL8) {
+ BLI_assert(data_format == GPU_DATA_UNSIGNED_INT_24_8);
}
else {
/* Integer formats */
- if (ELEM(data_type, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
- if (ELEM(data_type, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
- *data_format = GL_UNSIGNED_INT;
+ if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
+ if (ELEM(tex_format, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
+ BLI_assert(data_format == GPU_DATA_UNSIGNED_INT);
}
else {
- *data_format = GL_INT;
+ BLI_assert(data_format == GPU_DATA_INT);
}
+ }
+ /* Byte formats */
+ else if (ELEM(tex_format, GPU_R8, GPU_RG8, GPU_RGBA8)) {
+ BLI_assert(ELEM(data_format, GPU_DATA_UNSIGNED_BYTE, GPU_DATA_FLOAT));
+ }
+ /* Special case */
+ else if (ELEM(tex_format, GPU_R11F_G11F_B10F)) {
+ BLI_assert(ELEM(data_format, GPU_DATA_10_11_11_REV, GPU_DATA_FLOAT));
+ }
+ /* Float formats */
+ else {
+ BLI_assert(ELEM(data_format, GPU_DATA_FLOAT));
+ }
+ }
+}
+static GPUDataFormat gpu_get_data_format_from_tex_format(GPUTextureFormat tex_format)
+{
+ if (ELEM(tex_format,
+ GPU_DEPTH_COMPONENT24,
+ GPU_DEPTH_COMPONENT16,
+ GPU_DEPTH_COMPONENT32F))
+ {
+ return GPU_DATA_FLOAT;
+ }
+ else if (tex_format == GPU_DEPTH24_STENCIL8) {
+ return GPU_DATA_UNSIGNED_INT_24_8;
+ }
+ else {
+ /* Integer formats */
+ if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
+ if (ELEM(tex_format, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
+ return GPU_DATA_UNSIGNED_INT;
+ }
+ else {
+ return GPU_DATA_INT;
+ }
+ }
+ /* Byte formats */
+ else if (ELEM(tex_format, GPU_R8)) {
+ return GPU_DATA_UNSIGNED_BYTE;
+ }
+ /* Special case */
+ else if (ELEM(tex_format, GPU_R11F_G11F_B10F)) {
+ return GPU_DATA_10_11_11_REV;
+ }
+ else {
+ return GPU_DATA_FLOAT;
+ }
+ }
+}
+
+/* Definitely not complete, edit according to the gl specification. */
+static GLenum gpu_get_gl_dataformat(GPUTextureFormat data_type, GPUTextureFormatFlag *format_flag)
+{
+ if (ELEM(data_type,
+ GPU_DEPTH_COMPONENT24,
+ GPU_DEPTH_COMPONENT16,
+ GPU_DEPTH_COMPONENT32F))
+ {
+ *format_flag |= GPU_FORMAT_DEPTH;
+ return GL_DEPTH_COMPONENT;
+ }
+ else if (data_type == GPU_DEPTH24_STENCIL8) {
+ *format_flag |= GPU_FORMAT_DEPTH | GPU_FORMAT_STENCIL;
+ return GL_DEPTH_STENCIL;
+ }
+ else {
+ /* Integer formats */
+ if (ELEM(data_type, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
*format_flag |= GPU_FORMAT_INTEGER;
- switch (components) {
- case 1: *format = GL_RED_INTEGER; break;
- case 2: *format = GL_RG_INTEGER; break;
- case 3: *format = GL_RGB_INTEGER; break;
- case 4: *format = GL_RGBA_INTEGER; break;
- default: break;
+ switch (gpu_get_component_count(data_type)) {
+ case 1: return GL_RED_INTEGER; break;
+ case 2: return GL_RG_INTEGER; break;
+ case 3: return GL_RGB_INTEGER; break;
+ case 4: return GL_RGBA_INTEGER; break;
}
}
else if (ELEM(data_type, GPU_R8)) {
- *data_format = GL_UNSIGNED_BYTE;
- *format = GL_RED;
+ *format_flag |= GPU_FORMAT_FLOAT;
+ return GL_RED;
}
else {
- *data_format = GL_FLOAT;
*format_flag |= GPU_FORMAT_FLOAT;
- switch (components) {
- case 1: *format = GL_RED; break;
- case 2: *format = GL_RG; break;
- case 3: *format = GL_RGB; break;
- case 4: *format = GL_RGBA; break;
- default: break;
+ switch (gpu_get_component_count(data_type)) {
+ case 1: return GL_RED; break;
+ case 2: return GL_RG; break;
+ case 3: return GL_RGB; break;
+ case 4: return GL_RGBA; break;
}
}
}
+ BLI_assert(0);
+ *format_flag |= GPU_FORMAT_FLOAT;
+ return GL_RGBA;
+}
+
+static unsigned int gpu_get_bytesize(GPUTextureFormat data_type)
+{
switch (data_type) {
case GPU_RGBA32F:
- *bytesize = 32;
- break;
+ return 32;
case GPU_RG32F:
case GPU_RGBA16F:
case GPU_RGBA16:
- *bytesize = 16;
- break;
+ return 16;
case GPU_RGB16F:
- *bytesize = 12;
- break;
+ return 12;
case GPU_RG16F:
case GPU_RG16I:
case GPU_RG16UI:
@@ -212,28 +301,28 @@ static GLenum gpu_texture_get_format(
case GPU_R32F:
case GPU_R32UI:
case GPU_R32I:
- *bytesize = 4;
- break;
+ return 4;
case GPU_DEPTH_COMPONENT24:
- *bytesize = 3;
- break;
+ return 3;
case GPU_DEPTH_COMPONENT16:
case GPU_R16F:
+ case GPU_R16UI:
case GPU_R16I:
case GPU_RG8:
- *bytesize = 2;
- break;
+ return 2;
case GPU_R8:
- *bytesize = 1;
- break;
+ return 1;
default:
- *bytesize = 0;
- break;
+ BLI_assert(!"Texture format incorrect or unsupported\n");
+ return 0;
}
+}
+static GLenum gpu_get_gl_internalformat(GPUTextureFormat format)
+{
/* You can add any of the available type to this list
* For available types see GPU_texture.h */
- switch (data_type) {
+ switch (format) {
/* Formats texture & renderbuffer */
case GPU_RGBA32F: return GL_RGBA32F;
case GPU_RGBA16F: return GL_RGBA16F;
@@ -265,31 +354,29 @@ static GLenum gpu_texture_get_format(
case GPU_DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT24;
case GPU_DEPTH_COMPONENT16: return GL_DEPTH_COMPONENT16;
default:
- fprintf(stderr, "Texture format incorrect or unsupported\n");
+ BLI_assert(!"Texture format incorrect or unsupported\n");
return 0;
}
}
-static int gpu_texture_get_component_count(GPUTextureFormat format)
+static GLenum gpu_get_gl_datatype(GPUDataFormat format)
{
switch (format) {
- case GPU_RGBA8:
- case GPU_RGBA16F:
- case GPU_RGBA16:
- case GPU_RGBA32F:
- return 4;
- case GPU_RGB16F:
- case GPU_R11F_G11F_B10F:
- return 3;
- case GPU_RG8:
- case GPU_RG16:
- case GPU_RG16F:
- case GPU_RG16I:
- case GPU_RG16UI:
- case GPU_RG32F:
- return 2;
+ case GPU_DATA_FLOAT:
+ return GL_FLOAT;
+ case GPU_DATA_INT:
+ return GL_INT;
+ case GPU_DATA_UNSIGNED_INT:
+ return GL_UNSIGNED_INT;
+ case GPU_DATA_UNSIGNED_BYTE:
+ return GL_UNSIGNED_BYTE;
+ case GPU_DATA_UNSIGNED_INT_24_8:
+ return GL_UNSIGNED_INT_24_8;
+ case GPU_DATA_10_11_11_REV:
+ return GL_UNSIGNED_INT_10F_11F_11F_REV;
default:
- return 1;
+ BLI_assert(!"Unhandled data format");
+ return GL_FLOAT;
}
}
@@ -331,22 +418,22 @@ static float *GPU_texture_3D_rescale(GPUTexture *tex, int w, int h, int d, int c
/* This tries to allocate video memory for a given texture
* If alloc fails, lower the resolution until it fits. */
static bool gpu_texture_try_alloc(
- GPUTexture *tex, GLenum proxy, GLenum internalformat, GLenum format, GLenum data_format,
+ GPUTexture *tex, GLenum proxy, GLenum internalformat, GLenum data_format, GLenum data_type,
int channels, bool try_rescale, const float *fpixels, float **rescaled_fpixels)
{
int r_width;
switch (proxy) {
case GL_PROXY_TEXTURE_1D:
- glTexImage1D(proxy, 0, internalformat, tex->w, 0, format, data_format, NULL);
+ glTexImage1D(proxy, 0, internalformat, tex->w, 0, data_format, data_type, NULL);
break;
case GL_PROXY_TEXTURE_1D_ARRAY:
case GL_PROXY_TEXTURE_2D:
- glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, format, data_format, NULL);
+ glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, NULL);
break;
case GL_PROXY_TEXTURE_2D_ARRAY:
case GL_PROXY_TEXTURE_3D:
- glTexImage3D(proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, format, data_format, NULL);
+ glTexImage3D(proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, NULL);
break;
}
@@ -367,11 +454,11 @@ static bool gpu_texture_try_alloc(
if (tex->d == 0 && proxy == GL_PROXY_TEXTURE_3D) break;
if (proxy == GL_PROXY_TEXTURE_1D)
- glTexImage1D(proxy, 0, internalformat, tex->w, 0, format, data_format, NULL);
+ glTexImage1D(proxy, 0, internalformat, tex->w, 0, data_format, data_type, NULL);
else if (proxy == GL_PROXY_TEXTURE_2D)
- glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, format, data_format, NULL);
+ glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, NULL);
else if (proxy == GL_PROXY_TEXTURE_3D)
- glTexImage3D(proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, format, data_format, NULL);
+ glTexImage3D(proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, NULL);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &r_width);
}
@@ -384,6 +471,7 @@ static bool gpu_texture_try_alloc(
/* Do nothing for now */
return false;
case GL_PROXY_TEXTURE_3D:
+ BLI_assert(data_type == GL_FLOAT);
*rescaled_fpixels = GPU_texture_3D_rescale(tex, w, h, d, channels, fpixels);
return (bool)*rescaled_fpixels;
}
@@ -393,9 +481,9 @@ static bool gpu_texture_try_alloc(
return (r_width > 0);
}
-static GPUTexture *GPU_texture_create_nD(
- int w, int h, int d, int n, const float *fpixels,
- GPUTextureFormat data_type, int samples,
+GPUTexture *GPU_texture_create_nD(
+ int w, int h, int d, int n, const void *pixels,
+ GPUTextureFormat tex_format, GPUDataFormat gpu_data_format, int samples,
const bool can_rescale, char err_out[256])
{
if (samples) {
@@ -409,8 +497,9 @@ static GPUTexture *GPU_texture_create_nD(
tex->samples = samples;
tex->number = -1;
tex->refcount = 1;
- tex->format = data_type;
- tex->components = gpu_texture_get_component_count(data_type);
+ tex->format = tex_format;
+ tex->components = gpu_get_component_count(tex_format);
+ tex->bytesize = gpu_get_bytesize(tex_format);
tex->format_flag = 0;
if (n == 2) {
@@ -434,23 +523,25 @@ static GPUTexture *GPU_texture_create_nD(
return NULL;
}
+ gpu_validate_data_format(tex_format, gpu_data_format);
+
if (samples && n == 2 && d == 0)
tex->target = GL_TEXTURE_2D_MULTISAMPLE;
- GLenum format, internalformat, data_format;
- internalformat = gpu_texture_get_format(tex->components, data_type, &format, &data_format,
- &tex->format_flag, &tex->bytesize);
+ GLenum internalformat = gpu_get_gl_internalformat(tex_format);
+ GLenum data_format = gpu_get_gl_dataformat(tex_format, &tex->format_flag);
+ GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
gpu_texture_memory_footprint_add(tex);
/* Generate Texture object */
- glGenTextures(1, &tex->bindcode);
+ tex->bindcode = GPU_tex_alloc();
if (!tex->bindcode) {
if (err_out)
- BLI_snprintf(err_out, 256, "GPUTexture: texture create failed");
+ BLI_snprintf(err_out, 256, "GPUTexture: texture create failed\n");
else
- fprintf(stderr, "GPUTexture: texture create failed");
+ fprintf(stderr, "GPUTexture: texture create failed\n");
GPU_texture_free(tex);
return NULL;
}
@@ -474,9 +565,9 @@ static GPUTexture *GPU_texture_create_nD(
proxy = GL_PROXY_TEXTURE_3D;
}
- float *rescaled_fpixels = NULL;
- bool valid = gpu_texture_try_alloc(tex, proxy, internalformat, format, data_format, tex->components, can_rescale,
- fpixels, &rescaled_fpixels);
+ float *rescaled_pixels = NULL;
+ bool valid = gpu_texture_try_alloc(tex, proxy, internalformat, data_format, data_type, tex->components, can_rescale,
+ pixels, &rescaled_pixels);
if (!valid) {
if (err_out)
BLI_snprintf(err_out, 256, "GPUTexture: texture alloc failed");
@@ -487,7 +578,7 @@ static GPUTexture *GPU_texture_create_nD(
}
/* Upload Texture */
- const float *pix = (rescaled_fpixels) ? rescaled_fpixels : fpixels;
+ const float *pix = (rescaled_pixels) ? rescaled_pixels : pixels;
if (tex->target == GL_TEXTURE_2D ||
tex->target == GL_TEXTURE_2D_MULTISAMPLE ||
@@ -496,21 +587,21 @@ static GPUTexture *GPU_texture_create_nD(
if (samples) {
glTexImage2DMultisample(tex->target, samples, internalformat, tex->w, tex->h, true);
if (pix)
- glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, format, data_format, pix);
+ glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, data_format, data_type, pix);
}
else {
- glTexImage2D(tex->target, 0, internalformat, tex->w, tex->h, 0, format, data_format, pix);
+ glTexImage2D(tex->target, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, pix);
}
}
else if (tex->target == GL_TEXTURE_1D) {
- glTexImage1D(tex->target, 0, internalformat, tex->w, 0, format, data_format, pix);
+ glTexImage1D(tex->target, 0, internalformat, tex->w, 0, data_format, data_type, pix);
}
else {
- glTexImage3D(tex->target, 0, internalformat, tex->w, tex->h, tex->d, 0, format, data_format, pix);
+ glTexImage3D(tex->target, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, pix);
}
- if (rescaled_fpixels)
- MEM_freeN(rescaled_fpixels);
+ if (rescaled_pixels)
+ MEM_freeN(rescaled_pixels);
/* Texture Parameters */
if (GPU_texture_stencil(tex) || /* Does not support filtering */
@@ -547,11 +638,9 @@ static GPUTexture *GPU_texture_cube_create(
int w, int d,
const float *fpixels_px, const float *fpixels_py, const float *fpixels_pz,
const float *fpixels_nx, const float *fpixels_ny, const float *fpixels_nz,
- GPUTextureFormat data_type,
+ GPUTextureFormat tex_format, GPUDataFormat gpu_data_format,
char err_out[256])
{
- GLenum format, internalformat, data_format;
-
GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
tex->w = w;
tex->h = w;
@@ -559,8 +648,9 @@ static GPUTexture *GPU_texture_cube_create(
tex->samples = 0;
tex->number = -1;
tex->refcount = 1;
- tex->format = data_type;
- tex->components = gpu_texture_get_component_count(data_type);
+ tex->format = tex_format;
+ tex->components = gpu_get_component_count(tex_format);
+ tex->bytesize = gpu_get_bytesize(tex_format);
tex->format_flag = GPU_FORMAT_CUBE;
if (d == 0) {
@@ -571,19 +661,20 @@ static GPUTexture *GPU_texture_cube_create(
// tex->target_base = tex->target = GL_TEXTURE_CUBE_MAP_ARRAY;
}
- internalformat = gpu_texture_get_format(tex->components, data_type, &format, &data_format,
- &tex->format_flag, &tex->bytesize);
+ GLenum internalformat = gpu_get_gl_internalformat(tex_format);
+ GLenum data_format = gpu_get_gl_dataformat(tex_format, &tex->format_flag);
+ GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
gpu_texture_memory_footprint_add(tex);
/* Generate Texture object */
- glGenTextures(1, &tex->bindcode);
+ tex->bindcode = GPU_tex_alloc();
if (!tex->bindcode) {
if (err_out)
- BLI_snprintf(err_out, 256, "GPUTexture: texture create failed");
+ BLI_snprintf(err_out, 256, "GPUTexture: texture create failed\n");
else
- fprintf(stderr, "GPUTexture: texture create failed");
+ fprintf(stderr, "GPUTexture: texture create failed\n");
GPU_texture_free(tex);
return NULL;
}
@@ -591,12 +682,12 @@ static GPUTexture *GPU_texture_cube_create(
glBindTexture(tex->target, tex->bindcode);
/* Upload Texture */
- glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_px);
- glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_py);
- glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_pz);
- glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_nx);
- glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_ny);
- glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_nz);
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_px);
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_py);
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_pz);
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_nx);
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_ny);
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_nz);
/* Texture Parameters */
if (GPU_texture_stencil(tex) || /* Does not support filtering */
@@ -625,47 +716,48 @@ static GPUTexture *GPU_texture_cube_create(
return tex;
}
-/* Special buffer textures. data_type must be compatible with the buffer content. */
-GPUTexture *GPU_texture_create_buffer(GPUTextureFormat data_type, const GLuint buffer)
+/* Special buffer textures. tex_format must be compatible with the buffer content. */
+GPUTexture *GPU_texture_create_buffer(GPUTextureFormat tex_format, const GLuint buffer)
{
GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
tex->number = -1;
tex->refcount = 1;
- tex->format = data_type;
- tex->components = gpu_texture_get_component_count(data_type);
+ tex->format = tex_format;
+ tex->components = gpu_get_component_count(tex_format);
tex->format_flag = 0;
tex->target_base = tex->target = GL_TEXTURE_BUFFER;
-
- GLenum format, internalformat, data_format;
- internalformat = gpu_texture_get_format(tex->components, data_type, &format, &data_format,
- &tex->format_flag, &tex->bytesize);
-
- if (!(ELEM(data_type, GPU_R8, GPU_R16) ||
- ELEM(data_type, GPU_R16F, GPU_R32F) ||
- ELEM(data_type, GPU_R8I, GPU_R16I, GPU_R32I) ||
- ELEM(data_type, GPU_R8UI, GPU_R16UI, GPU_R32UI) ||
- ELEM(data_type, GPU_RG8, GPU_RG16) ||
- ELEM(data_type, GPU_RG16F, GPU_RG32F) ||
- ELEM(data_type, GPU_RG8I, GPU_RG16I, GPU_RG32I) ||
- ELEM(data_type, GPU_RG8UI, GPU_RG16UI, GPU_RG32UI) ||
- //ELEM(data_type, GPU_RGB32F, GPU_RGB32I, GPU_RGB32UI) || /* Not available until gl 4.0 */
- ELEM(data_type, GPU_RGBA8, GPU_RGBA16) ||
- ELEM(data_type, GPU_RGBA16F, GPU_RGBA32F) ||
- ELEM(data_type, GPU_RGBA8I, GPU_RGBA16I, GPU_RGBA32I) ||
- ELEM(data_type, GPU_RGBA8UI, GPU_RGBA16UI, GPU_RGBA32UI)))
+ tex->bytesize = gpu_get_bytesize(tex_format);
+
+ GLenum internalformat = gpu_get_gl_internalformat(tex_format);
+
+ gpu_get_gl_dataformat(tex_format, &tex->format_flag);
+
+ if (!(ELEM(tex_format, GPU_R8, GPU_R16) ||
+ ELEM(tex_format, GPU_R16F, GPU_R32F) ||
+ ELEM(tex_format, GPU_R8I, GPU_R16I, GPU_R32I) ||
+ ELEM(tex_format, GPU_R8UI, GPU_R16UI, GPU_R32UI) ||
+ ELEM(tex_format, GPU_RG8, GPU_RG16) ||
+ ELEM(tex_format, GPU_RG16F, GPU_RG32F) ||
+ ELEM(tex_format, GPU_RG8I, GPU_RG16I, GPU_RG32I) ||
+ ELEM(tex_format, GPU_RG8UI, GPU_RG16UI, GPU_RG32UI) ||
+ //ELEM(tex_format, GPU_RGB32F, GPU_RGB32I, GPU_RGB32UI) || /* Not available until gl 4.0 */
+ ELEM(tex_format, GPU_RGBA8, GPU_RGBA16) ||
+ ELEM(tex_format, GPU_RGBA16F, GPU_RGBA32F) ||
+ ELEM(tex_format, GPU_RGBA8I, GPU_RGBA16I, GPU_RGBA32I) ||
+ ELEM(tex_format, GPU_RGBA8UI, GPU_RGBA16UI, GPU_RGBA32UI)))
{
- fprintf(stderr, "GPUTexture: invalid format for texture buffer");
+ fprintf(stderr, "GPUTexture: invalid format for texture buffer\n");
GPU_texture_free(tex);
return NULL;
}
/* Generate Texture object */
- glGenTextures(1, &tex->bindcode);
+ tex->bindcode = GPU_tex_alloc();
if (!tex->bindcode) {
- fprintf(stderr, "GPUTexture: texture create failed");
+ fprintf(stderr, "GPUTexture: texture create failed\n");
GPU_texture_free(tex);
- BLI_assert(0 && "glGenTextures failled: Are you sure a valid OGL context is active on this thread?");
+ BLI_assert(0 && "glGenTextures failled: Are you sure a valid OGL context is active on this thread?\n");
return NULL;
}
@@ -766,40 +858,45 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
}
GPUTexture *GPU_texture_create_1D(
- int w, GPUTextureFormat data_type, const float *pixels, char err_out[256])
+ int w, GPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
- return GPU_texture_create_nD(w, 0, 0, 1, pixels, data_type, 0, false, err_out);
+ GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
+ return GPU_texture_create_nD(w, 0, 0, 1, pixels, tex_format, data_format, 0, false, err_out);
}
GPUTexture *GPU_texture_create_2D(
- int w, int h, GPUTextureFormat data_type, const float *pixels, char err_out[256])
+ int w, int h, GPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
- return GPU_texture_create_nD(w, h, 0, 2, pixels, data_type, 0, false, err_out);
+ GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
+ return GPU_texture_create_nD(w, h, 0, 2, pixels, tex_format, data_format, 0, false, err_out);
}
GPUTexture *GPU_texture_create_2D_multisample(
- int w, int h, GPUTextureFormat data_type, const float *pixels, int samples, char err_out[256])
+ int w, int h, GPUTextureFormat tex_format, const float *pixels, int samples, char err_out[256])
{
- return GPU_texture_create_nD(w, h, 0, 2, pixels, data_type, samples, false, err_out);
+ GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
+ return GPU_texture_create_nD(w, h, 0, 2, pixels, tex_format, data_format, samples, false, err_out);
}
GPUTexture *GPU_texture_create_2D_array(
- int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256])
+ int w, int h, int d, GPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
- return GPU_texture_create_nD(w, h, d, 2, pixels, data_type, 0, false, err_out);
+ GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
+ return GPU_texture_create_nD(w, h, d, 2, pixels, tex_format, data_format, 0, false, err_out);
}
GPUTexture *GPU_texture_create_3D(
- int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256])
+ int w, int h, int d, GPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
- return GPU_texture_create_nD(w, h, d, 3, pixels, data_type, 0, true, err_out);
+ GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
+ return GPU_texture_create_nD(w, h, d, 3, pixels, tex_format, data_format, 0, true, err_out);
}
GPUTexture *GPU_texture_create_cube(
- int w, GPUTextureFormat data_type, const float *fpixels, char err_out[256])
+ int w, GPUTextureFormat tex_format, const float *fpixels, char err_out[256])
{
const float *fpixels_px, *fpixels_py, *fpixels_pz, *fpixels_nx, *fpixels_ny, *fpixels_nz;
- const int channels = gpu_texture_get_component_count(data_type);
+ const int channels = gpu_get_component_count(tex_format);
if (fpixels) {
fpixels_px = fpixels + 0 * w * w * channels;
@@ -814,40 +911,40 @@ GPUTexture *GPU_texture_create_cube(
}
return GPU_texture_cube_create(w, 0, fpixels_px, fpixels_py, fpixels_pz, fpixels_nx, fpixels_ny, fpixels_nz,
- data_type, err_out);
+ tex_format, GPU_DATA_FLOAT, err_out);
}
-GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert)
+GPUTexture *GPU_texture_create_from_vertbuf(GPUVertBuf *vert)
{
- Gwn_VertFormat *format = &vert->format;
- Gwn_VertAttr *attr = &format->attribs[0];
+ GPUVertFormat *format = &vert->format;
+ GPUVertAttr *attr = &format->attribs[0];
/* Detect incompatible cases (not supported by texture buffers) */
- BLI_assert(format->attrib_ct == 1 && vert->vbo_id != 0);
- BLI_assert(attr->comp_ct != 3); /* Not until OGL 4.0 */
- BLI_assert(attr->comp_type != GWN_COMP_I10);
- BLI_assert(attr->fetch_mode != GWN_FETCH_INT_TO_FLOAT);
+ BLI_assert(format->attr_len == 1 && vert->vbo_id != 0);
+ BLI_assert(attr->comp_len != 3); /* Not until OGL 4.0 */
+ BLI_assert(attr->comp_type != GPU_COMP_I10);
+ BLI_assert(attr->fetch_mode != GPU_FETCH_INT_TO_FLOAT);
- unsigned int byte_per_comp = attr->sz / attr->comp_ct;
- bool is_uint = ELEM(attr->comp_type, GWN_COMP_U8, GWN_COMP_U16, GWN_COMP_U32);
+ unsigned int byte_per_comp = attr->sz / attr->comp_len;
+ bool is_uint = ELEM(attr->comp_type, GPU_COMP_U8, GPU_COMP_U16, GPU_COMP_U32);
/* Cannot fetch signed int or 32bit ints as normalized float. */
- if (attr->fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT) {
+ if (attr->fetch_mode == GPU_FETCH_INT_TO_FLOAT_UNIT) {
BLI_assert(is_uint || byte_per_comp <= 2);
}
GPUTextureFormat data_type;
switch (attr->fetch_mode) {
- case GWN_FETCH_FLOAT:
- switch (attr->comp_ct) {
+ case GPU_FETCH_FLOAT:
+ switch (attr->comp_len) {
case 1: data_type = GPU_R32F; break;
case 2: data_type = GPU_RG32F; break;
// case 3: data_type = GPU_RGB32F; break; /* Not supported */
default: data_type = GPU_RGBA32F; break;
}
break;
- case GWN_FETCH_INT:
- switch (attr->comp_ct) {
+ case GPU_FETCH_INT:
+ switch (attr->comp_len) {
case 1:
switch (byte_per_comp) {
case 1: data_type = (is_uint) ? GPU_R8UI : GPU_R8I; break;
@@ -871,8 +968,8 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert)
break;
}
break;
- case GWN_FETCH_INT_TO_FLOAT_UNIT:
- switch (attr->comp_ct) {
+ case GPU_FETCH_INT_TO_FLOAT_UNIT:
+ switch (attr->comp_len) {
case 1: data_type = (byte_per_comp == 1) ? GPU_R8 : GPU_R16; break;
case 2: data_type = (byte_per_comp == 1) ? GPU_RG8 : GPU_RG16; break;
default: data_type = (byte_per_comp == 1) ? GPU_RGBA8 : GPU_RGBA16; break;
@@ -886,17 +983,56 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert)
return GPU_texture_create_buffer(data_type, vert->vbo_id);
}
+void GPU_texture_add_mipmap(
+ GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl, const void *pixels)
+{
+ BLI_assert((int)tex->format > -1);
+ BLI_assert(tex->components > -1);
+
+ gpu_validate_data_format(tex->format, gpu_data_format);
+
+ GLenum internalformat = gpu_get_gl_internalformat(tex->format);
+ GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag);
+ GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
+
+ glBindTexture(tex->target, tex->bindcode);
+
+ int size[3];
+ GPU_texture_get_mipmap_size(tex, miplvl, size);
+
+ switch (tex->target) {
+ case GL_TEXTURE_1D:
+ glTexImage1D(tex->target, miplvl, internalformat, size[0], 0, data_format, data_type, pixels);
+ break;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_1D_ARRAY:
+ glTexImage2D(tex->target, miplvl, internalformat, size[0], size[1], 0, data_format, data_type, pixels);
+ break;
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_2D_ARRAY:
+ glTexImage3D(tex->target, miplvl, internalformat, size[0], size[1], size[2], 0, data_format, data_type, pixels);
+ break;
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ /* Multisample textures cannot have mipmaps. */
+ default:
+ BLI_assert(!"tex->target mode not supported");
+ }
+
+ glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_MAX_LEVEL, miplvl);
+
+ glBindTexture(tex->target, 0);
+}
+
void GPU_texture_update_sub(
- GPUTexture *tex, const void *pixels,
+ GPUTexture *tex, GPUDataFormat gpu_data_format, const void *pixels,
int offset_x, int offset_y, int offset_z, int width, int height, int depth)
{
BLI_assert((int)tex->format > -1);
BLI_assert(tex->components > -1);
- GLenum format, data_format;
+ GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag);
+ GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
GLint alignment;
- gpu_texture_get_format(tex->components, tex->format, &format, &data_format,
- &tex->format_flag, &tex->bytesize);
/* The default pack size for textures is 4, which won't work for byte based textures */
if (tex->bytesize == 1) {
@@ -906,21 +1042,21 @@ void GPU_texture_update_sub(
glBindTexture(tex->target, tex->bindcode);
switch (tex->target) {
+ case GL_TEXTURE_1D:
+ glTexSubImage1D(tex->target, 0, offset_x, width, data_format, data_type, pixels);
+ break;
case GL_TEXTURE_2D:
case GL_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_1D_ARRAY:
glTexSubImage2D(
tex->target, 0, offset_x, offset_y,
- width, height, format, data_format, pixels);
- break;
- case GL_TEXTURE_1D:
- glTexSubImage1D(tex->target, 0, offset_x, width, format, data_format, pixels);
+ width, height, data_format, data_type, pixels);
break;
case GL_TEXTURE_3D:
case GL_TEXTURE_2D_ARRAY:
glTexSubImage3D(
tex->target, 0, offset_x, offset_y, offset_z,
- width, height, depth, format, data_format, pixels);
+ width, height, depth, data_format, data_type, pixels);
break;
default:
BLI_assert(!"tex->target mode not supported");
@@ -933,9 +1069,53 @@ void GPU_texture_update_sub(
glBindTexture(tex->target, 0);
}
-void GPU_texture_update(GPUTexture *tex, const void *pixels)
+void *GPU_texture_read(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl)
+{
+ int size[3] = {0, 0, 0};
+ GPU_texture_get_mipmap_size(tex, miplvl, size);
+
+ gpu_validate_data_format(tex->format, gpu_data_format);
+
+ size_t buf_size = gpu_texture_memory_footprint_compute(tex);
+ size_t samples_count = max_ii(1, tex->samples);
+
+ samples_count *= size[0];
+ samples_count *= max_ii(1, size[1]);
+ samples_count *= max_ii(1, size[2]);
+
+ switch (gpu_data_format) {
+ case GPU_DATA_FLOAT:
+ buf_size = sizeof(float) * samples_count * tex->components;
+ break;
+ case GPU_DATA_INT:
+ case GPU_DATA_UNSIGNED_INT:
+ buf_size = sizeof(int) * samples_count * tex->components;
+ break;
+ case GPU_DATA_UNSIGNED_INT_24_8:
+ case GPU_DATA_10_11_11_REV:
+ buf_size = sizeof(int) * samples_count;
+ break;
+ case GPU_DATA_UNSIGNED_BYTE:
+ break;
+ }
+
+ void *buf = MEM_mallocN(buf_size, "GPU_texture_read");
+
+ GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag);
+ GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
+
+ glBindTexture(tex->target, tex->bindcode);
+
+ glGetTexImage(tex->target, miplvl, data_format, data_type, buf);
+
+ glBindTexture(tex->target, 0);
+
+ return buf;
+}
+
+void GPU_texture_update(GPUTexture *tex, GPUDataFormat data_format, const void *pixels)
{
- GPU_texture_update_sub(tex, pixels, 0, 0, 0, tex->w, tex->h, tex->d);
+ GPU_texture_update_sub(tex, data_format, pixels, 0, 0, 0, tex->w, tex->h, tex->d);
}
void GPU_invalid_tex_init(void)
@@ -984,8 +1164,9 @@ void GPU_texture_bind(GPUTexture *tex, int number)
if ((G.debug & G_DEBUG)) {
for (int i = 0; i < GPU_TEX_MAX_FBO_ATTACHED; ++i) {
if (tex->fb[i] && GPU_framebuffer_bound(tex->fb[i])) {
- fprintf(stderr, "Feedback loop warning!: Attempting to bind "
- "texture attached to current framebuffer!\n");
+ fprintf(stderr,
+ "Feedback loop warning!: Attempting to bind "
+ "texture attached to current framebuffer!\n");
BLI_assert(0); /* Should never happen! */
break;
}
@@ -1120,17 +1301,6 @@ void GPU_texture_filters(GPUTexture *tex, GPUFilterFunction min_filter, GPUFilte
glTexParameteri(tex->target_base, GL_TEXTURE_MAG_FILTER, gpu_get_gl_filterfunction(mag_filter));
}
-
-static void gpu_texture_delete(GPUTexture *tex)
-{
- if (tex->bindcode)
- glDeleteTextures(1, &tex->bindcode);
-
- gpu_texture_memory_footprint_remove(tex);
-
- MEM_freeN(tex);
-}
-
void GPU_texture_free(GPUTexture *tex)
{
tex->refcount--;
@@ -1145,38 +1315,13 @@ void GPU_texture_free(GPUTexture *tex)
}
}
- /* TODO(fclem): Check if the thread has an ogl context. */
- if (BLI_thread_is_main()) {
- gpu_texture_delete(tex);
- }
- else {
- BLI_mutex_lock(&g_orphan_lock);
- BLI_addtail(&g_orphaned_tex, BLI_genericNodeN(tex));
- BLI_mutex_unlock(&g_orphan_lock);
- }
- }
-}
+ if (tex->bindcode)
+ GPU_tex_free(tex->bindcode);
-void GPU_texture_orphans_init(void)
-{
- BLI_mutex_init(&g_orphan_lock);
-}
+ gpu_texture_memory_footprint_remove(tex);
-void GPU_texture_orphans_delete(void)
-{
- BLI_mutex_lock(&g_orphan_lock);
- LinkData *link;
- while ((link = BLI_pophead(&g_orphaned_tex))) {
- gpu_texture_delete((GPUTexture *)link->data);
- MEM_freeN(link);
+ MEM_freeN(tex);
}
- BLI_mutex_unlock(&g_orphan_lock);
-}
-
-void GPU_texture_orphans_exit(void)
-{
- GPU_texture_orphans_delete();
- BLI_mutex_end(&g_orphan_lock);
}
void GPU_texture_ref(GPUTexture *tex)
@@ -1199,6 +1344,11 @@ int GPU_texture_height(const GPUTexture *tex)
return tex->h;
}
+int GPU_texture_layers(const GPUTexture *tex)
+{
+ return tex->d;
+}
+
GPUTextureFormat GPU_texture_format(const GPUTexture *tex)
{
return tex->format;
@@ -1260,3 +1410,24 @@ int GPU_texture_detach_framebuffer(GPUTexture *tex, GPUFrameBuffer *fb)
BLI_assert(!"Error: Texture: Framebuffer is not attached");
return 0;
}
+
+void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *size)
+{
+ /* TODO assert if lvl is bellow the limit of 1px in each dimension. */
+ int div = 1 << lvl;
+ size[0] = max_ii(1, tex->w / div);
+
+ if (tex->target == GL_TEXTURE_1D_ARRAY) {
+ size[1] = tex->h;
+ }
+ else if (tex->h > 0) {
+ size[1] = max_ii(1, tex->h / div);
+ }
+
+ if (tex->target == GL_TEXTURE_2D_ARRAY) {
+ size[2] = tex->d;
+ }
+ else if (tex->d > 0) {
+ size[2] = max_ii(1, tex->d / div);
+ }
+}
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index 1e39b2ea5b7..9b8441efd08 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -35,6 +35,7 @@
#include "BLI_blenlib.h"
#include "gpu_codegen.h"
+#include "gpu_context_private.h"
#include "GPU_extensions.h"
#include "GPU_glew.h"
@@ -88,7 +89,7 @@ GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_
ubo->bindpoint = -1;
/* Generate Buffer object */
- glGenBuffers(1, &ubo->bindcode);
+ ubo->bindcode = GPU_buf_alloc();
if (!ubo->bindcode) {
if (err_out)
@@ -127,7 +128,7 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou
ubo->flag = GPU_UBO_FLAG_DIRTY;
/* Generate Buffer object. */
- glGenBuffers(1, &ubo->buffer.bindcode);
+ ubo->buffer.bindcode = GPU_buf_alloc();
if (!ubo->buffer.bindcode) {
if (err_out)
@@ -190,7 +191,7 @@ void GPU_uniformbuffer_free(GPUUniformBuffer *ubo)
gpu_uniformbuffer_dynamic_free(ubo);
}
- glDeleteBuffers(1, &ubo->bindcode);
+ GPU_buf_free(ubo->bindcode);
MEM_freeN(ubo);
}
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c
new file mode 100644
index 00000000000..d605378bf0e
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.c
@@ -0,0 +1,270 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, Clément Foucault
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_vertex_buffer.c
+ * \ingroup gpu
+ *
+ * GPU vertex buffer
+ */
+
+#include "GPU_vertex_buffer.h"
+
+#include "gpu_context_private.h"
+#include "gpu_vertex_format_private.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#define KEEP_SINGLE_COPY 1
+
+static uint vbo_memory_usage;
+
+static GLenum convert_usage_type_to_gl(GPUUsageType type)
+{
+ static const GLenum table[] = {
+ [GPU_USAGE_STREAM] = GL_STREAM_DRAW,
+ [GPU_USAGE_STATIC] = GL_STATIC_DRAW,
+ [GPU_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW
+ };
+ return table[type];
+}
+
+GPUVertBuf *GPU_vertbuf_create(GPUUsageType usage)
+{
+ GPUVertBuf *verts = malloc(sizeof(GPUVertBuf));
+ GPU_vertbuf_init(verts, usage);
+ return verts;
+}
+
+GPUVertBuf *GPU_vertbuf_create_with_format_ex(const GPUVertFormat *format, GPUUsageType usage)
+{
+ GPUVertBuf *verts = GPU_vertbuf_create(usage);
+ GPU_vertformat_copy(&verts->format, format);
+ if (!format->packed) {
+ VertexFormat_pack(&verts->format);
+ }
+ return verts;
+
+ /* this function might seem redundant, but there is potential for memory savings here... */
+ /* TODO: implement those memory savings */
+}
+
+void GPU_vertbuf_init(GPUVertBuf *verts, GPUUsageType usage)
+{
+ memset(verts, 0, sizeof(GPUVertBuf));
+ verts->usage = usage;
+ verts->dirty = true;
+}
+
+void GPU_vertbuf_init_with_format_ex(GPUVertBuf *verts, const GPUVertFormat *format, GPUUsageType usage)
+{
+ GPU_vertbuf_init(verts, usage);
+ GPU_vertformat_copy(&verts->format, format);
+ if (!format->packed) {
+ VertexFormat_pack(&verts->format);
+ }
+}
+
+void GPU_vertbuf_discard(GPUVertBuf *verts)
+{
+ if (verts->vbo_id) {
+ GPU_buf_free(verts->vbo_id);
+#if VRAM_USAGE
+ vbo_memory_usage -= GPU_vertbuf_size_get(verts);
+#endif
+ }
+ if (verts->data) {
+ free(verts->data);
+ }
+ free(verts);
+}
+
+uint GPU_vertbuf_size_get(const GPUVertBuf *verts)
+{
+ return vertex_buffer_size(&verts->format, verts->vertex_len);
+}
+
+/* create a new allocation, discarding any existing data */
+void GPU_vertbuf_data_alloc(GPUVertBuf *verts, uint v_len)
+{
+ GPUVertFormat *format = &verts->format;
+ if (!format->packed) {
+ VertexFormat_pack(format);
+ }
+#if TRUST_NO_ONE
+ /* catch any unnecessary use */
+ assert(verts->vertex_alloc != v_len || verts->data == NULL);
+#endif
+ /* only create the buffer the 1st time */
+ if (verts->vbo_id == 0) {
+ verts->vbo_id = GPU_buf_alloc();
+ }
+ /* discard previous data if any */
+ if (verts->data) {
+ free(verts->data);
+ }
+#if VRAM_USAGE
+ uint new_size = vertex_buffer_size(&verts->format, v_len);
+ vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts);
+#endif
+ verts->dirty = true;
+ verts->vertex_len = verts->vertex_alloc = v_len;
+ verts->data = malloc(sizeof(GLubyte) * GPU_vertbuf_size_get(verts));
+}
+
+/* resize buffer keeping existing data */
+void GPU_vertbuf_data_resize(GPUVertBuf *verts, uint v_len)
+{
+#if TRUST_NO_ONE
+ assert(verts->data != NULL);
+ assert(verts->vertex_alloc != v_len);
+#endif
+
+#if VRAM_USAGE
+ uint new_size = vertex_buffer_size(&verts->format, v_len);
+ vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts);
+#endif
+ verts->dirty = true;
+ verts->vertex_len = verts->vertex_alloc = v_len;
+ verts->data = realloc(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts));
+}
+
+/* Set vertex count but does not change allocation.
+ * Only this many verts will be uploaded to the GPU and rendered.
+ * This is usefull for streaming data. */
+void GPU_vertbuf_vertex_count_set(GPUVertBuf *verts, uint v_len)
+{
+#if TRUST_NO_ONE
+ assert(verts->data != NULL); /* only for dynamic data */
+ assert(v_len <= verts->vertex_alloc);
+#endif
+
+#if VRAM_USAGE
+ uint new_size = vertex_buffer_size(&verts->format, v_len);
+ vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts);
+#endif
+ verts->vertex_len = v_len;
+}
+
+void GPU_vertbuf_attr_set(GPUVertBuf *verts, uint a_idx, uint v_idx, const void *data)
+{
+ const GPUVertFormat *format = &verts->format;
+ const GPUVertAttr *a = format->attribs + a_idx;
+
+#if TRUST_NO_ONE
+ assert(a_idx < format->attr_len);
+ assert(v_idx < verts->vertex_alloc);
+ assert(verts->data != NULL);
+#endif
+ verts->dirty = true;
+ memcpy((GLubyte *)verts->data + a->offset + v_idx * format->stride, data, a->sz);
+}
+
+void GPU_vertbuf_attr_fill(GPUVertBuf *verts, uint a_idx, const void *data)
+{
+ const GPUVertFormat *format = &verts->format;
+ const GPUVertAttr *a = format->attribs + a_idx;
+
+#if TRUST_NO_ONE
+ assert(a_idx < format->attr_len);
+#endif
+ const uint stride = a->sz; /* tightly packed input data */
+
+ GPU_vertbuf_attr_fill_stride(verts, a_idx, stride, data);
+}
+
+void GPU_vertbuf_attr_fill_stride(GPUVertBuf *verts, uint a_idx, uint stride, const void *data)
+{
+ const GPUVertFormat *format = &verts->format;
+ const GPUVertAttr *a = format->attribs + a_idx;
+
+#if TRUST_NO_ONE
+ assert(a_idx < format->attr_len);
+ assert(verts->data != NULL);
+#endif
+ verts->dirty = true;
+ const uint vertex_len = verts->vertex_len;
+
+ if (format->attr_len == 1 && stride == format->stride) {
+ /* we can copy it all at once */
+ memcpy(verts->data, data, vertex_len * a->sz);
+ }
+ else {
+ /* we must copy it per vertex */
+ for (uint v = 0; v < vertex_len; ++v) {
+ memcpy((GLubyte *)verts->data + a->offset + v * format->stride, (const GLubyte *)data + v * stride, a->sz);
+ }
+ }
+}
+
+void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *verts, uint a_idx, GPUVertBufRaw *access)
+{
+ const GPUVertFormat *format = &verts->format;
+ const GPUVertAttr *a = format->attribs + a_idx;
+
+#if TRUST_NO_ONE
+ assert(a_idx < format->attr_len);
+ assert(verts->data != NULL);
+#endif
+
+ verts->dirty = true;
+
+ access->size = a->sz;
+ access->stride = format->stride;
+ access->data = (GLubyte *)verts->data + a->offset;
+ access->data_init = access->data;
+#if TRUST_NO_ONE
+ access->_data_end = access->data_init + (size_t)(verts->vertex_alloc * format->stride);
+#endif
+}
+
+static void VertBuffer_upload_data(GPUVertBuf *verts)
+{
+ uint buffer_sz = GPU_vertbuf_size_get(verts);
+
+ /* orphan the vbo to avoid sync */
+ glBufferData(GL_ARRAY_BUFFER, buffer_sz, NULL, convert_usage_type_to_gl(verts->usage));
+ /* upload data */
+ glBufferSubData(GL_ARRAY_BUFFER, 0, buffer_sz, verts->data);
+
+ if (verts->usage == GPU_USAGE_STATIC) {
+ free(verts->data);
+ verts->data = NULL;
+ }
+ verts->dirty = false;
+}
+
+void GPU_vertbuf_use(GPUVertBuf *verts)
+{
+ glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id);
+ if (verts->dirty) {
+ VertBuffer_upload_data(verts);
+ }
+}
+
+uint GPU_vertbuf_get_memory_usage(void)
+{
+ return vbo_memory_usage;
+}
diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c
new file mode 100644
index 00000000000..eef4945d9ef
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_vertex_format.c
@@ -0,0 +1,312 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, Clément Foucault
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_vertex_format.c
+ * \ingroup gpu
+ *
+ * GPU vertex format
+ */
+
+#include "GPU_vertex_format.h"
+#include "gpu_vertex_format_private.h"
+#include <stddef.h>
+#include <string.h>
+
+#define PACK_DEBUG 0
+
+#if PACK_DEBUG
+# include <stdio.h>
+#endif
+
+void GPU_vertformat_clear(GPUVertFormat *format)
+{
+#if TRUST_NO_ONE
+ memset(format, 0, sizeof(GPUVertFormat));
+#else
+ format->attr_len = 0;
+ format->packed = false;
+ format->name_offset = 0;
+ format->name_len = 0;
+
+ for (unsigned i = 0; i < GPU_VERT_ATTR_MAX_LEN; i++) {
+ format->attribs[i].name_len = 0;
+ }
+#endif
+}
+
+void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src)
+{
+ /* copy regular struct fields */
+ memcpy(dest, src, sizeof(GPUVertFormat));
+
+ for (unsigned i = 0; i < dest->attr_len; i++) {
+ for (unsigned j = 0; j < dest->attribs[i].name_len; j++) {
+ dest->attribs[i].name[j] = (char *)dest + (src->attribs[i].name[j] - ((char *)src));
+ }
+ }
+}
+
+static GLenum convert_comp_type_to_gl(GPUVertCompType type)
+{
+ static const GLenum table[] = {
+ [GPU_COMP_I8] = GL_BYTE,
+ [GPU_COMP_U8] = GL_UNSIGNED_BYTE,
+ [GPU_COMP_I16] = GL_SHORT,
+ [GPU_COMP_U16] = GL_UNSIGNED_SHORT,
+ [GPU_COMP_I32] = GL_INT,
+ [GPU_COMP_U32] = GL_UNSIGNED_INT,
+
+ [GPU_COMP_F32] = GL_FLOAT,
+
+ [GPU_COMP_I10] = GL_INT_2_10_10_10_REV
+ };
+ return table[type];
+}
+
+static unsigned comp_sz(GPUVertCompType type)
+{
+#if TRUST_NO_ONE
+ assert(type <= GPU_COMP_F32); /* other types have irregular sizes (not bytes) */
+#endif
+ const GLubyte sizes[] = {1, 1, 2, 2, 4, 4, 4};
+ return sizes[type];
+}
+
+static unsigned attrib_sz(const GPUVertAttr *a)
+{
+ if (a->comp_type == GPU_COMP_I10) {
+ return 4; /* always packed as 10_10_10_2 */
+ }
+ return a->comp_len * comp_sz(a->comp_type);
+}
+
+static unsigned attrib_align(const GPUVertAttr *a)
+{
+ if (a->comp_type == GPU_COMP_I10) {
+ return 4; /* always packed as 10_10_10_2 */
+ }
+ unsigned c = comp_sz(a->comp_type);
+ if (a->comp_len == 3 && c <= 2) {
+ return 4 * c; /* AMD HW can't fetch these well, so pad it out (other vendors too?) */
+ }
+ else {
+ return c; /* most fetches are ok if components are naturally aligned */
+ }
+}
+
+unsigned vertex_buffer_size(const GPUVertFormat *format, unsigned vertex_len)
+{
+#if TRUST_NO_ONE
+ assert(format->packed && format->stride > 0);
+#endif
+ return format->stride * vertex_len;
+}
+
+static const char *copy_attrib_name(GPUVertFormat *format, const char *name)
+{
+ /* strncpy does 110% of what we need; let's do exactly 100% */
+ char *name_copy = format->names + format->name_offset;
+ unsigned available = GPU_VERT_ATTR_NAMES_BUF_LEN - format->name_offset;
+ bool terminated = false;
+
+ for (unsigned i = 0; i < available; ++i) {
+ const char c = name[i];
+ name_copy[i] = c;
+ if (c == '\0') {
+ terminated = true;
+ format->name_offset += (i + 1);
+ break;
+ }
+ }
+#if TRUST_NO_ONE
+ assert(terminated);
+ assert(format->name_offset <= GPU_VERT_ATTR_NAMES_BUF_LEN);
+#else
+ (void)terminated;
+#endif
+ return name_copy;
+}
+
+unsigned GPU_vertformat_attr_add(
+ GPUVertFormat *format, const char *name,
+ GPUVertCompType comp_type, unsigned comp_len, GPUVertFetchMode fetch_mode)
+{
+#if TRUST_NO_ONE
+ assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */
+ assert(format->attr_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */
+ assert(!format->packed); /* packed means frozen/locked */
+ assert((comp_len >= 1 && comp_len <= 4) || comp_len == 8 || comp_len == 12 || comp_len == 16);
+
+ switch (comp_type) {
+ case GPU_COMP_F32:
+ /* float type can only kept as float */
+ assert(fetch_mode == GPU_FETCH_FLOAT);
+ break;
+ case GPU_COMP_I10:
+ /* 10_10_10 format intended for normals (xyz) or colors (rgb)
+ * extra component packed.w can be manually set to { -2, -1, 0, 1 } */
+ assert(comp_len == 3 || comp_len == 4);
+ assert(fetch_mode == GPU_FETCH_INT_TO_FLOAT_UNIT); /* not strictly required, may relax later */
+ break;
+ default:
+ /* integer types can be kept as int or converted/normalized to float */
+ assert(fetch_mode != GPU_FETCH_FLOAT);
+ /* only support float matrices (see Batch_update_program_bindings) */
+ assert(comp_len != 8 && comp_len != 12 && comp_len != 16);
+ }
+#endif
+ format->name_len++; /* multiname support */
+
+ const unsigned attrib_id = format->attr_len++;
+ GPUVertAttr *attrib = format->attribs + attrib_id;
+
+ attrib->name[attrib->name_len++] = copy_attrib_name(format, name);
+ attrib->comp_type = comp_type;
+ attrib->gl_comp_type = convert_comp_type_to_gl(comp_type);
+ attrib->comp_len = (comp_type == GPU_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */
+ attrib->sz = attrib_sz(attrib);
+ attrib->offset = 0; /* offsets & stride are calculated later (during pack) */
+ attrib->fetch_mode = fetch_mode;
+
+ return attrib_id;
+}
+
+void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias)
+{
+ GPUVertAttr *attrib = format->attribs + (format->attr_len - 1);
+#if TRUST_NO_ONE
+ assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */
+ assert(attrib->name_len < GPU_VERT_ATTR_MAX_NAMES);
+#endif
+ format->name_len++; /* multiname support */
+ attrib->name[attrib->name_len++] = copy_attrib_name(format, alias);
+}
+
+unsigned padding(unsigned offset, unsigned alignment)
+{
+ const unsigned mod = offset % alignment;
+ return (mod == 0) ? 0 : (alignment - mod);
+}
+
+#if PACK_DEBUG
+static void show_pack(unsigned a_idx, unsigned sz, unsigned pad)
+{
+ const char c = 'A' + a_idx;
+ for (unsigned i = 0; i < pad; ++i) {
+ putchar('-');
+ }
+ for (unsigned i = 0; i < sz; ++i) {
+ putchar(c);
+ }
+}
+#endif
+
+void VertexFormat_pack(GPUVertFormat *format)
+{
+ /* For now, attributes are packed in the order they were added,
+ * making sure each attrib is naturally aligned (add padding where necessary)
+ * Later we can implement more efficient packing w/ reordering
+ * (keep attrib ID order, adjust their offsets to reorder in buffer). */
+
+ /* TODO: realloc just enough to hold the final combo string. And just enough to
+ * hold used attribs, not all 16. */
+
+ GPUVertAttr *a0 = format->attribs + 0;
+ a0->offset = 0;
+ unsigned offset = a0->sz;
+
+#if PACK_DEBUG
+ show_pack(0, a0->sz, 0);
+#endif
+
+ for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) {
+ GPUVertAttr *a = format->attribs + a_idx;
+ unsigned mid_padding = padding(offset, attrib_align(a));
+ offset += mid_padding;
+ a->offset = offset;
+ offset += a->sz;
+
+#if PACK_DEBUG
+ show_pack(a_idx, a->sz, mid_padding);
+#endif
+ }
+
+ unsigned end_padding = padding(offset, attrib_align(a0));
+
+#if PACK_DEBUG
+ show_pack(0, 0, end_padding);
+ putchar('\n');
+#endif
+ format->stride = offset + end_padding;
+ format->packed = true;
+}
+
+
+/* OpenGL ES packs in a different order as desktop GL but component conversion is the same.
+ * Of the code here, only struct GPUPackedNormal needs to change. */
+
+#define SIGNED_INT_10_MAX 511
+#define SIGNED_INT_10_MIN -512
+
+static int clampi(int x, int min_allowed, int max_allowed)
+{
+#if TRUST_NO_ONE
+ assert(min_allowed <= max_allowed);
+#endif
+ if (x < min_allowed) {
+ return min_allowed;
+ }
+ else if (x > max_allowed) {
+ return max_allowed;
+ }
+ else {
+ return x;
+ }
+}
+
+static int quantize(float x)
+{
+ int qx = x * 511.0f;
+ return clampi(qx, SIGNED_INT_10_MIN, SIGNED_INT_10_MAX);
+}
+
+static int convert_i16(short x)
+{
+ /* 16-bit signed --> 10-bit signed */
+ /* TODO: round? */
+ return x >> 6;
+}
+
+GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3])
+{
+ GPUPackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) };
+ return n;
+}
+
+GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3])
+{
+ GPUPackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) };
+ return n;
+}
diff --git a/source/blender/gpu/intern/gpu_vertex_format_private.h b/source/blender/gpu/intern/gpu_vertex_format_private.h
new file mode 100644
index 00000000000..e4fe61e8697
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_vertex_format_private.h
@@ -0,0 +1,39 @@
+/*
+ * ***** 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) 2016 by Mike Erwin.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/intern/gpu_vertex_format_private.h
+ * \ingroup gpu
+ *
+ * GPU vertex format
+ */
+
+#ifndef __GPU_VERTEX_FORMAT_PRIVATE_H__
+#define __GPU_VERTEX_FORMAT_PRIVATE_H__
+
+void VertexFormat_pack(GPUVertFormat *format);
+uint padding(uint offset, uint alignment);
+uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len);
+
+#endif /* __GPU_VERTEX_FORMAT_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 0bf215f31a8..5d495779ba1 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -539,9 +539,9 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect)
glUniform1i(GPU_shader_get_uniform(shader, "image"), 0);
glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), halfx, halfy, 1.0f + halfx, 1.0f + halfy);
glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x1, y1, x2, y2);
- glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), 1.0f, 1.0f, 1.0f, 1.0f);
+ glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), 1.0f, 1.0f, 1.0f, 1.0f);
- GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4);
+ GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4);
GPU_texture_unbind(color);
}
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 3affacf5203..961837f6b16 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -170,6 +170,23 @@ void color_to_blender_normal_new_shading(vec3 color, out vec3 normal)
/*********** SHADER NODES ***************/
+void particle_info(
+ vec4 sprops, vec4 loc, vec3 vel, vec3 avel,
+ out float index, out float random, out float age,
+ out float life_time, out vec3 location,
+ out float size, out vec3 velocity, out vec3 angular_velocity)
+{
+ index = sprops.x;
+ random = loc.w;
+ age = sprops.y;
+ life_time = sprops.z;
+ size = sprops.w;
+
+ location = loc.xyz;
+ velocity = vel;
+ angular_velocity = avel;
+}
+
void vect_normalize(vec3 vin, out vec3 vout)
{
vout = normalize(vin);
@@ -372,6 +389,29 @@ void math_atan2(float val1, float val2, out float outval)
outval = atan(val1, val2);
}
+void math_floor(float val, out float outval)
+{
+ outval = floor(val);
+}
+
+void math_ceil(float val, out float outval)
+{
+ outval = ceil(val);
+}
+
+void math_fract(float val, out float outval)
+{
+ outval = val - floor(val);
+}
+
+void math_sqrt(float val, out float outval)
+{
+ if (val > 0.0)
+ outval = sqrt(val);
+ else
+ outval = 0.0;
+}
+
void squeeze(float val, float width, float center, out float outval)
{
outval = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width)));
@@ -1758,24 +1798,192 @@ void node_tex_environment_empty(vec3 co, out vec4 color)
color = vec4(1.0, 0.0, 1.0, 1.0);
}
-void node_tex_image(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+void node_tex_image_linear(vec3 co, sampler2D ima, out vec4 color, out float alpha)
{
color = texture(ima, co.xy);
alpha = color.a;
}
+void node_tex_image_nearest(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+{
+ ivec2 pix = ivec2(co.xy * textureSize(ima, 0).xy);
+ color = texelFetch(ima, pix, 0);
+ alpha = color.a;
+}
+
+void node_tex_image_cubic(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+{
+ vec2 tex_size = vec2(textureSize(ima, 0).xy);
+
+ co.xy *= tex_size;
+ /* texel center */
+ vec2 tc = floor(co.xy - 0.5) + 0.5;
+ vec2 f = co.xy - tc;
+ vec2 f2 = f * f;
+ vec2 f3 = f2 * f;
+ /* Bspline coefs (optimized) */
+ vec2 w3 = f3 / 6.0;
+ vec2 w0 = -w3 + f2 * 0.5 - f * 0.5 + 1.0 / 6.0;
+ vec2 w1 = f3 * 0.5 - f2 * 1.0 + 2.0 / 3.0;
+ vec2 w2 = 1.0 - w0 - w1 - w3;
+
+#if 1 /* Optimized version using 4 filtered tap. */
+ vec2 s0 = w0 + w1;
+ vec2 s1 = w2 + w3;
+
+ vec2 f0 = w1 / (w0 + w1);
+ vec2 f1 = w3 / (w2 + w3);
+
+ vec4 final_co;
+ final_co.xy = tc - 1.0 + f0;
+ final_co.zw = tc + 1.0 + f1;
+
+ final_co /= tex_size.xyxy;
+
+ color = texture(ima, final_co.xy) * s0.x * s0.y;
+ color += texture(ima, final_co.zy) * s1.x * s0.y;
+ color += texture(ima, final_co.xw) * s0.x * s1.y;
+ color += texture(ima, final_co.zw) * s1.x * s1.y;
+
+#else /* Reference bruteforce 16 tap. */
+ color = texelFetch(ima, ivec2(tc + vec2(-1.0, -1.0)), 0) * w0.x * w0.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 0.0, -1.0)), 0) * w1.x * w0.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 1.0, -1.0)), 0) * w2.x * w0.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 2.0, -1.0)), 0) * w3.x * w0.y;
+
+ color += texelFetch(ima, ivec2(tc + vec2(-1.0, 0.0)), 0) * w0.x * w1.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 0.0, 0.0)), 0) * w1.x * w1.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 1.0, 0.0)), 0) * w2.x * w1.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 2.0, 0.0)), 0) * w3.x * w1.y;
+
+ color += texelFetch(ima, ivec2(tc + vec2(-1.0, 1.0)), 0) * w0.x * w2.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 0.0, 1.0)), 0) * w1.x * w2.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 1.0, 1.0)), 0) * w2.x * w2.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 2.0, 1.0)), 0) * w3.x * w2.y;
+
+ color += texelFetch(ima, ivec2(tc + vec2(-1.0, 2.0)), 0) * w0.x * w3.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 0.0, 2.0)), 0) * w1.x * w3.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 1.0, 2.0)), 0) * w2.x * w3.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 2.0, 2.0)), 0) * w3.x * w3.y;
+#endif
+
+ alpha = color.a;
+}
+
+void node_tex_image_smart(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+{
+ /* use cubic for now */
+ node_tex_image_cubic(co, ima, color, alpha);
+}
+
+void tex_box_sample_linear(vec3 texco,
+ vec3 N,
+ sampler2D ima,
+ out vec4 color1,
+ out vec4 color2,
+ out vec4 color3)
+{
+ /* X projection */
+ vec2 uv = texco.yz;
+ if (N.x < 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ color1 = texture(ima, uv);
+ /* Y projection */
+ uv = texco.xz;
+ if (N.y > 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ color2 = texture(ima, uv);
+ /* Z projection */
+ uv = texco.yx;
+ if (N.z > 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ color3 = texture(ima, uv);
+}
+
+void tex_box_sample_nearest(vec3 texco,
+ vec3 N,
+ sampler2D ima,
+ out vec4 color1,
+ out vec4 color2,
+ out vec4 color3)
+{
+ /* X projection */
+ vec2 uv = texco.yz;
+ if (N.x < 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ ivec2 pix = ivec2(uv.xy * textureSize(ima, 0).xy);
+ color1 = texelFetch(ima, pix, 0);
+ /* Y projection */
+ uv = texco.xz;
+ if (N.y > 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ pix = ivec2(uv.xy * textureSize(ima, 0).xy);
+ color2 = texelFetch(ima, pix, 0);
+ /* Z projection */
+ uv = texco.yx;
+ if (N.z > 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ pix = ivec2(uv.xy * textureSize(ima, 0).xy);
+ color3 = texelFetch(ima, pix, 0);
+}
+
+void tex_box_sample_cubic(vec3 texco,
+ vec3 N,
+ sampler2D ima,
+ out vec4 color1,
+ out vec4 color2,
+ out vec4 color3)
+{
+ float alpha;
+ /* X projection */
+ vec2 uv = texco.yz;
+ if (N.x < 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ node_tex_image_cubic(uv.xyy, ima, color1, alpha);
+ /* Y projection */
+ uv = texco.xz;
+ if (N.y > 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ node_tex_image_cubic(uv.xyy, ima, color2, alpha);
+ /* Z projection */
+ uv = texco.yx;
+ if (N.z > 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ node_tex_image_cubic(uv.xyy, ima, color3, alpha);
+}
+
+void tex_box_sample_smart(vec3 texco,
+ vec3 N,
+ sampler2D ima,
+ out vec4 color1,
+ out vec4 color2,
+ out vec4 color3)
+{
+ tex_box_sample_cubic(texco, N, ima, color1, color2, color3);
+}
+
void node_tex_image_box(vec3 texco,
vec3 N,
+ vec4 color1,
+ vec4 color2,
+ vec4 color3,
sampler2D ima,
float blend,
out vec4 color,
out float alpha)
{
- vec3 signed_N = N;
-
/* project from direction vector to barycentric coordinates in triangles */
- N = vec3(abs(N.x), abs(N.y), abs(N.z));
- N /= (N.x + N.y + N.z);
+ N = abs(N);
+ N /= dot(N, vec3(1.0));
/* basic idea is to think of this as a triangle, each corner representing
* one of the 3 faces of the cube. in the corners we have single textures,
@@ -1785,72 +1993,36 @@ void node_tex_image_box(vec3 texco,
* the Nxyz values are the barycentric coordinates in an equilateral
* triangle, which in case of blending, in the middle has a smaller
* equilateral triangle where 3 textures blend. this divides things into
- * 7 zones, with an if () test for each zone */
+ * 7 zones, with an if () test for each zone
+ * EDIT: Now there is only 4 if's. */
- vec3 weight = vec3(0.0, 0.0, 0.0);
- float limit = 0.5 * (1.0 + blend);
+ float limit = 0.5 + 0.5 * blend;
- /* first test for corners with single texture */
- if (N.x > limit * (N.x + N.y) && N.x > limit * (N.x + N.z)) {
- weight.x = 1.0;
+ vec3 weight;
+ weight.x = N.x / (N.x + N.y);
+ weight.y = N.y / (N.y + N.z);
+ weight.z = N.z / (N.x + N.z);
+ weight = clamp((weight - 0.5 * (1.0 - blend)) / max(1e-8, blend), 0.0, 1.0);
+
+ /* test for mixes between two textures */
+ if (N.z < (1.0 - limit) * (N.y + N.x)) {
+ weight.z = 0.0;
+ weight.y = 1.0 - weight.x;
}
- else if (N.y > limit * (N.x + N.y) && N.y > limit * (N.y + N.z)) {
- weight.y = 1.0;
+ else if (N.x < (1.0 - limit) * (N.y + N.z)) {
+ weight.x = 0.0;
+ weight.z = 1.0 - weight.y;
}
- else if (N.z > limit * (N.x + N.z) && N.z > limit * (N.y + N.z)) {
- weight.z = 1.0;
- }
- else if (blend > 0.0) {
- /* in case of blending, test for mixes between two textures */
- if (N.z < (1.0 - limit) * (N.y + N.x)) {
- weight.x = N.x / (N.x + N.y);
- weight.x = clamp((weight.x - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
- weight.y = 1.0 - weight.x;
- }
- else if (N.x < (1.0 - limit) * (N.y + N.z)) {
- weight.y = N.y / (N.y + N.z);
- weight.y = clamp((weight.y - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
- weight.z = 1.0 - weight.y;
- }
- else if (N.y < (1.0 - limit) * (N.x + N.z)) {
- weight.x = N.x / (N.x + N.z);
- weight.x = clamp((weight.x - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
- weight.z = 1.0 - weight.x;
- }
- else {
- /* last case, we have a mix between three */
- weight.x = ((2.0 - limit) * N.x + (limit - 1.0)) / (2.0 * limit - 1.0);
- weight.y = ((2.0 - limit) * N.y + (limit - 1.0)) / (2.0 * limit - 1.0);
- weight.z = ((2.0 - limit) * N.z + (limit - 1.0)) / (2.0 * limit - 1.0);
- }
+ else if (N.y < (1.0 - limit) * (N.x + N.z)) {
+ weight.y = 0.0;
+ weight.x = 1.0 - weight.z;
}
else {
- /* Desperate mode, no valid choice anyway, fallback to one side.*/
- weight.x = 1.0;
- }
- color = vec4(0);
- if (weight.x > 0.0) {
- vec2 uv = texco.yz;
- if(signed_N.x < 0.0) {
- uv.x = 1.0 - uv.x;
- }
- color += weight.x * texture(ima, uv);
- }
- if (weight.y > 0.0) {
- vec2 uv = texco.xz;
- if(signed_N.y > 0.0) {
- uv.x = 1.0 - uv.x;
- }
- color += weight.y * texture(ima, uv);
- }
- if (weight.z > 0.0) {
- vec2 uv = texco.yx;
- if(signed_N.z > 0.0) {
- uv.x = 1.0 - uv.x;
- }
- color += weight.z * texture(ima, uv);
+ /* last case, we have a mix between three */
+ weight = ((2.0 - limit) * N + (limit - 1.0)) / max(1e-8, 2.0 * limit - 1.0);
}
+ color = weight.x * color1 + weight.y * color2 + weight.z * color3;
alpha = color.a;
}
@@ -2250,7 +2422,7 @@ void node_tex_sky(vec3 co, out vec4 color)
color = vec4(1.0);
}
-void node_tex_voronoi(vec3 co, float scale, float coloring, out vec4 color, out float fac)
+void node_tex_voronoi(vec3 co, float scale, float exponent, float coloring, out vec4 color, out float fac)
{
vec3 p = co * scale;
int xx, yy, zz, xi, yi, zi;
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 75f8df99e63..04ce2d6eaa3 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -431,7 +431,6 @@ bool IMB_isfloat(struct ImBuf *ibuf);
* \attention Defined in divers.c
*/
void IMB_de_interlace(struct ImBuf *ibuf);
-void IMB_interlace(struct ImBuf *ibuf);
/* create char buffer, color corrected if necessary, for ImBufs that lack one */
void IMB_rect_from_float(struct ImBuf *ibuf);
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index ee51854d7ed..e83357ac82e 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -242,7 +242,6 @@ typedef struct ImBuf {
#define IB_rect (1 << 0)
#define IB_test (1 << 1)
-#define IB_fields (1 << 2)
#define IB_zbuf (1 << 3)
#define IB_mem (1 << 4)
#define IB_rectfloat (1 << 5)
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 589955d2ab3..58554693aeb 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -521,7 +521,6 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
x = ibuf1->x;
y = ibuf1->y;
- if (ibuf1->flags & IB_fields) y *= 2;
ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags);
if (ibuf2 == NULL) return NULL;
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 290226acf78..9ab2ee7dd21 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -243,21 +243,35 @@ void IMB_close_anim_proxies(struct anim *anim)
struct IDProperty *IMB_anim_load_metadata(struct anim *anim)
{
+ switch (anim->curtype) {
+ case ANIM_FFMPEG:
+ {
#ifdef WITH_FFMPEG
- AVDictionaryEntry *entry = NULL;
+ AVDictionaryEntry *entry = NULL;
- BLI_assert(anim->pFormatCtx != NULL);
- av_log(anim->pFormatCtx, AV_LOG_DEBUG, "METADATA FETCH\n");
+ BLI_assert(anim->pFormatCtx != NULL);
+ av_log(anim->pFormatCtx, AV_LOG_DEBUG, "METADATA FETCH\n");
- while (true) {
- entry = av_dict_get(anim->pFormatCtx->metadata, "", entry, AV_DICT_IGNORE_SUFFIX);
- if (entry == NULL) break;
+ while (true) {
+ entry = av_dict_get(anim->pFormatCtx->metadata, "", entry, AV_DICT_IGNORE_SUFFIX);
+ if (entry == NULL) break;
- /* Delay creation of the property group until there is actual metadata to put in there. */
- IMB_metadata_ensure(&anim->metadata);
- IMB_metadata_set_field(anim->metadata, entry->key, entry->value);
- }
+ /* Delay creation of the property group until there is actual metadata to put in there. */
+ IMB_metadata_ensure(&anim->metadata);
+ IMB_metadata_set_field(anim->metadata, entry->key, entry->value);
+ }
#endif
+ break;
+ }
+ case ANIM_SEQUENCE:
+ case ANIM_AVI:
+ case ANIM_MOVIE:
+ /* TODO */
+ break;
+ case ANIM_NONE:
+ default:
+ break;
+ }
return anim->metadata;
}
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 2b6fa573e63..e6635080163 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -45,62 +45,6 @@
#include "MEM_guardedalloc.h"
-/**************************** Interlace/Deinterlace **************************/
-
-void IMB_de_interlace(ImBuf *ibuf)
-{
- ImBuf *tbuf1, *tbuf2;
-
- if (ibuf == NULL) return;
- if (ibuf->flags & IB_fields) return;
- ibuf->flags |= IB_fields;
-
- if (ibuf->rect) {
- /* make copies */
- tbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect);
- tbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect);
-
- ibuf->x *= 2;
- IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
- IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
-
- ibuf->x /= 2;
- IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y);
- IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y);
-
- IMB_freeImBuf(tbuf1);
- IMB_freeImBuf(tbuf2);
- }
- ibuf->y /= 2;
-}
-
-void IMB_interlace(ImBuf *ibuf)
-{
- ImBuf *tbuf1, *tbuf2;
-
- if (ibuf == NULL) return;
- ibuf->flags &= ~IB_fields;
-
- ibuf->y *= 2;
-
- if (ibuf->rect) {
- /* make copies */
- tbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect);
- tbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect);
-
- IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
- IMB_rectcpy(tbuf2, ibuf, 0, 0, 0, tbuf2->y, ibuf->x, ibuf->y);
-
- ibuf->x *= 2;
- IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y);
- IMB_rectcpy(ibuf, tbuf2, tbuf2->x, 0, 0, 0, tbuf2->x, tbuf2->y);
- ibuf->x /= 2;
-
- IMB_freeImBuf(tbuf1);
- IMB_freeImBuf(tbuf2);
- }
-}
-
/************************* Floyd-Steinberg dithering *************************/
typedef struct DitherContext {
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 0b4490a3beb..0cb1ab4b2c5 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -230,7 +230,6 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S
BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename));
for (a = 1; a < ibuf->miptot; a++)
BLI_strncpy(ibuf->mipmap[a - 1]->cachename, filepath_tx, sizeof(ibuf->cachename));
- if (flags & IB_fields) IMB_de_interlace(ibuf);
}
close(file);
diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.c
index a4418443790..7c58815c216 100644
--- a/source/blender/imbuf/intern/stereoimbuf.c
+++ b/source/blender/imbuf/intern/stereoimbuf.c
@@ -722,7 +722,6 @@ ImBuf *IMB_stereo3d_ImBuf(ImageFormatData *im_format, ImBuf *ibuf_left, ImBuf *i
ibuf_stereo->rect_colorspace = ibuf_left->rect_colorspace;
ibuf_stereo->float_colorspace = ibuf_left->float_colorspace;
- /* copy flags for IB_fields and other settings */
ibuf_stereo->flags = ibuf_left->flags;
imb_stereo3d_data_initialize(
@@ -1233,7 +1232,6 @@ void IMB_ImBufFromStereo3d(
ibuf_left = IMB_allocImBuf(width, height, ibuf_stereo3d->planes, (is_float ? IB_rectfloat : IB_rect));
ibuf_right = IMB_allocImBuf(width, height, ibuf_stereo3d->planes, (is_float ? IB_rectfloat : IB_rect));
- /* copy flags for IB_fields and other settings */
ibuf_left->flags = ibuf_stereo3d->flags;
ibuf_right->flags = ibuf_stereo3d->flags;
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index fa97fd53f32..ec71f28cb23 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -45,6 +45,27 @@ struct ID;
struct PackedFile;
struct GPUTexture;
+/* Runtime display data */
+struct DrawData;
+typedef void (*DrawDataInitCb)(struct DrawData *engine_data);
+typedef void (*DrawDataFreeCb)(struct DrawData *engine_data);
+
+#
+#
+typedef struct DrawData {
+ struct DrawData *next, *prev;
+ struct DrawEngineType *engine_type;
+ /* Only nested data, NOT the engine data itself. */
+ DrawDataFreeCb free;
+ /* Accumulated recalc flags, which corresponds to ID->recalc flags. */
+ int recalc;
+} DrawData;
+
+typedef struct DrawDataList {
+ struct DrawData *first, *last;
+} DrawDataList;
+
+
typedef struct IDPropertyData {
void *pointer;
ListBase group;
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 0546dcb1a6c..55e1a43925d 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -82,9 +82,9 @@ typedef struct bMotionPath {
int flag; /* baking settings - eMotionPath_Flag */
/* Used for drawing. */
- struct Gwn_VertBuf *points_vbo;
- struct Gwn_Batch *batch_line;
- struct Gwn_Batch *batch_points;
+ struct GPUVertBuf *points_vbo;
+ struct GPUBatch *batch_line;
+ struct GPUBatch *batch_points;
void *pad;
} bMotionPath;
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index 26d7f089f8b..a7ec121efda 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -51,7 +51,7 @@ typedef struct ImageUser {
int framenr; /* movies, sequences: current to display */
int frames; /* total amount of frames to use */
int offset, sfra; /* offset within movie, start frame in global time */
- char fie_ima, cycl; /* fields/image in movie, cyclic flag */
+ char _pad, cycl; /* cyclic flag */
char ok;
char multiview_eye; /* multiview current eye - for internal use of drawing routines */
@@ -157,8 +157,8 @@ typedef struct Image {
/* Image.flag */
enum {
- IMA_FIELDS = (1 << 0),
- IMA_STD_FIELD = (1 << 1),
+ // IMA_FIELDS = (1 << 0),
+ // IMA_STD_FIELD = (1 << 1),
#ifdef DNA_DEPRECATED
IMA_DO_PREMUL = (1 << 2), /* deprecated, should not be used */
#endif
diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h
index 86d4645ecf5..490e2574a33 100644
--- a/source/blender/makesdna/DNA_lightprobe_types.h
+++ b/source/blender/makesdna/DNA_lightprobe_types.h
@@ -68,11 +68,9 @@ typedef struct LightProbe {
struct Image *image; /* Image to use on as lighting data */
struct Collection *visibility_grp; /* Object visibility group, inclusive or exclusive */
- float data_draw_size;
-
/* Runtime display data */
float distfalloff, distgridinf;
- float pad;
+ float pad[2];
} LightProbe;
/* Probe->type */
@@ -106,6 +104,79 @@ enum {
LIGHTPROBE_SHAPE_BOX = 1,
};
+/* ------- Eevee LightProbes ------- */
+/* Needs to be there because written to file
+ * with the lightcache. */
+
+typedef struct LightProbeCache {
+ float position[3], parallax_type;
+ float attenuation_fac;
+ float attenuation_type;
+ float pad3[2];
+ float attenuationmat[4][4];
+ float parallaxmat[4][4];
+} LightProbeCache;
+
+typedef struct LightGridCache {
+ float mat[4][4];
+ int resolution[3], offset; /* offset to the first irradiance sample in the pool. */
+ float corner[3], attenuation_scale;
+ float increment_x[3], attenuation_bias; /* world space vector between 2 opposite cells */
+ float increment_y[3], level_bias;
+ float increment_z[3], pad4;
+ float visibility_bias, visibility_bleed, visibility_range, pad5;
+} LightGridCache;
+
+/* ------ Eevee Lightcache ------- */
+
+typedef struct LightCacheTexture {
+ struct GPUTexture *tex;
+ /* Copy of GPU datas to create GPUTextures on file read. */
+ char *data;
+ int tex_size[3];
+ char data_type;
+ char components;
+ char pad[2];
+} LightCacheTexture;
+
+typedef struct LightCache {
+ int flag;
+ /* only a single cache for now */
+ int cube_len, grid_len; /* Number of probes to use for rendering. */
+ int mips_len; /* Number of mipmap level to use. */
+ int vis_res, ref_res; /* Size of a visibility/reflection sample. */
+ int pad[2];
+ /* In the future, we could create a bigger texture containing
+ * multiple caches (for animation) and interpolate between the
+ * caches overtime to another texture. */
+ LightCacheTexture grid_tx;
+ LightCacheTexture cube_tx; /* Contains data for mipmap level 0. */
+ LightCacheTexture *cube_mips; /* Does not contains valid GPUTexture, only data. */
+ /* All lightprobes data contained in the cache. */
+ LightProbeCache *cube_data;
+ LightGridCache *grid_data;
+} LightCache;
+
+/* LightCache->flag */
+enum {
+ LIGHTCACHE_BAKED = (1 << 0),
+ LIGHTCACHE_BAKING = (1 << 1),
+ LIGHTCACHE_CUBE_READY = (1 << 2),
+ LIGHTCACHE_GRID_READY = (1 << 3),
+ /* Update tagging */
+ LIGHTCACHE_UPDATE_CUBE = (1 << 4),
+ LIGHTCACHE_UPDATE_GRID = (1 << 5),
+ LIGHTCACHE_UPDATE_WORLD = (1 << 6),
+ LIGHTCACHE_UPDATE_AUTO = (1 << 7),
+};
+
+/* EEVEE_LightCacheTexture->data_type */
+enum {
+ LIGHTCACHETEX_BYTE = (1 << 0),
+ LIGHTCACHETEX_FLOAT = (1 << 1),
+ LIGHTCACHETEX_UINT = (1 << 2),
+};
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index 247ffa4d865..9e15bd32b3b 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -279,9 +279,6 @@ enum {
/* this is so we can save bmesh files that load in trunk, ignoring NGons
* will eventually be removed */
-#define USE_BMESH_SAVE_AS_COMPAT
-#define USE_BMESH_SAVE_WITHOUT_MFACE
-
/* enable this so meshes get tessfaces calculated by default */
/* #define USE_TESSFACE_DEFAULT */
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 551ba945253..7d79242016f 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -385,7 +385,7 @@ enum {
/* SELECT = (1 << 0), */
ME_VERT_TMP_TAG = (1 << 2),
ME_HIDE = (1 << 4),
- ME_VERT_MERGED = (1 << 6),
+/* ME_VERT_MERGED = (1 << 6), */
ME_VERT_PBVH_UPDATE = (1 << 7),
};
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index fec73c267ce..02e70a323c7 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -120,15 +120,10 @@ typedef struct ModifierData {
typedef enum {
/* This modifier has been inserted in local override, and hence can be fully edited. */
eModifierFlag_StaticOverride_Local = (1 << 0),
+ /* This modifier does not own its caches, but instead shares them with another modifier. */
+ eModifierFlag_SharedCaches = (1 << 1),
} ModifierFlag;
-typedef enum {
- eSubsurfModifierFlag_Incremental = (1 << 0),
- eSubsurfModifierFlag_DebugIncr = (1 << 1),
- eSubsurfModifierFlag_ControlEdges = (1 << 2),
- eSubsurfModifierFlag_SubsurfUv = (1 << 3),
-} SubsurfModifierFlag;
-
/* not a real modifier */
typedef struct MappingInfoModifierData {
ModifierData modifier;
@@ -140,6 +135,18 @@ typedef struct MappingInfoModifierData {
int texmapping;
} MappingInfoModifierData;
+typedef enum {
+ eSubsurfModifierFlag_Incremental = (1 << 0),
+ eSubsurfModifierFlag_DebugIncr = (1 << 1),
+ eSubsurfModifierFlag_ControlEdges = (1 << 2),
+ eSubsurfModifierFlag_SubsurfUv = (1 << 3),
+} SubsurfModifierFlag;
+
+typedef enum {
+ SUBSURF_TYPE_CATMULL_CLARK = 0,
+ SUBSURF_TYPE_SIMPLE = 1,
+} eSubsurfModifierType;
+
typedef struct SubsurfModifierData {
ModifierData modifier;
@@ -631,8 +638,12 @@ typedef struct ClothModifierData {
struct Cloth *clothObject; /* The internal data structure for cloth. */
struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */
struct ClothCollSettings *coll_parms; /* definition is in DNA_cloth_types.h */
+
+ /* PointCache can be shared with other instances of ClothModifierData.
+ * Inspect (modifier.flag & eModifierFlag_SharedCaches) to find out. */
struct PointCache *point_cache; /* definition is in DNA_object_force_types.h */
struct ListBase ptcaches;
+
/* XXX nasty hack, remove once hair can be separated from cloth modifier data */
struct ClothHairData *hairdata;
/* grid geometry values of hair continuum */
@@ -832,7 +843,6 @@ typedef struct FluidsimModifierData {
ModifierData modifier;
struct FluidsimSettings *fss; /* definition is in DNA_object_fluidsim_types.h */
- struct PointCache *point_cache; /* definition is in DNA_object_force_types.h */
} FluidsimModifierData;
typedef struct ShrinkwrapModifierData {
@@ -1015,7 +1025,7 @@ typedef struct OceanModifierData {
char geometry_mode;
char flag;
- char refresh;
+ char pad2;
short repeat_x;
short repeat_y;
@@ -1035,13 +1045,6 @@ enum {
MOD_OCEAN_GEOM_SIM_ONLY = 2,
};
-enum {
- MOD_OCEAN_REFRESH_RESET = (1 << 0),
- MOD_OCEAN_REFRESH_SIM = (1 << 1),
- MOD_OCEAN_REFRESH_ADD = (1 << 2),
- MOD_OCEAN_REFRESH_CLEAR_CACHE = (1 << 3),
- MOD_OCEAN_REFRESH_TOPOLOGY = (1 << 4),
-};
enum {
MOD_OCEAN_GENERATE_FOAM = (1 << 0),
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index f38ae61421b..31a5931dde4 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -776,6 +776,8 @@ typedef struct NodeTexNoise {
typedef struct NodeTexVoronoi {
NodeTexBase base;
int coloring;
+ int distance;
+ int feature;
int pad;
} NodeTexVoronoi;
@@ -903,6 +905,14 @@ typedef struct NodeSunBeams {
float ray_length;
} NodeSunBeams;
+typedef struct NodeCryptomatte {
+ float add[3];
+ float remove[3];
+ char *matte_id;
+ int num_inputs;
+ int pad;
+} NodeCryptomatte;
+
/* script node mode */
#define NODE_SCRIPT_INTERNAL 0
#define NODE_SCRIPT_EXTERNAL 1
@@ -951,6 +961,11 @@ typedef struct NodeSunBeams {
#define SHD_HAIR_REFLECTION 0
#define SHD_HAIR_TRANSMISSION 1
+/* principled hair parametrization */
+#define SHD_PRINCIPLED_HAIR_REFLECTANCE 0
+#define SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION 1
+#define SHD_PRINCIPLED_HAIR_DIRECT_ABSORPTION 2
+
/* blend texture */
#define SHD_BLEND_LINEAR 0
#define SHD_BLEND_QUADRATIC 1
@@ -974,17 +989,20 @@ typedef struct NodeSunBeams {
#define SHD_NOISE_HARD 1
/* voronoi texture */
-#define SHD_VORONOI_DISTANCE_SQUARED 0
-#define SHD_VORONOI_ACTUAL_DISTANCE 1
-#define SHD_VORONOI_MANHATTAN 2
-#define SHD_VORONOI_CHEBYCHEV 3
-#define SHD_VORONOI_MINKOVSKY_H 4
-#define SHD_VORONOI_MINKOVSKY_4 5
-#define SHD_VORONOI_MINKOVSKY 6
+#define SHD_VORONOI_DISTANCE 0
+#define SHD_VORONOI_MANHATTAN 1
+#define SHD_VORONOI_CHEBYCHEV 2
+#define SHD_VORONOI_MINKOWSKI 3
#define SHD_VORONOI_INTENSITY 0
#define SHD_VORONOI_CELLS 1
+#define SHD_VORONOI_F1 0
+#define SHD_VORONOI_F2 1
+#define SHD_VORONOI_F3 2
+#define SHD_VORONOI_F4 3
+#define SHD_VORONOI_F2F1 4
+
/* musgrave texture */
#define SHD_MUSGRAVE_MULTIFRACTAL 0
#define SHD_MUSGRAVE_FBM 1
@@ -1071,6 +1089,10 @@ enum {
NODE_MATH_MOD = 17,
NODE_MATH_ABS = 18,
NODE_MATH_ATAN2 = 19,
+ NODE_MATH_FLOOR = 20,
+ NODE_MATH_CEIL = 21,
+ NODE_MATH_FRACT = 22,
+ NODE_MATH_SQRT = 23,
};
/* mix rgb node flags */
@@ -1101,39 +1123,6 @@ enum {
#define CMP_NODE_MASK_MBLUR_SAMPLES_MAX 64
-/* geometry output socket defines */
-#define GEOM_OUT_GLOB 0
-#define GEOM_OUT_LOCAL 1
-#define GEOM_OUT_VIEW 2
-#define GEOM_OUT_ORCO 3
-#define GEOM_OUT_UV 4
-#define GEOM_OUT_NORMAL 5
-#define GEOM_OUT_VCOL 6
-#define GEOM_OUT_VCOL_ALPHA 7
-#define GEOM_OUT_FRONTBACK 8
-
-/* material input socket defines */
-#define MAT_IN_COLOR 0
-#define MAT_IN_SPEC 1
-#define MAT_IN_REFL 2
-#define MAT_IN_NORMAL 3
-#define MAT_IN_MIR 4
-#define MAT_IN_AMB 5
-#define MAT_IN_EMIT 6
-#define MAT_IN_SPECTRA 7
-#define MAT_IN_RAY_MIRROR 8
-#define MAT_IN_ALPHA 9
-#define MAT_IN_TRANSLUCENCY 10
-#define NUM_MAT_IN 11 /* for array size */
-
-/* material output socket defines */
-#define MAT_OUT_COLOR 0
-#define MAT_OUT_ALPHA 1
-#define MAT_OUT_NORMAL 2
-#define MAT_OUT_DIFFUSE 3
-#define MAT_OUT_SPEC 4
-#define MAT_OUT_AO 5
-
/* image */
#define CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT 1
@@ -1176,4 +1165,12 @@ enum {
SHD_POINTDENSITY_COLOR_VERTNOR = 2,
};
+/* Output shader node */
+
+typedef enum NodeShaderOutputTarget {
+ SHD_OUTPUT_ALL = 0,
+ SHD_OUTPUT_EEVEE = 1,
+ SHD_OUTPUT_CYCLES = 2,
+} NodeShaderOutputTarget;
+
#endif
diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h
index ac7c969a810..3538abcff1a 100644
--- a/source/blender/makesdna/DNA_object_force_types.h
+++ b/source/blender/makesdna/DNA_object_force_types.h
@@ -37,6 +37,7 @@ extern "C" {
#endif
#include "DNA_listBase.h"
+#include "DNA_defs.h"
/* pd->forcefield: Effector Fields types */
typedef enum ePFieldType {
@@ -218,6 +219,15 @@ typedef struct SBVertex {
float vec[4];
} SBVertex;
+/* Container for data that is shared among CoW copies.
+ *
+ * This is placed in a separate struct so that values can be changed
+ * without having to update all CoW copies. */
+typedef struct SoftBody_Shared {
+ struct PointCache *pointcache;
+ struct ListBase ptcaches;
+} SoftBody_Shared;
+
typedef struct SoftBody {
/* dynamic data */
int totpoint, totspring;
@@ -289,8 +299,9 @@ typedef struct SoftBody {
float shearstiff;
float inpush;
- struct PointCache *pointcache;
- struct ListBase ptcaches;
+ struct SoftBody_Shared *shared;
+ struct PointCache *pointcache DNA_DEPRECATED; /* Moved to SoftBody_Shared */
+ struct ListBase ptcaches DNA_DEPRECATED; /* Moved to SoftBody_Shared */
struct Collection *collision_group;
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 3bcc0fb6dcc..999ebe0ccc3 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -76,22 +76,6 @@ typedef struct bFaceMap {
char pad[7];
} bFaceMap;
-/* Object Runtime display data */
-struct ObjectEngineData;
-typedef void (*ObjectEngineDataInitCb)(struct ObjectEngineData *engine_data);
-typedef void (*ObjectEngineDataFreeCb)(struct ObjectEngineData *engine_data);
-
-#
-#
-typedef struct ObjectEngineData {
- struct ObjectEngineData *next, *prev;
- struct DrawEngineType *engine_type;
- /* Only nested data, NOT the engine data itself. */
- ObjectEngineDataFreeCb free;
- /* Accumulated recalc flags, which corresponds to ID->recalc flags. */
- int recalc;
-} ObjectEngineData;
-
#define MAX_VGROUP_NAME 64
/* bDeformGroup->flag */
@@ -163,6 +147,7 @@ typedef struct Object_Runtime {
typedef struct Object {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
+ struct DrawDataList drawdata; /* runtime (must be immediately after id for utilities to use it). */
struct SculptSession *sculpt;
@@ -312,7 +297,6 @@ typedef struct Object {
struct PreviewImage *preview;
- ListBase drawdata; /* runtime, ObjectEngineData */
int pad6;
int select_color;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 0b8f8ee5ed1..e61b3ac9583 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1237,7 +1237,7 @@ typedef struct ToolSettings {
short autoik_chainlen; /* runtime only */
/* SCE_MPR_LOC/SCAL */
- char manipulator_flag;
+ char gizmo_flag;
/* Grease Pencil */
char gpencil_flags; /* flags/options for how the tool works */
@@ -1385,6 +1385,9 @@ typedef struct SceneDisplay {
float matcap_ssao_attenuation;
int matcap_ssao_samples;
int pad;
+
+ /* OpenGL render engine settings. */
+ View3DShading shading;
} SceneDisplay;
typedef struct SceneEEVEE {
@@ -1393,6 +1396,9 @@ typedef struct SceneEEVEE {
int gi_cubemap_resolution;
int gi_visibility_resolution;
+ float gi_cubemap_draw_size;
+ float gi_irradiance_draw_size;
+
int taa_samples;
int taa_render_samples;
int sss_samples;
@@ -1432,6 +1438,9 @@ typedef struct SceneEEVEE {
int shadow_method;
int shadow_cube_size;
int shadow_cascade_size;
+
+ struct LightCache *light_cache;
+ char light_cache_info[64];
} SceneEEVEE;
/* *************************************************************** */
@@ -1705,7 +1714,7 @@ enum {
/* RenderData.engine (scene.c) */
extern const char *RE_engine_id_BLENDER_EEVEE;
-extern const char *RE_engine_id_BLENDER_WORKBENCH;
+extern const char *RE_engine_id_BLENDER_OPENGL;
extern const char *RE_engine_id_CYCLES;
/* **************** SCENE ********************* */
@@ -1959,6 +1968,7 @@ typedef enum eSculptFlags {
/* If set, dynamic-topology detail size will be constant in object space */
SCULPT_DYNTOPO_DETAIL_CONSTANT = (1 << 13),
SCULPT_DYNTOPO_DETAIL_BRUSH = (1 << 14),
+ SCULPT_DYNTOPO_DETAIL_MANUAL = (1 << 16),
/* Don't display mask in viewport, but still use it for strokes. */
SCULPT_HIDE_MASK = (1 << 15),
@@ -2014,7 +2024,7 @@ typedef enum eImagePaintMode {
#define EDGE_MODE_TAG_BEVEL 4
#define EDGE_MODE_TAG_FREESTYLE 5
-/* ToolSettings.manipulator_flag */
+/* ToolSettings.gizmo_flag */
#define SCE_MANIP_TRANSLATE 1
#define SCE_MANIP_ROTATE 2
#define SCE_MANIP_SCALE 4
@@ -2111,6 +2121,9 @@ enum {
SCE_EEVEE_SSR_ENABLED = (1 << 14),
SCE_EEVEE_SSR_REFRACTION = (1 << 15),
SCE_EEVEE_SSR_HALF_RESOLUTION = (1 << 16),
+ SCE_EEVEE_SHOW_IRRADIANCE = (1 << 17),
+ SCE_EEVEE_SHOW_CUBEMAPS = (1 << 18),
+ SCE_EEVEE_GI_AUTOBAKE = (1 << 19),
};
/* SceneEEVEE->shadow_method */
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 3ee6bc38644..3815f01abeb 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -347,7 +347,7 @@ typedef struct ARegion {
ListBase handlers; /* wmEventHandler */
ListBase panels_category; /* Panel categories runtime */
- struct wmManipulatorMap *manipulator_map; /* manipulator-map of this region */
+ struct wmGizmoMap *gizmo_map; /* gizmo-map of this region */
struct wmTimer *regiontimer; /* blend in/out */
struct wmDrawBuffer *draw_buffer;
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 76b609b0c6c..443c6923ed0 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -137,6 +137,9 @@ typedef struct SmokeDomainSettings {
struct GPUTexture *tex_wt;
struct GPUTexture *tex_shadow;
struct GPUTexture *tex_flame;
+ struct GPUTexture *tex_velocity_x;
+ struct GPUTexture *tex_velocity_y;
+ struct GPUTexture *tex_velocity_z;
float *shadow;
/* simulation data */
diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h
index aefe1a7d5a3..02d3aa928c7 100644
--- a/source/blender/makesdna/DNA_sound_types.h
+++ b/source/blender/makesdna/DNA_sound_types.h
@@ -65,13 +65,15 @@ typedef struct bSound {
*/
struct PackedFile *newpackedfile;
struct Ipo *ipo;
+
float volume;
float attenuation;
float pitch;
float min_gain;
float max_gain;
float distance;
- int flags;
+ short flags;
+ short tags; /* Runtime only, always reset in readfile. */
int pad;
/* unused currently
@@ -116,13 +118,19 @@ enum {
SND_CFRA_NUM = 2,
};
+/* bSound->flags */
enum {
#ifdef DNA_DEPRECATED
SOUND_FLAGS_3D = (1 << 3), /* deprecated! used for sound actuator loading */
#endif
SOUND_FLAGS_CACHING = (1 << 4),
SOUND_FLAGS_MONO = (1 << 5),
- SOUND_FLAGS_WAVEFORM_LOADING = (1 << 6),
+};
+
+/* bSound->tags */
+enum {
+ SOUND_TAGS_WAVEFORM_NO_RELOAD = 1 << 0, /* Do not free/reset waveform on sound load, only used by undo code. */
+ SOUND_TAGS_WAVEFORM_LOADING = (1 << 6),
};
/* to DNA_sound_types.h*/
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index bbfbf660774..d6d043b03ae 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -138,8 +138,8 @@ typedef struct SpaceButs {
short space_subtype;
short mainb, mainbo, mainbuser; /* context tabs */
- short re_align, align; /* align for panels */
short preview; /* preview is signal to refresh */
+ short pad[2];
char flag;
char collection_context;
@@ -213,14 +213,6 @@ typedef enum eSpaceButtons_Flag {
SB_SHADING_CONTEXT = (1 << 4),
} eSpaceButtons_Flag;
-/* SpaceButs.align */
-typedef enum eSpaceButtons_Align {
- BUT_FREE = 0,
- BUT_HORIZONTAL = 1,
- BUT_VERTICAL = 2,
- BUT_AUTO = 3,
-} eSpaceButtons_Align;
-
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index ca420195b99..42198e22c6b 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -192,7 +192,7 @@ typedef struct Tex {
short extend;
/* variables disabled, moved to struct iuser */
- short fie_ima;
+ short _pad0;
int len;
int frames, offset, sfra;
@@ -319,7 +319,7 @@ typedef struct ColorMapping {
/* imaflag unused, only for version check */
#ifdef DNA_DEPRECATED_ALLOW
-#define TEX_FIELDS_ 8
+// #define TEX_FIELDS_ 8
#define TEX_ANIMCYCLIC_ 64
#define TEX_ANIM5_ 128
#define TEX_ANTIALI_ 256
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index d2782dee9ff..cdfcf5598e8 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -156,8 +156,7 @@ typedef struct uiPanelColors {
char header[4];
char back[4];
char sub_back[4];
- short show_header;
- short show_back;
+ char pad2[4];
} uiPanelColors;
typedef struct uiGradientColors {
@@ -196,12 +195,12 @@ typedef struct ThemeUI {
/* Axis Colors */
char xaxis[4], yaxis[4], zaxis[4];
- /* Manipulator Colors. */
- char manipulator_hi[4];
- char manipulator_primary[4];
- char manipulator_secondary[4];
- char manipulator_a[4];
- char manipulator_b[4];
+ /* Gizmo Colors. */
+ char gizmo_hi[4];
+ char gizmo_primary[4];
+ char gizmo_secondary[4];
+ char gizmo_a[4];
+ char gizmo_b[4];
char pad2[4];
} ThemeUI;
@@ -573,7 +572,7 @@ typedef struct UserDef {
short gp_settings; /* eGP_UserdefSettings */
short tb_leftmouse, tb_rightmouse;
struct SolidLight light[3];
- short manipulator_flag, manipulator_size;
+ short gizmo_flag, gizmo_size;
short pad6[3];
short textimeout, texcollectrate;
short dragthreshold;
@@ -674,7 +673,7 @@ typedef enum eUserPref_Section {
/* UserDef.flag */
typedef enum eUserPref_Flag {
USER_AUTOSAVE = (1 << 0),
- USER_FLAG_DEPRECATED_1 = (1 << 1), /* cleared */
+ USER_FLAG_NUMINPUT_ADVANCED = (1 << 1),
USER_FLAG_DEPRECATED_2 = (1 << 2), /* cleared */
USER_FLAG_DEPRECATED_3 = (1 << 3), /* cleared */
/* USER_SCENEGLOBAL = (1 << 4), deprecated */
@@ -752,7 +751,7 @@ typedef enum eUserpref_UI_Flag {
USER_ORBIT_SELECTION = (1 << 14),
USER_DEPTH_NAVIGATE = (1 << 15),
USER_HIDE_DOT = (1 << 16),
- USER_SHOW_ROTVIEWICON = (1 << 17),
+ USER_SHOW_GIZMO_AXIS = (1 << 17),
USER_SHOW_VIEWPORTNAME = (1 << 18),
USER_CAM_LOCK_NO_PARENT = (1 << 19),
USER_ZOOM_TO_MOUSEPOS = (1 << 20),
@@ -876,9 +875,7 @@ typedef enum eGP_UserdefSettings {
} eGP_UserdefSettings;
enum {
- USER_MANIPULATOR_DRAW = (1 << 0),
- USER_MANIPULATOR_DRAW_NAVIGATE = (1 << 1),
- USER_MANIPULATOR_SHADED = (1 << 8),
+ USER_GIZMO_DRAW = (1 << 0),
};
/* Color Picker Types.
diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h
index ebeb639e8aa..e2d8d836368 100644
--- a/source/blender/makesdna/DNA_view2d_types.h
+++ b/source/blender/makesdna/DNA_view2d_types.h
@@ -66,8 +66,7 @@ typedef struct View2D {
/* Usually set externally (as in, not in view2d files). */
char alpha_vert, alpha_hor; /* alpha of vertical and horizontal scrollbars (range is [0, 255]) */
- short size_vert, size_hor; /* Dynamic size for scrollers without scale markers (no V2D_SCROLL_SCALE_FOO) */
- short pad;
+ short pad[3];
/* animated smooth view */
struct SmoothView2DStore *sms;
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 6dbed4d5d6f..fedc604f120 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -49,6 +49,7 @@ struct GPUViewport;
#include "DNA_defs.h"
#include "DNA_listBase.h"
#include "DNA_image_types.h"
+#include "DNA_object_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_gpu_types.h"
@@ -89,7 +90,7 @@ typedef struct RegionView3D {
struct wmTimer *smooth_timer;
- /* transform manipulator matrix */
+ /* transform gizmo matrix */
float twmat[4][4];
/* min/max dot product on twmat xyz axis. */
float tw_axis_min[3], tw_axis_max[3];
@@ -134,11 +135,14 @@ typedef struct View3DCursor {
/* 3D Viewport Shading setings */
typedef struct View3DShading {
+ short type; /* Shading type (VIEW3D_SHADE_SOLID, ..) */
+ short prev_type; /* Runtime, for toggle between rendered viewport. */
+
short flag;
short color_type;
short light;
- char pad[2];
+ short pad[3];
char studio_light[256]; /* FILE_MAXFILE */
char matcap[256]; /* FILE_MAXFILE */
@@ -174,12 +178,12 @@ typedef struct View3DOverlay {
/* Armature edit/pose mode settings */
int arm_flag;
- float bone_selection_alpha;
+ float bone_select_alpha;
/* Other settings */
float wireframe_threshold;
+ char _pad0[4];
- int pad;
} View3DOverlay;
/* 3D ViewPort Struct */
@@ -201,6 +205,9 @@ typedef struct View3D {
unsigned int lay_prev; /* for active layer toggle */
unsigned int lay_used; /* used while drawing */
+ int object_type_exclude_viewport;
+ int object_type_exclude_select;
+
short persp DNA_DEPRECATED;
short view DNA_DEPRECATED;
@@ -232,13 +239,14 @@ typedef struct View3D {
short gridsubdiv; /* Number of subdivisions in the grid between each highlighted grid line */
char gridflag;
- /* transform manipulator info */
- char twtype, _pad5, twflag;
+ /* transform gizmo info */
+ char _pad5[2], gizmo_flag;
short flag3;
/* drawflags, denoting state */
- char zbuf, transp, xray;
+ char _pad2;
+ char transp, xray;
char multiview_eye; /* multiview current eye - for internal use */
@@ -262,9 +270,8 @@ typedef struct View3D {
float stereo3d_convergence_alpha;
/* Display settings */
- short drawtype; /* Shading mode (OB_SOLID, OB_TEXTURE, ..) */
- short prev_drawtype; /* Runtime, for toggle between rendered viewport. */
- int pad5;
+ short drawtype DNA_DEPRECATED;
+ short pad5[3];
View3DShading shading;
View3DOverlay overlay;
@@ -356,10 +363,11 @@ enum {
V3D_SHADING_OBJECT_OUTLINE = (1 << 0),
V3D_SHADING_XRAY = (1 << 1),
V3D_SHADING_SHADOW = (1 << 2),
- V3D_SHADING_SCENE_LIGHT = (1 << 3),
+ V3D_SHADING_SCENE_LIGHTS = (1 << 3),
V3D_SHADING_SPECULAR_HIGHLIGHT = (1 << 4),
V3D_SHADING_CAVITY = (1 << 5),
V3D_SHADING_MATCAP_FLIP_X = (1 << 6),
+ V3D_SHADING_SCENE_WORLD = (1 << 7),
};
/* View3DShading->color_type */
@@ -374,12 +382,15 @@ enum {
enum {
V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
V3D_OVERLAY_HIDE_CURSOR = (1 << 1),
- V3D_OVERLAY_BONE_SELECTION = (1 << 2),
+ V3D_OVERLAY_BONE_SELECT = (1 << 2),
V3D_OVERLAY_LOOK_DEV = (1 << 3),
V3D_OVERLAY_WIREFRAMES = (1 << 4),
V3D_OVERLAY_HIDE_TEXT = (1 << 5),
V3D_OVERLAY_HIDE_MOTION_PATHS = (1 << 6),
V3D_OVERLAY_ONION_SKINS = (1 << 7),
+ V3D_OVERLAY_HIDE_BONES = (1 << 8),
+ V3D_OVERLAY_HIDE_OBJECT_XTRAS = (1 << 9),
+ V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10),
};
/* View3DOverlay->edit_flag */
@@ -442,9 +453,13 @@ enum {
#define V3D_MANIP_CURSOR 5
#define V3D_MANIP_CUSTOM 1024
-/* View3d->twflag (also) */
+/* View3d.mpr_flag (also) */
enum {
- V3D_MANIPULATOR_DRAW = (1 << 0),
+ /** All gizmos. */
+ V3D_GIZMO_HIDE = (1 << 0),
+ V3D_GIZMO_HIDE_NAVIGATE = (1 << 1),
+ V3D_GIZMO_HIDE_CONTEXT = (1 << 2),
+ V3D_GIZMO_HIDE_TOOL = (1 << 3),
};
#define RV3D_CAMZOOM_MIN -30
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index c6ad1470561..25d9e50ff7a 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -184,10 +184,13 @@ typedef struct wmWindow {
struct wmWindow *next, *prev;
void *ghostwin; /* don't want to include ghost.h stuff */
- void *gwnctx; /* don't want to include gawin stuff */
+ void *gpuctx; /* don't want to include gpu stuff */
- struct Scene *scene; /* The scene displayed in this window. */
- struct Scene *new_scene; /* temporary when switching */
+ struct wmWindow *parent; /* Parent window */
+
+ struct Scene *scene; /* Active scene displayed in this window. */
+ struct Scene *new_scene; /* temporary when switching */
+ char view_layer_name[64]; /* Active view layer displayed in this window. */
struct WorkSpaceInstanceHook *workspace_hook;
@@ -328,6 +331,8 @@ typedef struct wmKeyMap {
/* runtime */
/** Verify if enabled in the current context, use #WM_keymap_poll instead of direct calls. */
bool (*poll)(struct bContext *);
+ bool (*poll_modal_item)(const struct wmOperator *op, int value);
+
/** For modal, #EnumPropertyItem for now. */
const void *modal_items;
} wmKeyMap;
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 585794fbe97..3eb40bfa523 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -58,12 +58,15 @@
typedef struct bToolRef_Runtime {
int cursor;
- /* One of these 3 must be defined. */
+ /** One of these 3 must be defined. */
char keymap[64];
- char manipulator_group[64];
+ char gizmo_group[64];
char data_block[64];
- /* index when a tool is a member of a group */
+ /** Use to infer primary operator to use when setting accelerator keys. */
+ char operator[64];
+
+ /** Index when a tool is a member of a group. */
int index;
} bToolRef_Runtime;
@@ -76,7 +79,7 @@ typedef struct bToolRef {
/** Use to avoid initializing the same tool multiple times. */
short tag;
- /** bToolKey (spacetype, mode), used in 'WM_api.h' */
+ /** #bToolKey (spacetype, mode), used in 'WM_api.h' */
short space_type;
/**
* Value depends ont the 'space_type', object mode for 3D view, image editor has own mode too.
@@ -126,7 +129,6 @@ typedef struct WorkSpace {
/* Store for each hook (so for each window) which layout has
* been activated the last time this workspace was visible. */
ListBase hook_layout_relations DNA_PRIVATE_WORKSPACE_READ_WRITE; /* WorkSpaceDataRelation */
- ListBase scene_layer_relations; /* WorkSpaceSceneRelation */
/* Feature tagging (use for addons) */
ListBase owner_ids DNA_PRIVATE_WORKSPACE_READ_WRITE; /* wmOwnerID */
@@ -187,13 +189,6 @@ typedef struct WorkSpaceDataRelation {
#endif /* DNA_PRIVATE_WORKSPACE_READ_WRITE */
-typedef struct WorkSpaceSceneRelation {
- struct WorkSpaceSceneRelation *next, *prev;
-
- struct Scene *scene;
- char view_layer[64]; /* MAX_NAME */
-} WorkSpaceSceneRelation;
-
/**
* Little wrapper to store data that is going to be per window, but comming from the workspace.
* It allows us to keep workspace and window data completely separate.
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index 2e38a402abb..7769833a835 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -51,6 +51,7 @@ struct MTex;
typedef struct World {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
+ DrawDataList drawdata; /* runtime (must be immediately after id for utilities to use it). */
char _pad0[4];
short texact, mistype;
@@ -81,8 +82,7 @@ typedef struct World {
short flag, pad3[3];
struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
- short pr_texture, use_nodes, pad;
- short update_flag; /* XXX temporary flag waiting for depsgraph proper tagging */
+ short pr_texture, use_nodes, pad[2];
/* previews */
struct PreviewImage *preview;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 6c5562d9bdd..8c57cb2ce42 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -69,7 +69,7 @@ extern StructRNA RNA_AnimVizMotionPaths;
extern StructRNA RNA_AnimVizOnionSkinning;
extern StructRNA RNA_AnyType;
extern StructRNA RNA_Area;
-extern StructRNA RNA_AreaLamp;
+extern StructRNA RNA_AreaLight;
extern StructRNA RNA_Armature;
extern StructRNA RNA_ArmatureModifier;
extern StructRNA RNA_ArmatureSensor;
@@ -281,7 +281,7 @@ extern StructRNA RNA_GaussianBlurSequence;
extern StructRNA RNA_GlowSequence;
extern StructRNA RNA_GreasePencil;
extern StructRNA RNA_Header;
-extern StructRNA RNA_HemiLamp;
+extern StructRNA RNA_HemiLight;
extern StructRNA RNA_Histogram;
extern StructRNA RNA_HookModifier;
extern StructRNA RNA_ID;
@@ -312,9 +312,9 @@ extern StructRNA RNA_KeyingSetInfo;
extern StructRNA RNA_KeyingSetPath;
extern StructRNA RNA_KeyingSetsAll;
extern StructRNA RNA_KinematicConstraint;
-extern StructRNA RNA_Lamp;
-extern StructRNA RNA_LampSkySettings;
-extern StructRNA RNA_LampTextureSlot;
+extern StructRNA RNA_Light;
+extern StructRNA RNA_LightSkySettings;
+extern StructRNA RNA_LightTextureSlot;
extern StructRNA RNA_LaplacianDeformModifier;
extern StructRNA RNA_LaplacianSmoothModifier;
extern StructRNA RNA_Lattice;
@@ -374,8 +374,8 @@ extern StructRNA RNA_LineStyleThicknessModifier_Tangent;
extern StructRNA RNA_LockedTrackConstraint;
extern StructRNA RNA_Macro;
extern StructRNA RNA_MagicTexture;
-extern StructRNA RNA_Manipulator;
-extern StructRNA RNA_ManipulatorProperties;
+extern StructRNA RNA_Gizmo;
+extern StructRNA RNA_GizmoProperties;
extern StructRNA RNA_MarbleTexture;
extern StructRNA RNA_MaskModifier;
extern StructRNA RNA_MaskSequence;
@@ -476,7 +476,7 @@ extern StructRNA RNA_ParticleSystemModifier;
extern StructRNA RNA_ParticleTarget;
extern StructRNA RNA_PivotConstraint;
extern StructRNA RNA_PointCache;
-extern StructRNA RNA_PointLamp;
+extern StructRNA RNA_PointLight;
extern StructRNA RNA_PointerProperty;
extern StructRNA RNA_Pose;
extern StructRNA RNA_PoseBone;
@@ -529,7 +529,7 @@ extern StructRNA RNA_ShaderNodeGeometry;
extern StructRNA RNA_ShaderNodeHueSaturation;
extern StructRNA RNA_ShaderNodeIESLight;
extern StructRNA RNA_ShaderNodeInvert;
-extern StructRNA RNA_ShaderNodeLampData;
+extern StructRNA RNA_ShaderNodeLightData;
extern StructRNA RNA_ShaderNodeMapping;
extern StructRNA RNA_ShaderNodeMaterial;
extern StructRNA RNA_ShaderNodeMath;
@@ -588,7 +588,7 @@ extern StructRNA RNA_Speaker;
extern StructRNA RNA_SpeedControlSequence;
extern StructRNA RNA_Spline;
extern StructRNA RNA_SplineIKConstraint;
-extern StructRNA RNA_SpotLamp;
+extern StructRNA RNA_SpotLight;
extern StructRNA RNA_Stereo3dDisplay;
extern StructRNA RNA_StretchToConstraint;
extern StructRNA RNA_StringProperty;
@@ -596,7 +596,7 @@ extern StructRNA RNA_Struct;
extern StructRNA RNA_StucciTexture;
extern StructRNA RNA_StudioLight;
extern StructRNA RNA_SubsurfModifier;
-extern StructRNA RNA_SunLamp;
+extern StructRNA RNA_SunLight;
extern StructRNA RNA_SurfaceCurve;
extern StructRNA RNA_SurfaceDeformModifier;
extern StructRNA RNA_SurfaceModifier;
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index ce1edba75fd..bafb2bf5753 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -129,7 +129,7 @@ extern const EnumPropertyItem rna_enum_symmetrize_direction_items[];
extern const EnumPropertyItem rna_enum_texture_type_items[];
-extern const EnumPropertyItem rna_enum_lamp_type_items[];
+extern const EnumPropertyItem rna_enum_light_type_items[];
extern const EnumPropertyItem rna_enum_unpack_method_items[];
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 2288e6c8405..eb32a5fc6cb 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -92,7 +92,7 @@ set(DEFSRC
rna_userdef.c
rna_vfont.c
rna_wm.c
- rna_wm_manipulator.c
+ rna_wm_gizmo.c
rna_workspace.c
rna_world.c
)
@@ -121,7 +121,7 @@ set(APISRC
rna_ui_api.c
rna_vfont_api.c
rna_wm_api.c
- rna_wm_manipulator_api.c
+ rna_wm_gizmo_api.c
rna_workspace_api.c
)
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 1dd4535610c..393ebc15d3e 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3407,7 +3407,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_group.c", NULL, RNA_def_collections},
{"rna_image.c", "rna_image_api.c", RNA_def_image},
{"rna_key.c", NULL, RNA_def_key},
- {"rna_lamp.c", NULL, RNA_def_lamp},
+ {"rna_lamp.c", NULL, RNA_def_light},
{"rna_lattice.c", "rna_lattice_api.c", RNA_def_lattice},
{"rna_layer.c", NULL, RNA_def_view_layer},
{"rna_linestyle.c", NULL, RNA_def_linestyle},
@@ -3443,7 +3443,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_userdef.c", NULL, RNA_def_userdef},
{"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont},
{"rna_wm.c", "rna_wm_api.c", RNA_def_wm},
- {"rna_wm_manipulator.c", "rna_wm_manipulator_api.c", RNA_def_wm_manipulator},
+ {"rna_wm_gizmo.c", "rna_wm_gizmo_api.c", RNA_def_wm_gizmo},
{"rna_workspace.c", "rna_workspace_api.c", RNA_def_workspace},
{"rna_world.c", NULL, RNA_def_world},
{"rna_movieclip.c", NULL, RNA_def_movieclip},
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 43535d6f498..0a294bfaab9 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -61,7 +61,7 @@ const EnumPropertyItem rna_enum_id_type_items[] = {
{ID_GR, "COLLECTION", ICON_GROUP, "Collection", ""},
{ID_IM, "IMAGE", ICON_IMAGE_DATA, "Image", ""},
{ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""},
- {ID_LA, "LAMP", ICON_LAMP_DATA, "Lamp", ""},
+ {ID_LA, "LIGHT", ICON_LIGHT_DATA, "Light", ""},
{ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""},
{ID_LS, "LINESTYLE", ICON_LINE_DATA, "Line Style", ""},
{ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""},
@@ -183,7 +183,7 @@ short RNA_type_to_ID_code(const StructRNA *type)
if (base_type == &RNA_Collection) return ID_GR;
if (base_type == &RNA_Image) return ID_IM;
if (base_type == &RNA_Key) return ID_KE;
- if (base_type == &RNA_Lamp) return ID_LA;
+ if (base_type == &RNA_Light) return ID_LA;
if (base_type == &RNA_Library) return ID_LI;
if (base_type == &RNA_FreestyleLineStyle) return ID_LS;
if (base_type == &RNA_Lattice) return ID_LT;
@@ -227,7 +227,7 @@ StructRNA *ID_code_to_RNA_type(short idcode)
case ID_GR: return &RNA_Collection;
case ID_IM: return &RNA_Image;
case ID_KE: return &RNA_Key;
- case ID_LA: return &RNA_Lamp;
+ case ID_LA: return &RNA_Light;
case ID_LI: return &RNA_Library;
case ID_LS: return &RNA_FreestyleLineStyle;
case ID_LT: return &RNA_Lattice;
@@ -272,7 +272,7 @@ IDProperty *rna_ID_idprops(PointerRNA *ptr, bool create)
return IDP_GetProperties(ptr->data, create);
}
-void rna_ID_fake_user_set(PointerRNA *ptr, int value)
+void rna_ID_fake_user_set(PointerRNA *ptr, bool value)
{
ID *id = (ID *)ptr->data;
@@ -689,7 +689,7 @@ static void rna_ImagePreview_pixels_float_set(PointerRNA *ptr, const float *valu
}
-static void rna_ImagePreview_is_image_custom_set(PointerRNA *ptr, int value)
+static void rna_ImagePreview_is_image_custom_set(PointerRNA *ptr, bool value)
{
rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_PREVIEW);
}
@@ -735,7 +735,7 @@ static void rna_ImagePreview_image_pixels_float_set(PointerRNA *ptr, const float
}
-static void rna_ImagePreview_is_icon_custom_set(PointerRNA *ptr, int value)
+static void rna_ImagePreview_is_icon_custom_set(PointerRNA *ptr, bool value)
{
rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_ICON);
}
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 638589c104a..7228f4a4683 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -620,7 +620,7 @@ StructRNA *RNA_struct_base(StructRNA *type)
/**
* Use to find the subtype directly below a base-type.
*
- * So if type were `RNA_SpotLamp`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Lamp`.
+ * So if type were `RNA_SpotLIght`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Light`.
*/
const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type)
{
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index 97c9d5a9866..12e28d457fb 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -423,10 +423,10 @@ static void rna_def_dopesheet(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
- prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "show_lights", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM);
- RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of lamp related animation data");
- RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0);
+ RNA_def_property_ui_text(prop, "Display Light", "Include visualization of light related animation data");
+ RNA_def_property_ui_icon(prop, ICON_LIGHT_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_linestyles", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 3faf8710d6e..6b014f462b5 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -119,7 +119,7 @@ static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value)
}
}
-static void rna_AnimData_tweakmode_set(PointerRNA *ptr, const int value)
+static void rna_AnimData_tweakmode_set(PointerRNA *ptr, const bool value)
{
AnimData *adt = (AnimData *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 596667a0afd..a4126e921d9 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -381,7 +381,7 @@ static void rna_EditBone_connected_check(EditBone *ebone)
}
}
-static void rna_EditBone_connected_set(PointerRNA *ptr, int value)
+static void rna_EditBone_connected_set(PointerRNA *ptr, bool value)
{
EditBone *ebone = (EditBone *)(ptr->data);
@@ -501,7 +501,7 @@ static void rna_Armature_bones_next(CollectionPropertyIterator *iter)
iter->valid = (internal->link != NULL);
}
-static int rna_Armature_is_editmode_get(PointerRNA *ptr)
+static bool rna_Armature_is_editmode_get(PointerRNA *ptr)
{
bArmature *arm = (bArmature *)ptr->id.data;
return (arm->edbo != NULL);
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 75d05115006..4f1e29b482d 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -135,25 +135,25 @@ const EnumPropertyItem rna_enum_brush_image_tool_items[] = {
#include "WM_api.h"
-static int rna_SculptToolCapabilities_has_accumulate_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_accumulate_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return SCULPT_TOOL_HAS_ACCUMULATE(br->sculpt_tool);
}
-static int rna_SculptToolCapabilities_has_auto_smooth_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_auto_smooth_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH);
}
-static int rna_SculptToolCapabilities_has_height_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_height_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return br->sculpt_tool == SCULPT_TOOL_LAYER;
}
-static int rna_SculptToolCapabilities_has_jitter_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_jitter_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return (!(br->flag & BRUSH_ANCHORED) &&
@@ -163,19 +163,19 @@ static int rna_SculptToolCapabilities_has_jitter_get(PointerRNA *ptr)
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
}
-static int rna_SculptToolCapabilities_has_normal_weight_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_normal_weight_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return SCULPT_TOOL_HAS_NORMAL_WEIGHT(br->sculpt_tool);
}
-static int rna_SculptToolCapabilities_has_rake_factor_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_rake_factor_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return SCULPT_TOOL_HAS_RAKE(br->sculpt_tool);
}
-static int rna_BrushCapabilities_has_overlay_get(PointerRNA *ptr)
+static bool rna_BrushCapabilities_has_overlay_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return ELEM(br->mtex.brush_map_mode,
@@ -184,26 +184,26 @@ static int rna_BrushCapabilities_has_overlay_get(PointerRNA *ptr)
MTEX_MAP_MODE_STENCIL);
}
-static int rna_SculptToolCapabilities_has_persistence_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_persistence_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return br->sculpt_tool == SCULPT_TOOL_LAYER;
}
-static int rna_SculptToolCapabilities_has_pinch_factor_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_pinch_factor_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return ELEM(br->sculpt_tool, SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE, SCULPT_TOOL_SNAKE_HOOK);
}
-static int rna_SculptToolCapabilities_has_plane_offset_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_plane_offset_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return ELEM(br->sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_SCRAPE);
}
-static int rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return (!ELEM(br->sculpt_tool,
@@ -211,7 +211,7 @@ static int rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *p
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
}
-static int rna_TextureCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
+static bool rna_TextureCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
{
MTex *mtex = (MTex *)ptr->data;
return ELEM(mtex->brush_map_mode,
@@ -221,13 +221,13 @@ static int rna_TextureCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
}
-static int rna_BrushCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
+static bool rna_BrushCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return !(br->flag & BRUSH_ANCHORED);
}
-static int rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return !ELEM(br->sculpt_tool, SCULPT_TOOL_INFLATE,
@@ -235,13 +235,13 @@ static int rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
SCULPT_TOOL_SMOOTH);
}
-static int rna_SculptToolCapabilities_has_secondary_color_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_secondary_color_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return BKE_brush_sculpt_has_secondary_color(br);
}
-static int rna_SculptToolCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return (!(br->flag & BRUSH_ANCHORED) &&
@@ -253,7 +253,7 @@ static int rna_SculptToolCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
}
-static int rna_BrushCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
+static bool rna_BrushCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return (!(br->flag & BRUSH_ANCHORED) &&
@@ -262,7 +262,7 @@ static int rna_BrushCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
!(br->flag & BRUSH_CURVE));
}
-static int rna_SculptToolCapabilities_has_space_attenuation_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_space_attenuation_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return ((br->flag & (BRUSH_SPACE | BRUSH_LINE | BRUSH_CURVE)) &&
@@ -270,38 +270,38 @@ static int rna_SculptToolCapabilities_has_space_attenuation_get(PointerRNA *ptr)
SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK));
}
-static int rna_ImapaintToolCapabilities_has_space_attenuation_get(PointerRNA *ptr)
+static bool rna_ImapaintToolCapabilities_has_space_attenuation_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return (br->flag & (BRUSH_SPACE | BRUSH_LINE | BRUSH_CURVE)) &&
br->imagepaint_tool != PAINT_TOOL_FILL;
}
-static int rna_BrushCapabilities_has_spacing_get(PointerRNA *ptr)
+static bool rna_BrushCapabilities_has_spacing_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return (!(br->flag & BRUSH_ANCHORED));
}
-static int rna_SculptToolCapabilities_has_strength_pressure_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_strength_pressure_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
}
-static int rna_TextureCapabilities_has_texture_angle_get(PointerRNA *ptr)
+static bool rna_TextureCapabilities_has_texture_angle_get(PointerRNA *ptr)
{
MTex *mtex = (MTex *)ptr->data;
return mtex->brush_map_mode != MTEX_MAP_MODE_3D;
}
-static int rna_SculptToolCapabilities_has_gravity_get(PointerRNA *ptr)
+static bool rna_SculptToolCapabilities_has_gravity_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH);
}
-static int rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr)
+static bool rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr)
{
MTex *mtex = (MTex *)ptr->data;
return ELEM(mtex->brush_map_mode,
@@ -310,7 +310,7 @@ static int rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr)
MTEX_MAP_MODE_RANDOM);
}
-static int rna_ImapaintToolCapabilities_has_accumulate_get(PointerRNA *ptr)
+static bool rna_ImapaintToolCapabilities_has_accumulate_get(PointerRNA *ptr)
{
/* only support for draw tool */
Brush *br = (Brush *)ptr->data;
@@ -325,7 +325,7 @@ static int rna_ImapaintToolCapabilities_has_accumulate_get(PointerRNA *ptr)
) ? false : true;
}
-static int rna_ImapaintToolCapabilities_has_radius_get(PointerRNA *ptr)
+static bool rna_ImapaintToolCapabilities_has_radius_get(PointerRNA *ptr)
{
/* only support for draw tool */
Brush *br = (Brush *)ptr->data;
@@ -465,7 +465,7 @@ static void rna_Brush_set_size(PointerRNA *ptr, int value)
brush->size = value;
}
-static void rna_Brush_use_gradient_set(PointerRNA *ptr, int value)
+static void rna_Brush_use_gradient_set(PointerRNA *ptr, bool value)
{
Brush *br = (Brush *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 99fa532452f..083551f2367 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -86,7 +86,7 @@ static void rna_CurveMapping_curves_begin(CollectionPropertyIterator *iter, Poin
rna_iterator_array_begin(iter, cumap->cm, sizeof(CurveMap), rna_CurveMapping_curves_length(ptr), 0, NULL);
}
-static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value)
+static void rna_CurveMapping_clip_set(PointerRNA *ptr, bool value)
{
CurveMapping *cumap = (CurveMapping *)ptr->data;
@@ -495,7 +495,7 @@ static const EnumPropertyItem *rna_ColorManagedViewSettings_look_itemf(
return items;
}
-static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, int value)
+static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, bool value)
{
ColorManagedViewSettings *view_settings = (ColorManagedViewSettings *) ptr->data;
@@ -1102,8 +1102,9 @@ static void rna_def_colormanage(BlenderRNA *brna)
prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "exposure");
- RNA_def_property_range(prop, -10.0f, 10.0f);
RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -32.0f, 32.0f);
+ RNA_def_property_ui_range(prop, -10.0f, 10.0f, 1, 3);
RNA_def_property_ui_text(prop, "Exposure", "Exposure (stops) applied before display transform");
RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index 6e07976a3c6..7b07faf8ee7 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -121,11 +121,11 @@ static PointerRNA rna_Context_region_data_get(PointerRNA *ptr)
return PointerRNA_NULL;
}
-static PointerRNA rna_Context_manipulator_group_get(PointerRNA *ptr)
+static PointerRNA rna_Context_gizmo_group_get(PointerRNA *ptr)
{
bContext *C = (bContext *)ptr->data;
PointerRNA newptr;
- RNA_pointer_create(NULL, &RNA_ManipulatorGroup, CTX_wm_manipulator_group(C), &newptr);
+ RNA_pointer_create(NULL, &RNA_GizmoGroup, CTX_wm_gizmo_group(C), &newptr);
return newptr;
}
@@ -256,10 +256,10 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "RegionView3D");
RNA_def_property_pointer_funcs(prop, "rna_Context_region_data_get", NULL, NULL, NULL);
- prop = RNA_def_property(srna, "manipulator_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "gizmo_group", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_struct_type(prop, "ManipulatorGroup");
- RNA_def_property_pointer_funcs(prop, "rna_Context_manipulator_group_get", NULL, NULL, NULL);
+ RNA_def_property_struct_type(prop, "GizmoGroup");
+ RNA_def_property_pointer_funcs(prop, "rna_Context_gizmo_group_get", NULL, NULL, NULL);
/* Data */
prop = RNA_def_property(srna, "blend_data", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 2feeba668ce..da1ef2b6921 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -737,7 +737,7 @@ static void rna_Curve_splines_begin(CollectionPropertyIterator *iter, PointerRNA
rna_iterator_listbase_begin(iter, BKE_curve_nurbs_get(cu), NULL);
}
-static int rna_Curve_is_editmode_get(PointerRNA *ptr)
+static bool rna_Curve_is_editmode_get(PointerRNA *ptr)
{
Curve *cu = (Curve *)ptr->id.data;
const short type = BKE_curve_type_get(cu);
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index eb069b5e069..a18442df085 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -143,27 +143,27 @@ static PointerRNA rna_DepsgraphUpdate_id_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_ID, ptr->data);
}
-static int rna_DepsgraphUpdate_updated_transform_get(PointerRNA *ptr)
+static bool rna_DepsgraphUpdate_is_dirty_transform_get(PointerRNA *ptr)
{
ID *id = ptr->data;
- return ((id->recalc & ID_RECALC_TRANSFORM) != 0);
+ return ((id->recalc & ID_RECALC_TRANSFORM) == 0);
}
-static int rna_DepsgraphUpdate_updated_geometry_get(PointerRNA *ptr)
+static bool rna_DepsgraphUpdate_is_dirty_geometry_get(PointerRNA *ptr)
{
ID *id = ptr->data;
if (id->recalc & ID_RECALC_GEOMETRY) {
- return true;
+ return false;
}
if (GS(id->name) != ID_OB) {
- return false;
+ return true;
}
Object *object = (Object *)id;
ID *data = object->data;
if (data == NULL) {
- return 0;
+ return true;
}
- return ((data->recalc & ID_RECALC_ALL) != 0);
+ return ((data->recalc & ID_RECALC_ALL) == 0);
}
/* **************** Depsgraph **************** */
@@ -454,15 +454,15 @@ static void rna_def_depsgraph_update(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_pointer_funcs(prop, "rna_DepsgraphUpdate_id_get", NULL, NULL, NULL);
- prop = RNA_def_property(srna, "updated_transform", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "is_dirty_transform", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Transform", "Object transformation was updated");
- RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_updated_transform_get", NULL);
+ RNA_def_property_ui_text(prop, "Transform", "Object transformation is not updated");
+ RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_dirty_transform_get", NULL);
- prop = RNA_def_property(srna, "updated_geometry", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "is_dirty_geometry", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Geometry", "Object geometry was updated");
- RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_updated_geometry_get", NULL);
+ RNA_def_property_ui_text(prop, "Geometry", "Object geometry is not updated");
+ RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_dirty_geometry_get", NULL);
}
static void rna_def_depsgraph(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 2801b292df6..884435d70cf 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -224,7 +224,7 @@ static void rna_DynamicPaint_uvlayer_set(PointerRNA *ptr, const char *value)
}
/* is point cache used */
-static int rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr)
+static bool rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr)
{
DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
@@ -232,7 +232,7 @@ static int rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr)
}
/* is some 3D view preview available */
-static int rna_DynamicPaint_use_color_preview_get(PointerRNA *ptr)
+static bool rna_DynamicPaint_use_color_preview_get(PointerRNA *ptr)
{
DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index f70ce67f1b0..3141e788d8d 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -524,7 +524,7 @@ static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, Pointe
RNA_POINTER_INVALIDATE(fcm_ptr);
}
-static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value))
+static void rna_FModifier_active_set(PointerRNA *ptr, bool UNUSED(value))
{
FModifier *fcm = (FModifier *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 2418102d94c..d9dba4679e0 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -275,7 +275,7 @@ static const EnumPropertyItem *rna_Object_parent_type_itemf(
return item;
}
-static int rna_GPencilLayer_is_parented_get(PointerRNA *ptr)
+static bool rna_GPencilLayer_is_parented_get(PointerRNA *ptr)
{
bGPDlayer *gpl = (bGPDlayer *)ptr->data;
return (gpl->parent != NULL);
@@ -366,7 +366,7 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info);
}
-static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value)
+static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const bool value)
{
bGPdata *gpd = ptr->id.data;
bGPDlayer *gpl;
@@ -423,7 +423,7 @@ static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd, cons
return NULL;
}
-static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const int value)
+static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const bool value)
{
bGPdata *gpd = ptr->id.data;
bGPDspoint *pt = ptr->data;
@@ -525,7 +525,7 @@ static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, Poi
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
-static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const int value)
+static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const bool value)
{
bGPDstroke *gps = ptr->data;
bGPDspoint *pt;
@@ -851,13 +851,13 @@ static void rna_GPencilStrokeColor_info_set(PointerRNA *ptr, const char *value)
}
-static int rna_GPencilPaletteColor_is_stroke_visible_get(PointerRNA *ptr)
+static bool rna_GPencilPaletteColor_is_stroke_visible_get(PointerRNA *ptr)
{
bGPDpalettecolor *pcolor = (bGPDpalettecolor *)ptr->data;
return (pcolor->color[3] > GPENCIL_ALPHA_OPACITY_THRESH);
}
-static int rna_GPencilPaletteColor_is_fill_visible_get(PointerRNA *ptr)
+static bool rna_GPencilPaletteColor_is_fill_visible_get(PointerRNA *ptr)
{
bGPDpalettecolor *pcolor = (bGPDpalettecolor *)ptr->data;
return (pcolor->fill[3] > GPENCIL_ALPHA_OPACITY_THRESH);
diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c
index b3afba36a9f..7797de9ad4b 100644
--- a/source/blender/makesrna/intern/rna_group.c
+++ b/source/blender/makesrna/intern/rna_group.c
@@ -116,6 +116,7 @@ static bool rna_Collection_objects_override_apply(
PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src, PointerRNA *UNUSED(ptr_item_storage),
IDOverrideStaticPropertyOperation *opop)
{
+ (void)opop;
BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_REPLACE &&
"Unsupported RNA override operation on collections' objects");
@@ -199,6 +200,7 @@ static bool rna_Collection_children_override_apply(
PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src, PointerRNA *UNUSED(ptr_item_storage),
IDOverrideStaticPropertyOperation *opop)
{
+ (void)opop;
BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_REPLACE &&
"Unsupported RNA override operation on collections' objects");
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 2570f88d09f..1759eb812e6 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -72,17 +72,17 @@ static const EnumPropertyItem image_source_items[] = {
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-static int rna_Image_is_stereo_3d_get(PointerRNA *ptr)
+static bool rna_Image_is_stereo_3d_get(PointerRNA *ptr)
{
return BKE_image_is_stereo((Image *)ptr->data);
}
-static int rna_Image_is_multiview_get(PointerRNA *ptr)
+static bool rna_Image_is_multiview_get(PointerRNA *ptr)
{
return BKE_image_is_multiview((Image *)ptr->data);
}
-static int rna_Image_dirty_get(PointerRNA *ptr)
+static bool rna_Image_dirty_get(PointerRNA *ptr)
{
return BKE_image_is_dirty((Image *)ptr->data);
}
@@ -99,27 +99,6 @@ static void rna_Image_source_set(PointerRNA *ptr, int value)
}
}
-static void rna_Image_fields_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
-{
- Image *ima = ptr->id.data;
- ImBuf *ibuf;
- void *lock;
-
- ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
-
- if (ibuf) {
- short nr = 0;
-
- if (!(ima->flag & IMA_FIELDS) && (ibuf->flags & IB_fields)) nr = 1;
- if ((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr = 1;
-
- if (nr)
- BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE);
- }
-
- BKE_image_release_ibuf(ima, ibuf, lock);
-}
-
static void rna_Image_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Image *ima = ptr->id.data;
@@ -240,7 +219,7 @@ static void rna_Image_file_format_set(PointerRNA *ptr, int value)
}
}
-static int rna_Image_has_data_get(PointerRNA *ptr)
+static bool rna_Image_has_data_get(PointerRNA *ptr)
{
Image *image = (Image *)ptr->data;
@@ -434,7 +413,7 @@ static int rna_Image_channels_get(PointerRNA *ptr)
return channels;
}
-static int rna_Image_is_float_get(PointerRNA *ptr)
+static bool rna_Image_is_float_get(PointerRNA *ptr)
{
Image *im = (Image *)ptr->data;
ImBuf *ibuf;
@@ -562,13 +541,6 @@ static void rna_def_imageuser(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- prop = RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "fie_ima");
- RNA_def_property_range(prop, 1, 200);
- RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)");
- RNA_def_property_update(prop, 0, "rna_ImageUser_update");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-
prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "layer");
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
@@ -672,11 +644,6 @@ static void rna_def_image(BlenderRNA *brna)
{IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem prop_field_order_items[] = {
- {0, "EVEN", 0, "Upper First", "Upper field first"},
- {IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"},
- {0, NULL, 0, NULL, NULL}
- };
static const EnumPropertyItem alpha_mode_items[] = {
{IMA_ALPHA_STRAIGHT, "STRAIGHT", 0, "Straight", "Transparent RGB and alpha pixels are unmodified"},
{IMA_ALPHA_PREMUL, "PREMUL", 0, "Premultiplied", "Transparent RGB pixels are multiplied by the alpha channel"},
@@ -727,22 +694,6 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Packed Files", "Collection of packed images");
- prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE);
- RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
- RNA_def_property_enum_items(prop, prop_field_order_items);
- RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines are displayed first)");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
- /* booleans */
- prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS);
- RNA_def_property_ui_text(prop, "Fields", "Use fields of the image");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-
-
prop = RNA_def_property(srna, "use_view_as_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER);
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 70b75efdb36..c7a3e103281 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -115,7 +115,9 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports
static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *reports)
{
- ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
+ void *lock;
+
+ ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
if (ibuf) {
char filename[FILE_MAX];
BLI_strncpy(filename, image->name, sizeof(filename));
@@ -142,7 +144,7 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r
BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
}
- BKE_image_release_ibuf(image, ibuf, NULL);
+ BKE_image_release_ibuf(image, ibuf, &lock);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image);
}
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 5784b2a489a..83d173de6c8 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -155,7 +155,7 @@ void RNA_def_fcurve(struct BlenderRNA *brna);
void RNA_def_gpencil(struct BlenderRNA *brna);
void RNA_def_image(struct BlenderRNA *brna);
void RNA_def_key(struct BlenderRNA *brna);
-void RNA_def_lamp(struct BlenderRNA *brna);
+void RNA_def_light(struct BlenderRNA *brna);
void RNA_def_lattice(struct BlenderRNA *brna);
void RNA_def_linestyle(struct BlenderRNA *brna);
void RNA_def_main(struct BlenderRNA *brna);
@@ -193,7 +193,7 @@ void RNA_def_ui(struct BlenderRNA *brna);
void RNA_def_userdef(struct BlenderRNA *brna);
void RNA_def_vfont(struct BlenderRNA *brna);
void RNA_def_wm(struct BlenderRNA *brna);
-void RNA_def_wm_manipulator(struct BlenderRNA *brna);
+void RNA_def_wm_gizmo(struct BlenderRNA *brna);
void RNA_def_workspace(struct BlenderRNA *brna);
void RNA_def_world(struct BlenderRNA *brna);
void RNA_def_movieclip(struct BlenderRNA *brna);
@@ -226,14 +226,14 @@ void rna_def_view_layer_common(struct StructRNA *srna, int scene);
void rna_def_actionbone_group_common(struct StructRNA *srna, int update_flag, const char *update_cb);
void rna_ActionGroup_colorset_set(struct PointerRNA *ptr, int value);
-int rna_ActionGroup_is_custom_colorset_get(struct PointerRNA *ptr);
+bool rna_ActionGroup_is_custom_colorset_get(struct PointerRNA *ptr);
void rna_ID_name_get(struct PointerRNA *ptr, char *value);
int rna_ID_name_length(struct PointerRNA *ptr);
void rna_ID_name_set(struct PointerRNA *ptr, const char *value);
struct StructRNA *rna_ID_refine(struct PointerRNA *ptr);
struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, bool create);
-void rna_ID_fake_user_set(struct PointerRNA *ptr, int value);
+void rna_ID_fake_user_set(struct PointerRNA *ptr, bool value);
void **rna_ID_instance(PointerRNA *ptr);
struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, bool create);
void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type);
@@ -283,7 +283,7 @@ void rna_TextureSlot_update(struct bContext *C, struct PointerRNA *ptr);
bool rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
bool rna_Camera_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
bool rna_Curve_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
-bool rna_Lamp_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
+bool rna_Light_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
bool rna_Lattice_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
bool rna_Mesh_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
@@ -308,8 +308,8 @@ void RNA_api_image(struct StructRNA *srna);
void RNA_api_lattice(struct StructRNA *srna);
void RNA_api_operator(struct StructRNA *srna);
void RNA_api_macro(struct StructRNA *srna);
-void RNA_api_manipulator(struct StructRNA *srna);
-void RNA_api_manipulatorgroup(struct StructRNA *srna);
+void RNA_api_gizmo(struct StructRNA *srna);
+void RNA_api_gizmogroup(struct StructRNA *srna);
void RNA_api_keyconfig(struct StructRNA *srna);
void RNA_api_keyconfigs(struct StructRNA *srna);
void RNA_api_keyingset(struct StructRNA *srna);
@@ -354,7 +354,7 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop);
-void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop);
+void RNA_def_main_lights(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop);
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index dff27e1c625..126c5e82206 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -54,7 +54,7 @@
#include "WM_api.h"
#include "WM_types.h"
-static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value)
+static void rna_Light_buffer_size_set(PointerRNA *ptr, int value)
{
Lamp *la = (Lamp *)ptr->data;
@@ -63,27 +63,27 @@ static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value)
la->bufsize &= (~15); /* round to multiple of 16 */
}
-static StructRNA *rna_Lamp_refine(struct PointerRNA *ptr)
+static StructRNA *rna_Light_refine(struct PointerRNA *ptr)
{
Lamp *la = (Lamp *)ptr->data;
switch (la->type) {
case LA_LOCAL:
- return &RNA_PointLamp;
+ return &RNA_PointLight;
case LA_SUN:
- return &RNA_SunLamp;
+ return &RNA_SunLight;
case LA_SPOT:
- return &RNA_SpotLamp;
+ return &RNA_SpotLight;
case LA_HEMI:
- return &RNA_HemiLamp;
+ return &RNA_HemiLight;
case LA_AREA:
- return &RNA_AreaLamp;
+ return &RNA_AreaLight;
default:
- return &RNA_Lamp;
+ return &RNA_Light;
}
}
-static void rna_Lamp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Light_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Lamp *la = ptr->id.data;
@@ -91,7 +91,7 @@ static void rna_Lamp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
WM_main_add_notifier(NC_LAMP | ND_LIGHTING, la);
}
-static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Light_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Lamp *la = ptr->id.data;
@@ -99,19 +99,19 @@ static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin
WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, la);
}
-static void rna_Lamp_use_nodes_update(bContext *C, PointerRNA *ptr)
+static void rna_Light_use_nodes_update(bContext *C, PointerRNA *ptr)
{
Lamp *la = (Lamp *)ptr->data;
if (la->use_nodes && la->nodetree == NULL)
ED_node_shader_default(C, &la->id);
- rna_Lamp_update(CTX_data_main(C), CTX_data_scene(C), ptr);
+ rna_Light_update(CTX_data_main(C), CTX_data_scene(C), ptr);
}
#else
-/* Don't define icons here, so they don't show up in the Lamp UI (properties Editor) - DingTo */
-const EnumPropertyItem rna_enum_lamp_type_items[] = {
+/* Don't define icons here, so they don't show up in the Light UI (properties Editor) - DingTo */
+const EnumPropertyItem rna_enum_light_type_items[] = {
{LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"},
{LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"},
{LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"},
@@ -120,21 +120,23 @@ const EnumPropertyItem rna_enum_lamp_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static void rna_def_lamp(BlenderRNA *brna)
+static void rna_def_light(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ static float default_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- srna = RNA_def_struct(brna, "Lamp", "ID");
- RNA_def_struct_refine_func(srna, "rna_Lamp_refine");
- RNA_def_struct_ui_text(srna, "Lamp", "Lamp data-block for lighting a scene");
- RNA_def_struct_ui_icon(srna, ICON_LAMP_DATA);
+ srna = RNA_def_struct(brna, "Light", "ID");
+ RNA_def_struct_sdna(srna, "Lamp");
+ RNA_def_struct_refine_func(srna, "rna_Light_refine");
+ RNA_def_struct_ui_text(srna, "Light", "Light data-block for lighting a scene");
+ RNA_def_struct_ui_icon(srna, ICON_LIGHT_DATA);
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, rna_enum_lamp_type_items);
- RNA_def_property_ui_text(prop, "Type", "Type of Lamp");
+ RNA_def_property_enum_items(prop, rna_enum_light_type_items);
+ RNA_def_property_ui_text(prop, "Type", "Type of Light");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_LAMP);
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "dist");
@@ -142,43 +144,46 @@ static void rna_def_lamp(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0, 1000, 1, 3);
RNA_def_property_ui_text(prop, "Distance",
"Falloff distance - the light is at half the original intensity at this point");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_default(prop, 10.0f);
RNA_def_property_ui_range(prop, 0, 10, 1, 3);
- RNA_def_property_ui_text(prop, "Energy", "Amount of light that the lamp emits");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_ui_text(prop, "Energy", "Amount of light emitted");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "r");
RNA_def_property_array(prop, 3);
+ RNA_def_property_float_array_default(prop, default_color);
RNA_def_property_ui_text(prop, "Color", "Light color");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "spec_fac");
+ RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.0f, 9999.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
/* 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 lamps");
+ RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lights");
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 shader nodes to render the lamp");
- RNA_def_property_update(prop, 0, "rna_Lamp_use_nodes_update");
+ RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the light");
+ RNA_def_property_update(prop, 0, "rna_Light_use_nodes_update");
/* common */
rna_def_animdata_common(srna);
}
-static void rna_def_lamp_falloff(StructRNA *srna)
+static void rna_def_light_falloff(StructRNA *srna)
{
PropertyRNA *prop;
@@ -195,54 +200,54 @@ static void rna_def_lamp_falloff(StructRNA *srna)
prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_fallofftype_items);
RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
- RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_ui_text(prop, "Falloff Curve", "Custom light falloff curve");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "att1");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Linear Attenuation", "Linear distance attenuation");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "quadratic_attenuation", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "att2");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Quadratic Attenuation", "Quadratic distance attenuation");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "constant_coefficient", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "coeff_const");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Constant Coefficient",
"Constant distance attenuation coefficient");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "linear_coefficient", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "coeff_lin");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Linear Coefficient",
"Linear distance attenuation coefficient");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "quadratic_coefficient", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "coeff_quad");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Quadratic Coefficient",
"Quadratic distance attenuation coefficient");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
}
-static void rna_def_lamp_shadow(StructRNA *srna, int sun)
+static void rna_def_light_shadow(StructRNA *srna, int sun)
{
PropertyRNA *prop;
prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHADOW);
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "bufsize");
@@ -250,66 +255,72 @@ static void rna_def_lamp_shadow(StructRNA *srna, int sun)
RNA_def_property_ui_text(prop, "Shadow Buffer Size",
"Resolution of the shadow buffer, higher values give crisper shadows "
"but use more memory");
- RNA_def_property_int_funcs(prop, NULL, "rna_Lamp_buffer_size_set", NULL);
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_int_funcs(prop, NULL, "rna_Light_buffer_size_set", NULL);
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "clipsta");
+ RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, 9999.0f);
RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start",
"Shadow map clip start, below which objects will not generate shadows");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "clipend");
+ RNA_def_property_float_default(prop, 40.0f);
RNA_def_property_range(prop, 0.0f, 9999.0f);
RNA_def_property_ui_text(prop, "Shadow Buffer Clip End",
"Shadow map clip end, beyond which objects will not generate shadows");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bias");
+ RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.001f, 9999.0f);
RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3);
RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Bias for reducing self shadowing");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_buffer_bleed_bias", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bleedbias");
RNA_def_property_range(prop, 0.f, 1.f);
RNA_def_property_ui_text(prop, "Shadow Buffer Bleed Bias", "Bias for reducing light-bleed on variance shadow maps");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_buffer_exp", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bleedexp");
+ RNA_def_property_float_default(prop, 2.5f);
RNA_def_property_range(prop, 1.0f, 9999.0f);
RNA_def_property_ui_text(prop, "Shadow Buffer Exponent", "Bias for reducing light-bleed on exponential shadow maps");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_buffer_soft", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "soft");
+ RNA_def_property_float_default(prop, 3.0f);
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Shadow Buffer Soft", "Size of shadow buffer sampling area");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_buffer_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "samp");
RNA_def_property_range(prop, 1, 16);
RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "shdwr");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the lamp");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the light");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "area_size");
+ RNA_def_property_float_default(prop, 0.25f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
/* Eevee */
prop = RNA_def_property(srna, "use_contact_shadow", PROP_BOOLEAN, PROP_NONE);
@@ -317,76 +328,84 @@ static void rna_def_lamp_shadow(StructRNA *srna, int sun)
RNA_def_property_ui_text(prop, "Contact Shadow", "Use screen space raytracing to have correct shadowing "
"near occluder, or for small features that does not appear "
"in shadow maps");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "contact_shadow_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "contact_dist");
+ RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_range(prop, 0.0f, 9999.0f);
RNA_def_property_ui_text(prop, "Contact Shadow Distance", "World space distance in which to search for "
"screen space occluder");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "contact_shadow_bias", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "contact_bias");
+ RNA_def_property_float_default(prop, 0.03f);
RNA_def_property_range(prop, 0.001f, 9999.0f);
RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3);
RNA_def_property_ui_text(prop, "Contact Shadow Bias", "Bias to avoid self shadowing");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "contact_shadow_soft_size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "contact_spread");
+ RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_range(prop, 0.0f, 9999.0f);
RNA_def_property_ui_text(prop, "Contact Shadow Soft", "Control how soft the contact shadows will be");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "contact_shadow_thickness", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "contact_thickness");
+ RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_range(prop, 0.0f, 9999.0f);
RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Contact Shadow Thickness", "Pixel thickness used to detect occlusion");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
if (sun) {
prop = RNA_def_property(srna, "shadow_cascade_max_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "cascade_max_dist");
+ RNA_def_property_float_default(prop, 1000.0f);
RNA_def_property_range(prop, 0.0f, 9999.0f);
RNA_def_property_ui_text(prop, "Cascade Max Distance", "End distance of the cascaded shadow map (only in perspective view)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_cascade_count", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "cascade_count");
+ RNA_def_property_int_default(prop, 4);
RNA_def_property_range(prop, 1, 4);
RNA_def_property_ui_text(prop, "Cascade Count", "Number of texture used by the cascaded shadow map");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_cascade_exponent", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "cascade_exponent");
+ RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Exponential Distribution", "Higher value increase resolution towards the viewpoint");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
prop = RNA_def_property(srna, "shadow_cascade_fade", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "cascade_fade");
+ RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Cascade Fade", "How smooth is the transition between each cascade");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
}
}
-static void rna_def_point_lamp(BlenderRNA *brna)
+static void rna_def_point_light(BlenderRNA *brna)
{
StructRNA *srna;
- srna = RNA_def_struct(brna, "PointLamp", "Lamp");
+ srna = RNA_def_struct(brna, "PointLight", "Light");
RNA_def_struct_sdna(srna, "Lamp");
- RNA_def_struct_ui_text(srna, "Point Lamp", "Omnidirectional point lamp");
- RNA_def_struct_ui_icon(srna, ICON_LAMP_POINT);
+ RNA_def_struct_ui_text(srna, "Point Light", "Omnidirectional point Light");
+ RNA_def_struct_ui_icon(srna, ICON_LIGHT_POINT);
- rna_def_lamp_falloff(srna);
- rna_def_lamp_shadow(srna, 0);
+ rna_def_light_falloff(srna);
+ rna_def_light_shadow(srna, 0);
}
-static void rna_def_area_lamp(BlenderRNA *brna)
+static void rna_def_area_light(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
@@ -399,103 +418,107 @@ static void rna_def_area_lamp(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- srna = RNA_def_struct(brna, "AreaLamp", "Lamp");
+ srna = RNA_def_struct(brna, "AreaLight", "Light");
RNA_def_struct_sdna(srna, "Lamp");
- RNA_def_struct_ui_text(srna, "Area Lamp", "Directional area lamp");
- RNA_def_struct_ui_icon(srna, ICON_LAMP_AREA);
+ RNA_def_struct_ui_text(srna, "Area Light", "Directional area Light");
+ RNA_def_struct_ui_icon(srna, ICON_LIGHT_AREA);
- rna_def_lamp_shadow(srna, 0);
- rna_def_lamp_falloff(srna);
+ rna_def_light_shadow(srna, 0);
+ rna_def_light_falloff(srna);
prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "area_shape");
RNA_def_property_enum_items(prop, prop_areashape_items);
- RNA_def_property_ui_text(prop, "Shape", "Shape of the area lamp");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_ui_text(prop, "Shape", "Shape of the area Light");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "area_size");
+ RNA_def_property_float_default(prop, 0.25f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
- RNA_def_property_ui_text(prop, "Size", "Size of the area of the area Lamp, X direction size for Rectangle shapes");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_ui_text(prop, "Size", "Size of the area of the area light, X direction size for rectangle shapes");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_float_sdna(prop, NULL, "area_sizey");
+ RNA_def_property_float_default(prop, 0.25f);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Size Y",
- "Size of the area of the area Lamp in the Y direction for Rectangle shapes");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ "Size of the area of the area light in the Y direction for rectangle shapes");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
}
-static void rna_def_spot_lamp(BlenderRNA *brna)
+static void rna_def_spot_light(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- srna = RNA_def_struct(brna, "SpotLamp", "Lamp");
+ srna = RNA_def_struct(brna, "SpotLight", "Light");
RNA_def_struct_sdna(srna, "Lamp");
- RNA_def_struct_ui_text(srna, "Spot Lamp", "Directional cone lamp");
- RNA_def_struct_ui_icon(srna, ICON_LAMP_SPOT);
+ RNA_def_struct_ui_text(srna, "Spot Light", "Directional cone Light");
+ RNA_def_struct_ui_icon(srna, ICON_LIGHT_SPOT);
- rna_def_lamp_falloff(srna);
- rna_def_lamp_shadow(srna, 0);
+ rna_def_light_falloff(srna);
+ rna_def_light_shadow(srna, 0);
prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE);
RNA_def_property_ui_text(prop, "Square", "Cast a square spot light shape");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "spotblend");
+ RNA_def_property_float_default(prop, 0.15f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "spotsize");
+ RNA_def_property_float_default(prop, DEG2RADF(45.0f));
RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f));
RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
prop = RNA_def_property(srna, "show_cone", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHOW_CONE);
RNA_def_property_ui_text(prop, "Show Cone",
"Draw transparent cone in 3D view to visualize which objects are contained in it");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
}
-static void rna_def_sun_lamp(BlenderRNA *brna)
+static void rna_def_sun_light(BlenderRNA *brna)
{
StructRNA *srna;
- srna = RNA_def_struct(brna, "SunLamp", "Lamp");
+ srna = RNA_def_struct(brna, "SunLight", "Light");
RNA_def_struct_sdna(srna, "Lamp");
- RNA_def_struct_ui_text(srna, "Sun Lamp", "Constant direction parallel ray lamp");
- RNA_def_struct_ui_icon(srna, ICON_LAMP_SUN);
+ RNA_def_struct_ui_text(srna, "Sun Light", "Constant direction parallel ray Light");
+ RNA_def_struct_ui_icon(srna, ICON_LIGHT_SUN);
- rna_def_lamp_shadow(srna, 1);
+ rna_def_light_shadow(srna, 1);
}
-static void rna_def_hemi_lamp(BlenderRNA *brna)
+static void rna_def_hemi_light(BlenderRNA *brna)
{
StructRNA *srna;
- srna = RNA_def_struct(brna, "HemiLamp", "Lamp");
+ srna = RNA_def_struct(brna, "HemiLight", "Light");
RNA_def_struct_sdna(srna, "Lamp");
- RNA_def_struct_ui_text(srna, "Hemi Lamp", "180 degree constant lamp");
- RNA_def_struct_ui_icon(srna, ICON_LAMP_HEMI);
+ RNA_def_struct_ui_text(srna, "Hemi Light", "180 degree constant Light");
+ RNA_def_struct_ui_icon(srna, ICON_LIGHT_HEMI);
}
-void RNA_def_lamp(BlenderRNA *brna)
+void RNA_def_light(BlenderRNA *brna)
{
- rna_def_lamp(brna);
- rna_def_point_lamp(brna);
- rna_def_area_lamp(brna);
- rna_def_spot_lamp(brna);
- rna_def_sun_lamp(brna);
- rna_def_hemi_lamp(brna);
+ rna_def_light(brna);
+ rna_def_point_light(brna);
+ rna_def_area_light(brna);
+ rna_def_spot_light(brna);
+ rna_def_sun_light(brna);
+ rna_def_hemi_light(brna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c
index ace7ac30408..d10471ad896 100644
--- a/source/blender/makesrna/intern/rna_lattice.c
+++ b/source/blender/makesrna/intern/rna_lattice.c
@@ -155,7 +155,7 @@ static void rna_Lattice_update_size(Main *bmain, Scene *scene, PointerRNA *ptr)
rna_Lattice_update_data(bmain, scene, ptr);
}
-static void rna_Lattice_use_outside_set(PointerRNA *ptr, int value)
+static void rna_Lattice_use_outside_set(PointerRNA *ptr, bool value)
{
Lattice *lt = ptr->data;
@@ -236,7 +236,7 @@ static char *rna_LatticePoint_path(PointerRNA *ptr)
return BLI_strdup("");
}
-static int rna_Lattice_is_editmode_get(PointerRNA *ptr)
+static bool rna_Lattice_is_editmode_get(PointerRNA *ptr)
{
Lattice *lt = (Lattice *)ptr->id.data;
return (lt->editlatt != NULL);
diff --git a/source/blender/makesrna/intern/rna_lightprobe.c b/source/blender/makesrna/intern/rna_lightprobe.c
index a14699691a6..f54c01fab8e 100644
--- a/source/blender/makesrna/intern/rna_lightprobe.c
+++ b/source/blender/makesrna/intern/rna_lightprobe.c
@@ -83,6 +83,7 @@ static void rna_def_lightprobe(BlenderRNA *brna)
prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "clipsta");
+ RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
RNA_def_property_ui_text(prop, "Clip Start",
@@ -91,6 +92,7 @@ static void rna_def_lightprobe(BlenderRNA *brna)
prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "clipend");
+ RNA_def_property_float_default(prop, 40.0f);
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
RNA_def_property_ui_text(prop, "Clip End",
@@ -115,11 +117,13 @@ static void rna_def_lightprobe(BlenderRNA *brna)
prop = RNA_def_property(srna, "influence_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "distinf");
+ RNA_def_property_float_default(prop, 2.5f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Influence Distance", "Influence distance of the probe");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Falloff", "Control how fast the probe influence decreases");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
@@ -141,6 +145,7 @@ static void rna_def_lightprobe(BlenderRNA *brna)
prop = RNA_def_property(srna, "parallax_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "distpar");
+ RNA_def_property_float_default(prop, 2.5f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Parallax Radius", "Lowest corner of the parallax bounding box");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
@@ -148,21 +153,25 @@ static void rna_def_lightprobe(BlenderRNA *brna)
/* irradiance grid */
prop = RNA_def_property(srna, "grid_resolution_x", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 1, 256);
+ RNA_def_property_int_default(prop, 4);
RNA_def_property_ui_text(prop, "Resolution X", "Number of sample along the x axis of the volume");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
prop = RNA_def_property(srna, "grid_resolution_y", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 1, 256);
+ RNA_def_property_int_default(prop, 4);
RNA_def_property_ui_text(prop, "Resolution Y", "Number of sample along the y axis of the volume");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
prop = RNA_def_property(srna, "grid_resolution_z", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 1, 256);
+ RNA_def_property_int_default(prop, 4);
RNA_def_property_ui_text(prop, "Resolution Z", "Number of sample along the z axis of the volume");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
prop = RNA_def_property(srna, "visibility_buffer_bias", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vis_bias");
+ RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.001f, 9999.0f);
RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3);
RNA_def_property_ui_text(prop, "Visibility Bias", "Bias for reducing self shadowing");
@@ -170,18 +179,21 @@ static void rna_def_lightprobe(BlenderRNA *brna)
prop = RNA_def_property(srna, "visibility_bleed_bias", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vis_bleedbias");
+ RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Visibility Bleed Bias", "Bias for reducing light-bleed on variance shadow maps");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "visibility_blur", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vis_blur");
+ RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Visibility Blur", "Filter size of the visibilty blur");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "intensity");
+ RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, 3.0f, 1.0, 3);
RNA_def_property_ui_text(prop, "Intensity", "Modify the intensity of the lighting captured by this probe");
@@ -206,11 +218,6 @@ static void rna_def_lightprobe(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Data", "Show captured lighting data into the 3D view for debuging purpose");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
- prop = RNA_def_property(srna, "data_draw_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.05f, 10.0f);
- RNA_def_property_ui_text(prop, "Data Draw Size", "Size of the spheres to debug captured light");
- RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
-
/* common */
rna_def_animdata_common(srna);
}
diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c
index 7b9184eb5df..5e05d37dc8c 100644
--- a/source/blender/makesrna/intern/rna_main.c
+++ b/source/blender/makesrna/intern/rna_main.c
@@ -42,7 +42,7 @@
/* all the list begin functions are added manually here, Main is not in SDNA */
-static int rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr))
+static bool rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr))
{
if (G.fileflags & G_AUTOPACK)
return 1;
@@ -50,7 +50,7 @@ static int rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr))
return 0;
}
-static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), int value)
+static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), bool value)
{
if (value)
G.fileflags |= G_AUTOPACK;
@@ -58,12 +58,12 @@ static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), int value)
G.fileflags &= ~G_AUTOPACK;
}
-static int rna_Main_is_saved_get(PointerRNA *UNUSED(ptr))
+static bool rna_Main_is_saved_get(PointerRNA *UNUSED(ptr))
{
return G.relbase_valid;
}
-static int rna_Main_is_dirty_get(PointerRNA *ptr)
+static bool rna_Main_is_dirty_get(PointerRNA *ptr)
{
/* XXX, not totally nice to do it this way, should store in main ? */
Main *bmain = (Main *)ptr->data;
@@ -107,7 +107,7 @@ static void rna_Main_object_begin(CollectionPropertyIterator *iter, PointerRNA *
rna_iterator_listbase_begin(iter, &bmain->object, NULL);
}
-static void rna_Main_lamp_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static void rna_Main_light_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain = (Main *)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->lamp, NULL);
@@ -353,7 +353,7 @@ void RNA_def_main(BlenderRNA *brna)
{"materials", "Material", "rna_Main_mat_begin", "Materials", "Material data-blocks", RNA_def_main_materials},
{"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group data-blocks", RNA_def_main_node_groups},
{"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh data-blocks", RNA_def_main_meshes},
- {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp data-blocks", RNA_def_main_lamps},
+ {"lights", "Light", "rna_Main_light_begin", "Lights", "Light data-blocks", RNA_def_main_lights},
{"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library data-blocks", RNA_def_main_libraries},
{"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen data-blocks", RNA_def_main_screens},
{"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager data-blocks", RNA_def_main_window_managers},
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index fff53aafcc7..febe74f63c9 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -185,7 +185,7 @@ static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports
BPy_BEGIN_ALLOW_THREADS;
#endif
- WM_window_change_active_scene(bmain, C, win, scene_new);
+ WM_window_set_active_scene(bmain, C, win, scene_new);
#ifdef WITH_PYTHON
BPy_END_ALLOW_THREADS;
@@ -319,7 +319,7 @@ Mesh *rna_Main_meshes_new_from_object(
return BKE_mesh_new_from_object(depsgraph, bmain, sce, ob, apply_modifiers, calc_tessface, calc_undeformed);
}
-static Lamp *rna_Main_lamps_new(Main *bmain, const char *name, int type)
+static Lamp *rna_Main_lights_new(Main *bmain, const char *name, int type)
{
char safe_name[MAX_ID_NAME - 2];
rna_idname_validate(name, safe_name);
@@ -603,7 +603,7 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(objects, object, ID_OB)
RNA_MAIN_ID_TAG_FUNCS_DEF(materials, mat, ID_MA)
RNA_MAIN_ID_TAG_FUNCS_DEF(node_groups, nodetree, ID_NT)
RNA_MAIN_ID_TAG_FUNCS_DEF(meshes, mesh, ID_ME)
-RNA_MAIN_ID_TAG_FUNCS_DEF(lamps, lamp, ID_LA)
+RNA_MAIN_ID_TAG_FUNCS_DEF(lights, lamp, ID_LA)
RNA_MAIN_ID_TAG_FUNCS_DEF(libraries, library, ID_LI)
RNA_MAIN_ID_TAG_FUNCS_DEF(screens, screen, ID_SCR)
RNA_MAIN_ID_TAG_FUNCS_DEF(window_managers, wm, ID_WM)
@@ -894,42 +894,43 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
-void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop)
+
+void RNA_def_main_lights(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- RNA_def_property_srna(cprop, "BlendDataLamps");
- srna = RNA_def_struct(brna, "BlendDataLamps", NULL);
+ RNA_def_property_srna(cprop, "BlendDataLights");
+ srna = RNA_def_struct(brna, "BlendDataLights", NULL);
RNA_def_struct_sdna(srna, "Main");
- RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps");
+ RNA_def_struct_ui_text(srna, "Main Lights", "Collection of lights");
- func = RNA_def_function(srna, "new", "rna_Main_lamps_new");
- RNA_def_function_ui_description(func, "Add a new lamp to the main database");
- parm = RNA_def_string(func, "name", "Lamp", 0, "", "New name for the data-block");
+ func = RNA_def_function(srna, "new", "rna_Main_lights_new");
+ RNA_def_function_ui_description(func, "Add a new light to the main database");
+ parm = RNA_def_string(func, "name", "Light", 0, "", "New name for the data-block");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_enum(func, "type", rna_enum_lamp_type_items, 0, "Type", "The type of texture to add");
+ parm = RNA_def_enum(func, "type", rna_enum_light_type_items, 0, "Type", "The type of texture to add");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* return type */
- parm = RNA_def_pointer(func, "lamp", "Lamp", "", "New lamp data-block");
+ parm = RNA_def_pointer(func, "light", "Light", "", "New light data-block");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile");
- parm = RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove");
+ RNA_def_function_ui_description(func, "Remove a light from the current blendfile");
+ parm = RNA_def_pointer(func, "light", "Light", "", "Light to remove");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "",
- "Unlink all usages of this lamp before deleting it "
- "(WARNING: will also delete objects instancing that lamp data)");
+ "Unlink all usages of this Light before deleting it "
+ "(WARNING: will also delete objects instancing that light data)");
RNA_def_boolean(func, "do_id_user", true, "",
- "Decrement user counter of all datablocks used by this lamp data");
+ "Decrement user counter of all datablocks used by this light data");
RNA_def_boolean(func, "do_ui_user", true, "",
- "Make sure interface does not reference this lamp data");
+ "Make sure interface does not reference this light data");
- func = RNA_def_function(srna, "tag", "rna_Main_lamps_tag");
+ func = RNA_def_function(srna, "tag", "rna_Main_lights_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 26c281ad9e1..0a8ea99b8fb 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -148,8 +148,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
Object *obedit = NULL;
{
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
}
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index d664415b8ad..92b7fd1760f 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -208,10 +208,10 @@ static void rna_MeshAnyLayer_name_set(PointerRNA *ptr, const char *value)
rna_cd_layer_name_set(cd, (CustomDataLayer *)ptr->data, value);
}
-static int rna_Mesh_has_custom_normals_get(PointerRNA *ptr)
+static bool rna_Mesh_has_custom_normals_get(PointerRNA *ptr)
{
Mesh *me = ptr->data;
- return (int)BKE_mesh_has_custom_loop_normals(me);
+ return BKE_mesh_has_custom_loop_normals(me);
}
/* -------------------------------------------------------------------- */
@@ -790,7 +790,7 @@ 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)
+static bool rna_MEdge_freestyle_edge_mark_get(PointerRNA *ptr)
{
Mesh *me = rna_mesh(ptr);
MEdge *medge = (MEdge *)ptr->data;
@@ -799,7 +799,7 @@ static int rna_MEdge_freestyle_edge_mark_get(PointerRNA *ptr)
return fed && (fed->flag & FREESTYLE_EDGE_MARK) != 0;
}
-static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, int value)
+static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, bool value)
{
Mesh *me = rna_mesh(ptr);
MEdge *medge = (MEdge *)ptr->data;
@@ -816,7 +816,7 @@ static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, int value)
}
}
-static int rna_MPoly_freestyle_face_mark_get(PointerRNA *ptr)
+static bool rna_MPoly_freestyle_face_mark_get(PointerRNA *ptr)
{
Mesh *me = rna_mesh(ptr);
MPoly *mpoly = (MPoly *)ptr->data;
@@ -881,32 +881,32 @@ static int rna_MeshUVLoopLayer_data_length(PointerRNA *ptr)
return (me->edit_btmesh) ? 0 : me->totloop;
}
-static int rna_MeshUVLoopLayer_active_render_get(PointerRNA *ptr)
+static bool rna_MeshUVLoopLayer_active_render_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV, 1);
}
-static int rna_MeshUVLoopLayer_active_get(PointerRNA *ptr)
+static bool rna_MeshUVLoopLayer_active_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV, 0);
}
-static int rna_MeshUVLoopLayer_clone_get(PointerRNA *ptr)
+static bool rna_MeshUVLoopLayer_clone_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_clone_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV);
}
-static void rna_MeshUVLoopLayer_active_render_set(PointerRNA *ptr, int value)
+static void rna_MeshUVLoopLayer_active_render_set(PointerRNA *ptr, bool value)
{
rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV, 1);
}
-static void rna_MeshUVLoopLayer_active_set(PointerRNA *ptr, int value)
+static void rna_MeshUVLoopLayer_active_set(PointerRNA *ptr, bool value)
{
rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV, 0);
}
-static void rna_MeshUVLoopLayer_clone_set(PointerRNA *ptr, int value)
+static void rna_MeshUVLoopLayer_clone_set(PointerRNA *ptr, bool value)
{
rna_CustomDataLayer_clone_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV);
}
@@ -932,22 +932,22 @@ static int rna_MeshTextureFaceLayer_data_length(PointerRNA *ptr)
return (me->edit_btmesh) ? 0 : me->totface;
}
-static int rna_MeshTextureFaceLayer_active_render_get(PointerRNA *ptr)
+static bool rna_MeshTextureFaceLayer_active_render_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE, 1);
}
-static int rna_MeshTextureFaceLayer_active_get(PointerRNA *ptr)
+static bool rna_MeshTextureFaceLayer_active_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE, 0);
}
-static int rna_MeshTextureFaceLayer_clone_get(PointerRNA *ptr)
+static bool rna_MeshTextureFaceLayer_clone_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_clone_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE);
}
-static void rna_MeshTextureFaceLayer_active_render_set(PointerRNA *ptr, int value)
+static void rna_MeshTextureFaceLayer_active_render_set(PointerRNA *ptr, bool value)
{
rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MTFACE, 1);
}
@@ -981,17 +981,17 @@ static int rna_MeshColorLayer_data_length(PointerRNA *ptr)
return me->totface;
}
-static int rna_MeshColorLayer_active_render_get(PointerRNA *ptr)
+static bool rna_MeshColorLayer_active_render_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MCOL, 1);
}
-static int rna_MeshColorLayer_active_get(PointerRNA *ptr)
+static bool rna_MeshColorLayer_active_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MCOL, 0);
}
-static void rna_MeshColorLayer_active_render_set(PointerRNA *ptr, int value)
+static void rna_MeshColorLayer_active_render_set(PointerRNA *ptr, bool value)
{
rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MCOL, 1);
}
@@ -1018,22 +1018,22 @@ static int rna_MeshLoopColorLayer_data_length(PointerRNA *ptr)
return (me->edit_btmesh) ? 0 : me->totloop;
}
-static int rna_MeshLoopColorLayer_active_render_get(PointerRNA *ptr)
+static bool rna_MeshLoopColorLayer_active_render_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPCOL, 1);
}
-static int rna_MeshLoopColorLayer_active_get(PointerRNA *ptr)
+static bool rna_MeshLoopColorLayer_active_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPCOL, 0);
}
-static void rna_MeshLoopColorLayer_active_render_set(PointerRNA *ptr, int value)
+static void rna_MeshLoopColorLayer_active_render_set(PointerRNA *ptr, bool value)
{
rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPCOL, 1);
}
-static void rna_MeshLoopColorLayer_active_set(PointerRNA *ptr, int value)
+static void rna_MeshLoopColorLayer_active_set(PointerRNA *ptr, bool value)
{
rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPCOL, 0);
}
@@ -1840,7 +1840,7 @@ static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, ReportList *
}
-static int rna_Mesh_is_editmode_get(PointerRNA *ptr)
+static bool rna_Mesh_is_editmode_get(PointerRNA *ptr)
{
Mesh *me = rna_mesh(ptr);
return (me->edit_btmesh != NULL);
diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c
index cdecba0760c..af674cd2763 100644
--- a/source/blender/makesrna/intern/rna_meta.c
+++ b/source/blender/makesrna/intern/rna_meta.c
@@ -160,7 +160,7 @@ static void rna_MetaBall_elements_clear(MetaBall *mb)
}
}
-static int rna_Meta_is_editmode_get(PointerRNA *ptr)
+static bool rna_Meta_is_editmode_get(PointerRNA *ptr)
{
MetaBall *mb = ptr->id.data;
return (mb->editelems != NULL);
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 70bd685dc56..f0898064860 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -50,6 +50,7 @@
#include "BKE_mesh_mapping.h"
#include "BKE_mesh_remap.h"
#include "BKE_multires.h"
+#include "BKE_ocean.h"
#include "BKE_smoke.h" /* For smokeModifier_free & smokeModifier_createType */
#include "RNA_access.h"
@@ -657,7 +658,7 @@ static void rna_MultiresModifier_level_range(PointerRNA *ptr, int *min, int *max
*max = max_ii(0, mmd->totlvl); /* intentionally _not_ -1 */
}
-static int rna_MultiresModifier_external_get(PointerRNA *ptr)
+static bool rna_MultiresModifier_external_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
Mesh *me = ob->data;
@@ -706,7 +707,7 @@ static void rna_ShrinkwrapModifier_face_cull_set(struct PointerRNA *ptr, int val
(swm->shrinkOpts & ~(MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) | value;
}
-static int rna_MeshDeformModifier_is_bound_get(PointerRNA *ptr)
+static bool rna_MeshDeformModifier_is_bound_get(PointerRNA *ptr)
{
return (((MeshDeformModifierData *)ptr->data)->bindcagecos != NULL);
}
@@ -720,7 +721,7 @@ static PointerRNA rna_SoftBodyModifier_settings_get(PointerRNA *ptr)
static PointerRNA rna_SoftBodyModifier_point_cache_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
- return rna_pointer_inherit_refine(ptr, &RNA_PointCache, ob->soft->pointcache);
+ return rna_pointer_inherit_refine(ptr, &RNA_PointCache, ob->soft->shared->pointcache);
}
static PointerRNA rna_CollisionModifier_settings_get(PointerRNA *ptr)
@@ -743,26 +744,7 @@ static void rna_OceanModifier_init_update(Main *bmain, Scene *scene, PointerRNA
{
OceanModifierData *omd = (OceanModifierData *)ptr->data;
- omd->refresh |= (MOD_OCEAN_REFRESH_RESET | MOD_OCEAN_REFRESH_SIM | MOD_OCEAN_REFRESH_CLEAR_CACHE);
-
- rna_Modifier_update(bmain, scene, ptr);
-}
-
-static void rna_OceanModifier_sim_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- OceanModifierData *omd = (OceanModifierData *)ptr->data;
-
- omd->refresh |= MOD_OCEAN_REFRESH_SIM;
-
- rna_Modifier_update(bmain, scene, ptr);
-}
-
-static void rna_OceanModifier_topology_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- OceanModifierData *omd = (OceanModifierData *)ptr->data;
-
- omd->refresh |= MOD_OCEAN_REFRESH_TOPOLOGY;
-
+ BKE_ocean_free_modifier_cache(omd);
rna_Modifier_update(bmain, scene, ptr);
}
@@ -776,12 +758,11 @@ static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value)
if ((old_value == 0.0f && value > 0.0f) ||
(old_value > 0.0f && value == 0.0f))
{
- omd->refresh |= MOD_OCEAN_REFRESH_RESET;
- omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE;
+ BKE_ocean_free_modifier_cache(omd);
}
}
-static int rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr)
+static bool rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr)
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)ptr->data;
return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->cache_system != NULL));
@@ -1130,13 +1111,13 @@ static void rna_CorrectiveSmoothModifier_rest_source_update(Main *bmain, Scene *
rna_CorrectiveSmoothModifier_update(bmain, scene, ptr);
}
-static int rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA *ptr)
+static bool rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA *ptr)
{
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)ptr->data;
return (csmd->bind_coords != NULL);
}
-static int rna_SurfaceDeformModifier_is_bound_get(PointerRNA *ptr)
+static bool rna_SurfaceDeformModifier_is_bound_get(PointerRNA *ptr)
{
return (((SurfaceDeformModifierData *)ptr->data)->verts != NULL);
}
@@ -1198,8 +1179,8 @@ static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr, co
static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[])
{
static const EnumPropertyItem prop_subdivision_type_items[] = {
- {0, "CATMULL_CLARK", 0, "Catmull-Clark", ""},
- {1, "SIMPLE", 0, "Simple", ""},
+ {SUBSURF_TYPE_CATMULL_CLARK, "CATMULL_CLARK", 0, "Catmull-Clark", ""},
+ {SUBSURF_TYPE_SIMPLE, "SIMPLE", 0, "Simple", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -1331,7 +1312,7 @@ static void rna_def_modifier_warp(BlenderRNA *brna)
prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
- RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve");
+ RNA_def_property_ui_text(prop, "Falloff Curve", "Custom falloff curve");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE);
@@ -1922,7 +1903,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna)
prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
- RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve");
+ RNA_def_property_ui_text(prop, "Falloff Curve", "Custom falloff curve");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "center", PROP_FLOAT, PROP_NONE);
@@ -4097,7 +4078,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_ui_text(prop, "Size", "Surface scale factor (does not affect the height of the waves)");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, -1);
- RNA_def_property_update(prop, 0, "rna_OceanModifier_topology_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "repeat_x", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "repeat_x");
@@ -4105,7 +4086,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_range(prop, 1, 1024);
RNA_def_property_ui_range(prop, 1, 100, 1, -1);
RNA_def_property_ui_text(prop, "Repeat X", "Repetitions of the generated surface in X");
- RNA_def_property_update(prop, 0, "rna_OceanModifier_topology_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "repeat_y", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "repeat_y");
@@ -4113,7 +4094,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_range(prop, 1, 1024);
RNA_def_property_ui_range(prop, 1, 100, 1, -1);
RNA_def_property_ui_text(prop, "Repeat Y", "Repetitions of the generated surface in Y");
- RNA_def_property_update(prop, 0, "rna_OceanModifier_topology_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_normals", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_OCEAN_GENERATE_NORMALS);
@@ -4177,7 +4158,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
prop = RNA_def_property(srna, "wave_scale", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "wave_scale");
RNA_def_property_ui_text(prop, "Wave Scale", "Scale of the displacement effect");
- RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "depth", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "depth");
@@ -4209,13 +4190,13 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
"Choppiness of the wave's crest (adds some horizontal component to the displacement)");
RNA_def_property_ui_range(prop, 0.0, 4.0, 3, -1);
RNA_def_property_float_funcs(prop, NULL, "rna_OceanModifier_ocean_chop_set", NULL);
- RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "time");
RNA_def_property_ui_text(prop, "Time", "Current time of the simulation");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, -1);
- RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "random_seed", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "seed");
diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c
index aa976775ad1..aded4229a3c 100644
--- a/source/blender/makesrna/intern/rna_movieclip.c
+++ b/source/blender/makesrna/intern/rna_movieclip.c
@@ -251,7 +251,7 @@ static void rna_def_moviecliUser(BlenderRNA *brna)
prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "render_size");
RNA_def_property_enum_items(prop, clip_render_size_items);
- RNA_def_property_ui_text(prop, "Proxy render size",
+ RNA_def_property_ui_text(prop, "Proxy Render Size",
"Draw preview using full resolution or different proxy resolutions");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update");
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 404d9089cd9..025bc705560 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -253,7 +253,7 @@ static void rna_NlaStrip_blend_out_set(PointerRNA *ptr, float value)
data->blendout = value;
}
-static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, int value)
+static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, bool value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
@@ -329,7 +329,7 @@ static void rna_NlaStrip_action_end_frame_set(PointerRNA *ptr, float value)
BKE_nlastrip_recalculate_bounds(data);
}
-static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, int value)
+static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, bool value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
@@ -342,7 +342,7 @@ static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, int value)
data->flag &= ~NLASTRIP_FLAG_USR_INFLUENCE;
}
-static void rna_NlaStrip_animated_time_set(PointerRNA *ptr, int value)
+static void rna_NlaStrip_animated_time_set(PointerRNA *ptr, bool value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
@@ -433,7 +433,7 @@ static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *report
/* Set the 'solo' setting for the given NLA-track, making sure that it is the only one
* that has this status in its AnimData block.
*/
-static void rna_NlaTrack_solo_set(PointerRNA *ptr, int value)
+static void rna_NlaTrack_solo_set(PointerRNA *ptr, bool value)
{
NlaTrack *data = (NlaTrack *)ptr->data;
AnimData *adt = BKE_animdata_from_id(ptr->id.data);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 492335d4d25..b9a8f306baf 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -144,6 +144,10 @@ const EnumPropertyItem rna_enum_node_math_items[] = {
{NODE_MATH_MOD, "MODULO", 0, "Modulo", ""},
{NODE_MATH_ABS, "ABSOLUTE", 0, "Absolute", ""},
{NODE_MATH_ATAN2, "ARCTAN2", 0, "Arctan2", ""},
+ {NODE_MATH_FLOOR, "FLOOR", 0, "Floor", ""},
+ {NODE_MATH_CEIL, "CEIL", 0, "Ceil", ""},
+ {NODE_MATH_FRACT, "FRACT", 0, "Fract", ""},
+ {NODE_MATH_SQRT, "SQRT", 0, "Square Root", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -175,6 +179,14 @@ static const EnumPropertyItem node_sampler_type_items[] = {
{2, "BICUBIC", 0, "Bicubic", ""},
{0, NULL, 0, NULL, NULL}
};
+
+
+static const EnumPropertyItem prop_shader_output_target_items[] = {
+ {SHD_OUTPUT_ALL, "ALL", 0, "All", "Use shaders for all renderers and viewports, unless there exists a more specific output"},
+ {SHD_OUTPUT_EEVEE, "EEVEE", 0, "Eevee", "Use shaders for Eevee renderer"},
+ {SHD_OUTPUT_CYCLES, "CYCLES", 0, "Cycles", "Use shaders for Cycles renderer"},
+ {0, NULL, 0, NULL, NULL}
+};
#endif
#ifdef RNA_RUNTIME
@@ -1091,7 +1103,7 @@ static void rna_NodeTree_interface_update(bNodeTree *ntree, bContext *C)
/* ******** NodeLink ******** */
-static int rna_NodeLink_is_hidden_get(PointerRNA *ptr)
+static bool rna_NodeLink_is_hidden_get(PointerRNA *ptr)
{
bNodeLink *link = ptr->data;
return nodeLinkIsHidden(link);
@@ -1592,7 +1604,7 @@ static void rna_Node_socket_value_update(ID *id, bNode *node, bContext *C)
ED_node_tag_update_nodetree(CTX_data_main(C), (bNodeTree *)id, node);
}
-static void rna_Node_select_set(PointerRNA *ptr, int value)
+static void rna_Node_select_set(PointerRNA *ptr, bool value)
{
bNode *node = (bNode *)ptr->data;
nodeSetSelected(node, value);
@@ -1962,7 +1974,7 @@ static void rna_NodeSocket_update(Main *bmain, Scene *UNUSED(scene), PointerRNA
}
}
-static int rna_NodeSocket_is_output_get(PointerRNA *ptr)
+static bool rna_NodeSocket_is_output_get(PointerRNA *ptr)
{
bNodeSocket *sock = ptr->data;
return sock->in_out == SOCK_OUT;
@@ -1974,7 +1986,7 @@ static void rna_NodeSocket_link_limit_set(PointerRNA *ptr, int value)
sock->limit = (value == 0 ? 0xFFF : value);
}
-static void rna_NodeSocket_hide_set(PointerRNA *ptr, int value)
+static void rna_NodeSocket_hide_set(PointerRNA *ptr, bool value)
{
bNodeSocket *sock = (bNodeSocket *)ptr->data;
@@ -2673,7 +2685,7 @@ static const EnumPropertyItem *rna_Node_image_layer_itemf(bContext *UNUSED(C), P
return item;
}
-static int rna_Node_image_has_layers_get(PointerRNA *ptr)
+static bool rna_Node_image_has_layers_get(PointerRNA *ptr)
{
bNode *node = (bNode *)ptr->data;
Image *ima = (Image *)node->id;
@@ -2683,7 +2695,7 @@ static int rna_Node_image_has_layers_get(PointerRNA *ptr)
return RE_layers_have_name(ima->rr);
}
-static int rna_Node_image_has_views_get(PointerRNA *ptr)
+static bool rna_Node_image_has_views_get(PointerRNA *ptr)
{
bNode *node = (bNode *)ptr->data;
Image *ima = (Image *)node->id;
@@ -2862,6 +2874,48 @@ static void rna_NodeColorBalance_update_cdl(Main *bmain, Scene *scene, PointerRN
rna_Node_update(bmain, scene, ptr);
}
+static void rna_NodeCryptomatte_matte_get(PointerRNA *ptr, char *value)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeCryptomatte *nc = node->storage;
+
+ strcpy(value, (nc->matte_id) ? nc->matte_id : "");
+}
+
+static int rna_NodeCryptomatte_matte_length(PointerRNA *ptr)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeCryptomatte *nc = node->storage;
+
+ return (nc->matte_id) ? strlen(nc->matte_id) : 0;
+}
+
+static void rna_NodeCryptomatte_matte_set(PointerRNA *ptr, const char *value)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeCryptomatte *nc = node->storage;
+
+ if (nc->matte_id)
+ MEM_freeN(nc->matte_id);
+
+ if (value && value[0])
+ nc->matte_id = BLI_strdup(value);
+ else
+ nc->matte_id = NULL;
+}
+
+static void rna_NodeCryptomatte_update_add(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ ntreeCompositCryptomatteSyncFromAdd(ptr->id.data, ptr->data);
+ rna_Node_update(bmain, scene, ptr);
+}
+
+static void rna_NodeCryptomatte_update_remove(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ ntreeCompositCryptomatteSyncFromRemove(ptr->id.data, ptr->data);
+ rna_Node_update(bmain, scene, ptr);
+}
+
/* ******** Node Socket Types ******** */
static PointerRNA rna_NodeOutputFile_slot_layer_get(CollectionPropertyIterator *iter)
@@ -3037,16 +3091,7 @@ static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *p
ED_node_tag_update_nodetree(bmain, ntree, node);
}
-static void rna_ShaderNodePrincipled_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- bNodeTree *ntree = (bNodeTree *)ptr->id.data;
- bNode *node = (bNode *)ptr->data;
-
- nodeUpdate(ntree, node);
- rna_Node_update(bmain, scene, ptr);
-}
-
-static void rna_ShaderNodeSubsurface_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_ShaderNode_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bNodeTree *ntree = (bNodeTree *)ptr->id.data;
bNode *node = (bNode *)ptr->data;
@@ -3294,6 +3339,13 @@ static const EnumPropertyItem node_hair_items[] = {
{0, NULL, 0, NULL, NULL}
};
+static const EnumPropertyItem node_principled_hair_items[] = {
+ {SHD_PRINCIPLED_HAIR_DIRECT_ABSORPTION, "ABSORPTION", 0, "Absorption coefficient", "Directly set the absorption coefficient sigma_a. This is not the most intuitive way to color hair."},
+ {SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION, "MELANIN", 0, "Melanin concentration", "Define the melanin concentrations below to get the most realistic-looking hair. You can get the concentrations for different types of hair online."},
+ {SHD_PRINCIPLED_HAIR_REFLECTANCE, "COLOR", 0, "Direct coloring", "Choose the color of your preference, and the shader will approximate the absorption coefficient to render lookalike hair."},
+ {0, NULL, 0, NULL, NULL}
+};
+
static const EnumPropertyItem node_script_mode_items[] = {
{NODE_SCRIPT_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text data-block"},
{NODE_SCRIPT_EXTERNAL, "EXTERNAL", 0, "External", "Use external .osl or .oso file"},
@@ -3536,6 +3588,12 @@ static void def_sh_output(StructRNA *srna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_DO_OUTPUT);
RNA_def_property_ui_text(prop, "Active Output", "True if this node is used as the active output");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "target", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, prop_shader_output_target_items);
+ RNA_def_property_ui_text(prop, "Target", "Which renderer and viewport shading types to use the shaders for");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
static void def_sh_output_linestyle(StructRNA *srna)
@@ -3923,6 +3981,23 @@ static void def_sh_tex_voronoi(StructRNA *srna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem prop_distance_items[] = {
+ { SHD_VORONOI_DISTANCE, "DISTANCE", 0, "Distance", "Distance" },
+ { SHD_VORONOI_MANHATTAN, "MANHATTAN", 0, "Manhattan", "Manhattan (city block) distance" },
+ { SHD_VORONOI_CHEBYCHEV, "CHEBYCHEV", 0, "Chebychev", "Chebychev distance" },
+ { SHD_VORONOI_MINKOWSKI, "MINKOWSKI", 0, "Minkowski", "Minkowski distance" },
+ { 0, NULL, 0, NULL, NULL }
+ };
+
+ static EnumPropertyItem prop_feature_items[] = {
+ { SHD_VORONOI_F1, "F1", 0, "Closest", "Closest point" },
+ { SHD_VORONOI_F2, "F2", 0, "2nd Closest", "2nd closest point" },
+ { SHD_VORONOI_F3, "F3", 0, "3rd Closest", "3rd closest point" },
+ { SHD_VORONOI_F4, "F4", 0, "4th Closest", "4th closest point" },
+ { SHD_VORONOI_F2F1, "F2F1", 0, "Crackle", "Difference between 2nd and 1st closest point" },
+ { 0, NULL, 0, NULL, NULL }
+ };
+
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeTexVoronoi", "storage");
@@ -3933,6 +4008,18 @@ static void def_sh_tex_voronoi(StructRNA *srna)
RNA_def_property_enum_items(prop, prop_coloring_items);
RNA_def_property_ui_text(prop, "Coloring", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "distance", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "distance");
+ RNA_def_property_enum_items(prop, prop_distance_items);
+ RNA_def_property_ui_text(prop, "Distance metric", "");
+ RNA_def_property_update(prop, 0, "rna_ShaderNode_socket_update");
+
+ prop = RNA_def_property(srna, "feature", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "feature");
+ RNA_def_property_enum_items(prop, prop_feature_items);
+ RNA_def_property_ui_text(prop, "Feature Output", "");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_wave(StructRNA *srna)
@@ -4194,13 +4281,13 @@ static void def_principled(StructRNA *srna)
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_principled_distribution_items);
RNA_def_property_ui_text(prop, "Distribution", "");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodePrincipled_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update");
prop = RNA_def_property(srna, "subsurface_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom2");
RNA_def_property_enum_items(prop, node_subsurface_method_items);
RNA_def_property_ui_text(prop, "Subsurface Method", "Method for rendering subsurface scattering");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodePrincipled_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update");
}
static void def_refraction(StructRNA *srna)
@@ -4257,6 +4344,21 @@ static void def_hair(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+/* RNA initialization for the custom property. */
+static void def_hair_principled(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "parametrization", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_ui_text(prop, "Color parametrization", "Select the shader's color parametrization");
+ RNA_def_property_enum_items(prop, node_principled_hair_items);
+ RNA_def_property_enum_default(prop, SHD_PRINCIPLED_HAIR_REFLECTANCE);
+ /* Upon editing, update both the node data AND the UI representation */
+ /* (This effectively shows/hides the relevant sockets) */
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update");
+}
+
static void def_sh_uvmap(StructRNA *srna)
{
PropertyRNA *prop;
@@ -4435,7 +4537,7 @@ static void def_sh_subsurface(StructRNA *srna)
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, prop_subsurface_falloff_items);
RNA_def_property_ui_text(prop, "Falloff", "Function to determine how much light nearby points contribute based on their distance to the shading point");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeSubsurface_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update");
}
static void def_sh_tex_ies(StructRNA *srna)
@@ -6867,6 +6969,33 @@ static void def_cmp_sunbeams(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_cmp_cryptomatte(StructRNA *srna)
+{
+ PropertyRNA *prop;
+ static float default_1[3] = {1.f, 1.f, 1.f};
+
+ RNA_def_struct_sdna_from(srna, "NodeCryptomatte", "storage");
+ prop = RNA_def_property(srna, "matte_id", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(
+ prop, "rna_NodeCryptomatte_matte_get", "rna_NodeCryptomatte_matte_length",
+ "rna_NodeCryptomatte_matte_set");
+ RNA_def_property_ui_text(prop, "Matte Objects", "List of object and material crypto IDs to include in matte");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+
+ prop = RNA_def_property(srna, "add", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_float_array_default(prop, default_1);
+ RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Add", "Add object or material to matte, by picking a color from the Pick output");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_add");
+
+ prop = RNA_def_property(srna, "remove", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_float_array_default(prop, default_1);
+ RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Remove", "Remove object or material from matte, by picking a color from the Pick output");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_remove");
+}
+
/* -- Texture Nodes --------------------------------------------------------- */
static void def_tex_output(StructRNA *srna)
@@ -7742,12 +7871,6 @@ static void rna_def_node(BlenderRNA *brna)
{NODE_CUSTOM, "CUSTOM", 0, "Custom", "Custom Node"},
{0, NULL, 0, NULL, NULL}};
- static const EnumPropertyItem node_shading_compatibilities[] = {
- {NODE_OLD_SHADING, "OLD_SHADING", 0, "Old Shading", "Old shading system compatibility"},
- {NODE_NEW_SHADING, "NEW_SHADING", 0, "New Shading", "New shading system compatibility"},
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "Node", NULL);
RNA_def_struct_ui_text(srna, "Node", "Node in a node tree");
RNA_def_struct_sdna(srna, "bNode");
@@ -7887,12 +8010,6 @@ static void rna_def_node(BlenderRNA *brna)
parm = RNA_def_boolean(func, "result", false, "Result", "");
RNA_def_function_return(func, parm);
- prop = RNA_def_property(srna, "shading_compatibility", PROP_ENUM, PROP_NONE);
- RNA_def_property_flag(prop, PROP_ENUM_FLAG);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_enum_sdna(prop, NULL, "typeinfo->compatibility");
- RNA_def_property_enum_items(prop, node_shading_compatibilities);
-
/* registration */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "typeinfo->idname");
@@ -8377,12 +8494,21 @@ static void rna_def_composite_nodetree(BlenderRNA *brna)
static void rna_def_shader_nodetree(BlenderRNA *brna)
{
StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
srna = RNA_def_struct(brna, "ShaderNodeTree", "NodeTree");
RNA_def_struct_ui_text(srna, "Shader Node Tree",
"Node tree consisting of linked nodes used for materials (and other shading data-blocks)");
RNA_def_struct_sdna(srna, "bNodeTree");
RNA_def_struct_ui_icon(srna, ICON_MATERIAL);
+
+ func = RNA_def_function(srna, "get_output_node", "ntreeShaderOutputNode");
+ RNA_def_function_ui_description(func, "Return active shader output node for the specified target");
+ parm = RNA_def_enum(func, "target", prop_shader_output_target_items, SHD_OUTPUT_ALL, "Target", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "node", "ShaderNode", "Node", "");
+ RNA_def_function_return(func, parm);
}
static void rna_def_texture_nodetree(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 04f4c41659d..ac1a6d512c3 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -146,7 +146,7 @@ const EnumPropertyItem rna_enum_object_type_items[] = {
{OB_EMPTY, "EMPTY", 0, "Empty", ""},
{0, "", 0, NULL, NULL},
{OB_CAMERA, "CAMERA", 0, "Camera", ""},
- {OB_LAMP, "LAMP", 0, "Lamp", ""},
+ {OB_LAMP, "LIGHT", 0, "Light", ""},
{OB_SPEAKER, "SPEAKER", 0, "Speaker", ""},
{OB_LIGHTPROBE, "LIGHT_PROBE", 0, "Probe", ""},
{0, NULL, 0, NULL, NULL}
@@ -356,10 +356,12 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
ob->data = id;
test_object_materials(G_MAIN, ob, id);
- if (GS(id->name) == ID_CU)
+ if (GS(id->name) == ID_CU) {
BKE_curve_type_test(ob);
- else if (ob->type == OB_ARMATURE)
- BKE_pose_rebuild(ob, ob->data);
+ }
+ else if (ob->type == OB_ARMATURE) {
+ BKE_pose_rebuild(G_MAIN, ob, ob->data);
+ }
}
}
@@ -375,7 +377,7 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
case OB_SURF: return &RNA_Curve;
case OB_FONT: return &RNA_Curve;
case OB_MBALL: return &RNA_MetaBall;
- case OB_LAMP: return &RNA_Lamp;
+ case OB_LAMP: return &RNA_Light;
case OB_CAMERA: return &RNA_Camera;
case OB_LATTICE: return &RNA_Lattice;
case OB_ARMATURE: return &RNA_Armature;
@@ -1446,7 +1448,7 @@ bool rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
return ((Object *)value.id.data)->type == OB_CAMERA;
}
-bool rna_Lamp_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
+bool rna_Light_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
{
return ((Object *)value.id.data)->type == OB_LAMP;
}
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index b902fa73334..1a2b3854668 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -517,7 +517,7 @@ void RNA_api_object(StructRNA *srna)
/* Camera-related operations */
func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera");
RNA_def_function_ui_description(func, "Generate the camera projection matrix of this object "
- "(mostly useful for Camera and Lamp types)");
+ "(mostly useful for Camera and Light types)");
parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "",
"Depsgraph to get evaluated data from");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index b79dee63136..97f1985b48b 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -290,52 +290,52 @@ static char *rna_CollisionSettings_path(PointerRNA *UNUSED(ptr))
#endif
}
-static int rna_SoftBodySettings_use_edges_get(PointerRNA *ptr)
+static bool rna_SoftBodySettings_use_edges_get(PointerRNA *ptr)
{
Object *data = (Object *)(ptr->id.data);
return (((data->softflag) & OB_SB_EDGES) != 0);
}
-static void rna_SoftBodySettings_use_edges_set(PointerRNA *ptr, int value)
+static void rna_SoftBodySettings_use_edges_set(PointerRNA *ptr, bool value)
{
Object *data = (Object *)(ptr->id.data);
if (value) data->softflag |= OB_SB_EDGES;
else data->softflag &= ~OB_SB_EDGES;
}
-static int rna_SoftBodySettings_use_goal_get(PointerRNA *ptr)
+static bool rna_SoftBodySettings_use_goal_get(PointerRNA *ptr)
{
Object *data = (Object *)(ptr->id.data);
return (((data->softflag) & OB_SB_GOAL) != 0);
}
-static void rna_SoftBodySettings_use_goal_set(PointerRNA *ptr, int value)
+static void rna_SoftBodySettings_use_goal_set(PointerRNA *ptr, bool value)
{
Object *data = (Object *)(ptr->id.data);
if (value) data->softflag |= OB_SB_GOAL;
else data->softflag &= ~OB_SB_GOAL;
}
-static int rna_SoftBodySettings_stiff_quads_get(PointerRNA *ptr)
+static bool rna_SoftBodySettings_stiff_quads_get(PointerRNA *ptr)
{
Object *data = (Object *)(ptr->id.data);
return (((data->softflag) & OB_SB_QUADS) != 0);
}
-static void rna_SoftBodySettings_stiff_quads_set(PointerRNA *ptr, int value)
+static void rna_SoftBodySettings_stiff_quads_set(PointerRNA *ptr, bool value)
{
Object *data = (Object *)(ptr->id.data);
if (value) data->softflag |= OB_SB_QUADS;
else data->softflag &= ~OB_SB_QUADS;
}
-static int rna_SoftBodySettings_self_collision_get(PointerRNA *ptr)
+static bool rna_SoftBodySettings_self_collision_get(PointerRNA *ptr)
{
Object *data = (Object *)(ptr->id.data);
return (((data->softflag) & OB_SB_SELF) != 0);
}
-static void rna_SoftBodySettings_self_collision_set(PointerRNA *ptr, int value)
+static void rna_SoftBodySettings_self_collision_set(PointerRNA *ptr, bool value)
{
Object *data = (Object *)(ptr->id.data);
if (value) data->softflag |= OB_SB_SELF;
@@ -360,26 +360,26 @@ static void rna_SoftBodySettings_new_aero_set(PointerRNA *ptr, int value)
data->softflag &= ~OB_SB_AERO_ANGLE;
}
-static int rna_SoftBodySettings_face_collision_get(PointerRNA *ptr)
+static bool rna_SoftBodySettings_face_collision_get(PointerRNA *ptr)
{
Object *data = (Object *)(ptr->id.data);
return (((data->softflag) & OB_SB_FACECOLL) != 0);
}
-static void rna_SoftBodySettings_face_collision_set(PointerRNA *ptr, int value)
+static void rna_SoftBodySettings_face_collision_set(PointerRNA *ptr, bool value)
{
Object *data = (Object *)(ptr->id.data);
if (value) data->softflag |= OB_SB_FACECOLL;
else data->softflag &= ~OB_SB_FACECOLL;
}
-static int rna_SoftBodySettings_edge_collision_get(PointerRNA *ptr)
+static bool rna_SoftBodySettings_edge_collision_get(PointerRNA *ptr)
{
Object *data = (Object *)(ptr->id.data);
return (((data->softflag) & OB_SB_EDGECOLL) != 0);
}
-static void rna_SoftBodySettings_edge_collision_set(PointerRNA *ptr, int value)
+static void rna_SoftBodySettings_edge_collision_set(PointerRNA *ptr, bool value)
{
Object *data = (Object *)(ptr->id.data);
if (value) data->softflag |= OB_SB_EDGECOLL;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index b33bf9a47b7..4b8299b9245 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -903,7 +903,7 @@ static float rna_PartSetting_linelenhead_get(struct PointerRNA *ptr)
}
-static int rna_PartSettings_is_fluid_get(PointerRNA *ptr)
+static bool rna_PartSettings_is_fluid_get(PointerRNA *ptr)
{
ParticleSettings *part = (ParticleSettings *)ptr->data;
@@ -1063,19 +1063,19 @@ static char *rna_SPHFluidSettings_path(PointerRNA *ptr)
return NULL;
}
-static int rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr)
+static bool rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr)
{
ParticleSystem *psys = (ParticleSystem *)ptr->data;
return (psys->ptcaches.first != psys->ptcaches.last);
}
-static int rna_ParticleSystem_editable_get(PointerRNA *ptr)
+static bool rna_ParticleSystem_editable_get(PointerRNA *ptr)
{
ParticleSystem *psys = (ParticleSystem *)ptr->data;
return psys_check_edited(psys);
}
-static int rna_ParticleSystem_edited_get(PointerRNA *ptr)
+static bool rna_ParticleSystem_edited_get(PointerRNA *ptr)
{
ParticleSystem *psys = (ParticleSystem *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 05eb2117990..882e195a520 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -186,7 +186,7 @@ void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value)
}
}
-int rna_ActionGroup_is_custom_colorset_get(PointerRNA *ptr)
+bool rna_ActionGroup_is_custom_colorset_get(PointerRNA *ptr)
{
bActionGroup *grp = ptr->data;
@@ -297,7 +297,7 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value)
ED_armature_bone_rename(G_MAIN, ob->data, oldname, newname);
}
-static int rna_PoseChannel_has_ik_get(PointerRNA *ptr)
+static bool rna_PoseChannel_has_ik_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index aa90ba28e23..592f8ee38c0 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -130,7 +130,7 @@ static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int va
#endif
}
-static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, bool value)
{
RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
@@ -193,7 +193,7 @@ static void rna_RigidBodyOb_shape_set(PointerRNA *ptr, int value)
rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
}
-static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, bool value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
@@ -275,7 +275,7 @@ static void rna_RigidBodyOb_collision_groups_set(PointerRNA *ptr, const bool *va
rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
}
-static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, bool value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
@@ -291,7 +291,7 @@ static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value)
#endif
}
-static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, bool value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
@@ -375,7 +375,7 @@ static void rna_RigidBodyCon_type_set(PointerRNA *ptr, int value)
rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
}
-static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
@@ -388,7 +388,7 @@ static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, int value)
#endif
}
-static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
@@ -397,7 +397,7 @@ static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, int value)
rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
}
-static void rna_RigidBodyCon_use_breaking_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyCon_use_breaking_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
@@ -432,7 +432,7 @@ static void rna_RigidBodyCon_breaking_threshold_set(PointerRNA *ptr, float value
#endif
}
-static void rna_RigidBodyCon_override_solver_iterations_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyCon_override_solver_iterations_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
@@ -632,7 +632,7 @@ static void rna_RigidBodyCon_motor_lin_max_impulse_set(PointerRNA *ptr, float va
#endif
}
-static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
@@ -645,7 +645,7 @@ static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, int value)
#endif
}
-static void rna_RigidBodyCon_use_motor_ang_set(PointerRNA *ptr, int value)
+static void rna_RigidBodyCon_use_motor_ang_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 874f3a8049d..866ea771b0f 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -573,7 +573,7 @@ static int rna_Property_icon_get(PointerRNA *ptr)
return prop->icon;
}
-static int rna_Property_readonly_get(PointerRNA *ptr)
+static bool rna_Property_readonly_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
@@ -584,64 +584,64 @@ static int rna_Property_readonly_get(PointerRNA *ptr)
return (prop->flag & PROP_EDITABLE) == 0;
}
-static int rna_Property_animatable_get(PointerRNA *ptr)
+static bool rna_Property_animatable_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag & PROP_ANIMATABLE) != 0;
}
-static int rna_Property_overridable_get(PointerRNA *ptr)
+static bool rna_Property_overridable_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_STATIC) != 0;
}
-static int rna_Property_use_output_get(PointerRNA *ptr)
+static bool rna_Property_use_output_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag_parameter & PARM_OUTPUT) != 0;
}
-static int rna_Property_is_required_get(PointerRNA *ptr)
+static bool rna_Property_is_required_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag_parameter & PARM_REQUIRED) != 0;
}
-static int rna_Property_is_argument_optional_get(PointerRNA *ptr)
+static bool rna_Property_is_argument_optional_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag_parameter & PARM_PYFUNC_OPTIONAL) != 0;
}
-static int rna_Property_is_never_none_get(PointerRNA *ptr)
+static bool rna_Property_is_never_none_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag & PROP_NEVER_NULL) != 0;
}
-static int rna_Property_is_hidden_get(PointerRNA *ptr)
+static bool rna_Property_is_hidden_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag & PROP_HIDDEN) != 0;
}
-static int rna_Property_is_skip_save_get(PointerRNA *ptr)
+static bool rna_Property_is_skip_save_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag & PROP_SKIP_SAVE) != 0;
}
-static int rna_Property_is_enum_flag_get(PointerRNA *ptr)
+static bool rna_Property_is_enum_flag_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag & PROP_ENUM_FLAG) != 0;
}
-static int rna_Property_is_library_editable_flag_get(PointerRNA *ptr)
+static bool rna_Property_is_library_editable_flag_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag & PROP_LIB_EXCEPTION) != 0;
@@ -698,26 +698,26 @@ static void rna_Property_array_dimensions_get(PointerRNA *ptr, int dimensions[RN
}
}
-static int rna_Property_is_registered_get(PointerRNA *ptr)
+static bool rna_Property_is_registered_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag & PROP_REGISTER) != 0;
}
-static int rna_Property_is_registered_optional_get(PointerRNA *ptr)
+static bool rna_Property_is_registered_optional_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag & PROP_REGISTER_OPTIONAL) != 0;
}
-static int rna_Property_is_runtime_get(PointerRNA *ptr)
+static bool rna_Property_is_runtime_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
return (prop->flag_internal & PROP_INTERN_RUNTIME) != 0;
}
-static int rna_BoolProperty_default_get(PointerRNA *ptr)
+static bool rna_BoolProperty_default_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
rna_idproperty_check(&prop, ptr);
@@ -740,7 +740,7 @@ static int rna_NumberProperty_default_array_get_length(PointerRNA *ptr, int leng
return length[0];
}
-static int rna_NumberProperty_is_array_get(PointerRNA *ptr)
+static bool rna_NumberProperty_is_array_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
@@ -1045,19 +1045,19 @@ static void rna_Function_parameters_begin(CollectionPropertyIterator *iter, Poin
rna_iterator_listbase_begin(iter, &((FunctionRNA *)ptr->data)->cont.properties, rna_property_builtin);
}
-static int rna_Function_registered_get(PointerRNA *ptr)
+static bool rna_Function_registered_get(PointerRNA *ptr)
{
FunctionRNA *func = (FunctionRNA *)ptr->data;
return 0 != (func->flag & FUNC_REGISTER);
}
-static int rna_Function_registered_optional_get(PointerRNA *ptr)
+static bool rna_Function_registered_optional_get(PointerRNA *ptr)
{
FunctionRNA *func = (FunctionRNA *)ptr->data;
return 0 != (func->flag & (FUNC_REGISTER_OPTIONAL & ~FUNC_REGISTER));
}
-static int rna_Function_no_self_get(PointerRNA *ptr)
+static bool rna_Function_no_self_get(PointerRNA *ptr)
{
FunctionRNA *func = (FunctionRNA *)ptr->data;
return !(func->flag & FUNC_NO_SELF);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 1ab7fdbecf0..3109671acb1 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -413,7 +413,7 @@ const EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static const EnumPropertyItem rna_enum_manipulator_items[] = {
+static const EnumPropertyItem rna_enum_gizmo_items[] = {
{SCE_MANIP_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
{SCE_MANIP_ROTATE, "ROTATE", 0, "Rotate", ""},
{SCE_MANIP_SCALE, "SCALE", 0, "Scale", ""},
@@ -647,11 +647,11 @@ static void rna_GPencilBrush_name_set(PointerRNA *ptr, const char *value)
/* ----------------- end of Grease pencil drawing brushes ------------*/
-static void rna_ToolSettings_manipulator_flag_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+static void rna_ToolSettings_gizmo_flag_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
ToolSettings *ts = scene->toolsettings;
- if ((ts->manipulator_flag & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) {
- ts->manipulator_flag |= SCE_MANIP_TRANSLATE;
+ if ((ts->gizmo_flag & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) {
+ ts->gizmo_flag |= SCE_MANIP_TRANSLATE;
}
}
@@ -838,7 +838,7 @@ static void rna_Scene_end_frame_set(PointerRNA *ptr, int value)
}
}
-static void rna_Scene_use_preview_range_set(PointerRNA *ptr, int value)
+static void rna_Scene_use_preview_range_set(PointerRNA *ptr, bool value)
{
Scene *data = (Scene *)ptr->data;
@@ -1064,7 +1064,7 @@ static int rna_RenderSettings_threads_mode_get(PointerRNA *ptr)
return (rd->mode & R_FIXED_THREADS);
}
-static int rna_RenderSettings_is_movie_format_get(PointerRNA *ptr)
+static bool rna_RenderSettings_is_movie_format_get(PointerRNA *ptr)
{
RenderData *rd = (RenderData *)ptr->data;
return BKE_imtype_is_movie(rd->im_format.imtype);
@@ -1306,7 +1306,7 @@ static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str)
}
#ifdef WITH_FFMPEG
-static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, int value)
+static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, bool value)
{
Scene *scene = (Scene *) ptr->id.data;
RenderData *rd = &scene->r;
@@ -1456,12 +1456,12 @@ static void rna_RenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused),
ED_render_engine_changed(bmain);
}
-static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
+static bool rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
{
return (BLI_listbase_count(&R_engines) > 1);
}
-static int rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
+static bool rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->id.data;
return BKE_scene_use_spherical_stereo(scene);
@@ -1654,13 +1654,13 @@ static void rna_Scene_use_persistent_data_update(Main *UNUSED(bmain), Scene *UNU
RE_FreePersistentData();
}
-static int rna_Scene_use_audio_get(PointerRNA *ptr)
+static bool rna_Scene_use_audio_get(PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->data;
return (scene->audio.flag & AUDIO_MUTE) != 0;
}
-static void rna_Scene_use_audio_set(PointerRNA *ptr, int value)
+static void rna_Scene_use_audio_set(PointerRNA *ptr, bool value)
{
Scene *scene = (Scene *)ptr->data;
@@ -1842,8 +1842,9 @@ static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
Scene *scene = (Scene *)ptr->id.data;
Object *camera = scene->camera;
- if (camera)
- DEG_id_tag_update(&camera->id, 0);
+ if (camera && (camera->type == OB_CAMERA)) {
+ DEG_id_tag_update(&camera->id, OB_RECALC_DATA);
+ }
}
static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
@@ -1981,12 +1982,17 @@ static void rna_GPUDOFSettings_blades_set(PointerRNA *ptr, const int value)
{
GPUDOFSettings *dofsettings = (GPUDOFSettings *)ptr->data;
- if (value < 3 && dofsettings->num_blades > 2)
- dofsettings->num_blades = 0;
- else if (value > 0 && dofsettings->num_blades == 0)
- dofsettings->num_blades = 3;
- else
+ if (value == 1 || value == 2) {
+ if (dofsettings->num_blades == 0) {
+ dofsettings->num_blades = 3;
+ }
+ else {
+ dofsettings->num_blades = 0;
+ }
+ }
+ else {
dofsettings->num_blades = value;
+ }
}
static void rna_GPUDOFSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
@@ -2018,7 +2024,7 @@ static void rna_Stereo3dFormat_update(Main *bmain, Scene *UNUSED(scene), Pointer
}
}
-static int rna_gpu_is_hq_supported_get(PointerRNA *UNUSED(ptr))
+static bool rna_gpu_is_hq_supported_get(PointerRNA *UNUSED(ptr))
{
return true;
}
@@ -2693,12 +2699,12 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_ORTHO, 0);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
- prop = RNA_def_property(srna, "use_manipulator_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "manipulator_flag");
- RNA_def_property_enum_items(prop, rna_enum_manipulator_items);
+ prop = RNA_def_property(srna, "use_gizmo_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "gizmo_flag");
+ RNA_def_property_enum_items(prop, rna_enum_gizmo_items);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
- RNA_def_property_ui_text(prop, "Manipulator", "");
- RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_manipulator_flag_update");
+ RNA_def_property_ui_text(prop, "Gizmo Mode", "");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_gizmo_flag_update");
/* Grease Pencil */
prop = RNA_def_property(srna, "use_gpencil_continuous_drawing", PROP_BOOLEAN, PROP_NONE);
@@ -5762,6 +5768,10 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_int_default(prop, 16);
RNA_def_property_ui_text(prop, "Samples", "Number of samples");
RNA_def_property_range(prop, 1, 500);
+
+ /* OpenGL render engine settings. */
+ prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Shading Settings", "Shading settings for OpenGL render engine");
}
static void rna_def_scene_eevee(BlenderRNA *brna)
@@ -5829,6 +5839,38 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
"Size of the shadow map applied to each irradiance sample");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
+ prop = RNA_def_property(srna, "gi_show_irradiance", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHOW_IRRADIANCE);
+ RNA_def_property_boolean_default(prop, 0);
+ RNA_def_property_ui_text(prop, "Show Irradiance Cache", "Display irradiance samples in the viewport");
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
+
+ prop = RNA_def_property(srna, "gi_show_cubemaps", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHOW_CUBEMAPS);
+ RNA_def_property_boolean_default(prop, 0);
+ RNA_def_property_ui_text(prop, "Show Cubemap Cache", "Display captured cubemaps in the viewport");
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
+
+ prop = RNA_def_property(srna, "gi_irradiance_draw_size", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.05f, 10.0f);
+ RNA_def_property_float_default(prop, 0.1f);
+ RNA_def_property_ui_text(prop, "Irradiance Draw Size", "Size of the irradiance sample spheres to debug captured light");
+
+ prop = RNA_def_property(srna, "gi_cubemap_draw_size", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.05f, 10.0f);
+ RNA_def_property_float_default(prop, 0.3f);
+ RNA_def_property_ui_text(prop, "Cubemap Draw Size", "Size of the cubemap spheres to debug captured light");
+
+ prop = RNA_def_property(srna, "gi_auto_bake", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GI_AUTOBAKE);
+ RNA_def_property_boolean_default(prop, 0);
+ RNA_def_property_ui_text(prop, "Auto Bake", "Auto bake indirect lighting when editing probes");
+
+ prop = RNA_def_property(srna, "gi_cache_info", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "light_cache_info");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Light Cache Info", "Info on current cache status");
+
/* Temporal Anti-Aliasing (super sampling) */
prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, 16);
@@ -5967,7 +6009,7 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_volumetric_lights", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_LIGHTS);
RNA_def_property_boolean_default(prop, 1);
- RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene lamps interactions with volumetrics");
+ RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene light interactions with volumetrics");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE);
@@ -6131,13 +6173,13 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "shadow_cube_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_default(prop, 512);
RNA_def_property_enum_items(prop, eevee_shadow_size_items);
- RNA_def_property_ui_text(prop, "Cube Shadows Resolution", "Size of point and area lamps shadow maps");
+ RNA_def_property_ui_text(prop, "Cube Shadows Resolution", "Size of point and area light shadow maps");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "shadow_cascade_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_default(prop, 1024);
RNA_def_property_enum_items(prop, eevee_shadow_size_items);
- RNA_def_property_ui_text(prop, "Directional Shadows Resolution", "Size of sun lamps shadow maps");
+ RNA_def_property_ui_text(prop, "Directional Shadows Resolution", "Size of sun light shadow maps");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index d41d04a4f11..a6a23d6322d 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -79,7 +79,7 @@ static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_ACTION);
}
-static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
+static bool rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
{
/* can be NULL on file load, T42619 */
wmWindowManager *wm = G_MAIN->wm.first;
@@ -130,7 +130,7 @@ static void rna_Screen_layout_name_set(PointerRNA *ptr, const char *value)
}
}
-static int rna_Screen_fullscreen_get(PointerRNA *ptr)
+static bool rna_Screen_fullscreen_get(PointerRNA *ptr)
{
bScreen *sc = (bScreen *)ptr->data;
return (sc->state == SCREENMAXIMIZED);
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index e68c4c284c6..5b2a3c9c4f4 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -223,13 +223,13 @@ static const EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerR
return particle_edit_cache_brush_items;
}
-static int rna_ParticleEdit_editable_get(PointerRNA *ptr)
+static bool rna_ParticleEdit_editable_get(PointerRNA *ptr)
{
ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data;
return (pset->object && pset->scene && PE_get_current(pset->scene, pset->object));
}
-static int rna_ParticleEdit_hair_get(PointerRNA *ptr)
+static bool rna_ParticleEdit_hair_get(PointerRNA *ptr)
{
ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data;
@@ -577,8 +577,10 @@ static void rna_def_sculpt(BlenderRNA *brna)
"Relative Detail", "Mesh detail is relative to the brush size and detail size"},
{SCULPT_DYNTOPO_DETAIL_CONSTANT, "CONSTANT", 0,
"Constant Detail", "Mesh detail is constant in object space according to detail size"},
- {SCULPT_DYNTOPO_DETAIL_BRUSH, "BRUSH", 0,
+ {SCULPT_DYNTOPO_DETAIL_BRUSH, "BRUSH", 0,
"Brush Detail", "Mesh detail is relative to brush radius"},
+ {SCULPT_DYNTOPO_DETAIL_MANUAL, "MANUAL", 0,
+ "Manual Detail", "Mesh detail does not change on each stroke, only when using Flood Fill"},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
new file mode 100644
index 00000000000..e04e78f3ac7
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_sensor.c
@@ -0,0 +1,939 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/makesrna/intern/rna_sensor.c
+ * \ingroup RNA
+ */
+
+#include <stdlib.h>
+
+#include "DNA_constraint_types.h"
+#include "DNA_object_types.h"
+#include "DNA_sensor_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+#include "BLI_string_utils.h"
+
+#include "BLT_translation.h"
+
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+#include "RNA_access.h"
+
+#include "rna_internal.h"
+
+#include "WM_types.h"
+
+/* Always keep in alphabetical order */
+static const EnumPropertyItem sensor_type_items[] = {
+ {SENS_ACTUATOR, "ACTUATOR", 0, "Actuator", ""},
+ {SENS_ALWAYS, "ALWAYS", 0, "Always", ""},
+ {SENS_ARMATURE, "ARMATURE", 0, "Armature", ""},
+ {SENS_COLLISION, "COLLISION", 0, "Collision", ""},
+ {SENS_DELAY, "DELAY", 0, "Delay", ""},
+ {SENS_JOYSTICK, "JOYSTICK", 0, "Joystick", ""},
+ {SENS_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
+ {SENS_MESSAGE, "MESSAGE", 0, "Message", ""},
+ {SENS_MOUSE, "MOUSE", 0, "Mouse", ""},
+ {SENS_NEAR, "NEAR", 0, "Near", ""},
+ {SENS_PROPERTY, "PROPERTY", 0, "Property", ""},
+ {SENS_RADAR, "RADAR", 0, "Radar", ""},
+ {SENS_RANDOM, "RANDOM", 0, "Random", ""},
+ {SENS_RAY, "RAY", 0, "Ray", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+#ifdef RNA_RUNTIME
+
+#include "BKE_sca.h"
+#include "DNA_controller_types.h"
+
+static StructRNA *rna_Sensor_refine(struct PointerRNA *ptr)
+{
+ bSensor *sensor = (bSensor *)ptr->data;
+
+ switch (sensor->type) {
+ case SENS_ALWAYS:
+ return &RNA_AlwaysSensor;
+ case SENS_NEAR:
+ return &RNA_NearSensor;
+ case SENS_KEYBOARD:
+ return &RNA_KeyboardSensor;
+ case SENS_PROPERTY:
+ return &RNA_PropertySensor;
+ case SENS_ARMATURE:
+ return &RNA_ArmatureSensor;
+ case SENS_MOUSE:
+ return &RNA_MouseSensor;
+ case SENS_COLLISION:
+ return &RNA_CollisionSensor;
+ case SENS_RADAR:
+ return &RNA_RadarSensor;
+ case SENS_RANDOM:
+ return &RNA_RandomSensor;
+ case SENS_RAY:
+ return &RNA_RaySensor;
+ case SENS_MESSAGE:
+ return &RNA_MessageSensor;
+ case SENS_JOYSTICK:
+ return &RNA_JoystickSensor;
+ case SENS_ACTUATOR:
+ return &RNA_ActuatorSensor;
+ case SENS_DELAY:
+ return &RNA_DelaySensor;
+ default:
+ return &RNA_Sensor;
+ }
+}
+
+static void rna_Sensor_name_set(PointerRNA *ptr, const char *value)
+{
+ Object *ob = ptr->id.data;
+ bSensor *sens = ptr->data;
+ BLI_strncpy_utf8(sens->name, value, sizeof(sens->name));
+ BLI_uniquename(&ob->sensors, sens, DATA_("Sensor"), '.', offsetof(bSensor, name), sizeof(sens->name));
+}
+
+static void rna_Sensor_type_set(struct PointerRNA *ptr, int value)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ if (value != sens->type) {
+ sens->type = value;
+ init_sensor(sens);
+ }
+}
+
+/* Always keep in alphabetical order */
+
+static void rna_Sensor_controllers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ rna_iterator_array_begin(iter, sens->links, sizeof(bController *), (int)sens->totlinks, 0, NULL);
+}
+
+static int rna_Sensor_controllers_length(PointerRNA *ptr)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ return (int) sens->totlinks;
+}
+
+const EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ EnumPropertyItem *item = NULL;
+ Object *ob = NULL;
+ int totitem = 0;
+
+ if (ptr->type == &RNA_Sensor || RNA_struct_is_a(ptr->type, &RNA_Sensor)) {
+ ob = (Object *)ptr->id.data;
+ }
+ else {
+ /* can't use ob from ptr->id.data because that enum is also used by operators */
+ ob = CTX_data_active_object(C);
+ }
+
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ACTUATOR);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ALWAYS);
+
+ if (ob != NULL) {
+ if (ob->type == OB_ARMATURE) {
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE);
+ }
+ }
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_DELAY);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_JOYSTICK);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_KEYBOARD);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MESSAGE);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MOUSE);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_NEAR);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_PROPERTY);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RADAR);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RANDOM);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RAY);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH);
+
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+
+ return item;
+}
+
+static void rna_Sensor_keyboard_key_set(struct PointerRNA *ptr, int value)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
+
+ if (ISKEYBOARD(value))
+ ks->key = value;
+ else
+ ks->key = 0;
+}
+
+static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
+
+ if (ISKEYBOARD(value))
+ ks->qual = value;
+ else
+ ks->qual = 0;
+}
+
+static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
+
+ if (ISKEYBOARD(value))
+ ks->qual2 = value;
+ else
+ ks->qual2 = 0;
+}
+
+static void rna_Sensor_tap_set(struct PointerRNA *ptr, bool value)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+
+ sens->tap = value;
+ if (sens->tap == 1)
+ sens->level = 0;
+}
+
+static void rna_Sensor_level_set(struct PointerRNA *ptr, bool value)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+
+ sens->level = value;
+ if (sens->level == 1)
+ sens->tap = 0;
+}
+
+static void rna_Sensor_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ bArmatureSensor *as = sens->data;
+ Object *ob = (Object *)ptr->id.data;
+
+ char *posechannel = as->posechannel;
+ char *constraint = as->constraint;
+
+ /* check that bone exist in the active object */
+ if (ob->type == OB_ARMATURE && ob->pose) {
+ bPoseChannel *pchan;
+ bPose *pose = ob->pose;
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (STREQ(pchan->name, posechannel)) {
+ /* found it, now look for constraint channel */
+ bConstraint *con;
+ for (con = pchan->constraints.first; con; con = con->next) {
+ if (STREQ(con->name, constraint)) {
+ /* found it, all ok */
+ return;
+ }
+ }
+ /* didn't find constraint, make empty */
+ constraint[0] = 0;
+ return;
+ }
+ }
+ }
+ /* didn't find any */
+ posechannel[0] = 0;
+ constraint[0] = 0;
+}
+#else
+
+static void rna_def_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "Sensor", NULL);
+ RNA_def_struct_ui_text(srna, "Sensor", "Game engine logic brick to detect events");
+ RNA_def_struct_sdna(srna, "bSensor");
+ RNA_def_struct_refine_func(srna, "rna_Sensor_refine");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Name", "Sensor name");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Sensor_name_set");
+ RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_enum_items(prop, sensor_type_items);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_type_set", "rna_Sensor_type_itemf");
+ RNA_def_property_ui_text(prop, "Type", "");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "pin", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_PIN);
+ RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller");
+ 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");
+ RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Invert Output", "Invert the level(output) of this sensor");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_level", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "level", 1);
+ RNA_def_property_ui_text(prop, "Level",
+ "Level detector, trigger controllers of new states "
+ "(only applicable upon logic state transition)");
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_Sensor_level_set");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_pulse_true_level", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "pulse", SENS_PULSE_REPEAT);
+ RNA_def_property_ui_text(prop, "Pulse True Level", "Activate TRUE level triggering (pulse mode)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_pulse_false_level", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "pulse", SENS_NEG_PULSE_MODE);
+ RNA_def_property_ui_text(prop, "Pulse False Level", "Activate FALSE level triggering (pulse mode)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "tick_skip", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "freq");
+ RNA_def_property_ui_text(prop, "Skip",
+ "Number of logic ticks skipped between 2 active pulses "
+ "(0 = pulse every logic tick, 1 = skip 1 logic tick between pulses, etc.)");
+ RNA_def_property_range(prop, 0, 10000);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_tap", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "tap", 1);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_Sensor_tap_set");
+ RNA_def_property_ui_text(prop, "Tap",
+ "Trigger controllers only for an instant, even while the sensor remains true");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
+ RNA_def_property_struct_type(prop, "Controller");
+ RNA_def_property_ui_text(prop, "Controllers", "The list containing the controllers connected to the sensor");
+ RNA_def_property_collection_funcs(prop, "rna_Sensor_controllers_begin", "rna_iterator_array_next",
+ "rna_iterator_array_end", "rna_iterator_array_dereference_get",
+ "rna_Sensor_controllers_length", NULL, NULL, NULL);
+
+
+ RNA_api_sensor(srna);
+}
+
+static void rna_def_always_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ srna = RNA_def_struct(brna, "AlwaysSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Always Sensor", "Sensor to generate continuous pulses");
+}
+
+static void rna_def_near_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "NearSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Near Sensor", "Sensor to detect nearby objects");
+ RNA_def_struct_sdna_from(srna, "bNearSensor", "data");
+
+ prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "dist");
+ RNA_def_property_ui_text(prop, "Distance", "Trigger distance");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "reset_distance", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "resetdist");
+ RNA_def_property_ui_text(prop, "Reset Distance", "The distance where the sensor forgets the actor");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_mouse_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static const EnumPropertyItem mouse_event_items[] = {
+ {BL_SENS_MOUSE_LEFT_BUTTON, "LEFTCLICK", 0, "Left Button", ""},
+ {BL_SENS_MOUSE_MIDDLE_BUTTON, "MIDDLECLICK", 0, "Middle Button", ""},
+ {BL_SENS_MOUSE_RIGHT_BUTTON, "RIGHTCLICK", 0, "Right Button", ""},
+ {BL_SENS_MOUSE_WHEEL_UP, "WHEELUP", 0, "Wheel Up", ""},
+ {BL_SENS_MOUSE_WHEEL_DOWN, "WHEELDOWN", 0, "Wheel Down", ""},
+ {BL_SENS_MOUSE_MOVEMENT, "MOVEMENT", 0, "Movement", ""},
+ {BL_SENS_MOUSE_MOUSEOVER, "MOUSEOVER", 0, "Mouse Over", ""},
+ {BL_SENS_MOUSE_MOUSEOVER_ANY, "MOUSEOVERANY", 0, "Mouse Over Any", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static const EnumPropertyItem prop_mouse_type_items[] = {
+ {SENS_COLLISION_PROPERTY, "PROPERTY", ICON_LOGIC, "Property", "Use a property for ray intersections"},
+ {SENS_COLLISION_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Use a material for ray intersections"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ srna = RNA_def_struct(brna, "MouseSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Mouse Sensor", "Sensor to detect mouse events");
+ RNA_def_struct_sdna_from(srna, "bMouseSensor", "data");
+
+ prop = RNA_def_property(srna, "mouse_event", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, mouse_event_items);
+ RNA_def_property_ui_text(prop, "Mouse Event", "Type of event this mouse sensor should trigger on");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_pulse", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_MOUSE_FOCUS_PULSE);
+ RNA_def_property_ui_text(prop, "Pulse", "Moving the mouse over a different object generates a pulse");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_material", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, prop_mouse_type_items);
+ RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "propname");
+ RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "matname");
+ RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_x_ray", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_RAY_XRAY);
+ RNA_def_property_ui_text(prop, "X-Ray", "Toggle X-Ray option (see through objects that don't have the property)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_keyboard_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "KeyboardSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Keyboard Sensor", "Sensor to detect keyboard events");
+ RNA_def_struct_sdna_from(srna, "bKeyboardSensor", "data");
+
+ prop = RNA_def_property(srna, "key", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "key");
+ RNA_def_property_enum_items(prop, rna_enum_event_type_items);
+ RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_key_set", NULL);
+ RNA_def_property_ui_text(prop, "Key", "");
+ RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_WINDOWMANAGER);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "modifier_key_1", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "qual");
+ RNA_def_property_enum_items(prop, rna_enum_event_type_items);
+ RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier_set", NULL);
+ RNA_def_property_ui_text(prop, "Modifier Key", "Modifier key code");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "modifier_key_2", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "qual2");
+ RNA_def_property_enum_items(prop, rna_enum_event_type_items);
+ RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier2_set", NULL);
+ RNA_def_property_ui_text(prop, "Second Modifier Key", "Modifier key code");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "target", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "targetName");
+ RNA_def_property_ui_text(prop, "Target", "Property that receives the keystrokes in case a string is logged");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "log", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "toggleName");
+ RNA_def_property_ui_text(prop, "Log Toggle", "Property that indicates whether to log keystrokes as a string");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_all_keys", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "type", 1);
+ RNA_def_property_ui_text(prop, "All Keys", "Trigger this sensor on any keystroke");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_property_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+ static const EnumPropertyItem prop_type_items[] = {
+ {SENS_PROP_EQUAL, "PROPEQUAL", 0, "Equal", ""},
+ {SENS_PROP_NEQUAL, "PROPNEQUAL", 0, "Not Equal", ""},
+ {SENS_PROP_INTERVAL, "PROPINTERVAL", 0, "Interval", ""},
+ {SENS_PROP_CHANGED, "PROPCHANGED", 0, "Changed", ""},
+ /* {SENS_PROP_EXPRESSION, "PROPEXPRESSION", 0, "Expression", ""}, NOT_USED_IN_UI */
+ {SENS_PROP_LESSTHAN, "PROPLESSTHAN", 0, "Less Than", ""},
+ {SENS_PROP_GREATERTHAN, "PROPGREATERTHAN", 0, "Greater Than", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ srna = RNA_def_struct(brna, "PropertySensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Property Sensor", "Sensor to detect values and changes in values of properties");
+ RNA_def_struct_sdna_from(srna, "bPropertySensor", "data");
+
+ prop = RNA_def_property(srna, "evaluation_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, prop_type_items);
+ RNA_def_property_ui_text(prop, "Evaluation Type", "Type of property evaluation");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Property", "");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "value");
+ RNA_def_property_ui_text(prop, "Value", "Check for this value in types in Equal, Not Equal, Less Than and Greater Than types");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "value_min", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "value");
+ RNA_def_property_ui_text(prop, "Minimum Value", "Minimum value in Interval type");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "value_max", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "maxvalue");
+ RNA_def_property_ui_text(prop, "Maximum Value", "Maximum value in Interval type");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_armature_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+ static const EnumPropertyItem prop_type_items[] = {
+ {SENS_ARM_STATE_CHANGED, "STATECHG", 0, "State Changed", ""},
+ {SENS_ARM_LIN_ERROR_BELOW, "LINERRORBELOW", 0, "Lin error below", ""},
+ {SENS_ARM_LIN_ERROR_ABOVE, "LINERRORABOVE", 0, "Lin error above", ""},
+ {SENS_ARM_ROT_ERROR_BELOW, "ROTERRORBELOW", 0, "Rot error below", ""},
+ {SENS_ARM_ROT_ERROR_ABOVE, "ROTERRORABOVE", 0, "Rot error above", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ srna = RNA_def_struct(brna, "ArmatureSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Armature Sensor", "Sensor to detect values and changes in values of IK solver");
+ RNA_def_struct_sdna_from(srna, "bArmatureSensor", "data");
+
+ prop = RNA_def_property(srna, "test_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, prop_type_items);
+ RNA_def_property_ui_text(prop, "Test", "Type of value and test");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "bone", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "posechannel");
+ RNA_def_property_ui_text(prop, "Bone Name", "Identify the bone to check value from");
+ RNA_def_property_update(prop, NC_LOGIC, "rna_Sensor_Armature_update");
+
+ prop = RNA_def_property(srna, "constraint", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "constraint");
+ RNA_def_property_ui_text(prop, "Constraint Name", "Identify the bone constraint to check value from");
+ RNA_def_property_update(prop, NC_LOGIC, "rna_Sensor_Armature_update");
+
+ prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "value");
+ RNA_def_property_ui_text(prop, "Compare Value", "Value to be used in comparison");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_actuator_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "ActuatorSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Actuator Sensor", "Sensor to detect state modifications of actuators");
+ RNA_def_struct_sdna_from(srna, "bActuatorSensor", "data");
+
+ /* XXX if eventually have Logics using RNA 100%, we could use the actuator data-block isntead of its name */
+ prop = RNA_def_property(srna, "actuator", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Actuator", "Actuator name, actuator active state modifications will be detected");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_delay_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "DelaySensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Delay Sensor", "Sensor to send delayed events");
+ RNA_def_struct_sdna_from(srna, "bDelaySensor", "data");
+
+ prop = RNA_def_property(srna, "delay", PROP_INT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Delay",
+ "Delay in number of logic tics before the positive trigger (default 60 per second)");
+ RNA_def_property_range(prop, 0, 5000);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "duration", PROP_INT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Duration",
+ "If >0, delay in number of logic tics before the negative trigger following "
+ "the positive trigger");
+ RNA_def_property_range(prop, 0, 5000);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_repeat", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_DELAY_REPEAT);
+ RNA_def_property_ui_text(prop, "Repeat",
+ "Toggle repeat option (if selected, the sensor restarts after Delay+Duration "
+ "logic tics)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_collision_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "CollisionSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Collision Sensor",
+ "Sensor to detect objects colliding with the current object, with more settings than "
+ "the Touch sensor");
+ RNA_def_struct_sdna_from(srna, "bCollisionSensor", "data");
+
+ prop = RNA_def_property(srna, "use_pulse", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_PULSE);
+ RNA_def_property_ui_text(prop, "Pulse", "Change to the set of colliding objects generates pulse");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_MATERIAL);
+ RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ /*XXX to make a setFunction to create a lookup with all materials in Blend File (not only this object mat.) */
+ prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "materialName");
+ RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+#if 0
+ /* XXX either use a data-block look up to store the string name (material)
+ * or to do a doversion and use a material pointer. */
+ prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "Material");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_sdna(prop, NULL, "ma");
+ RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
+#endif
+}
+
+static void rna_def_radar_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+ static const EnumPropertyItem axis_items[] = {
+ {SENS_RADAR_X_AXIS, "XAXIS", 0, "+X axis", ""},
+ {SENS_RADAR_Y_AXIS, "YAXIS", 0, "+Y axis", ""},
+ {SENS_RADAR_Z_AXIS, "ZAXIS", 0, "+Z axis", ""},
+ {SENS_RADAR_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""},
+ {SENS_RADAR_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""},
+ {SENS_RADAR_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ srna = RNA_def_struct(brna, "RadarSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Radar Sensor",
+ "Sensor to detect objects in a cone shaped radar emanating from the current object");
+ RNA_def_struct_sdna_from(srna, "bRadarSensor", "data");
+
+ prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, axis_items);
+ RNA_def_property_ui_text(prop, "Axis", "Along which axis the radar cone is cast");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_range(prop, 0.0, DEG2RADF(179.9f));
+ RNA_def_property_ui_text(prop, "Angle", "Opening angle of the radar cone");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "range");
+ RNA_def_property_range(prop, 0.0, 10000.0);
+ RNA_def_property_ui_text(prop, "Distance", "Depth of the radar cone");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_random_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "RandomSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Random Sensor", "Sensor to send random events");
+ RNA_def_struct_sdna_from(srna, "bRandomSensor", "data");
+
+ prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 0, 1000);
+ RNA_def_property_ui_text(prop, "Seed", "Initial seed of the generator (choose 0 for not random)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_ray_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+ static const EnumPropertyItem axis_items[] = {
+ {SENS_RAY_X_AXIS, "XAXIS", 0, "+X axis", ""},
+ {SENS_RAY_Y_AXIS, "YAXIS", 0, "+Y axis", ""},
+ {SENS_RAY_Z_AXIS, "ZAXIS", 0, "+Z axis", ""},
+ {SENS_RAY_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""},
+ {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""},
+ {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static const EnumPropertyItem prop_ray_type_items[] = {
+ {SENS_COLLISION_PROPERTY, "PROPERTY", ICON_LOGIC, "Property", "Use a property for ray intersections"},
+ {SENS_COLLISION_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Use a material for ray intersections"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ srna = RNA_def_struct(brna, "RaySensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Ray Sensor",
+ "Sensor to detect intersections with a ray emanating from the current object");
+ RNA_def_struct_sdna_from(srna, "bRaySensor", "data");
+
+ prop = RNA_def_property(srna, "ray_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, prop_ray_type_items);
+ RNA_def_property_ui_text(prop, "Ray Type", "Toggle collision on material or property");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "propname");
+ RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "matname");
+ RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+#if 0
+ /* XXX either use a data-block look up to store the string name (material)
+ * or to do a doversion and use a material pointer. */
+ prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "Material");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_sdna(prop, NULL, "ma");
+ RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
+#endif
+
+ prop = RNA_def_property(srna, "use_x_ray", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_RAY_XRAY);
+ RNA_def_property_ui_text(prop, "X-Ray Mode",
+ "Toggle X-Ray option (see through objects that don't have the property)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.01, 10000.0);
+ RNA_def_property_ui_text(prop, "Range", "Sense objects no farther than this distance");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "axisflag");
+ RNA_def_property_enum_items(prop, axis_items);
+ RNA_def_property_ui_text(prop, "Axis", "Along which axis the ray is cast");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_message_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "MessageSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Message Sensor", "Sensor to detect incoming messages");
+ RNA_def_struct_sdna_from(srna, "bMessageSensor", "data");
+
+ prop = RNA_def_property(srna, "subject", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Subject",
+ "Optional subject filter: only accept messages with this subject, "
+ "or empty to accept all");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+static void rna_def_joystick_sensor(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static const EnumPropertyItem event_type_joystick_items[] = {
+ {SENS_JOY_BUTTON, "BUTTON", 0, "Button", ""},
+ {SENS_JOY_AXIS, "AXIS", 0, "Axis", ""},
+ {SENS_JOY_HAT, "HAT", 0, "Hat", ""},
+ {SENS_JOY_AXIS_SINGLE, "AXIS_SINGLE", 0, "Single Axis", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static const EnumPropertyItem axis_direction_items[] = {
+ {SENS_JOY_X_AXIS, "RIGHTAXIS", 0, "Right Axis", ""},
+ {SENS_JOY_Y_AXIS, "UPAXIS", 0, "Up Axis", ""},
+ {SENS_JOY_NEG_X_AXIS, "LEFTAXIS", 0, "Left Axis", ""},
+ {SENS_JOY_NEG_Y_AXIS, "DOWNAXIS", 0, "Down Axis", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static const EnumPropertyItem hat_direction_items[] = {
+ {SENS_JOY_HAT_UP, "UP", 0, "Up", ""},
+ {SENS_JOY_HAT_DOWN, "DOWN", 0, "Down", ""},
+ {SENS_JOY_HAT_LEFT, "LEFT", 0, "Left", ""},
+ {SENS_JOY_HAT_RIGHT, "RIGHT", 0, "Right", ""},
+
+ {SENS_JOY_HAT_UP_RIGHT, "UPRIGHT", 0, "Up/Right", ""},
+ {SENS_JOY_HAT_DOWN_LEFT, "DOWNLEFT", 0, "Down/Left", ""},
+ {SENS_JOY_HAT_UP_LEFT, "UPLEFT", 0, "Up/Left", ""},
+ {SENS_JOY_HAT_DOWN_RIGHT, "DOWNRIGHT", 0, "Down/Right", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ srna = RNA_def_struct(brna, "JoystickSensor", "Sensor");
+ RNA_def_struct_ui_text(srna, "Joystick Sensor", "Sensor to detect joystick events");
+ RNA_def_struct_sdna_from(srna, "bJoystickSensor", "data");
+
+ prop = RNA_def_property(srna, "joystick_index", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "joyindex");
+ RNA_def_property_ui_text(prop, "Index", "Which joystick to use");
+ RNA_def_property_range(prop, 0, SENS_JOY_MAXINDEX - 1);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "event_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, event_type_joystick_items);
+ RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
+ RNA_def_property_ui_text(prop, "Event Type", "The type of event this joystick sensor is triggered on");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "use_all_events", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_JOY_ANY_EVENT);
+ RNA_def_property_ui_text(prop, "All Events",
+ "Triggered by all events on this joystick's current type (axis/button/hat)");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ /* Button */
+ prop = RNA_def_property(srna, "button_number", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "button");
+ RNA_def_property_ui_text(prop, "Button Number", "Which button to use");
+ RNA_def_property_range(prop, 0, 18);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ /* Axis */
+ prop = RNA_def_property(srna, "axis_number", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "axis");
+ RNA_def_property_ui_text(prop, "Axis Number", "Which axis pair to use, 1 is usually the main direction input");
+ RNA_def_property_range(prop, 1, 8);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "axis_threshold", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "precision");
+ RNA_def_property_ui_text(prop, "Axis Threshold", "Precision of the axis");
+ RNA_def_property_range(prop, 0, 32768);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "axis_direction", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "axisf");
+ RNA_def_property_enum_items(prop, axis_direction_items);
+ RNA_def_property_ui_text(prop, "Axis Direction", "The direction of the axis");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ /* Single Axis */
+ prop = RNA_def_property(srna, "single_axis_number", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "axis_single");
+ RNA_def_property_ui_text(prop, "Axis Number", "Single axis (vertical/horizontal/other) to detect");
+ RNA_def_property_range(prop, 1, 16);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ /* Hat */
+ prop = RNA_def_property(srna, "hat_number", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "hat");
+ RNA_def_property_ui_text(prop, "Hat Number", "Which hat to use");
+ RNA_def_property_range(prop, 1, 2);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop = RNA_def_property(srna, "hat_direction", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "hatf");
+ RNA_def_property_enum_items(prop, hat_direction_items);
+ RNA_def_property_ui_text(prop, "Hat Direction", "Hat direction");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+}
+
+void RNA_def_sensor(BlenderRNA *brna)
+{
+ rna_def_sensor(brna);
+
+ rna_def_always_sensor(brna);
+ rna_def_near_sensor(brna);
+ rna_def_mouse_sensor(brna);
+ rna_def_keyboard_sensor(brna);
+ rna_def_property_sensor(brna);
+ rna_def_armature_sensor(brna);
+ rna_def_actuator_sensor(brna);
+ rna_def_delay_sensor(brna);
+ rna_def_collision_sensor(brna);
+ rna_def_radar_sensor(brna);
+ rna_def_random_sensor(brna);
+ rna_def_ray_sensor(brna);
+ rna_def_message_sensor(brna);
+ rna_def_joystick_sensor(brna);
+}
+
+#endif
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 6417e48efdb..096970095cd 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -327,13 +327,13 @@ static void rna_Sequence_frame_offset_range(PointerRNA *ptr, int *min, int *max,
*max = INT_MAX;
}
-static void rna_Sequence_use_proxy_set(PointerRNA *ptr, int value)
+static void rna_Sequence_use_proxy_set(PointerRNA *ptr, bool value)
{
Sequence *seq = (Sequence *)ptr->data;
BKE_sequencer_proxy_set(seq, value != 0);
}
-static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value)
+static void rna_Sequence_use_translation_set(PointerRNA *ptr, bool value)
{
Sequence *seq = (Sequence *)ptr->data;
if (value) {
@@ -347,7 +347,7 @@ static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value)
}
}
-static void rna_Sequence_use_crop_set(PointerRNA *ptr, int value)
+static void rna_Sequence_use_crop_set(PointerRNA *ptr, bool value)
{
Sequence *seq = (Sequence *)ptr->data;
if (value) {
@@ -891,7 +891,7 @@ static void rna_SequenceColorBalance_update(Main *UNUSED(bmain), Scene *UNUSED(s
BKE_sequence_invalidate_cache_for_modifier(scene, seq);
}
-static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, int value)
+static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, bool value)
{
Scene *scene = ptr->id.data;
Editing *ed = BKE_sequencer_editing_get(scene, false);
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index b4c9e7ba3a2..9af5dabbb67 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -431,7 +431,7 @@ static void rna_SmokeFlow_uvlayer_set(PointerRNA *ptr, const char *value)
rna_object_uvlayer_name_set(ptr, value, flow->uvlayer_name, sizeof(flow->uvlayer_name));
}
-static void rna_Smoke_use_color_ramp_set(PointerRNA *ptr, int value)
+static void rna_Smoke_use_color_ramp_set(PointerRNA *ptr, bool value)
{
SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c
index 0c1391fd2f7..fb0ba0cdd11 100644
--- a/source/blender/makesrna/intern/rna_sound.c
+++ b/source/blender/makesrna/intern/rna_sound.c
@@ -44,13 +44,13 @@ static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
BKE_sound_load(bmain, (bSound *)ptr->data);
}
-static int rna_Sound_caching_get(PointerRNA *ptr)
+static bool rna_Sound_caching_get(PointerRNA *ptr)
{
bSound *sound = (bSound *)(ptr->data);
return (sound->flags & SOUND_FLAGS_CACHING) != 0;
}
-static void rna_Sound_caching_set(PointerRNA *ptr, const int value)
+static void rna_Sound_caching_set(PointerRNA *ptr, const bool value)
{
bSound *sound = (bSound *)(ptr->data);
if (value)
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index dfad4c07cb3..e670d3c31a5 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -426,7 +426,7 @@ 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)
+static bool rna_Space_view2d_sync_get(PointerRNA *ptr)
{
ScrArea *sa;
ARegion *ar;
@@ -441,7 +441,7 @@ static int rna_Space_view2d_sync_get(PointerRNA *ptr)
return false;
}
-static void rna_Space_view2d_sync_set(PointerRNA *ptr, int value)
+static void rna_Space_view2d_sync_set(PointerRNA *ptr, bool value)
{
ScrArea *sa;
ARegion *ar;
@@ -487,7 +487,7 @@ static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA
}
}
-static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int value)
+static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, bool value)
{
View3D *v3d = (View3D *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
@@ -545,6 +545,14 @@ static void rna_View3D_Cursor_rotation_set(PointerRNA *ptr, const float *values)
copy_qt_qt(cursor->rotation, values);
}
+static void rna_View3D_Cursor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
+{
+ View3D *v3d = ptr->data;
+ if (v3d->localvd == NULL) {
+ DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ }
+}
+
static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr)
{
View3D *v3d = (View3D *)(ptr->data);
@@ -573,14 +581,6 @@ static void rna_SpaceView3D_layer_update(Main *bmain, Scene *UNUSED(scene), Poin
DEG_on_visible_update(bmain, false);
}
-static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
-{
- View3D *v3d = (View3D *)(ptr->data);
- ScrArea *sa = rna_area_from_space(ptr);
-
- ED_view3d_shade_update(bmain, v3d, sa);
-}
-
static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr)
{
View3D *v3d = (View3D *)(ptr->data);
@@ -677,37 +677,77 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value
ED_view3d_from_m4(mat, rv3d->ofs, rv3d->viewquat, &rv3d->dist);
}
-static int rna_3DViewShading_type_get(PointerRNA *ptr)
+static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
+ ID *id = ptr->id.data;
+ if (GS(id->name) == ID_SCE) {
+ return;
+ }
+
bScreen *screen = ptr->id.data;
- Scene *scene = WM_windows_scene_get_from_screen(G_MAIN->wm.first, screen);
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (&v3d->shading == ptr->data) {
+ ED_view3d_shade_update(bmain, v3d, sa);
+ return;
+ }
+ }
+ }
+ }
+}
+
+static Scene *rna_3DViewShading_scene(PointerRNA *ptr)
+{
+ /* Get scene, depends if using 3D view or OpenGL render settings. */
+ ID *id = ptr->id.data;
+ if (GS(id->name) == ID_SCE) {
+ return (Scene *)id;
+ }
+ else {
+ bScreen *screen = ptr->id.data;
+ return WM_windows_scene_get_from_screen(G_MAIN->wm.first, screen);
+ }
+}
+
+static int rna_3DViewShading_type_get(PointerRNA *ptr)
+{
+ /* Available shading types depend on render engine. */
+ Scene *scene = rna_3DViewShading_scene(ptr);
RenderEngineType *type = RE_engines_find(scene->r.engine);
- View3D *v3d = (View3D *)ptr->data;
+ View3DShading *shading = (View3DShading *)ptr->data;
- if (!BKE_scene_uses_blender_eevee(scene) && v3d->drawtype == OB_RENDER) {
- if (!(type && type->view_draw)) {
+ if (BKE_scene_uses_blender_eevee(scene)) {
+ return shading->type;
+ }
+ else if (BKE_scene_uses_blender_opengl(scene)) {
+ return (shading->type == OB_MATERIAL) ? OB_RENDER : shading->type;
+ }
+ else {
+ if (shading->type == OB_RENDER && !(type && type->view_draw)) {
return OB_MATERIAL;
}
+ else {
+ return shading->type;
+ }
}
-
- return v3d->drawtype;
}
static void rna_3DViewShading_type_set(PointerRNA *ptr, int value)
{
- View3D *v3d = (View3D *)ptr->data;
- if (value != v3d->drawtype && value == OB_RENDER) {
- v3d->prev_drawtype = v3d->drawtype;
+ View3DShading *shading = (View3DShading *)ptr->data;
+ if (value != shading->type && value == OB_RENDER) {
+ shading->prev_type = shading->type;
}
- v3d->drawtype = value;
+ shading->type = value;
}
static const EnumPropertyItem *rna_3DViewShading_type_itemf(
- bContext *C, PointerRNA *UNUSED(ptr),
+ bContext *UNUSED(C), PointerRNA *ptr,
PropertyRNA *UNUSED(prop), bool *r_free)
{
- wmWindow *win = CTX_wm_window(C);
- Scene *scene = WM_window_get_active_scene(win);
+ Scene *scene = rna_3DViewShading_scene(ptr);
RenderEngineType *type = RE_engines_find(scene->r.engine);
EnumPropertyItem *item = NULL;
@@ -719,6 +759,9 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL);
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER);
}
+ else if (BKE_scene_uses_blender_opengl(scene)) {
+ RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER);
+ }
else {
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL);
if (type && type->view_draw) {
@@ -735,13 +778,13 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
/* Shading.selected_studio_light */
static PointerRNA rna_View3DShading_selected_studio_light_get(PointerRNA *ptr)
{
- View3D *v3d = (View3D *)ptr->data;
+ View3DShading *shading = (View3DShading *)ptr->data;
StudioLight *sl;
- if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) {
- sl = BKE_studiolight_find(v3d->shading.matcap, STUDIOLIGHT_FLAG_ALL);
+ if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
+ sl = BKE_studiolight_find(shading->matcap, STUDIOLIGHT_FLAG_ALL);
}
else {
- sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_FLAG_ALL);
+ sl = BKE_studiolight_find(shading->studio_light, STUDIOLIGHT_FLAG_ALL);
}
return rna_pointer_inherit_refine(ptr, &RNA_StudioLight, sl);
}
@@ -749,33 +792,33 @@ static PointerRNA rna_View3DShading_selected_studio_light_get(PointerRNA *ptr)
/* shading.light */
static int rna_View3DShading_light_get(PointerRNA *ptr)
{
- View3D *v3d = (View3D *)ptr->data;
- return v3d->shading.light;
+ View3DShading *shading = (View3DShading *)ptr->data;
+ return shading->light;
}
static void rna_View3DShading_light_set(PointerRNA *ptr, int value)
{
- View3D *v3d = (View3D *)ptr->data;
- if (value == V3D_LIGHTING_MATCAP && v3d->shading.color_type == V3D_SHADING_TEXTURE_COLOR) {
- v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR;
+ View3DShading *shading = (View3DShading *)ptr->data;
+ if (value == V3D_LIGHTING_MATCAP && shading->color_type == V3D_SHADING_TEXTURE_COLOR) {
+ shading->color_type = V3D_SHADING_MATERIAL_COLOR;
}
- v3d->shading.light = value;
+ shading->light = value;
}
static const EnumPropertyItem *rna_View3DShading_color_type_itemf(
bContext *UNUSED(C), PointerRNA *ptr,
PropertyRNA *UNUSED(prop), bool *r_free)
{
- View3D *v3d = (View3D *)ptr->data;
+ View3DShading *shading = (View3DShading *)ptr->data;
int totitem = 0;
EnumPropertyItem *item = NULL;
- if (v3d->drawtype == OB_SOLID) {
+ if (shading->type == OB_SOLID) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_SINGLE_COLOR);
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_MATERIAL_COLOR);
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_RANDOM_COLOR);
- if (v3d->shading.light != V3D_LIGHTING_MATCAP) {
+ if (shading->light != V3D_LIGHTING_MATCAP) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_TEXTURE_COLOR);
}
}
@@ -788,52 +831,59 @@ static const EnumPropertyItem *rna_View3DShading_color_type_itemf(
/* Studio light */
static int rna_View3DShading_studio_light_get(PointerRNA *ptr)
{
- View3D *v3d = (View3D *)ptr->data;
- char *dna_storage = v3d->shading.studio_light;
+ View3DShading *shading = (View3DShading *)ptr->data;
+ char *dna_storage = shading->studio_light;
int flag = STUDIOLIGHT_ORIENTATIONS_SOLID;
- if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) {
+ if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL;
- dna_storage = v3d->shading.matcap;
+ dna_storage = shading->matcap;
}
- else if (v3d->drawtype == OB_MATERIAL) {
+ else if (shading->type == OB_MATERIAL) {
flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE;
}
StudioLight *sl = BKE_studiolight_find(dna_storage, flag);
- BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE);
- return sl->index;
+ if (sl) {
+ BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE);
+ return sl->index;
+ }
+ else {
+ return 0;
+ }
}
static void rna_View3DShading_studio_light_set(PointerRNA *ptr, int value)
{
- View3D *v3d = (View3D *)ptr->data;
- char *dna_storage = v3d->shading.studio_light;
+ View3DShading *shading = (View3DShading *)ptr->data;
+ char *dna_storage = shading->studio_light;
int flag = STUDIOLIGHT_ORIENTATIONS_SOLID;
- if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) {
+ if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL;
- dna_storage = v3d->shading.matcap;
+ dna_storage = shading->matcap;
}
- else if (v3d->drawtype == OB_MATERIAL) {
+ else if (shading->type == OB_MATERIAL) {
flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE;
}
StudioLight *sl = BKE_studiolight_findindex(value, flag);
- BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE);
+ if (sl) {
+ BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE);
+ }
}
static const EnumPropertyItem *rna_View3DShading_studio_light_itemf(
bContext *UNUSED(C), PointerRNA *ptr,
PropertyRNA *UNUSED(prop), bool *r_free)
{
- View3D *v3d = (View3D *)ptr->data;
+ View3DShading *shading = (View3DShading *)ptr->data;
EnumPropertyItem *item = NULL;
int totitem = 0;
- if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) {
+ if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
const int flags = (STUDIOLIGHT_EXTERNAL_FILE | STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
LISTBASE_FOREACH(StudioLight *, sl, BKE_studiolight_listbase()) {
- int icon_id = (v3d->shading.flag & V3D_SHADING_MATCAP_FLIP_X) ? sl->icon_id_matcap_flipped: sl->icon_id_matcap;
+ int icon_id = (shading->flag & V3D_SHADING_MATCAP_FLIP_X) ? sl->icon_id_matcap_flipped: sl->icon_id_matcap;
if ((sl->flag & flags) == flags) {
EnumPropertyItem tmp = {sl->index, sl->name, icon_id, sl->name, ""};
RNA_enum_item_add(&item, &totitem, &tmp);
@@ -846,18 +896,21 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf(
bool show_studiolight = false;
if (sl->flag & STUDIOLIGHT_INTERNAL) {
- /* always show internal lights */
- show_studiolight = true;
+ /* always show internal lights for solid */
+ if (shading->type == OB_SOLID) {
+ show_studiolight = true;
+ }
}
else {
- switch (v3d->drawtype) {
+ switch (shading->type) {
case OB_SOLID:
case OB_TEXTURE:
- show_studiolight = (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) > 0;
+ show_studiolight = (
+ (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) != 0);
break;
case OB_MATERIAL:
- show_studiolight = (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) > 0;
+ show_studiolight = ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) != 0);
icon_id = sl->icon_id_radiance;
break;
}
@@ -887,9 +940,13 @@ static const EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(
return stereo3d_camera_items;
}
-static PointerRNA rna_SpaceView3D_shading_get(PointerRNA *ptr)
+static int rna_SpaceView3D_icon_from_show_object_viewport_get(PointerRNA *ptr)
{
- return rna_pointer_inherit_refine(ptr, &RNA_View3DShading, ptr->data);
+ const View3D *v3d = (View3D *)ptr->data;
+ /* Ignore selection values when view is off, intent is to show if visible objects aren't selectable. */
+ const int view_value = (v3d->object_type_exclude_viewport != 0);
+ const int select_value = (v3d->object_type_exclude_select & ~v3d->object_type_exclude_viewport) != 0;
+ return ICON_VIS_SEL_11 + (view_value << 1) + select_value;
}
static char *rna_View3DShading_path(PointerRNA *UNUSED(ptr))
@@ -930,7 +987,7 @@ static void rna_SpaceImageEditor_show_stereo_set(PointerRNA *ptr, int value)
sima->iuser.flag &= ~IMA_SHOW_STEREO;
}
-static int rna_SpaceImageEditor_show_stereo_get(PointerRNA *ptr)
+static bool rna_SpaceImageEditor_show_stereo_get(PointerRNA *ptr)
{
SpaceImage *sima = (SpaceImage *)(ptr->data);
return (sima->iuser.flag & IMA_SHOW_STEREO) != 0;
@@ -951,19 +1008,19 @@ static void rna_SpaceImageEditor_show_stereo_update(Main *UNUSED(bmain), Scene *
}
}
-static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)
+static bool rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)
{
SpaceImage *sima = (SpaceImage *)(ptr->data);
return ED_space_image_show_render(sima);
}
-static int rna_SpaceImageEditor_show_paint_get(PointerRNA *ptr)
+static bool rna_SpaceImageEditor_show_paint_get(PointerRNA *ptr)
{
SpaceImage *sima = (SpaceImage *)(ptr->data);
return ED_space_image_show_paint(sima);
}
-static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr)
+static bool rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr)
{
SpaceImage *sima = (SpaceImage *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
@@ -973,7 +1030,7 @@ static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr)
return ED_space_image_show_uvedit(sima, obedit);
}
-static int rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr)
+static bool rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr)
{
SpaceImage *sima = (SpaceImage *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
@@ -1148,7 +1205,7 @@ static const EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf(
/* Space Text Editor */
-static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value)
+static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, bool value)
{
SpaceText *st = (SpaceText *)(ptr->data);
@@ -1241,6 +1298,14 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(
RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_TOOL);
}
+ if (sbuts->pathflag & (1 << BCONTEXT_WORKSPACE)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORKSPACE);
+ }
+
+ if (totitem) {
+ RNA_enum_item_add_separator(&item, &totitem);
+ }
+
if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) {
RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_RENDER);
}
@@ -1257,8 +1322,8 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(
RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD);
}
- if (sbuts->pathflag & (1 << BCONTEXT_WORKSPACE)) {
- RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORKSPACE);
+ if (totitem) {
+ RNA_enum_item_add_separator(&item, &totitem);
}
if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) {
@@ -1311,20 +1376,12 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(
static void rna_SpaceProperties_context_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
SpaceButs *sbuts = (SpaceButs *)(ptr->data);
- /* XXX BCONTEXT_DATA is ugly, but required for lamps... See T51318. */
+ /* XXX BCONTEXT_DATA is ugly, but required for lights... See T51318. */
if (ELEM(sbuts->mainb, BCONTEXT_WORLD, BCONTEXT_MATERIAL, BCONTEXT_TEXTURE, BCONTEXT_DATA)) {
sbuts->preview = 1;
}
}
-static void rna_SpaceProperties_align_set(PointerRNA *ptr, int value)
-{
- SpaceButs *sbuts = (SpaceButs *)(ptr->data);
-
- sbuts->align = value;
- sbuts->re_align = 1;
-}
-
/* Space Console */
static void rna_ConsoleLine_body_get(PointerRNA *ptr, char *value)
{
@@ -1556,7 +1613,7 @@ static void rna_SpaceGraphEditor_display_mode_update(bContext *C, PointerRNA *pt
ED_area_tag_refresh(sa);
}
-static int rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr)
+static bool rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr)
{
SpaceIpo *sipo = (SpaceIpo *)(ptr->data);
return (BLI_listbase_is_empty(&sipo->ghostCurves) == false);
@@ -1716,7 +1773,7 @@ static void rna_SpaceClipEditor_view_type_update(Main *UNUSED(bmain), Scene *UNU
/* File browser. */
-static int rna_FileSelectParams_use_lib_get(PointerRNA *ptr)
+static bool rna_FileSelectParams_use_lib_get(PointerRNA *ptr)
{
FileSelectParams *params = ptr->data;
@@ -1806,13 +1863,13 @@ static int rna_FileBrowser_FSMenuEntry_name_get_editable(PointerRNA *ptr, const
return fsm->save ? PROP_EDITABLE : 0;
}
-static int rna_FileBrowser_FSMenuEntry_use_save_get(PointerRNA *ptr)
+static bool rna_FileBrowser_FSMenuEntry_use_save_get(PointerRNA *ptr)
{
FSMenuEntry *fsm = ptr->data;
return fsm->save;
}
-static int rna_FileBrowser_FSMenuEntry_is_valid_get(PointerRNA *ptr)
+static bool rna_FileBrowser_FSMenuEntry_is_valid_get(PointerRNA *ptr)
{
FSMenuEntry *fsm = ptr->data;
return fsm->valid;
@@ -2338,9 +2395,9 @@ static void rna_def_space_outliner(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Empties", "Show empty objects");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
- prop = RNA_def_property(srna, "use_filter_object_lamp", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_filter_object_light", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_LAMP);
- RNA_def_property_ui_text(prop, "Show Lamps", "Show lamps objects");
+ RNA_def_property_ui_text(prop, "Show Lights", "Show light objects");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
prop = RNA_def_property(srna, "use_filter_object_camera", PROP_BOOLEAN, PROP_NONE);
@@ -2370,14 +2427,13 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ /* Note these settings are used for both 3D viewport and the OpenGL render
+ * engine in the scene, so can't assume to always be part of a screen. */
srna = RNA_def_struct(brna, "View3DShading", NULL);
- RNA_def_struct_sdna(srna, "View3D");
- RNA_def_struct_nested(brna, srna, "SpaceView3D");
RNA_def_struct_path_func(srna, "rna_View3DShading_path");
RNA_def_struct_ui_text(srna, "3D View Shading Settings", "Settings for shading in the 3D viewport");
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "drawtype");
RNA_def_property_enum_items(prop, rna_enum_shading_type_items);
RNA_def_property_enum_funcs(prop, "rna_3DViewShading_type_get", "rna_3DViewShading_type_set",
"rna_3DViewShading_type_itemf");
@@ -2385,14 +2441,14 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update");
prop = RNA_def_property(srna, "light", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "shading.light");
+ RNA_def_property_enum_sdna(prop, NULL, "light");
RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items);
RNA_def_property_enum_funcs(prop, "rna_View3DShading_light_get", "rna_View3DShading_light_set", NULL);
RNA_def_property_ui_text(prop, "Lighting", "Lighting Method for Solid/Texture Viewport Shading");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_object_outline", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_OBJECT_OUTLINE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_OBJECT_OUTLINE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Outline", "Show Object Outline");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -2405,13 +2461,13 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_cavity", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_CAVITY);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_CAVITY);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Cavity", "Show Cavity");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "cavity_ridge_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "shading.cavity_ridge_factor");
+ RNA_def_property_float_sdna(prop, NULL, "cavity_ridge_factor");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Ridge", "Factor for the ridges");
RNA_def_property_range(prop, 0.0f, 250.0f);
@@ -2420,7 +2476,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "cavity_valley_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "shading.cavity_valley_factor");
+ RNA_def_property_float_sdna(prop, NULL, "cavity_valley_factor");
RNA_def_property_float_default(prop, 1.0);
RNA_def_property_ui_text(prop, "Valley", "Factor for the valleys");
RNA_def_property_range(prop, 0.0f, 250.0f);
@@ -2437,7 +2493,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_define_verify_sdna(1);
prop = RNA_def_property(srna, "studiolight_rotate_z", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "shading.studiolight_rot_z");
+ RNA_def_property_float_sdna(prop, NULL, "studiolight_rot_z");
RNA_def_property_float_default(prop, 0.0);
RNA_def_property_ui_text(prop, "Studiolight Rotation", "Rotation of the studiolight around the Z-Axis");
RNA_def_property_range(prop, -M_PI, M_PI);
@@ -2445,60 +2501,66 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "color_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "shading.color_type");
+ RNA_def_property_enum_sdna(prop, NULL, "color_type");
RNA_def_property_enum_items(prop, rna_enum_shading_color_type_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_View3DShading_color_type_itemf");
RNA_def_property_ui_text(prop, "Color", "Color Type");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "single_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "shading.single_color");
+ RNA_def_property_float_sdna(prop, NULL, "single_color");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Color", "Color for single color mode");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SHADOW);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SHADOW);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Shadow", "Show Shadow");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_xray", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_XRAY);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_XRAY);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "X-Ray", "Show whole scene transparent");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "xray_alpha", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "shading.xray_alpha");
+ RNA_def_property_float_sdna(prop, NULL, "xray_alpha");
RNA_def_property_float_default(prop, 0.5);
RNA_def_property_ui_text(prop, "X-Ray Alpha", "Amount of alpha to use");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "use_scene_light", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SCENE_LIGHT);
+ prop = RNA_def_property(srna, "use_scene_lights", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_LIGHTS);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Scene Light", "Render lamps and light probes of the scene");
+ RNA_def_property_ui_text(prop, "Scene Lights", "Render lights and light probes of the scene");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "use_scene_world", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_WORLD);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Scene World", "Use scene world for lighting");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_specular_highlight", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SPECULAR_HIGHLIGHT);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SPECULAR_HIGHLIGHT);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Specular Highlights", "Render specular highlights");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "object_outline_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "shading.object_outline_color");
+ RNA_def_property_float_sdna(prop, NULL, "object_outline_color");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Outline Color", "Color for object outline");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "shadow_intensity", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "shading.shadow_intensity");
+ RNA_def_property_float_sdna(prop, NULL, "shadow_intensity");
RNA_def_property_float_default(prop, 0.5);
RNA_def_property_ui_text(prop, "Shadow Intensity", "Darkness of shadows");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -2507,7 +2569,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "studiolight_background_alpha", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "shading.studiolight_background");
+ RNA_def_property_float_sdna(prop, NULL, "studiolight_background");
RNA_def_property_float_default(prop, 0.0);
RNA_def_property_ui_text(prop, "Background", "Show the studiolight in the background");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -2529,7 +2591,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_overlays", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag2", V3D_RENDER_OVERRIDE);
- RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like manipulators and outlines");
+ RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like gizmos and outlines");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE);
@@ -2585,7 +2647,12 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
"Show an outline highlight around selected objects in non-wireframe views");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "show_all_objects_origin", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "show_object_origins", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_OBJECT_ORIGINS);
+ RNA_def_property_ui_text(prop, "Object Origins", "Show object center dots");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_object_origins_all", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_DRAW_CENTERS);
RNA_def_property_ui_text(prop, "All Object Origins",
"Show the object origin center dot for all (selected and unselected) objects");
@@ -2613,20 +2680,30 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Text", "Display overlay text");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "show_ornaments", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_OBJECT_XTRAS);
+ RNA_def_property_ui_text(prop, "Ornaments", "Object details, including empty wire, cameras and other extras");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_bones", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_BONES);
+ RNA_def_property_ui_text(prop, "Show Bones", "Display bones");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "show_face_orientation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_FACE_ORIENTATION);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Face Orientation", "Show the Face Orientation Overlay");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "show_bone_selection", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_BONE_SELECTION);
+ prop = RNA_def_property(srna, "show_bone_select", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_BONE_SELECT);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Bone Selection", "Show the Bone Selection Overlay");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "bone_selection_alpha", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "overlay.bone_selection_alpha");
+ prop = RNA_def_property(srna, "bone_select_alpha", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "overlay.bone_select_alpha");
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Opacity", "Opacity to use for bone selection");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -2648,13 +2725,13 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_look_dev", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_LOOK_DEV);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Look Dev", "Show Look Development Balls and Palette");
+ RNA_def_property_ui_text(prop, "Look Dev Preview", "Show look development balls and palette");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_wireframes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_WIREFRAMES);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Wireframes", "Show face edges wires");
+ RNA_def_property_ui_text(prop, "Wireframe", "Show face edges wires");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "wireframe_threshold", PROP_FLOAT, PROP_FACTOR);
@@ -2828,14 +2905,14 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "3D Cursor Location",
"3D cursor location for this view (dependent on local view setting)");
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, RNA_TRANSLATION_PREC_DEFAULT);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_View3D_Cursor_update");
prop = RNA_def_property(srna, "cursor_rotation", PROP_FLOAT, PROP_QUATERNION);
RNA_def_property_array(prop, 4);
RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_rotation_get", "rna_View3D_Cursor_rotation_set", NULL);
RNA_def_property_ui_text(prop, "3D Cursor Rotation",
"Rotation in quaternions (keep normalized)");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_View3D_Cursor_update");
prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_UNIT_CAMERA);
RNA_def_property_float_sdna(prop, NULL, "lens");
@@ -2891,9 +2968,24 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_ORTHO, 0);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "twflag", V3D_MANIPULATOR_DRAW);
- RNA_def_property_ui_text(prop, "Manipulator", "Use a 3D manipulator widget for controlling transforms");
+ prop = RNA_def_property(srna, "show_gizmo", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE);
+ RNA_def_property_ui_text(prop, "Show Gizmo", "Show gizmos of all types");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_gizmo_navigate", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_NAVIGATE);
+ RNA_def_property_ui_text(prop, "Navigate Gizmo", "");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_gizmo_context", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_CONTEXT);
+ RNA_def_property_ui_text(prop, "Context Gizmo", "Context sensitive gizmos for the active item");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_gizmo_tool", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_TOOL);
+ RNA_def_property_ui_text(prop, "Tool Gizmo", "Active tool gizmo");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE);
@@ -3013,11 +3105,64 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Volume Alpha", "Opacity (alpha) of the cameras' frustum volume");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ {
+ struct {
+ const char *name;
+ int type_mask;
+ const char *identifier[2];
+ } info[] = {
+ {"Mesh", (1 << OB_MESH),
+ {"show_object_viewport_mesh", "show_object_select_mesh"}},
+ {"Curve", (1 << OB_CURVE),
+ {"show_object_viewport_curve", "show_object_select_curve"}},
+ {"Surface", (1 << OB_SURF),
+ {"show_object_viewport_surf", "show_object_select_surf"}},
+ {"Meta", (1 << OB_MBALL),
+ {"show_object_viewport_meta", "show_object_select_meta"}},
+ {"Font", (1 << OB_FONT),
+ {"show_object_viewport_font", "show_object_select_font"}},
+ {"Armature", (1 << OB_ARMATURE),
+ {"show_object_viewport_armature", "show_object_select_armature"}},
+ {"Lattice", (1 << OB_LATTICE),
+ {"show_object_viewport_lattice", "show_object_select_lattice"}},
+ {"Empty", (1 << OB_EMPTY),
+ {"show_object_viewport_empty", "show_object_select_empty"}},
+ {"Camera", (1 << OB_CAMERA),
+ {"show_object_viewport_camera", "show_object_select_camera"}},
+ {"Light", (1 << OB_LAMP),
+ {"show_object_viewport_light", "show_object_select_light"}},
+ {"Speaker", (1 << OB_SPEAKER),
+ {"show_object_viewport_speaker", "show_object_select_speaker"}},
+ {"Light Probe", (1 << OB_LIGHTPROBE),
+ {"show_object_viewport_light_probe", "show_object_select_light_probe"}},
+ };
+
+ const char *view_mask_member[2] = {
+ "object_type_exclude_viewport",
+ "object_type_exclude_select",
+ };
+ for (int mask_index = 0; mask_index < 2; mask_index++) {
+ for (int type_index = 0; type_index < ARRAY_SIZE(info); type_index++) {
+ prop = RNA_def_property(srna, info[type_index].identifier[mask_index], PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(
+ prop, NULL, view_mask_member[mask_index], info[type_index].type_mask);
+ RNA_def_property_ui_text(prop, info[type_index].name, "");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
+
+ }
+ }
+
+ /* Heper for drawing the icon. */
+ prop = RNA_def_property(srna, "icon_from_show_object_viewport", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(prop, "rna_SpaceView3D_icon_from_show_object_viewport_get", NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Visibility Iconm", "");
+ }
+
/* Nested Structs */
prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "View3DShading");
- RNA_def_property_pointer_funcs(prop, "rna_SpaceView3D_shading_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Shading Settings", "Settings for shading in the 3D viewport");
prop = RNA_def_property(srna, "overlay", PROP_POINTER, PROP_NONE);
@@ -3142,12 +3287,6 @@ static void rna_def_space_buttons(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static const EnumPropertyItem align_items[] = {
- {BUT_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""},
- {BUT_VERTICAL, "VERTICAL", 0, "Vertical", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "SpaceProperties", "Space");
RNA_def_struct_sdna(srna, "SpaceButs");
RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data");
@@ -3159,13 +3298,6 @@ static void rna_def_space_buttons(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Context", "Type of active data to display and edit");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_SpaceProperties_context_update");
- prop = RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "align");
- RNA_def_property_enum_items(prop, align_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_align_set", NULL);
- RNA_def_property_ui_text(prop, "Align", "Arrangement of the panels");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, NULL);
-
/* pinned data */
prop = RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "pinid");
@@ -3473,7 +3605,7 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "render_size");
RNA_def_property_enum_items(prop, proxy_render_size_items);
- RNA_def_property_ui_text(prop, "Proxy render size",
+ RNA_def_property_ui_text(prop, "Proxy Render Size",
"Draw preview using full resolution or different proxy resolutions");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
@@ -4049,7 +4181,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
{FILTER_ID_GD, "GREASE_PENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Show/hide Grease pencil data-blocks"},
{FILTER_ID_GR, "GROUP", ICON_GROUP, "Groups", "Show/hide Group data-blocks"},
{FILTER_ID_IM, "IMAGE", ICON_IMAGE_DATA, "Images", "Show/hide Image data-blocks"},
- {FILTER_ID_LA, "LAMP", ICON_LAMP_DATA, "Lamps", "Show/hide Lamp data-blocks"},
+ {FILTER_ID_LA, "LIGHT", ICON_LIGHT_DATA, "Lights", "Show/hide Light data-blocks"},
{FILTER_ID_LS, "LINESTYLE", ICON_LINE_DATA,
"Freestyle Linestyles", "Show/hide Freestyle's Line Style data-blocks"},
{FILTER_ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattices", "Show/hide Lattice data-blocks"},
@@ -4091,7 +4223,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
{FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO,
"IMAGE", ICON_IMAGE_DATA, "Images & Sounds", "Show/hide images, movie clips, sounds and masks"},
{FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS,
- "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lamps, cameras and speakers"},
+ "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lights, cameras and speakers"},
{FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_CF,
"MISC", ICON_GREASEPENCIL, "Miscellaneous", "Show/hide other data types"},
{0, NULL, 0, NULL, NULL}
diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c
index 1035a3f7f55..191c3355176 100644
--- a/source/blender/makesrna/intern/rna_text.c
+++ b/source/blender/makesrna/intern/rna_text.c
@@ -73,7 +73,7 @@ static void rna_Text_filename_set(PointerRNA *ptr, const char *value)
text->name = NULL;
}
-static int rna_Text_modified_get(PointerRNA *ptr)
+static bool rna_Text_modified_get(PointerRNA *ptr)
{
Text *text = (Text *)ptr->data;
return BKE_text_file_modified_check(text) != 0;
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index b848bb96392..07fd20c6fc5 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -368,7 +368,7 @@ static const EnumPropertyItem *rna_TextureSlot_output_node_itemf(
return item;
}
-static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value)
+static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, bool value)
{
Tex *tex = (Tex *)ptr->data;
@@ -393,7 +393,7 @@ static void rna_Texture_use_nodes_update(bContext *C, PointerRNA *ptr)
rna_Texture_nodes_update(CTX_data_main(C), CTX_data_scene(C), ptr);
}
-static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, int value)
+static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, bool value)
{
Tex *tex = (Tex *)ptr->data;
@@ -1435,7 +1435,7 @@ static void rna_def_texture(BlenderRNA *brna)
srna = RNA_def_struct(brna, "Texture", "ID");
RNA_def_struct_sdna(srna, "Tex");
- RNA_def_struct_ui_text(srna, "Texture", "Texture data-block used by materials, lamps, worlds and brushes");
+ RNA_def_struct_ui_text(srna, "Texture", "Texture data-block used by materials, lights, worlds and brushes");
RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA);
RNA_def_struct_refine_func(srna, "rna_Texture_refine");
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 4831f36d20a..5da49ac5957 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -209,14 +209,14 @@ static void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value)
}
}
-static int rna_trackingTrack_select_get(PointerRNA *ptr)
+static bool rna_trackingTrack_select_get(PointerRNA *ptr)
{
MovieTrackingTrack *track = (MovieTrackingTrack *)ptr->data;
return TRACK_SELECTED(track);
}
-static void rna_trackingTrack_select_set(PointerRNA *ptr, int value)
+static void rna_trackingTrack_select_set(PointerRNA *ptr, bool value)
{
MovieTrackingTrack *track = (MovieTrackingTrack *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index bb7af5f327d..a271df464b7 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -205,6 +205,8 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type)
BLI_freelistN(&pt->children);
BLI_freelinkN(&art->paneltypes, pt);
+ WM_paneltype_remove(pt);
+
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
@@ -313,6 +315,8 @@ static StructRNA *rna_Panel_register(
}
}
+ WM_paneltype_add(pt);
+
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -851,22 +855,22 @@ static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value)
/* UILayout */
-static int rna_UILayout_active_get(PointerRNA *ptr)
+static bool rna_UILayout_active_get(PointerRNA *ptr)
{
return uiLayoutGetActive(ptr->data);
}
-static void rna_UILayout_active_set(PointerRNA *ptr, int value)
+static void rna_UILayout_active_set(PointerRNA *ptr, bool value)
{
uiLayoutSetActive(ptr->data, value);
}
-static int rna_UILayout_alert_get(PointerRNA *ptr)
+static bool rna_UILayout_alert_get(PointerRNA *ptr)
{
return uiLayoutGetRedAlert(ptr->data);
}
-static void rna_UILayout_alert_set(PointerRNA *ptr, int value)
+static void rna_UILayout_alert_set(PointerRNA *ptr, bool value)
{
uiLayoutSetRedAlert(ptr->data, value);
}
@@ -881,12 +885,12 @@ static int rna_UILayout_op_context_get(PointerRNA *ptr)
return uiLayoutGetOperatorContext(ptr->data);
}
-static int rna_UILayout_enabled_get(PointerRNA *ptr)
+static bool rna_UILayout_enabled_get(PointerRNA *ptr)
{
return uiLayoutGetEnabled(ptr->data);
}
-static void rna_UILayout_enabled_set(PointerRNA *ptr, int value)
+static void rna_UILayout_enabled_set(PointerRNA *ptr, bool value)
{
uiLayoutSetEnabled(ptr->data, value);
}
@@ -897,12 +901,12 @@ static int rna_UILayout_red_alert_get(PointerRNA *ptr)
return uiLayoutGetRedAlert(ptr->data);
}
-static void rna_UILayout_red_alert_set(PointerRNA *ptr, int value)
+static void rna_UILayout_red_alert_set(PointerRNA *ptr, bool value)
{
uiLayoutSetRedAlert(ptr->data, value);
}
-static int rna_UILayout_keep_aspect_get(PointerRNA *ptr)
+static bool rna_UILayout_keep_aspect_get(PointerRNA *ptr)
{
return uiLayoutGetKeepAspect(ptr->data);
}
@@ -953,22 +957,22 @@ static void rna_UILayout_emboss_set(PointerRNA *ptr, int value)
uiLayoutSetEmboss(ptr->data, value);
}
-static int rna_UILayout_property_split_get(PointerRNA *ptr)
+static bool rna_UILayout_property_split_get(PointerRNA *ptr)
{
return uiLayoutGetPropSep(ptr->data);
}
-static void rna_UILayout_property_split_set(PointerRNA *ptr, int value)
+static void rna_UILayout_property_split_set(PointerRNA *ptr, bool value)
{
uiLayoutSetPropSep(ptr->data, value);
}
-static int rna_UILayout_property_decorate_get(PointerRNA *ptr)
+static bool rna_UILayout_property_decorate_get(PointerRNA *ptr)
{
return uiLayoutGetPropDecorate(ptr->data);
}
-static void rna_UILayout_property_decorate_set(PointerRNA *ptr, int value)
+static void rna_UILayout_property_decorate_set(PointerRNA *ptr, bool value)
{
uiLayoutSetPropDecorate(ptr->data, value);
}
@@ -1165,6 +1169,11 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
RNA_def_property_ui_text(prop, "Parent ID Name", "If this is set, the panel becomes a subpanel");
+ prop = RNA_def_property(srna, "bl_ui_units_x", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "type->ui_units_x");
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ RNA_def_property_ui_text(prop, "Units X", "When set, defines popup panel width");
+
prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_PIN);
RNA_def_property_ui_text(prop, "Pin", "");
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index be8bce61910..c9ce9ae7961 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -277,8 +277,7 @@ static void rna_uiItemM(
static void rna_uiItemPopoverPanel(
uiLayout *layout, bContext *C,
- int space_type, int region_type, const char *panel_type,
- const char *name, const char *text_ctxt,
+ const char *panel_type, const char *name, const char *text_ctxt,
bool translate, int icon, int icon_value)
{
/* Get translated name (label). */
@@ -288,7 +287,7 @@ static void rna_uiItemPopoverPanel(
icon = icon_value;
}
- uiItemPopoverPanel(layout, C, space_type, region_type, panel_type, name, icon);
+ uiItemPopoverPanel(layout, C, panel_type, name, icon);
}
static void rna_uiItemPopoverPanelFromGroup(
@@ -717,11 +716,7 @@ void RNA_api_ui_layout(StructRNA *srna)
func = RNA_def_function(srna, "popover", "rna_uiItemPopoverPanel");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
- parm = RNA_def_enum(func, "space_type", rna_enum_space_type_items, 0, "Space Type", "");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_enum(func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_string(func, "panel_type", NULL, 0, "", "Identifier of the panel");
+ parm = RNA_def_string(func, "panel", NULL, 0, "", "Identifier of the panel");
api_ui_item_common(func);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
@@ -844,7 +839,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "template_preview", "uiTemplatePreview");
- RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lamps or worlds");
+ RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lights or worlds");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
parm = RNA_def_pointer(func, "id", "ID", "", "ID data-block");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -856,7 +851,7 @@ void RNA_api_ui_layout(StructRNA *srna)
"(i.e. all previews of materials without explicit ID will have the same size...)");
func = RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping");
- RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lamps");
+ RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lights");
api_ui_item_rna_common(func);
RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display");
RNA_def_boolean(func, "levels", false, "", "Show black/white levels");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 347283cd529..0823e8ddd9a 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -143,17 +143,11 @@ static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
}
/* also used by buffer swap switching */
-static void rna_userdef_dpi_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+static void rna_userdef_dpi_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
/* font's are stored at each DPI level, without this we can easy load 100's of fonts */
BLF_cache_clear();
- /* force setting drawable again */
- wmWindowManager *wm = bmain->wm.first;
- if (wm) {
- wm->windrawable = NULL;
- }
-
WM_main_add_notifier(NC_WINDOW, NULL); /* full redraw */
WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); /* refresh region sizes */
}
@@ -171,36 +165,6 @@ static void rna_userdef_language_update(Main *UNUSED(bmain), Scene *UNUSED(scene
UI_reinit_font();
}
-static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- UserDef *userdef = (UserDef *)ptr->data;
-
- /* lame, loop over all views and set */
- bScreen *sc;
- ScrArea *sa;
- SpaceLink *sl;
-
- /* from scene copy to the other views */
- for (sc = bmain->screen.first; sc; sc = sc->id.next) {
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (userdef->manipulator_flag & USER_MANIPULATOR_DRAW) {
- v3d->twflag |= V3D_MANIPULATOR_DRAW;
- }
- else {
- v3d->twflag &= ~V3D_MANIPULATOR_DRAW;
- }
- }
- }
- }
- }
-
- rna_userdef_update(bmain, scene, ptr);
-}
-
-
static void rna_userdef_script_autoexec_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
UserDef *userdef = (UserDef *)ptr->data;
@@ -719,7 +683,9 @@ static void rna_UserDef_studiolight_path_irr_cache_get(PointerRNA *ptr, char *va
if (sl->path_irr_cache) {
BLI_strncpy(value, sl->path_irr_cache, FILE_MAX);
}
- value[0] = 0x00;
+ else {
+ value[0] = '\0';
+ }
}
static int rna_UserDef_studiolight_path_irr_cache_length(PointerRNA *ptr)
@@ -738,7 +704,9 @@ static void rna_UserDef_studiolight_path_sh_cache_get(PointerRNA *ptr, char *val
if (sl->path_sh_cache) {
BLI_strncpy(value, sl->path_sh_cache, FILE_MAX);
}
- value[0] = 0x00;
+ else {
+ value[0] = '\0';
+ }
}
static int rna_UserDef_studiolight_path_sh_cache_length(PointerRNA *ptr)
@@ -758,10 +726,10 @@ static int rna_UserDef_studiolight_index_get(PointerRNA *ptr)
}
/* StudioLight.is_user_defined */
-static int rna_UserDef_studiolight_is_user_defined_get(PointerRNA *ptr)
+static bool rna_UserDef_studiolight_is_user_defined_get(PointerRNA *ptr)
{
StudioLight *sl = (StudioLight *)ptr->data;
- return (sl->flag & STUDIOLIGHT_USER_DEFINED) > 0;
+ return (sl->flag & STUDIOLIGHT_USER_DEFINED) != 0;
}
/* StudioLight.orientation */
@@ -1035,14 +1003,6 @@ static void rna_def_userdef_theme_ui_panel(BlenderRNA *brna)
prop = RNA_def_property(srna, "sub_back", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_ui_text(prop, "Sub Background", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
- prop = RNA_def_property(srna, "show_header", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_ui_text(prop, "Show Header", "");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
-
- prop = RNA_def_property(srna, "show_back", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_ui_text(prop, "Show Background", "");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_ui_gradient(BlenderRNA *brna)
@@ -1245,35 +1205,35 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Z Axis", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- /* Generic manipulator colors. */
- prop = RNA_def_property(srna, "manipulator_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "manipulator_hi");
+ /* Generic gizmo colors. */
+ prop = RNA_def_property(srna, "gizmo_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "gizmo_hi");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Manipulator Highlight", "");
+ RNA_def_property_ui_text(prop, "Gizmo Highlight", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "manipulator_primary", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "manipulator_primary");
+ prop = RNA_def_property(srna, "gizmo_primary", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "gizmo_primary");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Manipulator Primary", "");
+ RNA_def_property_ui_text(prop, "Gizmo Primary", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "manipulator_secondary", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "manipulator_secondary");
+ prop = RNA_def_property(srna, "gizmo_secondary", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "gizmo_secondary");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Manipulator Secondary", "");
+ RNA_def_property_ui_text(prop, "Gizmo Secondary", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "manipulator_a", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "manipulator_a");
+ prop = RNA_def_property(srna, "gizmo_a", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "gizmo_a");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Manipulator A", "");
+ RNA_def_property_ui_text(prop, "Gizmo A", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "manipulator_b", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "manipulator_b");
+ prop = RNA_def_property(srna, "gizmo_b", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "gizmo_b");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Manipulator B", "");
+ RNA_def_property_ui_text(prop, "Gizmo B", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
}
@@ -1805,9 +1765,10 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Empty", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "lamp", PROP_FLOAT, PROP_COLOR_GAMMA);
+ prop = RNA_def_property(srna, "light", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "lamp");
RNA_def_property_array(prop, 4);
- RNA_def_property_ui_text(prop, "Lamp", "");
+ RNA_def_property_ui_text(prop, "Light", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "speaker", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -3470,12 +3431,6 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Direction", "Direction that the OpenGL light is shining");
RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
- prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "col");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the OpenGL light");
- RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
-
prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "spec");
RNA_def_property_array(prop, 3);
@@ -3746,10 +3701,17 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Rotate Around Selection", "Use selection as the pivot point");
/* mini axis */
- prop = RNA_def_property(srna, "show_mini_axis", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_ROTVIEWICON);
- RNA_def_property_ui_text(prop, "Show Mini Axes",
- "Show a small rotating 3D axes in the bottom left corner of the 3D View");
+ static const EnumPropertyItem mini_axis_type_items[] = {
+ {0, "MINIMAL", 0, "Simple Axis", ""},
+ {USER_SHOW_GIZMO_AXIS, "GIZMO", 0, "Interactive Navigation", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ prop = RNA_def_property(srna, "mini_axis_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, mini_axis_type_items);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "uiflag");
+ RNA_def_property_ui_text(prop, "Mini Axes Type",
+ "Show a small rotating 3D axes in the top right corner of the 3D View");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_NONE);
@@ -3775,35 +3737,22 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Rotation Angle", "Rotation step for numerical pad keys (2 4 6 8)");
/* 3D transform widget */
- prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW);
- RNA_def_property_ui_text(prop, "Manipulator", "Use 3D transform manipulator");
- RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update");
-
- prop = RNA_def_property(srna, "show_manipulator_navigate", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW_NAVIGATE);
- RNA_def_property_ui_text(prop, "Navigate Manipulator", "Use 3D navigation manipulator");
- RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update");
-
- /* TODO, expose once it's working. */
-#if 0
- prop = RNA_def_property(srna, "show_manipulator_shaded", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_SHADED);
- RNA_def_property_ui_text(prop, "Manipulator Shaded", "Use 3D transform manipulator");
+ prop = RNA_def_property(srna, "show_gizmo", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "gizmo_flag", USER_GIZMO_DRAW);
+ RNA_def_property_ui_text(prop, "Gizmos", "Use transform gizmos by default");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-#endif
- prop = RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_PIXEL);
- RNA_def_property_int_sdna(prop, NULL, "manipulator_size");
+ prop = RNA_def_property(srna, "gizmo_size", PROP_INT, PROP_PIXEL);
+ RNA_def_property_int_sdna(prop, NULL, "gizmo_size");
RNA_def_property_range(prop, 10, 200);
RNA_def_property_int_default(prop, 75);
- RNA_def_property_ui_text(prop, "Manipulator Size", "Diameter of the manipulator");
+ RNA_def_property_ui_text(prop, "Gizmo Size", "Diameter of the gizmo");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "obcenter_dia");
RNA_def_property_range(prop, 4, 10);
- RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Lamp origin display");
+ RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Light origin display");
RNA_def_property_update(prop, 0, "rna_userdef_update");
/* View2D Grid Displays */
@@ -3894,6 +3843,14 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Release confirms",
"Moving things with a mouse drag confirms when releasing the button");
+ prop = RNA_def_property(srna, "use_numeric_input_advanced", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_FLAG_NUMINPUT_ADVANCED);
+ RNA_def_property_ui_text(
+ prop, "Default to Advanced Numeric Input",
+ "When entering numbers while transforming, "
+ "default to advanced mode for full math expression evaluation");
+
+
/* Undo */
prop = RNA_def_property(srna, "undo_steps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "undosteps");
@@ -4038,9 +3995,9 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_ARM);
RNA_def_property_ui_text(prop, "Duplicate Armature", "Causes armature data to be duplicated with the object");
- prop = RNA_def_property(srna, "use_duplicate_lamp", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_duplicate_light", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_LAMP);
- RNA_def_property_ui_text(prop, "Duplicate Lamp", "Causes lamp data to be duplicated with the object");
+ RNA_def_property_ui_text(prop, "Duplicate Light", "Causes light data to be duplicated with the object");
prop = RNA_def_property(srna, "use_duplicate_material", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_MAT);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 1c94582c57e..3432adc6eb3 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -536,7 +536,7 @@ static int rna_Operator_name_length(PointerRNA *ptr)
return strlen(op->type->name);
}
-static int rna_Operator_has_reports_get(PointerRNA *ptr)
+static bool rna_Operator_has_reports_get(PointerRNA *ptr)
{
wmOperator *op = (wmOperator *)ptr->data;
return (op->reports && op->reports->list.first);
@@ -608,7 +608,7 @@ static float rna_Event_pressure_get(PointerRNA *ptr)
return WM_event_tablet_data(event, NULL, NULL);
}
-static int rna_Event_is_tablet_get(PointerRNA *ptr)
+static bool rna_Event_is_tablet_get(PointerRNA *ptr)
{
const wmEvent *event = ptr->data;
return WM_event_is_tablet(event);
@@ -675,7 +675,7 @@ static void rna_Window_scene_update(bContext *C, PointerRNA *ptr)
BPy_BEGIN_ALLOW_THREADS;
#endif
- WM_window_change_active_scene(bmain, C, win, win->new_scene);
+ WM_window_set_active_scene(bmain, C, win, win->new_scene);
#ifdef WITH_PYTHON
BPy_END_ALLOW_THREADS;
@@ -773,8 +773,8 @@ static void rna_workspace_screen_update(bContext *C, PointerRNA *ptr)
static PointerRNA rna_Window_view_layer_get(PointerRNA *ptr)
{
wmWindow *win = ptr->data;
- Scene *scene;
- ViewLayer *view_layer = WM_window_get_active_view_layer_ex(win, &scene);
+ Scene *scene = WM_window_get_active_scene(win);;
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
PointerRNA scene_ptr;
RNA_id_pointer_create(&scene->id, &scene_ptr);
@@ -784,10 +784,9 @@ static PointerRNA rna_Window_view_layer_get(PointerRNA *ptr)
static void rna_Window_view_layer_set(PointerRNA *ptr, PointerRNA value)
{
wmWindow *win = ptr->data;
- Scene *scene = WM_window_get_active_scene(win);
- WorkSpace *workspace = WM_window_get_active_workspace(win);
+ ViewLayer *view_layer = value.data;
- BKE_workspace_view_layer_set(workspace, value.data, scene);
+ WM_window_set_active_view_layer(win, view_layer);
}
static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
@@ -915,7 +914,7 @@ static const EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, Point
return rna_enum_keymap_propvalue_items; /* ERROR */
}
-static int rna_KeyMapItem_any_get(PointerRNA *ptr)
+static bool rna_KeyMapItem_any_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
@@ -931,7 +930,7 @@ static int rna_KeyMapItem_any_get(PointerRNA *ptr)
}
}
-static void rna_KeyMapItem_any_set(PointerRNA *ptr, int value)
+static void rna_KeyMapItem_any_set(PointerRNA *ptr, bool value)
{
wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
@@ -943,25 +942,25 @@ static void rna_KeyMapItem_any_set(PointerRNA *ptr, int value)
}
}
-static int rna_KeyMapItem_shift_get(PointerRNA *ptr)
+static bool rna_KeyMapItem_shift_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
return kmi->shift != 0;
}
-static int rna_KeyMapItem_ctrl_get(PointerRNA *ptr)
+static bool rna_KeyMapItem_ctrl_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
return kmi->ctrl != 0;
}
-static int rna_KeyMapItem_alt_get(PointerRNA *ptr)
+static bool rna_KeyMapItem_alt_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
return kmi->alt != 0;
}
-static int rna_KeyMapItem_oskey_get(PointerRNA *ptr)
+static bool rna_KeyMapItem_oskey_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
return kmi->oskey != 0;
@@ -1032,7 +1031,7 @@ static int rna_wmKeyMapItem_name_length(PointerRNA *ptr)
return strlen(ot ? RNA_struct_ui_name(ot->srna) : kmi->idname);
}
-static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
+static bool rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = ptr->data;
return kmi->id < 0;
@@ -2041,6 +2040,9 @@ static void rna_def_window(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Window", "Open window");
RNA_def_struct_sdna(srna, "wmWindow");
+ prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Parent Window", "Active workspace and scene follow this window");
+
rna_def_window_stereo3d(brna);
prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index afb12f48e28..a1780b45aed 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -118,33 +118,33 @@ static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer)
}
-static wmManipulatorGroupType *wm_manipulatorgrouptype_find_for_add_remove(ReportList *reports, const char *idname)
+static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports, const char *idname)
{
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, true);
- if (wgt == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Manipulator group type '%s' not found!", idname);
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, true);
+ if (gzgt == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname);
return NULL;
}
- if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) {
- BKE_reportf(reports, RPT_ERROR, "Manipulator group '%s' has 'PERSISTENT' option set!", idname);
+ if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) {
+ BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname);
return NULL;
}
- return wgt;
+ return gzgt;
}
-static void rna_manipulator_group_type_add(ReportList *reports, const char *idname)
+static void rna_gizmo_group_type_add(ReportList *reports, const char *idname)
{
- wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname);
- if (wgt != NULL) {
- WM_manipulator_group_type_add_ptr(wgt);
+ wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
+ if (gzgt != NULL) {
+ WM_gizmo_group_type_add_ptr(gzgt);
}
}
-static void rna_manipulator_group_type_remove(Main *bmain, ReportList *reports, const char *idname)
+static void rna_gizmo_group_type_remove(Main *bmain, ReportList *reports, const char *idname)
{
- wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname);
- if (wgt != NULL) {
- WM_manipulator_group_type_remove_ptr(bmain, wgt);
+ wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
+ if (gzgt != NULL) {
+ WM_gizmo_group_type_remove_ptr(bmain, gzgt);
}
}
@@ -376,12 +376,12 @@ static void rna_PopMenuEnd(bContext *C, PointerRNA *handle)
}
/* popover wrapper */
-static PointerRNA rna_PopoverBegin(bContext *C)
+static PointerRNA rna_PopoverBegin(bContext *C, int ui_units_x)
{
PointerRNA r_ptr;
void *data;
- data = (void *)UI_popover_begin(C);
+ data = (void *)UI_popover_begin(C, U.widget_unit * ui_units_x);
RNA_pointer_create(NULL, &RNA_UIPopover, data, &r_ptr);
@@ -516,16 +516,16 @@ void RNA_api_wm(StructRNA *srna)
parm = RNA_def_pointer(func, "timer", "Timer", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- func = RNA_def_function(srna, "manipulator_group_type_add", "rna_manipulator_group_type_add");
+ func = RNA_def_function(srna, "gizmo_group_type_add", "rna_gizmo_group_type_add");
RNA_def_function_ui_description(func, "Activate an existing widget group (when the persistent option isn't set)");
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS);
- parm = RNA_def_string(func, "identifier", NULL, 0, "", "Manipulator group type name");
+ parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- func = RNA_def_function(srna, "manipulator_group_type_remove", "rna_manipulator_group_type_remove");
+ func = RNA_def_function(srna, "gizmo_group_type_remove", "rna_gizmo_group_type_remove");
RNA_def_function_ui_description(func, "De-activate a widget group (when the persistent option isn't set)");
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_MAIN | FUNC_USE_REPORTS);
- parm = RNA_def_string(func, "identifier", NULL, 0, "", "Manipulator group type name");
+ parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* Progress bar interface */
@@ -602,6 +602,7 @@ void RNA_api_wm(StructRNA *srna)
/* wrap UI_popover_begin */
func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin");
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
+ RNA_def_property(func, "ui_units_x", PROP_INT, PROP_UNSIGNED);
/* return */
parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c
new file mode 100644
index 00000000000..7a2460a7694
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_wm_gizmo.c
@@ -0,0 +1,1336 @@
+/*
+ * ***** 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/makesrna/intern/rna_wm_gizmo.c
+ * \ingroup RNA
+ */
+
+#include <stdlib.h>
+
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_string_utils.h"
+
+#include "BLT_translation.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "rna_internal.h"
+
+#include "WM_types.h"
+
+#ifdef RNA_RUNTIME
+/* enum definitions */
+#endif /* RNA_RUNTIME */
+
+#ifdef RNA_RUNTIME
+
+#include <assert.h>
+
+#include "WM_api.h"
+
+#include "DNA_workspace_types.h"
+
+#include "ED_screen.h"
+
+#include "UI_interface.h"
+
+#include "BKE_global.h"
+#include "BKE_idprop.h"
+#include "BKE_workspace.h"
+
+#include "MEM_guardedalloc.h"
+
+#ifdef WITH_PYTHON
+# include "BPY_extern.h"
+#endif
+
+/* -------------------------------------------------------------------- */
+
+/** \name Gizmo API
+ * \{ */
+
+#ifdef WITH_PYTHON
+static void rna_gizmo_draw_cb(
+ const struct bContext *C, struct wmGizmo *gz)
+{
+ extern FunctionRNA rna_Gizmo_draw_func;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ PointerRNA gz_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr);
+ /* RNA_struct_find_function(&gz_ptr, "draw"); */
+ func = &rna_Gizmo_draw_func;
+ RNA_parameter_list_create(&list, &gz_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+static void rna_gizmo_draw_select_cb(
+ const struct bContext *C, struct wmGizmo *gz, int select_id)
+{
+ extern FunctionRNA rna_Gizmo_draw_select_func;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ PointerRNA gz_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr);
+ /* RNA_struct_find_function(&gz_ptr, "draw_select"); */
+ func = &rna_Gizmo_draw_select_func;
+ RNA_parameter_list_create(&list, &gz_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "select_id", &select_id);
+ gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+static int rna_gizmo_test_select_cb(
+ struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event)
+{
+ extern FunctionRNA rna_Gizmo_test_select_func;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ PointerRNA gz_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr);
+ /* RNA_struct_find_function(&gz_ptr, "test_select"); */
+ func = &rna_Gizmo_test_select_func;
+ RNA_parameter_list_create(&list, &gz_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "event", &event);
+ gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list);
+
+ void *ret;
+ RNA_parameter_get_lookup(&list, "intersect_id", &ret);
+ int intersect_id = *(int *)ret;
+
+ RNA_parameter_list_free(&list);
+ return intersect_id;
+}
+
+static int rna_gizmo_modal_cb(
+ struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event,
+ eWM_GizmoFlagTweak tweak_flag)
+{
+ extern FunctionRNA rna_Gizmo_modal_func;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ PointerRNA gz_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ const int tweak_flag_int = tweak_flag;
+ RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr);
+ /* RNA_struct_find_function(&gz_ptr, "modal"); */
+ func = &rna_Gizmo_modal_func;
+ RNA_parameter_list_create(&list, &gz_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "event", &event);
+ RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
+ gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list);
+
+ void *ret;
+ RNA_parameter_get_lookup(&list, "result", &ret);
+ int ret_enum = *(int *)ret;
+
+ RNA_parameter_list_free(&list);
+ return ret_enum;
+}
+
+static void rna_gizmo_setup_cb(
+ struct wmGizmo *gz)
+{
+ extern FunctionRNA rna_Gizmo_setup_func;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ PointerRNA gz_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr);
+ /* RNA_struct_find_function(&gz_ptr, "setup"); */
+ func = &rna_Gizmo_setup_func;
+ RNA_parameter_list_create(&list, &gz_ptr, func);
+ gzgroup->type->ext.call((bContext *)NULL, &gz_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+
+static int rna_gizmo_invoke_cb(
+ struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event)
+{
+ extern FunctionRNA rna_Gizmo_invoke_func;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ PointerRNA gz_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr);
+ /* RNA_struct_find_function(&gz_ptr, "invoke"); */
+ func = &rna_Gizmo_invoke_func;
+ RNA_parameter_list_create(&list, &gz_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "event", &event);
+ gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list);
+
+ void *ret;
+ RNA_parameter_get_lookup(&list, "result", &ret);
+ int ret_enum = *(int *)ret;
+
+ RNA_parameter_list_free(&list);
+ return ret_enum;
+}
+
+static void rna_gizmo_exit_cb(
+ struct bContext *C, struct wmGizmo *gz, bool cancel)
+{
+ extern FunctionRNA rna_Gizmo_exit_func;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ PointerRNA gz_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr);
+ /* RNA_struct_find_function(&gz_ptr, "exit"); */
+ func = &rna_Gizmo_exit_func;
+ RNA_parameter_list_create(&list, &gz_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ {
+ int cancel_i = cancel;
+ RNA_parameter_set_lookup(&list, "cancel", &cancel_i);
+ }
+ gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+static void rna_gizmo_select_refresh_cb(
+ struct wmGizmo *gz)
+{
+ extern FunctionRNA rna_Gizmo_select_refresh_func;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ PointerRNA gz_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr);
+ /* RNA_struct_find_function(&gz_ptr, "select_refresh"); */
+ func = &rna_Gizmo_select_refresh_func;
+ RNA_parameter_list_create(&list, &gz_ptr, func);
+ gzgroup->type->ext.call((bContext *)NULL, &gz_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+#endif /* WITH_PYTHON */
+
+/* just to work around 'const char *' warning and to ensure this is a python op */
+static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value)
+{
+ wmGizmo *data = ptr->data;
+ char *str = (char *)data->type->idname;
+ if (!str[0]) {
+ BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
+ }
+ else {
+ assert(!"setting the bl_idname on a non-builtin operator");
+ }
+}
+
+static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr)
+{
+#if 0
+ wmWindowManager *wm = ptr->id.data;
+#endif
+
+ /* We could try workaruond this lookup, but not trivial. */
+ for (bScreen *screen = G_MAIN->screen.first; screen; screen = screen->id.next) {
+ IDProperty *properties = ptr->data;
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->gizmo_map) {
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first;
+ gzgroup;
+ gzgroup = gzgroup->next)
+ {
+ for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ if (gz->properties == properties) {
+ return gz;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+static StructRNA *rna_GizmoProperties_refine(PointerRNA *ptr)
+{
+ wmGizmo *gz = rna_GizmoProperties_find_operator(ptr);
+
+ if (gz)
+ return gz->type->srna;
+ else
+ return ptr->type;
+}
+
+static IDProperty *rna_GizmoProperties_idprops(PointerRNA *ptr, bool create)
+{
+ if (create && !ptr->data) {
+ IDPropertyTemplate val = {0};
+ ptr->data = IDP_New(IDP_GROUP, &val, "RNA_GizmoProperties group");
+ }
+
+ return ptr->data;
+}
+
+static PointerRNA rna_Gizmo_properties_get(PointerRNA *ptr)
+{
+ wmGizmo *gz = ptr->data;
+ return rna_pointer_inherit_refine(ptr, gz->type->srna, gz->properties);
+}
+
+/* wmGizmo.float */
+#define RNA_GIZMO_GENERIC_FLOAT_RW_DEF(func_id, member_id) \
+static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ return gz->member_id; \
+} \
+static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ gz->member_id = value; \
+}
+#define RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \
+static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ return gz->member_id[index]; \
+} \
+static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ gz->member_id[index] = value; \
+}
+/* wmGizmo.float[len] */
+#define RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
+static void rna_Gizmo_##func_id##_get(PointerRNA *ptr, float value[len]) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ memcpy(value, gz->member_id, sizeof(float[len])); \
+} \
+static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, const float value[len]) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ memcpy(gz->member_id, value, sizeof(float[len])); \
+}
+
+/* wmGizmo.flag */
+#define RNA_GIZMO_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \
+static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ return (gz->member_id & flag_value) != 0; \
+} \
+static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ SET_FLAG_FROM_TEST(gz->member_id, value, flag_value); \
+}
+
+/* wmGizmo.flag (negative) */
+#define RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \
+static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ return (gz->member_id & flag_value) == 0; \
+} \
+static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ SET_FLAG_FROM_TEST(gz->member_id, !value, flag_value); \
+}
+
+#define RNA_GIZMO_FLAG_RO_DEF(func_id, member_id, flag_value) \
+static int rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmGizmo *gz = ptr->data; \
+ return (gz->member_id & flag_value) != 0; \
+}
+
+RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3);
+RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3);
+
+RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3);
+RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3);
+
+RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16);
+RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
+RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
+
+static void rna_Gizmo_matrix_world_get(PointerRNA *ptr, float value[16])
+{
+ wmGizmo *gz = ptr->data;
+ WM_gizmo_calc_matrix_final(gz, (float (*)[4])value);
+}
+
+RNA_GIZMO_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
+RNA_GIZMO_GENERIC_FLOAT_RW_DEF(line_width, line_width);
+
+RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_GIZMO_DRAW_HOVER);
+RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_GIZMO_DRAW_MODAL);
+RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_GIZMO_DRAW_VALUE);
+RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE);
+RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE);
+RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN);
+RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_GRAB_CURSOR);
+RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND);
+
+/* wmGizmo.state */
+RNA_GIZMO_FLAG_RO_DEF(state_is_highlight, state, WM_GIZMO_STATE_HIGHLIGHT);
+RNA_GIZMO_FLAG_RO_DEF(state_is_modal, state, WM_GIZMO_STATE_MODAL);
+RNA_GIZMO_FLAG_RO_DEF(state_select, state, WM_GIZMO_STATE_SELECT);
+
+static void rna_Gizmo_state_select_set(struct PointerRNA *ptr, bool value)
+{
+ wmGizmo *gz = ptr->data;
+ wmGizmoGroup *gzgroup = gz->parent_gzgroup;
+ WM_gizmo_select_set(gzgroup->parent_gzmap, gz, value);
+}
+
+static PointerRNA rna_Gizmo_group_get(PointerRNA *ptr)
+{
+ wmGizmo *gz = ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_GizmoGroup, gz->parent_gzgroup);
+}
+
+#ifdef WITH_PYTHON
+
+static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type);
+void BPY_RNA_gizmo_wrapper(wmGizmoType *gzgt, void *userdata);
+
+static StructRNA *rna_Gizmo_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+{
+ struct {
+ char idname[MAX_NAME];
+ } temp_buffers;
+
+ wmGizmoType dummygt = {NULL};
+ wmGizmo dummymnp = {NULL};
+ PointerRNA mnp_ptr;
+
+ /* Two sets of functions. */
+ int have_function[8];
+
+ /* setup dummy gizmo & gizmo type to store static properties in */
+ dummymnp.type = &dummygt;
+ dummygt.idname = temp_buffers.idname;
+ RNA_pointer_create(NULL, &RNA_Gizmo, &dummymnp, &mnp_ptr);
+
+ /* Clear so we can detect if it's left unset. */
+ temp_buffers.idname[0] = '\0';
+
+ /* validate the python class */
+ if (validate(&mnp_ptr, data, have_function) != 0)
+ return NULL;
+
+ if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
+ BKE_reportf(reports, RPT_ERROR, "Registering gizmo class: '%s' is too long, maximum length is %d",
+ identifier, (int)sizeof(temp_buffers.idname));
+ return NULL;
+ }
+
+ /* check if we have registered this gizmo type before, and remove it */
+ {
+ const wmGizmoType *gzt = WM_gizmotype_find(dummygt.idname, true);
+ if (gzt && gzt->ext.srna) {
+ rna_Gizmo_unregister(bmain, gzt->ext.srna);
+ }
+ }
+ if (!RNA_struct_available_or_report(reports, dummygt.idname)) {
+ return NULL;
+ }
+
+ { /* allocate the idname */
+ /* For multiple strings see GizmoGroup. */
+ dummygt.idname = BLI_strdup(temp_buffers.idname);
+ }
+
+ /* create a new gizmo type */
+ dummygt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummygt.idname, &RNA_Gizmo);
+ /* gizmo properties are registered separately */
+ RNA_def_struct_flag(dummygt.ext.srna, STRUCT_NO_IDPROPERTIES);
+ dummygt.ext.data = data;
+ dummygt.ext.call = call;
+ dummygt.ext.free = free;
+
+ {
+ int i = 0;
+ dummygt.draw = (have_function[i++]) ? rna_gizmo_draw_cb : NULL;
+ dummygt.draw_select = (have_function[i++]) ? rna_gizmo_draw_select_cb : NULL;
+ dummygt.test_select = (have_function[i++]) ? rna_gizmo_test_select_cb : NULL;
+ dummygt.modal = (have_function[i++]) ? rna_gizmo_modal_cb : NULL;
+// dummygt.property_update = (have_function[i++]) ? rna_gizmo_property_update : NULL;
+// dummygt.position_get = (have_function[i++]) ? rna_gizmo_position_get : NULL;
+ dummygt.setup = (have_function[i++]) ? rna_gizmo_setup_cb : NULL;
+ dummygt.invoke = (have_function[i++]) ? rna_gizmo_invoke_cb : NULL;
+ dummygt.exit = (have_function[i++]) ? rna_gizmo_exit_cb : NULL;
+ dummygt.select_refresh = (have_function[i++]) ? rna_gizmo_select_refresh_cb : NULL;
+
+ BLI_assert(i == ARRAY_SIZE(have_function));
+ }
+
+ WM_gizmotype_append_ptr(BPY_RNA_gizmo_wrapper, (void *)&dummygt);
+
+ /* update while blender is running */
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+
+ return dummygt.ext.srna;
+}
+
+static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type)
+{
+ wmGizmoType *gzt = RNA_struct_blender_type_get(type);
+
+ if (!gzt) {
+ return;
+ }
+
+ RNA_struct_free_extension(type, &gzt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
+
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+
+ WM_gizmotype_remove_ptr(NULL, bmain, gzt);
+}
+
+static void **rna_Gizmo_instance(PointerRNA *ptr)
+{
+ wmGizmo *gz = ptr->data;
+ return &gz->py_instance;
+}
+
+#endif /* WITH_PYTHON */
+
+
+static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr)
+{
+ wmGizmo *gz = mnp_ptr->data;
+ return (gz->type && gz->type->ext.srna) ? gz->type->ext.srna : &RNA_Gizmo;
+}
+
+/** \} */
+
+/** \name Gizmo Group API
+ * \{ */
+
+static wmGizmo *rna_GizmoGroup_gizmo_new(
+ wmGizmoGroup *gzgroup, ReportList *reports, const char *idname)
+{
+ const wmGizmoType *gzt = WM_gizmotype_find(idname, true);
+ if (gzt == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "GizmoType '%s' not known", idname);
+ return NULL;
+ }
+ wmGizmo *gz = WM_gizmo_new_ptr(gzt, gzgroup, NULL);
+ return gz;
+}
+
+static void rna_GizmoGroup_gizmo_remove(
+ wmGizmoGroup *gzgroup, bContext *C, wmGizmo *gz)
+{
+ WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C);
+}
+
+static void rna_GizmoGroup_gizmo_clear(
+ wmGizmoGroup *gzgroup, bContext *C)
+{
+ while (gzgroup->gizmos.first) {
+ WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gzgroup->gizmos.first, C);
+ }
+}
+
+static void rna_GizmoGroup_name_get(PointerRNA *ptr, char *value)
+{
+ wmGizmoGroup *gzgroup = ptr->data;
+ strcpy(value, gzgroup->type->name);
+}
+
+static int rna_GizmoGroup_name_length(PointerRNA *ptr)
+{
+ wmGizmoGroup *gzgroup = ptr->data;
+ return strlen(gzgroup->type->name);
+}
+
+/* just to work around 'const char *' warning and to ensure this is a python op */
+static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value)
+{
+ wmGizmoGroup *data = ptr->data;
+ char *str = (char *)data->type->idname;
+ if (!str[0])
+ BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
+ else
+ assert(!"setting the bl_idname on a non-builtin operator");
+}
+
+static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value)
+{
+ wmGizmoGroup *data = ptr->data;
+ char *str = (char *)data->type->name;
+ if (!str[0])
+ BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
+ else
+ assert(!"setting the bl_label on a non-builtin operator");
+}
+
+static bool rna_GizmoGroup_has_reports_get(PointerRNA *ptr)
+{
+ wmGizmoGroup *gzgroup = ptr->data;
+ return (gzgroup->reports && gzgroup->reports->list.first);
+}
+
+#ifdef WITH_PYTHON
+
+static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *gzgt)
+{
+
+ extern FunctionRNA rna_GizmoGroup_poll_func;
+
+ PointerRNA ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ void *ret;
+ int visible;
+
+ RNA_pointer_create(NULL, gzgt->ext.srna, NULL, &ptr); /* dummy */
+ func = &rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
+
+ RNA_parameter_list_create(&list, &ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ gzgt->ext.call((bContext *)C, &ptr, func, &list);
+
+ RNA_parameter_get_lookup(&list, "visible", &ret);
+ visible = *(int *)ret;
+
+ RNA_parameter_list_free(&list);
+
+ return visible;
+}
+
+static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *gzgroup)
+{
+ extern FunctionRNA rna_GizmoGroup_setup_func;
+
+ PointerRNA gzgroup_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr);
+ func = &rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */
+
+ RNA_parameter_list_create(&list, &gzgroup_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
+
+static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
+{
+ extern FunctionRNA rna_GizmoGroup_setup_keymap_func;
+ void *ret;
+
+ PointerRNA ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, gzgt->ext.srna, NULL, &ptr); /* dummy */
+ func = &rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */
+
+ RNA_parameter_list_create(&list, &ptr, func);
+ RNA_parameter_set_lookup(&list, "keyconfig", &config);
+ gzgt->ext.call(NULL, &ptr, func, &list);
+
+ RNA_parameter_get_lookup(&list, "keymap", &ret);
+ wmKeyMap *keymap = *(wmKeyMap **)ret;
+
+ RNA_parameter_list_free(&list);
+
+ return keymap;
+}
+
+static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *gzgroup)
+{
+ extern FunctionRNA rna_GizmoGroup_refresh_func;
+
+ PointerRNA gzgroup_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr);
+ func = &rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */
+
+ RNA_parameter_list_create(&list, &gzgroup_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
+
+static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *gzgroup)
+{
+ extern FunctionRNA rna_GizmoGroup_draw_prepare_func;
+
+ PointerRNA gzgroup_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr);
+ func = &rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */
+
+ RNA_parameter_list_create(&list, &gzgroup_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
+
+void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata);
+static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type);
+
+static StructRNA *rna_GizmoGroup_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+{
+ struct {
+ char name[MAX_NAME];
+ char idname[MAX_NAME];
+ } temp_buffers;
+
+ wmGizmoGroupType dummywgt = {NULL};
+ wmGizmoGroup dummywg = {NULL};
+ PointerRNA wgptr;
+
+ /* Two sets of functions. */
+ int have_function[5];
+
+ /* setup dummy gizmogroup & gizmogroup type to store static properties in */
+ dummywg.type = &dummywgt;
+ dummywgt.name = temp_buffers.name;
+ dummywgt.idname = temp_buffers.idname;
+
+ RNA_pointer_create(NULL, &RNA_GizmoGroup, &dummywg, &wgptr);
+
+ /* Clear so we can detect if it's left unset. */
+ temp_buffers.idname[0] = temp_buffers.name[0] = '\0';
+
+ /* validate the python class */
+ if (validate(&wgptr, data, have_function) != 0)
+ return NULL;
+
+ if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
+ BKE_reportf(reports, RPT_ERROR, "Registering gizmogroup class: '%s' is too long, maximum length is %d",
+ identifier, (int)sizeof(temp_buffers.idname));
+ return NULL;
+ }
+
+ /* check if the area supports widgets */
+ const struct wmGizmoMapType_Params wmap_params = {
+ .spaceid = dummywgt.gzmap_params.spaceid,
+ .regionid = dummywgt.gzmap_params.regionid,
+ };
+
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params);
+ if (gzmap_type == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "Area type does not support gizmos");
+ return NULL;
+ }
+
+ /* check if we have registered this gizmogroup type before, and remove it */
+ {
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummywgt.idname, true);
+ if (gzgt && gzgt->ext.srna) {
+ rna_GizmoGroup_unregister(bmain, gzgt->ext.srna);
+ }
+ }
+ if (!RNA_struct_available_or_report(reports, dummywgt.idname)) {
+ return NULL;
+ }
+
+ { /* allocate the idname */
+ const char *strings[] = {
+ temp_buffers.idname,
+ temp_buffers.name,
+ };
+ char *strings_table[ARRAY_SIZE(strings)];
+ BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
+
+ dummywgt.idname = strings_table[0]; /* allocated string stored here */
+ dummywgt.name = strings_table[1];
+ BLI_assert(ARRAY_SIZE(strings) == 2);
+ }
+
+ /* create a new gizmogroup type */
+ dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_GizmoGroup);
+ RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* gizmogroup properties are registered separately */
+ dummywgt.ext.data = data;
+ dummywgt.ext.call = call;
+ dummywgt.ext.free = free;
+
+ /* We used to register widget group types like this, now we do it similar to
+ * operator types. Thus we should be able to do the same as operator types now. */
+ dummywgt.poll = (have_function[0]) ? rna_gizmogroup_poll_cb : NULL;
+ dummywgt.setup_keymap = (have_function[1]) ? rna_gizmogroup_setup_keymap_cb : NULL;
+ dummywgt.setup = (have_function[2]) ? rna_gizmogroup_setup_cb : NULL;
+ dummywgt.refresh = (have_function[3]) ? rna_gizmogroup_refresh_cb : NULL;
+ dummywgt.draw_prepare = (have_function[4]) ? rna_gizmogroup_draw_prepare_cb : NULL;
+
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_append_ptr(
+ BPY_RNA_gizmogroup_wrapper, (void *)&dummywgt);
+
+ {
+ const char *owner_id = RNA_struct_state_owner_get();
+ if (owner_id) {
+ BLI_strncpy(gzgt->owner_id, owner_id, sizeof(gzgt->owner_id));
+ }
+ }
+
+ if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) {
+ WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
+
+ /* update while blender is running */
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+ }
+
+ return dummywgt.ext.srna;
+}
+
+static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type)
+{
+ wmGizmoGroupType *gzgt = RNA_struct_blender_type_get(type);
+
+ if (!gzgt)
+ return;
+
+ RNA_struct_free_extension(type, &gzgt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
+
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+
+ WM_gizmo_group_type_remove_ptr(bmain, gzgt);
+}
+
+static void **rna_GizmoGroup_instance(PointerRNA *ptr)
+{
+ wmGizmoGroup *gzgroup = ptr->data;
+ return &gzgroup->py_instance;
+}
+
+#endif /* WITH_PYTHON */
+
+static StructRNA *rna_GizmoGroup_refine(PointerRNA *gzgroup_ptr)
+{
+ wmGizmoGroup *gzgroup = gzgroup_ptr->data;
+ return (gzgroup->type && gzgroup->type->ext.srna) ? gzgroup->type->ext.srna : &RNA_GizmoGroup;
+}
+
+static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *gzgroup_ptr)
+{
+ wmGizmoGroup *gzgroup = gzgroup_ptr->data;
+ rna_iterator_listbase_begin(iter, &gzgroup->gizmos, NULL);
+}
+
+/** \} */
+
+
+#else /* RNA_RUNTIME */
+
+
+/* GizmoGroup.gizmos */
+static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "Gizmos");
+ srna = RNA_def_struct(brna, "Gizmos", NULL);
+ RNA_def_struct_sdna(srna, "wmGizmoGroup");
+ RNA_def_struct_ui_text(srna, "Gizmos", "Collection of gizmos");
+
+ func = RNA_def_function(srna, "new", "rna_GizmoGroup_gizmo_new");
+ RNA_def_function_ui_description(func, "Add gizmo");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_string(func, "type", "Type", 0, "", "Gizmo identifier"); /* optional */
+ parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_GizmoGroup_gizmo_remove");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Delete gizmo");
+ parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+ func = RNA_def_function(srna, "clear", "rna_GizmoGroup_gizmo_clear");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Delete all gizmos");
+}
+
+
+static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "Gizmo");
+ srna = RNA_def_struct(brna, "Gizmo", NULL);
+ RNA_def_struct_sdna(srna, "wmGizmo");
+ RNA_def_struct_ui_text(srna, "Gizmo", "Collection of gizmos");
+ RNA_def_struct_refine_func(srna, "rna_Gizmo_refine");
+
+#ifdef WITH_PYTHON
+ RNA_def_struct_register_funcs(
+ srna,
+ "rna_Gizmo_register",
+ "rna_Gizmo_unregister",
+ "rna_Gizmo_instance");
+#endif
+ RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+
+ prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_struct_type(prop, "GizmoProperties");
+ RNA_def_property_ui_text(prop, "Properties", "");
+ RNA_def_property_pointer_funcs(prop, "rna_Gizmo_properties_get", NULL, NULL, NULL);
+
+ /* -------------------------------------------------------------------- */
+ /* Registerable Variables */
+
+ RNA_define_verify_sdna(0); /* not in sdna */
+
+ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->idname");
+ RNA_def_property_string_maxlength(prop, MAX_NAME);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Gizmo_bl_idname_set");
+ /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
+ RNA_def_property_flag(prop, PROP_REGISTER);
+
+ RNA_define_verify_sdna(1); /* not in sdna */
+
+ /* wmGizmo.draw */
+ func = RNA_def_function(srna, "draw", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* wmGizmo.draw_select */
+ func = RNA_def_function(srna, "draw_select", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+
+ /* wmGizmo.test_select */
+ func = RNA_def_function(srna, "test_select", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "event", "Event", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_int(func, "intersect_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+ RNA_def_function_return(func, parm);
+
+ /* wmGizmo.handler */
+ static EnumPropertyItem tweak_actions[] = {
+ {WM_GIZMO_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""},
+ {WM_GIZMO_TWEAK_SNAP, "SNAP", 0, "Snap", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ func = RNA_def_function(srna, "modal", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "event", "Event", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ /* TODO, shuold be a enum-flag */
+ parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
+ RNA_def_function_return(func, parm);
+ /* wmGizmo.property_update */
+ /* TODO */
+
+ /* wmGizmo.setup */
+ func = RNA_def_function(srna, "setup", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+
+ /* wmGizmo.invoke */
+ func = RNA_def_function(srna, "invoke", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "event", "Event", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
+ RNA_def_function_return(func, parm);
+
+ /* wmGizmo.exit */
+ func = RNA_def_function(srna, "exit", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
+ /* wmGizmo.cursor_get */
+ /* TODO */
+
+ /* wmGizmo.select_refresh */
+ func = RNA_def_function(srna, "select_refresh", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+
+
+ /* -------------------------------------------------------------------- */
+ /* Instance Variables */
+
+ prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "GizmoGroup");
+ RNA_def_property_pointer_funcs(prop, "rna_Gizmo_group_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "", "Gizmo group this gizmo is a member of");
+
+ /* Color & Alpha */
+ prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_color_get", "rna_Gizmo_color_set", NULL);
+
+ prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Alpha", "");
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_get", "rna_Gizmo_alpha_set", NULL);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ /* Color & Alpha (highlight) */
+ prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_color_hi_get", "rna_Gizmo_color_hi_set", NULL);
+
+ prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Alpha", "");
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_hi_get", "rna_Gizmo_alpha_hi_set", NULL);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(prop, "Space Matrix", "");
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_space_get", "rna_Gizmo_matrix_space_set", NULL);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(prop, "Basis Matrix", "");
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_basis_get", "rna_Gizmo_matrix_basis_set", NULL);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(prop, "Offset Matrix", "");
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_offset_get", "rna_Gizmo_matrix_offset_set", NULL);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(prop, "Final World Matrix", "");
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_world_get", NULL, NULL);
+
+ prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Scale Basis", "");
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_scale_basis_get", "rna_Gizmo_scale_basis_set", NULL);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL);
+ RNA_def_property_ui_text(prop, "Line Width", "");
+ RNA_def_property_float_funcs(prop, "rna_Gizmo_line_width_get", "rna_Gizmo_line_width_set", NULL);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ /* wmGizmo.flag */
+ /* WM_GIZMO_HIDDEN */
+ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set");
+ RNA_def_property_ui_text(prop, "Hide", "");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_GIZMO_GRAB_CURSOR */
+ prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Gizmo_flag_use_grab_cursor_get", "rna_Gizmo_flag_use_grab_cursor_set");
+ RNA_def_property_ui_text(prop, "Grab Cursor", "");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ /* WM_GIZMO_DRAW_HOVER */
+ prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Gizmo_flag_use_draw_hover_get", "rna_Gizmo_flag_use_draw_hover_set");
+ RNA_def_property_ui_text(prop, "Draw Hover", "");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_GIZMO_DRAW_MODAL */
+ prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Gizmo_flag_use_draw_modal_get", "rna_Gizmo_flag_use_draw_modal_set");
+ RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_GIZMO_DRAW_VALUE */
+ prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Gizmo_flag_use_draw_value_get", "rna_Gizmo_flag_use_draw_value_set");
+ RNA_def_property_ui_text(prop, "Draw Value", "Show an indicator for the current value while dragging");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_GIZMO_DRAW_OFFSET_SCALE */
+ prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Gizmo_flag_use_draw_offset_scale_get", "rna_Gizmo_flag_use_draw_offset_scale_set");
+ RNA_def_property_ui_text(prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_GIZMO_DRAW_NO_SCALE (negated) */
+ prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Gizmo_flag_use_draw_scale_get", "rna_Gizmo_flag_use_draw_scale_set");
+ RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_GIZMO_SELECT_BACKGROUND */
+ prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Gizmo_flag_use_select_background_get", "rna_Gizmo_flag_use_select_background_set");
+ RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ /* wmGizmo.state (readonly) */
+ /* WM_GIZMO_STATE_HIGHLIGHT */
+ prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_highlight_get", NULL);
+ RNA_def_property_ui_text(prop, "Highlight", "");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ /* WM_GIZMO_STATE_MODAL */
+ prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_modal_get", NULL);
+ RNA_def_property_ui_text(prop, "Highlight", "");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ /* WM_GIZMO_STATE_SELECT */
+ /* (note that setting is involved, needs to handle array) */
+ prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_select_get", "rna_Gizmo_state_select_set");
+ RNA_def_property_ui_text(prop, "Select", "");
+
+ RNA_api_gizmo(srna);
+
+ srna = RNA_def_struct(brna, "GizmoProperties", NULL);
+ RNA_def_struct_ui_text(srna, "Gizmo Properties", "Input properties of an Gizmo");
+ RNA_def_struct_refine_func(srna, "rna_GizmoProperties_refine");
+ RNA_def_struct_idprops_func(srna, "rna_GizmoProperties_idprops");
+ RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES);
+}
+
+static void rna_def_gizmogroup(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ srna = RNA_def_struct(brna, "GizmoGroup", NULL);
+ RNA_def_struct_ui_text(srna, "GizmoGroup", "Storage of an operator being executed, or registered after execution");
+ RNA_def_struct_sdna(srna, "wmGizmoGroup");
+ RNA_def_struct_refine_func(srna, "rna_GizmoGroup_refine");
+#ifdef WITH_PYTHON
+ RNA_def_struct_register_funcs(
+ srna,
+ "rna_GizmoGroup_register",
+ "rna_GizmoGroup_unregister",
+ "rna_GizmoGroup_instance");
+#endif
+ RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+
+ /* -------------------------------------------------------------------- */
+ /* Registration */
+
+ RNA_define_verify_sdna(0); /* not in sdna */
+
+ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->idname");
+ RNA_def_property_string_maxlength(prop, MAX_NAME);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GizmoGroup_bl_idname_set");
+ RNA_def_property_flag(prop, PROP_REGISTER);
+ RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->name");
+ RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GizmoGroup_bl_label_set");
+ /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
+ RNA_def_property_flag(prop, PROP_REGISTER);
+
+ prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type->gzmap_params.spaceid");
+ RNA_def_property_enum_items(prop, rna_enum_space_type_items);
+ RNA_def_property_flag(prop, PROP_REGISTER);
+ RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in");
+
+ prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type->gzmap_params.regionid");
+ RNA_def_property_enum_items(prop, rna_enum_region_type_items);
+ RNA_def_property_flag(prop, PROP_REGISTER);
+ RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in");
+
+ prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+
+ /* bl_options */
+ static EnumPropertyItem gizmogroup_flag_items[] = {
+ {WM_GIZMOGROUPTYPE_3D, "3D", 0, "3D",
+ "Use in 3D viewport"},
+ {WM_GIZMOGROUPTYPE_SCALE, "SCALE", 0, "Scale",
+ "Scale to respect zoom (otherwise zoom independent draw size)"},
+ {WM_GIZMOGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D",
+ "Supports culled depth by other objects in the view"},
+ {WM_GIZMOGROUPTYPE_SELECT, "SELECT", 0, "Select",
+ "Supports selection"},
+ {WM_GIZMOGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent",
+ ""},
+ {WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All",
+ "Show all while interacting"},
+ {0, NULL, 0, NULL, NULL}
+ };
+ prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type->flag");
+ RNA_def_property_enum_items(prop, gizmogroup_flag_items);
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
+ RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
+
+ RNA_define_verify_sdna(1); /* not in sdna */
+
+
+ /* Functions */
+
+ /* poll */
+ func = RNA_def_function(srna, "poll", NULL);
+ RNA_def_function_ui_description(func, "Test if the gizmo group can be called or not");
+ RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* setup_keymap */
+ func = RNA_def_function(srna, "setup_keymap", NULL);
+ RNA_def_function_ui_description(
+ func,
+ "Initialize keymaps for this gizmo group, use fallback keymap when not present");
+ RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ /* return */
+ parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
+ RNA_def_property_flag(parm, PROP_NEVER_NULL);
+ RNA_def_function_return(func, parm);
+
+ /* setup */
+ func = RNA_def_function(srna, "setup", NULL);
+ RNA_def_function_ui_description(func, "Create gizmos function for the gizmo group");
+ RNA_def_function_flag(func, FUNC_REGISTER);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* refresh */
+ func = RNA_def_function(srna, "refresh", NULL);
+ RNA_def_function_ui_description(func, "Refresh data (called on common state changes such as selection)");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ func = RNA_def_function(srna, "draw_prepare", NULL);
+ RNA_def_function_ui_description(func, "Run before each redraw");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* -------------------------------------------------------------------- */
+ /* Instance Variables */
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_GizmoGroup_name_get", "rna_GizmoGroup_name_length", NULL);
+ RNA_def_property_ui_text(prop, "Name", "");
+
+ prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
+ RNA_def_property_boolean_funcs(prop, "rna_GizmoGroup_has_reports_get", NULL);
+ RNA_def_property_ui_text(prop, "Has Reports",
+ "GizmoGroup has a set of reports (warnings and errors) from last execution");
+
+
+ RNA_define_verify_sdna(0); /* not in sdna */
+
+ prop = RNA_def_property(srna, "gizmos", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "gizmos", NULL);
+ RNA_def_property_struct_type(prop, "Gizmo");
+ RNA_def_property_collection_funcs(
+ prop, "rna_GizmoGroup_gizmos_begin", "rna_iterator_listbase_next",
+ "rna_iterator_listbase_end", "rna_iterator_listbase_get",
+ NULL, NULL, NULL, NULL);
+
+ RNA_def_property_ui_text(prop, "Gizmos", "List of gizmos in the Gizmo Map");
+ rna_def_gizmo(brna, prop);
+ rna_def_gizmos(brna, prop);
+
+ RNA_define_verify_sdna(1); /* not in sdna */
+
+ RNA_api_gizmogroup(srna);
+}
+
+void RNA_def_wm_gizmo(BlenderRNA *brna)
+{
+ rna_def_gizmogroup(brna);
+}
+
+#endif /* RNA_RUNTIME */
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator_api.c b/source/blender/makesrna/intern/rna_wm_gizmo_api.c
index 16804042608..e8a9e585165 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator_api.c
+++ b/source/blender/makesrna/intern/rna_wm_gizmo_api.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/makesrna/intern/rna_wm_manipulator_api.c
+/** \file blender/makesrna/intern/rna_wm_gizmo_api.c
* \ingroup RNA
*/
@@ -44,46 +44,46 @@
#include "UI_interface.h"
#include "BKE_context.h"
-#include "ED_manipulator_library.h"
+#include "ED_gizmo_library.h"
-static void rna_manipulator_draw_preset_box(
- wmManipulator *mpr, float matrix[16], int select_id)
+static void rna_gizmo_draw_preset_box(
+ wmGizmo *gz, float matrix[16], int select_id)
{
- ED_manipulator_draw_preset_box(mpr, (float (*)[4])matrix, select_id);
+ ED_gizmo_draw_preset_box(gz, (float (*)[4])matrix, select_id);
}
-static void rna_manipulator_draw_preset_arrow(
- wmManipulator *mpr, float matrix[16], int axis, int select_id)
+static void rna_gizmo_draw_preset_arrow(
+ wmGizmo *gz, float matrix[16], int axis, int select_id)
{
- ED_manipulator_draw_preset_arrow(mpr, (float (*)[4])matrix, axis, select_id);
+ ED_gizmo_draw_preset_arrow(gz, (float (*)[4])matrix, axis, select_id);
}
-static void rna_manipulator_draw_preset_circle(
- wmManipulator *mpr, float matrix[16], int axis, int select_id)
+static void rna_gizmo_draw_preset_circle(
+ wmGizmo *gz, float matrix[16], int axis, int select_id)
{
- ED_manipulator_draw_preset_circle(mpr, (float (*)[4])matrix, axis, select_id);
+ ED_gizmo_draw_preset_circle(gz, (float (*)[4])matrix, axis, select_id);
}
-static void rna_manipulator_draw_preset_facemap(
- wmManipulator *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id)
+static void rna_gizmo_draw_preset_facemap(
+ wmGizmo *gz, struct bContext *C, struct Object *ob, int facemap, int select_id)
{
struct Scene *scene = CTX_data_scene(C);
- ED_manipulator_draw_preset_facemap(C, mpr, scene, ob, facemap, select_id);
+ ED_gizmo_draw_preset_facemap(C, gz, scene, ob, facemap, select_id);
}
/* -------------------------------------------------------------------- */
-/** \name Manipulator Property Define
+/** \name Gizmo Property Define
* \{ */
-static void rna_manipulator_target_set_prop(
- wmManipulator *mpr, ReportList *reports, const char *target_propname,
+static void rna_gizmo_target_set_prop(
+ wmGizmo *gz, ReportList *reports, const char *target_propname,
PointerRNA *ptr, const char *propname, int index)
{
- const wmManipulatorPropertyType *mpr_prop_type =
- WM_manipulatortype_target_property_find(mpr->type, target_propname);
- if (mpr_prop_type == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found",
- mpr->type->idname, target_propname);
+ const wmGizmoPropertyType *gz_prop_type =
+ WM_gizmotype_target_property_find(gz->type, target_propname);
+ if (gz_prop_type == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' not found",
+ gz->type->idname, target_propname);
return;
}
@@ -94,14 +94,14 @@ static void rna_manipulator_target_set_prop(
return;
}
- if (mpr_prop_type->data_type != RNA_property_type(prop)) {
- const int manipulator_type_index = RNA_enum_from_value(rna_enum_property_type_items, mpr_prop_type->data_type);
+ if (gz_prop_type->data_type != RNA_property_type(prop)) {
+ const int gizmo_type_index = RNA_enum_from_value(rna_enum_property_type_items, gz_prop_type->data_type);
const int prop_type_index = RNA_enum_from_value(rna_enum_property_type_items, RNA_property_type(prop));
- BLI_assert((manipulator_type_index != -1) && (prop_type_index == -1));
+ BLI_assert((gizmo_type_index != -1) && (prop_type_index == -1));
- BKE_reportf(reports, RPT_ERROR, "Manipulator target '%s.%s' expects '%s', '%s.%s' is '%s'",
- mpr->type->idname, target_propname,
- rna_enum_property_type_items[manipulator_type_index].identifier,
+ BKE_reportf(reports, RPT_ERROR, "Gizmo target '%s.%s' expects '%s', '%s.%s' is '%s'",
+ gz->type->idname, target_propname,
+ rna_enum_property_type_items[gizmo_type_index].identifier,
RNA_struct_identifier(ptr->type), propname,
rna_enum_property_type_items[prop_type_index].identifier);
return;
@@ -110,37 +110,37 @@ static void rna_manipulator_target_set_prop(
if (RNA_property_array_check(prop)) {
if (index == -1) {
const int prop_array_length = RNA_property_array_length(ptr, prop);
- if (mpr_prop_type->array_length != prop_array_length) {
+ if (gz_prop_type->array_length != prop_array_length) {
BKE_reportf(reports, RPT_ERROR,
- "Manipulator target property '%s.%s' expects an array of length %d, found %d",
- mpr->type->idname, target_propname,
- mpr_prop_type->array_length,
+ "Gizmo target property '%s.%s' expects an array of length %d, found %d",
+ gz->type->idname, target_propname,
+ gz_prop_type->array_length,
prop_array_length);
return;
}
}
}
else {
- if (mpr_prop_type->array_length != 1) {
+ if (gz_prop_type->array_length != 1) {
BKE_reportf(reports, RPT_ERROR,
- "Manipulator target property '%s.%s' expects an array of length %d",
- mpr->type->idname, target_propname,
- mpr_prop_type->array_length);
+ "Gizmo target property '%s.%s' expects an array of length %d",
+ gz->type->idname, target_propname,
+ gz_prop_type->array_length);
return;
}
}
- if (index >= mpr_prop_type->array_length) {
- BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s', index %d must be below %d",
- mpr->type->idname, target_propname, index, mpr_prop_type->array_length);
+ if (index >= gz_prop_type->array_length) {
+ BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s', index %d must be below %d",
+ gz->type->idname, target_propname, index, gz_prop_type->array_length);
return;
}
- WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index);
+ WM_gizmo_target_property_def_rna_ptr(gz, gz_prop_type, ptr, prop, index);
}
-static PointerRNA rna_manipulator_target_set_operator(
- wmManipulator *mpr, ReportList *reports, const char *opname, int part_index)
+static PointerRNA rna_gizmo_target_set_operator(
+ wmGizmo *gz, ReportList *reports, const char *opname, int part_index)
{
wmOperatorType *ot;
@@ -154,36 +154,36 @@ static PointerRNA rna_manipulator_target_set_operator(
IDProperty *properties;
{
IDPropertyTemplate val = {0};
- properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties");
+ properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties");
}
- return *WM_manipulator_operator_set(mpr, part_index, ot, properties);
+ return *WM_gizmo_operator_set(gz, part_index, ot, properties);
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Manipulator Property Access
+/** \name Gizmo Property Access
* \{ */
-static bool rna_manipulator_target_is_valid(
- wmManipulator *mpr, ReportList *reports, const char *target_propname)
+static bool rna_gizmo_target_is_valid(
+ wmGizmo *gz, ReportList *reports, const char *target_propname)
{
- wmManipulatorProperty *mpr_prop =
- WM_manipulator_target_property_find(mpr, target_propname);
- if (mpr_prop == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found",
- mpr->type->idname, target_propname);
+ wmGizmoProperty *gz_prop =
+ WM_gizmo_target_property_find(gz, target_propname);
+ if (gz_prop == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' not found",
+ gz->type->idname, target_propname);
return false;
}
- return WM_manipulator_target_property_is_valid(mpr_prop);
+ return WM_gizmo_target_property_is_valid(gz_prop);
}
/** \} */
#else
-void RNA_api_manipulator(StructRNA *srna)
+void RNA_api_gizmo(StructRNA *srna)
{
/* Utility draw functions, since we don't expose new OpenGL drawing wrappers via Python yet.
* exactly how these should be exposed isn't totally clear.
@@ -198,7 +198,7 @@ void RNA_api_manipulator(StructRNA *srna)
/* Primitive Shapes */
/* draw_preset_box */
- func = RNA_def_function(srna, "draw_preset_box", "rna_manipulator_draw_preset_box");
+ func = RNA_def_function(srna, "draw_preset_box", "rna_gizmo_draw_preset_box");
RNA_def_function_ui_description(func, "Draw a box");
parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -207,7 +207,7 @@ void RNA_api_manipulator(StructRNA *srna)
RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX);
/* draw_preset_box */
- func = RNA_def_function(srna, "draw_preset_arrow", "rna_manipulator_draw_preset_arrow");
+ func = RNA_def_function(srna, "draw_preset_arrow", "rna_gizmo_draw_preset_arrow");
RNA_def_function_ui_description(func, "Draw a box");
parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -216,7 +216,7 @@ void RNA_api_manipulator(StructRNA *srna)
RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation");
RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX);
- func = RNA_def_function(srna, "draw_preset_circle", "rna_manipulator_draw_preset_circle");
+ func = RNA_def_function(srna, "draw_preset_circle", "rna_gizmo_draw_preset_circle");
RNA_def_function_ui_description(func, "Draw a box");
parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -229,7 +229,7 @@ void RNA_api_manipulator(StructRNA *srna)
/* Other Shapes */
/* draw_preset_facemap */
- func = RNA_def_function(srna, "draw_preset_facemap", "rna_manipulator_draw_preset_facemap");
+ func = RNA_def_function(srna, "draw_preset_facemap", "rna_gizmo_draw_preset_facemap");
RNA_def_function_ui_description(func, "Draw the face-map of a mesh object");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
parm = RNA_def_pointer(func, "object", "Object", "", "Object");
@@ -242,8 +242,8 @@ void RNA_api_manipulator(StructRNA *srna)
/* Property API */
/* Define Properties */
- /* note, 'target_set_handler' is defined in 'bpy_rna_manipulator.c' */
- func = RNA_def_function(srna, "target_set_prop", "rna_manipulator_target_set_prop");
+ /* note, 'target_set_handler' is defined in 'bpy_rna_gizmo.c' */
+ func = RNA_def_function(srna, "target_set_prop", "rna_gizmo_target_set_prop");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "");
parm = RNA_def_string(func, "target", NULL, 0, "", "Target property");
@@ -255,10 +255,10 @@ void RNA_api_manipulator(StructRNA *srna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_int(func, "index", -1, -1, INT_MAX, "", "", -1, INT_MAX); /* RNA_NO_INDEX == -1 */
- func = RNA_def_function(srna, "target_set_operator", "rna_manipulator_target_set_operator");
+ func = RNA_def_function(srna, "target_set_operator", "rna_gizmo_target_set_operator");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(
- func, "Operator to run when activating the manipulator "
+ func, "Operator to run when activating the gizmo "
"(overrides property targets)");
parm = RNA_def_string(func, "operator", NULL, 0, "", "Target operator");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -270,8 +270,8 @@ void RNA_api_manipulator(StructRNA *srna)
RNA_def_function_return(func, parm);
/* Access Properties */
- /* note, 'target_get', 'target_set' is defined in 'bpy_rna_manipulator.c' */
- func = RNA_def_function(srna, "target_is_valid", "rna_manipulator_target_is_valid");
+ /* note, 'target_get', 'target_set' is defined in 'bpy_rna_gizmo.c' */
+ func = RNA_def_function(srna, "target_is_valid", "rna_gizmo_target_is_valid");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_string(func, "property", NULL, 0, "", "Property identifier");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -282,7 +282,7 @@ void RNA_api_manipulator(StructRNA *srna)
}
-void RNA_api_manipulatorgroup(StructRNA *UNUSED(srna))
+void RNA_api_gizmogroup(StructRNA *UNUSED(srna))
{
/* nothing yet */
}
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
deleted file mode 100644
index 6cfee512ff7..00000000000
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ /dev/null
@@ -1,1328 +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/makesrna/intern/rna_wm_manipulator.c
- * \ingroup RNA
- */
-
-#include <stdlib.h>
-
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-#include "DNA_userdef_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_windowmanager_types.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_string_utils.h"
-
-#include "BLT_translation.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-#include "RNA_enum_types.h"
-
-#include "rna_internal.h"
-
-#include "WM_types.h"
-
-#ifdef RNA_RUNTIME
-/* enum definitions */
-#endif /* RNA_RUNTIME */
-
-#ifdef RNA_RUNTIME
-
-#include <assert.h>
-
-#include "WM_api.h"
-
-#include "DNA_workspace_types.h"
-
-#include "ED_screen.h"
-
-#include "UI_interface.h"
-
-#include "BKE_global.h"
-#include "BKE_idprop.h"
-#include "BKE_workspace.h"
-
-#include "MEM_guardedalloc.h"
-
-#ifdef WITH_PYTHON
-# include "BPY_extern.h"
-#endif
-
-/* -------------------------------------------------------------------- */
-
-/** \name Manipulator API
- * \{ */
-
-#ifdef WITH_PYTHON
-static void rna_manipulator_draw_cb(
- const struct bContext *C, struct wmManipulator *mpr)
-{
- extern FunctionRNA rna_Manipulator_draw_func;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- PointerRNA mpr_ptr;
- ParameterList list;
- FunctionRNA *func;
- RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "draw"); */
- func = &rna_Manipulator_draw_func;
- RNA_parameter_list_create(&list, &mpr_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
- RNA_parameter_list_free(&list);
-}
-
-static void rna_manipulator_draw_select_cb(
- const struct bContext *C, struct wmManipulator *mpr, int select_id)
-{
- extern FunctionRNA rna_Manipulator_draw_select_func;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- PointerRNA mpr_ptr;
- ParameterList list;
- FunctionRNA *func;
- RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "draw_select"); */
- func = &rna_Manipulator_draw_select_func;
- RNA_parameter_list_create(&list, &mpr_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- RNA_parameter_set_lookup(&list, "select_id", &select_id);
- mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
- RNA_parameter_list_free(&list);
-}
-
-static int rna_manipulator_test_select_cb(
- struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event)
-{
- extern FunctionRNA rna_Manipulator_test_select_func;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- PointerRNA mpr_ptr;
- ParameterList list;
- FunctionRNA *func;
- RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "test_select"); */
- func = &rna_Manipulator_test_select_func;
- RNA_parameter_list_create(&list, &mpr_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- RNA_parameter_set_lookup(&list, "event", &event);
- mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
-
- void *ret;
- RNA_parameter_get_lookup(&list, "intersect_id", &ret);
- int intersect_id = *(int *)ret;
-
- RNA_parameter_list_free(&list);
- return intersect_id;
-}
-
-static int rna_manipulator_modal_cb(
- struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event,
- eWM_ManipulatorTweak tweak_flag)
-{
- extern FunctionRNA rna_Manipulator_modal_func;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- PointerRNA mpr_ptr;
- ParameterList list;
- FunctionRNA *func;
- const int tweak_flag_int = tweak_flag;
- RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "modal"); */
- func = &rna_Manipulator_modal_func;
- RNA_parameter_list_create(&list, &mpr_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- RNA_parameter_set_lookup(&list, "event", &event);
- RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
- mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
-
- void *ret;
- RNA_parameter_get_lookup(&list, "result", &ret);
- int ret_enum = *(int *)ret;
-
- RNA_parameter_list_free(&list);
- return ret_enum;
-}
-
-static void rna_manipulator_setup_cb(
- struct wmManipulator *mpr)
-{
- extern FunctionRNA rna_Manipulator_setup_func;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- PointerRNA mpr_ptr;
- ParameterList list;
- FunctionRNA *func;
- RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "setup"); */
- func = &rna_Manipulator_setup_func;
- RNA_parameter_list_create(&list, &mpr_ptr, func);
- mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list);
- RNA_parameter_list_free(&list);
-}
-
-
-static int rna_manipulator_invoke_cb(
- struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event)
-{
- extern FunctionRNA rna_Manipulator_invoke_func;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- PointerRNA mpr_ptr;
- ParameterList list;
- FunctionRNA *func;
- RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "invoke"); */
- func = &rna_Manipulator_invoke_func;
- RNA_parameter_list_create(&list, &mpr_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- RNA_parameter_set_lookup(&list, "event", &event);
- mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
-
- void *ret;
- RNA_parameter_get_lookup(&list, "result", &ret);
- int ret_enum = *(int *)ret;
-
- RNA_parameter_list_free(&list);
- return ret_enum;
-}
-
-static void rna_manipulator_exit_cb(
- struct bContext *C, struct wmManipulator *mpr, bool cancel)
-{
- extern FunctionRNA rna_Manipulator_exit_func;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- PointerRNA mpr_ptr;
- ParameterList list;
- FunctionRNA *func;
- RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "exit"); */
- func = &rna_Manipulator_exit_func;
- RNA_parameter_list_create(&list, &mpr_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- {
- int cancel_i = cancel;
- RNA_parameter_set_lookup(&list, "cancel", &cancel_i);
- }
- mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
- RNA_parameter_list_free(&list);
-}
-
-static void rna_manipulator_select_refresh_cb(
- struct wmManipulator *mpr)
-{
- extern FunctionRNA rna_Manipulator_select_refresh_func;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- PointerRNA mpr_ptr;
- ParameterList list;
- FunctionRNA *func;
- RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "select_refresh"); */
- func = &rna_Manipulator_select_refresh_func;
- RNA_parameter_list_create(&list, &mpr_ptr, func);
- mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list);
- RNA_parameter_list_free(&list);
-}
-
-#endif /* WITH_PYTHON */
-
-/* just to work around 'const char *' warning and to ensure this is a python op */
-static void rna_Manipulator_bl_idname_set(PointerRNA *ptr, const char *value)
-{
- wmManipulator *data = ptr->data;
- char *str = (char *)data->type->idname;
- if (!str[0]) {
- BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
- }
- else {
- assert(!"setting the bl_idname on a non-builtin operator");
- }
-}
-
-static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr)
-{
-#if 0
- wmWindowManager *wm = ptr->id.data;
-#endif
-
- /* We could try workaruond this lookup, but not trivial. */
- for (bScreen *screen = G_MAIN->screen.first; screen; screen = screen->id.next) {
- IDProperty *properties = ptr->data;
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->manipulator_map) {
- wmManipulatorMap *mmap = ar->manipulator_map;
- for (wmManipulatorGroup *mgroup = WM_manipulatormap_group_list(mmap)->first;
- mgroup;
- mgroup = mgroup->next)
- {
- for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
- if (mpr->properties == properties) {
- return mpr;
- }
- }
- }
- }
- }
- }
- }
- return NULL;
-}
-
-static StructRNA *rna_ManipulatorProperties_refine(PointerRNA *ptr)
-{
- wmManipulator *mpr = rna_ManipulatorProperties_find_operator(ptr);
-
- if (mpr)
- return mpr->type->srna;
- else
- return ptr->type;
-}
-
-static IDProperty *rna_ManipulatorProperties_idprops(PointerRNA *ptr, bool create)
-{
- if (create && !ptr->data) {
- IDPropertyTemplate val = {0};
- ptr->data = IDP_New(IDP_GROUP, &val, "RNA_ManipulatorProperties group");
- }
-
- return ptr->data;
-}
-
-static PointerRNA rna_Manipulator_properties_get(PointerRNA *ptr)
-{
- wmManipulator *mpr = ptr->data;
- return rna_pointer_inherit_refine(ptr, mpr->type->srna, mpr->properties);
-}
-
-/* wmManipulator.float */
-#define RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(func_id, member_id) \
-static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
-{ \
- wmManipulator *mpr = ptr->data; \
- return mpr->member_id; \
-} \
-static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \
-{ \
- wmManipulator *mpr = ptr->data; \
- mpr->member_id = value; \
-}
-#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \
-static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
-{ \
- wmManipulator *mpr = ptr->data; \
- return mpr->member_id[index]; \
-} \
-static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \
-{ \
- wmManipulator *mpr = ptr->data; \
- mpr->member_id[index] = value; \
-}
-/* wmManipulator.float[len] */
-#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
-static void rna_Manipulator_##func_id##_get(PointerRNA *ptr, float value[len]) \
-{ \
- wmManipulator *mpr = ptr->data; \
- memcpy(value, mpr->member_id, sizeof(float[len])); \
-} \
-static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, const float value[len]) \
-{ \
- wmManipulator *mpr = ptr->data; \
- memcpy(mpr->member_id, value, sizeof(float[len])); \
-}
-
-/* wmManipulator.flag */
-#define RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \
-static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
-{ \
- wmManipulator *mpr = ptr->data; \
- return (mpr->member_id & flag_value) != 0; \
-} \
-static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, int value) \
-{ \
- wmManipulator *mpr = ptr->data; \
- SET_FLAG_FROM_TEST(mpr->member_id, value, flag_value); \
-}
-
-/* wmManipulator.flag (negative) */
-#define RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \
-static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
-{ \
- wmManipulator *mpr = ptr->data; \
- return (mpr->member_id & flag_value) == 0; \
-} \
-static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, int value) \
-{ \
- wmManipulator *mpr = ptr->data; \
- SET_FLAG_FROM_TEST(mpr->member_id, !value, flag_value); \
-}
-
-#define RNA_MANIPULATOR_FLAG_RO_DEF(func_id, member_id, flag_value) \
-static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
-{ \
- wmManipulator *mpr = ptr->data; \
- return (mpr->member_id & flag_value) != 0; \
-}
-
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3);
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3);
-
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3);
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3);
-
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16);
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
-
-static void rna_Manipulator_matrix_world_get(PointerRNA *ptr, float value[16])
-{
- wmManipulator *mpr = ptr->data;
- WM_manipulator_calc_matrix_final(mpr, (float (*)[4])value);
-}
-
-RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
-RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(line_width, line_width);
-
-RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_MANIPULATOR_DRAW_HOVER);
-RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_MANIPULATOR_DRAW_MODAL);
-RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_MANIPULATOR_DRAW_VALUE);
-RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE);
-RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE);
-RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN);
-RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_MANIPULATOR_GRAB_CURSOR);
-
-/* wmManipulator.state */
-RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT);
-RNA_MANIPULATOR_FLAG_RO_DEF(state_is_modal, state, WM_MANIPULATOR_STATE_MODAL);
-RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT);
-
-static void rna_Manipulator_state_select_set(struct PointerRNA *ptr, int value)
-{
- wmManipulator *mpr = ptr->data;
- wmManipulatorGroup *mgroup = mpr->parent_mgroup;
- WM_manipulator_select_set(mgroup->parent_mmap, mpr, value);
-}
-
-static PointerRNA rna_Manipulator_group_get(PointerRNA *ptr)
-{
- wmManipulator *mpr = ptr->data;
- return rna_pointer_inherit_refine(ptr, &RNA_ManipulatorGroup, mpr->parent_mgroup);
-}
-
-#ifdef WITH_PYTHON
-
-static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type);
-void BPY_RNA_manipulator_wrapper(wmManipulatorType *wgt, void *userdata);
-
-static StructRNA *rna_Manipulator_register(
- Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
-{
- struct {
- char idname[MAX_NAME];
- } temp_buffers;
-
- wmManipulatorType dummywt = {NULL};
- wmManipulator dummymnp = {NULL};
- PointerRNA mnp_ptr;
-
- /* Two sets of functions. */
- int have_function[8];
-
- /* setup dummy manipulator & manipulator type to store static properties in */
- dummymnp.type = &dummywt;
- dummywt.idname = temp_buffers.idname;
- RNA_pointer_create(NULL, &RNA_Manipulator, &dummymnp, &mnp_ptr);
-
- /* Clear so we can detect if it's left unset. */
- temp_buffers.idname[0] = '\0';
-
- /* validate the python class */
- if (validate(&mnp_ptr, data, have_function) != 0)
- return NULL;
-
- if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
- BKE_reportf(reports, RPT_ERROR, "Registering manipulator class: '%s' is too long, maximum length is %d",
- identifier, (int)sizeof(temp_buffers.idname));
- return NULL;
- }
-
- /* check if we have registered this manipulator type before, and remove it */
- {
- const wmManipulatorType *wt = WM_manipulatortype_find(dummywt.idname, true);
- if (wt && wt->ext.srna) {
- rna_Manipulator_unregister(bmain, wt->ext.srna);
- }
- }
- if (!RNA_struct_available_or_report(reports, dummywt.idname)) {
- return NULL;
- }
-
- { /* allocate the idname */
- /* For multiple strings see ManipulatorGroup. */
- dummywt.idname = BLI_strdup(temp_buffers.idname);
- }
-
- /* create a new manipulator type */
- dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Manipulator);
- /* manipulator properties are registered separately */
- RNA_def_struct_flag(dummywt.ext.srna, STRUCT_NO_IDPROPERTIES);
- dummywt.ext.data = data;
- dummywt.ext.call = call;
- dummywt.ext.free = free;
-
- {
- int i = 0;
- dummywt.draw = (have_function[i++]) ? rna_manipulator_draw_cb : NULL;
- dummywt.draw_select = (have_function[i++]) ? rna_manipulator_draw_select_cb : NULL;
- dummywt.test_select = (have_function[i++]) ? rna_manipulator_test_select_cb : NULL;
- dummywt.modal = (have_function[i++]) ? rna_manipulator_modal_cb : NULL;
-// dummywt.property_update = (have_function[i++]) ? rna_manipulator_property_update : NULL;
-// dummywt.position_get = (have_function[i++]) ? rna_manipulator_position_get : NULL;
- dummywt.setup = (have_function[i++]) ? rna_manipulator_setup_cb : NULL;
- dummywt.invoke = (have_function[i++]) ? rna_manipulator_invoke_cb : NULL;
- dummywt.exit = (have_function[i++]) ? rna_manipulator_exit_cb : NULL;
- dummywt.select_refresh = (have_function[i++]) ? rna_manipulator_select_refresh_cb : NULL;
-
- BLI_assert(i == ARRAY_SIZE(have_function));
- }
-
- WM_manipulatortype_append_ptr(BPY_RNA_manipulator_wrapper, (void *)&dummywt);
-
- /* update while blender is running */
- WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
-
- return dummywt.ext.srna;
-}
-
-static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type)
-{
- wmManipulatorType *wt = RNA_struct_blender_type_get(type);
-
- if (!wt)
- return;
-
- RNA_struct_free_extension(type, &wt->ext);
- RNA_struct_free(&BLENDER_RNA, type);
-
- WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
-
- WM_manipulatortype_remove_ptr(NULL, bmain, wt);
-}
-
-static void **rna_Manipulator_instance(PointerRNA *ptr)
-{
- wmManipulator *mpr = ptr->data;
- return &mpr->py_instance;
-}
-
-#endif /* WITH_PYTHON */
-
-
-static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr)
-{
- wmManipulator *mpr = mnp_ptr->data;
- return (mpr->type && mpr->type->ext.srna) ? mpr->type->ext.srna : &RNA_Manipulator;
-}
-
-/** \} */
-
-/** \name Manipulator Group API
- * \{ */
-
-static wmManipulator *rna_ManipulatorGroup_manipulator_new(
- wmManipulatorGroup *mgroup, ReportList *reports, const char *idname)
-{
- const wmManipulatorType *wt = WM_manipulatortype_find(idname, true);
- if (wt == NULL) {
- BKE_reportf(reports, RPT_ERROR, "ManipulatorType '%s' not known", idname);
- return NULL;
- }
- wmManipulator *mpr = WM_manipulator_new_ptr(wt, mgroup, NULL);
- return mpr;
-}
-
-static void rna_ManipulatorGroup_manipulator_remove(
- wmManipulatorGroup *mgroup, bContext *C, wmManipulator *mpr)
-{
- WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C);
-}
-
-static void rna_ManipulatorGroup_manipulator_clear(
- wmManipulatorGroup *mgroup, bContext *C)
-{
- while (mgroup->manipulators.first) {
- WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mgroup->manipulators.first, C);
- }
-}
-
-static void rna_ManipulatorGroup_name_get(PointerRNA *ptr, char *value)
-{
- wmManipulatorGroup *mgroup = ptr->data;
- strcpy(value, mgroup->type->name);
-}
-
-static int rna_ManipulatorGroup_name_length(PointerRNA *ptr)
-{
- wmManipulatorGroup *mgroup = ptr->data;
- return strlen(mgroup->type->name);
-}
-
-/* just to work around 'const char *' warning and to ensure this is a python op */
-static void rna_ManipulatorGroup_bl_idname_set(PointerRNA *ptr, const char *value)
-{
- wmManipulatorGroup *data = ptr->data;
- char *str = (char *)data->type->idname;
- if (!str[0])
- BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
- else
- assert(!"setting the bl_idname on a non-builtin operator");
-}
-
-static void rna_ManipulatorGroup_bl_label_set(PointerRNA *ptr, const char *value)
-{
- wmManipulatorGroup *data = ptr->data;
- char *str = (char *)data->type->name;
- if (!str[0])
- BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
- else
- assert(!"setting the bl_label on a non-builtin operator");
-}
-
-static int rna_ManipulatorGroup_has_reports_get(PointerRNA *ptr)
-{
- wmManipulatorGroup *mgroup = ptr->data;
- return (mgroup->reports && mgroup->reports->list.first);
-}
-
-#ifdef WITH_PYTHON
-
-static bool rna_manipulatorgroup_poll_cb(const bContext *C, wmManipulatorGroupType *wgt)
-{
-
- extern FunctionRNA rna_ManipulatorGroup_poll_func;
-
- PointerRNA ptr;
- ParameterList list;
- FunctionRNA *func;
- void *ret;
- int visible;
-
- RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */
- func = &rna_ManipulatorGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
-
- RNA_parameter_list_create(&list, &ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- wgt->ext.call((bContext *)C, &ptr, func, &list);
-
- RNA_parameter_get_lookup(&list, "visible", &ret);
- visible = *(int *)ret;
-
- RNA_parameter_list_free(&list);
-
- return visible;
-}
-
-static void rna_manipulatorgroup_setup_cb(const bContext *C, wmManipulatorGroup *mgroup)
-{
- extern FunctionRNA rna_ManipulatorGroup_setup_func;
-
- PointerRNA mgroup_ptr;
- ParameterList list;
- FunctionRNA *func;
-
- RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
- func = &rna_ManipulatorGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */
-
- RNA_parameter_list_create(&list, &mgroup_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
-
- RNA_parameter_list_free(&list);
-}
-
-static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupType *wgt, wmKeyConfig *config)
-{
- extern FunctionRNA rna_ManipulatorGroup_setup_keymap_func;
- void *ret;
-
- PointerRNA ptr;
- ParameterList list;
- FunctionRNA *func;
-
- RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */
- func = &rna_ManipulatorGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */
-
- RNA_parameter_list_create(&list, &ptr, func);
- RNA_parameter_set_lookup(&list, "keyconfig", &config);
- wgt->ext.call(NULL, &ptr, func, &list);
-
- RNA_parameter_get_lookup(&list, "keymap", &ret);
- wmKeyMap *keymap = *(wmKeyMap **)ret;
-
- RNA_parameter_list_free(&list);
-
- return keymap;
-}
-
-static void rna_manipulatorgroup_refresh_cb(const bContext *C, wmManipulatorGroup *mgroup)
-{
- extern FunctionRNA rna_ManipulatorGroup_refresh_func;
-
- PointerRNA mgroup_ptr;
- ParameterList list;
- FunctionRNA *func;
-
- RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
- func = &rna_ManipulatorGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */
-
- RNA_parameter_list_create(&list, &mgroup_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
-
- RNA_parameter_list_free(&list);
-}
-
-static void rna_manipulatorgroup_draw_prepare_cb(const bContext *C, wmManipulatorGroup *mgroup)
-{
- extern FunctionRNA rna_ManipulatorGroup_draw_prepare_func;
-
- PointerRNA mgroup_ptr;
- ParameterList list;
- FunctionRNA *func;
-
- RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
- func = &rna_ManipulatorGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */
-
- RNA_parameter_list_create(&list, &mgroup_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
-
- RNA_parameter_list_free(&list);
-}
-
-void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata);
-static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type);
-
-static StructRNA *rna_ManipulatorGroup_register(
- Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
-{
- struct {
- char name[MAX_NAME];
- char idname[MAX_NAME];
- } temp_buffers;
-
- wmManipulatorGroupType dummywgt = {NULL};
- wmManipulatorGroup dummywg = {NULL};
- PointerRNA wgptr;
-
- /* Two sets of functions. */
- int have_function[5];
-
- /* setup dummy manipulatorgroup & manipulatorgroup type to store static properties in */
- dummywg.type = &dummywgt;
- dummywgt.name = temp_buffers.name;
- dummywgt.idname = temp_buffers.idname;
-
- RNA_pointer_create(NULL, &RNA_ManipulatorGroup, &dummywg, &wgptr);
-
- /* Clear so we can detect if it's left unset. */
- temp_buffers.idname[0] = temp_buffers.name[0] = '\0';
-
- /* validate the python class */
- if (validate(&wgptr, data, have_function) != 0)
- return NULL;
-
- if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
- BKE_reportf(reports, RPT_ERROR, "Registering manipulatorgroup class: '%s' is too long, maximum length is %d",
- identifier, (int)sizeof(temp_buffers.idname));
- return NULL;
- }
-
- /* check if the area supports widgets */
- const struct wmManipulatorMapType_Params wmap_params = {
- .spaceid = dummywgt.mmap_params.spaceid,
- .regionid = dummywgt.mmap_params.regionid,
- };
-
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wmap_params);
- if (mmap_type == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Area type does not support manipulators");
- return NULL;
- }
-
- /* check if we have registered this manipulatorgroup type before, and remove it */
- {
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true);
- if (wgt && wgt->ext.srna) {
- rna_ManipulatorGroup_unregister(bmain, wgt->ext.srna);
- }
- }
- if (!RNA_struct_available_or_report(reports, dummywgt.idname)) {
- return NULL;
- }
-
- { /* allocate the idname */
- const char *strings[] = {
- temp_buffers.idname,
- temp_buffers.name,
- };
- char *strings_table[ARRAY_SIZE(strings)];
- BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
-
- dummywgt.idname = strings_table[0]; /* allocated string stored here */
- dummywgt.name = strings_table[1];
- BLI_assert(ARRAY_SIZE(strings) == 2);
- }
-
- /* create a new manipulatorgroup type */
- dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_ManipulatorGroup);
- RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* manipulatorgroup properties are registered separately */
- dummywgt.ext.data = data;
- dummywgt.ext.call = call;
- dummywgt.ext.free = free;
-
- /* We used to register widget group types like this, now we do it similar to
- * operator types. Thus we should be able to do the same as operator types now. */
- dummywgt.poll = (have_function[0]) ? rna_manipulatorgroup_poll_cb : NULL;
- dummywgt.setup_keymap = (have_function[1]) ? rna_manipulatorgroup_setup_keymap_cb : NULL;
- dummywgt.setup = (have_function[2]) ? rna_manipulatorgroup_setup_cb : NULL;
- dummywgt.refresh = (have_function[3]) ? rna_manipulatorgroup_refresh_cb : NULL;
- dummywgt.draw_prepare = (have_function[4]) ? rna_manipulatorgroup_draw_prepare_cb : NULL;
-
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr(
- BPY_RNA_manipulatorgroup_wrapper, (void *)&dummywgt);
-
- {
- const char *owner_id = RNA_struct_state_owner_get();
- if (owner_id) {
- BLI_strncpy(wgt->owner_id, owner_id, sizeof(wgt->owner_id));
- }
- }
-
- if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) {
- WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type);
-
- /* update while blender is running */
- WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
- }
-
- return dummywgt.ext.srna;
-}
-
-static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type)
-{
- wmManipulatorGroupType *wgt = RNA_struct_blender_type_get(type);
-
- if (!wgt)
- return;
-
- RNA_struct_free_extension(type, &wgt->ext);
- RNA_struct_free(&BLENDER_RNA, type);
-
- WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
-
- WM_manipulator_group_type_remove_ptr(bmain, wgt);
-}
-
-static void **rna_ManipulatorGroup_instance(PointerRNA *ptr)
-{
- wmManipulatorGroup *mgroup = ptr->data;
- return &mgroup->py_instance;
-}
-
-#endif /* WITH_PYTHON */
-
-static StructRNA *rna_ManipulatorGroup_refine(PointerRNA *mgroup_ptr)
-{
- wmManipulatorGroup *mgroup = mgroup_ptr->data;
- return (mgroup->type && mgroup->type->ext.srna) ? mgroup->type->ext.srna : &RNA_ManipulatorGroup;
-}
-
-static void rna_ManipulatorGroup_manipulators_begin(CollectionPropertyIterator *iter, PointerRNA *mgroup_ptr)
-{
- wmManipulatorGroup *mgroup = mgroup_ptr->data;
- rna_iterator_listbase_begin(iter, &mgroup->manipulators, NULL);
-}
-
-/** \} */
-
-
-#else /* RNA_RUNTIME */
-
-
-/* ManipulatorGroup.manipulators */
-static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop)
-{
- StructRNA *srna;
-
- FunctionRNA *func;
- PropertyRNA *parm;
-
- RNA_def_property_srna(cprop, "Manipulators");
- srna = RNA_def_struct(brna, "Manipulators", NULL);
- RNA_def_struct_sdna(srna, "wmManipulatorGroup");
- RNA_def_struct_ui_text(srna, "Manipulators", "Collection of manipulators");
-
- func = RNA_def_function(srna, "new", "rna_ManipulatorGroup_manipulator_new");
- RNA_def_function_ui_description(func, "Add manipulator");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- RNA_def_string(func, "type", "Type", 0, "", "Manipulator identifier"); /* optional */
- parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "remove", "rna_ManipulatorGroup_manipulator_remove");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
- RNA_def_function_ui_description(func, "Delete manipulator");
- parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
-
- func = RNA_def_function(srna, "clear", "rna_ManipulatorGroup_manipulator_clear");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
- RNA_def_function_ui_description(func, "Delete all manipulators");
-}
-
-
-static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- FunctionRNA *func;
- PropertyRNA *parm;
-
- RNA_def_property_srna(cprop, "Manipulator");
- srna = RNA_def_struct(brna, "Manipulator", NULL);
- RNA_def_struct_sdna(srna, "wmManipulator");
- RNA_def_struct_ui_text(srna, "Manipulator", "Collection of manipulators");
- RNA_def_struct_refine_func(srna, "rna_Manipulator_refine");
-
-#ifdef WITH_PYTHON
- RNA_def_struct_register_funcs(
- srna,
- "rna_Manipulator_register",
- "rna_Manipulator_unregister",
- "rna_Manipulator_instance");
-#endif
- RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
-
- prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "ManipulatorProperties");
- RNA_def_property_ui_text(prop, "Properties", "");
- RNA_def_property_pointer_funcs(prop, "rna_Manipulator_properties_get", NULL, NULL, NULL);
-
- /* -------------------------------------------------------------------- */
- /* Registerable Variables */
-
- RNA_define_verify_sdna(0); /* not in sdna */
-
- prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "type->idname");
- RNA_def_property_string_maxlength(prop, MAX_NAME);
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Manipulator_bl_idname_set");
- /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
- RNA_def_property_flag(prop, PROP_REGISTER);
-
- RNA_define_verify_sdna(1); /* not in sdna */
-
- /* wmManipulator.draw */
- func = RNA_def_function(srna, "draw", NULL);
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-
- /* wmManipulator.draw_select */
- func = RNA_def_function(srna, "draw_select", NULL);
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
-
- /* wmManipulator.test_select */
- func = RNA_def_function(srna, "test_select", NULL);
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_pointer(func, "event", "Event", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_int(func, "intersect_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
- RNA_def_function_return(func, parm);
-
- /* wmManipulator.handler */
- static EnumPropertyItem tweak_actions[] = {
- {WM_MANIPULATOR_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""},
- {WM_MANIPULATOR_TWEAK_SNAP, "SNAP", 0, "Snap", ""},
- {0, NULL, 0, NULL, NULL}
- };
- func = RNA_def_function(srna, "modal", NULL);
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_pointer(func, "event", "Event", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- /* TODO, shuold be a enum-flag */
- parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", "");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
- RNA_def_function_return(func, parm);
- /* wmManipulator.property_update */
- /* TODO */
-
- /* wmManipulator.setup */
- func = RNA_def_function(srna, "setup", NULL);
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
-
- /* wmManipulator.invoke */
- func = RNA_def_function(srna, "invoke", NULL);
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_pointer(func, "event", "Event", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
- RNA_def_function_return(func, parm);
-
- /* wmManipulator.exit */
- func = RNA_def_function(srna, "exit", NULL);
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", "");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- /* wmManipulator.cursor_get */
- /* TODO */
-
- /* wmManipulator.select_refresh */
- func = RNA_def_function(srna, "select_refresh", NULL);
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
-
-
- /* -------------------------------------------------------------------- */
- /* Instance Variables */
-
- prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_struct_type(prop, "ManipulatorGroup");
- RNA_def_property_pointer_funcs(prop, "rna_Manipulator_group_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "", "Manipulator group this manipulator is a member of");
-
- /* Color & Alpha */
- prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_Manipulator_color_get", "rna_Manipulator_color_set", NULL);
-
- prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Alpha", "");
- RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_get", "rna_Manipulator_alpha_set", NULL);
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- /* Color & Alpha (highlight) */
- prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_Manipulator_color_hi_get", "rna_Manipulator_color_hi_set", NULL);
-
- prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Alpha", "");
- RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_hi_get", "rna_Manipulator_alpha_hi_set", NULL);
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- RNA_def_property_ui_text(prop, "Space Matrix", "");
- RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_space_get", "rna_Manipulator_matrix_space_set", NULL);
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- RNA_def_property_ui_text(prop, "Basis Matrix", "");
- RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_basis_get", "rna_Manipulator_matrix_basis_set", NULL);
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- RNA_def_property_ui_text(prop, "Offset Matrix", "");
- RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_offset_get", "rna_Manipulator_matrix_offset_set", NULL);
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- RNA_def_property_ui_text(prop, "Final World Matrix", "");
- RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_world_get", NULL, NULL);
-
- prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Scale Basis", "");
- RNA_def_property_float_funcs(prop, "rna_Manipulator_scale_basis_get", "rna_Manipulator_scale_basis_set", NULL);
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL);
- RNA_def_property_ui_text(prop, "Line Width", "");
- RNA_def_property_float_funcs(prop, "rna_Manipulator_line_width_get", "rna_Manipulator_line_width_set", NULL);
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- /* wmManipulator.flag */
- /* WM_MANIPULATOR_HIDDEN */
- prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(
- prop, "rna_Manipulator_flag_hide_get", "rna_Manipulator_flag_hide_set");
- RNA_def_property_ui_text(prop, "Hide", "");
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
- /* WM_MANIPULATOR_GRAB_CURSOR */
- prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(
- prop, "rna_Manipulator_flag_use_grab_cursor_get", "rna_Manipulator_flag_use_grab_cursor_set");
- RNA_def_property_ui_text(prop, "Grab Cursor", "");
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- /* WM_MANIPULATOR_DRAW_HOVER */
- prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(
- prop, "rna_Manipulator_flag_use_draw_hover_get", "rna_Manipulator_flag_use_draw_hover_set");
- RNA_def_property_ui_text(prop, "Draw Hover", "");
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
- /* WM_MANIPULATOR_DRAW_MODAL */
- prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(
- prop, "rna_Manipulator_flag_use_draw_modal_get", "rna_Manipulator_flag_use_draw_modal_set");
- RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging");
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
- /* WM_MANIPULATOR_DRAW_VALUE */
- prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(
- prop, "rna_Manipulator_flag_use_draw_value_get", "rna_Manipulator_flag_use_draw_value_set");
- RNA_def_property_ui_text(prop, "Draw Value", "Show an indicator for the current value while dragging");
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
- /* WM_MANIPULATOR_DRAW_OFFSET_SCALE */
- prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(
- prop, "rna_Manipulator_flag_use_draw_offset_scale_get", "rna_Manipulator_flag_use_draw_offset_scale_set");
- RNA_def_property_ui_text(prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)");
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
- /* WM_MANIPULATOR_DRAW_NO_SCALE (negated) */
- prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(
- prop, "rna_Manipulator_flag_use_draw_scale_get", "rna_Manipulator_flag_use_draw_scale_set");
- RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix");
- RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
-
- /* wmManipulator.state (readonly) */
- /* WM_MANIPULATOR_STATE_HIGHLIGHT */
- prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_highlight_get", NULL);
- RNA_def_property_ui_text(prop, "Highlight", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- /* WM_MANIPULATOR_STATE_MODAL */
- prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_modal_get", NULL);
- RNA_def_property_ui_text(prop, "Highlight", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- /* WM_MANIPULATOR_STATE_SELECT */
- /* (note that setting is involved, needs to handle array) */
- prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_select_get", "rna_Manipulator_state_select_set");
- RNA_def_property_ui_text(prop, "Select", "");
-
- RNA_api_manipulator(srna);
-
- srna = RNA_def_struct(brna, "ManipulatorProperties", NULL);
- RNA_def_struct_ui_text(srna, "Manipulator Properties", "Input properties of an Manipulator");
- RNA_def_struct_refine_func(srna, "rna_ManipulatorProperties_refine");
- RNA_def_struct_idprops_func(srna, "rna_ManipulatorProperties_idprops");
- RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES);
-}
-
-static void rna_def_manipulatorgroup(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- FunctionRNA *func;
- PropertyRNA *parm;
-
- srna = RNA_def_struct(brna, "ManipulatorGroup", NULL);
- RNA_def_struct_ui_text(srna, "ManipulatorGroup", "Storage of an operator being executed, or registered after execution");
- RNA_def_struct_sdna(srna, "wmManipulatorGroup");
- RNA_def_struct_refine_func(srna, "rna_ManipulatorGroup_refine");
-#ifdef WITH_PYTHON
- RNA_def_struct_register_funcs(
- srna,
- "rna_ManipulatorGroup_register",
- "rna_ManipulatorGroup_unregister",
- "rna_ManipulatorGroup_instance");
-#endif
- RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
-
- /* -------------------------------------------------------------------- */
- /* Registration */
-
- RNA_define_verify_sdna(0); /* not in sdna */
-
- prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "type->idname");
- RNA_def_property_string_maxlength(prop, MAX_NAME);
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_idname_set");
- RNA_def_property_flag(prop, PROP_REGISTER);
- RNA_def_struct_name_property(srna, prop);
-
- prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "type->name");
- RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_label_set");
- /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
- RNA_def_property_flag(prop, PROP_REGISTER);
-
- prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.spaceid");
- RNA_def_property_enum_items(prop, rna_enum_space_type_items);
- RNA_def_property_flag(prop, PROP_REGISTER);
- RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in");
-
- prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.regionid");
- RNA_def_property_enum_items(prop, rna_enum_region_type_items);
- RNA_def_property_flag(prop, PROP_REGISTER);
- RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in");
-
- prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
- RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
-
- /* bl_options */
- static EnumPropertyItem manipulatorgroup_flag_items[] = {
- {WM_MANIPULATORGROUPTYPE_3D, "3D", 0, "3D",
- "Use in 3D viewport"},
- {WM_MANIPULATORGROUPTYPE_SCALE, "SCALE", 0, "Scale",
- "Scale to respect zoom (otherwise zoom independent draw size)"},
- {WM_MANIPULATORGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D",
- "Supports culled depth by other objects in the view"},
- {WM_MANIPULATORGROUPTYPE_SELECT, "SELECT", 0, "Select",
- "Supports selection"},
- {WM_MANIPULATORGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent",
- ""},
- {WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All",
- "Show all while interacting"},
- {0, NULL, 0, NULL, NULL}
- };
- prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type->flag");
- RNA_def_property_enum_items(prop, manipulatorgroup_flag_items);
- RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
- RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
-
- RNA_define_verify_sdna(1); /* not in sdna */
-
-
- /* Functions */
-
- /* poll */
- func = RNA_def_function(srna, "poll", NULL);
- RNA_def_function_ui_description(func, "Test if the manipulator group can be called or not");
- RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
- RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-
- /* setup_keymap */
- func = RNA_def_function(srna, "setup_keymap", NULL);
- RNA_def_function_ui_description(
- func,
- "Initialize keymaps for this manipulator group, use fallback keymap when not present");
- RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
- parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- /* return */
- parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
- RNA_def_property_flag(parm, PROP_NEVER_NULL);
- RNA_def_function_return(func, parm);
-
- /* setup */
- func = RNA_def_function(srna, "setup", NULL);
- RNA_def_function_ui_description(func, "Create manipulators function for the manipulator group");
- RNA_def_function_flag(func, FUNC_REGISTER);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-
- /* refresh */
- func = RNA_def_function(srna, "refresh", NULL);
- RNA_def_function_ui_description(func, "Refresh data (called on common state changes such as selection)");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-
- func = RNA_def_function(srna, "draw_prepare", NULL);
- RNA_def_function_ui_description(func, "Run before each redraw");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-
- /* -------------------------------------------------------------------- */
- /* Instance Variables */
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_string_funcs(prop, "rna_ManipulatorGroup_name_get", "rna_ManipulatorGroup_name_length", NULL);
- RNA_def_property_ui_text(prop, "Name", "");
-
- prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
- RNA_def_property_boolean_funcs(prop, "rna_ManipulatorGroup_has_reports_get", NULL);
- RNA_def_property_ui_text(prop, "Has Reports",
- "ManipulatorGroup has a set of reports (warnings and errors) from last execution");
-
-
- RNA_define_verify_sdna(0); /* not in sdna */
-
- prop = RNA_def_property(srna, "manipulators", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "manipulators", NULL);
- RNA_def_property_struct_type(prop, "Manipulator");
- RNA_def_property_collection_funcs(
- prop, "rna_ManipulatorGroup_manipulators_begin", "rna_iterator_listbase_next",
- "rna_iterator_listbase_end", "rna_iterator_listbase_get",
- NULL, NULL, NULL, NULL);
-
- RNA_def_property_ui_text(prop, "Manipulators", "List of manipulators in the Manipulator Map");
- rna_def_manipulator(brna, prop);
- rna_def_manipulators(brna, prop);
-
- RNA_define_verify_sdna(1); /* not in sdna */
-
- RNA_api_manipulatorgroup(srna);
-}
-
-void RNA_def_wm_manipulator(BlenderRNA *brna)
-{
- rna_def_manipulatorgroup(brna);
-}
-
-#endif /* RNA_RUNTIME */
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c
index 0db192e8347..98e84f60b33 100644
--- a/source/blender/makesrna/intern/rna_workspace_api.c
+++ b/source/blender/makesrna/intern/rna_workspace_api.c
@@ -51,16 +51,18 @@ static void rna_WorkspaceTool_setup(
/* Args for: 'bToolRef_Runtime'. */
int cursor,
const char *keymap,
- const char *manipulator_group,
+ const char *gizmo_group,
const char *data_block,
+ const char *operator,
int index)
{
bToolRef_Runtime tref_rt = {0};
tref_rt.cursor = cursor;
STRNCPY(tref_rt.keymap, keymap);
- STRNCPY(tref_rt.manipulator_group, manipulator_group);
+ STRNCPY(tref_rt.gizmo_group, gizmo_group);
STRNCPY(tref_rt.data_block, data_block);
+ STRNCPY(tref_rt.operator, operator);
tref_rt.index = index;
WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, name);
@@ -108,8 +110,9 @@ void RNA_api_workspace_tool(StructRNA *srna)
parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(parm, rna_enum_window_cursor_items);
RNA_def_string(func, "keymap", NULL, KMAP_MAX_NAME, "Key Map", "");
- RNA_def_string(func, "manipulator_group", NULL, MAX_NAME, "Manipulator Group", "");
+ RNA_def_string(func, "gizmo_group", NULL, MAX_NAME, "Gizmo Group", "");
RNA_def_string(func, "data_block", NULL, MAX_NAME, "Data Block", "");
+ RNA_def_string(func, "operator", NULL, MAX_NAME, "Operator", "");
RNA_def_int(func, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX);
/* Access tool operator options (optionally create). */
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index ead67814f01..f4dc07cf6c3 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -207,10 +207,10 @@ void RNA_def_world(BlenderRNA *brna)
rna_def_animdata_common(srna);
/* colors */
- prop = RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR);
+ prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "horr");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Horizon Color", "Color at the horizon");
+ RNA_def_property_ui_text(prop, "Color", "Color of the background");
/* RNA_def_property_update(prop, 0, "rna_World_update"); */
/* render-only uses this */
RNA_def_property_update(prop, 0, "rna_World_draw_update");
diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner.py b/source/blender/makesrna/rna_cleanup/rna_cleaner.py
index f1cd46f3d57..a936e6499bc 100755
--- a/source/blender/makesrna/rna_cleanup/rna_cleaner.py
+++ b/source/blender/makesrna/rna_cleanup/rna_cleaner.py
@@ -56,19 +56,19 @@ def check_commandline():
"""
import sys
# Usage
- if len(sys.argv)==1 or len(sys.argv)>3:
+ if len(sys.argv) == 1 or len(sys.argv) > 3:
usage()
if sys.argv[1] == '-h':
help()
elif not sys.argv[1].endswith((".txt", ".py")):
- print ('\nBad input file extension... exiting.')
+ print('\nBad input file extension... exiting.')
usage()
else:
inputfile = sys.argv[1]
if len(sys.argv) == 2:
sort_priority = default_sort_choice
- print ('\nSecond parameter missing: choosing to order by %s.' % font_bold(sort_priority))
- elif len(sys.argv)==3:
+ print('\nSecond parameter missing: choosing to order by %s.' % font_bold(sort_priority))
+ elif len(sys.argv) == 3:
sort_priority = sys.argv[2]
if sort_priority not in sort_choices:
print('\nWrong sort_priority... exiting.')
@@ -93,9 +93,11 @@ def check_prefix(prop, btype):
return ""
-def check_if_changed(a,b):
- if a != b: return 'changed'
- else: return 'same'
+def check_if_changed(a, b):
+ if a != b:
+ return 'changed'
+ else:
+ return 'same'
def get_props_from_txt(input_filename):
@@ -103,12 +105,12 @@ def get_props_from_txt(input_filename):
If the file is *.txt, the script assumes it is formatted as outlined in this script docstring
"""
- file=open(input_filename,'r')
- file_lines=file.readlines()
+ file = open(input_filename, 'r')
+ file_lines = file.readlines()
file.close()
- props_list=[]
- props_length_max=[0,0,0,0,0,0,0,0]
+ props_list = []
+ props_length_max = [0, 0, 0, 0, 0, 0, 0, 0]
done_text = "+"
done = 0
@@ -117,7 +119,7 @@ def get_props_from_txt(input_filename):
for iii, line in enumerate(file_lines):
# debug
- #print(line)
+ # print(line)
line_strip = line.strip()
# empty line or comment
if not line_strip:
@@ -136,7 +138,7 @@ def get_props_from_txt(input_filename):
if '*' in bclass:
comment, bclass = [x.strip() for x in bclass.split('*', 1)]
else:
- comment= ''
+ comment = ''
# skipping the header if we have one.
# the header is assumed to be "NOTE * CLASS.FROM -> TO: TYPE DESCRIPTION"
@@ -155,7 +157,7 @@ def get_props_from_txt(input_filename):
# make life easy and strip quotes
description = description.replace("'", "").replace('"', "").replace("\\", "").strip()
except ValueError:
- btype, description = [tail,'NO DESCRIPTION']
+ btype, description = [tail, 'NO DESCRIPTION']
# keyword-check
kwcheck = check_prefix(bto, btype)
@@ -164,17 +166,17 @@ def get_props_from_txt(input_filename):
changed = check_if_changed(bfrom, bto)
# lists formatting
- props=[comment, changed, bclass, bfrom, bto, kwcheck, btype, description]
+ props = [comment, changed, bclass, bfrom, bto, kwcheck, btype, description]
props_list.append(props)
- props_length_max=list(map(max,zip(props_length_max,list(map(len,props)))))
+ props_length_max = list(map(max, zip(props_length_max, list(map(len, props)))))
if done_text in comment:
done += 1
tot += 1
- print("Total done %.2f" % (done / tot * 100.0) )
+ print("Total done %.2f" % (done / tot * 100.0))
- return (props_list,props_length_max)
+ return (props_list, props_length_max)
def get_props_from_py(input_filename):
@@ -185,25 +187,25 @@ def get_props_from_py(input_filename):
# adds the list "rna_api" to this function's scope
rna_api = __import__(input_filename[:-3]).rna_api
- props_length_max = [0 for i in rna_api[0]] # this way if the vector will take more elements we are safe
- for index,props in enumerate(rna_api):
+ props_length_max = [0 for i in rna_api[0]] # this way if the vector will take more elements we are safe
+ for index, props in enumerate(rna_api):
comment, changed, bclass, bfrom, bto, kwcheck, btype, description = props
kwcheck = check_prefix(bto, btype) # keyword-check
changed = check_if_changed(bfrom, bto) # changed?
description = repr(description)
description = description.replace("'", "").replace('"', "").replace("\\", "").strip()
rna_api[index] = [comment, changed, bclass, bfrom, bto, kwcheck, btype, description]
- props_length = list(map(len,props)) # lengths
- props_length_max = list(map(max,zip(props_length_max,props_length))) # max lengths
- return (rna_api,props_length_max)
+ props_length = list(map(len, props)) # lengths
+ props_length_max = list(map(max, zip(props_length_max, props_length))) # max lengths
+ return (rna_api, props_length_max)
def get_props(input_filename):
if input_filename.endswith(".txt"):
- props_list,props_length_max = get_props_from_txt(input_filename)
+ props_list, props_length_max = get_props_from_txt(input_filename)
elif input_filename.endswith(".py"):
- props_list,props_length_max = get_props_from_py(input_filename)
- return (props_list,props_length_max)
+ props_list, props_length_max = get_props_from_py(input_filename)
+ return (props_list, props_length_max)
def sort(props_list, sort_priority):
@@ -222,7 +224,7 @@ def sort(props_list, sort_priority):
else:
props_list = sorted(props_list, key=lambda p: p[i])
- print ('\nSorted by %s.' % font_bold(sort_priority))
+ print('\nSorted by %s.' % font_bold(sort_priority))
return props_list
@@ -250,30 +252,35 @@ def write_files(basename, props_list, props_length_max):
* rna_api.py: unformatted, just as final output
"""
- f_rna = open("rna_api.py",'w')
- f_txt = open(basename + '_work.txt','w')
- f_py = open(basename + '_work.py','w')
+ f_rna = open("rna_api.py", 'w')
+ f_txt = open(basename + '_work.txt', 'w')
+ f_py = open(basename + '_work.py', 'w')
# reminder: props=[comment, changed, bclass, bfrom, bto, kwcheck, btype, description]
# [comment *] ToolSettings.snap_align_rotation -> use_snap_align_rotation: boolean [Align rotation with the snapping target]
rna = py = txt = ''
props_list = [['NOTE', 'CHANGED', 'CLASS', 'FROM', 'TO', 'KEYWORD-CHECK', 'TYPE', 'DESCRIPTION']] + props_list
for props in props_list:
- #txt
+ # txt
# quick way we can tell if it changed
- if props[3] == props[4]: txt += "#"
- else: txt += " "
+ if props[3] == props[4]:
+ txt += "#"
+ else:
+ txt += " "
- if props[0] != '': txt += '%s * ' % props[0] # comment
- txt += '%s.%s -> %s: %s "%s"\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check
+ if props[0] != '':
+ txt += '%s * ' % props[0] # comment
+ txt += '%s.%s -> %s: %s "%s"\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check
# rna_api
- if props[0] == 'NOTE': indent = '# '
- else: indent = ' '
- rna += indent + '("%s", "%s", "%s", "%s", "%s"),\n' % tuple(props[2:5] + props[6:]) # description is already string formatted
+ if props[0] == 'NOTE':
+ indent = '# '
+ else:
+ indent = ' '
+ rna += indent + '("%s", "%s", "%s", "%s", "%s"),\n' % tuple(props[2:5] + props[6:]) # description is already string formatted
# py
- blanks = [' '* (x[0]-x[1]) for x in zip(props_length_max,list(map(len,props)))]
- props = [('"%s"%s' if props[-1] != x[0] else "%s%s") % (x[0],x[1]) for x in zip(props,blanks)]
+ blanks = [' ' * (x[0] - x[1]) for x in zip(props_length_max, list(map(len, props)))]
+ props = [('"%s"%s' if props[-1] != x[0] else "%s%s") % (x[0], x[1]) for x in zip(props, blanks)]
py += indent + '(%s, %s, %s, %s, %s, %s, %s, "%s"),\n' % tuple(props)
f_txt.write(txt)
@@ -290,7 +297,7 @@ def write_files(basename, props_list, props_length_max):
f_py.close()
f_rna.close()
- print ('\nSaved %s, %s and %s.\n' % (font_bold(f_txt.name), font_bold(f_py.name), font_bold(f_rna.name) ) )
+ print('\nSaved %s, %s and %s.\n' % (font_bold(f_txt.name), font_bold(f_py.name), font_bold(f_rna.name)))
def main():
@@ -298,21 +305,21 @@ def main():
global sort_choices, default_sort_choice
global kw_prefixes, kw
- sort_choices = ['note','changed','class','from','to','kw', 'class.to']
+ sort_choices = ['note', 'changed', 'class', 'from', 'to', 'kw', 'class.to']
default_sort_choice = sort_choices[-1]
- kw_prefixes = [ 'active','apply','bl','exclude','has','invert','is','lock', \
- 'pressed','show','show_only','use','use_only','layers','states', 'select']
- kw = ['active','hide','invert','select','layers','mute','states','use','lock']
+ kw_prefixes = ['active', 'apply', 'bl', 'exclude', 'has', 'invert', 'is', 'lock',
+ 'pressed', 'show', 'show_only', 'use', 'use_only', 'layers', 'states', 'select']
+ kw = ['active', 'hide', 'invert', 'select', 'layers', 'mute', 'states', 'use', 'lock']
input_filename, sort_priority = check_commandline()
- props_list,props_length_max = get_props(input_filename)
- props_list = sort(props_list,sort_priority)
+ props_list, props_length_max = get_props(input_filename)
+ props_list = sort(props_list, sort_priority)
output_basename = file_basename(input_filename)
- write_files(output_basename, props_list,props_length_max)
+ write_files(output_basename, props_list, props_length_max)
-if __name__=='__main__':
+if __name__ == '__main__':
import sys
if not sys.version.startswith("3"):
print("Incorrect python version, use python 3!")
diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
index a5d5cebcbb7..236313f1f5c 100755
--- a/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
+++ b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
@@ -6,56 +6,58 @@ import sys
Example usage:
python3 rna_cleaner_merge.py out_work.py rna_booleans_work.py
'''
+
+
def main():
- def work_line_id(line):
- return line[2].split("|")[-1], line[3] # class/from
+ def work_line_id(line):
+ return line[2].split("|")[-1], line[3] # class/from
+ if not (sys.argv[-1].endswith(".py") and sys.argv[-2].endswith(".py")):
+ print("Only accepts 2 py files as arguments.")
- if not (sys.argv[-1].endswith(".py") and sys.argv[-2].endswith(".py")):
- print("Only accepts 2 py files as arguments.")
+ sys.path.insert(0, ".")
- sys.path.insert(0, ".")
+ mod_from = __import__(sys.argv[-1][:-3])
+ mod_to = __import__(sys.argv[-2][:-3])
- mod_from = __import__(sys.argv[-1][:-3])
- mod_to = __import__(sys.argv[-2][:-3])
+ mod_to_dict = dict([(work_line_id(line), line) for line in mod_to.rna_api])
+ mod_from_dict = dict([(work_line_id(line), line) for line in mod_from.rna_api])
- mod_to_dict = dict([(work_line_id(line), line) for line in mod_to.rna_api])
- mod_from_dict = dict([(work_line_id(line), line) for line in mod_from.rna_api])
+ rna_api_new = []
- rna_api_new = []
+ for key, val_orig in mod_to_dict.items():
+ try:
+ val_new = mod_from_dict.pop(key)
+ except:
+ # print("not found", key)
+ val_new = val_orig
- for key, val_orig in mod_to_dict.items():
- try:
- val_new = mod_from_dict.pop(key)
- except:
- # print("not found", key)
- val_new = val_orig
+ # always take the class from the base
+ val = list(val_orig)
+ val[0] = val_new[0] # comment
+ val[4] = val_new[4] # -> to
+ val = tuple(val)
+ rna_api_new.append(val)
- # always take the class from the base
- val = list(val_orig)
- val[0] = val_new[0] # comment
- val[4] = val_new[4] # -> to
- val = tuple(val)
- rna_api_new.append(val)
+ def write_work_file(file_path, rna_api):
+ rna_api = list(rna_api)
+ rna_api.sort(key=work_line_id)
+ file_out = open(file_path, "w")
+ file_out.write("rna_api = [\n")
+ for line in rna_api:
+ file_out.write(" %s,\n" % (repr(line)))
+ file_out.write("]\n")
+ file_out.close()
- def write_work_file(file_path, rna_api):
- rna_api = list(rna_api)
- rna_api.sort(key=work_line_id)
- file_out = open(file_path, "w")
- file_out.write("rna_api = [\n")
- for line in rna_api:
- file_out.write(" %s,\n" % (repr(line)))
- file_out.write("]\n")
- file_out.close()
+ file_path = sys.argv[-2][:-3] + "_merged.py"
+ write_work_file(file_path, rna_api_new)
- file_path = sys.argv[-2][:-3] + "_merged.py"
- write_work_file(file_path, rna_api_new)
+ if mod_from_dict:
+ file_path = sys.argv[-2][:-3] + "_lost.py"
+ write_work_file(file_path, list(mod_from_dict.values()))
+ print("Warning '%s' contains lost %d items from module %s.py" % (file_path, len(mod_from_dict), mod_from.__name__))
- if mod_from_dict:
- file_path = sys.argv[-2][:-3] + "_lost.py"
- write_work_file(file_path, list(mod_from_dict.values()))
- print("Warning '%s' contains lost %d items from module %s.py" % (file_path, len(mod_from_dict), mod_from.__name__))
if __name__ == "__main__":
- main()
+ main()
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 09ba865cce3..c44b65dffec 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -64,14 +64,14 @@ static void initData(ModifierData *md)
amd->deformflag = ARM_DEF_VGROUP;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
const ArmatureModifierData *amd = (const ArmatureModifierData *) md;
#endif
ArmatureModifierData *tamd = (ArmatureModifierData *) target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
tamd->prevCos = NULL;
}
@@ -85,7 +85,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(
return dataMask;
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 6cea7b8fece..db1078fa677 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -76,7 +76,7 @@ static void initData(ModifierData *md)
bmd->double_threshold = 1e-6f;
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
BooleanModifierData *bmd = (BooleanModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index cd6cd709b1d..a0901b6d838 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -63,7 +63,7 @@ static void initData(ModifierData *md)
cmd->object = NULL;
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
CastModifierData *cmd = (CastModifierData *) md;
short flag;
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 58979fa201b..53e71bfc1a4 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -42,6 +42,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_cloth.h"
@@ -155,7 +156,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const ClothModifierData *clmd = (const ClothModifierData *) md;
ClothModifierData *tclmd = (ClothModifierData *) target;
@@ -170,14 +171,21 @@ static void copyData(const ModifierData *md, ModifierData *target)
MEM_freeN(tclmd->coll_parms);
BKE_ptcache_free_list(&tclmd->ptcaches);
- tclmd->point_cache = NULL;
+ if (flag & LIB_ID_CREATE_NO_MAIN) {
+ /* Share the cache with the original object's modifier. */
+ tclmd->modifier.flag |= eModifierFlag_SharedCaches;
+ tclmd->ptcaches = clmd->ptcaches;
+ tclmd->point_cache = clmd->point_cache;
+ }
+ else {
+ tclmd->point_cache = BKE_ptcache_add(&tclmd->ptcaches);
+ tclmd->point_cache->step = 1;
+ }
tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms);
if (clmd->sim_parms->effector_weights)
tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights);
tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms);
- tclmd->point_cache = BKE_ptcache_add(&tclmd->ptcaches);
- tclmd->point_cache->step = 1;
tclmd->clothObject = NULL;
tclmd->hairdata = NULL;
tclmd->solver_result = NULL;
@@ -206,7 +214,12 @@ static void freeData(ModifierData *md)
if (clmd->coll_parms)
MEM_freeN(clmd->coll_parms);
- BKE_ptcache_free_list(&clmd->ptcaches);
+ if (md->flag & eModifierFlag_SharedCaches) {
+ BLI_listbase_clear(&clmd->ptcaches);
+ }
+ else {
+ BKE_ptcache_free_list(&clmd->ptcaches);
+ }
clmd->point_cache = NULL;
if (clmd->hairdata)
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index 879b07de6d9..d59360896e8 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -80,12 +80,12 @@ static void initData(ModifierData *md)
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const CorrectiveSmoothModifierData *csmd = (const CorrectiveSmoothModifierData *)md;
CorrectiveSmoothModifierData *tcsmd = (CorrectiveSmoothModifierData *)target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
if (csmd->bind_coords) {
tcsmd->bind_coords = MEM_dupallocN(csmd->bind_coords);
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index e90ff939b68..b74b63e2478 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -71,7 +71,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams))
+static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
{
CurveModifierData *cmd = (CurveModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index 8e025059d6c..ac45ce8732d 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -133,7 +133,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
/* If no source object, bypass. */
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index ac8fb91bc8d..1b8b7120058 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -138,7 +138,7 @@ static void foreachTexLink(
walk(userData, ob, md, "texture");
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
DisplaceModifierData *dmd = (DisplaceModifierData *) md;
return ((!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) || dmd->strength == 0.0f);
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index 9131bc0659f..61219096b43 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -57,7 +57,7 @@ static void initData(ModifierData *md)
pmd->type = MOD_DYNAMICPAINT_TYPE_CANVAS;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag))
{
const DynamicPaintModifierData *pmd = (const DynamicPaintModifierData *)md;
DynamicPaintModifierData *tpmd = (DynamicPaintModifierData *)target;
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 948aaf0751e..04bfe96bc59 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -70,14 +70,14 @@ static void freeData(ModifierData *md)
MEM_SAFE_FREE(emd->facepa);
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
const ExplodeModifierData *emd = (const ExplodeModifierData *) md;
#endif
ExplodeModifierData *temd = (ExplodeModifierData *) target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
temd->facepa = NULL;
}
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c
index ffa74be0b33..ebea7250d18 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -33,14 +33,13 @@
*/
+#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_fluidsim_types.h"
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
-
-#include "BKE_cdderivedmesh.h"
#include "BKE_layer.h"
#include "BKE_modifier.h"
@@ -65,45 +64,49 @@ static void freeData(ModifierData *md)
fluidsim_free(fluidmd);
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag))
{
const FluidsimModifierData *fluidmd = (const FluidsimModifierData *) md;
FluidsimModifierData *tfluidmd = (FluidsimModifierData *) target;
- if (fluidmd->fss) {
- tfluidmd->fss = MEM_dupallocN(fluidmd->fss);
- if (tfluidmd->fss && (tfluidmd->fss->meshVelocities != NULL)) {
- tfluidmd->fss->meshVelocities = MEM_dupallocN(tfluidmd->fss->meshVelocities);
- }
+ /* Free any FSS that was allocated in initData() */
+ if (tfluidmd->fss) {
+ MEM_SAFE_FREE(tfluidmd->fss->meshVelocities);
+ MEM_freeN(tfluidmd->fss);
}
- /* Seems to never be used, but for sqke of consistency... */
- BLI_assert(fluidmd->point_cache == NULL);
- BLI_assert(tfluidmd->point_cache == NULL);
- tfluidmd->point_cache = NULL;
+ if (fluidmd->fss == NULL) {
+ tfluidmd->fss = NULL;
+ return;
+ }
+
+ tfluidmd->fss = MEM_dupallocN(fluidmd->fss);
+ if (tfluidmd->fss->meshVelocities != NULL) {
+ tfluidmd->fss->meshVelocities = MEM_dupallocN(tfluidmd->fss->meshVelocities);
+ }
}
-static DerivedMesh *applyModifier(
+static Mesh *applyModifier(
ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *dm)
+ Mesh *mesh)
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *) md;
- DerivedMesh *result = NULL;
+ Mesh *result = NULL;
/* check for alloc failing */
if (!fluidmd->fss) {
initData(md);
if (!fluidmd->fss) {
- return dm;
+ return mesh;
}
}
- result = fluidsimModifier_do(fluidmd, ctx, dm);
+ result = fluidsimModifier_do(fluidmd, ctx, mesh);
- return result ? result : dm;
+ return result ? result : mesh;
}
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
@@ -150,14 +153,14 @@ ModifierTypeInfo modifierType_Fluidsim = {
/* deformMatrices_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ applyModifier,
+ /* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
+ /* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index cea9e69526c..44079163de5 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -47,8 +47,8 @@
#include "BLI_utildefines.h"
#include "BKE_fluidsim.h" /* ensure definitions here match */
-#include "BKE_cdderivedmesh.h"
#include "BKE_main.h"
+#include "BKE_mesh.h"
#ifdef WITH_MOD_FLUID
# include "BKE_global.h"
#endif
@@ -160,22 +160,18 @@ void fluidsim_free(FluidsimModifierData *fluidmd)
MEM_SAFE_FREE(fluidmd->fss);
}
- /* Seems to never be used, but for sqke of consistency... */
- BLI_assert(fluidmd->point_cache == NULL);
- fluidmd->point_cache = NULL;
-
return;
}
#ifdef WITH_MOD_FLUID
/* read .bobj.gz file into a fluidsimDerivedMesh struct */
-static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_example)
+static Mesh *fluidsim_read_obj(const char *filename, const MPoly *mp_example)
{
int wri = 0, i;
int gotBytes;
gzFile gzf;
int numverts = 0, numfaces = 0;
- DerivedMesh *dm = NULL;
+ Mesh *mesh = NULL;
MPoly *mp;
MLoop *ml;
MVert *mv;
@@ -224,9 +220,9 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
return NULL;
}
- dm = CDDM_new(numverts, 0, 0, numfaces * 3, numfaces);
+ mesh = BKE_mesh_new_nomain(numverts, 0, 0, numfaces * 3, numfaces);
- if (!dm) {
+ if (!mesh) {
gzclose(gzf);
return NULL;
}
@@ -235,7 +231,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
gotBytes = gzread(gzf, &wri, sizeof(wri));
/* read vertex position from file */
- mv = CDDM_get_verts(dm);
+ mv = mesh->mvert;
for (i = 0; i < numverts; i++, mv++)
gotBytes = gzread(gzf, mv->co, sizeof(float) * 3);
@@ -243,16 +239,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
/* should be the same as numverts */
gotBytes = gzread(gzf, &wri, sizeof(wri));
if (wri != numverts) {
- if (dm)
- dm->release(dm);
+ if (mesh)
+ BKE_id_free(NULL, mesh);
gzclose(gzf);
return NULL;
}
normals = MEM_calloc_arrayN(numverts, 3 * sizeof(short), "fluid_tmp_normals");
if (!normals) {
- if (dm)
- dm->release(dm);
+ if (mesh)
+ BKE_id_free(NULL, mesh);
gzclose(gzf);
return NULL;
}
@@ -268,16 +264,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
if (wri != numfaces) {
printf("Fluidsim: error in reading data from file.\n");
- if (dm)
- dm->release(dm);
+ if (mesh)
+ BKE_id_free(NULL, mesh);
gzclose(gzf);
MEM_freeN(normals);
return NULL;
}
/* read triangles from file */
- mp = CDDM_get_polys(dm);
- ml = CDDM_get_loops(dm);
+ mp = mesh->mpoly;
+ ml = mesh->mloop;
for (i = 0; i < numfaces; i++, mp++, ml += 3) {
int face[3];
@@ -298,13 +294,12 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
gzclose(gzf);
- CDDM_calc_edges(dm);
-
- CDDM_apply_vert_normals(dm, (short (*)[3])normals);
+ BKE_mesh_calc_edges(mesh, false, false);
+ BKE_mesh_apply_vert_normals(mesh, (short (*)[3])normals);
MEM_freeN(normals);
// CDDM_calc_normals(result);
- return dm;
+ return mesh;
}
@@ -374,14 +369,14 @@ void fluid_estimate_memory(Object *ob, FluidsimSettings *fss, char *value)
/* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */
-static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename)
+static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, Mesh *mesh, char *filename)
{
int wri, i, j;
float wrf;
gzFile gzf;
FluidsimSettings *fss = fluidmd->fss;
int len = strlen(filename);
- int totvert = dm->getNumVerts(dm);
+ int totvert = mesh->totvert;
FluidVertexVelocity *velarray = NULL;
/* mesh and vverts have to be valid from loading... */
@@ -395,7 +390,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
if (fss->domainNovecgen > 0) return;
- fss->meshVelocities = MEM_calloc_arrayN(dm->getNumVerts(dm), sizeof(FluidVertexVelocity), "Fluidsim_velocities");
+ fss->meshVelocities = MEM_calloc_arrayN(mesh->totvert, sizeof(FluidVertexVelocity), "Fluidsim_velocities");
fss->totvert = totvert;
velarray = fss->meshVelocities;
@@ -430,8 +425,8 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
gzclose(gzf);
}
-static DerivedMesh *fluidsim_read_cache(
- Object *ob, DerivedMesh *orgdm,
+static Mesh *fluidsim_read_cache(
+ Object *ob, Mesh *orgmesh,
FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
{
int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */
@@ -440,7 +435,7 @@ static DerivedMesh *fluidsim_read_cache(
char targetFile[FILE_MAX];
FluidsimSettings *fss = fluidmd->fss;
- DerivedMesh *dm = NULL;
+ Mesh *newmesh = NULL;
MPoly *mpoly;
MPoly mp_example = {0};
@@ -469,17 +464,17 @@ static DerivedMesh *fluidsim_read_cache(
BLI_path_abs(targetFile, modifier_path_relbase_from_global(ob));
BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no
- /* assign material + flags to new dm
- * if there's no faces in original dm, keep materials and flags unchanged */
- mpoly = orgdm->getPolyArray(orgdm);
+ /* assign material + flags to new mesh.
+ * if there's no faces in original mesh, keep materials and flags unchanged */
+ mpoly = orgmesh->mpoly;
if (mpoly) {
mp_example = *mpoly;
}
/* else leave NULL'd */
- dm = fluidsim_read_obj(targetFile, &mp_example);
+ newmesh = fluidsim_read_obj(targetFile, &mp_example);
- if (!dm) {
+ if (!newmesh) {
/* switch, abort background rendering when fluidsim mesh is missing */
const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp
@@ -494,7 +489,7 @@ static DerivedMesh *fluidsim_read_cache(
}
}
- /* display org. object upon failure which is in dm */
+ /* display org. object upon failure which is in new mesh */
return NULL;
}
@@ -502,7 +497,7 @@ static DerivedMesh *fluidsim_read_cache(
* TODO? use generate flag as loading flag as well?
* warning, needs original .bobj.gz mesh loading filename */
if (displaymode == OB_FSDOM_FINAL) {
- fluidsim_read_vel_cache(fluidmd, dm, targetFile);
+ fluidsim_read_vel_cache(fluidmd, newmesh, targetFile);
}
else {
if (fss->meshVelocities)
@@ -511,21 +506,21 @@ static DerivedMesh *fluidsim_read_cache(
fss->meshVelocities = NULL;
}
- return dm;
+ return newmesh;
}
#endif // WITH_MOD_FLUID
-DerivedMesh *fluidsimModifier_do(
+Mesh *fluidsimModifier_do(
FluidsimModifierData *fluidmd,
const ModifierEvalContext *ctx,
- DerivedMesh *dm)
+ Mesh *mesh)
{
#ifdef WITH_MOD_FLUID
Object *ob = ctx->object;
Depsgraph *depsgraph = ctx->depsgraph;
const bool useRenderParams = (ctx->flag & MOD_APPLY_RENDER) != 0;
// const bool isFinalCalc = (ctx->flag & MOD_APPLY_USECACHE) != 0;
- DerivedMesh *result = NULL;
+ Mesh *result = NULL;
int framenr;
FluidsimSettings *fss = NULL;
@@ -533,11 +528,11 @@ DerivedMesh *fluidsimModifier_do(
/* only handle fluidsim domains */
if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN))
- return dm;
+ return mesh;
/* sanity check */
if (!fluidmd || !fluidmd->fss)
- return dm;
+ return mesh;
fss = fluidmd->fss;
@@ -552,15 +547,13 @@ DerivedMesh *fluidsimModifier_do(
/* try to read from cache */
/* if the frame is there, fine, otherwise don't do anything */
- if ((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
+ if ((result = fluidsim_read_cache(ob, mesh, fluidmd, framenr, useRenderParams)))
return result;
- return dm;
+ return mesh;
#else
/* unused */
- (void)fluidmd;
- (void)ctx;
- (void)dm;
+ UNUSED_VARS(fluidmd, ctx, mesh);
return NULL;
#endif
}
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.h b/source/blender/modifiers/intern/MOD_fluidsim_util.h
index 0a0c8419a99..041a67eddbd 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.h
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.h
@@ -36,16 +36,16 @@
struct Object;
struct Scene;
struct FluidsimModifierData;
-struct DerivedMesh;
+struct Mesh;
struct ModifierEvalContext;
/* new fluid-modifier interface */
void fluidsim_init(struct FluidsimModifierData *fluidmd);
void fluidsim_free(struct FluidsimModifierData *fluidmd);
-struct DerivedMesh *fluidsimModifier_do(
+struct Mesh *fluidsimModifier_do(
struct FluidsimModifierData *fluidmd,
const struct ModifierEvalContext *ctx,
- struct DerivedMesh *dm);
+ struct Mesh *dm);
#endif
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index a5013bb38c6..a1629d8c1f2 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -63,12 +63,12 @@ static void initData(ModifierData *md)
hmd->flag = 0;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const HookModifierData *hmd = (const HookModifierData *) md;
HookModifierData *thmd = (HookModifierData *) target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
thmd->curfalloff = curvemapping_copy(hmd->curfalloff);
@@ -96,7 +96,7 @@ static void freeData(ModifierData *md)
MEM_SAFE_FREE(hmd->indexar);
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
HookModifierData *hmd = (HookModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index e5b96c633f7..2406739e6df 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -704,18 +704,18 @@ static void initData(ModifierData *md)
lmd->flag = 0;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const LaplacianDeformModifierData *lmd = (const LaplacianDeformModifierData *)md;
LaplacianDeformModifierData *tlmd = (LaplacianDeformModifierData *)target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
tlmd->vertexco = MEM_dupallocN(lmd->vertexco);
tlmd->cache_system = NULL;
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
if (lmd->anchor_grp_name[0]) return 0;
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 580de4b1572..19838a2b637 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -81,7 +81,7 @@ struct BLaplacianSystem {
typedef struct BLaplacianSystem LaplacianSystem;
static CustomDataMask required_data_mask(Object *ob, ModifierData *md);
-static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, int useRenderParams);
+static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, bool useRenderParams);
static float compute_volume(const float center[3], float (*vertexCos)[3], const MPoly *mpoly, int numPolys, const MLoop *mloop);
static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numPolys, int a_numLoops, int a_numVerts);
static void delete_laplacian_system(LaplacianSystem *sys);
@@ -474,7 +474,7 @@ static void init_data(ModifierData *md)
smd->defgrp_name[0] = '\0';
}
-static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md;
short flag;
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 540876ac339..3acd39bf19d 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -67,7 +67,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
{
LatticeModifierData *lmd = (LatticeModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index 9d6dfc0e1eb..8d2ac001e2d 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -72,7 +72,7 @@ static bool dependsOnTime(ModifierData *md)
return (mcmd->play_mode == MOD_MESHCACHE_PLAY_CFEA);
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
MeshCacheModifierData *mcmd = (MeshCacheModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index af37b30b7aa..9bfbbc4e44e 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -81,12 +81,12 @@ static void freeData(ModifierData *md)
if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const MeshDeformModifierData *mmd = (const MeshDeformModifierData *) md;
MeshDeformModifierData *tmmd = (MeshDeformModifierData *) target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
if (mmd->bindinfluences) tmmd->bindinfluences = MEM_dupallocN(mmd->bindinfluences);
if (mmd->bindoffsets) tmmd->bindoffsets = MEM_dupallocN(mmd->bindoffsets);
@@ -109,7 +109,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index a6c9f865e4c..cef55bf467b 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -55,14 +55,14 @@ static void initData(ModifierData *md)
mcmd->read_flag = MOD_MESHSEQ_READ_ALL;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
const MeshSeqCacheModifierData *mcmd = (const MeshSeqCacheModifierData *)md;
#endif
MeshSeqCacheModifierData *tmcmd = (MeshSeqCacheModifierData *)target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
tmcmd->reader = NULL;
}
@@ -79,7 +79,7 @@ static void freeData(ModifierData *md)
}
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c
index c973bd18830..7a6a5b94b8e 100644
--- a/source/blender/modifiers/intern/MOD_none.c
+++ b/source/blender/modifiers/intern/MOD_none.c
@@ -43,7 +43,7 @@
* no other functions will be called
*/
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *UNUSED(md), int UNUSED(userRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *UNUSED(md), bool UNUSED(userRenderParams))
{
return true;
}
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index ae67296dda7..14af389668c 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -524,7 +524,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk,
walk(userData, ob, &enmd->target, IDWALK_CB_NOP);
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
NormalEditModifierData *enmd = (NormalEditModifierData *)md;
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 702e557ccb1..12845b27166 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -31,6 +31,7 @@
#include "DNA_customdata_types.h"
#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"
@@ -40,9 +41,9 @@
#include "BLI_task.h"
#include "BLI_utildefines.h"
-#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_ocean.h"
@@ -60,38 +61,8 @@ static void init_cache_data(Object *ob, struct OceanModifierData *omd)
omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
}
-static void clear_cache_data(struct OceanModifierData *omd)
-{
- BKE_ocean_free_cache(omd->oceancache);
- omd->oceancache = NULL;
- omd->cached = false;
-}
-
-/* keep in sync with init_ocean_modifier_bake(), object_modifier.c */
-static void init_ocean_modifier(struct OceanModifierData *omd)
-{
- int do_heightfield, do_chop, do_normals, do_jacobian;
-
- if (!omd || !omd->ocean) return;
-
- do_heightfield = true;
- do_chop = (omd->chop_amount > 0);
- do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS);
- do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
-
- BKE_ocean_free_data(omd->ocean);
- BKE_ocean_init(omd->ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution,
- omd->spatial_size, omd->spatial_size,
- omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
- omd->depth, omd->time,
- do_heightfield, do_chop, do_normals, do_jacobian,
- omd->seed);
-}
-
static void simulate_ocean_modifier(struct OceanModifierData *omd)
{
- if (!omd || !omd->ocean) return;
-
BKE_ocean_simulate(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount);
}
#endif /* WITH_OCEANSIM */
@@ -125,8 +96,6 @@ static void initData(ModifierData *md)
omd->seed = 0;
omd->time = 1.0;
- omd->refresh = 0;
-
omd->size = 1.0;
omd->repeat_x = 1;
omd->repeat_y = 1;
@@ -141,7 +110,7 @@ static void initData(ModifierData *md)
omd->foamlayername[0] = '\0'; /* layer name empty by default */
omd->ocean = BKE_ocean_add();
- init_ocean_modifier(omd);
+ BKE_ocean_init_from_modifier(omd->ocean, omd);
simulate_ocean_modifier(omd);
#else /* WITH_OCEANSIM */
/* unused */
@@ -163,7 +132,7 @@ static void freeData(ModifierData *md)
#endif /* WITH_OCEANSIM */
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#ifdef WITH_OCEANSIM
#if 0
@@ -171,21 +140,20 @@ static void copyData(const ModifierData *md, ModifierData *target)
#endif
OceanModifierData *tomd = (OceanModifierData *) target;
- modifier_copyData_generic(md, target);
-
- tomd->refresh = 0;
+ modifier_copyData_generic(md, target, flag);
- /* XXX todo: copy cache runtime too */
- tomd->cached = 0;
+ /* The oceancache object will be recreated for this copy
+ * automatically when cached=true */
tomd->oceancache = NULL;
tomd->ocean = BKE_ocean_add();
- init_ocean_modifier(tomd);
+ BKE_ocean_init_from_modifier(tomd->ocean, tomd);
simulate_ocean_modifier(tomd);
#else /* WITH_OCEANSIM */
/* unused */
(void)md;
(void)target;
+ (void)flag;
#endif /* WITH_OCEANSIM */
}
@@ -343,9 +311,9 @@ static void generate_ocean_geometry_uvs(
}
}
-static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
+static Mesh *generate_ocean_geometry(OceanModifierData *omd)
{
- DerivedMesh *result;
+ Mesh *result;
GenerateOceanGeometryData gogd;
@@ -370,13 +338,13 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
gogd.sx /= gogd.rx;
gogd.sy /= gogd.ry;
- result = CDDM_new(num_verts, 0, 0, num_polys * 4, num_polys);
+ result = BKE_mesh_new_nomain(num_verts, 0, 0, num_polys * 4, num_polys);
- gogd.mverts = CDDM_get_verts(result);
- gogd.mpolys = CDDM_get_polys(result);
- gogd.mloops = CDDM_get_loops(result);
+ gogd.mverts = result->mvert;
+ gogd.mpolys = result->mpoly;
+ gogd.mloops = result->mloop;
- gogd.origindex = CustomData_get_layer(&result->polyData, CD_ORIGINDEX);
+ gogd.origindex = CustomData_get_layer(&result->pdata, CD_ORIGINDEX);
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
@@ -388,11 +356,11 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
/* create faces */
BLI_task_parallel_range(0, gogd.res_y, &gogd, generate_ocean_geometry_polygons, &settings);
- CDDM_calc_edges(result);
+ BKE_mesh_calc_edges(result, false, false);
/* add uvs */
- if (CustomData_number_of_layers(&result->loopData, CD_MLOOPUV) < MAX_MTFACE) {
- gogd.mloopuvs = CustomData_add_layer(&result->loopData, CD_MLOOPUV, CD_CALLOC, NULL, num_polys * 4);
+ if (CustomData_number_of_layers(&result->ldata, CD_MLOOPUV) < MAX_MTFACE) {
+ gogd.mloopuvs = CustomData_add_layer(&result->ldata, CD_MLOOPUV, CD_CALLOC, NULL, num_polys * 4);
if (gogd.mloopuvs) { /* unlikely to fail */
gogd.ix = 1.0 / gogd.rx;
@@ -402,24 +370,24 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
}
}
- result->dirty |= DM_DIRTY_NORMALS;
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
return result;
}
-static DerivedMesh *doOcean(
- ModifierData *md, Scene *scene, Object *ob,
- DerivedMesh *derivedData,
- int UNUSED(useRenderParams))
+static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
OceanModifierData *omd = (OceanModifierData *) md;
+ int cfra_scene = (int)DEG_get_ctime(ctx->depsgraph);
+ Object *ob = ctx->object;
+ bool allocated_ocean = false;
- DerivedMesh *dm = NULL;
+ Mesh *result = NULL;
OceanResult ocr;
MVert *mverts;
- int cfra;
+ int cfra_for_cache;
int i, j;
/* use cached & inverted value for speed
@@ -432,58 +400,57 @@ static DerivedMesh *doOcean(
/* can happen in when size is small, avoid bad array lookups later and quit now */
if (!isfinite(size_co_inv)) {
- return derivedData;
+ return mesh;
}
- /* update modifier */
- if (omd->refresh & MOD_OCEAN_REFRESH_ADD) {
- omd->ocean = BKE_ocean_add();
- }
- if (omd->refresh & MOD_OCEAN_REFRESH_RESET) {
- init_ocean_modifier(omd);
- }
- if (omd->refresh & MOD_OCEAN_REFRESH_CLEAR_CACHE) {
- clear_cache_data(omd);
- }
- omd->refresh = 0;
-
/* do ocean simulation */
if (omd->cached == true) {
if (!omd->oceancache) {
init_cache_data(ob, omd);
}
- BKE_ocean_simulate_cache(omd->oceancache, scene->r.cfra);
+ BKE_ocean_simulate_cache(omd->oceancache, cfra_scene);
}
else {
+ /* omd->ocean is NULL on an original object (in contrast to an evaluated one).
+ * We can create a new one, but we have to free it as well once we're done.
+ * This function is only called on an original object when applying the modifier
+ * using the 'Apply Modifier' button, and thus it is not called frequently for
+ * simulation. */
+ allocated_ocean |= BKE_ocean_ensure(omd);
simulate_ocean_modifier(omd);
}
if (omd->geometry_mode == MOD_OCEAN_GEOM_GENERATE) {
- dm = generate_ocean_geometry(omd);
- DM_ensure_normals(dm);
+ result = generate_ocean_geometry(omd);
+ BKE_mesh_ensure_normals(result);
}
else if (omd->geometry_mode == MOD_OCEAN_GEOM_DISPLACE) {
- dm = CDDM_copy(derivedData);
+ BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_NO_PREVIEW,
+ false);
}
- cfra = scene->r.cfra;
- CLAMP(cfra, omd->bakestart, omd->bakeend);
- cfra -= omd->bakestart; /* shift to 0 based */
+ cfra_for_cache = cfra_scene;
+ CLAMP(cfra_for_cache, omd->bakestart, omd->bakeend);
+ cfra_for_cache -= omd->bakestart; /* shift to 0 based */
- mverts = dm->getVertArray(dm);
+ mverts = result->mvert;
/* add vcols before displacement - allows lookup based on position */
if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
- if (CustomData_number_of_layers(&dm->loopData, CD_MLOOPCOL) < MAX_MCOL) {
- const int num_polys = dm->getNumPolys(dm);
- const int num_loops = dm->getNumLoops(dm);
- MLoop *mloops = dm->getLoopArray(dm);
+ if (CustomData_number_of_layers(&result->ldata, CD_MLOOPCOL) < MAX_MCOL) {
+ const int num_polys = result->totpoly;
+ const int num_loops = result->totloop;
+ MLoop *mloops = result->mloop;
MLoopCol *mloopcols = CustomData_add_layer_named(
- &dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->foamlayername);
+ &result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->foamlayername);
if (mloopcols) { /* unlikely to fail */
- MPoly *mpolys = dm->getPolyArray(dm);
+ MPoly *mpolys = result->mpoly;
MPoly *mp;
for (i = 0, mp = mpolys; i < num_polys; i++, mp++) {
@@ -497,7 +464,7 @@ static DerivedMesh *doOcean(
float foam;
if (omd->oceancache && omd->cached == true) {
- BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v);
+ BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra_for_cache, u, v);
foam = ocr.foam;
CLAMP(foam, 0.0f, 1.0f);
}
@@ -520,7 +487,7 @@ static DerivedMesh *doOcean(
/* Note: tried to parallelized that one and previous foam loop, but gives 20% slower results... odd. */
{
- const int num_verts = dm->getNumVerts(dm);
+ const int num_verts = result->totvert;
for (i = 0; i < num_verts; i++) {
float *vco = mverts[i].co;
@@ -528,7 +495,7 @@ static DerivedMesh *doOcean(
const float v = OCEAN_CO(size_co_inv, vco[1]);
if (omd->oceancache && omd->cached == true) {
- BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v);
+ BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra_for_cache, u, v);
}
else {
BKE_ocean_eval_uv(omd->ocean, &ocr, u, v);
@@ -543,33 +510,32 @@ static DerivedMesh *doOcean(
}
}
+ if (allocated_ocean) {
+ BKE_ocean_free(omd->ocean);
+ omd->ocean = NULL;
+ }
+
#undef OCEAN_CO
- return dm;
+ return result;
}
#else /* WITH_OCEANSIM */
-static DerivedMesh *doOcean(
- ModifierData *UNUSED(md), Scene *UNUSED(scene), Object *UNUSED(ob),
- DerivedMesh *derivedData,
- int UNUSED(useRenderParams))
+static Mesh *doOcean(ModifierData *UNUSED(md), const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
{
- /* unused */
- return derivedData;
+ return mesh;
}
#endif /* WITH_OCEANSIM */
-static DerivedMesh *applyModifier(
+static Mesh *applyModifier(
ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *derivedData)
+ Mesh *mesh)
{
- DerivedMesh *result;
- Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
-
+ Mesh *result;
- result = doOcean(md, scene, ctx->object, derivedData, 0);
+ result = doOcean(md, ctx, mesh);
- if (result != derivedData)
- result->dirty |= DM_DIRTY_NORMALS;
+ if (result != mesh)
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
return result;
}
@@ -590,14 +556,14 @@ ModifierTypeInfo modifierType_Ocean = {
/* deformVerts_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ applyModifier,
+ /* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
+ /* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index bb6ed8e8344..edafcd6fcb9 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -88,7 +88,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
-static bool isDisabled(const struct Scene *scene, ModifierData *md, int useRenderParams)
+static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRenderParams)
{
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
ParticleSystem *psys;
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 1821a0fced0..6f9a44cd9e6 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -79,14 +79,14 @@ static void freeData(ModifierData *md)
psmd->psys->flag |= PSYS_DELETE;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
const ParticleSystemModifierData *psmd = (const ParticleSystemModifierData *) md;
#endif
ParticleSystemModifierData *tpsmd = (ParticleSystemModifierData *) target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
tpsmd->mesh_final = NULL;
tpsmd->mesh_original = NULL;
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 72c1c1552c7..5497673a52d 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -84,7 +84,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md;
return !smd->target;
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index e81c760ed67..9a27f31adaa 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -71,7 +71,7 @@ static void initData(ModifierData *md)
smd->time = -1;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag))
{
const SmokeModifierData *smd = (const SmokeModifierData *)md;
SmokeModifierData *tsmd = (SmokeModifierData *)target;
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 280a795fae8..29508524f9c 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -61,7 +61,7 @@ static void initData(ModifierData *md)
smd->defgrp_name[0] = '\0';
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
SmoothModifierData *smd = (SmoothModifierData *) md;
short flag;
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 3de04e878ac..08dc7c92693 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -35,8 +35,9 @@
#include <stddef.h>
-#include "DNA_scene_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_mesh_types.h"
#ifdef WITH_OPENSUBDIV
# include "DNA_userdef_types.h"
@@ -44,9 +45,9 @@
#include "BLI_utildefines.h"
-
#include "BKE_cdderivedmesh.h"
#include "BKE_scene.h"
+#include "BKE_subdiv.h"
#include "BKE_subsurf.h"
#include "DEG_depsgraph.h"
@@ -56,6 +57,8 @@
#include "intern/CCGSubSurf.h"
+// #define USE_OPENSUBDIV
+
static void initData(ModifierData *md)
{
SubsurfModifierData *smd = (SubsurfModifierData *) md;
@@ -65,14 +68,14 @@ static void initData(ModifierData *md)
smd->flags |= eSubsurfModifierFlag_SubsurfUv;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
const SubsurfModifierData *smd = (const SubsurfModifierData *) md;
#endif
SubsurfModifierData *tsmd = (SubsurfModifierData *) target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
tsmd->emCache = tsmd->mCache = NULL;
}
@@ -91,7 +94,7 @@ static void freeData(ModifierData *md)
}
}
-static bool isDisabled(const Scene *scene, ModifierData *md, int useRenderParams)
+static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParams)
{
SubsurfModifierData *smd = (SubsurfModifierData *) md;
int levels = (useRenderParams) ? smd->renderLevels : smd->levels;
@@ -181,9 +184,74 @@ static DerivedMesh *applyModifierEM(
#endif
result = subsurf_make_derived_from_derived(derivedData, smd, scene, NULL, ss_flags);
+ return result;
+}
+
+#ifdef USE_OPENSUBDIV
+static int subdiv_levels_for_modifier_get(const SubsurfModifierData *smd,
+ const ModifierEvalContext *ctx)
+{
+ Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
+ const bool use_render_params = (ctx->flag & MOD_APPLY_RENDER);
+ const int requested_levels = (use_render_params) ? smd->renderLevels
+ : smd->levels;
+ return get_render_subsurf_level(&scene->r,
+ requested_levels,
+ use_render_params);
+}
+
+static void subdiv_settings_init(SubdivSettings *settings,
+ const SubsurfModifierData *smd,
+ const ModifierEvalContext *ctx)
+{
+ settings->is_simple = (smd->subdivType == SUBSURF_TYPE_SIMPLE);
+ settings->is_adaptive = !settings->is_simple;
+ settings->level = subdiv_levels_for_modifier_get(smd, ctx);
+ settings->fvar_linear_interpolation =
+ (smd->flags & eSubsurfModifierFlag_SubsurfUv)
+ ? SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY
+ : SUBDIV_FVAR_LINEAR_INTERPOLATION_ALL;
+}
+
+static void subdiv_mesh_settings_init(SubdivToMeshSettings *settings,
+ const SubdivSettings *subdiv_settings)
+{
+ settings->resolution = (1 << subdiv_settings->level) + 1;
+}
+static Mesh *applyModifier_subdiv(ModifierData *md,
+ const ModifierEvalContext *ctx,
+ Mesh *mesh)
+{
+ Mesh *result = mesh;
+ SubsurfModifierData *smd = (SubsurfModifierData *) md;
+ SubdivSettings subdiv_settings;
+ subdiv_settings_init(&subdiv_settings, smd, ctx);
+ if (subdiv_settings.level == 0) {
+ /* NOTE: Shouldn't really happen, is supposed to be catched by
+ * isDisabled() callback.
+ */
+ return result;
+ }
+ /* TODO(sergey): Try to re-use subdiv when possible. */
+ Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, mesh);
+ if (subdiv == NULL) {
+ /* Happens on bad topology. */
+ /* TODO(sergey): This also happens on meshes without faces, so probably
+ * need to handle those differently (i.e. set modifier error when
+ * topology itself is bad, and not do anything when there are no faces).
+ */
+ return result;
+ }
+ SubdivToMeshSettings mesh_settings;
+ subdiv_mesh_settings_init(&mesh_settings, &subdiv_settings);
+ result = BKE_subdiv_to_mesh(subdiv, &mesh_settings, mesh);
+ /* TODO(sergey): Cache subdiv somehow. */
+ // BKE_subdiv_stats_print(&subdiv->stats);
+ BKE_subdiv_free(subdiv);
return result;
}
+#endif
static bool dependsOnNormals(ModifierData *md)
{
@@ -222,7 +290,11 @@ ModifierTypeInfo modifierType_Subsurf = {
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
+#ifdef USE_OPENSUBDIV
+ /* applyModifier */ applyModifier_subdiv,
+#else
/* applyModifier */ NULL,
+#endif
/* applyModifierEM */ NULL,
/* initData */ initData,
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index a3ab2d74602..6dbeed9b4c8 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -136,12 +136,12 @@ static void freeData(ModifierData *md)
}
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const SurfaceDeformModifierData *smd = (const SurfaceDeformModifierData *)md;
SurfaceDeformModifierData *tsmd = (SurfaceDeformModifierData *)target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
if (smd->verts) {
tsmd->verts = MEM_dupallocN(smd->verts);
@@ -1195,7 +1195,7 @@ static void deformVertsEM(
surfacedeformModifier_do(md, ctx, vertexCos, numVerts, ctx->object);
}
-static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 54f8ce8c515..a8f305bcc13 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -65,12 +65,12 @@ static void initData(ModifierData *md)
wmd->flag = 0;
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const WarpModifierData *wmd = (const WarpModifierData *) md;
WarpModifierData *twmd = (WarpModifierData *) target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
twmd->curfalloff = curvemapping_copy(wmd->curfalloff);
}
@@ -109,7 +109,7 @@ static void freeData(ModifierData *md)
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
{
WarpModifierData *wmd = (WarpModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index a26cb73d823..a34ed1baaff 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -81,12 +81,12 @@ static void freeData(ModifierData *md)
curvemapping_free(wmd->cmap_curve);
}
-static void copyData(const ModifierData *md, ModifierData *target)
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const WeightVGEditModifierData *wmd = (const WeightVGEditModifierData *) md;
WeightVGEditModifierData *twmd = (WeightVGEditModifierData *) target;
- modifier_copyData_generic(md, target);
+ modifier_copyData_generic(md, target, flag);
twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve);
}
@@ -148,7 +148,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md;
/* If no vertex group, bypass. */
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 90bd5acff62..b6a7228b171 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -185,7 +185,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md;
/* If no vertex group, bypass. */
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 88e33f28eaf..05b1ec19253 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -358,7 +358,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md;
/* If no vertex group, bypass. */
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 67c86180188..8df114afa24 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -60,6 +60,7 @@ set(SRC
composite/nodes/node_composite_composite.c
composite/nodes/node_composite_cornerpin.c
composite/nodes/node_composite_crop.c
+ composite/nodes/node_composite_cryptomatte.c
composite/nodes/node_composite_curves.c
composite/nodes/node_composite_despeckle.c
composite/nodes/node_composite_doubleEdgeMask.c
@@ -168,6 +169,7 @@ set(SRC
shader/nodes/node_shader_bsdf_transparent.c
shader/nodes/node_shader_bsdf_velvet.c
shader/nodes/node_shader_bsdf_hair.c
+ shader/nodes/node_shader_bsdf_hair_principled.c
shader/nodes/node_shader_bump.c
shader/nodes/node_shader_emission.c
shader/nodes/node_shader_fresnel.c
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index dfcb83b873a..a728d1e228d 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -109,6 +109,7 @@ void register_node_type_cmp_luma_matte(void);
void register_node_type_cmp_doubleedgemask(void);
void register_node_type_cmp_keyingscreen(void);
void register_node_type_cmp_keying(void);
+void register_node_type_cmp_cryptomatte(void);
void register_node_type_cmp_translate(void);
void register_node_type_cmp_rotate(void);
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index 83a5f5c5bf1..2f466b0296c 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -111,6 +111,7 @@ void register_node_type_sh_volume_absorption(void);
void register_node_type_sh_volume_scatter(void);
void register_node_type_sh_volume_principled(void);
void register_node_type_sh_bsdf_hair(void);
+void register_node_type_sh_bsdf_hair_principled(void);
void register_node_type_sh_subsurface_scattering(void);
void register_node_type_sh_mix_shader(void);
void register_node_type_sh_add_shader(void);
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index ec4e88768de..22c2afcc466 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -62,8 +62,8 @@ DefNode( ShaderNode, SH_NODE_COMBRGB, 0, "COMBR
DefNode( ShaderNode, SH_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" )
DefNode( ShaderNode, SH_NODE_OUTPUT_MATERIAL, def_sh_output, "OUTPUT_MATERIAL", OutputMaterial, "Material Output", "" )
-DefNode( ShaderNode, SH_NODE_EEVEE_SPECULAR, 0, "EEVEE_SPECULAR", EeveeSpecular, "Specular", "")
-DefNode( ShaderNode, SH_NODE_OUTPUT_LAMP, def_sh_output, "OUTPUT_LAMP", OutputLamp, "Lamp Output", "" )
+DefNode( ShaderNode, SH_NODE_EEVEE_SPECULAR, 0, "EEVEE_SPECULAR", EeveeSpecular, "Specular", "" )
+DefNode( ShaderNode, SH_NODE_OUTPUT_LIGHT, def_sh_output, "OUTPUT_LIGHT", OutputLight, "Light Output", "" )
DefNode( ShaderNode, SH_NODE_OUTPUT_WORLD, def_sh_output, "OUTPUT_WORLD", OutputWorld, "World Output", "" )
DefNode( ShaderNode, SH_NODE_OUTPUT_LINESTYLE, def_sh_output_linestyle,"OUTPUT_LINESTYLE", OutputLineStyle, "Line Style Output", "" )
DefNode( ShaderNode, SH_NODE_FRESNEL, 0, "FRESNEL", Fresnel, "Fresnel", "" )
@@ -85,6 +85,7 @@ DefNode( ShaderNode, SH_NODE_BSDF_TRANSPARENT, 0, "BS
DefNode( ShaderNode, SH_NODE_BSDF_VELVET, 0, "BSDF_VELVET", BsdfVelvet, "Velvet BSDF", "" )
DefNode( ShaderNode, SH_NODE_BSDF_TOON, def_toon, "BSDF_TOON", BsdfToon, "Toon BSDF", "" )
DefNode( ShaderNode, SH_NODE_BSDF_HAIR, def_hair, "BSDF_HAIR", BsdfHair, "Hair BSDF", "" )
+DefNode( ShaderNode, SH_NODE_BSDF_HAIR_PRINCIPLED, def_hair_principled, "BSDF_HAIR_PRINCIPLED", BsdfHairPrincipled, "Principled Hair BSDF", "")
DefNode( ShaderNode, SH_NODE_SUBSURFACE_SCATTERING, def_sh_subsurface, "SUBSURFACE_SCATTERING",SubsurfaceScattering,"Subsurface Scattering","")
DefNode( ShaderNode, SH_NODE_VOLUME_ABSORPTION, 0, "VOLUME_ABSORPTION", VolumeAbsorption, "Volume Absorption", "" )
DefNode( ShaderNode, SH_NODE_VOLUME_SCATTER, 0, "VOLUME_SCATTER", VolumeScatter, "Volume Scatter", "" )
@@ -215,6 +216,7 @@ DefNode( CompositorNode, CMP_NODE_PIXELATE, 0, "PIXEL
DefNode( CompositorNode, CMP_NODE_PLANETRACKDEFORM,def_cmp_planetrackdeform,"PLANETRACKDEFORM",PlaneTrackDeform,"Plane Track Deform","" )
DefNode( CompositorNode, CMP_NODE_CORNERPIN, 0, "CORNERPIN", CornerPin, "Corner Pin", "" )
DefNode( CompositorNode, CMP_NODE_SUNBEAMS, def_cmp_sunbeams, "SUNBEAMS", SunBeams, "Sun Beams", "" )
+DefNode( CompositorNode, CMP_NODE_CRYPTOMATTE, def_cmp_cryptomatte, "CRYPTOMATTE", Cryptomatte, "Cryptomatte", "" )
DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" )
DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" )
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
new file mode 100644
index 00000000000..bf9ab4a5064
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -0,0 +1,302 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Stockner, Stefan Werner
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/composite/nodes/node_composite_cryptomatte.c
+ * \ingroup cmpnodes
+ */
+
+#include "node_composite_util.h"
+#include "BLI_assert.h"
+#include "BLI_dynstr.h"
+#include "BLI_hash_mm3.h"
+#include "BLI_utildefines.h"
+
+/* this is taken from the cryptomatte specification 1.0 */
+
+static inline float hash_to_float(uint32_t hash)
+{
+ uint32_t mantissa = hash & ((1 << 23) - 1);
+ uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
+ exponent = MAX2(exponent, (uint32_t)1);
+ exponent = MIN2(exponent, (uint32_t)254);
+ exponent = exponent << 23;
+ uint32_t sign = (hash >> 31);
+ sign = sign << 31;
+ uint32_t float_bits = sign | exponent | mantissa;
+ float f;
+ /* Bit casting relies on equal size for both types. */
+ BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "float and uint32_t are not the same size")
+ memcpy(&f, &float_bits, sizeof(float));
+ return f;
+}
+
+static void cryptomatte_add(NodeCryptomatte *n, float f)
+{
+ /* Turn the number into a string. */
+ char number[32];
+ BLI_snprintf(number, sizeof(number), "<%.9g>", f);
+
+ /* Search if we already have the number. */
+ if (n->matte_id && strlen(n->matte_id) != 0) {
+ size_t start = 0;
+ const size_t end = strlen(n->matte_id);
+ size_t token_len = 0;
+ while (start < end) {
+ /* Ignore leading whitespace. */
+ while (start < end && n->matte_id[start] == ' ') {
+ ++start;
+ }
+
+ /* Find the next seprator. */
+ char *token_end = strchr(n->matte_id + start, ',');
+ if (token_end == NULL || token_end == n->matte_id + start) {
+ token_end = n->matte_id + end;
+ }
+ /* Be aware that token_len still contains any trailing white space. */
+ token_len = token_end - (n->matte_id + start);
+
+ /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */
+ if (n->matte_id[start] == '<') {
+ if (strncmp(n->matte_id + start, number, strlen(number)) == 0) {
+ /* This number is already there, so continue. */
+ return;
+ }
+ }
+ else {
+ /* Remove trailing white space */
+ size_t name_len = token_len;
+ while (n->matte_id[start + name_len] == ' ' && name_len > 0) {
+ name_len--;
+ }
+ /* Calculate the hash of the token and compare. */
+ uint32_t hash = BLI_hash_mm3((const unsigned char *)(n->matte_id + start), name_len, 0);
+ if (f == hash_to_float(hash)) {
+ return;
+ }
+ }
+ start += token_len + 1;
+ }
+ }
+
+ DynStr *new_matte = BLI_dynstr_new();
+ if (!new_matte) {
+ return;
+ }
+
+ if (n->matte_id) {
+ BLI_dynstr_append(new_matte, n->matte_id);
+ MEM_freeN(n->matte_id);
+ }
+
+ if (BLI_dynstr_get_len(new_matte) > 0) {
+ BLI_dynstr_append(new_matte, ",");
+ }
+ BLI_dynstr_append(new_matte, number);
+ n->matte_id = BLI_dynstr_get_cstring(new_matte);
+ BLI_dynstr_free(new_matte);
+}
+
+static void cryptomatte_remove(NodeCryptomatte *n, float f)
+{
+ if (n->matte_id == NULL || strlen(n->matte_id) == 0) {
+ /* Empty string, nothing to remove. */
+ return;
+ }
+
+ /* This will be the new string without the removed key. */
+ DynStr *new_matte = BLI_dynstr_new();
+ if (!new_matte) {
+ return;
+ }
+
+ /* Turn the number into a string. */
+ static char number[32];
+ BLI_snprintf(number, sizeof(number), "<%.9g>", f);
+
+ /* Search if we already have the number. */
+ size_t start = 0;
+ const size_t end = strlen(n->matte_id);
+ size_t token_len = 0;
+ bool is_first = true;
+ while (start < end) {
+ bool skip = false;
+ /* Ignore leading whitespace or commas. */
+ while (start < end && ((n->matte_id[start] == ' ') || (n->matte_id[start] == ','))) {
+ ++start;
+ }
+
+ /* Find the next seprator. */
+ char *token_end = strchr(n->matte_id + start + 1, ',');
+ if (token_end == NULL || token_end == n->matte_id + start) {
+ token_end = n->matte_id + end;
+ }
+ /* Be aware that token_len still contains any trailing white space. */
+ token_len = token_end - (n->matte_id + start);
+
+ if (token_len == 1) {
+ skip = true;
+ }
+ /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */
+ else if (n->matte_id[start] == '<') {
+ if (strncmp(n->matte_id + start, number, strlen(number)) == 0) {
+ /* This number is already there, so skip it. */
+ skip = true;
+ }
+ }
+ else {
+ /* Remove trailing white space */
+ size_t name_len = token_len;
+ while (n->matte_id[start + name_len] == ' ' && name_len > 0) {
+ name_len--;
+ }
+ /* Calculate the hash of the token and compare. */
+ uint32_t hash = BLI_hash_mm3((const unsigned char *)(n->matte_id + start), name_len, 0);
+ if (f == hash_to_float(hash)) {
+ skip = true;
+ }
+ }
+ if (!skip) {
+ if (is_first) {
+ is_first = false;
+ }
+ else {
+ BLI_dynstr_append(new_matte, ", ");
+ }
+ BLI_dynstr_nappend(new_matte, n->matte_id + start, token_len);
+ }
+ start += token_len + 1;
+ }
+
+ if (n->matte_id) {
+ MEM_freeN(n->matte_id);
+ n->matte_id = NULL;
+ }
+ if (BLI_dynstr_get_len(new_matte) > 0) {
+ n->matte_id = BLI_dynstr_get_cstring(new_matte);
+ }
+ BLI_dynstr_free(new_matte);
+}
+
+static bNodeSocketTemplate outputs[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { SOCK_FLOAT, 0, N_("Matte")},
+ { SOCK_RGBA, 0, N_("Pick")},
+ { -1, 0, "" }
+};
+
+void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeCryptomatte *n = node->storage;
+ if (n->add[0] != 0.0f) {
+ cryptomatte_add(n, n->add[0]);
+ n->add[0] = 0.0f;
+ n->add[1] = 0.0f;
+ n->add[2] = 0.0f;
+ }
+}
+
+void ntreeCompositCryptomatteSyncFromRemove(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeCryptomatte *n = node->storage;
+ if (n->remove[0] != 0.0f) {
+ cryptomatte_remove(n, n->remove[0]);
+ n->remove[0] = 0.0f;
+ n->remove[1] = 0.0f;
+ n->remove[2] = 0.0f;
+ }
+}
+
+bNodeSocket *ntreeCompositCryptomatteAddSocket(bNodeTree *ntree, bNode *node)
+{
+ NodeCryptomatte *n = node->storage;
+ char sockname[32];
+ n->num_inputs++;
+ BLI_snprintf(sockname, sizeof(sockname), "Crypto %.2d", n->num_inputs - 1);
+ bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, sockname);
+ return sock;
+}
+
+int ntreeCompositCryptomatteRemoveSocket(bNodeTree *ntree, bNode *node)
+{
+ NodeCryptomatte *n = node->storage;
+ if (n->num_inputs < 2) {
+ return 0;
+ }
+ bNodeSocket *sock = node->inputs.last;
+ nodeRemoveSocket(ntree, node, sock);
+ n->num_inputs--;
+ return 1;
+}
+
+static void init(bNodeTree *ntree, bNode *node)
+{
+ NodeCryptomatte *user = MEM_callocN(sizeof(NodeCryptomatte), "cryptomatte user");
+ node->storage = user;
+
+
+ nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, "image", "Image");
+
+ /* Add three inputs by default, as recommended by the Cryptomatte specification. */
+ ntreeCompositCryptomatteAddSocket(ntree, node);
+ ntreeCompositCryptomatteAddSocket(ntree, node);
+ ntreeCompositCryptomatteAddSocket(ntree, node);
+}
+
+static void node_free_cryptomatte(bNode *node)
+{
+ NodeCryptomatte *nc = node->storage;
+
+ if (nc) {
+ if (nc->matte_id) {
+ MEM_freeN(nc->matte_id);
+ }
+
+ MEM_freeN(nc);
+ }
+}
+
+static void node_copy_cryptomatte(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
+{
+ NodeCryptomatte *src_nc = src_node->storage;
+ NodeCryptomatte *dest_nc = MEM_dupallocN(src_nc);
+
+ if (src_nc->matte_id)
+ dest_nc->matte_id = MEM_dupallocN(src_nc->matte_id);
+
+ dest_node->storage = dest_nc;
+}
+
+void register_node_type_cmp_cryptomatte(void)
+{
+ static bNodeType ntype;
+
+ cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE, "Cryptomatte", NODE_CLASS_CONVERTOR, 0);
+ node_type_socket_templates(&ntype, NULL, outputs);
+ node_type_init(&ntype, init);
+ node_type_storage(&ntype, "NodeCryptomatte", node_free_cryptomatte, node_copy_cryptomatte);
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 8bdaa39f3b7..78956f63e8a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -304,7 +304,6 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node)
node->storage = iuser;
iuser->frames = 1;
iuser->sfra = 1;
- iuser->fie_ima = 2;
iuser->ok = 1;
iuser->flag |= IMA_ANIM_ALWAYS;
@@ -442,6 +441,7 @@ void register_node_type_cmp_rlayers(void)
node_type_storage(&ntype, NULL, node_composit_free_rlayers, node_composit_copy_rlayers);
node_type_update(&ntype, cmp_node_rlayers_update, NULL);
node_type_init(&ntype, node_cmp_rlayers_outputs);
+ node_type_size_preset(&ntype, NODE_SIZE_LARGE);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
index f7008bc9ae4..863c8af66bb 100644
--- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
@@ -47,7 +47,6 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node
ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user");
node->storage = iuser;
iuser->sfra = 1;
- iuser->fie_ima = 2;
iuser->ok = 1;
node->custom1 = 50; /* default 50% split */
diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c
index f82b0d7206a..6221202398a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c
@@ -49,7 +49,6 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node)
ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user");
node->storage = iuser;
iuser->sfra = 1;
- iuser->fie_ima = 2;
iuser->ok = 1;
node->custom3 = 0.5f;
node->custom4 = 0.5f;
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index cb04b341c26..2dbb573f305 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -210,7 +210,6 @@ void register_node_type_frame(void)
node_type_init(ntype, node_frame_init);
node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage);
node_type_size(ntype, 150, 100, 0);
- node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
ntype->needs_free = 1;
nodeRegisterType(ntype);
@@ -484,7 +483,6 @@ void register_node_type_group_input(void)
node_type_size(ntype, 140, 80, 400);
node_type_init(ntype, node_group_input_init);
node_type_update(ntype, node_group_input_update, node_group_input_verify);
- node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
ntype->needs_free = 1;
nodeRegisterType(ntype);
@@ -583,7 +581,6 @@ void register_node_type_group_output(void)
node_type_size(ntype, 140, 80, 400);
node_type_init(ntype, node_group_output_init);
node_type_update(ntype, node_group_output_update, node_group_output_verify);
- node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
ntype->needs_free = 1;
nodeRegisterType(ntype);
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 301fd3c35a8..919af171756 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -209,20 +209,52 @@ static void ntree_shader_link_builtin_normal(bNodeTree *ntree,
* render engines works but it's how the GPU shader compilation works. This we
* can change in the future and make it a generic function, but for now it stays
* private here.
- *
- * It also does not yet take into account render engine specific output nodes,
- * it should give priority to e.g. the Eevee material output node for Eevee.
*/
-static bNode *ntree_shader_output_node(bNodeTree *ntree)
+bNode *ntreeShaderOutputNode(bNodeTree *ntree, int target)
{
/* Make sure we only have single node tagged as output. */
ntreeSetOutput(ntree);
- for (bNode *node = ntree->nodes.first; node != NULL; node = node->next) {
- if (node->flag & NODE_DO_OUTPUT) {
- return node;
+
+ /* Find output node that matches type and target. If there are
+ * multiple, we prefer exact target match and active nodes. */
+ bNode *output_node = NULL;
+
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (!ELEM(node->type, SH_NODE_OUTPUT_MATERIAL,
+ SH_NODE_OUTPUT_WORLD,
+ SH_NODE_OUTPUT_LIGHT))
+ {
+ continue;
+ }
+
+ if (node->custom1 == SHD_OUTPUT_ALL) {
+ if (output_node == NULL) {
+ output_node = node;
+ }
+ else if (output_node->custom1 == SHD_OUTPUT_ALL) {
+ if ((node->flag & NODE_DO_OUTPUT) &&
+ !(output_node->flag & NODE_DO_OUTPUT))
+ {
+ output_node = node;
+ }
+ }
+ }
+ else if (node->custom1 == target) {
+ if (output_node == NULL) {
+ output_node = node;
+ }
+ else if (output_node->custom1 == SHD_OUTPUT_ALL) {
+ output_node = node;
+ }
+ else if ((node->flag & NODE_DO_OUTPUT) &&
+ !(output_node->flag & NODE_DO_OUTPUT))
+ {
+ output_node = node;
+ }
}
}
- return NULL;
+
+ return output_node;
}
/* Find socket with a specified identifier. */
@@ -258,11 +290,11 @@ static bNodeSocket *ntree_shader_node_find_output(bNode *node,
* also returned.
*/
static bool ntree_shader_has_displacement(bNodeTree *ntree,
+ bNode *output_node,
bNode **r_node,
bNodeSocket **r_socket,
bNodeLink **r_link)
{
- bNode *output_node = ntree_shader_output_node(ntree);
if (output_node == NULL) {
/* We can't have displacement without output node, apparently. */
return false;
@@ -426,17 +458,13 @@ static void ntree_shader_link_builtin_normal(bNodeTree *ntree,
/* Re-link displacement output to unconnected normal sockets via bump node.
* This way material with have proper displacement in the viewport.
*/
-static void ntree_shader_relink_displacement(bNodeTree *ntree,
- short compatibility)
+static void ntree_shader_relink_displacement(bNodeTree *ntree, bNode *output_node)
{
- if ((compatibility & NODE_NEW_SHADING) == 0) {
- /* We can only deal with new shading system here. */
- return;
- }
bNode *displacement_node;
bNodeSocket *displacement_socket;
bNodeLink *displacement_link;
if (!ntree_shader_has_displacement(ntree,
+ output_node,
&displacement_node,
&displacement_socket,
&displacement_link))
@@ -514,14 +542,8 @@ static bool ntree_tag_ssr_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *
/* EEVEE: Scan the ntree to set the Screen Space Reflection
* layer id of every specular node.
*/
-static void ntree_shader_tag_ssr_node(bNodeTree *ntree, short compatibility)
+static void ntree_shader_tag_ssr_node(bNodeTree *ntree, bNode *output_node)
{
- if ((compatibility & NODE_NEWER_SHADING) == 0) {
- /* We can only deal with new shading system here. */
- return;
- }
-
- bNode *output_node = ntree_shader_output_node(ntree);
if (output_node == NULL) {
return;
}
@@ -549,14 +571,8 @@ static bool ntree_tag_sss_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *
/* EEVEE: Scan the ntree to set the Subsurface Scattering id of every SSS node.
*/
-static void ntree_shader_tag_sss_node(bNodeTree *ntree, short compatibility)
+static void ntree_shader_tag_sss_node(bNodeTree *ntree, bNode *output_node)
{
- if ((compatibility & NODE_NEWER_SHADING) == 0) {
- /* We can only deal with new shading system here. */
- return;
- }
-
- bNode *output_node = ntree_shader_output_node(ntree);
if (output_node == NULL) {
return;
}
@@ -567,15 +583,26 @@ static void ntree_shader_tag_sss_node(bNodeTree *ntree, short compatibility)
nodeChainIter(ntree, output_node, ntree_tag_sss_bsdf_cb, &sss_id, true);
}
-/* EEVEE: Find which material domain are used (volume, surface ...).
- */
-void ntreeGPUMaterialDomain(bNodeTree *ntree, bool *has_surface_output, bool *has_volume_output)
+void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, bool *has_surface_output, bool *has_volume_output)
{
/* localize tree to create links for reroute and mute */
bNodeTree *localtree = ntreeLocalize(ntree);
+ bNode *output = ntreeShaderOutputNode(localtree, SHD_OUTPUT_EEVEE);
+ bNodeTreeExec *exec;
- struct bNode *output = ntree_shader_output_node(localtree);
+ /* Perform all needed modifications on the tree in order to support
+ * displacement/bump mapping.
+ */
+ ntree_shader_relink_displacement(localtree, output);
+ ntree_shader_tag_ssr_node(localtree, output);
+ ntree_shader_tag_sss_node(localtree, output);
+
+ exec = ntreeShaderBeginExecTree(localtree);
+ ntreeExecGPUNodes(exec, mat, 1);
+ ntreeShaderEndExecTree(exec);
+
+ /* EEVEE: Find which material domain was used (volume, surface ...). */
*has_surface_output = false;
*has_volume_output = false;
@@ -596,28 +623,6 @@ void ntreeGPUMaterialDomain(bNodeTree *ntree, bool *has_surface_output, bool *ha
MEM_freeN(localtree);
}
-void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, short compatibility)
-{
- /* localize tree to create links for reroute and mute */
- bNodeTree *localtree = ntreeLocalize(ntree);
- bNodeTreeExec *exec;
-
- /* Perform all needed modifications on the tree in order to support
- * displacement/bump mapping.
- */
- ntree_shader_relink_displacement(localtree, compatibility);
-
- ntree_shader_tag_ssr_node(localtree, compatibility);
- ntree_shader_tag_sss_node(localtree, compatibility);
-
- exec = ntreeShaderBeginExecTree(localtree);
- ntreeExecGPUNodes(exec, mat, 1, compatibility);
- ntreeShaderEndExecTree(exec);
-
- ntreeFreeTree(localtree);
- MEM_freeN(localtree);
-}
-
bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key)
{
bNodeTreeExec *exec;
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 5cc7d14bc8b..9190f0d53cd 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -207,7 +207,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
return inactivenode;
}
-void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, short compatibility)
+void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
{
bNodeExec *nodeexec;
bNode *node;
@@ -226,9 +226,8 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, sh
do_it = false;
/* for groups, only execute outputs for edited group */
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
- if (node->typeinfo->compatibility & compatibility)
- if (do_outputs && (node->flag & NODE_DO_OUTPUT))
- do_it = true;
+ if (do_outputs && (node->flag & NODE_DO_OUTPUT))
+ do_it = true;
}
else {
do_it = true;
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index 4fb18b1a9d8..7fce5ed9927 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -98,6 +98,6 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeSta
void node_data_from_gpu_stack(struct bNodeStack *ns, struct GPUNodeStack *gs);
void node_shader_gpu_tex_mapping(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out);
-void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs, short compatibility);
+void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs);
#endif
diff --git a/source/blender/nodes/shader/nodes/node_shader_add_shader.c b/source/blender/nodes/shader/nodes/node_shader_add_shader.c
index d3bb8fccf71..0661ab59434 100644
--- a/source/blender/nodes/shader/nodes/node_shader_add_shader.c
+++ b/source/blender/nodes/shader/nodes/node_shader_add_shader.c
@@ -51,7 +51,6 @@ void register_node_type_sh_add_shader(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_ADD_SHADER, "Add Shader", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_add_shader_in, sh_node_add_shader_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
index 4c770984717..76ef257f8a3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
+++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
@@ -62,7 +62,6 @@ void register_node_type_sh_ambient_occlusion(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_AMBIENT_OCCLUSION, "Ambient Occlusion", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_ambient_occlusion_in, sh_node_ambient_occlusion_out);
node_type_init(&ntype, node_shader_init_ambient_occlusion);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 05091a2709a..aca72ac27cc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -76,7 +76,6 @@ void register_node_type_sh_attribute(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_ATTRIBUTE, "Attribute", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_attribute_out);
node_type_init(&ntype, node_shader_init_attribute);
node_type_storage(&ntype, "NodeShaderAttribute", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/shader/nodes/node_shader_background.c b/source/blender/nodes/shader/nodes/node_shader_background.c
index 4ea675f9e0c..38b5883bc1e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_background.c
+++ b/source/blender/nodes/shader/nodes/node_shader_background.c
@@ -51,7 +51,6 @@ void register_node_type_sh_background(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BACKGROUND, "Background", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_background_in, sh_node_background_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bevel.c b/source/blender/nodes/shader/nodes/node_shader_bevel.c
index dd9bc91e2d1..05161bd453a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bevel.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bevel.c
@@ -60,7 +60,6 @@ void register_node_type_sh_bevel(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BEVEL, "Bevel", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bevel_in, sh_node_bevel_out);
node_type_init(&ntype, node_shader_init_bevel);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.c b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
index 7bdce077977..76291df41bc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_blackbody.c
+++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
@@ -54,7 +54,6 @@ void register_node_type_sh_blackbody(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BLACKBODY, "Blackbody", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_socket_templates(&ntype, sh_node_blackbody_in, sh_node_blackbody_out);
node_type_init(&ntype, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c
index bb95ed2d32c..d17a5b9ba6e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_brightness.c
+++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c
@@ -52,7 +52,6 @@ void register_node_type_sh_brightcontrast(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
index ee3db99d2ab..c1423867d96 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
@@ -63,7 +63,6 @@ void register_node_type_sh_bsdf_anisotropic(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_ANISOTROPIC, "Anisotropic BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_anisotropic_in, sh_node_bsdf_anisotropic_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_anisotropic);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
index be7012712cc..58a37b0e81d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
@@ -55,7 +55,6 @@ void register_node_type_sh_bsdf_diffuse(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_DIFFUSE, "Diffuse BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_diffuse_in, sh_node_bsdf_diffuse_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
index 3d3173f6862..7b060bc68aa 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
@@ -61,7 +61,6 @@ void register_node_type_sh_bsdf_glass(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_GLASS, "Glass BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_glass_in, sh_node_bsdf_glass_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_glass);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
index eb5bd7b57d8..c3fb43c0ce8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
@@ -60,7 +60,6 @@ void register_node_type_sh_bsdf_glossy(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_GLOSSY, "Glossy BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_glossy_in, sh_node_bsdf_glossy_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_glossy);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
index 9db0e3284b9..d97344ad6a7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
@@ -54,7 +54,6 @@ void register_node_type_sh_bsdf_hair(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_HAIR, "Hair BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_hair_in, sh_node_bsdf_hair_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
new file mode 100644
index 00000000000..83e4bf1731b
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
@@ -0,0 +1,132 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Stockner, L. E. Segovia
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+/* Color, melanin and absorption coefficient default to approximately same brownish hair. */
+static bNodeSocketTemplate sh_node_bsdf_hair_principled_in[] = {
+ { SOCK_RGBA, 1, N_("Color"), 0.017513f, 0.005763f, 0.002059f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Melanin"), 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_FLOAT, 1, N_("Melanin Redness"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_RGBA, 1, N_("Tint"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 1, N_("Absorption Coefficient"), 0.245531f, 0.52f, 1.365f, 0.0f, 0.0f, 1000.0f},
+ { SOCK_FLOAT, 1, N_("Roughness"), 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_FLOAT, 1, N_("Radial Roughness"), 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_FLOAT, 1, N_("Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_FLOAT, 1, N_("IOR"), 1.55f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+ { SOCK_FLOAT, 1, N_("Offset"), 2.0f * ((float)M_PI) / 180.f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE},
+ { SOCK_FLOAT, 1, N_("Random Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_FLOAT, 1, N_("Random Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_FLOAT, 1, N_("Random"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+ { -1, 0, "" },
+};
+
+static bNodeSocketTemplate sh_node_bsdf_hair_principled_out[] = {
+ { SOCK_SHADER, 0, N_("BSDF")},
+ { -1, 0, "" }
+};
+
+/* Initialize the custom Parametrization property to Color. */
+static void node_shader_init_hair_principled(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ node->custom1 = SHD_PRINCIPLED_HAIR_REFLECTANCE;
+}
+
+/* Triggers (in)visibility of some sockets when changing Parametrization. */
+static void node_shader_update_hair_principled(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ bNodeSocket *sock;
+ int parametrization = node->custom1;
+
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->name, "Color")) {
+ if (parametrization == SHD_PRINCIPLED_HAIR_REFLECTANCE) {
+ sock->flag &= ~SOCK_UNAVAIL;
+ }
+ else {
+ sock->flag |= SOCK_UNAVAIL;
+ }
+ }
+ else if (STREQ(sock->name, "Melanin")) {
+ if (parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION) {
+ sock->flag &= ~SOCK_UNAVAIL;
+ }
+ else {
+ sock->flag |= SOCK_UNAVAIL;
+ }
+ }
+ else if (STREQ(sock->name, "Melanin Redness")) {
+ if (parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION) {
+ sock->flag &= ~SOCK_UNAVAIL;
+ }
+ else {
+ sock->flag |= SOCK_UNAVAIL;
+ }
+ }
+ else if (STREQ(sock->name, "Tint")) {
+ if (parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION) {
+ sock->flag &= ~SOCK_UNAVAIL;
+ }
+ else {
+ sock->flag |= SOCK_UNAVAIL;
+ }
+ }
+ else if (STREQ(sock->name, "Absorption Coefficient")) {
+ if (parametrization == SHD_PRINCIPLED_HAIR_DIRECT_ABSORPTION) {
+ sock->flag &= ~SOCK_UNAVAIL;
+ }
+ else {
+ sock->flag |= SOCK_UNAVAIL;
+ }
+ }
+ else if (STREQ(sock->name, "Random Color")) {
+ if (parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION) {
+ sock->flag &= ~SOCK_UNAVAIL;
+ }
+ else {
+ sock->flag |= SOCK_UNAVAIL;
+ }
+ }
+ }
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_hair_principled(void)
+{
+ static bNodeType ntype;
+
+ sh_node_type_base(&ntype, SH_NODE_BSDF_HAIR_PRINCIPLED, "Principled Hair BSDF", NODE_CLASS_SHADER, 0);
+ node_type_socket_templates(&ntype, sh_node_bsdf_hair_principled_in, sh_node_bsdf_hair_principled_out);
+ node_type_size_preset(&ntype, NODE_SIZE_LARGE);
+ node_type_init(&ntype, node_shader_init_hair_principled);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_update(&ntype, node_shader_update_hair_principled, NULL);
+
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index b4a83c847be..7f02295d45f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
@@ -143,7 +143,6 @@ void register_node_type_sh_bsdf_principled(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_PRINCIPLED, "Principled BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_principled_in, sh_node_bsdf_principled_out);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_init(&ntype, node_shader_init_principled);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
index 949f6a90de5..41dd3f8af3c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
@@ -61,7 +61,6 @@ void register_node_type_sh_bsdf_refraction(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_REFRACTION, "Refraction BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_refraction_in, sh_node_bsdf_refraction_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_refraction);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
index 0470795930b..0754a7e5a3b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
@@ -58,7 +58,6 @@ void register_node_type_sh_bsdf_toon(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_TOON, "Toon BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_toon_in, sh_node_bsdf_toon_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
index 7757ae38efd..2c0949f275c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
@@ -54,7 +54,6 @@ void register_node_type_sh_bsdf_translucent(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSLUCENT, "Translucent BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_translucent_in, sh_node_bsdf_translucent_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
index 441a7c50305..08ddf221804 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
@@ -50,7 +50,6 @@ void register_node_type_sh_bsdf_transparent(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSPARENT, "Transparent BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_transparent_in, sh_node_bsdf_transparent_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
index fec106a131a..ce331f03d4e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
@@ -55,7 +55,6 @@ void register_node_type_sh_bsdf_velvet(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BSDF_VELVET, "Velvet BSDF", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_velvet_in, sh_node_bsdf_velvet_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.c b/source/blender/nodes/shader/nodes/node_shader_bump.c
index 6274d132bc7..08b50a886c5 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bump.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bump.c
@@ -68,7 +68,6 @@ void register_node_type_sh_bump(void)
static bNodeType ntype;
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, "", NULL, NULL);
node_type_gpu(&ntype, gpu_shader_bump);
diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c
index dfd712afb29..9089d415759 100644
--- a/source/blender/nodes/shader/nodes/node_shader_camera.c
+++ b/source/blender/nodes/shader/nodes/node_shader_camera.c
@@ -54,7 +54,6 @@ void register_node_type_sh_camera(void)
static bNodeType ntype;
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, "", NULL, NULL);
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 24de03dbda4..23b27fc5008 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -215,11 +215,7 @@ static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execd
return 0;
group_gpu_copy_inputs(node, in, exec->stack);
-#if 0 /* XXX NODE_GROUP_EDIT is deprecated, depends on node space */
- ntreeExecGPUNodes(exec, mat, (node->flag & NODE_GROUP_EDIT));
-#else
- ntreeExecGPUNodes(exec, mat, 0, NODE_NEW_SHADING | NODE_OLD_SHADING);
-#endif
+ ntreeExecGPUNodes(exec, mat, 0);
group_gpu_move_outputs(node, out, exec->stack);
return 1;
@@ -242,7 +238,6 @@ void register_node_type_sh_group(void)
BLI_assert(ntype.ext.srna != NULL);
RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c
index 4f3dc92ad02..d5932ff233a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_curves.c
+++ b/source/blender/nodes/shader/nodes/node_shader_curves.c
@@ -74,7 +74,6 @@ void register_node_type_sh_curve_vec(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_curve_vec_in, sh_node_curve_vec_out);
node_type_init(&ntype, node_shader_init_curve_vec);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
@@ -133,7 +132,6 @@ void register_node_type_sh_curve_rgb(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_curve_rgb_in, sh_node_curve_rgb_out);
node_type_init(&ntype, node_shader_init_curve_rgb);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.c b/source/blender/nodes/shader/nodes/node_shader_displacement.c
index c26968e8d14..4480cbdf56b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_displacement.c
+++ b/source/blender/nodes/shader/nodes/node_shader_displacement.c
@@ -74,7 +74,6 @@ void register_node_type_sh_displacement(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_DISPLACEMENT, "Displacement", NODE_CLASS_OP_VECTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_displacement_in, sh_node_displacement_out);
node_type_storage(&ntype, "", NULL, NULL);
node_type_init(&ntype, node_shader_init_displacement);
diff --git a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c
index cd912a4b4cb..e05b0be1e62 100644
--- a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c
+++ b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c
@@ -77,7 +77,6 @@ void register_node_type_sh_eevee_specular(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_EEVEE_SPECULAR, "Specular", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_eevee_specular_in, sh_node_eevee_specular_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.c b/source/blender/nodes/shader/nodes/node_shader_emission.c
index f2ab4a119da..7a7c89be3a0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_emission.c
+++ b/source/blender/nodes/shader/nodes/node_shader_emission.c
@@ -51,7 +51,6 @@ void register_node_type_sh_emission(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_EMISSION, "Emission", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_emission_in, sh_node_emission_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
index 072abed6c16..cb6b35ac4a7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c
+++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
@@ -61,7 +61,6 @@ void register_node_type_sh_fresnel(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_FRESNEL, "Fresnel", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING);
node_type_socket_templates(&ntype, sh_node_fresnel_in, sh_node_fresnel_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c
index e536d198ed0..4a946e92778 100644
--- a/source/blender/nodes/shader/nodes/node_shader_gamma.c
+++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c
@@ -62,7 +62,6 @@ void register_node_type_sh_gamma(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_gamma_in, sh_node_gamma_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c
index 2af3e3e259a..dfeebcea305 100644
--- a/source/blender/nodes/shader/nodes/node_shader_geometry.c
+++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c
@@ -55,7 +55,6 @@ void register_node_type_sh_geometry(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_NEW_GEOMETRY, "Geometry", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_geometry_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.c b/source/blender/nodes/shader/nodes/node_shader_hair_info.c
index 13259dce9d1..8b2f4b479ad 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hair_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.c
@@ -48,7 +48,6 @@ void register_node_type_sh_hair_info(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_HAIR_INFO, "Hair Info", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, outputs);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.c b/source/blender/nodes/shader/nodes/node_shader_holdout.c
index 42563f2bfa8..6109022fddf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_holdout.c
+++ b/source/blender/nodes/shader/nodes/node_shader_holdout.c
@@ -45,7 +45,6 @@ void register_node_type_sh_holdout(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_HOLDOUT, "Holdout", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_holdout_in, sh_node_holdout_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
index 07f1e9e3233..c017765c8e2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
@@ -92,7 +92,6 @@ void register_node_type_sh_hue_sat(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_hue_sat_in, sh_node_hue_sat_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_hue_sat);
diff --git a/source/blender/nodes/shader/nodes/node_shader_ies_light.c b/source/blender/nodes/shader/nodes/node_shader_ies_light.c
index 8084f445e34..2714d560862 100644
--- a/source/blender/nodes/shader/nodes/node_shader_ies_light.c
+++ b/source/blender/nodes/shader/nodes/node_shader_ies_light.c
@@ -52,7 +52,6 @@ void register_node_type_sh_tex_ies(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_IES, "IES Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_ies_in, sh_node_tex_ies_out);
node_type_init(&ntype, node_shader_init_tex_ies);
node_type_storage(&ntype, "NodeShaderTexIES", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c
index b1805946f65..448d305b44e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_invert.c
+++ b/source/blender/nodes/shader/nodes/node_shader_invert.c
@@ -75,7 +75,6 @@ void register_node_type_sh_invert(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_invert_in, sh_node_invert_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_invert);
node_type_gpu(&ntype, gpu_shader_invert);
diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
index 53bfad833eb..9c0b0a2f5f6 100644
--- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
+++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
@@ -63,7 +63,6 @@ void register_node_type_sh_layer_weight(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_LAYER_WEIGHT, "Layer Weight", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING);
node_type_socket_templates(&ntype, sh_node_layer_weight_in, sh_node_layer_weight_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
index 1dd7a945259..f32570eaeaa 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
@@ -55,7 +55,6 @@ void register_node_type_sh_light_falloff(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_light_falloff_in, sh_node_light_falloff_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, NULL);
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 0e87da2215b..23d01ad4417 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_path.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_path.c
@@ -57,7 +57,6 @@ void register_node_type_sh_light_path(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_LIGHT_PATH, "Light Path", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_light_path_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c
index fdbf23618ef..a84e88e9551 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mapping.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c
@@ -107,7 +107,6 @@ void register_node_type_sh_mapping(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out);
node_type_size(&ntype, 320, 160, 360);
node_type_init(&ntype, node_shader_init_mapping);
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index bf594325119..1b702a722ba 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -226,6 +226,46 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode
r = atan2(a, b);
break;
}
+ case NODE_MATH_FLOOR:
+ {
+ if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ r = floorf(a);
+ else
+ r = floorf(b);
+ break;
+ }
+ case NODE_MATH_CEIL:
+ {
+ if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ r = ceilf(a);
+ else
+ r = ceilf(b);
+ break;
+ }
+ case NODE_MATH_FRACT:
+ {
+ if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ r = a - floorf(a);
+ else
+ r = b - floorf(b);
+ break;
+ }
+ case NODE_MATH_SQRT:
+ {
+ if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
+ if (a > 0)
+ r = sqrt(a);
+ else
+ r = 0.0;
+ }
+ else {
+ if (b > 0)
+ r = sqrt(b);
+ else
+ r = 0.0;
+ }
+ break;
+ }
}
if (node->custom2 & SHD_MATH_CLAMP) {
CLAMP(r, 0.0f, 1.0f);
@@ -240,7 +280,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
"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_abs",
- "math_atan2"
+ "math_atan2", "math_floor", "math_ceil", "math_fract", "math_sqrt"
};
switch (node->custom1) {
@@ -266,6 +306,10 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
case NODE_MATH_ATAN:
case NODE_MATH_ROUND:
case NODE_MATH_ABS:
+ case NODE_MATH_FLOOR:
+ case NODE_MATH_FRACT:
+ case NODE_MATH_CEIL:
+ case NODE_MATH_SQRT:
if (in[0].hasinput || !in[1].hasinput) {
/* use only first item and terminator */
GPUNodeStack tmp_in[2];
@@ -299,7 +343,6 @@ void register_node_type_sh_math(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0);
- 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, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
index 054b02b220d..b598859ab8e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
@@ -87,7 +87,6 @@ void register_node_type_sh_mix_rgb(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_mix_rgb_in, sh_node_mix_rgb_out);
node_type_label(&ntype, node_blend_label);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_mix_rgb);
diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
index 892b41ab058..1d6c76766b3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
@@ -52,7 +52,6 @@ void register_node_type_sh_mix_shader(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_MIX_SHADER, "Mix Shader", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_mix_shader_in, sh_node_mix_shader_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c
index 265f6ac6fab..121cb9cc1a5 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal.c
@@ -69,7 +69,6 @@ void register_node_type_sh_normal(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_normal);
node_type_gpu(&ntype, gpu_shader_normal);
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
index 0d58be76030..3c0fb145987 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -111,7 +111,6 @@ void register_node_type_sh_normal_map(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING);
node_type_socket_templates(&ntype, sh_node_normal_map_in, sh_node_normal_map_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_normal_map);
diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.c b/source/blender/nodes/shader/nodes/node_shader_object_info.c
index 623df319690..713e2f749f7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_object_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_object_info.c
@@ -52,7 +52,6 @@ void register_node_type_sh_object_info(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_OBJECT_INFO, "Object Info", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_object_info_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
index b08a4b4ff57..f44f5d332cf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
@@ -39,8 +39,7 @@ void register_node_type_sh_output_lamp(void)
{
static bNodeType ntype;
- sh_node_type_base(&ntype, SH_NODE_OUTPUT_LAMP, "Lamp Output", NODE_CLASS_OUTPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ sh_node_type_base(&ntype, SH_NODE_OUTPUT_LIGHT, "Light Output", NODE_CLASS_OUTPUT, 0);
node_type_socket_templates(&ntype, sh_node_output_lamp_in, NULL);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c
index 2eb68f23912..b56d6eca44b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c
@@ -43,7 +43,6 @@ void register_node_type_sh_output_linestyle(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_OUTPUT_LINESTYLE, "Line Style Output", NODE_CLASS_OUTPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_output_linestyle_in, NULL);
node_type_init(&ntype, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
index 05837e79f82..81a89177351 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c
@@ -55,7 +55,6 @@ void register_node_type_sh_output_material(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_OUTPUT_MATERIAL, "Material Output", NODE_CLASS_OUTPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_output_material_in, NULL);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c
index 2c115bdda20..1980e6be5a3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_world.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c
@@ -51,7 +51,6 @@ void register_node_type_sh_output_world(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_OUTPUT_WORLD, "World Output", NODE_CLASS_OUTPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_output_world_in, NULL);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
index 73c95fa2ba7..34c4d364fac 100644
--- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
@@ -62,7 +62,6 @@ void register_node_type_sh_particle_info(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING);
node_type_socket_templates(&ntype, NULL, outputs);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_particle_info);
node_type_gpu(&ntype, gpu_shader_particle_info);
diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c
index dce7e5354e1..0ddad803270 100644
--- a/source/blender/nodes/shader/nodes/node_shader_rgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c
@@ -49,7 +49,6 @@ void register_node_type_sh_rgb(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_RGB, "RGB", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_rgb_out);
node_type_gpu(&ntype, gpu_shader_rgb);
diff --git a/source/blender/nodes/shader/nodes/node_shader_script.c b/source/blender/nodes/shader/nodes/node_shader_script.c
index 888e502a7f6..2d13fc214be 100644
--- a/source/blender/nodes/shader/nodes/node_shader_script.c
+++ b/source/blender/nodes/shader/nodes/node_shader_script.c
@@ -68,7 +68,6 @@ void register_node_type_sh_script(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SCRIPT, "Script", NODE_CLASS_SCRIPT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_init(&ntype, init);
node_type_storage(&ntype, "NodeShaderScript", node_free_script, node_copy_script);
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
index 148f8e99c8f..09cd997f86b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
@@ -63,7 +63,6 @@ void register_node_type_sh_sephsv(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_sephsv);
node_type_gpu(&ntype, gpu_shader_sephsv);
@@ -104,7 +103,6 @@ void register_node_type_sh_combhsv(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_combhsv);
node_type_gpu(&ntype, gpu_shader_combhsv);
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
index bd914399a28..b4810b95d4b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
@@ -64,7 +64,6 @@ void register_node_type_sh_seprgb(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_seprgb);
node_type_gpu(&ntype, gpu_shader_seprgb);
@@ -108,7 +107,6 @@ void register_node_type_sh_combrgb(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_combrgb);
node_type_gpu(&ntype, gpu_shader_combrgb);
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
index ba8bf565ca8..bff8e38b8c8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
@@ -54,7 +54,6 @@ void register_node_type_sh_sepxyz(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_sepxyz_in, sh_node_sepxyz_out);
node_type_gpu(&ntype, gpu_shader_sepxyz);
@@ -85,7 +84,6 @@ void register_node_type_sh_combxyz(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_combxyz_in, sh_node_combxyz_out);
node_type_gpu(&ntype, gpu_shader_combxyz);
diff --git a/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c b/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c
index c565c311efc..8617e3414b5 100644
--- a/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c
@@ -51,7 +51,6 @@ void register_node_type_sh_shadertorgb(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SHADERTORGB, "Shader to RGB", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_shadertorgb_in, sh_node_shadertorgb_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
index e46494efd34..51167db857b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c
+++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
@@ -66,7 +66,6 @@ void register_node_type_sh_squeeze(void)
static bNodeType ntype;
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, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_squeeze);
diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
index 60442a46da1..57fb9026595 100644
--- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
+++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
@@ -90,7 +90,6 @@ void register_node_type_sh_subsurface_scattering(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SUBSURFACE_SCATTERING, "Subsurface Scattering", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_subsurface_scattering_in, sh_node_subsurface_scattering_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_subsurface_scattering);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
index f2c59ec8fd8..da3a8e39ccb 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -69,7 +69,6 @@ void register_node_type_sh_tangent(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TANGENT, "Tangent", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_tangent_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_tangent);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
index 67fe6d08ffd..227df5e8e56 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
@@ -92,7 +92,6 @@ void register_node_type_sh_tex_brick(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_brick_in, sh_node_tex_brick_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_tex_brick);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
index 633cc9a1d0e..4e065ffde23 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
@@ -70,7 +70,6 @@ void register_node_type_sh_tex_checker(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_CHECKER, "Checker Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_checker_in, sh_node_tex_checker_out);
node_type_init(&ntype, node_shader_init_tex_checker);
node_type_storage(&ntype, "NodeTexChecker", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
index 360b28d768a..002fdc6d3ae 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
@@ -70,7 +70,6 @@ void register_node_type_sh_tex_coord(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_COORD, "Texture Coordinate", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_tex_coord_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index d441a674838..41860df5670 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -48,7 +48,6 @@ static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode *no
tex->projection = SHD_PROJ_EQUIRECTANGULAR;
tex->iuser.frames = 1;
tex->iuser.sfra = 1;
- tex->iuser.fie_ima = 2;
tex->iuser.ok = 1;
node->storage = tex;
@@ -97,12 +96,12 @@ void register_node_type_sh_tex_environment(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_ENVIRONMENT, "Environment Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_environment_in, sh_node_tex_environment_out);
node_type_init(&ntype, node_shader_init_tex_environment);
node_type_storage(&ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_environment);
node_type_label(&ntype, node_image_label);
+ node_type_size_preset(&ntype, NODE_SIZE_LARGE);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
index 0721a24688f..06f3773e6d8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
@@ -70,7 +70,6 @@ void register_node_type_sh_tex_gradient(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_GRADIENT, "Gradient Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_gradient_in, sh_node_tex_gradient_out);
node_type_init(&ntype, node_shader_init_tex_gradient);
node_type_storage(&ntype, "NodeTexGradient", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index 2c958c6478d..9782df2638f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -48,7 +48,6 @@ static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node)
tex->color_space = SHD_COLORSPACE_COLOR;
tex->iuser.frames = 1;
tex->iuser.sfra = 1;
- tex->iuser.fie_ima = 2;
tex->iuser.ok = 1;
node->storage = tex;
@@ -56,11 +55,28 @@ static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node)
static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
+ static const char *names[] = {
+ "node_tex_image_linear",
+ "node_tex_image_nearest",
+ "node_tex_image_cubic",
+ "node_tex_image_smart"
+ };
+ static const char *names_box[] = {
+ "tex_box_sample_linear",
+ "tex_box_sample_nearest",
+ "tex_box_sample_cubic",
+ "tex_box_sample_smart"
+ };
+
Image *ima = (Image *)node->id;
ImageUser *iuser = NULL;
NodeTexImage *tex = node->storage;
+ const char *gpu_node_name = (tex->projection == SHD_PROJ_BOX)
+ ? names_box[tex->interpolation]
+ : names[tex->interpolation];
+ bool do_color_correction = false;
- GPUNodeLink *norm;
+ GPUNodeLink *norm, *col1, *col2, *col3;
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
float blend = tex->projection_blend;
@@ -68,6 +84,15 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
if (!ima)
return GPU_stack_link(mat, node, "node_tex_image_empty", in, out);
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
+ if ((tex->color_space == SHD_COLORSPACE_COLOR) &&
+ ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
+ GPU_material_do_color_management(mat))
+ {
+ do_color_correction = true;
+ }
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+
if (!in[0].link)
in[0].link = GPU_attribute(CD_MTFACE, "");
@@ -75,7 +100,7 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
switch (tex->projection) {
case SHD_PROJ_FLAT:
- GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
+ GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
case SHD_PROJ_BOX:
GPU_link(mat, "direction_transform_m4v3", GPU_builtin(GPU_VIEW_NORMAL),
@@ -84,8 +109,20 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
GPU_link(mat, "direction_transform_m4v3", norm,
GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
&norm);
+ GPU_link(mat, gpu_node_name, in[0].link,
+ norm,
+ GPU_image(ima, iuser, isdata),
+ &col1,
+ &col2,
+ &col3);
+ if (do_color_correction) {
+ GPU_link(mat, "srgb_to_linearrgb", col1, &col1);
+ GPU_link(mat, "srgb_to_linearrgb", col2, &col2);
+ GPU_link(mat, "srgb_to_linearrgb", col3, &col3);
+ }
GPU_link(mat, "node_tex_image_box", in[0].link,
norm,
+ col1, col2, col3,
GPU_image(ima, iuser, isdata),
GPU_uniform(&blend),
&out[0].link,
@@ -94,23 +131,18 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
case SHD_PROJ_SPHERE:
GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
GPU_link(mat, "point_map_to_sphere", in[0].link, &in[0].link);
- GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
+ GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
case SHD_PROJ_TUBE:
GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
GPU_link(mat, "point_map_to_tube", in[0].link, &in[0].link);
- GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
+ GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
}
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
- if ((tex->color_space == SHD_COLORSPACE_COLOR) &&
- ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
- GPU_material_do_color_management(mat))
- {
+ if (do_color_correction && (tex->projection != SHD_PROJ_BOX)) {
GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
}
- BKE_image_release_ibuf(ima, ibuf, NULL);
return true;
}
@@ -121,12 +153,12 @@ void register_node_type_sh_tex_image(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_IMAGE, "Image Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_image_in, sh_node_tex_image_out);
node_type_init(&ntype, node_shader_init_tex_image);
node_type_storage(&ntype, "NodeTexImage", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_image);
node_type_label(&ntype, node_image_label);
+ node_type_size_preset(&ntype, NODE_SIZE_LARGE);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
index 14e6cbf337e..deb81b7b78f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
@@ -73,7 +73,6 @@ void register_node_type_sh_tex_magic(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_magic_in, sh_node_tex_magic_out);
node_type_init(&ntype, node_shader_init_tex_magic);
node_type_storage(&ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
index 48ab45895bc..03f401e7f01 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
@@ -77,7 +77,6 @@ void register_node_type_sh_tex_musgrave(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_musgrave_in, sh_node_tex_musgrave_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_tex_musgrave);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
index 2f6994c6533..e2879528a5f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
@@ -70,7 +70,6 @@ void register_node_type_sh_tex_noise(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out);
node_type_init(&ntype, node_shader_init_tex_noise);
node_type_storage(&ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c
index 436eeeefb4a..1c5f53132bd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c
@@ -85,7 +85,6 @@ void register_node_type_sh_tex_pointdensity(void)
"Point Density",
NODE_CLASS_TEXTURE,
0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype,
sh_node_tex_pointdensity_in,
sh_node_tex_pointdensity_out);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 8a17ee1e0d2..821d4b41d09 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -70,7 +70,6 @@ void register_node_type_sh_tex_sky(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_SKY, "Sky Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_sky_in, sh_node_tex_sky_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_tex_sky);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
index 7f30d244da6..18d0dee8b88 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
@@ -32,6 +32,7 @@
static bNodeSocketTemplate sh_node_tex_voronoi_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
+ { SOCK_FLOAT, 1, N_("Exponent"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 32.0f},
{ -1, 0, "" }
};
@@ -47,6 +48,8 @@ static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node)
BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT);
BKE_texture_colormapping_default(&tex->base.color_mapping);
tex->coloring = SHD_VORONOI_INTENSITY;
+ tex->distance = SHD_VORONOI_DISTANCE;
+ tex->feature = SHD_VORONOI_F1;
node->storage = tex;
}
@@ -66,17 +69,34 @@ static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *node, bNodeExecD
return GPU_stack_link(mat, node, "node_tex_voronoi", in, out, GPU_uniform(&coloring));
}
+static void node_shader_update_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage;
+ bNodeSocket *sock;
+
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->name, "Exponent")) {
+ if (tex->distance == SHD_VORONOI_MINKOWSKI) {
+ sock->flag &= ~SOCK_UNAVAIL;
+ }
+ else {
+ sock->flag |= SOCK_UNAVAIL;
+ }
+ }
+ }
+}
+
/* node type definition */
void register_node_type_sh_tex_voronoi(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_VORONOI, "Voronoi Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_voronoi_in, sh_node_tex_voronoi_out);
node_type_init(&ntype, node_shader_init_tex_voronoi);
node_type_storage(&ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_voronoi);
+ node_type_update(&ntype, node_shader_update_tex_voronoi, NULL);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
index a9071fdbdd4..2b06f66eb63 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
@@ -76,7 +76,6 @@ void register_node_type_sh_tex_wave(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_wave_in, sh_node_tex_wave_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_tex_wave);
diff --git a/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c b/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c
index 67342e1e836..023f5417e22 100644
--- a/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c
+++ b/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c
@@ -40,7 +40,6 @@ void register_node_type_sh_uvalongstroke(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_UVALONGSTROKE, "UV Along Stroke", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_uvalongstroke_out);
node_type_init(&ntype, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_uvmap.c b/source/blender/nodes/shader/nodes/node_shader_uvmap.c
index c47bb9022b6..9da1056b47f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_uvmap.c
+++ b/source/blender/nodes/shader/nodes/node_shader_uvmap.c
@@ -56,7 +56,6 @@ void register_node_type_sh_uvmap(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_UVMAP, "UV Map", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_uvmap_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_uvmap);
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
index a1879df3a18..b6581cb18cb 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
@@ -77,7 +77,6 @@ void register_node_type_sh_valtorgb(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_valtorgb_in, sh_node_valtorgb_out);
node_type_init(&ntype, node_shader_init_valtorgb);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
@@ -120,7 +119,6 @@ void register_node_type_sh_rgbtobw(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_rgbtobw_in, sh_node_rgbtobw_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_rgbtobw);
node_type_gpu(&ntype, gpu_shader_rgbtobw);
diff --git a/source/blender/nodes/shader/nodes/node_shader_value.c b/source/blender/nodes/shader/nodes/node_shader_value.c
index a1b8717cebc..a143b0118e7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_value.c
+++ b/source/blender/nodes/shader/nodes/node_shader_value.c
@@ -49,7 +49,6 @@ void register_node_type_sh_value(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_value_out);
node_type_gpu(&ntype, gpu_shader_value);
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
index ca5291e6041..8087e1cab41 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
@@ -141,7 +141,6 @@ void register_node_type_sh_vect_math(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VECT_MATH, "Vector Math", NODE_CLASS_CONVERTOR, 0);
- 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, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
index d0b16dd5886..63964e27d20 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
@@ -136,7 +136,6 @@ void register_node_type_sh_vect_transform(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VECT_TRANSFORM, "Vector Transform", NODE_CLASS_OP_VECTOR, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_init(&ntype, node_shader_init_vect_transform);
node_type_socket_templates(&ntype, sh_node_vect_transform_in, sh_node_vect_transform_out);
node_type_storage(&ntype, "NodeShaderVectTransform", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
index 79b41509fcc..2a40d98baf9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
@@ -73,7 +73,6 @@ void register_node_type_sh_vector_displacement(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VECTOR_DISPLACEMENT, "Vector Displacement", NODE_CLASS_OP_VECTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_vector_displacement_in, sh_node_vector_displacement_out);
node_type_storage(&ntype, "", NULL, NULL);
node_type_init(&ntype, node_shader_init_vector_displacement);
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c
index 518ab6587b2..d0ba43d1a15 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c
@@ -51,7 +51,6 @@ void register_node_type_sh_volume_absorption(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VOLUME_ABSORPTION, "Volume Absorption", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_volume_absorption_in, sh_node_volume_absorption_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
index 40d24df6845..a88a7ebb21a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
@@ -153,7 +153,6 @@ void register_node_type_sh_volume_principled(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VOLUME_PRINCIPLED, "Principled Volume", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_volume_principled_in, sh_node_volume_principled_out);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_init(&ntype, node_shader_init_volume_principled);
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
index 34ba179b4a3..0f97d08803a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
@@ -52,7 +52,6 @@ void register_node_type_sh_volume_scatter(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VOLUME_SCATTER, "Volume Scatter", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_volume_scatter_in, sh_node_volume_scatter_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_wavelength.c b/source/blender/nodes/shader/nodes/node_shader_wavelength.c
index f903e314edf..edc4333c000 100644
--- a/source/blender/nodes/shader/nodes/node_shader_wavelength.c
+++ b/source/blender/nodes/shader/nodes/node_shader_wavelength.c
@@ -44,7 +44,6 @@ void register_node_type_sh_wavelength(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_WAVELENGTH, "Wavelength", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_socket_templates(&ntype, sh_node_wavelength_in, sh_node_wavelength_out);
node_type_init(&ntype, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.c b/source/blender/nodes/shader/nodes/node_shader_wireframe.c
index 0b9f3ac347a..11d889def31 100644
--- a/source/blender/nodes/shader/nodes/node_shader_wireframe.c
+++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.c
@@ -44,7 +44,6 @@ void register_node_type_sh_wireframe(void)
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_WIREFRAME, "Wireframe", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_wireframe_in, sh_node_wireframe_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c
index 0d70eff15e3..4fccab27b24 100644
--- a/source/blender/nodes/texture/nodes/node_texture_image.c
+++ b/source/blender/nodes/texture/nodes/node_texture_image.c
@@ -93,7 +93,6 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node)
ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user");
node->storage = iuser;
iuser->sfra = 1;
- iuser->fie_ima = 2;
iuser->ok = 1;
iuser->flag |= IMA_ANIM_ALWAYS;
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index d8dc2a62625..f786a293080 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -195,6 +195,33 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
break;
}
+ case NODE_MATH_FLOOR:
+ {
+ *out = floorf(in0);
+ break;
+ }
+
+ case NODE_MATH_CEIL:
+ {
+ *out = ceilf(in0);
+ break;
+ }
+
+ case NODE_MATH_FRACT:
+ {
+ *out = in0 - floorf(in0);
+ break;
+ }
+
+ case NODE_MATH_SQRT:
+ {
+ if (in0 > 0.0f)
+ *out = sqrtf(in0);
+ else
+ *out = 0.0f;
+ break;
+ }
+
default:
{
BLI_assert(0);
diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt
index 8d26fee0abd..030576fefd1 100644
--- a/source/blender/python/CMakeLists.txt
+++ b/source/blender/python/CMakeLists.txt
@@ -17,7 +17,7 @@
# ***** END GPL LICENSE BLOCK *****
add_subdirectory(intern)
-add_subdirectory(gawain)
add_subdirectory(generic)
+add_subdirectory(gpu)
add_subdirectory(mathutils)
add_subdirectory(bmesh)
diff --git a/source/blender/python/gawain/CMakeLists.txt b/source/blender/python/gpu/CMakeLists.txt
index 9eab323a0fe..141a36bbcc2 100644
--- a/source/blender/python/gawain/CMakeLists.txt
+++ b/source/blender/python/gpu/CMakeLists.txt
@@ -24,7 +24,6 @@ set(INC
../../blenlib
../../gpu
../../makesdna
- ../../../../intern/gawain
../../../../intern/guardedalloc
../../../../intern/glew-mx
)
@@ -35,13 +34,13 @@ set(INC_SYS
)
set(SRC
- gwn_py_api.c
- gwn_py_types.c
+ gpu_py_api.c
+ gpu_py_types.c
- gwn_py_api.h
- gwn_py_types.h
+ gpu_py_api.h
+ gpu_py_types.h
)
add_definitions(${GL_DEFINITIONS})
-blender_add_lib(bf_python_gawain "${SRC}" "${INC}" "${INC_SYS}")
+blender_add_lib(bf_python_gpu "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/python/gawain/gwn_py_api.c b/source/blender/python/gpu/gpu_py_api.c
index d79ef070649..53285b372d8 100644
--- a/source/blender/python/gawain/gwn_py_api.c
+++ b/source/blender/python/gpu/gpu_py_api.c
@@ -18,44 +18,44 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/python/gawain/gwn_py_api.c
- * \ingroup pygawain
+/** \file blender/python/gpu/gpu_py_api.c
+ * \ingroup pygpu
*
- * Experimental Python API, not considered public yet (called '_gawain'),
+ * Experimental Python API, not considered public yet (called '_gpu'),
* we may re-expose as public later.
*/
#include <Python.h>
-#include "gawain/gwn_batch.h"
-#include "gawain/gwn_vertex_format.h"
+#include "GPU_batch.h"
+#include "GPU_vertex_format.h"
-#include "gwn_py_api.h"
-#include "gwn_py_types.h"
+#include "gpu_py_api.h"
+#include "gpu_py_types.h"
#include "BLI_utildefines.h"
#include "../generic/python_utildefines.h"
-PyDoc_STRVAR(GWN_doc,
-"This module provides access to gawain drawing functions."
+PyDoc_STRVAR(GPU_doc,
+"This module provides access to gpu drawing functions."
);
-static struct PyModuleDef GWN_module_def = {
+static struct PyModuleDef GPU_module_def = {
PyModuleDef_HEAD_INIT,
- .m_name = "_gawain", /* m_name */
- .m_doc = GWN_doc, /* m_doc */
+ .m_name = "_gpu", /* m_name */
+ .m_doc = GPU_doc, /* m_doc */
};
-PyObject *BPyInit_gawain(void)
+PyObject *BPyInit_gpu(void)
{
PyObject *sys_modules = PyThreadState_GET()->interp->modules;
PyObject *submodule;
PyObject *mod;
- mod = PyModule_Create(&GWN_module_def);
+ mod = PyModule_Create(&GPU_module_def);
- /* _gawain.types */
- PyModule_AddObject(mod, "types", (submodule = BPyInit_gawain_types()));
+ /* _gpu.types */
+ PyModule_AddObject(mod, "types", (submodule = BPyInit_gpu_types()));
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
Py_INCREF(submodule);
diff --git a/source/blender/python/gawain/gwn_py_api.h b/source/blender/python/gpu/gpu_py_api.h
index 3ef85e8ae0f..387bfcab950 100644
--- a/source/blender/python/gawain/gwn_py_api.h
+++ b/source/blender/python/gpu/gpu_py_api.h
@@ -18,13 +18,13 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __GWN_PY_API_H__
-#define __GWN_PY_API_H__
+#ifndef __GPU_PY_API_H__
+#define __GPU_PY_API_H__
-/** \file blender/python/gawain/gwn_py_api.h
- * \ingroup pygawain
+/** \file blender/python/gpu/gpu_py_api.h
+ * \ingroup pygpu
*/
-PyObject *BPyInit_gawain(void);
+PyObject *BPyInit_gpu(void);
-#endif /* __GWN_PY_API_H__ */
+#endif /* __GPU_PY_API_H__ */
diff --git a/source/blender/python/gawain/gwn_py_types.c b/source/blender/python/gpu/gpu_py_types.c
index 9ddad009a12..4e564fdf849 100644
--- a/source/blender/python/gawain/gwn_py_types.c
+++ b/source/blender/python/gpu/gpu_py_types.c
@@ -18,28 +18,26 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/python/gawain/gwn_py_types.c
- * \ingroup pygawain
+/** \file blender/python/gpu/gpu_py_types.c
+ * \ingroup pygpu
*
- * - Use ``bpygwn_`` for local API.
- * - Use ``BPyGwn_`` for public API.
+ * - Use ``bpygpu_`` for local API.
+ * - Use ``BPyGPU`` for public API.
*/
#include <Python.h>
-#include "gawain/gwn_batch.h"
-#include "gawain/gwn_vertex_format.h"
+#include "GPU_batch.h"
+#include "GPU_vertex_format.h"
#include "BLI_math.h"
-#include "GPU_batch.h"
-
#include "MEM_guardedalloc.h"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
-#include "gwn_py_types.h" /* own include */
+#include "gpu_py_types.h" /* own include */
#ifdef __BIG_ENDIAN__
/* big endian */
@@ -60,7 +58,7 @@
* Use with PyArg_ParseTuple's "O&" formatting.
* \{ */
-static int bpygwn_ParseVertCompType(PyObject *o, void *p)
+static int bpygpu_ParseVertCompType(PyObject *o, void *p)
{
Py_ssize_t comp_type_id_len;
const char *comp_type_id = _PyUnicode_AsStringAndSize(o, &comp_type_id_len);
@@ -71,21 +69,21 @@ static int bpygwn_ParseVertCompType(PyObject *o, void *p)
return 0;
}
- Gwn_VertCompType comp_type;
+ GPUVertCompType comp_type;
if (comp_type_id_len == 2) {
switch (*((ushort *)comp_type_id)) {
- case MAKE_ID2('I', '8'): { comp_type = GWN_COMP_I8; goto success; }
- case MAKE_ID2('U', '8'): { comp_type = GWN_COMP_U8; goto success; }
+ case MAKE_ID2('I', '8'): { comp_type = GPU_COMP_I8; goto success; }
+ case MAKE_ID2('U', '8'): { comp_type = GPU_COMP_U8; goto success; }
}
}
else if (comp_type_id_len == 3) {
switch (*((uint *)comp_type_id)) {
- case MAKE_ID3('I', '1', '6'): { comp_type = GWN_COMP_I16; goto success; }
- case MAKE_ID3('U', '1', '6'): { comp_type = GWN_COMP_U16; goto success; }
- case MAKE_ID3('I', '3', '2'): { comp_type = GWN_COMP_I32; goto success; }
- case MAKE_ID3('U', '3', '2'): { comp_type = GWN_COMP_U32; goto success; }
- case MAKE_ID3('F', '3', '2'): { comp_type = GWN_COMP_F32; goto success; }
- case MAKE_ID3('I', '1', '0'): { comp_type = GWN_COMP_I10; goto success; }
+ case MAKE_ID3('I', '1', '6'): { comp_type = GPU_COMP_I16; goto success; }
+ case MAKE_ID3('U', '1', '6'): { comp_type = GPU_COMP_U16; goto success; }
+ case MAKE_ID3('I', '3', '2'): { comp_type = GPU_COMP_I32; goto success; }
+ case MAKE_ID3('U', '3', '2'): { comp_type = GPU_COMP_U32; goto success; }
+ case MAKE_ID3('F', '3', '2'): { comp_type = GPU_COMP_F32; goto success; }
+ case MAKE_ID3('I', '1', '0'): { comp_type = GPU_COMP_I10; goto success; }
}
}
@@ -95,11 +93,11 @@ static int bpygwn_ParseVertCompType(PyObject *o, void *p)
return 0;
success:
- *((Gwn_VertCompType *)p) = comp_type;
+ *((GPUVertCompType *)p) = comp_type;
return 1;
}
-static int bpygwn_ParseVertFetchMode(PyObject *o, void *p)
+static int bpygpu_ParseVertFetchMode(PyObject *o, void *p)
{
Py_ssize_t mode_id_len;
const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len);
@@ -112,12 +110,12 @@ static int bpygwn_ParseVertFetchMode(PyObject *o, void *p)
#define MATCH_ID(id) \
if (mode_id_len == strlen(STRINGIFY(id))) { \
if (STREQ(mode_id, STRINGIFY(id))) { \
- mode = GWN_FETCH_##id; \
+ mode = GPU_FETCH_##id; \
goto success; \
} \
} ((void)0)
- Gwn_VertFetchMode mode;
+ GPUVertFetchMode mode;
MATCH_ID(FLOAT);
MATCH_ID(INT);
MATCH_ID(INT_TO_FLOAT_UNIT);
@@ -129,11 +127,11 @@ static int bpygwn_ParseVertFetchMode(PyObject *o, void *p)
return 0;
success:
- (*(Gwn_VertFetchMode *)p) = mode;
+ (*(GPUVertFetchMode *)p) = mode;
return 1;
}
-static int bpygwn_ParsePrimType(PyObject *o, void *p)
+static int bpygpu_ParsePrimType(PyObject *o, void *p)
{
Py_ssize_t mode_id_len;
const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len);
@@ -146,12 +144,12 @@ static int bpygwn_ParsePrimType(PyObject *o, void *p)
#define MATCH_ID(id) \
if (mode_id_len == strlen(STRINGIFY(id))) { \
if (STREQ(mode_id, STRINGIFY(id))) { \
- mode = GWN_PRIM_##id; \
+ mode = GPU_PRIM_##id; \
goto success; \
} \
} ((void)0)
- Gwn_PrimType mode;
+ GPUPrimType mode;
MATCH_ID(POINTS);
MATCH_ID(LINES);
MATCH_ID(TRIS);
@@ -168,7 +166,7 @@ static int bpygwn_ParsePrimType(PyObject *o, void *p)
return 0;
success:
- (*(Gwn_PrimType *)p) = mode;
+ (*(GPUPrimType *)p) = mode;
return 1;
}
@@ -182,19 +180,19 @@ success:
#define PY_AS_NATIVE_SWITCH(attr) \
switch (attr->comp_type) { \
- case GWN_COMP_I8: { PY_AS_NATIVE(int8_t, PyC_Long_AsI8); break; } \
- case GWN_COMP_U8: { PY_AS_NATIVE(uint8_t, PyC_Long_AsU8); break; } \
- case GWN_COMP_I16: { PY_AS_NATIVE(int16_t, PyC_Long_AsI16); break; } \
- case GWN_COMP_U16: { PY_AS_NATIVE(uint16_t, PyC_Long_AsU16); break; } \
- case GWN_COMP_I32: { PY_AS_NATIVE(int32_t, PyC_Long_AsI32); break; } \
- case GWN_COMP_U32: { PY_AS_NATIVE(uint32_t, PyC_Long_AsU32); break; } \
- case GWN_COMP_F32: { PY_AS_NATIVE(float, PyFloat_AsDouble); break; } \
+ case GPU_COMP_I8: { PY_AS_NATIVE(int8_t, PyC_Long_AsI8); break; } \
+ case GPU_COMP_U8: { PY_AS_NATIVE(uint8_t, PyC_Long_AsU8); break; } \
+ case GPU_COMP_I16: { PY_AS_NATIVE(int16_t, PyC_Long_AsI16); break; } \
+ case GPU_COMP_U16: { PY_AS_NATIVE(uint16_t, PyC_Long_AsU16); break; } \
+ case GPU_COMP_I32: { PY_AS_NATIVE(int32_t, PyC_Long_AsI32); break; } \
+ case GPU_COMP_U32: { PY_AS_NATIVE(uint32_t, PyC_Long_AsU32); break; } \
+ case GPU_COMP_F32: { PY_AS_NATIVE(float, PyFloat_AsDouble); break; } \
default: \
BLI_assert(0); \
} ((void)0)
/* No error checking, callers must run PyErr_Occurred */
-static void fill_format_elem(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr)
+static void fill_format_elem(void *data_dst_void, PyObject *py_src, const GPUVertAttr *attr)
{
#define PY_AS_NATIVE(ty_dst, py_as_native) \
{ \
@@ -208,9 +206,9 @@ static void fill_format_elem(void *data_dst_void, PyObject *py_src, const Gwn_Ve
}
/* No error checking, callers must run PyErr_Occurred */
-static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr)
+static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const GPUVertAttr *attr)
{
- const uint len = attr->comp_ct;
+ const uint len = attr->comp_len;
/**
* Args are constants, so range checks will be optimized out if they're nop's.
@@ -230,15 +228,15 @@ static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const Gwn_V
#undef WARN_TYPE_LIMIT_PUSH
#undef WARN_TYPE_LIMIT_POP
-static bool bpygwn_vertbuf_fill_impl(
- Gwn_VertBuf *vbo,
+static bool bpygpu_vertbuf_fill_impl(
+ GPUVertBuf *vbo,
uint data_id, PyObject *seq)
{
bool ok = true;
- const Gwn_VertAttr *attr = &vbo->format.attribs[data_id];
+ const GPUVertAttr *attr = &vbo->format.attribs[data_id];
- Gwn_VertBufRaw data_step;
- GWN_vertbuf_attr_get_raw_data(vbo, data_id, &data_step);
+ GPUVertBufRaw data_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, data_id, &data_step);
PyObject *seq_fast = PySequence_Fast(seq, "Vertex buffer fill");
if (seq_fast == NULL) {
@@ -247,24 +245,24 @@ static bool bpygwn_vertbuf_fill_impl(
const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast);
- if (seq_len != vbo->vertex_ct) {
+ if (seq_len != vbo->vertex_len) {
PyErr_Format(PyExc_ValueError,
"Expected a sequence of size %d, got %d",
- vbo->vertex_ct, seq_len);
+ vbo->vertex_len, seq_len);
}
PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast);
- if (attr->comp_ct == 1) {
+ if (attr->comp_len == 1) {
for (uint i = 0; i < seq_len; i++) {
- uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step);
+ uchar *data = (uchar *)GPU_vertbuf_raw_step(&data_step);
PyObject *item = seq_items[i];
fill_format_elem(data, item, attr);
}
}
else {
for (uint i = 0; i < seq_len; i++) {
- uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step);
+ uchar *data = (uchar *)GPU_vertbuf_raw_step(&data_step);
PyObject *item = seq_items[i];
if (!PyTuple_CheckExact(item)) {
PyErr_Format(PyExc_ValueError,
@@ -273,10 +271,10 @@ static bool bpygwn_vertbuf_fill_impl(
ok = false;
goto finally;
}
- if (PyTuple_GET_SIZE(item) != attr->comp_ct) {
+ if (PyTuple_GET_SIZE(item) != attr->comp_len) {
PyErr_Format(PyExc_ValueError,
"expected a tuple of size %d, got %d",
- attr->comp_ct, PyTuple_GET_SIZE(item));
+ attr->comp_len, PyTuple_GET_SIZE(item));
ok = false;
goto finally;
}
@@ -298,10 +296,10 @@ finally:
/* handy, but not used just now */
#if 0
-static int bpygwn_find_id(const Gwn_VertFormat *fmt, const char *id)
+static int bpygpu_find_id(const GPUVertFormat *fmt, const char *id)
{
- for (int i = 0; i < fmt->attrib_ct; i++) {
- for (uint j = 0; j < fmt->name_ct; j++) {
+ for (int i = 0; i < fmt->attr_len; i++) {
+ for (uint j = 0; j < fmt->name_len; j++) {
if (STREQ(fmt->attribs[i].name[j], id)) {
return i;
}
@@ -319,7 +317,7 @@ static int bpygwn_find_id(const Gwn_VertFormat *fmt, const char *id)
/** \name VertFormat Type
* \{ */
-static PyObject *bpygwn_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *bpygpu_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{
if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) {
PyErr_SetString(PyExc_TypeError,
@@ -327,64 +325,64 @@ static PyObject *bpygwn_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *arg
return NULL;
}
- BPyGwn_VertFormat *ret = (BPyGwn_VertFormat *)BPyGwn_VertFormat_CreatePyObject(NULL);
+ BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(NULL);
return (PyObject *)ret;
}
-PyDoc_STRVAR(bpygwn_VertFormat_attr_add_doc,
+PyDoc_STRVAR(bpygpu_VertFormat_attr_add_doc,
"TODO"
);
-static PyObject *bpygwn_VertFormat_attr_add(BPyGwn_VertFormat *self, PyObject *args, PyObject *kwds)
+static PyObject *bpygpu_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"id", "comp_type", "len", "fetch_mode", NULL};
struct {
const char *id;
- Gwn_VertCompType comp_type;
+ GPUVertCompType comp_type;
uint len;
- Gwn_VertFetchMode fetch_mode;
+ GPUVertFetchMode fetch_mode;
} params;
- if (self->fmt.attrib_ct == GWN_VERT_ATTR_MAX_LEN) {
- PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GWN_VERT_ATTR_MAX_LEN));
+ if (self->fmt.attr_len == GPU_VERT_ATTR_MAX_LEN) {
+ PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GPU_VERT_ATTR_MAX_LEN));
return NULL;
}
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "$sO&IO&:attr_add", (char **)kwlist,
&params.id,
- bpygwn_ParseVertCompType, &params.comp_type,
+ bpygpu_ParseVertCompType, &params.comp_type,
&params.len,
- bpygwn_ParseVertFetchMode, &params.fetch_mode))
+ bpygpu_ParseVertFetchMode, &params.fetch_mode))
{
return NULL;
}
- uint attr_id = GWN_vertformat_attr_add(&self->fmt, params.id, params.comp_type, params.len, params.fetch_mode);
+ uint attr_id = GPU_vertformat_attr_add(&self->fmt, params.id, params.comp_type, params.len, params.fetch_mode);
return PyLong_FromLong(attr_id);
}
-static struct PyMethodDef bpygwn_VertFormat_methods[] = {
- {"attr_add", (PyCFunction)bpygwn_VertFormat_attr_add,
- METH_VARARGS | METH_KEYWORDS, bpygwn_VertFormat_attr_add_doc},
+static struct PyMethodDef bpygpu_VertFormat_methods[] = {
+ {"attr_add", (PyCFunction)bpygpu_VertFormat_attr_add,
+ METH_VARARGS | METH_KEYWORDS, bpygpu_VertFormat_attr_add_doc},
{NULL, NULL, 0, NULL}
};
-static void bpygwn_VertFormat_dealloc(BPyGwn_VertFormat *self)
+static void bpygpu_VertFormat_dealloc(BPyGPUVertFormat *self)
{
Py_TYPE(self)->tp_free(self);
}
-PyTypeObject BPyGwn_VertFormat_Type = {
+PyTypeObject BPyGPUVertFormat_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "Gwn_VertFormat",
- .tp_basicsize = sizeof(BPyGwn_VertFormat),
- .tp_dealloc = (destructor)bpygwn_VertFormat_dealloc,
+ .tp_name = "GPUVertFormat",
+ .tp_basicsize = sizeof(BPyGPUVertFormat),
+ .tp_dealloc = (destructor)bpygpu_VertFormat_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_methods = bpygwn_VertFormat_methods,
- .tp_new = bpygwn_VertFormat_new,
+ .tp_methods = bpygpu_VertFormat_methods,
+ .tp_new = bpygpu_VertFormat_new,
};
/** \} */
@@ -395,35 +393,35 @@ PyTypeObject BPyGwn_VertFormat_Type = {
/** \name VertBuf Type
* \{ */
-static PyObject *bpygwn_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *bpygpu_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{
const char * const keywords[] = {"len", "format", NULL};
struct {
- BPyGwn_VertFormat *py_fmt;
+ BPyGPUVertFormat *py_fmt;
uint len;
} params;
if (!PyArg_ParseTupleAndKeywords(
args, kwds,
- "$IO!:Gwn_VertBuf.__new__", (char **)keywords,
+ "$IO!:GPUVertBuf.__new__", (char **)keywords,
&params.len,
- &BPyGwn_VertFormat_Type, &params.py_fmt))
+ &BPyGPUVertFormat_Type, &params.py_fmt))
{
return NULL;
}
- struct Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&params.py_fmt->fmt);
+ struct GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&params.py_fmt->fmt);
- GWN_vertbuf_data_alloc(vbo, params.len);
+ GPU_vertbuf_data_alloc(vbo, params.len);
- return BPyGwn_VertBuf_CreatePyObject(vbo);
+ return BPyGPUVertBuf_CreatePyObject(vbo);
}
-PyDoc_STRVAR(bpygwn_VertBuf_fill_doc,
+PyDoc_STRVAR(bpygpu_VertBuf_fill_doc,
"TODO"
);
-static PyObject *bpygwn_VertBuf_fill(BPyGwn_VertBuf *self, PyObject *args, PyObject *kwds)
+static PyObject *bpygpu_VertBuf_fill(BPyGPUVertBuf *self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"id", "data", NULL};
@@ -440,7 +438,7 @@ static PyObject *bpygwn_VertBuf_fill(BPyGwn_VertBuf *self, PyObject *args, PyObj
return NULL;
}
- if (params.id >= self->buf->format.attrib_ct) {
+ if (params.id >= self->buf->format.attr_len) {
PyErr_Format(PyExc_ValueError,
"Format id %d out of range",
params.id);
@@ -453,32 +451,32 @@ static PyObject *bpygwn_VertBuf_fill(BPyGwn_VertBuf *self, PyObject *args, PyObj
return NULL;
}
- if (!bpygwn_vertbuf_fill_impl(self->buf, params.id, params.py_seq_data)) {
+ if (!bpygpu_vertbuf_fill_impl(self->buf, params.id, params.py_seq_data)) {
return NULL;
}
Py_RETURN_NONE;
}
-static struct PyMethodDef bpygwn_VertBuf_methods[] = {
- {"fill", (PyCFunction) bpygwn_VertBuf_fill,
- METH_VARARGS | METH_KEYWORDS, bpygwn_VertBuf_fill_doc},
+static struct PyMethodDef bpygpu_VertBuf_methods[] = {
+ {"fill", (PyCFunction) bpygpu_VertBuf_fill,
+ METH_VARARGS | METH_KEYWORDS, bpygpu_VertBuf_fill_doc},
{NULL, NULL, 0, NULL}
};
-static void bpygwn_VertBuf_dealloc(BPyGwn_VertBuf *self)
+static void bpygpu_VertBuf_dealloc(BPyGPUVertBuf *self)
{
- GWN_vertbuf_discard(self->buf);
+ GPU_vertbuf_discard(self->buf);
Py_TYPE(self)->tp_free(self);
}
-PyTypeObject BPyGwn_VertBuf_Type = {
+PyTypeObject BPyGPUVertBuf_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "Gwn_VertBuf",
- .tp_basicsize = sizeof(BPyGwn_VertBuf),
- .tp_dealloc = (destructor)bpygwn_VertBuf_dealloc,
+ .tp_name = "GPUVertBuf",
+ .tp_basicsize = sizeof(BPyGPUVertBuf),
+ .tp_dealloc = (destructor)bpygpu_VertBuf_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_methods = bpygwn_VertBuf_methods,
- .tp_new = bpygwn_VertBuf_new,
+ .tp_methods = bpygpu_VertBuf_methods,
+ .tp_new = bpygpu_VertBuf_new,
};
/** \} */
@@ -489,28 +487,28 @@ PyTypeObject BPyGwn_VertBuf_Type = {
/** \name VertBatch Type
* \{ */
-static PyObject *bpygwn_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *bpygpu_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{
const char * const keywords[] = {"type", "buf", NULL};
struct {
- Gwn_PrimType type_id;
- BPyGwn_VertBuf *py_buf;
+ GPUPrimType type_id;
+ BPyGPUVertBuf *py_buf;
} params;
if (!PyArg_ParseTupleAndKeywords(
args, kwds,
- "$O&O!:Gwn_Batch.__new__", (char **)keywords,
- bpygwn_ParsePrimType, &params.type_id,
- &BPyGwn_VertBuf_Type, &params.py_buf))
+ "$O&O!:GPUBatch.__new__", (char **)keywords,
+ bpygpu_ParsePrimType, &params.type_id,
+ &BPyGPUVertBuf_Type, &params.py_buf))
{
return NULL;
}
- Gwn_Batch *batch = GWN_batch_create(params.type_id, params.py_buf->buf, NULL);
- BPyGwn_Batch *ret = (BPyGwn_Batch *)BPyGwn_Batch_CreatePyObject(batch);
+ GPUBatch *batch = GPU_batch_create(params.type_id, params.py_buf->buf, NULL);
+ BPyGPUBatch *ret = (BPyGPUBatch *)BPyGPUBatch_CreatePyObject(batch);
-#ifdef USE_GWN_PY_REFERENCES
+#ifdef USE_GPU_PY_REFERENCES
ret->references = PyList_New(1);
PyList_SET_ITEM(ret->references, 0, (PyObject *)params.py_buf);
Py_INCREF(params.py_buf);
@@ -520,39 +518,39 @@ static PyObject *bpygwn_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, Py
return (PyObject *)ret;
}
-PyDoc_STRVAR(bpygwn_VertBatch_vertbuf_add_doc,
+PyDoc_STRVAR(bpygpu_VertBatch_vertbuf_add_doc,
"TODO"
);
-static PyObject *bpygwn_VertBatch_vertbuf_add(BPyGwn_Batch *self, BPyGwn_VertBuf *py_buf)
+static PyObject *bpygpu_VertBatch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
{
- if (!BPyGwn_VertBuf_Check(py_buf)) {
+ if (!BPyGPUVertBuf_Check(py_buf)) {
PyErr_Format(PyExc_TypeError,
- "Expected a Gwn_VertBuf, got %s",
+ "Expected a GPUVertBuf, got %s",
Py_TYPE(py_buf)->tp_name);
return NULL;
}
- if (self->batch->verts[0]->vertex_ct != py_buf->buf->vertex_ct) {
+ if (self->batch->verts[0]->vertex_len != py_buf->buf->vertex_len) {
PyErr_Format(PyExc_TypeError,
"Expected %d length, got %d",
- self->batch->verts[0]->vertex_ct, py_buf->buf->vertex_ct);
+ self->batch->verts[0]->vertex_len, py_buf->buf->vertex_len);
return NULL;
}
-#ifdef USE_GWN_PY_REFERENCES
+#ifdef USE_GPU_PY_REFERENCES
/* Hold user */
PyList_Append(self->references, (PyObject *)py_buf);
#endif
- GWN_batch_vertbuf_add(self->batch, py_buf->buf);
+ GPU_batch_vertbuf_add(self->batch, py_buf->buf);
Py_RETURN_NONE;
}
/* Currently magic number from Py perspective. */
-PyDoc_STRVAR(bpygwn_VertBatch_program_set_builtin_doc,
+PyDoc_STRVAR(bpygpu_VertBatch_program_set_builtin_doc,
"TODO"
);
-static PyObject *bpygwn_VertBatch_program_set_builtin(BPyGwn_Batch *self, PyObject *args, PyObject *kwds)
+static PyObject *bpygpu_VertBatch_program_set_builtin(BPyGPUBatch *self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"id", NULL};
@@ -590,11 +588,11 @@ static PyObject *bpygwn_VertBatch_program_set_builtin(BPyGwn_Batch *self, PyObje
return NULL;
success:
- GWN_batch_program_set_builtin(self->batch, shader);
+ GPU_batch_program_set_builtin(self->batch, shader);
Py_RETURN_NONE;
}
-static PyObject *bpygwn_VertBatch_uniform_bool(BPyGwn_Batch *self, PyObject *args)
+static PyObject *bpygpu_VertBatch_uniform_bool(BPyGPUBatch *self, PyObject *args)
{
struct {
const char *id;
@@ -609,11 +607,11 @@ static PyObject *bpygwn_VertBatch_uniform_bool(BPyGwn_Batch *self, PyObject *arg
return NULL;
}
- GWN_batch_uniform_1b(self->batch, params.id, params.values[0]);
+ GPU_batch_uniform_1b(self->batch, params.id, params.values[0]);
Py_RETURN_NONE;
}
-static PyObject *bpygwn_VertBatch_uniform_i32(BPyGwn_Batch *self, PyObject *args)
+static PyObject *bpygpu_VertBatch_uniform_i32(BPyGPUBatch *self, PyObject *args)
{
struct {
const char *id;
@@ -628,11 +626,11 @@ static PyObject *bpygwn_VertBatch_uniform_i32(BPyGwn_Batch *self, PyObject *args
return NULL;
}
- GWN_batch_uniform_1i(self->batch, params.id, params.values[0]);
+ GPU_batch_uniform_1i(self->batch, params.id, params.values[0]);
Py_RETURN_NONE;
}
-static PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args)
+static PyObject *bpygpu_VertBatch_uniform_f32(BPyGPUBatch *self, PyObject *args)
{
struct {
const char *id;
@@ -648,78 +646,78 @@ static PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args
}
switch (PyTuple_GET_SIZE(args)) {
- case 2: GWN_batch_uniform_1f(self->batch, params.id, params.values[0]); break;
- case 3: GWN_batch_uniform_2f(self->batch, params.id, UNPACK2(params.values)); break;
- case 4: GWN_batch_uniform_3f(self->batch, params.id, UNPACK3(params.values)); break;
- case 5: GWN_batch_uniform_4f(self->batch, params.id, UNPACK4(params.values)); break;
+ case 2: GPU_batch_uniform_1f(self->batch, params.id, params.values[0]); break;
+ case 3: GPU_batch_uniform_2f(self->batch, params.id, UNPACK2(params.values)); break;
+ case 4: GPU_batch_uniform_3f(self->batch, params.id, UNPACK3(params.values)); break;
+ case 5: GPU_batch_uniform_4f(self->batch, params.id, UNPACK4(params.values)); break;
default:
BLI_assert(0);
}
Py_RETURN_NONE;
}
-PyDoc_STRVAR(bpygwn_VertBatch_draw_doc,
+PyDoc_STRVAR(bpygpu_VertBatch_draw_doc,
"TODO"
);
-static PyObject *bpygwn_VertBatch_draw(BPyGwn_Batch *self)
+static PyObject *bpygpu_VertBatch_draw(BPyGPUBatch *self)
{
if (!glIsProgram(self->batch->program)) {
PyErr_SetString(PyExc_ValueError,
"batch program has not not set");
}
- GWN_batch_draw(self->batch);
+ GPU_batch_draw(self->batch);
Py_RETURN_NONE;
}
-static PyObject *bpygwn_VertBatch_program_use_begin(BPyGwn_Batch *self)
+static PyObject *bpygpu_VertBatch_program_use_begin(BPyGPUBatch *self)
{
if (!glIsProgram(self->batch->program)) {
PyErr_SetString(PyExc_ValueError,
"batch program has not not set");
}
- GWN_batch_program_use_begin(self->batch);
+ GPU_batch_program_use_begin(self->batch);
Py_RETURN_NONE;
}
-static PyObject *bpygwn_VertBatch_program_use_end(BPyGwn_Batch *self)
+static PyObject *bpygpu_VertBatch_program_use_end(BPyGPUBatch *self)
{
if (!glIsProgram(self->batch->program)) {
PyErr_SetString(PyExc_ValueError,
"batch program has not not set");
}
- GWN_batch_program_use_end(self->batch);
+ GPU_batch_program_use_end(self->batch);
Py_RETURN_NONE;
}
-static struct PyMethodDef bpygwn_VertBatch_methods[] = {
- {"vertbuf_add", (PyCFunction)bpygwn_VertBatch_vertbuf_add,
- METH_O, bpygwn_VertBatch_vertbuf_add_doc},
- {"program_set_builtin", (PyCFunction)bpygwn_VertBatch_program_set_builtin,
- METH_VARARGS | METH_KEYWORDS, bpygwn_VertBatch_program_set_builtin_doc},
- {"uniform_bool", (PyCFunction)bpygwn_VertBatch_uniform_bool,
+static struct PyMethodDef bpygpu_VertBatch_methods[] = {
+ {"vertbuf_add", (PyCFunction)bpygpu_VertBatch_vertbuf_add,
+ METH_O, bpygpu_VertBatch_vertbuf_add_doc},
+ {"program_set_builtin", (PyCFunction)bpygpu_VertBatch_program_set_builtin,
+ METH_VARARGS | METH_KEYWORDS, bpygpu_VertBatch_program_set_builtin_doc},
+ {"uniform_bool", (PyCFunction)bpygpu_VertBatch_uniform_bool,
METH_VARARGS, NULL},
- {"uniform_i32", (PyCFunction)bpygwn_VertBatch_uniform_i32,
+ {"uniform_i32", (PyCFunction)bpygpu_VertBatch_uniform_i32,
METH_VARARGS, NULL},
- {"uniform_f32", (PyCFunction)bpygwn_VertBatch_uniform_f32,
+ {"uniform_f32", (PyCFunction)bpygpu_VertBatch_uniform_f32,
METH_VARARGS, NULL},
- {"draw", (PyCFunction) bpygwn_VertBatch_draw,
- METH_NOARGS, bpygwn_VertBatch_draw_doc},
- {"program_use_begin", (PyCFunction)bpygwn_VertBatch_program_use_begin,
+ {"draw", (PyCFunction) bpygpu_VertBatch_draw,
+ METH_NOARGS, bpygpu_VertBatch_draw_doc},
+ {"program_use_begin", (PyCFunction)bpygpu_VertBatch_program_use_begin,
METH_NOARGS, ""},
- {"program_use_end", (PyCFunction)bpygwn_VertBatch_program_use_end,
+ {"program_use_end", (PyCFunction)bpygpu_VertBatch_program_use_end,
METH_NOARGS, ""},
{NULL, NULL, 0, NULL}
};
-#ifdef USE_GWN_PY_REFERENCES
+#ifdef USE_GPU_PY_REFERENCES
-static int bpygwn_Batch_traverse(BPyGwn_Batch *self, visitproc visit, void *arg)
+static int bpygpu_Batch_traverse(BPyGPUBatch *self, visitproc visit, void *arg)
{
Py_VISIT(self->references);
return 0;
}
-static int bpygwn_Batch_clear(BPyGwn_Batch *self)
+static int bpygpu_Batch_clear(BPyGPUBatch *self)
{
Py_CLEAR(self->references);
return 0;
@@ -727,14 +725,14 @@ static int bpygwn_Batch_clear(BPyGwn_Batch *self)
#endif
-static void bpygwn_Batch_dealloc(BPyGwn_Batch *self)
+static void bpygpu_Batch_dealloc(BPyGPUBatch *self)
{
- GWN_batch_discard(self->batch);
+ GPU_batch_discard(self->batch);
-#ifdef USE_GWN_PY_REFERENCES
+#ifdef USE_GPU_PY_REFERENCES
if (self->references) {
PyObject_GC_UnTrack(self);
- bpygwn_Batch_clear(self);
+ bpygpu_Batch_clear(self);
Py_XDECREF(self->references);
}
#endif
@@ -742,52 +740,52 @@ static void bpygwn_Batch_dealloc(BPyGwn_Batch *self)
Py_TYPE(self)->tp_free(self);
}
-PyTypeObject BPyGwn_Batch_Type = {
+PyTypeObject BPyGPUBatch_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "Gwn_Batch",
- .tp_basicsize = sizeof(BPyGwn_Batch),
- .tp_dealloc = (destructor)bpygwn_Batch_dealloc,
-#ifdef USE_GWN_PY_REFERENCES
+ .tp_name = "GPUBatch",
+ .tp_basicsize = sizeof(BPyGPUBatch),
+ .tp_dealloc = (destructor)bpygpu_Batch_dealloc,
+#ifdef USE_GPU_PY_REFERENCES
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- .tp_traverse = (traverseproc)bpygwn_Batch_traverse,
- .tp_clear = (inquiry)bpygwn_Batch_clear,
+ .tp_traverse = (traverseproc)bpygpu_Batch_traverse,
+ .tp_clear = (inquiry)bpygpu_Batch_clear,
#else
.tp_flags = Py_TPFLAGS_DEFAULT,
#endif
- .tp_methods = bpygwn_VertBatch_methods,
- .tp_new = bpygwn_Batch_new,
+ .tp_methods = bpygpu_VertBatch_methods,
+ .tp_new = bpygpu_Batch_new,
};
/* -------------------------------------------------------------------- */
-/** \name Gawain Types Module
+/** \name GPU Types Module
* \{ */
static struct PyModuleDef BPy_BM_types_module_def = {
PyModuleDef_HEAD_INIT,
- .m_name = "_gawain.types",
+ .m_name = "_gpu.types",
};
-PyObject *BPyInit_gawain_types(void)
+PyObject *BPyInit_gpu_types(void)
{
PyObject *submodule;
submodule = PyModule_Create(&BPy_BM_types_module_def);
- if (PyType_Ready(&BPyGwn_VertFormat_Type) < 0)
+ if (PyType_Ready(&BPyGPUVertFormat_Type) < 0)
return NULL;
- if (PyType_Ready(&BPyGwn_VertBuf_Type) < 0)
+ if (PyType_Ready(&BPyGPUVertBuf_Type) < 0)
return NULL;
- if (PyType_Ready(&BPyGwn_Batch_Type) < 0)
+ if (PyType_Ready(&BPyGPUBatch_Type) < 0)
return NULL;
#define MODULE_TYPE_ADD(s, t) \
PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t)
- MODULE_TYPE_ADD(submodule, BPyGwn_VertFormat_Type);
- MODULE_TYPE_ADD(submodule, BPyGwn_VertBuf_Type);
- MODULE_TYPE_ADD(submodule, BPyGwn_Batch_Type);
+ MODULE_TYPE_ADD(submodule, BPyGPUVertFormat_Type);
+ MODULE_TYPE_ADD(submodule, BPyGPUVertBuf_Type);
+ MODULE_TYPE_ADD(submodule, BPyGPUBatch_Type);
#undef MODULE_TYPE_ADD
@@ -802,11 +800,11 @@ PyObject *BPyInit_gawain_types(void)
/** \name Public API
* \{ */
-PyObject *BPyGwn_VertFormat_CreatePyObject(Gwn_VertFormat *fmt)
+PyObject *BPyGPUVertFormat_CreatePyObject(GPUVertFormat *fmt)
{
- BPyGwn_VertFormat *self;
+ BPyGPUVertFormat *self;
- self = PyObject_New(BPyGwn_VertFormat, &BPyGwn_VertFormat_Type);
+ self = PyObject_New(BPyGPUVertFormat, &BPyGPUVertFormat_Type);
if (fmt) {
self->fmt = *fmt;
}
@@ -817,26 +815,26 @@ PyObject *BPyGwn_VertFormat_CreatePyObject(Gwn_VertFormat *fmt)
return (PyObject *)self;
}
-PyObject *BPyGwn_VertBuf_CreatePyObject(Gwn_VertBuf *buf)
+PyObject *BPyGPUVertBuf_CreatePyObject(GPUVertBuf *buf)
{
- BPyGwn_VertBuf *self;
+ BPyGPUVertBuf *self;
- self = PyObject_New(BPyGwn_VertBuf, &BPyGwn_VertBuf_Type);
+ self = PyObject_New(BPyGPUVertBuf, &BPyGPUVertBuf_Type);
self->buf = buf;
return (PyObject *)self;
}
-PyObject *BPyGwn_Batch_CreatePyObject(Gwn_Batch *batch)
+PyObject *BPyGPUBatch_CreatePyObject(GPUBatch *batch)
{
- BPyGwn_Batch *self;
+ BPyGPUBatch *self;
-#ifdef USE_GWN_PY_REFERENCES
- self = (BPyGwn_Batch *)_PyObject_GC_New(&BPyGwn_Batch_Type);
+#ifdef USE_GPU_PY_REFERENCES
+ self = (BPyGPUBatch *)_PyObject_GC_New(&BPyGPUBatch_Type);
self->references = NULL;
#else
- self = PyObject_New(BPyGwn_Batch, &BPyGwn_Batch_Type);
+ self = PyObject_New(BPyGPUBatch, &BPyGPUBatch_Type);
#endif
self->batch = batch;
diff --git a/source/blender/python/gawain/gwn_py_types.h b/source/blender/python/gpu/gpu_py_types.h
index dde6cf98827..f736a8f749a 100644
--- a/source/blender/python/gawain/gwn_py_types.h
+++ b/source/blender/python/gpu/gpu_py_types.h
@@ -18,50 +18,50 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/python/gawain/gwn_py_types.h
- * \ingroup pygawain
+/** \file blender/python/gpu/gpu_py_types.h
+ * \ingroup pygpu
*/
-#ifndef __GWN_PY_TYPES_H__
-#define __GWN_PY_TYPES_H__
+#ifndef __GPU_PY_TYPES_H__
+#define __GPU_PY_TYPES_H__
#include "BLI_compiler_attrs.h"
-#define USE_GWN_PY_REFERENCES
+#define USE_GPU_PY_REFERENCES
-extern PyTypeObject BPyGwn_VertFormat_Type;
-extern PyTypeObject BPyGwn_VertBuf_Type;
-extern PyTypeObject BPyGwn_Batch_Type;
+extern PyTypeObject BPyGPUVertFormat_Type;
+extern PyTypeObject BPyGPUVertBuf_Type;
+extern PyTypeObject BPyGPUBatch_Type;
-#define BPyGwn_VertFormat_Check(v) (Py_TYPE(v) == &BPyGwn_VertFormat_Type)
-#define BPyGwn_VertBuf_Check(v) (Py_TYPE(v) == &BPyGwn_VertBuf_Type)
-#define BPyGwn_Batch_Check(v) (Py_TYPE(v) == &BPyGwn_Batch_Type)
+#define BPyGPUVertFormat_Check(v) (Py_TYPE(v) == &BPyGPUVertFormat_Type)
+#define BPyGPUVertBuf_Check(v) (Py_TYPE(v) == &BPyGPUVertBuf_Type)
+#define BPyGPUBatch_Check(v) (Py_TYPE(v) == &BPyGPUBatch_Type)
-typedef struct BPyGwn_VertFormat {
+typedef struct BPyGPUVertFormat {
PyObject_VAR_HEAD
- struct Gwn_VertFormat fmt;
-} BPyGwn_VertFormat;
+ struct GPUVertFormat fmt;
+} BPyGPUVertFormat;
-typedef struct BPyGwn_VertBuf {
+typedef struct BPyGPUVertBuf {
PyObject_VAR_HEAD
/* The buf is owned, we may support thin wrapped batches later. */
- struct Gwn_VertBuf *buf;
-} BPyGwn_VertBuf;
+ struct GPUVertBuf *buf;
+} BPyGPUVertBuf;
-typedef struct BPyGwn_Batch {
+typedef struct BPyGPUBatch {
PyObject_VAR_HEAD
/* The batch is owned, we may support thin wrapped batches later. */
- struct Gwn_Batch *batch;
-#ifdef USE_GWN_PY_REFERENCES
+ struct GPUBatch *batch;
+#ifdef USE_GPU_PY_REFERENCES
/* Just to keep a user to prevent freeing buf's we're using */
PyObject *references;
#endif
-} BPyGwn_Batch;
+} BPyGPUBatch;
-PyObject *BPyInit_gawain_types(void);
+PyObject *BPyInit_gpu_types(void);
-PyObject *BPyGwn_VertFormat_CreatePyObject(struct Gwn_VertFormat *fmt);
-PyObject *BPyGwn_VertBuf_CreatePyObject(struct Gwn_VertBuf *vbo) ATTR_NONNULL(1);
-PyObject *BPyGwn_Batch_CreatePyObject(struct Gwn_Batch *batch) ATTR_NONNULL(1);
+PyObject *BPyGPUVertFormat_CreatePyObject(struct GPUVertFormat *fmt);
+PyObject *BPyGPUVertBuf_CreatePyObject(struct GPUVertBuf *vbo) ATTR_NONNULL(1);
+PyObject *BPyGPUBatch_CreatePyObject(struct GPUBatch *batch) ATTR_NONNULL(1);
-#endif /* __GWN_PY_TYPES_H__ */
+#endif /* __GPU_PY_TYPES_H__ */
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index b3f4b4977bf..3255fb49667 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -66,7 +66,7 @@ set(SRC
bpy_intern_string.c
bpy_library_load.c
bpy_library_write.c
- bpy_manipulator_wrap.c
+ bpy_gizmo_wrap.c
bpy_msgbus.c
bpy_operator.c
bpy_operator_wrap.c
@@ -78,7 +78,7 @@ set(SRC
bpy_rna_callback.c
bpy_rna_driver.c
bpy_rna_id_collection.c
- bpy_rna_manipulator.c
+ bpy_rna_gizmo.c
bpy_traceback.c
bpy_utils_previews.c
bpy_utils_units.c
@@ -105,7 +105,7 @@ set(SRC
bpy_driver.h
bpy_intern_string.h
bpy_library.h
- bpy_manipulator_wrap.h
+ bpy_gizmo_wrap.h
bpy_msgbus.h
bpy_operator.h
bpy_operator_wrap.h
@@ -116,7 +116,7 @@ set(SRC
bpy_rna_callback.h
bpy_rna_driver.h
bpy_rna_id_collection.h
- bpy_rna_manipulator.h
+ bpy_rna_gizmo.h
bpy_traceback.h
bpy_utils_previews.h
bpy_utils_units.h
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 751625e378b..07ad8274f11 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -46,7 +46,7 @@
#include "bpy_rna.h"
#include "bpy_app.h"
#include "bpy_rna_id_collection.h"
-#include "bpy_rna_manipulator.h"
+#include "bpy_rna_gizmo.h"
#include "bpy_props.h"
#include "bpy_library.h"
#include "bpy_operator.h"
@@ -340,7 +340,7 @@ void BPy_init_modules(void)
BPY_rna_id_collection_module(mod);
- BPY_rna_manipulator_module(mod);
+ BPY_rna_gizmo_module(mod);
bpy_import_test("bpy_types");
PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 948a78d5794..72bc5bbc910 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -59,6 +59,10 @@ static PyStructSequence_Field app_cb_info_fields[] = {
{(char *)"load_post", (char *)"on loading a new blend file (after)"},
{(char *)"save_pre", (char *)"on saving a blend file (before)"},
{(char *)"save_post", (char *)"on saving a blend file (after)"},
+ {(char *)"undo_pre", (char *)"on loading an undo step (before)"},
+ {(char *)"undo_post", (char *)"on loading an undo step (after)"},
+ {(char *)"redo_pre", (char *)"on loading a redo step (before)"},
+ {(char *)"redo_post", (char *)"on loading a redo step (after)"},
{(char *)"version_update", (char *)"on ending the versioning code"},
/* sets the permanent tag */
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index b8c71d4e054..d3464ea5841 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -255,7 +255,6 @@ static void pydriver_error(ChannelDriver *driver)
#define OK_OP(op) [op] = 1
const char secure_opcodes[255] = {
- OK_OP(0),
OK_OP(POP_TOP),
OK_OP(ROT_TWO),
OK_OP(ROT_THREE),
@@ -349,15 +348,14 @@ static bool bpy_driver_secure_bytecode_validate(PyObject *expr_code, PyObject *d
/* Check opcodes. */
{
- const char *codestr;
+ const _Py_CODEUNIT *codestr;
Py_ssize_t code_len;
PyBytes_AsStringAndSize(py_code->co_code, (char **)&codestr, &code_len);
+ code_len /= sizeof(*codestr);
-#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1)
-
- for (Py_ssize_t i = 0; i < code_len; i += CODESIZE(codestr[i])) {
- const int opcode = codestr[i];
+ for (Py_ssize_t i = 0; i < code_len; i++) {
+ const int opcode = _Py_OPCODE(codestr[i]);
if (secure_opcodes[opcode] == 0) {
fprintf(stderr, "\tBPY_driver_eval() - restructed access disallows opcode '%d', "
"enable auto-execution to support\n", opcode);
diff --git a/source/blender/python/intern/bpy_manipulator_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c
index 3703ea92fa7..2a932cb6a99 100644
--- a/source/blender/python/intern/bpy_manipulator_wrap.c
+++ b/source/blender/python/intern/bpy_gizmo_wrap.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/python/intern/bpy_manipulator_wrap.c
+/** \file blender/python/intern/bpy_gizmo_wrap.c
* \ingroup pythonintern
*
* This file is so Python can define widget-group's that C can call into.
@@ -43,18 +43,18 @@
#include "bpy_rna.h"
#include "bpy_intern_string.h"
-#include "bpy_manipulator_wrap.h" /* own include */
+#include "bpy_gizmo_wrap.h" /* own include */
/* we may want to add, but not now */
/* -------------------------------------------------------------------- */
-/** \name Manipulator
+/** \name Gizmo
* \{ */
-static bool bpy_manipulatortype_target_property_def(
- wmManipulatorType *wt, PyObject *item)
+static bool bpy_gizmotype_target_property_def(
+ wmGizmoType *gzt, PyObject *item)
{
/* Note: names based on 'rna_rna.c' */
PyObject *empty_tuple = PyTuple_New(0);
@@ -102,7 +102,7 @@ static bool bpy_manipulatortype_target_property_def(
goto fail;
}
- WM_manipulatortype_target_property_def(wt, params.id, params.type, params.array_length);
+ WM_gizmotype_target_property_def(gzt, params.id, params.type, params.array_length);
Py_DECREF(empty_tuple);
return true;
@@ -111,17 +111,17 @@ fail:
return false;
}
-static void manipulator_properties_init(wmManipulatorType *wt)
+static void gizmo_properties_init(wmGizmoType *gzt)
{
- PyTypeObject *py_class = wt->ext.data;
- RNA_struct_blender_type_set(wt->ext.srna, wt);
+ PyTypeObject *py_class = gzt->ext.data;
+ RNA_struct_blender_type_set(gzt->ext.srna, gzt);
/* only call this so pyrna_deferred_register_class gives a useful error
* WM_operatortype_append_ptr will call RNA_def_struct_identifier
* later */
- RNA_def_struct_identifier_no_struct_map(wt->srna, wt->idname);
+ RNA_def_struct_identifier_no_struct_map(gzt->srna, gzt->idname);
- if (pyrna_deferred_register_class(wt->srna, py_class) != 0) {
+ if (pyrna_deferred_register_class(gzt->srna, py_class) != 0) {
PyErr_Print(); /* failed to register operator props */
PyErr_Clear();
}
@@ -149,7 +149,7 @@ static void manipulator_properties_init(wmManipulatorType *wt)
PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast);
for (uint i = 0; i < items_len; i++) {
- if (!bpy_manipulatortype_target_property_def(wt, items[i])) {
+ if (!bpy_gizmotype_target_property_def(gzt, items[i])) {
PyErr_Print();
PyErr_Clear();
break;
@@ -161,25 +161,25 @@ static void manipulator_properties_init(wmManipulatorType *wt)
}
}
-void BPY_RNA_manipulator_wrapper(wmManipulatorType *wt, void *userdata)
+void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata)
{
/* take care not to overwrite anything set in
- * WM_manipulatormaptype_group_link_ptr before opfunc() is called */
- StructRNA *srna = wt->srna;
- *wt = *((wmManipulatorType *)userdata);
- wt->srna = srna; /* restore */
+ * WM_gizmomaptype_group_link_ptr before opfunc() is called */
+ StructRNA *srna = gzt->srna;
+ *gzt = *((wmGizmoType *)userdata);
+ gzt->srna = srna; /* restore */
/* don't do translations here yet */
#if 0
- /* Use i18n context from ext.srna if possible (py manipulatorgroups). */
- if (wt->ext.srna) {
- RNA_def_struct_translation_context(wt->srna, RNA_struct_translation_context(wt->ext.srna));
+ /* Use i18n context from ext.srna if possible (py gizmogroups). */
+ if (gt->ext.srna) {
+ RNA_def_struct_translation_context(gt->srna, RNA_struct_translation_context(gt->ext.srna));
}
#endif
- wt->struct_size = sizeof(wmManipulator);
+ gzt->struct_size = sizeof(wmGizmo);
- manipulator_properties_init(wt);
+ gizmo_properties_init(gzt);
}
/** \} */
@@ -187,49 +187,49 @@ void BPY_RNA_manipulator_wrapper(wmManipulatorType *wt, void *userdata)
/* -------------------------------------------------------------------- */
-/** \name Manipulator Group
+/** \name Gizmo Group
* \{ */
-static void manipulatorgroup_properties_init(wmManipulatorGroupType *wgt)
+static void gizmogroup_properties_init(wmGizmoGroupType *gzgt)
{
#ifdef USE_SRNA
- PyTypeObject *py_class = wgt->ext.data;
+ PyTypeObject *py_class = gzgt->ext.data;
#endif
- RNA_struct_blender_type_set(wgt->ext.srna, wgt);
+ RNA_struct_blender_type_set(gzgt->ext.srna, gzgt);
#ifdef USE_SRNA
/* only call this so pyrna_deferred_register_class gives a useful error
* WM_operatortype_append_ptr will call RNA_def_struct_identifier
* later */
- RNA_def_struct_identifier(wgt->srna, wgt->idname);
+ RNA_def_struct_identifier(gzgt->srna, gzgt->idname);
- if (pyrna_deferred_register_class(wgt->srna, py_class) != 0) {
+ if (pyrna_deferred_register_class(gzgt->srna, py_class) != 0) {
PyErr_Print(); /* failed to register operator props */
PyErr_Clear();
}
#endif
}
-void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata)
+void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata)
{
/* take care not to overwrite anything set in
- * WM_manipulatormaptype_group_link_ptr before opfunc() is called */
+ * WM_gizmomaptype_group_link_ptr before opfunc() is called */
#ifdef USE_SRNA
- StructRNA *srna = wgt->srna;
+ StructRNA *srna = gzgt->srna;
#endif
- *wgt = *((wmManipulatorGroupType *)userdata);
+ *gzgt = *((wmGizmoGroupType *)userdata);
#ifdef USE_SRNA
- wgt->srna = srna; /* restore */
+ gzgt->srna = srna; /* restore */
#endif
#ifdef USE_SRNA
- /* Use i18n context from ext.srna if possible (py manipulatorgroups). */
- if (wgt->ext.srna) {
- RNA_def_struct_translation_context(wgt->srna, RNA_struct_translation_context(wgt->ext.srna));
+ /* Use i18n context from ext.srna if possible (py gizmogroups). */
+ if (gzgt->ext.srna) {
+ RNA_def_struct_translation_context(gzgt->srna, RNA_struct_translation_context(gzgt->ext.srna));
}
#endif
- manipulatorgroup_properties_init(wgt);
+ gizmogroup_properties_init(gzgt);
}
/** \} */
diff --git a/source/blender/python/intern/bpy_manipulator_wrap.h b/source/blender/python/intern/bpy_gizmo_wrap.h
index 3e415350228..96f15312a4e 100644
--- a/source/blender/python/intern/bpy_manipulator_wrap.h
+++ b/source/blender/python/intern/bpy_gizmo_wrap.h
@@ -18,18 +18,18 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/python/intern/bpy_manipulator_wrap.h
+/** \file blender/python/intern/bpy_gizmo_wrap.h
* \ingroup pythonintern
*/
-#ifndef __BPY_MANIPULATOR_WRAP_H__
-#define __BPY_MANIPULATOR_WRAP_H__
+#ifndef __BPY_GIZMO_WRAP_H__
+#define __BPY_GIZMO_WRAP_H__
-struct wmManipulatorType;
-struct wmManipulatorGroupType;
+struct wmGizmoType;
+struct wmGizmoGroupType;
/* exposed to rna/wm api */
-void BPY_RNA_manipulator_wrapper(struct wmManipulatorType *wt, void *userdata);
-void BPY_RNA_manipulatorgroup_wrapper(struct wmManipulatorGroupType *wgt, void *userdata);
+void BPY_RNA_gizmo_wrapper(struct wmGizmoType *gzt, void *userdata);
+void BPY_RNA_gizmogroup_wrapper(struct wmGizmoGroupType *gzgt, void *userdata);
-#endif /* __BPY_MANIPULATOR_WRAP_H__ */
+#endif /* __BPY_GIZMO_WRAP_H__ */
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 0d7b0c92a90..64bc54c6221 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -75,7 +75,7 @@
#include "../generic/blf_py_api.h"
#include "../generic/idprop_py_api.h"
#include "../generic/imbuf_py_api.h"
-#include "../gawain/gwn_py_api.h"
+#include "../gpu/gpu_py_api.h"
#include "../bmesh/bmesh_py_api.h"
#include "../mathutils/mathutils.h"
@@ -219,7 +219,7 @@ static struct _inittab bpy_internal_modules[] = {
{"mathutils.kdtree", PyInit_mathutils_kdtree},
#endif
{"_bpy_path", BPyInit__bpy_path},
- {"_gawain", BPyInit_gawain},
+ {"_gpu", BPyInit_gpu},
{"bgl", BPyInit_bgl},
{"blf", BPyInit_blf},
{"imbuf", BPyInit_imbuf},
diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.c
index 6911e985e93..41276963fc9 100644
--- a/source/blender/python/intern/bpy_intern_string.c
+++ b/source/blender/python/intern/bpy_intern_string.c
@@ -36,6 +36,7 @@
static PyObject *bpy_intern_str_arr[16];
+PyObject *bpy_intern_str___annotations__;
PyObject *bpy_intern_str___doc__;
PyObject *bpy_intern_str___main__;
PyObject *bpy_intern_str___module__;
@@ -47,7 +48,6 @@ PyObject *bpy_intern_str_bl_rna;
PyObject *bpy_intern_str_bl_target_properties;
PyObject *bpy_intern_str_bpy_types;
PyObject *bpy_intern_str_frame;
-PyObject *bpy_intern_str_order;
PyObject *bpy_intern_str_properties;
PyObject *bpy_intern_str_register;
PyObject *bpy_intern_str_self;
@@ -60,6 +60,7 @@ void bpy_intern_string_init(void)
#define BPY_INTERN_STR(var, str) \
{ var = bpy_intern_str_arr[i++] = PyUnicode_FromString(str); } (void)0
+ BPY_INTERN_STR(bpy_intern_str___annotations__, "__annotations__");
BPY_INTERN_STR(bpy_intern_str___doc__, "__doc__");
BPY_INTERN_STR(bpy_intern_str___main__, "__main__");
BPY_INTERN_STR(bpy_intern_str___module__, "__module__");
@@ -71,7 +72,6 @@ void bpy_intern_string_init(void)
BPY_INTERN_STR(bpy_intern_str_bl_target_properties, "bl_target_properties");
BPY_INTERN_STR(bpy_intern_str_bpy_types, "bpy.types");
BPY_INTERN_STR(bpy_intern_str_frame, "frame");
- BPY_INTERN_STR(bpy_intern_str_order, "order");
BPY_INTERN_STR(bpy_intern_str_properties, "properties");
BPY_INTERN_STR(bpy_intern_str_register, "register");
BPY_INTERN_STR(bpy_intern_str_self, "self");
diff --git a/source/blender/python/intern/bpy_intern_string.h b/source/blender/python/intern/bpy_intern_string.h
index 998c312c321..41cd58f9c3d 100644
--- a/source/blender/python/intern/bpy_intern_string.h
+++ b/source/blender/python/intern/bpy_intern_string.h
@@ -30,6 +30,7 @@
void bpy_intern_string_init(void);
void bpy_intern_string_exit(void);
+extern PyObject *bpy_intern_str___annotations__;
extern PyObject *bpy_intern_str___doc__;
extern PyObject *bpy_intern_str___main__;
extern PyObject *bpy_intern_str___module__;
@@ -41,7 +42,6 @@ extern PyObject *bpy_intern_str_bl_rna;
extern PyObject *bpy_intern_str_bl_target_properties;
extern PyObject *bpy_intern_str_bpy_types;
extern PyObject *bpy_intern_str_frame;
-extern PyObject *bpy_intern_str_order;
extern PyObject *bpy_intern_str_properties;
extern PyObject *bpy_intern_str_register;
extern PyObject *bpy_intern_str_self;
diff --git a/source/blender/python/intern/bpy_msgbus.c b/source/blender/python/intern/bpy_msgbus.c
index b76ecafe6f0..101cc8b41a3 100644
--- a/source/blender/python/intern/bpy_msgbus.c
+++ b/source/blender/python/intern/bpy_msgbus.c
@@ -44,7 +44,7 @@
#include "bpy_capi_utils.h"
#include "bpy_rna.h"
#include "bpy_intern_string.h"
-#include "bpy_manipulator_wrap.h" /* own include */
+#include "bpy_gizmo_wrap.h" /* own include */
#include "bpy_msgbus.h" /* own include */
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 3e1c85d7f9f..30bd3bc5ca3 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1853,13 +1853,13 @@ static int pyrna_py_to_prop(
{
const StructRNA *base_type =
RNA_struct_base_child_of(((const BPy_StructRNA *)value)->ptr.type, NULL);
- if (ELEM(base_type, &RNA_Operator, &RNA_Manipulator)) {
+ if (ELEM(base_type, &RNA_Operator, &RNA_Gizmo)) {
value = PyObject_GetAttr(value, bpy_intern_str_properties);
value_new = value;
}
}
- /* if property is an OperatorProperties/ManipulatorProperties pointer and value is a map,
+ /* if property is an OperatorProperties/GizmoProperties pointer and value is a map,
* forward back to pyrna_pydict_to_props */
if (PyDict_Check(value)) {
const StructRNA *base_type = RNA_struct_base_child_of(ptr_type, NULL);
@@ -1867,7 +1867,7 @@ static int pyrna_py_to_prop(
PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
}
- else if (base_type == &RNA_ManipulatorProperties) {
+ else if (base_type == &RNA_GizmoProperties) {
PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
}
@@ -5118,6 +5118,9 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
case PROP_RAW_DOUBLE:
item = PyFloat_FromDouble((double) ((double *)array)[i]);
break;
+ case PROP_RAW_BOOLEAN:
+ item = PyBool_FromLong((long) ((bool *)array)[i]);
+ break;
default: /* PROP_RAW_UNSET */
/* should never happen */
BLI_assert(!"Invalid array type - get");
@@ -7423,29 +7426,38 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict)
{
+ PyObject *fields_dict;
PyObject *item, *key;
- PyObject *order;
Py_ssize_t pos = 0;
int ret = 0;
/* in both cases PyDict_CheckExact(class_dict) will be true even
* though Operators have a metaclass dict namespace */
+ if ((fields_dict = PyDict_GetItem(class_dict, bpy_intern_str___annotations__)) && PyDict_CheckExact(fields_dict)) {
+ while (PyDict_Next(fields_dict, &pos, &key, &item)) {
+ ret = deferred_register_prop(srna, key, item);
- if ((order = PyDict_GetItem(class_dict, bpy_intern_str_order)) && PyList_CheckExact(order)) {
- for (pos = 0; pos < PyList_GET_SIZE(order); pos++) {
- key = PyList_GET_ITEM(order, pos);
- /* however unlikely its possible
- * fails in py 3.3 beta with __qualname__ */
- if ((item = PyDict_GetItem(class_dict, key))) {
- ret = deferred_register_prop(srna, key, item);
- if (ret != 0) {
- break;
- }
+ if (ret != 0) {
+ break;
}
}
}
- else {
+
+ {
+ /* This block can be removed once 2.8x is released and fields are in use. */
+ bool has_warning = false;
while (PyDict_Next(class_dict, &pos, &key, &item)) {
+ if (pyrna_is_deferred_prop(item)) {
+ if (!has_warning) {
+ printf("Warning: class %.200s "
+ "contains a properties which should be a field!\n",
+ RNA_struct_identifier(srna));
+ PyC_LineSpit();
+ has_warning = true;
+ }
+ printf(" make field: %.200s.%.200s\n",
+ RNA_struct_identifier(srna), _PyUnicode_AsString(key));
+ }
ret = deferred_register_prop(srna, key, item);
if (ret != 0)
@@ -7650,10 +7662,12 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
if (!(flag & PROP_REGISTER))
continue;
+ /* TODO(campbell): Use Python3.7x _PyObject_LookupAttr(), also in the macro below. */
identifier = RNA_property_identifier(prop);
item = PyObject_GetAttrString(py_class, identifier);
if (item == NULL) {
+ PyErr_Clear();
/* Sneaky workaround to use the class name as the bl_idname */
#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \
@@ -7669,6 +7683,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
} \
Py_DECREF(item); \
} \
+ else { \
+ PyErr_Clear(); \
+ } \
} /* intentionally allow else here */
if (false) {} /* needed for macro */
@@ -7724,7 +7741,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
#ifdef USE_PEDANTIC_WRITE
const bool is_readonly_init = !(RNA_struct_is_a(ptr->type, &RNA_Operator) ||
- RNA_struct_is_a(ptr->type, &RNA_Manipulator));
+ RNA_struct_is_a(ptr->type, &RNA_Gizmo));
// const char *func_id = RNA_function_identifier(func); /* UNUSED */
/* testing, for correctness, not operator and not draw function */
const bool is_readonly = !(RNA_function_flag(func) & FUNC_ALLOW_WRITE);
diff --git a/source/blender/python/intern/bpy_rna_manipulator.c b/source/blender/python/intern/bpy_rna_gizmo.c
index 950f7f98be0..ded26f777a5 100644
--- a/source/blender/python/intern/bpy_rna_manipulator.c
+++ b/source/blender/python/intern/bpy_rna_gizmo.c
@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/python/intern/bpy_rna_manipulator.c
+/** \file blender/python/intern/bpy_rna_gizmo.c
* \ingroup pythonintern
*
* .
@@ -38,7 +38,7 @@
#include "WM_types.h"
#include "bpy_capi_utils.h"
-#include "bpy_rna_manipulator.h"
+#include "bpy_rna_gizmo.h"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
@@ -51,43 +51,43 @@
/* -------------------------------------------------------------------- */
-/** \name Manipulator Target Property Define API
+/** \name Gizmo Target Property Define API
* \{ */
enum {
- BPY_MANIPULATOR_FN_SLOT_GET = 0,
- BPY_MANIPULATOR_FN_SLOT_SET,
- BPY_MANIPULATOR_FN_SLOT_RANGE_GET,
+ BPY_GIZMO_FN_SLOT_GET = 0,
+ BPY_GIZMO_FN_SLOT_SET,
+ BPY_GIZMO_FN_SLOT_RANGE_GET,
};
-#define BPY_MANIPULATOR_FN_SLOT_LEN (BPY_MANIPULATOR_FN_SLOT_RANGE_GET + 1)
+#define BPY_GIZMO_FN_SLOT_LEN (BPY_GIZMO_FN_SLOT_RANGE_GET + 1)
-struct BPyManipulatorHandlerUserData {
+struct BPyGizmoHandlerUserData {
- PyObject *fn_slots[BPY_MANIPULATOR_FN_SLOT_LEN];
+ PyObject *fn_slots[BPY_GIZMO_FN_SLOT_LEN];
};
-static void py_rna_manipulator_handler_get_cb(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void py_rna_gizmo_handler_get_cb(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
void *value_p)
{
PyGILState_STATE gilstate = PyGILState_Ensure();
- struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data;
- PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_GET], NULL);
+ struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data;
+ PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_GET], NULL);
if (ret == NULL) {
goto fail;
}
- if (mpr_prop->type->data_type == PROP_FLOAT) {
+ if (gz_prop->type->data_type == PROP_FLOAT) {
float *value = value_p;
- if (mpr_prop->type->array_length == 1) {
+ if (gz_prop->type->array_length == 1) {
if ((*value = PyFloat_AsDouble(ret)) == -1.0f && PyErr_Occurred()) {
goto fail;
}
}
else {
- if (PyC_AsArray(value, ret, mpr_prop->type->array_length, &PyFloat_Type, false,
- "Manipulator get callback: ") == -1)
+ if (PyC_AsArray(value, ret, gz_prop->type->array_length, &PyFloat_Type, false,
+ "Gizmo get callback: ") == -1)
{
goto fail;
}
@@ -110,24 +110,24 @@ fail:
PyGILState_Release(gilstate);
}
-static void py_rna_manipulator_handler_set_cb(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void py_rna_gizmo_handler_set_cb(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
const void *value_p)
{
PyGILState_STATE gilstate = PyGILState_Ensure();
- struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data;
+ struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data;
PyObject *args = PyTuple_New(1);
- if (mpr_prop->type->data_type == PROP_FLOAT) {
+ if (gz_prop->type->data_type == PROP_FLOAT) {
const float *value = value_p;
PyObject *py_value;
- if (mpr_prop->type->array_length == 1) {
+ if (gz_prop->type->array_length == 1) {
py_value = PyFloat_FromDouble(*value);
}
else {
- py_value = PyC_Tuple_PackArray_F32(value, mpr_prop->type->array_length);
+ py_value = PyC_Tuple_PackArray_F32(value, gz_prop->type->array_length);
}
if (py_value == NULL) {
goto fail;
@@ -139,7 +139,7 @@ static void py_rna_manipulator_handler_set_cb(
goto fail;
}
- PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_SET], args);
+ PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_SET], args);
if (ret == NULL) {
goto fail;
}
@@ -157,15 +157,15 @@ fail:
PyGILState_Release(gilstate);
}
-static void py_rna_manipulator_handler_range_get_cb(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void py_rna_gizmo_handler_range_get_cb(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop,
void *value_p)
{
- struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data;
+ struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data;
PyGILState_STATE gilstate = PyGILState_Ensure();
- PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET], NULL);
+ PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_RANGE_GET], NULL);
if (ret == NULL) {
goto fail;
}
@@ -184,7 +184,7 @@ static void py_rna_manipulator_handler_range_get_cb(
goto fail;
}
- if (mpr_prop->type->data_type == PROP_FLOAT) {
+ if (gz_prop->type->data_type == PROP_FLOAT) {
float range[2];
for (int i = 0; i < 2; i++) {
if (((range[i] = PyFloat_AsDouble(PyTuple_GET_ITEM(ret, i))) == -1.0f && PyErr_Occurred()) == 0) {
@@ -214,13 +214,13 @@ fail:
PyGILState_Release(gilstate);
}
-static void py_rna_manipulator_handler_free_cb(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop)
+static void py_rna_gizmo_handler_free_cb(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
{
- struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data;
+ struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data;
PyGILState_STATE gilstate = PyGILState_Ensure();
- for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) {
+ for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) {
Py_XDECREF(data->fn_slots[i]);
}
PyGILState_Release(gilstate);
@@ -229,26 +229,26 @@ static void py_rna_manipulator_handler_free_cb(
}
-PyDoc_STRVAR(bpy_manipulator_target_set_handler_doc,
+PyDoc_STRVAR(bpy_gizmo_target_set_handler_doc,
".. method:: target_set_handler(target, get, set, range=None):\n"
"\n"
-" Assigns callbacks to a manipulators property.\n"
+" Assigns callbacks to a gizmos property.\n"
"\n"
" :arg get: Function that returns the value for this property (single value or sequence).\n"
" :type get: callable\n"
" :arg set: Function that takes a single value argument and applies it.\n"
" :type set: callable\n"
-" :arg range: Function that returns a (min, max) tuple for manipulators that use a range.\n"
+" :arg range: Function that returns a (min, max) tuple for gizmos that use a range.\n"
" :type range: callable\n"
);
-static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
PyGILState_STATE gilstate = PyGILState_Ensure();
struct {
PyObject *self;
char *target;
- PyObject *py_fn_slots[BPY_MANIPULATOR_FN_SLOT_LEN];
+ PyObject *py_fn_slots[BPY_GIZMO_FN_SLOT_LEN];
} params = {
.self = NULL,
.target = NULL,
@@ -256,36 +256,36 @@ static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyOb
};
/* Note: this is a counter-part to functions:
- * 'Manipulator.target_set_prop & target_set_operator'
- * (see: rna_wm_manipulator_api.c). conventions should match. */
+ * 'Gizmo.target_set_prop & target_set_operator'
+ * (see: rna_wm_gizmo_api.c). conventions should match. */
static const char * const _keywords[] = {"self", "target", "get", "set", "range", NULL};
static _PyArg_Parser _parser = {"Os|$OOO:target_set_handler", _keywords, 0};
if (!_PyArg_ParseTupleAndKeywordsFast(
args, kw, &_parser,
&params.self,
&params.target,
- &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_GET],
- &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_SET],
- &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET]))
+ &params.py_fn_slots[BPY_GIZMO_FN_SLOT_GET],
+ &params.py_fn_slots[BPY_GIZMO_FN_SLOT_SET],
+ &params.py_fn_slots[BPY_GIZMO_FN_SLOT_RANGE_GET]))
{
goto fail;
}
- wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
+ wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data;
- const wmManipulatorPropertyType *mpr_prop_type =
- WM_manipulatortype_target_property_find(mpr->type, params.target);
- if (mpr_prop_type == NULL) {
+ const wmGizmoPropertyType *gz_prop_type =
+ WM_gizmotype_target_property_find(gz->type, params.target);
+ if (gz_prop_type == NULL) {
PyErr_Format(PyExc_ValueError,
- "Manipulator target property '%s.%s' not found",
- mpr->type->idname, params.target);
+ "Gizmo target property '%s.%s' not found",
+ gz->type->idname, params.target);
goto fail;
}
{
const int slots_required = 2;
const int slots_start = 2;
- for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) {
+ for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) {
if (params.py_fn_slots[i] == NULL) {
if (i < slots_required) {
PyErr_Format(PyExc_ValueError, "Argument '%s' not given", _keywords[slots_start + i]);
@@ -299,20 +299,20 @@ static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyOb
}
}
- struct BPyManipulatorHandlerUserData *data = MEM_callocN(sizeof(*data), __func__);
+ struct BPyGizmoHandlerUserData *data = MEM_callocN(sizeof(*data), __func__);
- for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) {
+ for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) {
data->fn_slots[i] = params.py_fn_slots[i];
Py_XINCREF(params.py_fn_slots[i]);
}
- WM_manipulator_target_property_def_func_ptr(
- mpr, mpr_prop_type,
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = py_rna_manipulator_handler_get_cb,
- .value_set_fn = py_rna_manipulator_handler_set_cb,
- .range_get_fn = py_rna_manipulator_handler_range_get_cb,
- .free_fn = py_rna_manipulator_handler_free_cb,
+ WM_gizmo_target_property_def_func_ptr(
+ gz, gz_prop_type,
+ &(const struct wmGizmoPropertyFnParams) {
+ .value_get_fn = py_rna_gizmo_handler_get_cb,
+ .value_set_fn = py_rna_gizmo_handler_set_cb,
+ .range_get_fn = py_rna_gizmo_handler_range_get_cb,
+ .free_fn = py_rna_gizmo_handler_free_cb,
.user_data = data,
});
@@ -328,10 +328,10 @@ fail:
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Manipulator Target Property Access API
+/** \name Gizmo Target Property Access API
* \{ */
-PyDoc_STRVAR(bpy_manipulator_target_get_value_doc,
+PyDoc_STRVAR(bpy_gizmo_target_get_value_doc,
".. method:: target_get_value(target):\n"
"\n"
" Get the value of this target property.\n"
@@ -341,7 +341,7 @@ PyDoc_STRVAR(bpy_manipulator_target_get_value_doc,
" :return: The value of the target property.\n"
" :rtype: Single value or array based on the target type\n"
);
-static PyObject *bpy_manipulator_target_get_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
struct {
PyObject *self;
@@ -361,28 +361,28 @@ static PyObject *bpy_manipulator_target_get_value(PyObject *UNUSED(self), PyObje
goto fail;
}
- wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
+ wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data;
- wmManipulatorProperty *mpr_prop =
- WM_manipulator_target_property_find(mpr, params.target);
- if (mpr_prop == NULL) {
+ wmGizmoProperty *gz_prop =
+ WM_gizmo_target_property_find(gz, params.target);
+ if (gz_prop == NULL) {
PyErr_Format(PyExc_ValueError,
- "Manipulator target property '%s.%s' not found",
- mpr->type->idname, params.target);
+ "Gizmo target property '%s.%s' not found",
+ gz->type->idname, params.target);
goto fail;
}
- const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop);
- switch (mpr_prop->type->data_type) {
+ const int array_len = WM_gizmo_target_property_array_length(gz, gz_prop);
+ switch (gz_prop->type->data_type) {
case PROP_FLOAT:
{
if (array_len != 0) {
float *value = BLI_array_alloca(value, array_len);
- WM_manipulator_target_property_value_get_array(mpr, mpr_prop, value);
+ WM_gizmo_target_property_value_get_array(gz, gz_prop, value);
return PyC_Tuple_PackArray_F32(value, array_len);
}
else {
- float value = WM_manipulator_target_property_value_get(mpr, mpr_prop);
+ float value = WM_gizmo_target_property_value_get(gz, gz_prop);
return PyFloat_FromDouble(value);
}
break;
@@ -398,7 +398,7 @@ fail:
return NULL;
}
-PyDoc_STRVAR(bpy_manipulator_target_set_value_doc,
+PyDoc_STRVAR(bpy_gizmo_target_set_value_doc,
".. method:: target_set_value(target):\n"
"\n"
" Set the value of this target property.\n"
@@ -406,7 +406,7 @@ PyDoc_STRVAR(bpy_manipulator_target_set_value_doc,
" :arg target: Target property name.\n"
" :type target: string\n"
);
-static PyObject *bpy_manipulator_target_set_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
struct {
PyObject *self;
@@ -429,36 +429,36 @@ static PyObject *bpy_manipulator_target_set_value(PyObject *UNUSED(self), PyObje
goto fail;
}
- wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
+ wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data;
- wmManipulatorProperty *mpr_prop =
- WM_manipulator_target_property_find(mpr, params.target);
- if (mpr_prop == NULL) {
+ wmGizmoProperty *gz_prop =
+ WM_gizmo_target_property_find(gz, params.target);
+ if (gz_prop == NULL) {
PyErr_Format(PyExc_ValueError,
- "Manipulator target property '%s.%s' not found",
- mpr->type->idname, params.target);
+ "Gizmo target property '%s.%s' not found",
+ gz->type->idname, params.target);
goto fail;
}
- const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop);
- switch (mpr_prop->type->data_type) {
+ const int array_len = WM_gizmo_target_property_array_length(gz, gz_prop);
+ switch (gz_prop->type->data_type) {
case PROP_FLOAT:
{
if (array_len != 0) {
float *value = BLI_array_alloca(value, array_len);
- if (PyC_AsArray(value, params.value, mpr_prop->type->array_length, &PyFloat_Type, false,
- "Manipulator target property array") == -1)
+ if (PyC_AsArray(value, params.value, gz_prop->type->array_length, &PyFloat_Type, false,
+ "Gizmo target property array") == -1)
{
goto fail;
}
- WM_manipulator_target_property_value_set_array(BPy_GetContext(), mpr, mpr_prop, value);
+ WM_gizmo_target_property_value_set_array(BPy_GetContext(), gz, gz_prop, value);
}
else {
float value;
if ((value = PyFloat_AsDouble(params.value)) == -1.0f && PyErr_Occurred()) {
goto fail;
}
- WM_manipulator_target_property_value_set(BPy_GetContext(), mpr, mpr_prop, value);
+ WM_gizmo_target_property_value_set(BPy_GetContext(), gz, gz_prop, value);
}
Py_RETURN_NONE;
}
@@ -474,7 +474,7 @@ fail:
}
-PyDoc_STRVAR(bpy_manipulator_target_get_range_doc,
+PyDoc_STRVAR(bpy_gizmo_target_get_range_doc,
".. method:: target_get_range(target):\n"
"\n"
" Get the range for this target property.\n"
@@ -484,7 +484,7 @@ PyDoc_STRVAR(bpy_manipulator_target_get_range_doc,
" :return: The range of this property (min, max).\n"
" :rtype: tuple pair.\n"
);
-static PyObject *bpy_manipulator_target_get_range(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
struct {
PyObject *self;
@@ -504,22 +504,22 @@ static PyObject *bpy_manipulator_target_get_range(PyObject *UNUSED(self), PyObje
goto fail;
}
- wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
+ wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data;
- wmManipulatorProperty *mpr_prop =
- WM_manipulator_target_property_find(mpr, params.target);
- if (mpr_prop == NULL) {
+ wmGizmoProperty *gz_prop =
+ WM_gizmo_target_property_find(gz, params.target);
+ if (gz_prop == NULL) {
PyErr_Format(PyExc_ValueError,
- "Manipulator target property '%s.%s' not found",
- mpr->type->idname, params.target);
+ "Gizmo target property '%s.%s' not found",
+ gz->type->idname, params.target);
goto fail;
}
- switch (mpr_prop->type->data_type) {
+ switch (gz_prop->type->data_type) {
case PROP_FLOAT:
{
float range[2];
- WM_manipulator_target_property_range_get(mpr, mpr_prop, range);
+ WM_gizmo_target_property_range_get(gz, gz_prop, range);
return PyC_Tuple_PackArray_F32(range, 2);
}
default:
@@ -535,19 +535,19 @@ fail:
/** \} */
-int BPY_rna_manipulator_module(PyObject *mod_par)
+int BPY_rna_gizmo_module(PyObject *mod_par)
{
static PyMethodDef method_def_array[] = {
- /* Manipulator Target Property Define API */
- {"target_set_handler", (PyCFunction)bpy_manipulator_target_set_handler,
- METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_handler_doc},
- /* Manipulator Target Property Access API */
- {"target_get_value", (PyCFunction)bpy_manipulator_target_get_value,
- METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_value_doc},
- {"target_set_value", (PyCFunction)bpy_manipulator_target_set_value,
- METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_value_doc},
- {"target_get_range", (PyCFunction)bpy_manipulator_target_get_range,
- METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_range_doc},
+ /* Gizmo Target Property Define API */
+ {"target_set_handler", (PyCFunction)bpy_gizmo_target_set_handler,
+ METH_VARARGS | METH_KEYWORDS, bpy_gizmo_target_set_handler_doc},
+ /* Gizmo Target Property Access API */
+ {"target_get_value", (PyCFunction)bpy_gizmo_target_get_value,
+ METH_VARARGS | METH_KEYWORDS, bpy_gizmo_target_get_value_doc},
+ {"target_set_value", (PyCFunction)bpy_gizmo_target_set_value,
+ METH_VARARGS | METH_KEYWORDS, bpy_gizmo_target_set_value_doc},
+ {"target_get_range", (PyCFunction)bpy_gizmo_target_get_range,
+ METH_VARARGS | METH_KEYWORDS, bpy_gizmo_target_get_range_doc},
/* no sentinel needed. */
};
@@ -556,7 +556,7 @@ int BPY_rna_manipulator_module(PyObject *mod_par)
PyObject *func = PyCFunction_New(m, NULL);
PyObject *func_inst = PyInstanceMethod_New(func);
char name_prefix[128];
- PyOS_snprintf(name_prefix, sizeof(name_prefix), "_rna_manipulator_%s", m->ml_name);
+ PyOS_snprintf(name_prefix, sizeof(name_prefix), "_rna_gizmo_%s", m->ml_name);
/* TODO, return a type that binds nearly to a method. */
PyModule_AddObject(mod_par, name_prefix, func_inst);
}
diff --git a/source/blender/python/intern/bpy_rna_manipulator.h b/source/blender/python/intern/bpy_rna_gizmo.h
index b6f3a2e651d..68d8c1e052a 100644
--- a/source/blender/python/intern/bpy_rna_manipulator.h
+++ b/source/blender/python/intern/bpy_rna_gizmo.h
@@ -20,13 +20,13 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/python/intern/bpy_rna_manipulator.h
+/** \file blender/python/intern/bpy_rna_gizmo.h
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_MANIPULATOR_H__
-#define __BPY_RNA_MANIPULATOR_H__
+#ifndef __BPY_RNA_GIZMO_H__
+#define __BPY_RNA_GIZMO_H__
-int BPY_rna_manipulator_module(PyObject *);
+int BPY_rna_gizmo_module(PyObject *);
-#endif /* __BPY_RNA_MANIPULATOR_H__ */
+#endif /* __BPY_RNA_GIZMO_H__ */
diff --git a/source/blender/python/intern/gpu_py_matrix.c b/source/blender/python/intern/gpu_py_matrix.c
index 68b08dfb324..2ab6fd864eb 100644
--- a/source/blender/python/intern/gpu_py_matrix.c
+++ b/source/blender/python/intern/gpu_py_matrix.c
@@ -102,7 +102,7 @@ static PyObject *pygpu_matrix_push(PyObject *UNUSED(self))
if (!pygpu_stack_is_push_model_view_ok_or_error()) {
return NULL;
}
- gpuPushMatrix();
+ GPU_matrix_push();
Py_RETURN_NONE;
}
@@ -116,7 +116,7 @@ static PyObject *pygpu_matrix_pop(PyObject *UNUSED(self))
if (!pygpu_stack_is_pop_model_view_ok_or_error()) {
return NULL;
}
- gpuPopMatrix();
+ GPU_matrix_pop();
Py_RETURN_NONE;
}
@@ -130,7 +130,7 @@ static PyObject *pygpu_matrix_push_projection(PyObject *UNUSED(self))
if (!pygpu_stack_is_push_projection_ok_or_error()) {
return NULL;
}
- gpuPushProjectionMatrix();
+ GPU_matrix_push_projection();
Py_RETURN_NONE;
}
@@ -144,7 +144,7 @@ static PyObject *pygpu_matrix_pop_projection(PyObject *UNUSED(self))
if (!pygpu_stack_is_pop_projection_ok_or_error()) {
return NULL;
}
- gpuPopProjectionMatrix();
+ GPU_matrix_pop_projection();
Py_RETURN_NONE;
}
@@ -197,14 +197,14 @@ static PyObject *pygpu_matrix_stack_context_enter(BPy_GPU_MatrixStackContext *se
if (!pygpu_stack_is_push_model_view_ok_or_error()) {
return NULL;
}
- gpuPushMatrix();
+ GPU_matrix_push();
self->level = GPU_matrix_stack_level_get_model_view();
}
else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
if (!pygpu_stack_is_push_projection_ok_or_error()) {
return NULL;
}
- gpuPushProjectionMatrix();
+ GPU_matrix_push_projection();
self->level = GPU_matrix_stack_level_get_projection();
}
else {
@@ -227,7 +227,7 @@ static PyObject *pygpu_matrix_stack_context_exit(BPy_GPU_MatrixStackContext *sel
fprintf(stderr, "Level push/pop mismatch, expected %d, got %d\n", self->level, level);
}
if (level != 0) {
- gpuPopMatrix();
+ GPU_matrix_pop();
}
}
else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
@@ -236,7 +236,7 @@ static PyObject *pygpu_matrix_stack_context_exit(BPy_GPU_MatrixStackContext *sel
fprintf(stderr, "Level push/pop mismatch, expected %d, got %d", self->level, level);
}
if (level != 0) {
- gpuPopProjectionMatrix();
+ GPU_matrix_pop_projection();
}
}
else {
@@ -294,7 +294,7 @@ static PyObject *pygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *
if (!Matrix_Parse4x4(value, &pymat)) {
return NULL;
}
- gpuMultMatrix(pymat->matrix);
+ GPU_matrix_mul(pymat->matrix);
Py_RETURN_NONE;
}
@@ -314,10 +314,10 @@ static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value)
return NULL;
}
if (len == 2) {
- gpuScale2fv(scale);
+ GPU_matrix_scale_2fv(scale);
}
else {
- gpuScale3fv(scale);
+ GPU_matrix_scale_3fv(scale);
}
Py_RETURN_NONE;
}
@@ -337,7 +337,7 @@ static PyObject *pygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *va
Py_TYPE(value)->tp_name);
return NULL;
}
- gpuScaleUniform(scalar);
+ GPU_matrix_scale_1f(scalar);
Py_RETURN_NONE;
}
@@ -357,10 +357,10 @@ static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value)
return NULL;
}
if (len == 2) {
- gpuTranslate2fv(offset);
+ GPU_matrix_translate_2fv(offset);
}
else {
- gpuTranslate3fv(offset);
+ GPU_matrix_translate_3fv(offset);
}
Py_RETURN_NONE;
}
@@ -378,7 +378,7 @@ PyDoc_STRVAR(pygpu_matrix_reset_doc,
);
static PyObject *pygpu_matrix_reset(PyObject *UNUSED(self))
{
- gpuMatrixReset();
+ GPU_matrix_reset();
Py_RETURN_NONE;
}
@@ -389,7 +389,7 @@ PyDoc_STRVAR(pygpu_matrix_load_identity_doc,
);
static PyObject *pygpu_matrix_load_identity(PyObject *UNUSED(self))
{
- gpuLoadIdentity();
+ GPU_matrix_identity_set();
Py_RETURN_NONE;
}
@@ -407,7 +407,7 @@ static PyObject *pygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *valu
if (!Matrix_Parse4x4(value, &pymat)) {
return NULL;
}
- gpuLoadMatrix(pymat->matrix);
+ GPU_matrix_set(pymat->matrix);
Py_RETURN_NONE;
}
@@ -428,7 +428,7 @@ PyDoc_STRVAR(pygpu_matrix_get_projection_matrix_doc,
static PyObject *pygpu_matrix_get_projection_matrix(PyObject *UNUSED(self))
{
float matrix[4][4];
- gpuGetModelViewMatrix(matrix);
+ GPU_matrix_model_view_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
}
@@ -444,7 +444,7 @@ PyDoc_STRVAR(pygpu_matrix_get_modal_view_matrix_doc,
static PyObject *pygpu_matrix_get_modal_view_matrix(PyObject *UNUSED(self))
{
float matrix[4][4];
- gpuGetProjectionMatrix(matrix);
+ GPU_matrix_projection_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
}
@@ -459,7 +459,7 @@ PyDoc_STRVAR(pygpu_matrix_get_normal_matrix_doc,
static PyObject *pygpu_matrix_get_normal_matrix(PyObject *UNUSED(self))
{
float matrix[3][3];
- gpuGetNormalMatrix(matrix);
+ GPU_matrix_normal_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 3, 3, NULL);
}
diff --git a/source/blender/python/intern/gpu_py_select.c b/source/blender/python/intern/gpu_py_select.c
index f570c4cdae2..fcdcce24935 100644
--- a/source/blender/python/intern/gpu_py_select.c
+++ b/source/blender/python/intern/gpu_py_select.c
@@ -23,7 +23,7 @@
*
* This file defines the gpu.select API.
*
- * \note Currently only used for manipulator selection,
+ * \note Currently only used for gizmo selection,
* will need to add begin/end and a way to access the hits.
*/
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 1a6fd0ee86f..48c18dd20c1 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -1100,7 +1100,8 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
{
PyObject *seq = NULL;
double angle = 0.0f;
- float quat[QUAT_SIZE] = {0.0f, 0.0f, 0.0f, 0.0f};
+ float quat[QUAT_SIZE];
+ unit_qt(quat);
if (kwds && PyDict_Size(kwds)) {
PyErr_SetString(PyExc_TypeError,
diff --git a/source/blender/python/rna_dump.py b/source/blender/python/rna_dump.py
index 7259ceb67a0..3c09175910e 100644
--- a/source/blender/python/rna_dump.py
+++ b/source/blender/python/rna_dump.py
@@ -129,6 +129,7 @@ def seek(r, txt, recurs):
newtxt = txt + '[' + str(i) + ']'
seek(r[i], newtxt, recurs + 1)
+
seek(bpy.data, 'bpy.data', 0)
# seek(bpy.types, 'bpy.types', 0)
'''
@@ -140,8 +141,8 @@ for d in dir(bpy.types):
seek(r, 'bpy.types.' + d + '.bl_rna', 0)
'''
-#print dir(bpy)
+# print dir(bpy)
#import sys
-#sys.exit()
+# sys.exit()
print("iter over ", seek_count, "rna items")
diff --git a/source/blender/python/simple_enum_gen.py b/source/blender/python/simple_enum_gen.py
index 95052ccae0c..3a9c1847fc7 100644
--- a/source/blender/python/simple_enum_gen.py
+++ b/source/blender/python/simple_enum_gen.py
@@ -1,22 +1,22 @@
- # ***** BEGIN GPL LICENSE BLOCK *****
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License
- # as published by the Free Software Foundation; either version 2
- # of the License, or (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software Foundation,
- # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- #
- # Contributor(s): Campbell Barton
- #
- # #**** END GPL LICENSE BLOCK #****
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+# <pep8 compliant>
defs = """
SPACE_EMPTY,
@@ -50,8 +50,10 @@ for d in defs.split('\n'):
if not w:
continue
- try: w.remove("#define")
- except: pass
+ try:
+ w.remove("#define")
+ except:
+ pass
# print w
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index d3fef51e9e9..8f921d7850a 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -37,6 +37,7 @@ set(INC
../nodes
../physics
../draw
+ ../gpu
../../../intern/atomic
../../../intern/guardedalloc
../../../intern/mikktspace
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index cb32efb0b0f..df8953857ee 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -315,7 +315,7 @@ void RE_current_scene_update_cb(struct Render *re, void *handle, void (*f)(void
void RE_gl_context_create(Render *re);
void RE_gl_context_destroy(Render *re);
void *RE_gl_context_get(Render *re);
-void *RE_gwn_context_get(Render *re);
+void *RE_gpu_context_get(Render *re);
/* should move to kernel once... still unsure on how/where */
float RE_filter_value(int type, float x);
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 117b82570e7..5d5d12f028a 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -160,7 +160,7 @@ struct Render {
/* TODO replace by a whole draw manager. */
void *gl_context;
- void *gwn_context;
+ void *gpu_context;
};
/* **************** defines ********************* */
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 1e9ad79e599..3a31413c5cd 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -873,29 +873,25 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl
static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
{
if (tex->imaflag & TEX_MIPMAP) {
- if ((ibuf->flags & IB_fields) == 0) {
-
- if (ibuf->mipmap[0] && (ibuf->userflags & IB_MIPMAP_INVALID)) {
- BLI_thread_lock(LOCK_IMAGE);
- if (ibuf->userflags & IB_MIPMAP_INVALID) {
- IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
- ibuf->userflags &= ~IB_MIPMAP_INVALID;
- }
- BLI_thread_unlock(LOCK_IMAGE);
- }
- if (ibuf->mipmap[0] == NULL) {
- BLI_thread_lock(LOCK_IMAGE);
- if (ibuf->mipmap[0] == NULL)
- IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
- BLI_thread_unlock(LOCK_IMAGE);
- }
- /* if no mipmap could be made, fall back on non-mipmap render */
- if (ibuf->mipmap[0] == NULL) {
- tex->imaflag &= ~TEX_MIPMAP;
+ if (ibuf->mipmap[0] && (ibuf->userflags & IB_MIPMAP_INVALID)) {
+ BLI_thread_lock(LOCK_IMAGE);
+ if (ibuf->userflags & IB_MIPMAP_INVALID) {
+ IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
+ ibuf->userflags &= ~IB_MIPMAP_INVALID;
}
+ BLI_thread_unlock(LOCK_IMAGE);
+ }
+ if (ibuf->mipmap[0] == NULL) {
+ BLI_thread_lock(LOCK_IMAGE);
+ if (ibuf->mipmap[0] == NULL)
+ IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
+ BLI_thread_unlock(LOCK_IMAGE);
+ }
+ /* if no mipmap could be made, fall back on non-mipmap render */
+ if (ibuf->mipmap[0] == NULL) {
+ tex->imaflag &= ~TEX_MIPMAP;
}
}
-
}
static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], float dxt[2], float dyt[2], TexResult *texres, struct ImagePool *pool, const bool skip_load_image)
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 361324bf07c..510a4aa4685 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -64,6 +64,7 @@
#include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */
#include "BKE_camera.h"
#include "BKE_colortools.h"
+#include "BKE_context.h" /* XXX needed by wm_window.h */
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_layer.h"
@@ -95,7 +96,8 @@
#include "RE_render_ext.h"
#include "../../../windowmanager/WM_api.h" /* XXX */
-#include "../../../intern/gawain/gawain/gwn_context.h"
+#include "../../../windowmanager/wm_window.h" /* XXX */
+#include "GPU_context.h"
#ifdef WITH_FREESTYLE
# include "FRS_freestyle.h"
@@ -1034,15 +1036,17 @@ void RE_gl_context_create(Render *re)
{
/* Needs to be created in the main ogl thread. */
re->gl_context = WM_opengl_context_create();
+ /* So we activate the window's one afterwards. */
+ wm_window_reset_drawable();
}
void RE_gl_context_destroy(Render *re)
{
/* Needs to be called from the thread which used the ogl context for rendering. */
- if (re->gwn_context) {
- GWN_context_active_set(re->gwn_context);
- GWN_context_discard(re->gwn_context);
- re->gwn_context = NULL;
+ if (re->gpu_context) {
+ GPU_context_active_set(re->gpu_context);
+ GPU_context_discard(re->gpu_context);
+ re->gpu_context = NULL;
}
if (re->gl_context) {
WM_opengl_context_dispose(re->gl_context);
@@ -1055,12 +1059,12 @@ void *RE_gl_context_get(Render *re)
return re->gl_context;
}
-void *RE_gwn_context_get(Render *re)
+void *RE_gpu_context_get(Render *re)
{
- if (re->gwn_context == NULL) {
- re->gwn_context = GWN_context_create();
+ if (re->gpu_context == NULL) {
+ re->gpu_context = GPU_context_create();
}
- return re->gwn_context;
+ return re->gpu_context;
}
/* ********* add object data (later) ******** */
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index 8fc46b6ce3f..edf76364503 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -25,8 +25,8 @@
set(INC
.
- manipulators
- manipulators/intern
+ gizmo
+ gizmo/intern
../blenfont
../blenkernel
../blenlib
@@ -56,7 +56,6 @@ set(INC_SYS
set(SRC
intern/wm.c
- intern/wm_playanim.c
intern/wm_cursors.c
intern/wm_dragdrop.c
intern/wm_draw.c
@@ -68,19 +67,24 @@ set(SRC
intern/wm_init_exit.c
intern/wm_jobs.c
intern/wm_keymap.c
+ intern/wm_menu_type.c
intern/wm_operator_props.c
+ intern/wm_operator_type.c
intern/wm_operators.c
- intern/wm_subwindow.c
- intern/wm_window.c
+ intern/wm_panel_type.c
+ intern/wm_playanim.c
intern/wm_stereo.c
+ intern/wm_subwindow.c
intern/wm_toolsystem.c
intern/wm_tooltip.c
- manipulators/intern/wm_manipulator.c
- manipulators/intern/wm_manipulator_group.c
- manipulators/intern/wm_manipulator_group_type.c
- manipulators/intern/wm_manipulator_map.c
- manipulators/intern/wm_manipulator_target_props.c
- manipulators/intern/wm_manipulator_type.c
+ intern/wm_uilist_type.c
+ intern/wm_window.c
+ gizmo/intern/wm_gizmo.c
+ gizmo/intern/wm_gizmo_group.c
+ gizmo/intern/wm_gizmo_group_type.c
+ gizmo/intern/wm_gizmo_map.c
+ gizmo/intern/wm_gizmo_target_props.c
+ gizmo/intern/wm_gizmo_type.c
message_bus/intern/wm_message_bus.c
message_bus/intern/wm_message_bus_rna.c
message_bus/intern/wm_message_bus_static.c
@@ -96,11 +100,11 @@ set(SRC
wm_event_types.h
wm_files.h
wm_window.h
- manipulators/WM_manipulator_api.h
- manipulators/WM_manipulator_types.h
- manipulators/wm_manipulator_fn.h
- manipulators/wm_manipulator_wmapi.h
- manipulators/intern/wm_manipulator_intern.h
+ gizmo/WM_gizmo_api.h
+ gizmo/WM_gizmo_types.h
+ gizmo/wm_gizmo_fn.h
+ gizmo/wm_gizmo_wmapi.h
+ gizmo/intern/wm_gizmo_intern.h
message_bus/intern/wm_message_bus_intern.h
message_bus/wm_message_bus.h
)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 3d1ee273108..67ca5f8a08a 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -77,9 +77,9 @@ struct wmNDOFMotionData;
#endif
typedef struct wmJob wmJob;
-typedef struct wmManipulator wmManipulator;
-typedef struct wmManipulatorMap wmManipulatorMap;
-typedef struct wmManipulatorMapType wmManipulatorMapType;
+typedef struct wmGizmo wmGizmo;
+typedef struct wmGizmoMap wmGizmoMap;
+typedef struct wmGizmoMapType wmGizmoMapType;
/* general API */
void WM_init_state_size_set (int stax, int stay, int sizx, int sizy);
@@ -111,18 +111,19 @@ struct Scene *WM_windows_scene_get_from_screen(const struct wmWindowManager *wm,
struct WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
struct Scene *WM_window_get_active_scene(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void WM_window_change_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win,
- struct Scene *scene_new) ATTR_NONNULL();
+void WM_window_set_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win,
+ struct Scene *scene_new) ATTR_NONNULL();
struct WorkSpace *WM_window_get_active_workspace(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void WM_window_set_active_workspace(struct wmWindow *win, struct WorkSpace *workspace) ATTR_NONNULL(1);
+void WM_window_set_active_workspace(struct bContext *C, struct wmWindow *win, struct WorkSpace *workspace) ATTR_NONNULL(1);
struct WorkSpaceLayout *WM_window_get_active_layout(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
void WM_window_set_active_layout(
struct wmWindow *win, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL(1);
struct bScreen *WM_window_get_active_screen(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
void WM_window_set_active_screen(struct wmWindow *win, struct WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL(1);
-struct ViewLayer *WM_window_get_active_view_layer_ex(const struct wmWindow *win, struct Scene **r_scene) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
struct ViewLayer *WM_window_get_active_view_layer(const struct wmWindow *win) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
+void WM_window_set_active_view_layer(struct wmWindow *win, struct ViewLayer *view_layer) ATTR_NONNULL(1);
+void WM_window_ensure_active_view_layer(struct wmWindow *win) ATTR_NONNULL(1);
bool WM_window_is_temp_screen(const struct wmWindow *win) ATTR_WARN_UNUSED_RESULT;
@@ -306,27 +307,6 @@ void WM_operator_type_set(struct wmOperator *op, struct wmOperatorType *ot);
void WM_operator_stack_clear(struct wmWindowManager *wm);
void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot);
-struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet);
-void WM_operatortype_iter(struct GHashIterator *ghi);
-void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *));
-void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
-void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
-void WM_operatortype_remove_ptr(struct wmOperatorType *ot);
-bool WM_operatortype_remove(const char *idname);
-void WM_operatortype_last_properties_clear_all(void);
-void WM_operatortype_props_advanced_begin(struct wmOperatorType *ot);
-void WM_operatortype_props_advanced_end(struct wmOperatorType *ot);
-
-#define WM_operatortype_prop_tag(property, tags) \
- { \
- CHECK_TYPE(tags, eOperatorPropTags); \
- RNA_def_property_tags(prop, tags); \
- } (void)0
-
-struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag);
-struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname);
-
-
bool WM_operator_poll (struct bContext *C, struct wmOperatorType *ot);
bool WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context);
int WM_operator_call_ex(struct bContext *C, struct wmOperator *op, const bool store);
@@ -425,14 +405,35 @@ void WM_operator_py_idname(char *to, const char *from);
bool WM_operator_py_idname_ok_or_report(struct ReportList *reports, const char *classname, const char *idname);
const char *WM_context_member_from_ptr(struct bContext *C, const struct PointerRNA *ptr);
-/* *************** uilist types ******************** */
+/* wm_operator_type.c */
+struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet);
+void WM_operatortype_iter(struct GHashIterator *ghi);
+void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *));
+void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
+void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
+void WM_operatortype_remove_ptr(struct wmOperatorType *ot);
+bool WM_operatortype_remove(const char *idname);
+void WM_operatortype_last_properties_clear_all(void);
+void WM_operatortype_props_advanced_begin(struct wmOperatorType *ot);
+void WM_operatortype_props_advanced_end(struct wmOperatorType *ot);
+
+#define WM_operatortype_prop_tag(property, tags) \
+ { \
+ CHECK_TYPE(tags, eOperatorPropTags); \
+ RNA_def_property_tags(prop, tags); \
+ } (void)0
+
+struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag);
+struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname);
+
+/* wm_uilist_type.c */
void WM_uilisttype_init(void);
struct uiListType *WM_uilisttype_find(const char *idname, bool quiet);
bool WM_uilisttype_add(struct uiListType *ult);
void WM_uilisttype_freelink(struct uiListType *ult);
void WM_uilisttype_free(void);
-/* *************** menu types ******************** */
+/* wm_menu_type.c */
void WM_menutype_init(void);
struct MenuType *WM_menutype_find(const char *idname, bool quiet);
bool WM_menutype_add(struct MenuType *mt);
@@ -440,6 +441,13 @@ void WM_menutype_freelink(struct MenuType *mt);
void WM_menutype_free(void);
bool WM_menutype_poll(struct bContext *C, struct MenuType *mt);
+/* wm_panel_type.c */
+void WM_paneltype_init(void);
+void WM_paneltype_clear(void);
+struct PanelType *WM_paneltype_find(const char *idname, bool quiet);
+bool WM_paneltype_add(struct PanelType *mt);
+void WM_paneltype_remove(struct PanelType *mt);
+
/* wm_gesture_ops.c */
int WM_gesture_border_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_gesture_border_modal (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
@@ -523,6 +531,7 @@ enum {
WM_JOB_TYPE_ALEMBIC,
WM_JOB_TYPE_SHADER_COMPILATION,
WM_JOB_TYPE_STUDIOLIGHT,
+ WM_JOB_TYPE_LIGHT_BAKE,
/* add as needed, screencast, seq proxy build
* if having hard coded values is a problem */
};
@@ -607,6 +616,12 @@ bool WM_event_is_ime_switch(const struct wmEvent *event);
const char *WM_window_cursor_keymap_status_get(const struct wmWindow *win, int button_index, int type_index);
void WM_window_cursor_keymap_status_refresh(struct bContext *C, struct wmWindow *win);
+void WM_window_status_area_tag_redraw(struct wmWindow *win);
+struct ScrArea *WM_window_status_area_find(struct wmWindow *win, struct bScreen *sc);
+bool WM_window_modal_keymap_status_draw(
+ struct bContext *C, struct wmWindow *win,
+ struct uiLayout *layout);
+
/* wm_tooltip.c */
typedef struct ARegion *(*wmTooltipInitFn)(struct bContext *, struct ARegion *, bool *);
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index d1f6d268835..547028c88f9 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -66,6 +66,7 @@ wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, in
int val, int modifier, int keymodifier);
wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap, const char *idname, int type,
int val, int modifier, int keymodifier);
+wmKeyMapItem *WM_keymap_add_panel(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
wmKeyMapItem *WM_keymap_add_tool(struct wmKeyMap *keymap, const char *idname, int type,
int val, int modifier, int keymodifier);
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index 30470e17ed4..f4505bef962 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -73,11 +73,9 @@ void WM_toolsystem_ref_set_from_runtime(
void WM_toolsystem_init(struct bContext *C);
int WM_toolsystem_mode_from_spacetype(
- struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa,
- int space_type);
+ struct ViewLayer *view_layer, struct ScrArea *sa, int space_type);
bool WM_toolsystem_key_from_context(
- struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa,
- bToolKey *tkey);
+ struct ViewLayer *view_layer, struct ScrArea *sa, bToolKey *tkey);
void WM_toolsystem_update_from_context(
struct bContext *C,
struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa);
@@ -95,7 +93,7 @@ void WM_toolsystem_ref_properties_ensure(struct bToolRef *tref, struct wmOperato
void WM_toolsystem_ref_properties_init_for_keymap(
struct bToolRef *tref, struct PointerRNA *dst_ptr, struct PointerRNA *src_ptr, struct wmOperatorType *ot);
-void WM_toolsystem_refresh_screen_area(struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa);
+void WM_toolsystem_refresh_screen_area(struct WorkSpace *workspace, struct ViewLayer *view_layer, struct ScrArea *sa);
void WM_toolsystem_refresh_screen_all(struct Main *bmain);
#ifdef __cplusplus
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 8e05822dd55..a5536dbd652 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -121,10 +121,10 @@ struct ImBuf;
/* exported types for WM */
#include "wm_cursors.h"
#include "wm_event_types.h"
-#include "manipulators/WM_manipulator_types.h"
+#include "gizmo/WM_gizmo_types.h"
-/* Include external manipulator API's */
-#include "manipulators/WM_manipulator_api.h"
+/* Include external gizmo API's */
+#include "gizmo/WM_gizmo_api.h"
/* ************** wmOperatorType ************************ */
@@ -257,6 +257,7 @@ typedef struct wmNotifier {
#define NC_GPENCIL (22<<24)
#define NC_LINESTYLE (23<<24)
#define NC_CAMERA (24<<24)
+#define NC_LIGHTPROBE (25<<24)
/* data type, 256 entries is enough, it can overlap */
#define NOTE_DATA 0x00FF0000
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
new file mode 100644
index 00000000000..9b8cecfb4bc
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
@@ -0,0 +1,343 @@
+/*
+ * ***** 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/windowmanager/gizmo/WM_gizmo_api.h
+ * \ingroup wm
+ *
+ * \name Gizmo API
+ * \brief API for external use of wmGizmo types.
+ *
+ * Only included in WM_api.h
+ */
+
+
+#ifndef __WM_GIZMO_API_H__
+#define __WM_GIZMO_API_H__
+
+struct ARegion;
+struct GHashIterator;
+struct IDProperty;
+struct Main;
+struct PropertyRNA;
+struct wmKeyConfig;
+struct wmGizmo;
+struct wmGizmoProperty;
+struct wmGizmoPropertyType;
+struct wmGizmoType;
+struct wmGizmoGroup;
+struct wmGizmoGroupType;
+struct wmGizmoMap;
+struct wmGizmoMapType;
+struct wmGizmoMapType_Params;
+struct wmMsgSubscribeKey;
+struct wmMsgSubscribeValue;
+
+#include "wm_gizmo_fn.h"
+
+/* -------------------------------------------------------------------- */
+/* wmGizmo */
+
+struct wmGizmo *WM_gizmo_new_ptr(
+ const struct wmGizmoType *gzt, struct wmGizmoGroup *gzgroup,
+ struct PointerRNA *properties);
+struct wmGizmo *WM_gizmo_new(
+ const char *idname, struct wmGizmoGroup *gzgroup,
+ struct PointerRNA *properties);
+void WM_gizmo_free(struct wmGizmo *gz);
+void WM_gizmo_unlink(
+ ListBase *gizmolist, struct wmGizmoMap *gzmap, struct wmGizmo *gz,
+ struct bContext *C);
+
+void WM_gizmo_name_set(struct wmGizmoGroup *gzgroup, struct wmGizmo *gz, const char *name);
+
+bool WM_gizmo_select_unlink(struct wmGizmoMap *gzmap, struct wmGizmo *gz);
+bool WM_gizmo_select_set(struct wmGizmoMap *gzmap, struct wmGizmo *gz, bool select);
+void WM_gizmo_highlight_set(struct wmGizmoMap *gzmap, struct wmGizmo *gz);
+
+void WM_gizmo_modal_set_from_setup(
+ struct wmGizmoMap *gzmap, struct bContext *C,
+ struct wmGizmo *gz, int part_index, const struct wmEvent *event);
+
+struct wmGizmoOpElem *WM_gizmo_operator_get(
+ struct wmGizmo *gz, int part_index);
+struct PointerRNA *WM_gizmo_operator_set(
+ struct wmGizmo *gz, int part_index,
+ struct wmOperatorType *ot, struct IDProperty *properties);
+
+/* callbacks */
+void WM_gizmo_set_fn_custom_modal(struct wmGizmo *gz, wmGizmoFnModal fn);
+
+void WM_gizmo_set_matrix_location(
+ struct wmGizmo *gz, const float origin[3]);
+void WM_gizmo_set_matrix_rotation_from_z_axis(
+ struct wmGizmo *gz, const float z_axis[3]);
+void WM_gizmo_set_matrix_rotation_from_yz_axis(
+ struct wmGizmo *gz, const float y_axis[3], const float z_axis[3]);
+
+void WM_gizmo_set_matrix_offset_location(
+ struct wmGizmo *gz, const float origin[3]);
+void WM_gizmo_set_matrix_offset_rotation_from_z_axis(
+ struct wmGizmo *gz, const float z_axis[3]);
+void WM_gizmo_set_matrix_offset_rotation_from_yz_axis(
+ struct wmGizmo *gz, const float y_axis[3], const float z_axis[3]);
+
+void WM_gizmo_set_flag(struct wmGizmo *gz, const int flag, const bool enable);
+void WM_gizmo_set_scale(struct wmGizmo *gz, float scale);
+void WM_gizmo_set_line_width(struct wmGizmo *gz, const float line_width);
+
+void WM_gizmo_get_color(const struct wmGizmo *gz, float color[4]);
+void WM_gizmo_set_color(struct wmGizmo *gz, const float color[4]);
+void WM_gizmo_get_color_highlight(const struct wmGizmo *gz, float color_hi[4]);
+void WM_gizmo_set_color_highlight(struct wmGizmo *gz, const float color[4]);
+
+/**
+ * Leaving values NULL use values from #wmGizmo.
+ */
+struct WM_GizmoMatrixParams {
+ const float(*matrix_space)[4];
+ const float(*matrix_basis)[4];
+ const float(*matrix_offset)[4];
+ const float *scale_final;
+};
+
+void WM_gizmo_calc_matrix_final_params(
+ const struct wmGizmo *gz, const struct WM_GizmoMatrixParams *params,
+ float r_mat[4][4]);
+void WM_gizmo_calc_matrix_final_no_offset(
+ const struct wmGizmo *gz, float r_mat[4][4]);
+
+void WM_gizmo_calc_matrix_final(
+ const struct wmGizmo *gz, float r_mat[4][4]);
+
+/* properties */
+void WM_gizmo_properties_create_ptr(struct PointerRNA *ptr, struct wmGizmoType *gzt);
+void WM_gizmo_properties_create(struct PointerRNA *ptr, const char *opstring);
+void WM_gizmo_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring);
+void WM_gizmo_properties_sanitize(struct PointerRNA *ptr, const bool no_context);
+bool WM_gizmo_properties_default(struct PointerRNA *ptr, const bool do_update);
+void WM_gizmo_properties_reset(struct wmGizmo *op);
+void WM_gizmo_properties_clear(struct PointerRNA *ptr);
+void WM_gizmo_properties_free(struct PointerRNA *ptr);
+
+
+/* wm_gizmo_type.c */
+const struct wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet);
+void WM_gizmotype_append(void (*wtfunc)(struct wmGizmoType *));
+void WM_gizmotype_append_ptr(void (*mnpfunc)(struct wmGizmoType *, void *), void *userdata);
+bool WM_gizmotype_remove(struct bContext *C, struct Main *bmain, const char *idname);
+void WM_gizmotype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmGizmoType *gzt);
+void WM_gizmotype_iter(struct GHashIterator *ghi);
+
+/* wm_gizmo_group_type.c */
+struct wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet);
+struct wmGizmoGroupType *WM_gizmogrouptype_append(void (*wtfunc)(struct wmGizmoGroupType *));
+struct wmGizmoGroupType *WM_gizmogrouptype_append_ptr(void (*mnpfunc)(struct wmGizmoGroupType *, void *), void *userdata);
+bool WM_gizmogrouptype_free(const char *idname);
+void WM_gizmogrouptype_free_ptr(struct wmGizmoGroupType *wt);
+void WM_gizmogrouptype_iter(struct GHashIterator *ghi);
+
+struct wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link(
+ struct wmGizmoMapType *gzmap_type,
+ void (*wtfunc)(struct wmGizmoGroupType *));
+
+/* wm_gizmo_map.c */
+
+/* Dynamic Updates (for RNA runtime registration) */
+void WM_gizmoconfig_update_tag_init(struct wmGizmoMapType *gzmap_type, struct wmGizmoGroupType *gzgt);
+void WM_gizmoconfig_update_tag_remove(struct wmGizmoMapType *gzmap_type, struct wmGizmoGroupType *gzgt);
+void WM_gizmoconfig_update(struct Main *bmain);
+
+
+/* wm_maniulator_target_props.c */
+struct wmGizmoProperty *WM_gizmo_target_property_array(struct wmGizmo *gz);
+struct wmGizmoProperty *WM_gizmo_target_property_at_index(
+ struct wmGizmo *gz, int index);
+struct wmGizmoProperty *WM_gizmo_target_property_find(
+ struct wmGizmo *gz, const char *idname);
+
+void WM_gizmo_target_property_def_rna_ptr(
+ struct wmGizmo *gz, const struct wmGizmoPropertyType *gz_prop_type,
+ struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
+void WM_gizmo_target_property_def_rna(
+ struct wmGizmo *gz, const char *idname,
+ struct PointerRNA *ptr, const char *propname, int index);
+
+void WM_gizmo_target_property_def_func_ptr(
+ struct wmGizmo *gz, const struct wmGizmoPropertyType *gz_prop_type,
+ const struct wmGizmoPropertyFnParams *params);
+void WM_gizmo_target_property_def_func(
+ struct wmGizmo *gz, const char *idname,
+ const struct wmGizmoPropertyFnParams *params);
+
+void WM_gizmo_target_property_clear_rna_ptr(
+ struct wmGizmo *gz, const struct wmGizmoPropertyType *gz_prop_type);
+void WM_gizmo_target_property_clear_rna(
+ struct wmGizmo *gz, const char *idname);
+
+bool WM_gizmo_target_property_is_valid_any(struct wmGizmo *gz);
+bool WM_gizmo_target_property_is_valid(
+ const struct wmGizmoProperty *gz_prop);
+float WM_gizmo_target_property_value_get(
+ const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop);
+void WM_gizmo_target_property_value_set(
+ struct bContext *C, const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop,
+ const float value);
+
+void WM_gizmo_target_property_value_get_array(
+ const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop,
+ float *value);
+void WM_gizmo_target_property_value_set_array(
+ struct bContext *C, const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop,
+ const float *value);
+
+bool WM_gizmo_target_property_range_get(
+ const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop,
+ float range[2]);
+
+int WM_gizmo_target_property_array_length(
+ const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop);
+
+/* definitions */
+const struct wmGizmoPropertyType *WM_gizmotype_target_property_find(
+ const struct wmGizmoType *gzt, const char *idname);
+void WM_gizmotype_target_property_def(
+ struct wmGizmoType *gzt, const char *idname, int data_type, int array_length);
+
+/* utilities */
+void WM_gizmo_do_msg_notify_tag_refresh(
+ struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val);
+void WM_gizmo_target_property_subscribe_all(
+ struct wmGizmo *gz, struct wmMsgBus *mbus, struct ARegion *ar);
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoGroup */
+
+/* Callbacks for 'wmGizmoGroupType.setup_keymap' */
+struct wmKeyMap *WM_gizmogroup_keymap_common(
+ const struct wmGizmoGroupType *gzgt, struct wmKeyConfig *config);
+struct wmKeyMap *WM_gizmogroup_keymap_common_select(
+ const struct wmGizmoGroupType *gzgt, struct wmKeyConfig *config);
+
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoMap */
+
+struct wmGizmoMap *WM_gizmomap_new_from_type(
+ const struct wmGizmoMapType_Params *gzmap_params);
+const struct ListBase *WM_gizmomap_group_list(struct wmGizmoMap *gzmap);
+struct wmGizmoGroup *WM_gizmomap_group_find(
+ struct wmGizmoMap *gzmap,
+ const char *idname);
+struct wmGizmoGroup *WM_gizmomap_group_find_ptr(
+ struct wmGizmoMap *gzmap,
+ const struct wmGizmoGroupType *gzgt);
+void WM_gizmomap_tag_refresh(struct wmGizmoMap *gzmap);
+void WM_gizmomap_draw(
+ struct wmGizmoMap *gzmap, const struct bContext *C, const eWM_GizmoFlagMapDrawStep drawstep);
+void WM_gizmomap_add_handlers(struct ARegion *ar, struct wmGizmoMap *gzmap);
+bool WM_gizmomap_select_all(struct bContext *C, struct wmGizmoMap *gzmap, const int action);
+bool WM_gizmomap_cursor_set(const struct wmGizmoMap *gzmap, struct wmWindow *win);
+void WM_gizmomap_message_subscribe(
+ struct bContext *C, struct wmGizmoMap *gzmap, struct ARegion *ar, struct wmMsgBus *mbus);
+bool WM_gizmomap_is_any_selected(const struct wmGizmoMap *gzmap);
+bool WM_gizmomap_minmax(
+ const struct wmGizmoMap *gzmap, bool use_hidden, bool use_select,
+ float r_min[3], float r_max[3]);
+
+struct ARegion *WM_gizmomap_tooltip_init(
+ struct bContext *C, struct ARegion *ar, bool *r_exit_on_event);
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoMapType */
+
+struct wmGizmoMapType *WM_gizmomaptype_find(
+ const struct wmGizmoMapType_Params *gzmap_params);
+struct wmGizmoMapType *WM_gizmomaptype_ensure(
+ const struct wmGizmoMapType_Params *gzmap_params);
+
+struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(
+ struct wmGizmoMapType *gzmap_type,
+ const char *idname);
+struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr(
+ struct wmGizmoMapType *gzmap_type,
+ const struct wmGizmoGroupType *gzgt);
+struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_link(
+ struct wmGizmoMapType *gzmap_type,
+ const char *idname);
+struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr(
+ struct wmGizmoMapType *gzmap_type,
+ struct wmGizmoGroupType *gzgt);
+
+void WM_gizmomaptype_group_init_runtime_keymap(
+ const struct Main *bmain,
+ struct wmGizmoGroupType *gzgt);
+void WM_gizmomaptype_group_init_runtime(
+ const struct Main *bmain, struct wmGizmoMapType *gzmap_type,
+ struct wmGizmoGroupType *gzgt);
+void WM_gizmomaptype_group_unlink(
+ struct bContext *C, struct Main *bmain, struct wmGizmoMapType *gzmap_type,
+ const struct wmGizmoGroupType *gzgt);
+
+void WM_gizmomaptype_group_free(struct wmGizmoGroupTypeRef *gzgt);
+
+/* -------------------------------------------------------------------- */
+/* GizmoGroup */
+
+/* Add/Ensure/Remove (High level API) */
+
+void WM_gizmo_group_type_add_ptr_ex(
+ struct wmGizmoGroupType *gzgt,
+ struct wmGizmoMapType *gzmap_type);
+void WM_gizmo_group_type_add_ptr(
+ struct wmGizmoGroupType *gzgt);
+void WM_gizmo_group_type_add(const char *idname);
+
+void WM_gizmo_group_type_ensure_ptr_ex(
+ struct wmGizmoGroupType *gzgt,
+ struct wmGizmoMapType *gzmap_type);
+void WM_gizmo_group_type_ensure_ptr(
+ struct wmGizmoGroupType *gzgt);
+void WM_gizmo_group_type_ensure(const char *idname);
+
+void WM_gizmo_group_type_remove_ptr_ex(
+ struct Main *bmain, struct wmGizmoGroupType *gzgt,
+ struct wmGizmoMapType *gzmap_type);
+void WM_gizmo_group_type_remove_ptr(
+ struct Main *bmain, struct wmGizmoGroupType *gzgt);
+void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname);
+
+void WM_gizmo_group_type_unlink_delayed_ptr_ex(
+ struct wmGizmoGroupType *gzgt,
+ struct wmGizmoMapType *gzmap_type);
+void WM_gizmo_group_type_unlink_delayed_ptr(
+ struct wmGizmoGroupType *gzgt);
+void WM_gizmo_group_type_unlink_delayed(const char *idname);
+
+/* Utilities */
+bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step);
+
+bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *gzgt);
+
+#endif /* __WM_GIZMO_API_H__ */
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
new file mode 100644
index 00000000000..2339523db5e
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
@@ -0,0 +1,422 @@
+/*
+ * ***** 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/windowmanager/gizmo/WM_gizmo_types.h
+ * \ingroup wm
+ *
+ * \name Gizmo Types
+ * \brief Gizmo defines for external use.
+ *
+ * Only included in WM_types.h and lower level files.
+ */
+
+
+#ifndef __WM_GIZMO_TYPES_H__
+#define __WM_GIZMO_TYPES_H__
+
+#include "BLI_compiler_attrs.h"
+
+struct wmGizmoMapType;
+struct wmGizmoGroupType;
+struct wmGizmoGroup;
+struct wmGizmo;
+struct wmGizmoProperty;
+struct wmKeyConfig;
+
+#include "DNA_listBase.h"
+
+
+/* -------------------------------------------------------------------- */
+/* Enum Typedef's */
+
+
+/**
+ * #wmGizmo.state
+ */
+typedef enum eWM_GizmoFlagState {
+ WM_GIZMO_STATE_HIGHLIGHT = (1 << 0), /* while hovered */
+ WM_GIZMO_STATE_MODAL = (1 << 1), /* while dragging */
+ WM_GIZMO_STATE_SELECT = (1 << 2),
+} eWM_GizmoFlagState;
+
+
+/**
+ * #wmGizmo.flag
+ * Flags for individual gizmos.
+ */
+typedef enum eWM_GizmoFlagFlag {
+ WM_GIZMO_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */
+ WM_GIZMO_DRAW_MODAL = (1 << 1), /* draw while dragging */
+ WM_GIZMO_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */
+ WM_GIZMO_HIDDEN = (1 << 3),
+ /**
+ * When set 'scale_final' value also scales the offset.
+ * Use when offset is to avoid screen-space overlap instead of absolute positioning. */
+ WM_GIZMO_DRAW_OFFSET_SCALE = (1 << 4),
+ /**
+ * User should still use 'scale_final' for any handles and UI elements.
+ * This simply skips scale when calculating the final matrix.
+ * Needed when the gizmo needs to align with the interface underneath it. */
+ WM_GIZMO_DRAW_NO_SCALE = (1 << 5),
+ /**
+ * Hide the cursor and lock it's position while interacting with this gizmo.
+ */
+ WM_GIZMO_GRAB_CURSOR = (1 << 6),
+ /** Don't write into the depth buffer when selecting. */
+ WM_GIZMO_SELECT_BACKGROUND = (1 << 7),
+} eWM_GizmoFlagFlag;
+
+/**
+ * #wmGizmoGroupType.flag
+ * Flags that influence the behavior of all gizmos in the group.
+ */
+typedef enum eWM_GizmoFlagGroupTypeFlag {
+ /* Mark gizmo-group as being 3D */
+ WM_GIZMOGROUPTYPE_3D = (1 << 0),
+ /* Scale gizmos as 3D object that respects zoom (otherwise zoom independent draw size).
+ * note: currently only for 3D views, 2D support needs adding. */
+ WM_GIZMOGROUPTYPE_SCALE = (1 << 1),
+ /* Gizmos can be depth culled with scene objects (covered by other geometry - TODO) */
+ WM_GIZMOGROUPTYPE_DEPTH_3D = (1 << 2),
+ /* Gizmos can be selected */
+ WM_GIZMOGROUPTYPE_SELECT = (1 << 3),
+ /* The gizmo group is to be kept (not removed on loading a new file for eg). */
+ WM_GIZMOGROUPTYPE_PERSISTENT = (1 << 4),
+ /* Show all other gizmos when interacting. */
+ WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL = (1 << 5),
+} eWM_GizmoFlagGroupTypeFlag;
+
+
+/**
+ * #wmGizmoGroup.init_flag
+ */
+typedef enum eWM_GizmoFlagGroupInitFlag {
+ /* mgroup has been initialized */
+ WM_GIZMOGROUP_INIT_SETUP = (1 << 0),
+ WM_GIZMOGROUP_INIT_REFRESH = (1 << 1),
+} eWM_GizmoFlagGroupInitFlag;
+
+/**
+ * #wmGizmoMapType.type_update_flag
+ * Gizmo-map type update flag
+ */
+typedef enum eWM_GizmoFlagMapTypeUpdateFlag {
+ /* A new type has been added, needs to be initialized for all views. */
+ WM_GIZMOMAPTYPE_UPDATE_INIT = (1 << 0),
+ WM_GIZMOMAPTYPE_UPDATE_REMOVE = (1 << 1),
+
+ /* Needed because keymap may be registered before and after window initialization.
+ * So we need to keep track of keymap initialization separately. */
+ WM_GIZMOMAPTYPE_KEYMAP_INIT = (1 << 2),
+} eWM_GizmoFlagMapTypeUpdateFlag;
+
+/* -------------------------------------------------------------------- */
+/* wmGizmo */
+
+/**
+ * \brief Gizmo tweak flag.
+ * Bitflag passed to gizmo while tweaking.
+ *
+ * \note Gizmos are responsible for handling this #wmGizmo.modal callback!.
+ */
+typedef enum {
+ /* Drag with extra precision (Shift). */
+ WM_GIZMO_TWEAK_PRECISE = (1 << 0),
+ /* Drag with snap enabled (Ctrl). */
+ WM_GIZMO_TWEAK_SNAP = (1 << 1),
+} eWM_GizmoFlagTweak;
+
+#include "wm_gizmo_fn.h"
+
+typedef struct wmGizmoOpElem {
+ struct wmOperatorType *type;
+ /* operator properties if gizmo spawns and controls an operator,
+ * or owner pointer if gizmo spawns and controls a property */
+ PointerRNA ptr;
+
+ bool is_redo;
+} wmGizmoOpElem;
+
+/* gizmos are set per region by registering them on gizmo-maps */
+struct wmGizmo {
+ struct wmGizmo *next, *prev;
+
+ /* While we don't have a real type, use this to put type-like vars. */
+ const struct wmGizmoType *type;
+
+ /* Overrides 'type->modal' when set.
+ * Note that this is a workaround, remove if we can. */
+ wmGizmoFnModal custom_modal;
+
+ /* pointer back to group this gizmo is in (just for quick access) */
+ struct wmGizmoGroup *parent_gzgroup;
+
+ void *py_instance;
+
+ /* rna pointer to access properties */
+ struct PointerRNA *ptr;
+
+ /* flags that influence the behavior or how the gizmos are drawn */
+ eWM_GizmoFlagFlag flag;
+ /* state flags (active, highlighted, selected) */
+ eWM_GizmoFlagState state;
+
+ /* Optional ID for highlighting different parts of this gizmo.
+ * -1 when unset, otherwise a valid index. (Used as index to 'op_data'). */
+ int highlight_part;
+ /* For single click button gizmos, use a different part as a fallback, -1 when unused. */
+ int drag_part;
+
+ /* Transformation of the gizmo in 2d or 3d space.
+ * - Matrix axis are expected to be unit length (scale is applied after).
+ * - Behavior when axis aren't orthogonal depends on each gizmo.
+ * - Typically the +Z is the primary axis for gizmos to use.
+ * - 'matrix[3]' must be used for location,
+ * besides this it's up to the gizmos internal code how the
+ * rotation components are used for drawing and interaction.
+ */
+
+ /* The space this gizmo is being modified in. */
+ float matrix_space[4][4];
+ /* Transformation of this gizmo. */
+ float matrix_basis[4][4];
+ /* custom offset from origin */
+ float matrix_offset[4][4];
+ /* runtime property, set the scale while drawing on the viewport */
+ float scale_final;
+ /* user defined scale, in addition to the original one */
+ float scale_basis;
+ /* user defined width for line drawing */
+ float line_width;
+ /* gizmo colors (uses default fallbacks if not defined) */
+ float color[4], color_hi[4];
+
+ /* data used during interaction */
+ void *interaction_data;
+
+ /* Operator to spawn when activating the gizmo (overrides property editing),
+ * an array of items (aligned with #wmGizmo.highlight_part). */
+ wmGizmoOpElem *op_data;
+ int op_data_len;
+
+ struct IDProperty *properties;
+
+ /* over alloc target_properties after 'wmGizmoType.struct_size' */
+};
+
+/* Similar to PropertyElemRNA, but has an identifier. */
+typedef struct wmGizmoProperty {
+ const struct wmGizmoPropertyType *type;
+
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ int index;
+
+
+ /* Optional functions for converting to/from RNA */
+ struct {
+ wmGizmoPropertyFnGet value_get_fn;
+ wmGizmoPropertyFnSet value_set_fn;
+ wmGizmoPropertyFnRangeGet range_get_fn;
+ wmGizmoPropertyFnFree free_fn;
+ void *user_data;
+ } custom_func;
+} wmGizmoProperty;
+
+typedef struct wmGizmoPropertyType {
+ struct wmGizmoPropertyType *next, *prev;
+ /* PropertyType, typically 'PROP_FLOAT' */
+ int data_type;
+ int array_length;
+
+ /* index within 'wmGizmoType' */
+ int index_in_type;
+
+ /* over alloc */
+ char idname[0];
+} wmGizmoPropertyType;
+
+
+/**
+ * Simple utility wrapper for storing a single gizmo as wmGizmoGroup.customdata (which gets freed).
+ */
+typedef struct wmGizmoWrapper {
+ struct wmGizmo *gizmo;
+} wmGizmoWrapper;
+
+struct wmGizmoMapType_Params {
+ short spaceid;
+ short regionid;
+};
+
+typedef struct wmGizmoType {
+
+ const char *idname; /* MAX_NAME */
+
+ /* Set to 'sizeof(wmGizmo)' or larger for instances of this type,
+ * use so we can cant to other types without the hassle of a custom-data pointer. */
+ uint struct_size;
+
+ /* Initialize struct (calloc'd 'struct_size' region). */
+ wmGizmoFnSetup setup;
+
+ /* draw gizmo */
+ wmGizmoFnDraw draw;
+
+ /* determines 3d intersection by rendering the gizmo in a selection routine. */
+ wmGizmoFnDrawSelect draw_select;
+
+ /* Determine if the mouse intersects with the gizmo.
+ * The calculation should be done in the callback itself, -1 for no seleciton. */
+ wmGizmoFnTestSelect test_select;
+
+ /* handler used by the gizmo. Usually handles interaction tied to a gizmo type */
+ wmGizmoFnModal modal;
+
+ /* gizmo-specific handler to update gizmo attributes based on the property value */
+ wmGizmoFnPropertyUpdate property_update;
+
+ /* Returns the final transformation which may be different from the 'matrix',
+ * depending on the gizmo.
+ * Notes:
+ * - Scale isn't applied (wmGizmo.scale/user_scale).
+ * - Offset isn't applied (wmGizmo.matrix_offset).
+ */
+ wmGizmoFnMatrixBasisGet matrix_basis_get;
+
+ /* activate a gizmo state when the user clicks on it */
+ wmGizmoFnInvoke invoke;
+
+ /* called when gizmo tweaking is done - used to free data and reset property when cancelling */
+ wmGizmoFnExit exit;
+
+ wmGizmoFnCursorGet cursor_get;
+
+ /* called when gizmo selection state changes */
+ wmGizmoFnSelectRefresh select_refresh;
+
+ /* Free data (not the gizmo it's self), use when the gizmo allocates it's own members. */
+ wmGizmoFnFree free;
+
+ /* RNA for properties */
+ struct StructRNA *srna;
+
+ /* RNA integration */
+ ExtensionRNA ext;
+
+ ListBase target_property_defs;
+ int target_property_defs_len;
+
+} wmGizmoType;
+
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoGroup */
+
+/* factory class for a gizmo-group type, gets called every time a new area is spawned */
+typedef struct wmGizmoGroupTypeRef {
+ struct wmGizmoGroupTypeRef *next, *prev;
+ struct wmGizmoGroupType *type;
+} wmGizmoGroupTypeRef;
+
+/* factory class for a gizmo-group type, gets called every time a new area is spawned */
+typedef struct wmGizmoGroupType {
+ const char *idname; /* MAX_NAME */
+ const char *name; /* gizmo-group name - displayed in UI (keymap editor) */
+ char owner_id[64]; /* MAX_NAME */
+
+ /* poll if gizmo-map should be visible */
+ wmGizmoGroupFnPoll poll;
+ /* initially create gizmos and set permanent data - stuff you only need to do once */
+ wmGizmoGroupFnInit setup;
+ /* refresh data, only called if recreate flag is set (WM_gizmomap_tag_refresh) */
+ wmGizmoGroupFnRefresh refresh;
+ /* refresh data for drawing, called before each redraw */
+ wmGizmoGroupFnDrawPrepare draw_prepare;
+
+ /* Keymap init callback for this gizmo-group (optional),
+ * will fall back to default tweak keymap when left NULL. */
+ wmGizmoGroupFnSetupKeymap setup_keymap;
+
+ /* Optionally subscribe to wmMsgBus events,
+ * these are calculated automatically from RNA properties,
+ * only needed if gizmos depend indirectly on properties. */
+ wmGizmoGroupFnMsgBusSubscribe message_subscribe;
+
+ /* keymap created with callback from above */
+ struct wmKeyMap *keymap;
+ /* Only for convenient removal. */
+ struct wmKeyConfig *keyconf;
+
+ /* Disable for now, maybe some day we want properties. */
+#if 0
+ /* rna for properties */
+ struct StructRNA *srna;
+#endif
+
+ /* RNA integration */
+ ExtensionRNA ext;
+
+ eWM_GizmoFlagGroupTypeFlag flag;
+
+ /* So we know which group type to update. */
+ eWM_GizmoFlagMapTypeUpdateFlag type_update_flag;
+
+ /* same as gizmo-maps, so registering/unregistering goes to the correct region */
+ struct wmGizmoMapType_Params gzmap_params;
+
+} wmGizmoGroupType;
+
+typedef struct wmGizmoGroup {
+ struct wmGizmoGroup *next, *prev;
+
+ struct wmGizmoGroupType *type;
+ ListBase gizmos;
+
+ struct wmGizmoMap *parent_gzmap;
+
+ void *py_instance; /* python stores the class instance here */
+ struct ReportList *reports; /* errors and warnings storage */
+
+ void *customdata;
+ void (*customdata_free)(void *); /* for freeing customdata from above */
+ eWM_GizmoFlagGroupInitFlag init_flag;
+} wmGizmoGroup;
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoMap */
+
+/**
+ * Pass a value of this enum to #WM_gizmomap_draw to tell it what to draw.
+ */
+typedef enum eWM_GizmoFlagMapDrawStep {
+ /** Draw 2D gizmo-groups (#WM_GIZMOGROUPTYPE_3D not set). */
+ WM_GIZMOMAP_DRAWSTEP_2D = 0,
+ /** Draw 3D gizmo-groups (#WM_GIZMOGROUPTYPE_3D set). */
+ WM_GIZMOMAP_DRAWSTEP_3D,
+} eWM_GizmoFlagMapDrawStep;
+#define WM_GIZMOMAP_DRAWSTEP_MAX 2
+
+#endif /* __WM_GIZMO_TYPES_H__ */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
new file mode 100644
index 00000000000..14deb0be725
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
@@ -0,0 +1,800 @@
+/*
+ * ***** 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
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/windowmanager/gizmo/intern/wm_gizmo.c
+ * \ingroup wm
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_string_utils.h"
+
+#include "BKE_context.h"
+
+#include "GPU_batch.h"
+#include "GPU_glew.h"
+#include "GPU_immediate.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_idprop.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "UI_interface.h"
+
+#ifdef WITH_PYTHON
+#include "BPY_extern.h"
+#endif
+
+/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */
+#include "wm.h"
+
+/* own includes */
+#include "wm_gizmo_wmapi.h"
+#include "wm_gizmo_intern.h"
+
+static void wm_gizmo_register(
+ wmGizmoGroup *gzgroup, wmGizmo *gz);
+
+/**
+ * \note Follow #wm_operator_create convention.
+ */
+static wmGizmo *wm_gizmo_create(
+ const wmGizmoType *gzt,
+ PointerRNA *properties)
+{
+ BLI_assert(gzt != NULL);
+ BLI_assert(gzt->struct_size >= sizeof(wmGizmo));
+
+ wmGizmo *gz = MEM_callocN(
+ gzt->struct_size + (sizeof(wmGizmoProperty) * gzt->target_property_defs_len), __func__);
+ gz->type = gzt;
+
+ /* initialize properties, either copy or create */
+ gz->ptr = MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA");
+ if (properties && properties->data) {
+ gz->properties = IDP_CopyProperty(properties->data);
+ }
+ else {
+ IDPropertyTemplate val = {0};
+ gz->properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties");
+ }
+ RNA_pointer_create(G_MAIN->wm.first, gzt->srna, gz->properties, gz->ptr);
+
+ WM_gizmo_properties_sanitize(gz->ptr, 0);
+
+ unit_m4(gz->matrix_space);
+ unit_m4(gz->matrix_basis);
+ unit_m4(gz->matrix_offset);
+
+ gz->drag_part = -1;
+
+ return gz;
+}
+
+wmGizmo *WM_gizmo_new_ptr(
+ const wmGizmoType *gzt, wmGizmoGroup *gzgroup,
+ PointerRNA *properties)
+{
+ wmGizmo *gz = wm_gizmo_create(gzt, properties);
+
+ wm_gizmo_register(gzgroup, gz);
+
+ if (gz->type->setup != NULL) {
+ gz->type->setup(gz);
+ }
+
+ return gz;
+}
+
+/**
+ * \param gt: Must be valid,
+ * if you need to check it exists use #WM_gizmo_new_ptr
+ * because callers of this function don't NULL check the return value.
+ */
+wmGizmo *WM_gizmo_new(
+ const char *idname, wmGizmoGroup *gzgroup,
+ PointerRNA *properties)
+{
+ const wmGizmoType *gzt = WM_gizmotype_find(idname, false);
+ return WM_gizmo_new_ptr(gzt, gzgroup, properties);
+}
+
+/**
+ * Initialize default values and allocate needed memory for members.
+ */
+static void gizmo_init(wmGizmo *gz)
+{
+ const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ gz->scale_basis = 1.0f;
+ gz->line_width = 1.0f;
+
+ /* defaults */
+ copy_v4_v4(gz->color, color_default);
+ copy_v4_v4(gz->color_hi, color_default);
+}
+
+/**
+ * Register \a gizmo.
+ *
+ * \param name: name used to create a unique idname for \a gizmo in \a gzgroup
+ *
+ * \note Not to be confused with type registration from RNA.
+ */
+static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
+{
+ gizmo_init(gz);
+ wm_gizmogroup_gizmo_register(gzgroup, gz);
+}
+
+/**
+ * \warning this doesn't check #wmGizmoMap (highlight, selection etc).
+ * Typical use is when freeing the windowing data,
+ * where caller can manage clearing selection, highlight... etc.
+ */
+void WM_gizmo_free(wmGizmo *gz)
+{
+ if (gz->type->free != NULL) {
+ gz->type->free(gz);
+ }
+
+#ifdef WITH_PYTHON
+ if (gz->py_instance) {
+ /* do this first in case there are any __del__ functions or
+ * similar that use properties */
+ BPY_DECREF_RNA_INVALIDATE(gz->py_instance);
+ }
+#endif
+
+ if (gz->op_data) {
+ for (int i = 0; i < gz->op_data_len; i++) {
+ WM_operator_properties_free(&gz->op_data[i].ptr);
+ }
+ MEM_freeN(gz->op_data);
+ }
+
+ if (gz->ptr != NULL) {
+ WM_gizmo_properties_free(gz->ptr);
+ MEM_freeN(gz->ptr);
+ }
+
+ if (gz->type->target_property_defs_len != 0) {
+ wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz);
+ for (int i = 0; i < gz->type->target_property_defs_len; i++) {
+ wmGizmoProperty *gz_prop = &gz_prop_array[i];
+ if (gz_prop->custom_func.free_fn) {
+ gz_prop->custom_func.free_fn(gz, gz_prop);
+ }
+ }
+ }
+
+ MEM_freeN(gz);
+}
+
+/**
+ * Free \a gizmo and unlink from \a gizmolist.
+ * \a gizmolist is allowed to be NULL.
+ */
+void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
+{
+ if (gz->state & WM_GIZMO_STATE_HIGHLIGHT) {
+ wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
+ }
+ if (gz->state & WM_GIZMO_STATE_MODAL) {
+ wm_gizmomap_modal_set(gzmap, C, gz, NULL, false);
+ }
+ /* Unlink instead of setting so we don't run callbacks. */
+ if (gz->state & WM_GIZMO_STATE_SELECT) {
+ WM_gizmo_select_unlink(gzmap, gz);
+ }
+
+ if (gizmolist) {
+ BLI_remlink(gizmolist, gz);
+ }
+
+ BLI_assert(gzmap->gzmap_context.highlight != gz);
+ BLI_assert(gzmap->gzmap_context.modal != gz);
+
+ WM_gizmo_free(gz);
+}
+
+/* -------------------------------------------------------------------- */
+/** \name Gizmo Creation API
+ *
+ * API for defining data on gizmo creation.
+ *
+ * \{ */
+
+struct wmGizmoOpElem *WM_gizmo_operator_get(
+ wmGizmo *gz, int part_index)
+{
+ if (gz->op_data && ((part_index >= 0) && (part_index < gz->op_data_len))) {
+ return &gz->op_data[part_index];
+ }
+ return NULL;
+}
+
+PointerRNA *WM_gizmo_operator_set(
+ wmGizmo *gz, int part_index,
+ wmOperatorType *ot, IDProperty *properties)
+{
+ BLI_assert(part_index < 255);
+ /* We could pre-allocate these but using multiple is such a rare thing. */
+ if (part_index >= gz->op_data_len) {
+ gz->op_data_len = part_index + 1;
+ gz->op_data = MEM_recallocN(gz->op_data, sizeof(*gz->op_data) * gz->op_data_len);
+ }
+ wmGizmoOpElem *mpop = &gz->op_data[part_index];
+ mpop->type = ot;
+
+ if (mpop->ptr.data) {
+ WM_operator_properties_free(&mpop->ptr);
+ }
+ WM_operator_properties_create_ptr(&mpop->ptr, ot);
+
+ if (properties) {
+ mpop->ptr.data = properties;
+ }
+
+ return &mpop->ptr;
+}
+
+static void wm_gizmo_set_matrix_rotation_from_z_axis__internal(
+ float matrix[4][4], const float z_axis[3])
+{
+ /* old code, seems we can use simpler method */
+#if 0
+ const float z_global[3] = {0.0f, 0.0f, 1.0f};
+ float rot[3][3];
+
+ rotation_between_vecs_to_mat3(rot, z_global, z_axis);
+ copy_v3_v3(matrix[0], rot[0]);
+ copy_v3_v3(matrix[1], rot[1]);
+ copy_v3_v3(matrix[2], rot[2]);
+#else
+ normalize_v3_v3(matrix[2], z_axis);
+ ortho_basis_v3v3_v3(matrix[0], matrix[1], matrix[2]);
+#endif
+
+}
+
+static void wm_gizmo_set_matrix_rotation_from_yz_axis__internal(
+ float matrix[4][4], const float y_axis[3], const float z_axis[3])
+{
+ normalize_v3_v3(matrix[1], y_axis);
+ normalize_v3_v3(matrix[2], z_axis);
+ cross_v3_v3v3(matrix[0], matrix[1], matrix[2]);
+ normalize_v3(matrix[0]);
+}
+
+/**
+ * wmGizmo.matrix utils.
+ */
+void WM_gizmo_set_matrix_rotation_from_z_axis(
+ wmGizmo *gz, const float z_axis[3])
+{
+ wm_gizmo_set_matrix_rotation_from_z_axis__internal(gz->matrix_basis, z_axis);
+}
+void WM_gizmo_set_matrix_rotation_from_yz_axis(
+ wmGizmo *gz, const float y_axis[3], const float z_axis[3])
+{
+ wm_gizmo_set_matrix_rotation_from_yz_axis__internal(gz->matrix_basis, y_axis, z_axis);
+}
+void WM_gizmo_set_matrix_location(wmGizmo *gz, const float origin[3])
+{
+ copy_v3_v3(gz->matrix_basis[3], origin);
+}
+
+/**
+ * wmGizmo.matrix_offset utils.
+ */
+void WM_gizmo_set_matrix_offset_rotation_from_z_axis(
+ wmGizmo *gz, const float z_axis[3])
+{
+ wm_gizmo_set_matrix_rotation_from_z_axis__internal(gz->matrix_offset, z_axis);
+}
+void WM_gizmo_set_matrix_offset_rotation_from_yz_axis(
+ wmGizmo *gz, const float y_axis[3], const float z_axis[3])
+{
+ wm_gizmo_set_matrix_rotation_from_yz_axis__internal(gz->matrix_offset, y_axis, z_axis);
+}
+void WM_gizmo_set_matrix_offset_location(wmGizmo *gz, const float offset[3])
+{
+ copy_v3_v3(gz->matrix_offset[3], offset);
+}
+
+void WM_gizmo_set_flag(wmGizmo *gz, const int flag, const bool enable)
+{
+ if (enable) {
+ gz->flag |= flag;
+ }
+ else {
+ gz->flag &= ~flag;
+ }
+}
+
+void WM_gizmo_set_scale(wmGizmo *gz, const float scale)
+{
+ gz->scale_basis = scale;
+}
+
+void WM_gizmo_set_line_width(wmGizmo *gz, const float line_width)
+{
+ gz->line_width = line_width;
+}
+
+/**
+ * Set gizmo rgba colors.
+ *
+ * \param col Normal state color.
+ * \param col_hi Highlighted state color.
+ */
+void WM_gizmo_get_color(const wmGizmo *gz, float color[4])
+{
+ copy_v4_v4(color, gz->color);
+}
+void WM_gizmo_set_color(wmGizmo *gz, const float color[4])
+{
+ copy_v4_v4(gz->color, color);
+}
+
+void WM_gizmo_get_color_highlight(const wmGizmo *gz, float color_hi[4])
+{
+ copy_v4_v4(color_hi, gz->color_hi);
+}
+void WM_gizmo_set_color_highlight(wmGizmo *gz, const float color_hi[4])
+{
+ copy_v4_v4(gz->color_hi, color_hi);
+}
+
+
+/** \} */ // Gizmo Creation API
+
+
+/* -------------------------------------------------------------------- */
+/** \name Gizmo Callback Assignment
+ *
+ * \{ */
+
+void WM_gizmo_set_fn_custom_modal(struct wmGizmo *gz, wmGizmoFnModal fn)
+{
+ gz->custom_modal = fn;
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/**
+ * Add/Remove \a gizmo to selection.
+ * Reallocates memory for selected gizmos so better not call for selecting multiple ones.
+ *
+ * \return if the selection has changed.
+ */
+bool wm_gizmo_select_set_ex(
+ wmGizmoMap *gzmap, wmGizmo *gz, bool select,
+ bool use_array, bool use_callback)
+{
+ bool changed = false;
+
+ if (select) {
+ if ((gz->state & WM_GIZMO_STATE_SELECT) == 0) {
+ if (use_array) {
+ wm_gizmomap_select_array_push_back(gzmap, gz);
+ }
+ gz->state |= WM_GIZMO_STATE_SELECT;
+ changed = true;
+ }
+ }
+ else {
+ if (gz->state & WM_GIZMO_STATE_SELECT) {
+ if (use_array) {
+ wm_gizmomap_select_array_remove(gzmap, gz);
+ }
+ gz->state &= ~WM_GIZMO_STATE_SELECT;
+ changed = true;
+ }
+ }
+
+ /* In the case of unlinking we only want to remove from the array
+ * and not write to the external state */
+ if (use_callback && changed) {
+ if (gz->type->select_refresh) {
+ gz->type->select_refresh(gz);
+ }
+ }
+
+ return changed;
+}
+
+/* Remove from selection array without running callbacks. */
+bool WM_gizmo_select_unlink(wmGizmoMap *gzmap, wmGizmo *gz)
+{
+ return wm_gizmo_select_set_ex(gzmap, gz, false, true, false);
+}
+
+bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
+{
+ return wm_gizmo_select_set_ex(gzmap, gz, select, true, true);
+}
+
+void WM_gizmo_highlight_set(wmGizmoMap *gzmap, wmGizmo *gz)
+{
+ wm_gizmomap_highlight_set(gzmap, NULL, gz, gz ? gz->highlight_part : 0);
+}
+
+bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz)
+{
+ if (WM_gizmo_select_set(gzmap, gz, true)) {
+ wm_gizmomap_highlight_set(gzmap, C, gz, gz->highlight_part);
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+/**
+ * Special function to run from setup so gizmos start out interactive.
+ *
+ * We could do this when linking them, but this complicates things since the window update code needs to run first.
+ */
+void WM_gizmo_modal_set_from_setup(
+ struct wmGizmoMap *gzmap, struct bContext *C,
+ struct wmGizmo *gz, int part_index, const wmEvent *event)
+{
+ gz->highlight_part = part_index;
+ WM_gizmo_highlight_set(gzmap, gz);
+ if (false) {
+ wm_gizmomap_modal_set(gzmap, C, gz, event, true);
+ }
+ else {
+ /* WEAK: but it works. */
+ WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_DEFAULT, NULL);
+ }
+}
+
+void wm_gizmo_calculate_scale(wmGizmo *gz, const bContext *C)
+{
+ const RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ float scale = UI_DPI_FAC;
+
+ if ((gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_SCALE) == 0) {
+ scale *= U.gizmo_size;
+ if (rv3d) {
+ /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */
+ float matrix_world[4][4];
+ if (gz->type->matrix_basis_get) {
+ float matrix_basis[4][4];
+ gz->type->matrix_basis_get(gz, matrix_basis);
+ mul_m4_m4m4(matrix_world, gz->matrix_space, matrix_basis);
+ }
+ else {
+ mul_m4_m4m4(matrix_world, gz->matrix_space, gz->matrix_basis);
+ }
+
+ /* Exclude matrix_offset from scale. */
+ scale *= ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_world[3]);
+ }
+ else {
+ scale *= 0.02f;
+ }
+ }
+
+ gz->scale_final = gz->scale_basis * scale;
+}
+
+static void gizmo_update_prop_data(wmGizmo *gz)
+{
+ /* gizmo property might have been changed, so update gizmo */
+ if (gz->type->property_update) {
+ wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz);
+ for (int i = 0; i < gz->type->target_property_defs_len; i++) {
+ wmGizmoProperty *gz_prop = &gz_prop_array[i];
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ gz->type->property_update(gz, gz_prop);
+ }
+ }
+ }
+}
+
+void wm_gizmo_update(wmGizmo *gz, const bContext *C, const bool refresh_map)
+{
+ if (refresh_map) {
+ gizmo_update_prop_data(gz);
+ }
+ wm_gizmo_calculate_scale(gz, C);
+}
+
+int wm_gizmo_is_visible(wmGizmo *gz)
+{
+ if (gz->flag & WM_GIZMO_HIDDEN) {
+ return 0;
+ }
+ if ((gz->state & WM_GIZMO_STATE_MODAL) &&
+ !(gz->flag & (WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_VALUE)))
+ {
+ /* don't draw while modal (dragging) */
+ return 0;
+ }
+ if ((gz->flag & WM_GIZMO_DRAW_HOVER) &&
+ !(gz->state & WM_GIZMO_STATE_HIGHLIGHT) &&
+ !(gz->state & WM_GIZMO_STATE_SELECT)) /* still draw selected gizmos */
+ {
+ /* update but don't draw */
+ return WM_GIZMO_IS_VISIBLE_UPDATE;
+ }
+
+ return WM_GIZMO_IS_VISIBLE_UPDATE | WM_GIZMO_IS_VISIBLE_DRAW;
+}
+
+void WM_gizmo_calc_matrix_final_params(
+ const wmGizmo *gz,
+ const struct WM_GizmoMatrixParams *params,
+ float r_mat[4][4])
+{
+ const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : gz->matrix_space;
+ const float (* const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis : gz->matrix_basis;
+ const float (* const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset : gz->matrix_offset;
+ const float *scale_final = params->scale_final ? params->scale_final : &gz->scale_final;
+
+ float final_matrix[4][4];
+ if (params->matrix_basis == NULL && gz->type->matrix_basis_get) {
+ gz->type->matrix_basis_get(gz, final_matrix);
+ }
+ else {
+ copy_m4_m4(final_matrix, matrix_basis);
+ }
+
+ if (gz->flag & WM_GIZMO_DRAW_NO_SCALE) {
+ mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
+ }
+ else {
+ if (gz->flag & WM_GIZMO_DRAW_OFFSET_SCALE) {
+ mul_mat3_m4_fl(final_matrix, *scale_final);
+ mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
+ }
+ else {
+ mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
+ mul_mat3_m4_fl(final_matrix, *scale_final);
+ }
+ }
+
+ mul_m4_m4m4(r_mat, matrix_space, final_matrix);
+}
+
+void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4])
+{
+ float mat_identity[4][4];
+ unit_m4(mat_identity);
+
+ WM_gizmo_calc_matrix_final_params(
+ gz,
+ &((struct WM_GizmoMatrixParams) {
+ .matrix_space = NULL,
+ .matrix_basis = NULL,
+ .matrix_offset = mat_identity,
+ .scale_final = NULL,
+ }), r_mat
+ );
+}
+
+void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
+{
+ WM_gizmo_calc_matrix_final_params(
+ gz,
+ &((struct WM_GizmoMatrixParams) {
+ .matrix_space = NULL,
+ .matrix_basis = NULL,
+ .matrix_offset = NULL,
+ .scale_final = NULL,
+ }), r_mat
+ );
+}
+
+/** \name Gizmo Propery Access
+ *
+ * Matches `WM_operator_properties` conventions.
+ *
+ * \{ */
+
+
+void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *gzt)
+{
+ RNA_pointer_create(NULL, gzt->srna, NULL, ptr);
+}
+
+void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
+{
+ const wmGizmoType *gzt = WM_gizmotype_find(gtstring, false);
+
+ if (gzt)
+ WM_gizmo_properties_create_ptr(ptr, (wmGizmoType *)gzt);
+ else
+ RNA_pointer_create(NULL, &RNA_GizmoProperties, NULL, ptr);
+}
+
+/* similar to the function above except its uses ID properties
+ * used for keymaps and macros */
+void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring)
+{
+ if (*properties == NULL) {
+ IDPropertyTemplate val = {0};
+ *properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
+ }
+
+ if (*ptr == NULL) {
+ *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
+ WM_gizmo_properties_create(*ptr, gtstring);
+ }
+
+ (*ptr)->data = *properties;
+
+}
+
+void WM_gizmo_properties_sanitize(PointerRNA *ptr, const bool no_context)
+{
+ RNA_STRUCT_BEGIN (ptr, prop)
+ {
+ switch (RNA_property_type(prop)) {
+ case PROP_ENUM:
+ if (no_context)
+ RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT);
+ else
+ RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT);
+ break;
+ case PROP_POINTER:
+ {
+ StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
+
+ /* recurse into gizmo properties */
+ if (RNA_struct_is_a(ptype, &RNA_GizmoProperties)) {
+ PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
+ WM_gizmo_properties_sanitize(&opptr, no_context);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ RNA_STRUCT_END;
+}
+
+
+/** set all props to their default,
+ * \param do_update Only update un-initialized props.
+ *
+ * \note, theres nothing specific to gizmos here.
+ * this could be made a general function.
+ */
+bool WM_gizmo_properties_default(PointerRNA *ptr, const bool do_update)
+{
+ bool changed = false;
+ RNA_STRUCT_BEGIN (ptr, prop)
+ {
+ switch (RNA_property_type(prop)) {
+ case PROP_POINTER:
+ {
+ StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
+ if (ptype != &RNA_Struct) {
+ PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
+ changed |= WM_gizmo_properties_default(&opptr, do_update);
+ }
+ break;
+ }
+ default:
+ if ((do_update == false) || (RNA_property_is_set(ptr, prop) == false)) {
+ if (RNA_property_reset(ptr, prop, -1)) {
+ changed = true;
+ }
+ }
+ break;
+ }
+ }
+ RNA_STRUCT_END;
+
+ return changed;
+}
+
+/* remove all props without PROP_SKIP_SAVE */
+void WM_gizmo_properties_reset(wmGizmo *gz)
+{
+ if (gz->ptr->data) {
+ PropertyRNA *iterprop;
+ iterprop = RNA_struct_iterator_property(gz->type->srna);
+
+ RNA_PROP_BEGIN (gz->ptr, itemptr, iterprop)
+ {
+ PropertyRNA *prop = itemptr.data;
+
+ if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
+ const char *identifier = RNA_property_identifier(prop);
+ RNA_struct_idprops_unset(gz->ptr, identifier);
+ }
+ }
+ RNA_PROP_END;
+ }
+}
+
+void WM_gizmo_properties_clear(PointerRNA *ptr)
+{
+ IDProperty *properties = ptr->data;
+
+ if (properties) {
+ IDP_ClearProperty(properties);
+ }
+}
+
+void WM_gizmo_properties_free(PointerRNA *ptr)
+{
+ IDProperty *properties = ptr->data;
+
+ if (properties) {
+ IDP_FreeProperty(properties);
+ MEM_freeN(properties);
+ ptr->data = NULL; /* just in case */
+ }
+}
+
+/** \} */
+
+/** \name General Utilities
+ *
+ * \{ */
+
+bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step)
+{
+ switch (step) {
+ case WM_GIZMOMAP_DRAWSTEP_2D:
+ {
+ break;
+ }
+ case WM_GIZMOMAP_DRAWSTEP_3D:
+ {
+ wmWindowManager *wm = CTX_wm_manager(C);
+ if (ED_screen_animation_playing(wm)) {
+ return false;
+ }
+ break;
+ }
+ }
+ return true;
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
new file mode 100644
index 00000000000..9cc096e1cdd
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -0,0 +1,949 @@
+/*
+ * ***** 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
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+ * \ingroup wm
+ *
+ * \name Gizmo-Group
+ *
+ * Gizmo-groups store and manage groups of gizmos. They can be
+ * attached to modal handlers and have own keymaps.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BLI_math.h"
+
+#include "BKE_context.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+#include "BKE_workspace.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "wm_event_system.h"
+
+#include "ED_screen.h"
+#include "ED_undo.h"
+
+/* own includes */
+#include "wm_gizmo_wmapi.h"
+#include "wm_gizmo_intern.h"
+
+#ifdef WITH_PYTHON
+# include "BPY_extern.h"
+#endif
+
+/* Allow gizmo part's to be single click only,
+ * dragging falls back to activating their 'drag_part' action. */
+#define USE_DRAG_DETECT
+
+/* -------------------------------------------------------------------- */
+/** \name wmGizmoGroup
+ *
+ * \{ */
+
+/**
+ * Create a new gizmo-group from \a gzgt.
+ */
+wmGizmoGroup *wm_gizmogroup_new_from_type(
+ wmGizmoMap *gzmap, wmGizmoGroupType *gzgt)
+{
+ wmGizmoGroup *gzgroup = MEM_callocN(sizeof(*gzgroup), "gizmo-group");
+ gzgroup->type = gzgt;
+
+ /* keep back-link */
+ gzgroup->parent_gzmap = gzmap;
+
+ BLI_addtail(&gzmap->groups, gzgroup);
+
+ return gzgroup;
+}
+
+void wm_gizmogroup_free(bContext *C, wmGizmoGroup *gzgroup)
+{
+ wmGizmoMap *gzmap = gzgroup->parent_gzmap;
+
+ /* Similar to WM_gizmo_unlink, but only to keep gzmap state correct,
+ * we don't want to run callbacks. */
+ if (gzmap->gzmap_context.highlight && gzmap->gzmap_context.highlight->parent_gzgroup == gzgroup) {
+ wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
+ }
+ if (gzmap->gzmap_context.modal && gzmap->gzmap_context.modal->parent_gzgroup == gzgroup) {
+ wm_gizmomap_modal_set(gzmap, C, gzmap->gzmap_context.modal, NULL, false);
+ }
+
+ for (wmGizmo *gz = gzgroup->gizmos.first, *gz_next; gz; gz = gz_next) {
+ gz_next = gz->next;
+ if (gzmap->gzmap_context.select.len) {
+ WM_gizmo_select_unlink(gzmap, gz);
+ }
+ WM_gizmo_free(gz);
+ }
+ BLI_listbase_clear(&gzgroup->gizmos);
+
+#ifdef WITH_PYTHON
+ if (gzgroup->py_instance) {
+ /* do this first in case there are any __del__ functions or
+ * similar that use properties */
+ BPY_DECREF_RNA_INVALIDATE(gzgroup->py_instance);
+ }
+#endif
+
+ if (gzgroup->reports && (gzgroup->reports->flag & RPT_FREE)) {
+ BKE_reports_clear(gzgroup->reports);
+ MEM_freeN(gzgroup->reports);
+ }
+
+ if (gzgroup->customdata_free) {
+ gzgroup->customdata_free(gzgroup->customdata);
+ }
+ else {
+ MEM_SAFE_FREE(gzgroup->customdata);
+ }
+
+ BLI_remlink(&gzmap->groups, gzgroup);
+
+ MEM_freeN(gzgroup);
+}
+
+/**
+ * Add \a gizmo to \a gzgroup and make sure its name is unique within the group.
+ */
+void wm_gizmogroup_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
+{
+ BLI_assert(BLI_findindex(&gzgroup->gizmos, gz) == -1);
+ BLI_addtail(&gzgroup->gizmos, gz);
+ gz->parent_gzgroup = gzgroup;
+}
+
+wmGizmo *wm_gizmogroup_find_intersected_gizmo(
+ const wmGizmoGroup *gzgroup, bContext *C, const wmEvent *event,
+ int *r_part)
+{
+ for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ if (gz->type->test_select && (gz->flag & WM_GIZMO_HIDDEN) == 0) {
+ if ((*r_part = gz->type->test_select(C, gz, event)) != -1) {
+ return gz;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * Adds all gizmos of \a gzgroup that can be selected to the head of \a listbase. Added items need freeing!
+ */
+void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *gzgroup, ListBase *listbase)
+{
+ for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ if ((gz->flag & WM_GIZMO_HIDDEN) == 0) {
+ if (((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) && gz->type->draw_select) ||
+ ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && gz->type->test_select))
+ {
+ BLI_addhead(listbase, BLI_genericNodeN(gz));
+ }
+ }
+ }
+}
+
+void wm_gizmogroup_ensure_initialized(wmGizmoGroup *gzgroup, const bContext *C)
+{
+ /* prepare for first draw */
+ if (UNLIKELY((gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0)) {
+ gzgroup->type->setup(C, gzgroup);
+
+ /* Not ideal, initialize keymap here, needed for RNA runtime generated gizmos. */
+ wmGizmoGroupType *gzgt = gzgroup->type;
+ if (gzgt->keymap == NULL) {
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wm_gizmogrouptype_setup_keymap(gzgt, wm->defaultconf);
+ BLI_assert(gzgt->keymap != NULL);
+ }
+ gzgroup->init_flag |= WM_GIZMOGROUP_INIT_SETUP;
+ }
+
+ /* refresh may be called multiple times, this just ensures its called at least once before we draw. */
+ if (UNLIKELY((gzgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0)) {
+ if (gzgroup->type->refresh) {
+ gzgroup->type->refresh(C, gzgroup);
+ }
+ gzgroup->init_flag |= WM_GIZMOGROUP_INIT_REFRESH;
+ }
+}
+
+bool WM_gizmo_group_type_poll(const bContext *C, const struct wmGizmoGroupType *gzgt)
+{
+ /* If we're tagged, only use compatible. */
+ if (gzgt->owner_id[0] != '\0') {
+ const WorkSpace *workspace = CTX_wm_workspace(C);
+ if (BKE_workspace_owner_id_check(workspace, gzgt->owner_id) == false) {
+ return false;
+ }
+ }
+ /* Check for poll function, if gizmo-group belongs to an operator, also check if the operator is running. */
+ return (!gzgt->poll || gzgt->poll(C, (wmGizmoGroupType *)gzgt));
+}
+
+bool wm_gizmogroup_is_visible_in_drawstep(
+ const wmGizmoGroup *gzgroup, const eWM_GizmoFlagMapDrawStep drawstep)
+{
+ switch (drawstep) {
+ case WM_GIZMOMAP_DRAWSTEP_2D:
+ return (gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0;
+ case WM_GIZMOMAP_DRAWSTEP_3D:
+ return (gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D);
+ default:
+ BLI_assert(0);
+ return false;
+ }
+}
+
+bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *gzgroup)
+{
+ if (gzgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT) {
+ for (const wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ if (gz->state & WM_GIZMO_STATE_SELECT) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/** \} */
+
+/** \name Gizmo operators
+ *
+ * Basic operators for gizmo interaction with user configurable keymaps.
+ *
+ * \{ */
+
+static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ ARegion *ar = CTX_wm_region(C);
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
+ wmGizmo *highlight = gzmap->gzmap_context.highlight;
+
+ bool extend = RNA_boolean_get(op->ptr, "extend");
+ bool deselect = RNA_boolean_get(op->ptr, "deselect");
+ bool toggle = RNA_boolean_get(op->ptr, "toggle");
+
+ /* deselect all first */
+ if (extend == false && deselect == false && toggle == false) {
+ wm_gizmomap_deselect_all(gzmap);
+ BLI_assert(msel->items == NULL && msel->len == 0);
+ UNUSED_VARS_NDEBUG(msel);
+ }
+
+ if (highlight) {
+ const bool is_selected = (highlight->state & WM_GIZMO_STATE_SELECT);
+ bool redraw = false;
+
+ if (toggle) {
+ /* toggle: deselect if already selected, else select */
+ deselect = is_selected;
+ }
+
+ if (deselect) {
+ if (is_selected && WM_gizmo_select_set(gzmap, highlight, false)) {
+ redraw = true;
+ }
+ }
+ else if (wm_gizmo_select_and_highlight(C, gzmap, highlight)) {
+ redraw = true;
+ }
+
+ if (redraw) {
+ ED_region_tag_redraw(ar);
+ }
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ BLI_assert(0);
+ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
+ }
+
+ return OPERATOR_PASS_THROUGH;
+}
+
+void GIZMOGROUP_OT_gizmo_select(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Gizmo Select";
+ ot->description = "Select the currently highlighted gizmo";
+ ot->idname = "GIZMOGROUP_OT_gizmo_select";
+
+ /* api callbacks */
+ ot->invoke = gizmo_select_invoke;
+
+ ot->flag = OPTYPE_UNDO;
+
+ WM_operator_properties_mouse_select(ot);
+}
+
+typedef struct GizmoTweakData {
+ wmGizmoMap *gzmap;
+ wmGizmoGroup *gzgroup;
+ wmGizmo *gz_modal;
+
+ int init_event; /* initial event type */
+ int flag; /* tweak flags */
+
+#ifdef USE_DRAG_DETECT
+ /* True until the mouse is moved (only use when the operator has no modal).
+ * this allows some gizmos to be click-only. */
+ enum {
+ /* Don't detect dragging. */
+ DRAG_NOP = 0,
+ /* Detect dragging (wait until a drag or click is detected). */
+ DRAG_DETECT,
+ /* Drag has started, idle until there is no active modal operator.
+ * This is needed because finishing the modal operator also exits
+ * the modal gizmo state (un-grabbs the cursor).
+ * Ideally this workaround could be removed later. */
+ DRAG_IDLE,
+ } drag_state;
+#endif
+
+} GizmoTweakData;
+
+static bool gizmo_tweak_start(
+ bContext *C, wmGizmoMap *gzmap, wmGizmo *gz, const wmEvent *event)
+{
+ /* activate highlighted gizmo */
+ wm_gizmomap_modal_set(gzmap, C, gz, event, true);
+
+ return (gz->state & WM_GIZMO_STATE_MODAL);
+}
+
+static bool gizmo_tweak_start_and_finish(
+ bContext *C, wmGizmoMap *gzmap, wmGizmo *gz, const wmEvent *event, bool *r_is_modal)
+{
+ wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, gz->highlight_part);
+ if (r_is_modal) {
+ *r_is_modal = false;
+ }
+ if (mpop && mpop->type) {
+
+ /* Undo/Redo */
+ if (mpop->is_redo) {
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmOperator *op = WM_operator_last_redo(C);
+
+ /* We may want to enable this, for now the gizmo can manage it's own properties. */
+#if 0
+ IDP_MergeGroup(mpop->ptr.data, op->properties, false);
+#endif
+
+ WM_operator_free_all_after(wm, op);
+ ED_undo_pop_op(C, op);
+ }
+
+ /* XXX temporary workaround for modal gizmo operator
+ * conflicting with modal operator attached to gizmo */
+ if (mpop->type->modal) {
+ /* activate highlighted gizmo */
+ wm_gizmomap_modal_set(gzmap, C, gz, event, true);
+ if (r_is_modal) {
+ *r_is_modal = true;
+ }
+ }
+ else {
+ /* Allow for 'button' gizmos, single click to run an action. */
+ WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr);
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal)
+{
+ GizmoTweakData *mtweak = op->customdata;
+ if (mtweak->gz_modal->type->exit) {
+ mtweak->gz_modal->type->exit(C, mtweak->gz_modal, cancel);
+ }
+ if (clear_modal) {
+ /* The gizmo may have been removed. */
+ if ((BLI_findindex(&mtweak->gzmap->groups, mtweak->gzgroup) != -1) &&
+ (BLI_findindex(&mtweak->gzgroup->gizmos, mtweak->gz_modal) != -1))
+ {
+ wm_gizmomap_modal_set(mtweak->gzmap, C, mtweak->gz_modal, NULL, false);
+ }
+ }
+ MEM_freeN(mtweak);
+}
+
+static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ GizmoTweakData *mtweak = op->customdata;
+ wmGizmo *gz = mtweak->gz_modal;
+ int retval = OPERATOR_PASS_THROUGH;
+ bool clear_modal = true;
+
+ if (gz == NULL) {
+ BLI_assert(0);
+ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
+ }
+
+#ifdef USE_DRAG_DETECT
+ wmGizmoMap *gzmap = mtweak->gzmap;
+ if (mtweak->drag_state == DRAG_DETECT) {
+ if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
+ if (len_manhattan_v2v2_int(&event->x, gzmap->gzmap_context.event_xy) > 2) {
+ mtweak->drag_state = DRAG_IDLE;
+ gz->highlight_part = gz->drag_part;
+ }
+ }
+ else if (event->type == mtweak->init_event && event->val == KM_RELEASE) {
+ mtweak->drag_state = DRAG_NOP;
+ retval = OPERATOR_FINISHED;
+ }
+
+ if (mtweak->drag_state != DRAG_DETECT) {
+ /* Follow logic in 'gizmo_tweak_invoke' */
+ bool is_modal = false;
+ if (gizmo_tweak_start_and_finish(C, gzmap, gz, event, &is_modal)) {
+ if (is_modal) {
+ clear_modal = false;
+ }
+ }
+ else {
+ if (!gizmo_tweak_start(C, gzmap, gz, event)) {
+ retval = OPERATOR_FINISHED;
+ }
+ }
+ }
+ }
+ if (mtweak->drag_state == DRAG_IDLE) {
+ if (gzmap->gzmap_context.modal != NULL) {
+ return OPERATOR_PASS_THROUGH;
+ }
+ else {
+ gizmo_tweak_finish(C, op, false, false);
+ return OPERATOR_FINISHED;
+ }
+ }
+#endif /* USE_DRAG_DETECT */
+
+ if (retval == OPERATOR_FINISHED) {
+ /* pass */
+ }
+ else if (event->type == mtweak->init_event && event->val == KM_RELEASE) {
+ retval = OPERATOR_FINISHED;
+ }
+ else if (event->type == EVT_MODAL_MAP) {
+ switch (event->val) {
+ case TWEAK_MODAL_CANCEL:
+ retval = OPERATOR_CANCELLED;
+ break;
+ case TWEAK_MODAL_CONFIRM:
+ retval = OPERATOR_FINISHED;
+ break;
+ case TWEAK_MODAL_PRECISION_ON:
+ mtweak->flag |= WM_GIZMO_TWEAK_PRECISE;
+ break;
+ case TWEAK_MODAL_PRECISION_OFF:
+ mtweak->flag &= ~WM_GIZMO_TWEAK_PRECISE;
+ break;
+
+ case TWEAK_MODAL_SNAP_ON:
+ mtweak->flag |= WM_GIZMO_TWEAK_SNAP;
+ break;
+ case TWEAK_MODAL_SNAP_OFF:
+ mtweak->flag &= ~WM_GIZMO_TWEAK_SNAP;
+ break;
+ }
+ }
+
+ if (retval != OPERATOR_PASS_THROUGH) {
+ gizmo_tweak_finish(C, op, retval != OPERATOR_FINISHED, clear_modal);
+ return retval;
+ }
+
+ /* handle gizmo */
+ wmGizmoFnModal modal_fn = gz->custom_modal ? gz->custom_modal : gz->type->modal;
+ if (modal_fn) {
+ int modal_retval = modal_fn(C, gz, event, mtweak->flag);
+
+ if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) {
+ gizmo_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true);
+ return OPERATOR_FINISHED;
+ }
+
+ /* Ugly hack to send gizmo events */
+ ((wmEvent *)event)->type = EVT_GIZMO_UPDATE;
+ }
+
+ /* always return PASS_THROUGH so modal handlers
+ * with gizmos attached can update */
+ BLI_assert(retval == OPERATOR_PASS_THROUGH);
+ return OPERATOR_PASS_THROUGH;
+}
+
+static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ARegion *ar = CTX_wm_region(C);
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ wmGizmo *gz = gzmap->gzmap_context.highlight;
+
+ /* Needed for single click actions which don't enter modal state. */
+ WM_tooltip_clear(C, CTX_wm_window(C));
+
+ if (!gz) {
+ /* wm_handlers_do_intern shouldn't let this happen */
+ BLI_assert(0);
+ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
+ }
+
+ bool use_drag_fallback = false;
+
+#ifdef USE_DRAG_DETECT
+ use_drag_fallback = !ELEM(gz->drag_part, -1, gz->highlight_part);
+#endif
+
+ if (use_drag_fallback == false) {
+ if (gizmo_tweak_start_and_finish(C, gzmap, gz, event, NULL)) {
+ return OPERATOR_FINISHED;
+ }
+ }
+
+ bool use_drag_detect = false;
+#ifdef USE_DRAG_DETECT
+ if (use_drag_fallback) {
+ wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, gz->highlight_part);
+ if (mpop && mpop->type) {
+ if (mpop->type->modal == NULL) {
+ use_drag_detect = true;
+ }
+ }
+ }
+#endif
+
+ if (use_drag_detect == false) {
+ if (!gizmo_tweak_start(C, gzmap, gz, event)) {
+ /* failed to start */
+ return OPERATOR_PASS_THROUGH;
+ }
+ }
+
+ GizmoTweakData *mtweak = MEM_mallocN(sizeof(GizmoTweakData), __func__);
+
+ mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type);
+ mtweak->gz_modal = gzmap->gzmap_context.highlight;
+ mtweak->gzgroup = mtweak->gz_modal->parent_gzgroup;
+ mtweak->gzmap = gzmap;
+ mtweak->flag = 0;
+
+#ifdef USE_DRAG_DETECT
+ mtweak->drag_state = use_drag_detect ? DRAG_DETECT : DRAG_NOP;
+#endif
+
+ op->customdata = mtweak;
+
+ WM_event_add_modal_handler(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void GIZMOGROUP_OT_gizmo_tweak(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Gizmo Tweak";
+ ot->description = "Tweak the active gizmo";
+ ot->idname = "GIZMOGROUP_OT_gizmo_tweak";
+
+ /* api callbacks */
+ ot->invoke = gizmo_tweak_invoke;
+ ot->modal = gizmo_tweak_modal;
+
+ /* TODO(campbell) This causes problems tweaking settings for operators,
+ * need to find a way to support this. */
+#if 0
+ ot->flag = OPTYPE_UNDO;
+#endif
+}
+
+/** \} */
+
+
+static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *gzgroupname)
+{
+ wmKeyMap *keymap;
+ char name[KMAP_MAX_NAME];
+
+ static EnumPropertyItem modal_items[] = {
+ {TWEAK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
+ {TWEAK_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
+ {TWEAK_MODAL_PRECISION_ON, "PRECISION_ON", 0, "Enable Precision", ""},
+ {TWEAK_MODAL_PRECISION_OFF, "PRECISION_OFF", 0, "Disable Precision", ""},
+ {TWEAK_MODAL_SNAP_ON, "SNAP_ON", 0, "Enable Snap", ""},
+ {TWEAK_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Disable Snap", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+
+ BLI_snprintf(name, sizeof(name), "%s Tweak Modal Map", gzgroupname);
+ keymap = WM_modalkeymap_get(keyconf, name);
+
+ /* this function is called for each spacetype, only needs to add map once */
+ if (keymap && keymap->modal_items)
+ return NULL;
+
+ keymap = WM_modalkeymap_add(keyconf, name, modal_items);
+
+
+ /* items for modal map */
+ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL);
+ WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL);
+
+ WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM);
+
+ WM_modalkeymap_add_item(keymap, RIGHTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON);
+ WM_modalkeymap_add_item(keymap, RIGHTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF);
+ WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON);
+ WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF);
+
+ WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON);
+ WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF);
+ WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON);
+ WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF);
+
+ WM_modalkeymap_assign(keymap, "GIZMOGROUP_OT_gizmo_tweak");
+
+ return keymap;
+}
+
+/**
+ * Common default keymap for gizmo groups
+ */
+wmKeyMap *WM_gizmogroup_keymap_common(
+ const wmGizmoGroupType *gzgt, wmKeyConfig *config)
+{
+ /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */
+ wmKeyMap *km = WM_keymap_find(config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid);
+
+ WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
+ gizmogroup_tweak_modal_keymap(config, gzgt->name);
+
+ return km;
+}
+
+/**
+ * Variation of #WM_gizmogroup_keymap_common but with keymap items for selection
+ */
+wmKeyMap *WM_gizmogroup_keymap_common_select(
+ const wmGizmoGroupType *gzgt, wmKeyConfig *config)
+{
+ /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */
+ wmKeyMap *km = WM_keymap_find(config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid);
+
+ WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
+ WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", EVT_TWEAK_S, KM_ANY, 0, 0);
+ gizmogroup_tweak_modal_keymap(config, gzgt->name);
+
+ wmKeyMapItem *kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", SELECTMOUSE, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "extend", false);
+ RNA_boolean_set(kmi->ptr, "deselect", false);
+ RNA_boolean_set(kmi->ptr, "toggle", false);
+ kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", false);
+ RNA_boolean_set(kmi->ptr, "deselect", false);
+ RNA_boolean_set(kmi->ptr, "toggle", true);
+
+ return km;
+}
+
+/** \} */ /* wmGizmoGroup */
+
+/* -------------------------------------------------------------------- */
+/** \name wmGizmoGroupType
+ *
+ * \{ */
+
+struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr(
+ struct wmGizmoMapType *gzmap_type,
+ const wmGizmoGroupType *gzgt)
+{
+ /* could use hash lookups as operator types do, for now simple search. */
+ for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first;
+ gzgt_ref;
+ gzgt_ref = gzgt_ref->next)
+ {
+ if (gzgt_ref->type == gzgt) {
+ return gzgt_ref;
+ }
+ }
+ return NULL;
+}
+
+struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(
+ struct wmGizmoMapType *gzmap_type,
+ const char *idname)
+{
+ /* could use hash lookups as operator types do, for now simple search. */
+ for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first;
+ gzgt_ref;
+ gzgt_ref = gzgt_ref->next)
+ {
+ if (STREQ(idname, gzgt_ref->type->idname)) {
+ return gzgt_ref;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * Use this for registering gizmos on startup. For runtime, use #WM_gizmomaptype_group_link_runtime.
+ */
+wmGizmoGroupTypeRef *WM_gizmomaptype_group_link(
+ wmGizmoMapType *gzmap_type, const char *idname)
+{
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
+ BLI_assert(gzgt != NULL);
+ return WM_gizmomaptype_group_link_ptr(gzmap_type, gzgt);
+}
+
+wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr(
+ wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
+{
+ wmGizmoGroupTypeRef *gzgt_ref = MEM_callocN(sizeof(wmGizmoGroupTypeRef), "gizmo-group-ref");
+ gzgt_ref->type = gzgt;
+ BLI_addtail(&gzmap_type->grouptype_refs, gzgt_ref);
+ return gzgt_ref;
+}
+
+void WM_gizmomaptype_group_init_runtime_keymap(
+ const Main *bmain,
+ wmGizmoGroupType *gzgt)
+{
+ /* init keymap - on startup there's an extra call to init keymaps for 'permanent' gizmo-groups */
+ wm_gizmogrouptype_setup_keymap(gzgt, ((wmWindowManager *)bmain->wm.first)->defaultconf);
+}
+
+void WM_gizmomaptype_group_init_runtime(
+ const Main *bmain, wmGizmoMapType *gzmap_type,
+ wmGizmoGroupType *gzgt)
+{
+ /* now create a gizmo for all existing areas */
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ARegion *ar = lb->first; ar; ar = ar->next) {
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ if (gzmap && gzmap->type == gzmap_type) {
+ wm_gizmogroup_new_from_type(gzmap, gzgt);
+
+ /* just add here, drawing will occur on next update */
+ wm_gizmomap_highlight_set(gzmap, NULL, NULL, 0);
+ ED_region_tag_redraw(ar);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * Unlike #WM_gizmomaptype_group_unlink this doesn't maintain correct state, simply free.
+ */
+void WM_gizmomaptype_group_free(wmGizmoGroupTypeRef *gzgt_ref)
+{
+ MEM_freeN(gzgt_ref);
+}
+
+void WM_gizmomaptype_group_unlink(
+ bContext *C, Main *bmain, wmGizmoMapType *gzmap_type,
+ const wmGizmoGroupType *gzgt)
+{
+ /* Free instances. */
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ARegion *ar = lb->first; ar; ar = ar->next) {
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ if (gzmap && gzmap->type == gzmap_type) {
+ wmGizmoGroup *gzgroup, *gzgroup_next;
+ for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup_next) {
+ gzgroup_next = gzgroup->next;
+ if (gzgroup->type == gzgt) {
+ BLI_assert(gzgroup->parent_gzmap == gzmap);
+ wm_gizmogroup_free(C, gzgroup);
+ ED_region_tag_redraw(ar);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* Free types. */
+ wmGizmoGroupTypeRef *gzgt_ref = WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt);
+ if (gzgt_ref) {
+ BLI_remlink(&gzmap_type->grouptype_refs, gzgt_ref);
+ WM_gizmomaptype_group_free(gzgt_ref);
+ }
+
+ /* Note, we may want to keep this keymap for editing */
+ WM_keymap_remove(gzgt->keyconf, gzgt->keymap);
+
+ BLI_assert(WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt) == NULL);
+}
+
+void wm_gizmogrouptype_setup_keymap(
+ wmGizmoGroupType *gzgt, wmKeyConfig *keyconf)
+{
+ /* Use flag since setup_keymap may return NULL,
+ * in that case we better not keep calling it. */
+ if (gzgt->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) {
+ gzgt->keymap = gzgt->setup_keymap(gzgt, keyconf);
+ gzgt->keyconf = keyconf;
+ gzgt->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT;
+ }
+}
+
+/** \} */ /* wmGizmoGroupType */
+
+/* -------------------------------------------------------------------- */
+/** \name High Level Add/Remove API
+ *
+ * For use directly from operators & RNA registration.
+ *
+ * \note In context of gizmo API these names are a bit misleading,
+ * but for general use terms its OK.
+ * `WM_gizmo_group_type_add` would be more correctly called:
+ * `WM_gizmomaptype_grouptype_reference_link`
+ * but for general purpose API this is too detailed & annoying.
+ *
+ * \note We may want to return a value if there is nothing to remove.
+ *
+ * \{ */
+
+void WM_gizmo_group_type_add_ptr_ex(
+ wmGizmoGroupType *gzgt,
+ wmGizmoMapType *gzmap_type)
+{
+ WM_gizmomaptype_group_link_ptr(gzmap_type, gzgt);
+
+ WM_gizmoconfig_update_tag_init(gzmap_type, gzgt);
+}
+void WM_gizmo_group_type_add_ptr(
+ wmGizmoGroupType *gzgt)
+{
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
+ WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
+}
+void WM_gizmo_group_type_add(const char *idname)
+{
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
+ BLI_assert(gzgt != NULL);
+ WM_gizmo_group_type_add_ptr(gzgt);
+}
+
+void WM_gizmo_group_type_ensure_ptr_ex(
+ wmGizmoGroupType *gzgt,
+ wmGizmoMapType *gzmap_type)
+{
+ wmGizmoGroupTypeRef *gzgt_ref = WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt);
+ if (gzgt_ref == NULL) {
+ WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
+ }
+}
+void WM_gizmo_group_type_ensure_ptr(
+ wmGizmoGroupType *gzgt)
+{
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
+ WM_gizmo_group_type_ensure_ptr_ex(gzgt, gzmap_type);
+}
+void WM_gizmo_group_type_ensure(const char *idname)
+{
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
+ BLI_assert(gzgt != NULL);
+ WM_gizmo_group_type_ensure_ptr(gzgt);
+}
+
+void WM_gizmo_group_type_remove_ptr_ex(
+ struct Main *bmain, wmGizmoGroupType *gzgt,
+ wmGizmoMapType *gzmap_type)
+{
+ WM_gizmomaptype_group_unlink(NULL, bmain, gzmap_type, gzgt);
+ WM_gizmogrouptype_free_ptr(gzgt);
+}
+void WM_gizmo_group_type_remove_ptr(
+ struct Main *bmain, wmGizmoGroupType *gzgt)
+{
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
+ WM_gizmo_group_type_remove_ptr_ex(bmain, gzgt, gzmap_type);
+}
+void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname)
+{
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
+ BLI_assert(gzgt != NULL);
+ WM_gizmo_group_type_remove_ptr(bmain, gzgt);
+}
+
+/* delayed versions */
+
+void WM_gizmo_group_type_unlink_delayed_ptr_ex(
+ wmGizmoGroupType *gzgt,
+ wmGizmoMapType *gzmap_type)
+{
+ WM_gizmoconfig_update_tag_remove(gzmap_type, gzgt);
+}
+
+void WM_gizmo_group_type_unlink_delayed_ptr(
+ wmGizmoGroupType *gzgt)
+{
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
+ WM_gizmo_group_type_unlink_delayed_ptr_ex(gzgt, gzmap_type);
+}
+
+void WM_gizmo_group_type_unlink_delayed(const char *idname)
+{
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
+ BLI_assert(gzgt != NULL);
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c
new file mode 100644
index 00000000000..a44005a7d28
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c
@@ -0,0 +1,197 @@
+/*
+ * ***** 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/windowmanager/gizmo/intern/wm_gizmo_group_type.c
+ * \ingroup wm
+ */
+
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+#include "BLI_string.h"
+#include "BLI_string_utils.h"
+
+#include "BKE_context.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+/* only for own init/exit calls (wm_gizmogrouptype_init/wm_gizmogrouptype_free) */
+#include "wm.h"
+
+/* own includes */
+#include "wm_gizmo_wmapi.h"
+#include "wm_gizmo_intern.h"
+
+
+/** \name GizmoGroup Type Append
+ *
+ * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
+ * \{ */
+
+static GHash *global_gizmogrouptype_hash = NULL;
+
+wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet)
+{
+ if (idname[0]) {
+ wmGizmoGroupType *gzgt;
+
+ gzgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname);
+ if (gzgt) {
+ return gzgt;
+ }
+
+ if (!quiet) {
+ printf("search for unknown gizmo group '%s'\n", idname);
+ }
+ }
+ else {
+ if (!quiet) {
+ printf("search for empty gizmo group\n");
+ }
+ }
+
+ return NULL;
+}
+
+/* caller must free */
+void WM_gizmogrouptype_iter(GHashIterator *ghi)
+{
+ BLI_ghashIterator_init(ghi, global_gizmogrouptype_hash);
+}
+
+static wmGizmoGroupType *wm_gizmogrouptype_append__begin(void)
+{
+ wmGizmoGroupType *gzgt = MEM_callocN(sizeof(wmGizmoGroupType), "gizmogrouptype");
+
+ return gzgt;
+}
+static void wm_gizmogrouptype_append__end(wmGizmoGroupType *gzgt)
+{
+ BLI_assert(gzgt->name != NULL);
+ BLI_assert(gzgt->idname != NULL);
+
+ gzgt->type_update_flag |= WM_GIZMOMAPTYPE_KEYMAP_INIT;
+
+ /* if not set, use default */
+ if (gzgt->setup_keymap == NULL) {
+ if (gzgt->flag & WM_GIZMOGROUPTYPE_SELECT) {
+ gzgt->setup_keymap = WM_gizmogroup_keymap_common_select;
+ }
+ else {
+ gzgt->setup_keymap = WM_gizmogroup_keymap_common;
+ }
+ }
+
+ BLI_ghash_insert(global_gizmogrouptype_hash, (void *)gzgt->idname, gzgt);
+}
+
+wmGizmoGroupType *WM_gizmogrouptype_append(
+ void (*wtfunc)(struct wmGizmoGroupType *))
+{
+ wmGizmoGroupType *gzgt = wm_gizmogrouptype_append__begin();
+ wtfunc(gzgt);
+ wm_gizmogrouptype_append__end(gzgt);
+ return gzgt;
+}
+
+wmGizmoGroupType *WM_gizmogrouptype_append_ptr(
+ void (*wtfunc)(struct wmGizmoGroupType *, void *), void *userdata)
+{
+ wmGizmoGroupType *gzgt = wm_gizmogrouptype_append__begin();
+ wtfunc(gzgt, userdata);
+ wm_gizmogrouptype_append__end(gzgt);
+ return gzgt;
+}
+
+/**
+ * Append and insert into a gizmo typemap.
+ * This is most common for C gizmos which are enabled by default.
+ */
+wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link(
+ wmGizmoMapType *gzmap_type,
+ void (*wtfunc)(struct wmGizmoGroupType *))
+{
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_append(wtfunc);
+
+ gzgt->gzmap_params.spaceid = gzmap_type->spaceid;
+ gzgt->gzmap_params.regionid = gzmap_type->regionid;
+
+ return WM_gizmomaptype_group_link_ptr(gzmap_type, gzgt);
+}
+
+/**
+ * Free but don't remove from ghash.
+ */
+static void gizmogrouptype_free(wmGizmoGroupType *gzgt)
+{
+ if (gzgt->ext.srna) { /* python gizmo group, allocs own string */
+ MEM_freeN((void *)gzgt->idname);
+ }
+
+ MEM_freeN(gzgt);
+}
+
+void WM_gizmogrouptype_free_ptr(wmGizmoGroupType *gzgt)
+{
+ BLI_assert(gzgt == WM_gizmogrouptype_find(gzgt->idname, false));
+
+ BLI_ghash_remove(global_gizmogrouptype_hash, gzgt->idname, NULL, NULL);
+
+ gizmogrouptype_free(gzgt);
+
+ /* XXX, TODO, update the world! */
+}
+
+bool WM_gizmogrouptype_free(const char *idname)
+{
+ wmGizmoGroupType *gzgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname);
+
+ if (gzgt == NULL) {
+ return false;
+ }
+
+ WM_gizmogrouptype_free_ptr(gzgt);
+
+ return true;
+}
+
+static void wm_gizmogrouptype_ghash_free_cb(wmGizmoGroupType *gzgt)
+{
+ gizmogrouptype_free(gzgt);
+}
+
+void wm_gizmogrouptype_free(void)
+{
+ BLI_ghash_free(global_gizmogrouptype_hash, NULL, (GHashValFreeFP)wm_gizmogrouptype_ghash_free_cb);
+ global_gizmogrouptype_hash = NULL;
+}
+
+/* called on initialize WM_init() */
+void wm_gizmogrouptype_init(void)
+{
+ /* reserve size is set based on blender default setup */
+ global_gizmogrouptype_hash = BLI_ghash_str_new_ex("wm_gizmogrouptype_init gh", 128);
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
new file mode 100644
index 00000000000..d4a9dc4f54c
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
@@ -0,0 +1,144 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
+ * \ingroup wm
+ */
+
+
+#ifndef __WM_GIZMO_INTERN_H__
+#define __WM_GIZMO_INTERN_H__
+
+struct wmKeyConfig;
+struct wmGizmoMap;
+struct GizmoGeomInfo;
+struct GHashIterator;
+
+#include "wm_gizmo_fn.h"
+
+/* -------------------------------------------------------------------- */
+/* wmGizmo */
+
+
+bool wm_gizmo_select_set_ex(
+ struct wmGizmoMap *gzmap, struct wmGizmo *gz, bool select,
+ bool use_array, bool use_callback);
+bool wm_gizmo_select_and_highlight(bContext *C, struct wmGizmoMap *gzmap, struct wmGizmo *gz);
+
+void wm_gizmo_calculate_scale(struct wmGizmo *gz, const bContext *C);
+void wm_gizmo_update(struct wmGizmo *gz, const bContext *C, const bool refresh_map);
+
+int wm_gizmo_is_visible(struct wmGizmo *gz);
+enum {
+ WM_GIZMO_IS_VISIBLE_UPDATE = (1 << 0),
+ WM_GIZMO_IS_VISIBLE_DRAW = (1 << 1),
+};
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoGroup */
+
+enum {
+ TWEAK_MODAL_CANCEL = 1,
+ TWEAK_MODAL_CONFIRM,
+ TWEAK_MODAL_PRECISION_ON,
+ TWEAK_MODAL_PRECISION_OFF,
+ TWEAK_MODAL_SNAP_ON,
+ TWEAK_MODAL_SNAP_OFF,
+};
+
+struct wmGizmoGroup *wm_gizmogroup_new_from_type(
+ struct wmGizmoMap *gzmap, struct wmGizmoGroupType *gzgt);
+void wm_gizmogroup_free(bContext *C, struct wmGizmoGroup *gzgroup);
+void wm_gizmogroup_gizmo_register(struct wmGizmoGroup *gzgroup, struct wmGizmo *gz);
+struct wmGizmo *wm_gizmogroup_find_intersected_gizmo(
+ const struct wmGizmoGroup *gzgroup, struct bContext *C, const struct wmEvent *event,
+ int *r_part);
+void wm_gizmogroup_intersectable_gizmos_to_list(
+ const struct wmGizmoGroup *gzgroup, struct ListBase *listbase);
+void wm_gizmogroup_ensure_initialized(struct wmGizmoGroup *gzgroup, const struct bContext *C);
+bool wm_gizmogroup_is_visible_in_drawstep(
+ const struct wmGizmoGroup *gzgroup, const eWM_GizmoFlagMapDrawStep drawstep);
+
+void wm_gizmogrouptype_setup_keymap(
+ struct wmGizmoGroupType *gzgt, struct wmKeyConfig *keyconf);
+
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoMap */
+
+typedef struct wmGizmoMapSelectState {
+ struct wmGizmo **items;
+ int len, len_alloc;
+} wmGizmoMapSelectState;
+
+struct wmGizmoMap {
+
+ struct wmGizmoMapType *type;
+ ListBase groups; /* wmGizmoGroup */
+
+ /* private, update tagging (enum defined in C source). */
+ char update_flag[WM_GIZMOMAP_DRAWSTEP_MAX];
+
+ /**
+ * \brief Gizmo map runtime context
+ *
+ * Contains information about this gizmo-map. Currently
+ * highlighted gizmo, currently selected gizmos, ...
+ */
+ struct {
+ /* we redraw the gizmo-map when this changes */
+ struct wmGizmo *highlight;
+ /* User has clicked this gizmo and it gets all input. */
+ struct wmGizmo *modal;
+ /* array for all selected gizmos */
+ struct wmGizmoMapSelectState select;
+ /* cursor location at point of entering modal (see: WM_GIZMO_GRAB_CURSOR) */
+ int event_xy[2];
+ short event_grabcursor;
+ /* until we have nice cursor push/pop API. */
+ int last_cursor;
+ } gzmap_context;
+};
+
+/**
+ * This is a container for all gizmo types that can be instantiated in a region.
+ * (similar to dropboxes).
+ *
+ * \note There is only ever one of these for every (area, region) combination.
+ */
+struct wmGizmoMapType {
+ struct wmGizmoMapType *next, *prev;
+ short spaceid, regionid;
+ /* types of gizmo-groups for this gizmo-map type */
+ ListBase grouptype_refs;
+
+ /* eGizmoMapTypeUpdateFlags */
+ eWM_GizmoFlagMapTypeUpdateFlag type_update_flag;
+};
+
+void wm_gizmomap_select_array_clear(struct wmGizmoMap *gzmap);
+bool wm_gizmomap_deselect_all(struct wmGizmoMap *gzmap);
+void wm_gizmomap_select_array_shrink(struct wmGizmoMap *gzmap, int len_subtract);
+void wm_gizmomap_select_array_push_back(struct wmGizmoMap *gzmap, wmGizmo *gz);
+void wm_gizmomap_select_array_remove(struct wmGizmoMap *gzmap, wmGizmo *gz);
+
+#endif
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
new file mode 100644
index 00000000000..9321ec674a9
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -0,0 +1,1209 @@
+/*
+ * ***** 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
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+ * \ingroup wm
+ */
+
+#include <string.h>
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_rect.h"
+#include "BLI_string.h"
+#include "BLI_ghash.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "GPU_glew.h"
+#include "GPU_matrix.h"
+#include "GPU_select.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "wm_event_system.h"
+
+/* for tool-tips */
+#include "UI_interface.h"
+
+#include "DEG_depsgraph.h"
+
+/* own includes */
+#include "wm_gizmo_wmapi.h"
+#include "wm_gizmo_intern.h"
+
+/**
+ * Store all gizmo-maps here. Anyone who wants to register a gizmo for a certain
+ * area type can query the gizmo-map to do so.
+ */
+static ListBase gizmomaptypes = {NULL, NULL};
+
+/**
+ * Update when gizmo-map types change.
+ */
+/* so operator removal can trigger update */
+typedef enum eWM_GizmoFlagGroupTypeGlobalFlag {
+ WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0),
+ WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1),
+} eWM_GizmoFlagGroupTypeGlobalFlag;
+
+static eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag = 0;
+
+/**
+ * Gizmo-map update tagging.
+ */
+enum {
+ /** #gizmomap_prepare_drawing has run */
+ GIZMOMAP_IS_PREPARE_DRAW = (1 << 0),
+ GIZMOMAP_IS_REFRESH_CALLBACK = (1 << 1),
+};
+
+
+/* -------------------------------------------------------------------- */
+/** \name wmGizmoMap Selection Array API
+ *
+ * Just handle ``wm_gizmomap_select_array_*``, not flags or callbacks.
+ *
+ * \{ */
+
+static void wm_gizmomap_select_array_ensure_len_alloc(wmGizmoMap *gzmap, int len)
+{
+ wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
+ if (len <= msel->len_alloc) {
+ return;
+ }
+ msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * len);
+ msel->len_alloc = len;
+}
+
+void wm_gizmomap_select_array_clear(wmGizmoMap *gzmap)
+{
+ wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
+ MEM_SAFE_FREE(msel->items);
+ msel->len = 0;
+ msel->len_alloc = 0;
+}
+
+void wm_gizmomap_select_array_shrink(wmGizmoMap *gzmap, int len_subtract)
+{
+ wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
+ msel->len -= len_subtract;
+ if (msel->len <= 0) {
+ wm_gizmomap_select_array_clear(gzmap);
+ }
+ else {
+ if (msel->len < msel->len_alloc / 2) {
+ msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len);
+ msel->len_alloc = msel->len;
+ }
+ }
+}
+
+void wm_gizmomap_select_array_push_back(wmGizmoMap *gzmap, wmGizmo *gz)
+{
+ wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
+ BLI_assert(msel->len <= msel->len_alloc);
+ if (msel->len == msel->len_alloc) {
+ msel->len_alloc = (msel->len + 1) * 2;
+ msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len_alloc);
+ }
+ msel->items[msel->len++] = gz;
+}
+
+void wm_gizmomap_select_array_remove(wmGizmoMap *gzmap, wmGizmo *gz)
+{
+ wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
+ /* remove gizmo from selected_gizmos array */
+ for (int i = 0; i < msel->len; i++) {
+ if (msel->items[i] == gz) {
+ for (int j = i; j < (msel->len - 1); j++) {
+ msel->items[j] = msel->items[j + 1];
+ }
+ wm_gizmomap_select_array_shrink(gzmap, 1);
+ break;
+ }
+ }
+
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/** \name wmGizmoMap
+ *
+ * \{ */
+
+/**
+ * Creates a gizmo-map with all registered gizmos for that type
+ */
+wmGizmoMap *WM_gizmomap_new_from_type(
+ const struct wmGizmoMapType_Params *gzmap_params)
+{
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(gzmap_params);
+ wmGizmoMap *gzmap;
+
+ gzmap = MEM_callocN(sizeof(wmGizmoMap), "GizmoMap");
+ gzmap->type = gzmap_type;
+ WM_gizmomap_tag_refresh(gzmap);
+
+ /* create all gizmo-groups for this gizmo-map. We may create an empty one
+ * too in anticipation of gizmos from operators etc */
+ for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; gzgt_ref = gzgt_ref->next) {
+ wm_gizmogroup_new_from_type(gzmap, gzgt_ref->type);
+ }
+
+ return gzmap;
+}
+
+void wm_gizmomap_remove(wmGizmoMap *gzmap)
+{
+ /* Clear first so further calls don't waste time trying to maintain correct array state. */
+ wm_gizmomap_select_array_clear(gzmap);
+
+ for (wmGizmoGroup *gzgroup = gzmap->groups.first, *gzgroup_next; gzgroup; gzgroup = gzgroup_next) {
+ gzgroup_next = gzgroup->next;
+ BLI_assert(gzgroup->parent_gzmap == gzmap);
+ wm_gizmogroup_free(NULL, gzgroup);
+ }
+ BLI_assert(BLI_listbase_is_empty(&gzmap->groups));
+
+ MEM_freeN(gzmap);
+}
+
+
+wmGizmoGroup *WM_gizmomap_group_find(
+ struct wmGizmoMap *gzmap,
+ const char *idname)
+{
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
+ if (gzgt) {
+ return WM_gizmomap_group_find_ptr(gzmap, gzgt);
+ }
+ return NULL;
+}
+
+wmGizmoGroup *WM_gizmomap_group_find_ptr(
+ struct wmGizmoMap *gzmap,
+ const struct wmGizmoGroupType *gzgt)
+{
+ for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ if (gzgroup->type == gzgt) {
+ return gzgroup;
+ }
+ }
+ return NULL;
+}
+
+const ListBase *WM_gizmomap_group_list(wmGizmoMap *gzmap)
+{
+ return &gzmap->groups;
+}
+
+bool WM_gizmomap_is_any_selected(const wmGizmoMap *gzmap)
+{
+ return gzmap->gzmap_context.select.len != 0;
+}
+
+/**
+ * \note We could use a callback to define bounds, for now just use matrix location.
+ */
+bool WM_gizmomap_minmax(
+ const wmGizmoMap *gzmap, bool UNUSED(use_hidden), bool use_select,
+ float r_min[3], float r_max[3])
+{
+ if (use_select) {
+ int i;
+ for (i = 0; i < gzmap->gzmap_context.select.len; i++) {
+ minmax_v3v3_v3(r_min, r_max, gzmap->gzmap_context.select.items[i]->matrix_basis[3]);
+ }
+ return i != 0;
+ }
+ else {
+ bool ok = false;
+ BLI_assert(!"TODO");
+ return ok;
+ }
+}
+
+/**
+ * Creates and returns idname hash table for (visible) gizmos in \a gzmap
+ *
+ * \param poll Polling function for excluding gizmos.
+ * \param data Custom data passed to \a poll
+ *
+ * TODO(campbell): this uses unreliable order,
+ * best we use an iterator function instead of a hash.
+ */
+static GHash *WM_gizmomap_gizmo_hash_new(
+ const bContext *C, wmGizmoMap *gzmap,
+ bool (*poll)(const wmGizmo *, void *),
+ void *data, const bool include_hidden)
+{
+ GHash *hash = BLI_ghash_ptr_new(__func__);
+
+ /* collect gizmos */
+ for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ if (WM_gizmo_group_type_poll(C, gzgroup->type)) {
+ for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ if ((include_hidden || (gz->flag & WM_GIZMO_HIDDEN) == 0) &&
+ (!poll || poll(gz, data)))
+ {
+ BLI_ghash_insert(hash, gz, gz);
+ }
+ }
+ }
+ }
+
+ return hash;
+}
+
+void WM_gizmomap_tag_refresh(wmGizmoMap *gzmap)
+{
+ if (gzmap) {
+ /* We might want only to refresh some, for tag all steps. */
+ for (int i = 0; i < WM_GIZMOMAP_DRAWSTEP_MAX; i++) {
+ gzmap->update_flag[i] |= (
+ GIZMOMAP_IS_PREPARE_DRAW |
+ GIZMOMAP_IS_REFRESH_CALLBACK);
+ }
+ }
+}
+
+static bool gizmo_prepare_drawing(
+ wmGizmoMap *gzmap, wmGizmo *gz,
+ const bContext *C, ListBase *draw_gizmos,
+ const eWM_GizmoFlagMapDrawStep drawstep)
+{
+ int do_draw = wm_gizmo_is_visible(gz);
+ if (do_draw == 0) {
+ /* skip */
+ }
+ else {
+ /* Ensure we get RNA updates */
+ if (do_draw & WM_GIZMO_IS_VISIBLE_UPDATE) {
+ /* hover gizmos need updating, even if we don't draw them */
+ wm_gizmo_update(gz, C, (gzmap->update_flag[drawstep] & GIZMOMAP_IS_PREPARE_DRAW) != 0);
+ }
+ if (do_draw & WM_GIZMO_IS_VISIBLE_DRAW) {
+ BLI_addhead(draw_gizmos, BLI_genericNodeN(gz));
+ }
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Update gizmos of \a gzmap to prepare for drawing. Adds all gizmos that
+ * should be drawn to list \a draw_gizmos, note that added items need freeing.
+ */
+static void gizmomap_prepare_drawing(
+ wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos,
+ const eWM_GizmoFlagMapDrawStep drawstep)
+{
+ if (!gzmap || BLI_listbase_is_empty(&gzmap->groups))
+ return;
+ wmGizmo *gz_modal = gzmap->gzmap_context.modal;
+
+ /* only active gizmo needs updating */
+ if (gz_modal) {
+ if ((gz_modal->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL) == 0) {
+ if (wm_gizmogroup_is_visible_in_drawstep(gz_modal->parent_gzgroup, drawstep)) {
+ if (gizmo_prepare_drawing(gzmap, gz_modal, C, draw_gizmos, drawstep)) {
+ gzmap->update_flag[drawstep] &= ~GIZMOMAP_IS_PREPARE_DRAW;
+ }
+ }
+ /* don't draw any other gizmos */
+ return;
+ }
+ }
+
+ for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */
+ if (!wm_gizmogroup_is_visible_in_drawstep(gzgroup, drawstep) ||
+ !WM_gizmo_group_type_poll(C, gzgroup->type))
+ {
+ continue;
+ }
+
+ /* needs to be initialized on first draw */
+ /* XXX weak: Gizmo-group may skip refreshing if it's invisible (map gets untagged nevertheless) */
+ if (gzmap->update_flag[drawstep] & GIZMOMAP_IS_REFRESH_CALLBACK) {
+ /* force refresh again. */
+ gzgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH;
+ }
+ /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */
+ wm_gizmogroup_ensure_initialized(gzgroup, C);
+
+ /* prepare drawing */
+ if (gzgroup->type->draw_prepare) {
+ gzgroup->type->draw_prepare(C, gzgroup);
+ }
+
+ for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ gizmo_prepare_drawing(gzmap, gz, C, draw_gizmos, drawstep);
+ }
+ }
+
+ gzmap->update_flag[drawstep] &=
+ ~(GIZMOMAP_IS_REFRESH_CALLBACK |
+ GIZMOMAP_IS_PREPARE_DRAW);
+}
+
+/**
+ * Draw all visible gizmos in \a gzmap.
+ * Uses global draw_gizmos listbase.
+ */
+static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos)
+{
+ /* Can be empty if we're dynamically added and removed. */
+ if ((gzmap == NULL) || BLI_listbase_is_empty(&gzmap->groups)) {
+ return;
+ }
+
+ /* TODO this will need it own shader probably? don't think it can be handled from that point though. */
+/* const bool use_lighting = (U.gizmo_flag & V3D_GIZMO_SHADED) != 0; */
+
+ bool is_depth_prev = false;
+
+ /* draw_gizmos contains all visible gizmos - draw them */
+ for (LinkData *link = draw_gizmos->first, *link_next; link; link = link_next) {
+ wmGizmo *gz = link->data;
+ link_next = link->next;
+
+ bool is_depth = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0;
+
+ /* Weak! since we don't 100% support depth yet (select ignores depth) always show highlighted */
+ if (is_depth && (gz->state & WM_GIZMO_STATE_HIGHLIGHT)) {
+ is_depth = false;
+ }
+
+ if (is_depth == is_depth_prev) {
+ /* pass */
+ }
+ else {
+ if (is_depth) {
+ glEnable(GL_DEPTH_TEST);
+ }
+ else {
+ glDisable(GL_DEPTH_TEST);
+ }
+ is_depth_prev = is_depth;
+ }
+
+ /* XXX force AntiAlias Gizmos. */
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_POLYGON_SMOOTH);
+
+ gz->type->draw(C, gz);
+
+ glDisable(GL_LINE_SMOOTH);
+ glDisable(GL_POLYGON_SMOOTH);
+
+ /* free/remove gizmo link after drawing */
+ BLI_freelinkN(draw_gizmos, link);
+ }
+
+ if (is_depth_prev) {
+ glDisable(GL_DEPTH_TEST);
+ }
+}
+
+void WM_gizmomap_draw(
+ wmGizmoMap *gzmap, const bContext *C,
+ const eWM_GizmoFlagMapDrawStep drawstep)
+{
+ if (!WM_gizmo_context_check_drawstep(C, drawstep)) {
+ return;
+ }
+
+ ListBase draw_gizmos = {NULL};
+
+ gizmomap_prepare_drawing(gzmap, C, &draw_gizmos, drawstep);
+ gizmos_draw_list(gzmap, C, &draw_gizmos);
+ BLI_assert(BLI_listbase_is_empty(&draw_gizmos));
+}
+
+static void gizmo_draw_select_3D_loop(const bContext *C, ListBase *visible_gizmos)
+{
+ int select_id = 0;
+ wmGizmo *gz;
+
+ /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */
+ bool is_depth_prev = false;
+ bool is_depth_skip_prev = false;
+
+ for (LinkData *link = visible_gizmos->first; link; link = link->next) {
+ gz = link->data;
+
+ bool is_depth = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0;
+ if (is_depth == is_depth_prev) {
+ /* pass */
+ }
+ else {
+ if (is_depth) {
+ glEnable(GL_DEPTH_TEST);
+ }
+ else {
+ glDisable(GL_DEPTH_TEST);
+ }
+ is_depth_prev = is_depth;
+ }
+ bool is_depth_skip = (gz->flag & WM_GIZMO_SELECT_BACKGROUND) != 0;
+ if (is_depth_skip == is_depth_skip_prev) {
+ /* pass */
+ }
+ else {
+ glDepthMask(!is_depth_skip);
+ is_depth_skip_prev = is_depth_skip;
+ }
+
+ /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected gizmo part id */
+
+ gz->type->draw_select(C, gz, select_id << 8);
+
+
+ select_id++;
+ }
+
+ if (is_depth_prev) {
+ glDisable(GL_DEPTH_TEST);
+ }
+ if (is_depth_skip_prev) {
+ glDepthMask(true);
+ }
+}
+
+static int gizmo_find_intersected_3d_intern(
+ ListBase *visible_gizmos, const bContext *C, const int co[2],
+ const int hotspot)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+ View3D *v3d = sa->spacedata.first;
+ rcti rect;
+ /* Almost certainly overkill, but allow for many custom gizmos. */
+ GLuint buffer[MAXPICKBUF];
+ short hits;
+ const bool do_passes = GPU_select_query_check_active();
+
+ BLI_rcti_init_pt_radius(&rect, co, hotspot);
+
+ ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, &rect);
+
+ if (do_passes)
+ GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0);
+ else
+ GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_ALL, 0);
+ /* do the drawing */
+ gizmo_draw_select_3D_loop(C, visible_gizmos);
+
+ hits = GPU_select_end();
+
+ if (do_passes && (hits > 0)) {
+ GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits);
+ gizmo_draw_select_3D_loop(C, visible_gizmos);
+ GPU_select_end();
+ }
+
+ ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, NULL);
+
+ const GLuint *hit_near = GPU_select_buffer_near(buffer, hits);
+
+ return hit_near ? hit_near[3] : -1;
+}
+
+/**
+ * Try to find a 3D gizmo at screen-space coordinate \a co. Uses OpenGL picking.
+ */
+static wmGizmo *gizmo_find_intersected_3d(
+ bContext *C, const int co[2], ListBase *visible_gizmos,
+ int *r_part)
+{
+ wmGizmo *result = NULL;
+ int hit = -1;
+
+ int hotspot_radii[] = {
+ 3 * U.pixelsize,
+ /* This runs on mouse move, careful doing too many tests! */
+ 10 * U.pixelsize,
+ };
+
+ *r_part = 0;
+
+ /* set up view matrices */
+ view3d_operator_needs_opengl(C);
+
+ hit = -1;
+
+ for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) {
+ hit = gizmo_find_intersected_3d_intern(visible_gizmos, C, co, hotspot_radii[i]);
+ if (hit != -1) {
+ break;
+ }
+ }
+
+ if (hit != -1) {
+ LinkData *link = BLI_findlink(visible_gizmos, hit >> 8);
+ if (link != NULL) {
+ *r_part = hit & 255;
+ result = link->data;
+ }
+ else {
+ /* All gizmos should use selection ID they're given as part of the callback,
+ * if they don't it will attempt tp lookup non-existing index. */
+ BLI_assert(0);
+ }
+ }
+
+ return result;
+}
+
+/**
+ * Try to find a gizmo under the mouse position. 2D intersections have priority over
+ * 3D ones (could check for smallest screen-space distance but not needed right now).
+ */
+wmGizmo *wm_gizmomap_highlight_find(
+ wmGizmoMap *gzmap, bContext *C, const wmEvent *event,
+ int *r_part)
+{
+ wmGizmo *gz = NULL;
+ ListBase visible_3d_gizmos = {NULL};
+ bool do_step[WM_GIZMOMAP_DRAWSTEP_MAX];
+
+ for (int i = 0; i < ARRAY_SIZE(do_step); i++) {
+ do_step[i] = WM_gizmo_context_check_drawstep(C, i);
+ }
+
+ for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+
+ /* If it were important we could initialize here,
+ * but this only happens when events are handled before drawing,
+ * just skip to keep code-path for initializing gizmos simple. */
+ if ((gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0) {
+ continue;
+ }
+
+ if (WM_gizmo_group_type_poll(C, gzgroup->type)) {
+ eWM_GizmoFlagMapDrawStep step;
+ if (gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
+ step = WM_GIZMOMAP_DRAWSTEP_3D;
+ }
+ else {
+ step = WM_GIZMOMAP_DRAWSTEP_2D;
+ }
+
+ if (do_step[step]) {
+ if ((gzmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) &&
+ (gzgroup->type->refresh != NULL))
+ {
+ gzgroup->type->refresh(C, gzgroup);
+ /* cleared below */
+ }
+ if (step == WM_GIZMOMAP_DRAWSTEP_3D) {
+ wm_gizmogroup_intersectable_gizmos_to_list(gzgroup, &visible_3d_gizmos);
+ }
+ else if (step == WM_GIZMOMAP_DRAWSTEP_2D) {
+ if ((gz = wm_gizmogroup_find_intersected_gizmo(gzgroup, C, event, r_part))) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!BLI_listbase_is_empty(&visible_3d_gizmos)) {
+ /* 2D gizmos get priority. */
+ if (gz == NULL) {
+ gz = gizmo_find_intersected_3d(C, event->mval, &visible_3d_gizmos, r_part);
+ }
+ BLI_freelistN(&visible_3d_gizmos);
+ }
+
+ gzmap->update_flag[WM_GIZMOMAP_DRAWSTEP_3D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK;
+ gzmap->update_flag[WM_GIZMOMAP_DRAWSTEP_2D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK;
+
+ return gz;
+}
+
+void WM_gizmomap_add_handlers(ARegion *ar, wmGizmoMap *gzmap)
+{
+ wmEventHandler *handler;
+
+ for (handler = ar->handlers.first; handler; handler = handler->next) {
+ if (handler->gizmo_map == gzmap) {
+ return;
+ }
+ }
+
+ handler = MEM_callocN(sizeof(wmEventHandler), "gizmo handler");
+
+ BLI_assert(gzmap == ar->gizmo_map);
+ handler->gizmo_map = gzmap;
+ BLI_addtail(&ar->handlers, handler);
+}
+
+void wm_gizmomaps_handled_modal_update(
+ bContext *C, wmEvent *event, wmEventHandler *handler)
+{
+ const bool modal_running = (handler->op != NULL);
+
+ /* happens on render or when joining areas */
+ if (!handler->op_region || !handler->op_region->gizmo_map) {
+ return;
+ }
+
+ wmGizmoMap *gzmap = handler->op_region->gizmo_map;
+ wmGizmo *gz = wm_gizmomap_modal_get(gzmap);
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region = CTX_wm_region(C);
+
+ wm_gizmomap_handler_context(C, handler);
+
+ /* regular update for running operator */
+ if (modal_running) {
+ wmGizmoOpElem *mpop = gz ? WM_gizmo_operator_get(gz, gz->highlight_part) : NULL;
+ if (gz && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) {
+ wmGizmoFnModal modal_fn = gz->custom_modal ? gz->custom_modal : gz->type->modal;
+ if (modal_fn != NULL) {
+ int retval = modal_fn(C, gz, event, 0);
+ /* The gizmo is tried to the operator, we can't choose when to exit. */
+ BLI_assert(retval & OPERATOR_RUNNING_MODAL);
+ UNUSED_VARS_NDEBUG(retval);
+ }
+ }
+ }
+ /* operator not running anymore */
+ else {
+ wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
+ if (gz) {
+ /* This isn't defined if it ends because of success of cancel, we may want to change. */
+ bool cancel = true;
+ if (gz->type->exit) {
+ gz->type->exit(C, gz, cancel);
+ }
+ wm_gizmomap_modal_set(gzmap, C, gz, NULL, false);
+ }
+ }
+
+ /* restore the area */
+ CTX_wm_area_set(C, area);
+ CTX_wm_region_set(C, region);
+}
+
+/**
+ * Deselect all selected gizmos in \a gzmap.
+ * \return if selection has changed.
+ */
+bool wm_gizmomap_deselect_all(wmGizmoMap *gzmap)
+{
+ wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
+
+ if (msel->items == NULL || msel->len == 0) {
+ return false;
+ }
+
+ for (int i = 0; i < msel->len; i++) {
+ wm_gizmo_select_set_ex(gzmap, msel->items[i], false, false, true);
+ }
+
+ wm_gizmomap_select_array_clear(gzmap);
+
+ /* always return true, we already checked
+ * if there's anything to deselect */
+ return true;
+}
+
+BLI_INLINE bool gizmo_selectable_poll(const wmGizmo *gz, void *UNUSED(data))
+{
+ return (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT);
+}
+
+/**
+ * Select all selectable gizmos in \a gzmap.
+ * \return if selection has changed.
+ */
+static bool wm_gizmomap_select_all_intern(
+ bContext *C, wmGizmoMap *gzmap)
+{
+ wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
+ /* GHash is used here to avoid having to loop over all gizmos twice (once to
+ * get tot_sel for allocating, once for actually selecting). Instead we collect
+ * selectable gizmos in hash table and use this to get tot_sel and do selection */
+
+ GHash *hash = WM_gizmomap_gizmo_hash_new(C, gzmap, gizmo_selectable_poll, NULL, true);
+ GHashIterator gh_iter;
+ int i;
+ bool changed = false;
+
+ wm_gizmomap_select_array_ensure_len_alloc(gzmap, BLI_ghash_len(hash));
+
+ GHASH_ITER_INDEX (gh_iter, hash, i) {
+ wmGizmo *gz_iter = BLI_ghashIterator_getValue(&gh_iter);
+ WM_gizmo_select_set(gzmap, gz_iter, true);
+ }
+ /* highlight first gizmo */
+ wm_gizmomap_highlight_set(gzmap, C, msel->items[0], msel->items[0]->highlight_part);
+
+ BLI_assert(BLI_ghash_len(hash) == msel->len);
+
+ BLI_ghash_free(hash, NULL, NULL);
+ return changed;
+}
+
+/**
+ * Select/Deselect all selectable gizmos in \a gzmap.
+ * \return if selection has changed.
+ *
+ * TODO select all by type
+ */
+bool WM_gizmomap_select_all(bContext *C, wmGizmoMap *gzmap, const int action)
+{
+ bool changed = false;
+
+ switch (action) {
+ case SEL_SELECT:
+ changed = wm_gizmomap_select_all_intern(C, gzmap);
+ break;
+ case SEL_DESELECT:
+ changed = wm_gizmomap_deselect_all(gzmap);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+
+ if (changed)
+ WM_event_add_mousemove(C);
+
+ return changed;
+}
+
+/**
+ * Prepare context for gizmo handling (but only if area/region is
+ * part of screen). Version of #wm_handler_op_context for gizmos.
+ */
+void wm_gizmomap_handler_context(bContext *C, wmEventHandler *handler)
+{
+ bScreen *screen = CTX_wm_screen(C);
+
+ if (screen) {
+ if (handler->op_area == NULL) {
+ /* do nothing in this context */
+ }
+ else {
+ ScrArea *sa;
+
+ for (sa = screen->areabase.first; sa; sa = sa->next)
+ if (sa == handler->op_area)
+ break;
+ if (sa == NULL) {
+ /* when changing screen layouts with running modal handlers (like render display), this
+ * is not an error to print */
+ if (handler->gizmo_map == NULL)
+ printf("internal error: modal gizmo-map handler has invalid area\n");
+ }
+ else {
+ ARegion *ar;
+ CTX_wm_area_set(C, sa);
+ for (ar = sa->regionbase.first; ar; ar = ar->next)
+ if (ar == handler->op_region)
+ break;
+ /* XXX no warning print here, after full-area and back regions are remade */
+ if (ar)
+ CTX_wm_region_set(C, ar);
+ }
+ }
+ }
+}
+
+bool WM_gizmomap_cursor_set(const wmGizmoMap *gzmap, wmWindow *win)
+{
+ wmGizmo *gz = gzmap->gzmap_context.highlight;
+ if (gz && gz->type->cursor_get) {
+ WM_cursor_set(win, gz->type->cursor_get(gz));
+ return true;
+ }
+
+ return false;
+}
+
+bool wm_gizmomap_highlight_set(
+ wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz, int part)
+{
+ if ((gz != gzmap->gzmap_context.highlight) ||
+ (gz && part != gz->highlight_part))
+ {
+ if (gzmap->gzmap_context.highlight) {
+ gzmap->gzmap_context.highlight->state &= ~WM_GIZMO_STATE_HIGHLIGHT;
+ gzmap->gzmap_context.highlight->highlight_part = -1;
+ }
+
+ gzmap->gzmap_context.highlight = gz;
+
+ if (gz) {
+ gz->state |= WM_GIZMO_STATE_HIGHLIGHT;
+ gz->highlight_part = part;
+ gzmap->gzmap_context.last_cursor = -1;
+
+ if (C && gz->type->cursor_get) {
+ wmWindow *win = CTX_wm_window(C);
+ gzmap->gzmap_context.last_cursor = win->cursor;
+ WM_cursor_set(win, gz->type->cursor_get(gz));
+ }
+ }
+ else {
+ if (C && gzmap->gzmap_context.last_cursor != -1) {
+ wmWindow *win = CTX_wm_window(C);
+ WM_cursor_set(win, gzmap->gzmap_context.last_cursor);
+ }
+ }
+
+ /* tag the region for redraw */
+ if (C) {
+ ARegion *ar = CTX_wm_region(C);
+ ED_region_tag_redraw(ar);
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+wmGizmo *wm_gizmomap_highlight_get(wmGizmoMap *gzmap)
+{
+ return gzmap->gzmap_context.highlight;
+}
+
+/**
+ * Caller should call exit when (enable == False).
+ */
+void wm_gizmomap_modal_set(
+ wmGizmoMap *gzmap, bContext *C, wmGizmo *gz, const wmEvent *event, bool enable)
+{
+ if (enable) {
+ BLI_assert(gzmap->gzmap_context.modal == NULL);
+ wmWindow *win = CTX_wm_window(C);
+
+ WM_tooltip_clear(C, win);
+
+ if (gz->type->invoke &&
+ (gz->type->modal || gz->custom_modal))
+ {
+ const int retval = gz->type->invoke(C, gz, event);
+ if ((retval & OPERATOR_RUNNING_MODAL) == 0) {
+ return;
+ }
+ }
+
+ gz->state |= WM_GIZMO_STATE_MODAL;
+ gzmap->gzmap_context.modal = gz;
+
+ if ((gz->flag & WM_GIZMO_GRAB_CURSOR) &&
+ (event->is_motion_absolute == false))
+ {
+ WM_cursor_grab_enable(win, true, true, NULL);
+ copy_v2_v2_int(gzmap->gzmap_context.event_xy, &event->x);
+ gzmap->gzmap_context.event_grabcursor = win->grabcursor;
+ }
+ else {
+ gzmap->gzmap_context.event_xy[0] = INT_MAX;
+ }
+
+ struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, gz->highlight_part);
+ if (mpop && mpop->type) {
+ const int retval = WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr);
+ if ((retval & OPERATOR_RUNNING_MODAL) == 0) {
+ wm_gizmomap_modal_set(gzmap, C, gz, event, false);
+ }
+
+ /* we failed to hook the gizmo to the operator handler or operator was cancelled, return */
+ if (!gzmap->gzmap_context.modal) {
+ gz->state &= ~WM_GIZMO_STATE_MODAL;
+ MEM_SAFE_FREE(gz->interaction_data);
+ }
+ return;
+ }
+ }
+ else {
+ BLI_assert(ELEM(gzmap->gzmap_context.modal, NULL, gz));
+
+ /* deactivate, gizmo but first take care of some stuff */
+ if (gz) {
+ gz->state &= ~WM_GIZMO_STATE_MODAL;
+ MEM_SAFE_FREE(gz->interaction_data);
+ }
+ gzmap->gzmap_context.modal = NULL;
+
+ if (C) {
+ wmWindow *win = CTX_wm_window(C);
+ if (gzmap->gzmap_context.event_xy[0] != INT_MAX) {
+ /* Check if some other part of Blender (typically operators)
+ * have adjusted the grab mode since it was set.
+ * If so: warp, so we have a predictable outcome. */
+ if (gzmap->gzmap_context.event_grabcursor == win->grabcursor) {
+ WM_cursor_grab_disable(win, gzmap->gzmap_context.event_xy);
+ }
+ else {
+ WM_cursor_warp(win, UNPACK2(gzmap->gzmap_context.event_xy));
+ }
+ }
+ ED_region_tag_redraw(CTX_wm_region(C));
+ WM_event_add_mousemove(C);
+ }
+
+ gzmap->gzmap_context.event_xy[0] = INT_MAX;
+ }
+}
+
+wmGizmo *wm_gizmomap_modal_get(wmGizmoMap *gzmap)
+{
+ return gzmap->gzmap_context.modal;
+}
+
+wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *gzmap, int *r_selected_len)
+{
+ *r_selected_len = gzmap->gzmap_context.select.len;
+ return gzmap->gzmap_context.select.items;
+}
+
+ListBase *wm_gizmomap_groups_get(wmGizmoMap *gzmap)
+{
+ return &gzmap->groups;
+}
+
+void WM_gizmomap_message_subscribe(
+ bContext *C, wmGizmoMap *gzmap, ARegion *ar, struct wmMsgBus *mbus)
+{
+ for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ if (!WM_gizmo_group_type_poll(C, gzgroup->type)) {
+ continue;
+ }
+ for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ if (gz->flag & WM_GIZMO_HIDDEN) {
+ continue;
+ }
+ WM_gizmo_target_property_subscribe_all(gz, mbus, ar);
+ }
+ if (gzgroup->type->message_subscribe != NULL) {
+ gzgroup->type->message_subscribe(C, gzgroup, mbus);
+ }
+ }
+}
+
+/** \} */ /* wmGizmoMap */
+
+
+/* -------------------------------------------------------------------- */
+/** \name Tooltip Handling
+ *
+ * \{ */
+
+struct ARegion *WM_gizmomap_tooltip_init(
+ struct bContext *C, struct ARegion *ar, bool *r_exit_on_event)
+{
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ *r_exit_on_event = true;
+ if (gzmap) {
+ wmGizmo *gz = gzmap->gzmap_context.highlight;
+ if (gz) {
+ return UI_tooltip_create_from_gizmo(C, gz);
+ }
+ }
+ return NULL;
+}
+
+/** \} */ /* wmGizmoMapType */
+
+/* -------------------------------------------------------------------- */
+/** \name wmGizmoMapType
+ *
+ * \{ */
+
+wmGizmoMapType *WM_gizmomaptype_find(
+ const struct wmGizmoMapType_Params *gzmap_params)
+{
+ for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; gzmap_type = gzmap_type->next) {
+ if (gzmap_type->spaceid == gzmap_params->spaceid &&
+ gzmap_type->regionid == gzmap_params->regionid)
+ {
+ return gzmap_type;
+ }
+ }
+
+ return NULL;
+}
+
+wmGizmoMapType *WM_gizmomaptype_ensure(
+ const struct wmGizmoMapType_Params *gzmap_params)
+{
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_find(gzmap_params);
+
+ if (gzmap_type) {
+ return gzmap_type;
+ }
+
+ gzmap_type = MEM_callocN(sizeof(wmGizmoMapType), "gizmotype list");
+ gzmap_type->spaceid = gzmap_params->spaceid;
+ gzmap_type->regionid = gzmap_params->regionid;
+ BLI_addhead(&gizmomaptypes, gzmap_type);
+
+ return gzmap_type;
+}
+
+void wm_gizmomaptypes_free(void)
+{
+ for (wmGizmoMapType *gzmap_type = gizmomaptypes.first, *gzmap_type_next;
+ gzmap_type;
+ gzmap_type = gzmap_type_next)
+ {
+ gzmap_type_next = gzmap_type->next;
+ for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_next;
+ gzgt_ref;
+ gzgt_ref = gzgt_next)
+ {
+ gzgt_next = gzgt_ref->next;
+ WM_gizmomaptype_group_free(gzgt_ref);
+ }
+ MEM_freeN(gzmap_type);
+ }
+}
+
+/**
+ * Initialize keymaps for all existing gizmo-groups
+ */
+void wm_gizmos_keymap(wmKeyConfig *keyconf)
+{
+ /* we add this item-less keymap once and use it to group gizmo-group keymaps into it */
+ WM_keymap_find(keyconf, "Gizmos", 0, 0);
+
+ for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; gzmap_type = gzmap_type->next) {
+ for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; gzgt_ref = gzgt_ref->next) {
+ wm_gizmogrouptype_setup_keymap(gzgt_ref->type, keyconf);
+ }
+ }
+}
+
+/** \} */ /* wmGizmoMapType */
+
+/* -------------------------------------------------------------------- */
+/** \name Updates for Dynamic Type Registraion
+ *
+ * \{ */
+
+
+void WM_gizmoconfig_update_tag_init(
+ wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
+{
+ /* tag for update on next use */
+ gzmap_type->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT);
+ gzgt->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT);
+
+ wm_gzmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT;
+}
+
+void WM_gizmoconfig_update_tag_remove(
+ wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
+{
+ /* tag for update on next use */
+ gzmap_type->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE;
+ gzgt->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE;
+
+ wm_gzmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE;
+}
+
+/**
+ * Run incase new types have been added (runs often, early exit where possible).
+ * Follows #WM_keyconfig_update concentions.
+ */
+void WM_gizmoconfig_update(struct Main *bmain)
+{
+ if (G.background)
+ return;
+
+ if (wm_gzmap_type_update_flag == 0)
+ return;
+
+ if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) {
+ for (wmGizmoMapType *gzmap_type = gizmomaptypes.first;
+ gzmap_type;
+ gzmap_type = gzmap_type->next)
+ {
+ if (gzmap_type->type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) {
+ gzmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE;
+ for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_ref_next;
+ gzgt_ref;
+ gzgt_ref = gzgt_ref_next)
+ {
+ gzgt_ref_next = gzgt_ref->next;
+ if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_REMOVE) {
+ gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE;
+ WM_gizmomaptype_group_unlink(NULL, bmain, gzmap_type, gzgt_ref->type);
+ }
+ }
+ }
+ }
+
+ wm_gzmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE;
+ }
+
+ if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT) {
+ for (wmGizmoMapType *gzmap_type = gizmomaptypes.first;
+ gzmap_type;
+ gzmap_type = gzmap_type->next)
+ {
+ const uchar type_update_all = WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT;
+ if (gzmap_type->type_update_flag & type_update_all) {
+ gzmap_type->type_update_flag &= ~type_update_all;
+ for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first;
+ gzgt_ref;
+ gzgt_ref = gzgt_ref->next)
+ {
+ if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) {
+ WM_gizmomaptype_group_init_runtime_keymap(bmain, gzgt_ref->type);
+ gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT;
+ }
+
+ if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_INIT) {
+ WM_gizmomaptype_group_init_runtime(bmain, gzmap_type, gzgt_ref->type);
+ gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_INIT;
+ }
+ }
+ }
+ }
+
+ wm_gzmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT;
+ }
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
new file mode 100644
index 00000000000..601c54b8be5
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
@@ -0,0 +1,364 @@
+/*
+ * ***** 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/windowmanager/gizmo/intern/wm_gizmo_target_props.c
+ * \ingroup wm
+ */
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_string_utils.h"
+
+#include "BKE_context.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "WM_message.h"
+
+#include "wm.h"
+
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+/* own includes */
+#include "wm_gizmo_wmapi.h"
+#include "wm_gizmo_intern.h"
+
+/* -------------------------------------------------------------------- */
+
+/** \name Property Definition
+ * \{ */
+
+BLI_INLINE wmGizmoProperty *wm_gizmo_target_property_array(wmGizmo *gz)
+{
+ return (wmGizmoProperty *)(POINTER_OFFSET(gz, gz->type->struct_size));
+}
+
+wmGizmoProperty *WM_gizmo_target_property_array(wmGizmo *gz)
+{
+ return wm_gizmo_target_property_array(gz);
+}
+
+wmGizmoProperty *WM_gizmo_target_property_at_index(wmGizmo *gz, int index)
+{
+ BLI_assert(index < gz->type->target_property_defs_len);
+ BLI_assert(index != -1);
+ wmGizmoProperty *gz_prop_array = wm_gizmo_target_property_array(gz);
+ return &gz_prop_array[index];
+}
+
+wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
+{
+ int index = BLI_findstringindex(
+ &gz->type->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname));
+ if (index != -1) {
+ return WM_gizmo_target_property_at_index(gz, index);
+ }
+ else {
+ return NULL;
+ }
+}
+
+void WM_gizmo_target_property_def_rna_ptr(
+ wmGizmo *gz, const wmGizmoPropertyType *gz_prop_type,
+ PointerRNA *ptr, PropertyRNA *prop, int index)
+{
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type);
+
+ /* if gizmo evokes an operator we cannot use it for property manipulation */
+ BLI_assert(gz->op_data == NULL);
+
+ gz_prop->type = gz_prop_type;
+
+ gz_prop->ptr = *ptr;
+ gz_prop->prop = prop;
+ gz_prop->index = index;
+
+ if (gz->type->property_update) {
+ gz->type->property_update(gz, gz_prop);
+ }
+}
+
+void WM_gizmo_target_property_def_rna(
+ wmGizmo *gz, const char *idname,
+ PointerRNA *ptr, const char *propname, int index)
+{
+ const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(gz->type, idname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
+ WM_gizmo_target_property_def_rna_ptr(gz, gz_prop_type, ptr, prop, index);
+}
+
+void WM_gizmo_target_property_def_func_ptr(
+ wmGizmo *gz, const wmGizmoPropertyType *gz_prop_type,
+ const wmGizmoPropertyFnParams *params)
+{
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type);
+
+ /* if gizmo evokes an operator we cannot use it for property manipulation */
+ BLI_assert(gz->op_data == NULL);
+
+ gz_prop->type = gz_prop_type;
+
+ gz_prop->custom_func.value_get_fn = params->value_get_fn;
+ gz_prop->custom_func.value_set_fn = params->value_set_fn;
+ gz_prop->custom_func.range_get_fn = params->range_get_fn;
+ gz_prop->custom_func.free_fn = params->free_fn;
+ gz_prop->custom_func.user_data = params->user_data;
+
+ if (gz->type->property_update) {
+ gz->type->property_update(gz, gz_prop);
+ }
+}
+
+void WM_gizmo_target_property_def_func(
+ wmGizmo *gz, const char *idname,
+ const wmGizmoPropertyFnParams *params)
+{
+ const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(gz->type, idname);
+ WM_gizmo_target_property_def_func_ptr(gz, gz_prop_type, params);
+}
+
+void WM_gizmo_target_property_clear_rna_ptr(
+ wmGizmo *gz, const wmGizmoPropertyType *gz_prop_type)
+{
+ wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type);
+
+ /* if gizmo evokes an operator we cannot use it for property manipulation */
+ BLI_assert(gz->op_data == NULL);
+
+ gz_prop->type = NULL;
+
+ gz_prop->ptr = PointerRNA_NULL;
+ gz_prop->prop = NULL;
+ gz_prop->index = -1;
+}
+
+void WM_gizmo_target_property_clear_rna(
+ wmGizmo *gz, const char *idname)
+{
+ const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(gz->type, idname);
+ WM_gizmo_target_property_clear_rna_ptr(gz, gz_prop_type);
+}
+
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Property Access
+ * \{ */
+
+bool WM_gizmo_target_property_is_valid_any(wmGizmo *gz)
+{
+ wmGizmoProperty *gz_prop_array = wm_gizmo_target_property_array(gz);
+ for (int i = 0; i < gz->type->target_property_defs_len; i++) {
+ wmGizmoProperty *gz_prop = &gz_prop_array[i];
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
+{
+ return ((gz_prop->prop != NULL) ||
+ (gz_prop->custom_func.value_get_fn && gz_prop->custom_func.value_set_fn));
+}
+
+float WM_gizmo_target_property_value_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop)
+{
+ if (gz_prop->custom_func.value_get_fn) {
+ float value = 0.0f;
+ BLI_assert(gz_prop->type->array_length == 1);
+ gz_prop->custom_func.value_get_fn(gz, gz_prop, &value);
+ return value;
+ }
+
+ if (gz_prop->index == -1) {
+ return RNA_property_float_get(&gz_prop->ptr, gz_prop->prop);
+ }
+ else {
+ return RNA_property_float_get_index(&gz_prop->ptr, gz_prop->prop, gz_prop->index);
+ }
+}
+
+void WM_gizmo_target_property_value_set(
+ bContext *C, const wmGizmo *gz,
+ wmGizmoProperty *gz_prop, const float value)
+{
+ if (gz_prop->custom_func.value_set_fn) {
+ BLI_assert(gz_prop->type->array_length == 1);
+ gz_prop->custom_func.value_set_fn(gz, gz_prop, &value);
+ return;
+ }
+
+ /* reset property */
+ if (gz_prop->index == -1) {
+ RNA_property_float_set(&gz_prop->ptr, gz_prop->prop, value);
+ }
+ else {
+ RNA_property_float_set_index(&gz_prop->ptr, gz_prop->prop, gz_prop->index, value);
+ }
+ RNA_property_update(C, &gz_prop->ptr, gz_prop->prop);
+}
+
+void WM_gizmo_target_property_value_get_array(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
+ float *value)
+{
+ if (gz_prop->custom_func.value_get_fn) {
+ gz_prop->custom_func.value_get_fn(gz, gz_prop, value);
+ return;
+ }
+ RNA_property_float_get_array(&gz_prop->ptr, gz_prop->prop, value);
+}
+
+void WM_gizmo_target_property_value_set_array(
+ bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop,
+ const float *value)
+{
+ if (gz_prop->custom_func.value_set_fn) {
+ gz_prop->custom_func.value_set_fn(gz, gz_prop, value);
+ return;
+ }
+ RNA_property_float_set_array(&gz_prop->ptr, gz_prop->prop, value);
+
+ RNA_property_update(C, &gz_prop->ptr, gz_prop->prop);
+}
+
+bool WM_gizmo_target_property_range_get(
+ const wmGizmo *gz, wmGizmoProperty *gz_prop,
+ float range[2])
+{
+ if (gz_prop->custom_func.value_get_fn) {
+ if (gz_prop->custom_func.range_get_fn) {
+ gz_prop->custom_func.range_get_fn(gz, gz_prop, range);
+ return true;
+ }
+ else {
+ return false;
+
+ }
+ }
+
+ float step, precision;
+ RNA_property_float_ui_range(&gz_prop->ptr, gz_prop->prop, &range[0], &range[1], &step, &precision);
+ return true;
+}
+
+int WM_gizmo_target_property_array_length(
+ const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
+{
+ if (gz_prop->custom_func.value_get_fn) {
+ return gz_prop->type->array_length;
+ }
+ return RNA_property_array_length(&gz_prop->ptr, gz_prop->prop);
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Property Define
+ * \{ */
+
+const wmGizmoPropertyType *WM_gizmotype_target_property_find(
+ const wmGizmoType *gzt, const char *idname)
+{
+ return BLI_findstring(&gzt->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname));
+}
+
+void WM_gizmotype_target_property_def(
+ wmGizmoType *gzt, const char *idname, int data_type, int array_length)
+{
+ wmGizmoPropertyType *mpt;
+
+ BLI_assert(WM_gizmotype_target_property_find(gzt, idname) == NULL);
+
+ const uint idname_size = strlen(idname) + 1;
+ mpt = MEM_callocN(sizeof(wmGizmoPropertyType) + idname_size, __func__);
+ memcpy(mpt->idname, idname, idname_size);
+ mpt->data_type = data_type;
+ mpt->array_length = array_length;
+ mpt->index_in_type = gzt->target_property_defs_len;
+ gzt->target_property_defs_len += 1;
+ BLI_addtail(&gzt->target_property_defs, mpt);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Property Utilities
+ * \{ */
+
+void WM_gizmo_do_msg_notify_tag_refresh(
+ bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val)
+{
+ ARegion *ar = msg_val->owner;
+ wmGizmoMap *gzmap = msg_val->user_data;
+
+ ED_region_tag_redraw(ar);
+ WM_gizmomap_tag_refresh(gzmap);
+}
+
+/**
+ * Runs on the "prepare draw" pass,
+ * drawing the region clears.
+ */
+void WM_gizmo_target_property_subscribe_all(
+ wmGizmo *gz, struct wmMsgBus *mbus, ARegion *ar)
+{
+ if (gz->type->target_property_defs_len) {
+ wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz);
+ for (int i = 0; i < gz->type->target_property_defs_len; i++) {
+ wmGizmoProperty *gz_prop = &gz_prop_array[i];
+ if (WM_gizmo_target_property_is_valid(gz_prop)) {
+ if (gz_prop->prop) {
+ WM_msg_subscribe_rna(
+ mbus, &gz_prop->ptr, gz_prop->prop,
+ &(const wmMsgSubscribeValue){
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ }, __func__);
+ WM_msg_subscribe_rna(
+ mbus, &gz_prop->ptr, gz_prop->prop,
+ &(const wmMsgSubscribeValue){
+ .owner = ar,
+ .user_data = gz->parent_gzgroup->parent_gzmap,
+ .notify = WM_gizmo_do_msg_notify_tag_refresh,
+ }, __func__);
+ }
+ }
+ }
+ }
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c
new file mode 100644
index 00000000000..2ff0148044c
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c
@@ -0,0 +1,212 @@
+/*
+ * ***** 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/windowmanager/gizmo/intern/wm_gizmo_type.c
+ * \ingroup wm
+ */
+
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BLI_string_utils.h"
+
+#include "BKE_context.h"
+#include "BKE_main.h"
+
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_screen.h"
+
+/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */
+#include "wm.h"
+
+/* own includes */
+#include "wm_gizmo_wmapi.h"
+#include "wm_gizmo_intern.h"
+
+
+/** \name Gizmo Type Append
+ *
+ * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
+ * \{ */
+
+static GHash *global_gizmotype_hash = NULL;
+
+const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet)
+{
+ if (idname[0]) {
+ wmGizmoType *gzt;
+
+ gzt = BLI_ghash_lookup(global_gizmotype_hash, idname);
+ if (gzt) {
+ return gzt;
+ }
+
+ if (!quiet) {
+ printf("search for unknown gizmo '%s'\n", idname);
+ }
+ }
+ else {
+ if (!quiet) {
+ printf("search for empty gizmo\n");
+ }
+ }
+
+ return NULL;
+}
+
+/* caller must free */
+void WM_gizmotype_iter(GHashIterator *ghi)
+{
+ BLI_ghashIterator_init(ghi, global_gizmotype_hash);
+}
+
+static wmGizmoType *wm_gizmotype_append__begin(void)
+{
+ wmGizmoType *gzt = MEM_callocN(sizeof(wmGizmoType), "gizmotype");
+ gzt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoProperties);
+#if 0
+ /* Set the default i18n context now, so that opfunc can redefine it if needed! */
+ RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+ ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
+#endif
+ return gzt;
+}
+static void wm_gizmotype_append__end(wmGizmoType *gzt)
+{
+ BLI_assert(gzt->struct_size >= sizeof(wmGizmo));
+
+ RNA_def_struct_identifier(&BLENDER_RNA, gzt->srna, gzt->idname);
+
+ BLI_ghash_insert(global_gizmotype_hash, (void *)gzt->idname, gzt);
+}
+
+void WM_gizmotype_append(void (*gtfunc)(struct wmGizmoType *))
+{
+ wmGizmoType *gzt = wm_gizmotype_append__begin();
+ gtfunc(gzt);
+ wm_gizmotype_append__end(gzt);
+}
+
+void WM_gizmotype_append_ptr(void (*gtfunc)(struct wmGizmoType *, void *), void *userdata)
+{
+ wmGizmoType *mt = wm_gizmotype_append__begin();
+ gtfunc(mt, userdata);
+ wm_gizmotype_append__end(mt);
+}
+
+/**
+ * Free but don't remove from ghash.
+ */
+static void gizmotype_free(wmGizmoType *gzt)
+{
+ if (gzt->ext.srna) { /* python gizmo, allocs own string */
+ MEM_freeN((void *)gzt->idname);
+ }
+
+ BLI_freelistN(&gzt->target_property_defs);
+ MEM_freeN(gzt);
+}
+
+/**
+ * \param C: May be NULL.
+ */
+static void gizmotype_unlink(
+ bContext *C, Main *bmain, wmGizmoType *gzt)
+{
+ /* Free instances. */
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ARegion *ar = lb->first; ar; ar = ar->next) {
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ if (gzmap) {
+ wmGizmoGroup *gzgroup;
+ for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ for (wmGizmo *gz = gzgroup->gizmos.first, *gz_next; gz; gz = gz_next) {
+ gz_next = gz->next;
+ BLI_assert(gzgroup->parent_gzmap == gzmap);
+ if (gz->type == gzt) {
+ WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C);
+ ED_region_tag_redraw(ar);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt)
+{
+ BLI_assert(gzt == WM_gizmotype_find(gzt->idname, false));
+
+ BLI_ghash_remove(global_gizmotype_hash, gzt->idname, NULL, NULL);
+
+ gizmotype_unlink(C, bmain, gzt);
+
+ gizmotype_free(gzt);
+}
+
+bool WM_gizmotype_remove(bContext *C, Main *bmain, const char *idname)
+{
+ wmGizmoType *gzt = BLI_ghash_lookup(global_gizmotype_hash, idname);
+
+ if (gzt == NULL) {
+ return false;
+ }
+
+ WM_gizmotype_remove_ptr(C, bmain, gzt);
+
+ return true;
+}
+
+static void wm_gizmotype_ghash_free_cb(wmGizmoType *mt)
+{
+ gizmotype_free(mt);
+}
+
+void wm_gizmotype_free(void)
+{
+ BLI_ghash_free(global_gizmotype_hash, NULL, (GHashValFreeFP)wm_gizmotype_ghash_free_cb);
+ global_gizmotype_hash = NULL;
+}
+
+/* called on initialize WM_init() */
+void wm_gizmotype_init(void)
+{
+ /* reserve size is set based on blender default setup */
+ global_gizmotype_hash = BLI_ghash_str_new_ex("wm_gizmotype_init gh", 128);
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h
new file mode 100644
index 00000000000..a94f1e994e9
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h
@@ -0,0 +1,88 @@
+/*
+ * ***** 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/windowmanager/gizmo/wm_gizmo_fn.h
+ * \ingroup wm
+ *
+ * Callback function definitions, needed for both Types & API headers.
+ */
+
+#ifndef __WM_GIZMO_FN_H__
+#define __WM_GIZMO_FN_H__
+
+#include "BLI_compiler_attrs.h"
+
+/* wmGizmoGroup */
+typedef bool (*wmGizmoGroupFnPoll)(
+ const struct bContext *, struct wmGizmoGroupType *)
+ ATTR_WARN_UNUSED_RESULT;
+typedef void (*wmGizmoGroupFnInit)(
+ const struct bContext *, struct wmGizmoGroup *);
+typedef void (*wmGizmoGroupFnRefresh)(
+ const struct bContext *, struct wmGizmoGroup *);
+typedef void (*wmGizmoGroupFnDrawPrepare)(
+ const struct bContext *, struct wmGizmoGroup *);
+typedef struct wmKeyMap *(*wmGizmoGroupFnSetupKeymap)(
+ const struct wmGizmoGroupType *, struct wmKeyConfig *)
+ ATTR_WARN_UNUSED_RESULT;
+typedef void (*wmGizmoGroupFnMsgBusSubscribe)(
+ const struct bContext *, struct wmGizmoGroup *, struct wmMsgBus *);
+
+/* wmGizmo */
+/* See: wmGizmoType for docs on each type. */
+
+typedef void (*wmGizmoFnSetup)(struct wmGizmo *);
+typedef void (*wmGizmoFnDraw)(const struct bContext *, struct wmGizmo *);
+typedef void (*wmGizmoFnDrawSelect)(const struct bContext *, struct wmGizmo *, int);
+typedef int (*wmGizmoFnTestSelect)(struct bContext *, struct wmGizmo *, const struct wmEvent *);
+typedef int (*wmGizmoFnModal)(struct bContext *, struct wmGizmo *, const struct wmEvent *, eWM_GizmoFlagTweak);
+typedef void (*wmGizmoFnPropertyUpdate)(struct wmGizmo *, struct wmGizmoProperty *);
+typedef void (*wmGizmoFnMatrixBasisGet)(const struct wmGizmo *, float[4][4]);
+typedef int (*wmGizmoFnInvoke)(struct bContext *, struct wmGizmo *, const struct wmEvent *);
+typedef void (*wmGizmoFnExit)(struct bContext *, struct wmGizmo *, const bool);
+typedef int (*wmGizmoFnCursorGet)(struct wmGizmo *);
+typedef void (*wmGizmoFnSelectRefresh)(struct wmGizmo *);
+typedef void (*wmGizmoFnFree)(struct wmGizmo *);
+
+/* wmGizmoProperty ('value' type defined by 'wmGizmoProperty.data_type') */
+typedef void (*wmGizmoPropertyFnGet)(
+ const struct wmGizmo *, struct wmGizmoProperty *,
+ /* typically 'float *' */
+ void *value);
+typedef void (*wmGizmoPropertyFnSet)(
+ const struct wmGizmo *, struct wmGizmoProperty *,
+ /* typically 'const float *' */
+ const void *value);
+typedef void (*wmGizmoPropertyFnRangeGet)(
+ const struct wmGizmo *, struct wmGizmoProperty *,
+ /* typically 'float[2]' */
+ void *range);
+typedef void (*wmGizmoPropertyFnFree)(
+ const struct wmGizmo *, struct wmGizmoProperty *);
+
+typedef struct wmGizmoPropertyFnParams {
+ wmGizmoPropertyFnGet value_get_fn;
+ wmGizmoPropertyFnSet value_set_fn;
+ wmGizmoPropertyFnRangeGet range_get_fn;
+ wmGizmoPropertyFnFree free_fn;
+ void *user_data;
+} wmGizmoPropertyFnParams;
+
+#endif /* __WM_GIZMO_FN_H__ */
diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h
new file mode 100644
index 00000000000..414109e89e5
--- /dev/null
+++ b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h
@@ -0,0 +1,97 @@
+/*
+ * ***** 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/windowmanager/gizmo/wm_gizmo_wmapi.h
+ * \ingroup wm
+ *
+ * \name Gizmos Window Manager API
+ * API for usage in window manager code only. It should contain all functionality
+ * needed to hook up the gizmo system with Blender's window manager. It's
+ * mostly the event system that needs to communicate with gizmo code.
+ *
+ * Only included in wm.h and lower level files.
+ */
+
+
+#ifndef __WM_GIZMO_WMAPI_H__
+#define __WM_GIZMO_WMAPI_H__
+
+struct wmEventHandler;
+struct wmGizmoMap;
+struct wmOperatorType;
+struct wmOperator;
+
+
+/* -------------------------------------------------------------------- */
+/* wmGizmo */
+
+/* wm_gizmo_type.c, for init/exit */
+void wm_gizmotype_free(void);
+void wm_gizmotype_init(void);
+
+/* wm_gizmogroup_type.c, for init/exit */
+void wm_gizmogrouptype_free(void);
+void wm_gizmogrouptype_init(void);
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoGroup */
+
+void GIZMOGROUP_OT_gizmo_select(struct wmOperatorType *ot);
+void GIZMOGROUP_OT_gizmo_tweak(struct wmOperatorType *ot);
+
+bool wm_gizmogroup_is_any_selected(const struct wmGizmoGroup *gzgroup);
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoMap */
+
+void wm_gizmomap_remove(struct wmGizmoMap *gzmap);
+
+void wm_gizmos_keymap(struct wmKeyConfig *keyconf);
+
+void wm_gizmomaps_handled_modal_update(
+ bContext *C, struct wmEvent *event, struct wmEventHandler *handler);
+void wm_gizmomap_handler_context(bContext *C, struct wmEventHandler *handler);
+
+struct wmGizmo *wm_gizmomap_highlight_find(
+ struct wmGizmoMap *gzmap, bContext *C, const struct wmEvent *event,
+ int *r_part);
+bool wm_gizmomap_highlight_set(
+ struct wmGizmoMap *gzmap, const bContext *C,
+ struct wmGizmo *gz, int part);
+struct wmGizmo *wm_gizmomap_highlight_get(struct wmGizmoMap *gzmap);
+void wm_gizmomap_modal_set(
+ struct wmGizmoMap *gzmap, bContext *C, struct wmGizmo *gz,
+ const struct wmEvent *event, bool enable);
+
+struct wmGizmo *wm_gizmomap_modal_get(struct wmGizmoMap *gzmap);
+struct wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *gzmap, int *r_selected_len);
+struct ListBase *wm_gizmomap_groups_get(wmGizmoMap *gzmap);
+
+/* -------------------------------------------------------------------- */
+/* wmGizmoMapType */
+
+void wm_gizmomaptypes_free(void);
+
+#endif /* __WM_GIZMO_WMAPI_H__ */
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 701ad49b520..f92cc511449 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -282,80 +282,6 @@ void WM_uilisttype_free(void)
uilisttypes_hash = NULL;
}
-/* ************ MenuType handling ************** */
-
-static GHash *menutypes_hash = NULL;
-
-MenuType *WM_menutype_find(const char *idname, bool quiet)
-{
- MenuType *mt;
-
- if (idname[0]) {
- mt = BLI_ghash_lookup(menutypes_hash, idname);
- if (mt)
- return mt;
- }
-
- if (!quiet)
- printf("search for unknown menutype %s\n", idname);
-
- return NULL;
-}
-
-bool WM_menutype_add(MenuType *mt)
-{
- BLI_ghash_insert(menutypes_hash, mt->idname, mt);
- return true;
-}
-
-void WM_menutype_freelink(MenuType *mt)
-{
- bool ok;
-
- ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN);
-
- BLI_assert(ok);
- (void)ok;
-}
-
-/* called on initialize WM_init() */
-void WM_menutype_init(void)
-{
- /* reserve size is set based on blender default setup */
- menutypes_hash = BLI_ghash_str_new_ex("menutypes_hash gh", 512);
-}
-
-void WM_menutype_free(void)
-{
- GHashIterator gh_iter;
-
- GHASH_ITER (gh_iter, menutypes_hash) {
- MenuType *mt = BLI_ghashIterator_getValue(&gh_iter);
- if (mt->ext.free) {
- mt->ext.free(mt->ext.data);
- }
- }
-
- BLI_ghash_free(menutypes_hash, NULL, MEM_freeN);
- menutypes_hash = NULL;
-}
-
-bool WM_menutype_poll(bContext *C, MenuType *mt)
-{
- /* If we're tagged, only use compatible. */
- if (mt->owner_id[0] != '\0') {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if (BKE_workspace_owner_id_check(workspace, mt->owner_id) == false) {
- return false;
- }
- }
-
- if (mt->poll != NULL) {
- return mt->poll(C, mt);
- }
- return true;
-}
-
/* ****************************************** */
void WM_keymap_init(bContext *C)
@@ -461,10 +387,11 @@ void wm_add_default(Main *bmain, bContext *C)
WorkSpaceLayout *layout = BKE_workspace_layout_find_global(bmain, screen, &workspace);
CTX_wm_manager_set(C, wm);
- win = wm_window_new(C);
+ win = wm_window_new(C, NULL);
win->scene = CTX_data_scene(C);
- WM_window_set_active_workspace(win, workspace);
- WM_window_set_active_layout(win, workspace, layout);
+ STRNCPY(win->view_layer_name, CTX_data_view_layer(C)->name);
+ BKE_workspace_active_set(win->workspace_hook, workspace);
+ BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace, layout);
screen->winid = win->winid;
wm->winactive = win;
@@ -484,7 +411,8 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
wm_autosave_timer_ended(wm);
while ((win = BLI_pophead(&wm->windows))) {
- WM_window_set_active_workspace(win, NULL); /* prevent draw clear to use screen */
+ /* prevent draw clear to use screen */
+ BKE_workspace_active_set(win->workspace_hook, NULL);
wm_window_free(C, wm, win);
}
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 5b88268f416..160aeb6671b 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -456,9 +456,9 @@ void wm_draw_region_blend(ARegion *ar, int view, bool blend)
glUniform1i(GPU_shader_get_uniform(shader, "image"), 0);
glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), halfx, halfy, 1.0f + halfx, 1.0f + halfy);
glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), ar->winrct.xmin, ar->winrct.ymin, ar->winrct.xmax + 1, ar->winrct.ymax + 1);
- glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
+ glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
- GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4);
+ GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4);
glBindTexture(GL_TEXTURE_2D, 0);
@@ -729,9 +729,8 @@ static void wm_draw_window(bContext *C, wmWindow *win)
/* quick test to prevent changing window drawable */
static bool wm_draw_update_test_window(wmWindow *win)
{
- struct WorkSpace *workspace = WM_window_get_active_workspace(win);
Scene *scene = WM_window_get_active_scene(win);
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
bScreen *screen = WM_window_get_active_screen(win);
ARegion *ar;
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 2a92eedf456..8b1cce27502 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -296,11 +296,7 @@ static void wm_notifier_clear(wmNotifier *note)
memset(((char *)note) + sizeof(Link), 0, sizeof(*note) - sizeof(Link));
}
-/**
- * Was part of #wm_event_do_notifiers, split out so it can be called once before entering the #WM_main loop.
- * This ensures operators don't run before the UI and depsgraph are initialized.
- */
-void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
+void wm_event_do_depsgraph(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
uint64_t win_combine_v3d_datamask = 0;
@@ -315,17 +311,8 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
/* cached: editor refresh callbacks now, they get context */
for (wmWindow *win = wm->windows.first; win; win = win->next) {
- const bScreen *screen = WM_window_get_active_screen(win);
Scene *scene = WM_window_get_active_scene(win);
- ScrArea *sa;
-
- CTX_wm_window_set(C, win);
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->do_refresh) {
- CTX_wm_area_set(C, sa);
- ED_area_do_refresh(C, sa);
- }
- }
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
/* XXX make lock in future, or separated derivedmesh users in scene */
if (G.is_rendering == false) {
@@ -338,12 +325,42 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
/* XXX, hack so operators can enforce datamasks [#26482], gl render */
scene->customdata_mask |= scene->customdata_mask_modal;
- WorkSpace *workspace = WM_window_get_active_workspace(win);
+ /* TODO(sergey): For now all dependency graphs which are evaluated from
+ * workspace are considered active. This will work all fine with "locked"
+ * view layer and time across windows. This is to be granted separately,
+ * and for until then we have to accept ambiguities when object is shared
+ * across visible view layers and has overrides on it.
+ */
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ DEG_make_active(depsgraph);
+ BKE_scene_graph_update_tagged(depsgraph, bmain);
+ }
+ }
+}
- BKE_workspace_update_tagged(bmain, workspace, scene);
+/**
+ * Was part of #wm_event_do_notifiers, split out so it can be called once before entering the #WM_main loop.
+ * This ensures operators don't run before the UI and depsgraph are initialized.
+ */
+void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ /* cached: editor refresh callbacks now, they get context */
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ const bScreen *screen = WM_window_get_active_screen(win);
+ ScrArea *sa;
+
+ CTX_wm_window_set(C, win);
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ if (sa->do_refresh) {
+ CTX_wm_area_set(C, sa);
+ ED_area_do_refresh(C, sa);
+ }
}
}
+ wm_event_do_depsgraph(C);
+
CTX_wm_window_set(C, NULL);
}
@@ -384,7 +401,7 @@ void wm_event_do_notifiers(bContext *C)
UI_popup_handlers_remove_all(C, &win->modalhandlers);
- ED_workspace_change(ref_ws, C, wm, win);
+ WM_window_set_active_workspace(C, win, ref_ws);
if (G.debug & G_DEBUG_EVENTS)
printf("%s: Workspace set %p\n", __func__, note->reference);
}
@@ -473,13 +490,13 @@ void wm_event_do_notifiers(bContext *C)
ED_screen_do_listen(C, note);
for (ar = screen->regionbase.first; ar; ar = ar->next) {
- ED_region_do_listen(screen, NULL, ar, note, scene);
+ ED_region_do_listen(win, NULL, ar, note, scene);
}
ED_screen_areas_iter(win, screen, sa) {
- ED_area_do_listen(screen, sa, note, scene, workspace);
+ ED_area_do_listen(win, sa, note, scene);
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- ED_region_do_listen(screen, sa, ar, note, scene);
+ ED_region_do_listen(win, sa, ar, note, scene);
}
}
}
@@ -1953,6 +1970,11 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
wm_operator_reports(C, op, retval, false);
+
+ if (op->type->modalkeymap) {
+ wmWindow *win = CTX_wm_window(C);
+ WM_window_status_area_tag_redraw(win);
+ }
}
else {
/* not very common, but modal operators may report before finishing */
@@ -1982,8 +2004,8 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
CTX_wm_region_set(C, NULL);
}
- /* update manipulators during modal handlers */
- wm_manipulatormaps_handled_modal_update(C, event, handler);
+ /* update gizmos during modal handlers */
+ wm_gizmomaps_handled_modal_update(C, event, handler);
/* remove modal handler, operator itself should have been canceled and freed */
if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
@@ -2370,70 +2392,70 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
}
}
}
- else if (handler->manipulator_map) {
+ else if (handler->gizmo_map) {
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- wmManipulatorMap *mmap = handler->manipulator_map;
- wmManipulator *mpr = wm_manipulatormap_highlight_get(mmap);
+ wmGizmoMap *gzmap = handler->gizmo_map;
+ wmGizmo *gz = wm_gizmomap_highlight_get(gzmap);
- if (region->manipulator_map != handler->manipulator_map) {
- WM_manipulatormap_tag_refresh(handler->manipulator_map);
+ if (region->gizmo_map != handler->gizmo_map) {
+ WM_gizmomap_tag_refresh(handler->gizmo_map);
}
- wm_manipulatormap_handler_context(C, handler);
+ wm_gizmomap_handler_context(C, handler);
wm_region_mouse_co(C, event);
- /* handle manipulator highlighting */
- if (event->type == MOUSEMOVE && !wm_manipulatormap_modal_get(mmap)) {
+ /* handle gizmo highlighting */
+ if (event->type == MOUSEMOVE && !wm_gizmomap_modal_get(gzmap)) {
int part;
- mpr = wm_manipulatormap_highlight_find(mmap, C, event, &part);
- if (wm_manipulatormap_highlight_set(mmap, C, mpr, part) && mpr != NULL) {
- WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_manipulatormap_tooltip_init);
+ gz = wm_gizmomap_highlight_find(gzmap, C, event, &part);
+ if (wm_gizmomap_highlight_set(gzmap, C, gz, part) && gz != NULL) {
+ WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_gizmomap_tooltip_init);
}
}
else {
/* Either we operate on a single highlighted item
- * or groups attached to the selected manipulators.
+ * or groups attached to the selected gizmos.
* To simplify things both cases loop over an array of items. */
- wmManipulatorGroup *mgroup_first;
- bool is_mgroup_single;
+ wmGizmoGroup *gzgroup_first;
+ bool is_gzgroup_single;
if (ISMOUSE(event->type)) {
- /* Keep mpr set as-is, just fake single selection. */
- if (mpr) {
- mgroup_first = mpr->parent_mgroup;
+ /* Keep gz set as-is, just fake single selection. */
+ if (gz) {
+ gzgroup_first = gz->parent_gzgroup;
}
else {
- mgroup_first = NULL;
+ gzgroup_first = NULL;
}
- is_mgroup_single = true;
+ is_gzgroup_single = true;
}
else {
- if (WM_manipulatormap_is_any_selected(mmap)) {
- const ListBase *groups = WM_manipulatormap_group_list(mmap);
- mgroup_first = groups->first;
+ if (WM_gizmomap_is_any_selected(gzmap)) {
+ const ListBase *groups = WM_gizmomap_group_list(gzmap);
+ gzgroup_first = groups->first;
}
else {
- mgroup_first = NULL;
+ gzgroup_first = NULL;
}
- is_mgroup_single = false;
+ is_gzgroup_single = false;
}
/* Don't use from now on. */
- mpr = NULL;
+ gz = NULL;
- for (wmManipulatorGroup *mgroup = mgroup_first; mgroup; mgroup = mgroup->next) {
+ for (wmGizmoGroup *gzgroup = gzgroup_first; gzgroup; gzgroup = gzgroup->next) {
/* get user customized keymap from default one */
- if ((is_mgroup_single == false) &&
- /* We might want to change the logic here and use some kind of manipulator edit-mode.
+ if ((is_gzgroup_single == false) &&
+ /* We might want to change the logic here and use some kind of gizmo edit-mode.
* For now just use keymap when a selection exists. */
- wm_manipulatorgroup_is_any_selected(mgroup) == false)
+ wm_gizmogroup_is_any_selected(gzgroup) == false)
{
continue;
}
- wmKeyMap *keymap = WM_keymap_active(wm, mgroup->type->keymap);
+ wmKeyMap *keymap = WM_keymap_active(wm, gzgroup->type->keymap);
wmKeyMapItem *kmi;
PRINT("%s: checking '%s' ...", __func__, keymap->idname);
@@ -2450,14 +2472,14 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
/* weak, but allows interactive callback to not use rawkey */
event->keymap_idname = kmi->idname;
- CTX_wm_manipulator_group_set(C, mgroup);
+ CTX_wm_gizmo_group_set(C, gzgroup);
/* handler->op is called later, we want keymap op to be triggered here */
handler->op = NULL;
action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
handler->op = op;
- CTX_wm_manipulator_group_set(C, NULL);
+ CTX_wm_gizmo_group_set(C, NULL);
if (action & WM_HANDLER_BREAK) {
if (keymap_callback.handle_post_fn != NULL) {
@@ -2493,7 +2515,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
break;
}
- if (is_mgroup_single) {
+ if (is_gzgroup_single) {
break;
}
}
@@ -2782,7 +2804,7 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event)
}
#ifdef USE_WORKSPACE_TOOL
-static void wm_event_manipulator_temp_handler_apply(
+static void wm_event_gizmo_temp_handler_apply(
bContext *C, ScrArea *sa, ARegion *ar, wmEventHandler *sneaky_handler)
{
if (ar->regiontype == RGN_TYPE_WINDOW) {
@@ -2796,17 +2818,17 @@ static void wm_event_manipulator_temp_handler_apply(
/* Handle widgets first. */
wmEventHandler *handler_last = ar->handlers.last;
- while (handler_last && handler_last->manipulator_map == NULL) {
+ while (handler_last && handler_last->gizmo_map == NULL) {
handler_last = handler_last->prev;
}
- /* Head of list or after last manipulator. */
+ /* Head of list or after last gizmo. */
BLI_insertlinkafter(&ar->handlers, handler_last, sneaky_handler);
}
}
}
}
-static void wm_event_manipulator_temp_handler_clear(
+static void wm_event_gizmo_temp_handler_clear(
bContext *UNUSED(C), ScrArea *UNUSED(sa), ARegion *ar, wmEventHandler *sneaky_handler)
{
if (sneaky_handler->keymap) {
@@ -2824,7 +2846,7 @@ void wm_event_do_handlers(bContext *C)
/* update key configuration before handling events */
WM_keyconfig_update(wm);
- WM_manipulatorconfig_update(CTX_data_main(C));
+ WM_gizmoconfig_update(CTX_data_main(C));
for (win = wm->windows.first; win; win = win->next) {
bScreen *screen = WM_window_get_active_screen(win);
@@ -2999,13 +3021,13 @@ void wm_event_do_handlers(bContext *C)
* to fetch its current keymap.
*/
wmEventHandler sneaky_handler = {NULL};
- wm_event_manipulator_temp_handler_apply(C, sa, ar, &sneaky_handler);
+ wm_event_gizmo_temp_handler_apply(C, sa, ar, &sneaky_handler);
#endif /* USE_WORKSPACE_TOOL */
action |= wm_handlers_do(C, event, &ar->handlers);
#ifdef USE_WORKSPACE_TOOL
- wm_event_manipulator_temp_handler_clear(C, sa, ar, &sneaky_handler);
+ wm_event_gizmo_temp_handler_clear(C, sa, ar, &sneaky_handler);
#endif /* USE_WORKSPACE_TOOL */
/* fileread case (python), [#29489] */
@@ -3072,7 +3094,7 @@ void wm_event_do_handlers(bContext *C)
/* update key configuration after handling events */
WM_keyconfig_update(wm);
- WM_manipulatorconfig_update(CTX_data_main(C));
+ WM_gizmoconfig_update(CTX_data_main(C));
}
/* ********** filesector handling ************ */
@@ -3184,6 +3206,10 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op)
BLI_addhead(&win->modalhandlers, handler);
+ if (op->type->modalkeymap) {
+ WM_window_status_area_tag_redraw(win);
+ }
+
return handler;
}
@@ -4314,11 +4340,14 @@ const char *WM_window_cursor_keymap_status_get(const wmWindow *win, int button_i
return NULL;
}
-void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win)
+/**
+ * Similar to #BKE_screen_area_map_find_area_xy and related functions,
+ * use here since the ara is stored in the window manager.
+ */
+ScrArea *WM_window_status_area_find(wmWindow *win, bScreen *screen)
{
- bScreen *screen = WM_window_get_active_screen(win);
if (screen->state == SCREENFULL) {
- return;
+ return NULL;
}
ScrArea *sa_statusbar = NULL;
for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) {
@@ -4327,6 +4356,22 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win)
break;
}
}
+ return sa_statusbar;
+}
+
+void WM_window_status_area_tag_redraw(wmWindow *win)
+{
+ bScreen *sc = WM_window_get_active_screen(win);
+ ScrArea *sa = WM_window_status_area_find(win, sc);
+ if (sa != NULL) {
+ ED_area_tag_redraw(sa);
+ }
+}
+
+void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win)
+{
+ bScreen *screen = WM_window_get_active_screen(win);
+ ScrArea *sa_statusbar = WM_window_status_area_find(win, screen);
if (sa_statusbar == NULL) {
return;
}
@@ -4380,11 +4425,11 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win)
{
bToolRef *tref = NULL;
if (ar->regiontype == RGN_TYPE_WINDOW) {
- Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
WorkSpace *workspace = WM_window_get_active_workspace(win);
const bToolKey tkey = {
.space_type = sa->spacetype,
- .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype),
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
};
tref = WM_toolsystem_ref_find(workspace, &tkey);
}
@@ -4425,7 +4470,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win)
#ifdef USE_WORKSPACE_TOOL
wmEventHandler sneaky_handler = {NULL};
- wm_event_manipulator_temp_handler_apply(C, sa, ar, &sneaky_handler);
+ wm_event_gizmo_temp_handler_apply(C, sa, ar, &sneaky_handler);
#endif
ListBase *handlers[] = {
@@ -4458,7 +4503,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win)
}
#ifdef USE_WORKSPACE_TOOL
- wm_event_manipulator_temp_handler_clear(C, sa, ar, &sneaky_handler);
+ wm_event_gizmo_temp_handler_clear(C, sa, ar, &sneaky_handler);
#endif
if (memcmp(&cd_prev.text, &cd->text, sizeof(cd_prev.text)) != 0) {
@@ -4469,3 +4514,89 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Modal Keymap Status
+ *
+ * \{ */
+
+bool WM_window_modal_keymap_status_draw(
+ bContext *UNUSED(C), wmWindow *win,
+ uiLayout *layout)
+{
+ wmKeyMap *keymap = NULL;
+ wmOperator *op = NULL;
+ for (wmEventHandler *handler = win->modalhandlers.first; handler; handler = handler->next) {
+ if (handler->op) {
+ /* 'handler->keymap' could be checked too, seems not to be used. */
+ wmKeyMap *keymap_test = handler->op->type->modalkeymap;
+ if (keymap_test && keymap_test->modal_items) {
+ keymap = keymap_test;
+ op = handler->op;
+ break;
+ }
+ }
+ }
+ if (keymap == NULL) {
+ return false;
+ }
+ const EnumPropertyItem *items = keymap->modal_items;
+
+ uiLayout *row = uiLayoutRow(layout, true);
+ for (int i = 0; items[i].identifier; i++) {
+ if (!items[i].identifier[0]) {
+ continue;
+ }
+ if ((keymap->poll_modal_item != NULL) &&
+ (keymap->poll_modal_item(op, items[i].value) == false))
+ {
+ continue;
+ }
+
+ bool show_text = true;
+
+ {
+ /* warning: O(n^2) */
+ wmKeyMapItem *kmi = NULL;
+ for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ if (kmi->propvalue == items[i].value) {
+ break;
+ }
+ }
+ if (kmi != NULL) {
+ if (kmi->val == KM_RELEASE) {
+ /* Assume release events just disable something which was toggled on. */
+ continue;
+ }
+ int icon_mod[4];
+#ifdef WITH_HEADLESS
+ int icon = 0;
+#else
+ int icon = UI_icon_from_keymap_item(kmi, icon_mod);
+#endif
+ if (icon != 0) {
+ for (int j = 0; j < ARRAY_SIZE(icon_mod) && icon_mod[j]; j++) {
+ uiItemL(row, "", icon_mod[j]);
+ }
+ uiItemL(row, items[i].name, icon);
+ show_text = false;
+ }
+ }
+ }
+ if (show_text) {
+ char buf[UI_MAX_DRAW_STR];
+ int available_len = sizeof(buf);
+ char *p = buf;
+ WM_modalkeymap_operator_items_to_string_buf(
+ op->type, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p);
+ p -= 1;
+ if (p > buf) {
+ BLI_snprintf(p, available_len, ": %s", items[i].name);
+ uiItemL(row, buf, 0);
+ }
+ }
+ }
+ return true;
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index f00ec500bc0..c191255cd21 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -64,7 +64,6 @@
#include "BLF_api.h"
-#include "DNA_mesh_types.h" /* only for USE_BMESH_SAVE_AS_COMPAT */
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
@@ -186,19 +185,24 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
ED_editors_exit(C);
}
-static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWindow *win)
+static void wm_window_substitute_old(wmWindowManager *oldwm, wmWindowManager *wm, wmWindow *oldwin, wmWindow *win)
{
win->ghostwin = oldwin->ghostwin;
- win->gwnctx = oldwin->gwnctx;
+ win->gpuctx = oldwin->gpuctx;
win->active = oldwin->active;
- if (win->active)
+ if (win->active) {
wm->winactive = win;
+ }
+ if (oldwm->windrawable == oldwin) {
+ oldwm->windrawable = NULL;
+ wm->windrawable = win;
+ }
if (!G.background) /* file loading in background mode still calls this */
GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */
oldwin->ghostwin = NULL;
- oldwin->gwnctx = NULL;
+ oldwin->gpuctx = NULL;
win->eventstate = oldwin->eventstate;
oldwin->eventstate = NULL;
@@ -281,13 +285,13 @@ static void wm_window_match_replace_by_file_wm(
if (oldwin->winid == win->winid) {
has_match = true;
- wm_window_substitute_old(wm, oldwin, win);
+ wm_window_substitute_old(oldwm, wm, oldwin, win);
}
}
}
/* make sure at least one window is kept open so we don't lose the context, check T42303 */
if (!has_match) {
- wm_window_substitute_old(wm, oldwm->windows.first, wm->windows.first);
+ wm_window_substitute_old(oldwm, wm, oldwm->windows.first, wm->windows.first);
}
wm_close_and_free_all(C, current_wm_list);
@@ -482,11 +486,18 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
CTX_wm_window_set(C, wm->windows.first);
- ED_editors_init(C);
-
Main *bmain = CTX_data_main(C);
DEG_on_visible_update(bmain, true);
+ if (!is_startup_file) {
+ /* When starting up, the UI hasn't been fully initialised yet, and
+ * this call can trigger icon updates, causing a segfault due to a
+ * not-yet-initialised ghash for the icons. */
+ wm_event_do_depsgraph(C);
+ }
+
+ ED_editors_init(C);
+
#ifdef WITH_PYTHON
if (is_startup_file) {
/* possible python hasn't been initialized */
@@ -2136,16 +2147,6 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
RNA_boolean_get(op->ptr, "copy")),
G_FILE_SAVE_COPY);
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- SET_FLAG_FROM_TEST(
- fileflags,
- (RNA_struct_find_property(op->ptr, "use_mesh_compat") &&
- RNA_boolean_get(op->ptr, "use_mesh_compat")),
- G_FILE_MESH_COMPAT);
-#else
-# error "don't remove by accident"
-#endif
-
if (wm_file_write(C, path, fileflags, op->reports) != 0)
return OPERATOR_CANCELLED;
@@ -2197,11 +2198,6 @@ void WM_OT_save_as_mainfile(wmOperatorType *ot)
prop = RNA_def_boolean(ot->srna, "copy", false, "Save Copy",
"Save a copy of the actual working state but does not make saved file active");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- RNA_def_boolean(ot->srna, "use_mesh_compat", false, "Legacy Mesh Format",
- "Save using legacy mesh format (no ngons) - WARNING: only saves tris and quads, other ngons will "
- "be lost (no implicit triangulation)");
-#endif
}
static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 4366013084c..06a7f3528c5 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -166,7 +166,7 @@ static void wm_gesture_draw_line(wmGesture *gt)
{
rcti *rect = (rcti *)gt->customdata;
- uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -181,7 +181,7 @@ static void wm_gesture_draw_line(wmGesture *gt)
float xmin = (float)rect->xmin;
float ymin = (float)rect->ymin;
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(shdr_pos, xmin, ymin);
immVertex2f(shdr_pos, (float)rect->xmax, (float)rect->ymax);
immEnd();
@@ -193,7 +193,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
{
rcti *rect = (rcti *)gt->customdata;
- uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
glEnable(GL_BLEND);
@@ -206,7 +206,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
glDisable(GL_BLEND);
- shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -231,7 +231,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
glEnable(GL_BLEND);
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -346,7 +346,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled)
return;
}
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -358,7 +358,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled)
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
immUniform1f("dash_width", 2.0f);
- immBegin((gt->type == WM_GESTURE_LASSO) ? GWN_PRIM_LINE_LOOP : GWN_PRIM_LINE_STRIP, numverts);
+ immBegin((gt->type == WM_GESTURE_LASSO) ? GPU_PRIM_LINE_LOOP : GPU_PRIM_LINE_STRIP, numverts);
for (i = 0; i < gt->points; i++, lasso += 2) {
immVertex2f(shdr_pos, (float)lasso[0], (float)lasso[1]);
@@ -377,7 +377,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
float x1, x2, y1, y2;
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -389,7 +389,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
immUniform1f("dash_width", 8.0f);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
x1 = (float)(rect->xmin - winsize_x);
y1 = (float)rect->ymin;
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index c1af7153b62..c51d4c5534a 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -35,6 +35,7 @@
#include <string.h>
#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
@@ -119,6 +120,7 @@
#include "GPU_material.h"
#include "GPU_draw.h"
+#include "GPU_immediate.h"
#include "GPU_init_exit.h"
#include "BKE_sound.h"
@@ -207,17 +209,20 @@ void WM_init(bContext *C, int argc, const char **argv)
BKE_addon_pref_type_init();
wm_operatortype_init();
+ wm_operatortypes_register();
+
+ WM_paneltype_init(); /* Lookup table only. */
WM_menutype_init();
WM_uilisttype_init();
- wm_manipulatortype_init();
- wm_manipulatorgrouptype_init();
+ wm_gizmotype_init();
+ wm_gizmogrouptype_init();
ED_undosys_type_init();
BKE_library_callback_free_window_manager_set(wm_close_and_free); /* library.c */
BKE_library_callback_free_notifier_reference_set(WM_main_remove_notifier_reference); /* library.c */
- BKE_region_callback_free_manipulatormap_set(wm_manipulatormap_remove); /* screen.c */
- BKE_region_callback_refresh_tag_manipulatormap_set(WM_manipulatormap_tag_refresh);
+ BKE_region_callback_free_gizmomap_set(wm_gizmomap_remove); /* screen.c */
+ BKE_region_callback_refresh_tag_gizmomap_set(WM_gizmomap_tag_refresh);
BKE_library_callback_remap_editor_id_reference_set(WM_main_remap_editor_id_reference); /* library.c */
BKE_blender_callback_test_break_set(wm_window_testbreak); /* blender.c */
BKE_spacedata_callback_id_remap_set(ED_spacedata_id_remap); /* screen.c */
@@ -451,6 +456,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
}
}
+ WM_paneltype_clear();
BKE_addon_pref_type_free();
wm_operatortype_free();
wm_dropbox_free();
@@ -491,8 +497,6 @@ void WM_exit_ext(bContext *C, const bool do_python)
#endif
GPU_free_unused_buffers(G_MAIN);
-
- GPU_exit();
}
BKE_blender_free(); /* blender.c, does entire library and spacetypes */
@@ -505,15 +509,18 @@ void WM_exit_ext(bContext *C, const bool do_python)
ED_gpencil_strokes_copybuf_free();
BKE_node_clipboard_clear();
- /* free manipulator-maps after freeing blender, so no deleted data get accessed during cleaning up of areas */
- wm_manipulatormaptypes_free();
- wm_manipulatorgrouptype_free();
- wm_manipulatortype_free();
+ /* free gizmo-maps after freeing blender, so no deleted data get accessed during cleaning up of areas */
+ wm_gizmomaptypes_free();
+ wm_gizmogrouptype_free();
+ wm_gizmotype_free();
BLF_exit();
if (opengl_is_init) {
+ DRW_opengl_context_enable_ex(false);
GPU_pass_cache_free();
+ GPU_exit();
+ DRW_opengl_context_disable_ex(false);
DRW_opengl_context_destroy();
}
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 3a4195ae1ae..dd9e7edf413 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -500,7 +500,7 @@ void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type)
next_job = wm_job->next;
if (!owner || wm_job->owner == owner)
- if (wm_job->job_type == job_type)
+ if (job_type == WM_JOB_TYPE_ANY || wm_job->job_type == job_type)
wm_jobs_kill_job(wm, wm_job);
}
}
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 9c435297069..a95ccf36fdb 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -509,6 +509,15 @@ wmKeyMapItem *WM_keymap_add_menu_pie(wmKeyMap *keymap, const char *idname, int t
return kmi;
}
+wmKeyMapItem *WM_keymap_add_panel(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
+{
+ wmKeyMapItem *kmi = WM_keymap_add_item(keymap, "WM_OT_call_panel", type, val, modifier, keymodifier);
+ RNA_string_set(kmi->ptr, "name", idname);
+ /* TODO: we might want to disable this. */
+ RNA_boolean_set(kmi->ptr, "keep_open", false);
+ return kmi;
+}
+
/* tool wrapper for WM_keymap_add_item */
wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
{
diff --git a/source/blender/windowmanager/intern/wm_menu_type.c b/source/blender/windowmanager/intern/wm_menu_type.c
new file mode 100644
index 00000000000..97ca5690954
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_menu_type.c
@@ -0,0 +1,115 @@
+/*
+ * ***** 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/windowmanager/intern/wm_menu_type.c
+ * \ingroup wm
+ *
+ * Menu Registry.
+ */
+
+#include "BLI_sys_types.h"
+
+#include "DNA_windowmanager_types.h"
+#include "DNA_workspace_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+
+#include "BKE_context.h"
+#include "BKE_library.h"
+#include "BKE_screen.h"
+#include "BKE_workspace.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+static GHash *menutypes_hash = NULL;
+
+MenuType *WM_menutype_find(const char *idname, bool quiet)
+{
+ MenuType *mt;
+
+ if (idname[0]) {
+ mt = BLI_ghash_lookup(menutypes_hash, idname);
+ if (mt)
+ return mt;
+ }
+
+ if (!quiet)
+ printf("search for unknown menutype %s\n", idname);
+
+ return NULL;
+}
+
+bool WM_menutype_add(MenuType *mt)
+{
+ BLI_ghash_insert(menutypes_hash, mt->idname, mt);
+ return true;
+}
+
+void WM_menutype_freelink(MenuType *mt)
+{
+ bool ok;
+
+ ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN);
+
+ BLI_assert(ok);
+ (void)ok;
+}
+
+/* called on initialize WM_init() */
+void WM_menutype_init(void)
+{
+ /* reserve size is set based on blender default setup */
+ menutypes_hash = BLI_ghash_str_new_ex("menutypes_hash gh", 512);
+}
+
+void WM_menutype_free(void)
+{
+ GHashIterator gh_iter;
+
+ GHASH_ITER (gh_iter, menutypes_hash) {
+ MenuType *mt = BLI_ghashIterator_getValue(&gh_iter);
+ if (mt->ext.free) {
+ mt->ext.free(mt->ext.data);
+ }
+ }
+
+ BLI_ghash_free(menutypes_hash, NULL, MEM_freeN);
+ menutypes_hash = NULL;
+}
+
+bool WM_menutype_poll(bContext *C, MenuType *mt)
+{
+ /* If we're tagged, only use compatible. */
+ if (mt->owner_id[0] != '\0') {
+ const WorkSpace *workspace = CTX_wm_workspace(C);
+ if (BKE_workspace_owner_id_check(workspace, mt->owner_id) == false) {
+ return false;
+ }
+ }
+
+ if (mt->poll != NULL) {
+ return mt->poll(C, mt);
+ }
+ return true;
+}
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
new file mode 100644
index 00000000000..89421ac0ab0
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -0,0 +1,567 @@
+/*
+ * ***** 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/windowmanager/intern/wm_operator_type.c
+ * \ingroup wm
+ *
+ * Operator Registry.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "CLG_log.h"
+
+#include "DNA_ID.h"
+#include "DNA_screen_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_userdef_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BLT_translation.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+
+#include "BKE_context.h"
+#include "BKE_idprop.h"
+#include "BKE_library.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "wm.h"
+#include "wm_event_system.h"
+
+#define UNDOCUMENTED_OPERATOR_TIP N_("(undocumented operator)")
+
+static void wm_operatortype_free_macro(wmOperatorType *ot);
+
+/* -------------------------------------------------------------------- */
+/** \name Operator Type Registry
+ * \{ */
+
+static GHash *global_ops_hash = NULL;
+/** Counter for operator-properties that should not be tagged with #OP_PROP_TAG_ADVANCED. */
+static int ot_prop_basic_count = -1;
+
+wmOperatorType *WM_operatortype_find(const char *idname, bool quiet)
+{
+ if (idname[0]) {
+ wmOperatorType *ot;
+
+ /* needed to support python style names without the _OT_ syntax */
+ char idname_bl[OP_MAX_TYPENAME];
+ WM_operator_bl_idname(idname_bl, idname);
+
+ ot = BLI_ghash_lookup(global_ops_hash, idname_bl);
+ if (ot) {
+ return ot;
+ }
+
+ if (!quiet) {
+ CLOG_INFO(WM_LOG_OPERATORS, 0, "search for unknown operator '%s', '%s'\n", idname_bl, idname);
+ }
+ }
+ else {
+ if (!quiet) {
+ CLOG_INFO(WM_LOG_OPERATORS, 0, "search for empty operator");
+ }
+ }
+
+ return NULL;
+}
+
+/* caller must free */
+void WM_operatortype_iter(GHashIterator *ghi)
+{
+ BLI_ghashIterator_init(ghi, global_ops_hash);
+}
+
+/** \name Operator Type Append
+ * \{ */
+
+static wmOperatorType *wm_operatortype_append__begin(void)
+{
+ wmOperatorType *ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
+
+ BLI_assert(ot_prop_basic_count == -1);
+
+ ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
+ RNA_def_struct_property_tags(ot->srna, rna_enum_operator_property_tags);
+ /* Set the default i18n context now, so that opfunc can redefine it if needed! */
+ RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+ ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
+
+ return ot;
+}
+static void wm_operatortype_append__end(wmOperatorType *ot)
+{
+ if (ot->name == NULL) {
+ CLOG_ERROR(WM_LOG_OPERATORS, "Operator '%s' has no name property", ot->idname);
+ }
+
+ /* Allow calling _begin without _end in operatortype creation. */
+ WM_operatortype_props_advanced_end(ot);
+
+ /* XXX All ops should have a description but for now allow them not to. */
+ RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
+ RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
+
+ BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
+}
+
+/* all ops in 1 list (for time being... needs evaluation later) */
+void WM_operatortype_append(void (*opfunc)(wmOperatorType *))
+{
+ wmOperatorType *ot = wm_operatortype_append__begin();
+ opfunc(ot);
+ wm_operatortype_append__end(ot);
+}
+
+void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata)
+{
+ wmOperatorType *ot = wm_operatortype_append__begin();
+ opfunc(ot, userdata);
+ wm_operatortype_append__end(ot);
+}
+
+/** \} */
+
+
+/* called on initialize WM_exit() */
+void WM_operatortype_remove_ptr(wmOperatorType *ot)
+{
+ BLI_assert(ot == WM_operatortype_find(ot->idname, false));
+
+ RNA_struct_free(&BLENDER_RNA, ot->srna);
+
+ if (ot->last_properties) {
+ IDP_FreeProperty(ot->last_properties);
+ MEM_freeN(ot->last_properties);
+ }
+
+ if (ot->macro.first)
+ wm_operatortype_free_macro(ot);
+
+ BLI_ghash_remove(global_ops_hash, ot->idname, NULL, NULL);
+
+ WM_keyconfig_update_operatortype();
+
+ MEM_freeN(ot);
+}
+
+bool WM_operatortype_remove(const char *idname)
+{
+ wmOperatorType *ot = WM_operatortype_find(idname, 0);
+
+ if (ot == NULL)
+ return false;
+
+ WM_operatortype_remove_ptr(ot);
+
+ return true;
+}
+
+/* called on initialize WM_init() */
+void wm_operatortype_init(void)
+{
+ /* reserve size is set based on blender default setup */
+ global_ops_hash = BLI_ghash_str_new_ex("wm_operatortype_init gh", 2048);
+}
+
+static void operatortype_ghash_free_cb(wmOperatorType *ot)
+{
+ if (ot->last_properties) {
+ IDP_FreeProperty(ot->last_properties);
+ MEM_freeN(ot->last_properties);
+ }
+
+ if (ot->macro.first)
+ wm_operatortype_free_macro(ot);
+
+ if (ot->ext.srna) /* python operator, allocs own string */
+ MEM_freeN((void *)ot->idname);
+
+ MEM_freeN(ot);
+}
+
+void wm_operatortype_free(void)
+{
+ BLI_ghash_free(global_ops_hash, NULL, (GHashValFreeFP)operatortype_ghash_free_cb);
+ global_ops_hash = NULL;
+}
+
+/**
+ * Tag all operator-properties of \a ot defined after calling this, until
+ * the next #WM_operatortype_props_advanced_end call (if available), with
+ * #OP_PROP_TAG_ADVANCED. Previously defined ones properties not touched.
+ *
+ * Calling this multiple times without a call to #WM_operatortype_props_advanced_end,
+ * all calls after the first one are ignored. Meaning all propereties defined after the
+ * first call are tagged as advanced.
+ *
+ * This doesn't do the actual tagging, #WM_operatortype_props_advanced_end does which is
+ * called for all operators during registration (see #wm_operatortype_append__end).
+ */
+void WM_operatortype_props_advanced_begin(wmOperatorType *ot)
+{
+ if (ot_prop_basic_count == -1) { /* Don't do anything if _begin was called before, but not _end */
+ ot_prop_basic_count = RNA_struct_count_properties(ot->srna);
+ }
+}
+
+/**
+ * Tags all operator-properties of \ot defined since the first #WM_operatortype_props_advanced_begin
+ * call, or the last #WM_operatortype_props_advanced_end call, with #OP_PROP_TAG_ADVANCED.
+ * Note that this is called for all operators during registration (see #wm_operatortype_append__end).
+ * So it does not need to be explicitly called in operator-type definition.
+ */
+void WM_operatortype_props_advanced_end(wmOperatorType *ot)
+{
+ PointerRNA struct_ptr;
+ int counter = 0;
+
+ if (ot_prop_basic_count == -1) {
+ /* WM_operatortype_props_advanced_begin was not called. Don't do anything. */
+ return;
+ }
+
+ RNA_pointer_create(NULL, ot->srna, NULL, &struct_ptr);
+
+ RNA_STRUCT_BEGIN (&struct_ptr, prop)
+ {
+ counter++;
+ if (counter > ot_prop_basic_count) {
+ WM_operatortype_prop_tag(prop, OP_PROP_TAG_ADVANCED);
+ }
+ }
+ RNA_STRUCT_END;
+
+ ot_prop_basic_count = -1;
+}
+
+/**
+ * Remove memory of all previously executed tools.
+ */
+void WM_operatortype_last_properties_clear_all(void)
+{
+ GHashIterator iter;
+
+ for (WM_operatortype_iter(&iter);
+ (!BLI_ghashIterator_done(&iter));
+ (BLI_ghashIterator_step(&iter)))
+ {
+ wmOperatorType *ot = BLI_ghashIterator_getValue(&iter);
+
+ if (ot->last_properties) {
+ IDP_FreeProperty(ot->last_properties);
+ MEM_freeN(ot->last_properties);
+ ot->last_properties = NULL;
+ }
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Operator Macro Type
+ * \{ */
+
+typedef struct {
+ int retval;
+} MacroData;
+
+static void wm_macro_start(wmOperator *op)
+{
+ if (op->customdata == NULL) {
+ op->customdata = MEM_callocN(sizeof(MacroData), "MacroData");
+ }
+}
+
+static int wm_macro_end(wmOperator *op, int retval)
+{
+ if (retval & OPERATOR_CANCELLED) {
+ MacroData *md = op->customdata;
+
+ if (md->retval & OPERATOR_FINISHED) {
+ retval |= OPERATOR_FINISHED;
+ retval &= ~OPERATOR_CANCELLED;
+ }
+ }
+
+ /* if modal is ending, free custom data */
+ if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) {
+ if (op->customdata) {
+ MEM_freeN(op->customdata);
+ op->customdata = NULL;
+ }
+ }
+
+ return retval;
+}
+
+/* macro exec only runs exec calls */
+static int wm_macro_exec(bContext *C, wmOperator *op)
+{
+ wmOperator *opm;
+ int retval = OPERATOR_FINISHED;
+
+ wm_macro_start(op);
+
+ for (opm = op->macro.first; opm; opm = opm->next) {
+
+ if (opm->type->exec) {
+ retval = opm->type->exec(C, opm);
+ OPERATOR_RETVAL_CHECK(retval);
+
+ if (retval & OPERATOR_FINISHED) {
+ MacroData *md = op->customdata;
+ md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
+ }
+ else {
+ break; /* operator didn't finish, end macro */
+ }
+ }
+ else {
+ CLOG_WARN(WM_LOG_OPERATORS, "'%s' cant exec macro", opm->type->idname);
+ }
+ }
+
+ return wm_macro_end(op, retval);
+}
+
+static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent *event, wmOperator *opm)
+{
+ int retval = OPERATOR_FINISHED;
+
+ /* start from operator received as argument */
+ for (; opm; opm = opm->next) {
+ if (opm->type->invoke)
+ retval = opm->type->invoke(C, opm, event);
+ else if (opm->type->exec)
+ retval = opm->type->exec(C, opm);
+
+ OPERATOR_RETVAL_CHECK(retval);
+
+ BLI_movelisttolist(&op->reports->list, &opm->reports->list);
+
+ if (retval & OPERATOR_FINISHED) {
+ MacroData *md = op->customdata;
+ md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
+ }
+ else {
+ break; /* operator didn't finish, end macro */
+ }
+ }
+
+ return wm_macro_end(op, retval);
+}
+
+static int wm_macro_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ wm_macro_start(op);
+ return wm_macro_invoke_internal(C, op, event, op->macro.first);
+}
+
+static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ wmOperator *opm = op->opm;
+ int retval = OPERATOR_FINISHED;
+
+ if (opm == NULL) {
+ CLOG_ERROR(WM_LOG_OPERATORS, "macro error, calling NULL modal()");
+ }
+ else {
+ retval = opm->type->modal(C, opm, event);
+ OPERATOR_RETVAL_CHECK(retval);
+
+ /* if we're halfway through using a tool and cancel it, clear the options [#37149] */
+ if (retval & OPERATOR_CANCELLED) {
+ WM_operator_properties_clear(opm->ptr);
+ }
+
+ /* if this one is done but it's not the last operator in the macro */
+ if ((retval & OPERATOR_FINISHED) && opm->next) {
+ MacroData *md = op->customdata;
+
+ md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
+
+ retval = wm_macro_invoke_internal(C, op, event, opm->next);
+
+ /* if new operator is modal and also added its own handler */
+ if (retval & OPERATOR_RUNNING_MODAL && op->opm != opm) {
+ wmWindow *win = CTX_wm_window(C);
+ wmEventHandler *handler;
+
+ handler = BLI_findptr(&win->modalhandlers, op, offsetof(wmEventHandler, op));
+ if (handler) {
+ BLI_remlink(&win->modalhandlers, handler);
+ wm_event_free_handler(handler);
+ }
+
+ /* if operator is blocking, grab cursor
+ * This may end up grabbing twice, but we don't care.
+ * */
+ if (op->opm->type->flag & OPTYPE_BLOCKING) {
+ int bounds[4] = {-1, -1, -1, -1};
+ const bool wrap = (
+ (U.uiflag & USER_CONTINUOUS_MOUSE) &&
+ ((op->opm->flag & OP_IS_MODAL_GRAB_CURSOR) || (op->opm->type->flag & OPTYPE_GRAB_CURSOR)));
+
+ if (wrap) {
+ ARegion *ar = CTX_wm_region(C);
+ if (ar) {
+ bounds[0] = ar->winrct.xmin;
+ bounds[1] = ar->winrct.ymax;
+ bounds[2] = ar->winrct.xmax;
+ bounds[3] = ar->winrct.ymin;
+ }
+ }
+
+ WM_cursor_grab_enable(win, wrap, false, bounds);
+ }
+ }
+ }
+ }
+
+ return wm_macro_end(op, retval);
+}
+
+static void wm_macro_cancel(bContext *C, wmOperator *op)
+{
+ /* call cancel on the current modal operator, if any */
+ if (op->opm && op->opm->type->cancel) {
+ op->opm->type->cancel(C, op->opm);
+ }
+
+ wm_macro_end(op, OPERATOR_CANCELLED);
+}
+
+/* Names have to be static for now */
+wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)
+{
+ wmOperatorType *ot;
+ const char *i18n_context;
+
+ if (WM_operatortype_find(idname, true)) {
+ CLOG_ERROR(WM_LOG_OPERATORS, "operator %s exists, cannot create macro", idname);
+ return NULL;
+ }
+
+ ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
+ ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
+
+ ot->idname = idname;
+ ot->name = name;
+ ot->description = description;
+ ot->flag = OPTYPE_MACRO | flag;
+
+ ot->exec = wm_macro_exec;
+ ot->invoke = wm_macro_invoke;
+ ot->modal = wm_macro_modal;
+ ot->cancel = wm_macro_cancel;
+ ot->poll = NULL;
+
+ if (!ot->description) /* XXX All ops should have a description but for now allow them not to. */
+ ot->description = UNDOCUMENTED_OPERATOR_TIP;
+
+ RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
+ RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
+ /* Use i18n context from ext.srna if possible (py operators). */
+ i18n_context = ot->ext.srna ? RNA_struct_translation_context(ot->ext.srna) : BLT_I18NCONTEXT_OPERATOR_DEFAULT;
+ RNA_def_struct_translation_context(ot->srna, i18n_context);
+ ot->translation_context = i18n_context;
+
+ BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
+
+ return ot;
+}
+
+void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata)
+{
+ wmOperatorType *ot;
+
+ ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
+ ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
+
+ ot->flag = OPTYPE_MACRO;
+ ot->exec = wm_macro_exec;
+ ot->invoke = wm_macro_invoke;
+ ot->modal = wm_macro_modal;
+ ot->cancel = wm_macro_cancel;
+ ot->poll = NULL;
+
+ if (!ot->description)
+ ot->description = UNDOCUMENTED_OPERATOR_TIP;
+
+ /* Set the default i18n context now, so that opfunc can redefine it if needed! */
+ RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+ ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
+ opfunc(ot, userdata);
+
+ RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
+ RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
+
+ BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
+}
+
+wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
+{
+ wmOperatorTypeMacro *otmacro = MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro");
+
+ BLI_strncpy(otmacro->idname, idname, OP_MAX_TYPENAME);
+
+ /* do this on first use, since operatordefinitions might have been not done yet */
+ WM_operator_properties_alloc(&(otmacro->ptr), &(otmacro->properties), idname);
+ WM_operator_properties_sanitize(otmacro->ptr, 1);
+
+ BLI_addtail(&ot->macro, otmacro);
+
+ {
+ /* operator should always be found but in the event its not. don't segfault */
+ wmOperatorType *otsub = WM_operatortype_find(idname, 0);
+ if (otsub) {
+ RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna,
+ otsub->name, otsub->description);
+ }
+ }
+
+ return otmacro;
+}
+
+static void wm_operatortype_free_macro(wmOperatorType *ot)
+{
+ wmOperatorTypeMacro *otmacro;
+
+ for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
+ if (otmacro->ptr) {
+ WM_operator_properties_free(otmacro->ptr);
+ MEM_freeN(otmacro->ptr);
+ }
+ }
+ BLI_freelistN(&ot->macro);
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index fb4ff4ddb28..e757c7bee52 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -120,478 +120,10 @@
#include "wm_files.h"
#include "wm_window.h"
-static GHash *global_ops_hash = NULL;
-/** Counter for operator-properties that should not be tagged with #OP_PROP_TAG_ADVANCED. */
-static int ot_prop_basic_count = -1;
-
#define UNDOCUMENTED_OPERATOR_TIP N_("(undocumented operator)")
/* ************ operator API, exported ********** */
-
-wmOperatorType *WM_operatortype_find(const char *idname, bool quiet)
-{
- if (idname[0]) {
- wmOperatorType *ot;
-
- /* needed to support python style names without the _OT_ syntax */
- char idname_bl[OP_MAX_TYPENAME];
- WM_operator_bl_idname(idname_bl, idname);
-
- ot = BLI_ghash_lookup(global_ops_hash, idname_bl);
- if (ot) {
- return ot;
- }
-
- if (!quiet) {
- CLOG_INFO(WM_LOG_OPERATORS, 0, "search for unknown operator '%s', '%s'\n", idname_bl, idname);
- }
- }
- else {
- if (!quiet) {
- CLOG_INFO(WM_LOG_OPERATORS, 0, "search for empty operator");
- }
- }
-
- return NULL;
-}
-
-/* caller must free */
-void WM_operatortype_iter(GHashIterator *ghi)
-{
- BLI_ghashIterator_init(ghi, global_ops_hash);
-}
-
-/** \name Operator Type Append
- * \{ */
-
-static wmOperatorType *wm_operatortype_append__begin(void)
-{
- wmOperatorType *ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
-
- BLI_assert(ot_prop_basic_count == -1);
-
- ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
- RNA_def_struct_property_tags(ot->srna, rna_enum_operator_property_tags);
- /* Set the default i18n context now, so that opfunc can redefine it if needed! */
- RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
- ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
-
- return ot;
-}
-static void wm_operatortype_append__end(wmOperatorType *ot)
-{
- if (ot->name == NULL) {
- CLOG_ERROR(WM_LOG_OPERATORS, "Operator '%s' has no name property", ot->idname);
- }
-
- /* Allow calling _begin without _end in operatortype creation. */
- WM_operatortype_props_advanced_end(ot);
-
- /* XXX All ops should have a description but for now allow them not to. */
- RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
- RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
-
- BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
-}
-
-/* all ops in 1 list (for time being... needs evaluation later) */
-void WM_operatortype_append(void (*opfunc)(wmOperatorType *))
-{
- wmOperatorType *ot = wm_operatortype_append__begin();
- opfunc(ot);
- wm_operatortype_append__end(ot);
-}
-
-void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata)
-{
- wmOperatorType *ot = wm_operatortype_append__begin();
- opfunc(ot, userdata);
- wm_operatortype_append__end(ot);
-}
-
-/** \} */
-
-/* ********************* macro operator ******************** */
-
-typedef struct {
- int retval;
-} MacroData;
-
-static void wm_macro_start(wmOperator *op)
-{
- if (op->customdata == NULL) {
- op->customdata = MEM_callocN(sizeof(MacroData), "MacroData");
- }
-}
-
-static int wm_macro_end(wmOperator *op, int retval)
-{
- if (retval & OPERATOR_CANCELLED) {
- MacroData *md = op->customdata;
-
- if (md->retval & OPERATOR_FINISHED) {
- retval |= OPERATOR_FINISHED;
- retval &= ~OPERATOR_CANCELLED;
- }
- }
-
- /* if modal is ending, free custom data */
- if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) {
- if (op->customdata) {
- MEM_freeN(op->customdata);
- op->customdata = NULL;
- }
- }
-
- return retval;
-}
-
-/* macro exec only runs exec calls */
-static int wm_macro_exec(bContext *C, wmOperator *op)
-{
- wmOperator *opm;
- int retval = OPERATOR_FINISHED;
-
- wm_macro_start(op);
-
- for (opm = op->macro.first; opm; opm = opm->next) {
-
- if (opm->type->exec) {
- retval = opm->type->exec(C, opm);
- OPERATOR_RETVAL_CHECK(retval);
-
- if (retval & OPERATOR_FINISHED) {
- MacroData *md = op->customdata;
- md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
- }
- else {
- break; /* operator didn't finish, end macro */
- }
- }
- else {
- CLOG_WARN(WM_LOG_OPERATORS, "'%s' cant exec macro", opm->type->idname);
- }
- }
-
- return wm_macro_end(op, retval);
-}
-
-static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent *event, wmOperator *opm)
-{
- int retval = OPERATOR_FINISHED;
-
- /* start from operator received as argument */
- for (; opm; opm = opm->next) {
- if (opm->type->invoke)
- retval = opm->type->invoke(C, opm, event);
- else if (opm->type->exec)
- retval = opm->type->exec(C, opm);
-
- OPERATOR_RETVAL_CHECK(retval);
-
- BLI_movelisttolist(&op->reports->list, &opm->reports->list);
-
- if (retval & OPERATOR_FINISHED) {
- MacroData *md = op->customdata;
- md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
- }
- else {
- break; /* operator didn't finish, end macro */
- }
- }
-
- return wm_macro_end(op, retval);
-}
-
-static int wm_macro_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- wm_macro_start(op);
- return wm_macro_invoke_internal(C, op, event, op->macro.first);
-}
-
-static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- wmOperator *opm = op->opm;
- int retval = OPERATOR_FINISHED;
-
- if (opm == NULL) {
- CLOG_ERROR(WM_LOG_OPERATORS, "macro error, calling NULL modal()");
- }
- else {
- retval = opm->type->modal(C, opm, event);
- OPERATOR_RETVAL_CHECK(retval);
-
- /* if we're halfway through using a tool and cancel it, clear the options [#37149] */
- if (retval & OPERATOR_CANCELLED) {
- WM_operator_properties_clear(opm->ptr);
- }
-
- /* if this one is done but it's not the last operator in the macro */
- if ((retval & OPERATOR_FINISHED) && opm->next) {
- MacroData *md = op->customdata;
-
- md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
-
- retval = wm_macro_invoke_internal(C, op, event, opm->next);
-
- /* if new operator is modal and also added its own handler */
- if (retval & OPERATOR_RUNNING_MODAL && op->opm != opm) {
- wmWindow *win = CTX_wm_window(C);
- wmEventHandler *handler;
-
- handler = BLI_findptr(&win->modalhandlers, op, offsetof(wmEventHandler, op));
- if (handler) {
- BLI_remlink(&win->modalhandlers, handler);
- wm_event_free_handler(handler);
- }
-
- /* if operator is blocking, grab cursor
- * This may end up grabbing twice, but we don't care.
- * */
- if (op->opm->type->flag & OPTYPE_BLOCKING) {
- int bounds[4] = {-1, -1, -1, -1};
- const bool wrap = (
- (U.uiflag & USER_CONTINUOUS_MOUSE) &&
- ((op->opm->flag & OP_IS_MODAL_GRAB_CURSOR) || (op->opm->type->flag & OPTYPE_GRAB_CURSOR)));
-
- if (wrap) {
- ARegion *ar = CTX_wm_region(C);
- if (ar) {
- bounds[0] = ar->winrct.xmin;
- bounds[1] = ar->winrct.ymax;
- bounds[2] = ar->winrct.xmax;
- bounds[3] = ar->winrct.ymin;
- }
- }
-
- WM_cursor_grab_enable(win, wrap, false, bounds);
- }
- }
- }
- }
-
- return wm_macro_end(op, retval);
-}
-
-static void wm_macro_cancel(bContext *C, wmOperator *op)
-{
- /* call cancel on the current modal operator, if any */
- if (op->opm && op->opm->type->cancel) {
- op->opm->type->cancel(C, op->opm);
- }
-
- wm_macro_end(op, OPERATOR_CANCELLED);
-}
-
-/* Names have to be static for now */
-wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)
-{
- wmOperatorType *ot;
- const char *i18n_context;
-
- if (WM_operatortype_find(idname, true)) {
- CLOG_ERROR(WM_LOG_OPERATORS, "operator %s exists, cannot create macro", idname);
- return NULL;
- }
-
- ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
- ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
-
- ot->idname = idname;
- ot->name = name;
- ot->description = description;
- ot->flag = OPTYPE_MACRO | flag;
-
- ot->exec = wm_macro_exec;
- ot->invoke = wm_macro_invoke;
- ot->modal = wm_macro_modal;
- ot->cancel = wm_macro_cancel;
- ot->poll = NULL;
-
- if (!ot->description) /* XXX All ops should have a description but for now allow them not to. */
- ot->description = UNDOCUMENTED_OPERATOR_TIP;
-
- RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
- RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
- /* Use i18n context from ext.srna if possible (py operators). */
- i18n_context = ot->ext.srna ? RNA_struct_translation_context(ot->ext.srna) : BLT_I18NCONTEXT_OPERATOR_DEFAULT;
- RNA_def_struct_translation_context(ot->srna, i18n_context);
- ot->translation_context = i18n_context;
-
- BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
-
- return ot;
-}
-
-void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata)
-{
- wmOperatorType *ot;
-
- ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
- ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
-
- ot->flag = OPTYPE_MACRO;
- ot->exec = wm_macro_exec;
- ot->invoke = wm_macro_invoke;
- ot->modal = wm_macro_modal;
- ot->cancel = wm_macro_cancel;
- ot->poll = NULL;
-
- if (!ot->description)
- ot->description = UNDOCUMENTED_OPERATOR_TIP;
-
- /* Set the default i18n context now, so that opfunc can redefine it if needed! */
- RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
- ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
- opfunc(ot, userdata);
-
- RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
- RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
-
- BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
-}
-
-wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
-{
- wmOperatorTypeMacro *otmacro = MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro");
-
- BLI_strncpy(otmacro->idname, idname, OP_MAX_TYPENAME);
-
- /* do this on first use, since operatordefinitions might have been not done yet */
- WM_operator_properties_alloc(&(otmacro->ptr), &(otmacro->properties), idname);
- WM_operator_properties_sanitize(otmacro->ptr, 1);
-
- BLI_addtail(&ot->macro, otmacro);
-
- {
- /* operator should always be found but in the event its not. don't segfault */
- wmOperatorType *otsub = WM_operatortype_find(idname, 0);
- if (otsub) {
- RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna,
- otsub->name, otsub->description);
- }
- }
-
- return otmacro;
-}
-
-static void wm_operatortype_free_macro(wmOperatorType *ot)
-{
- wmOperatorTypeMacro *otmacro;
-
- for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
- if (otmacro->ptr) {
- WM_operator_properties_free(otmacro->ptr);
- MEM_freeN(otmacro->ptr);
- }
- }
- BLI_freelistN(&ot->macro);
-}
-
-void WM_operatortype_remove_ptr(wmOperatorType *ot)
-{
- BLI_assert(ot == WM_operatortype_find(ot->idname, false));
-
- RNA_struct_free(&BLENDER_RNA, ot->srna);
-
- if (ot->last_properties) {
- IDP_FreeProperty(ot->last_properties);
- MEM_freeN(ot->last_properties);
- }
-
- if (ot->macro.first)
- wm_operatortype_free_macro(ot);
-
- BLI_ghash_remove(global_ops_hash, ot->idname, NULL, NULL);
-
- WM_keyconfig_update_operatortype();
-
- MEM_freeN(ot);
-}
-
-bool WM_operatortype_remove(const char *idname)
-{
- wmOperatorType *ot = WM_operatortype_find(idname, 0);
-
- if (ot == NULL)
- return false;
-
- WM_operatortype_remove_ptr(ot);
-
- return true;
-}
-
-/**
- * Remove memory of all previously executed tools.
- */
-void WM_operatortype_last_properties_clear_all(void)
-{
- GHashIterator iter;
-
- for (WM_operatortype_iter(&iter);
- (!BLI_ghashIterator_done(&iter));
- (BLI_ghashIterator_step(&iter)))
- {
- wmOperatorType *ot = BLI_ghashIterator_getValue(&iter);
-
- if (ot->last_properties) {
- IDP_FreeProperty(ot->last_properties);
- MEM_freeN(ot->last_properties);
- ot->last_properties = NULL;
- }
- }
-}
-
-/**
- * Tag all operator-properties of \a ot defined after calling this, until
- * the next #WM_operatortype_props_advanced_end call (if available), with
- * #OP_PROP_TAG_ADVANCED. Previously defined ones properties not touched.
- *
- * Calling this multiple times without a call to #WM_operatortype_props_advanced_end,
- * all calls after the first one are ignored. Meaning all propereties defined after the
- * first call are tagged as advanced.
- *
- * This doesn't do the actual tagging, #WM_operatortype_props_advanced_end does which is
- * called for all operators during registration (see #wm_operatortype_append__end).
- */
-void WM_operatortype_props_advanced_begin(wmOperatorType *ot)
-{
- if (ot_prop_basic_count == -1) { /* Don't do anything if _begin was called before, but not _end */
- ot_prop_basic_count = RNA_struct_count_properties(ot->srna);
- }
-}
-
-/**
- * Tags all operator-properties of \ot defined since the first #WM_operatortype_props_advanced_begin
- * call, or the last #WM_operatortype_props_advanced_end call, with #OP_PROP_TAG_ADVANCED.
- * Note that this is called for all operators during registration (see #wm_operatortype_append__end).
- * So it does not need to be explicitly called in operator-type definition.
- */
-void WM_operatortype_props_advanced_end(wmOperatorType *ot)
-{
- PointerRNA struct_ptr;
- int counter = 0;
-
- if (ot_prop_basic_count == -1) {
- /* WM_operatortype_props_advanced_begin was not called. Don't do anything. */
- return;
- }
-
- RNA_pointer_create(NULL, ot->srna, NULL, &struct_ptr);
-
- RNA_STRUCT_BEGIN (&struct_ptr, prop)
- {
- counter++;
- if (counter > ot_prop_basic_count) {
- WM_operatortype_prop_tag(prop, OP_PROP_TAG_ADVANCED);
- }
- }
- RNA_STRUCT_END;
-
- ot_prop_basic_count = -1;
-}
-
/* SOME_OT_op -> some.op */
void WM_operator_py_idname(char *to, const char *from)
{
@@ -1959,7 +1491,13 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
/* label for 'a' bugfix releases, or 'Release Candidate 1'...
* avoids recreating splash for version updates */
- if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) {
+ if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha")) {
+ version_suffix = "Alpha";
+ }
+ else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "beta")) {
+ version_suffix = "Beta";
+ }
+ else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) {
version_suffix = "Release Candidate";
}
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) {
@@ -2027,10 +1565,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
split = uiLayoutSplit(layout, 0.0f, false);
col = uiLayoutColumn(split, false);
uiItemL(col, IFACE_("Links"), ICON_NONE);
-#if 0
- uiItemStringO(col, IFACE_("Support an Open Animation Movie"), ICON_URL, "WM_OT_url_open", "url",
- "https://cloud.blender.org/join");
-#endif
+ uiItemStringO(col, IFACE_("Join the Development Fund"), ICON_URL, "WM_OT_url_open", "url",
+ "https://www.blender.org/foundation/development-fund/");
uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url",
"http://www.blender.org/foundation/donation-payment/");
uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url",
@@ -2242,11 +1778,9 @@ static int wm_call_panel_exec(bContext *C, wmOperator *op)
{
char idname[BKE_ST_MAXNAME];
RNA_string_get(op->ptr, "name", idname);
- const int space_type = RNA_enum_get(op->ptr, "space_type");
- const int region_type = RNA_enum_get(op->ptr, "region_type");
const bool keep_open = RNA_boolean_get(op->ptr, "keep_open");
- return UI_popover_panel_invoke(C, space_type, region_type, idname, keep_open, op->reports);
+ return UI_popover_panel_invoke(C, idname, keep_open, op->reports);
}
static void WM_OT_call_panel(wmOperatorType *ot)
@@ -2264,10 +1798,6 @@ static void WM_OT_call_panel(wmOperatorType *ot)
prop = RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_enum(ot->srna, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_enum(ot->srna, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "keep_open", true, "Keep Open", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -2294,7 +1824,7 @@ static void WM_OT_window_close(wmOperatorType *ot)
{
ot->name = "Close Window";
ot->idname = "WM_OT_window_close";
- ot->description = "Close the current Blender window";
+ ot->description = "Close the current window";
ot->exec = wm_window_close_exec;
ot->poll = WM_operator_winactive;
@@ -2304,12 +1834,22 @@ static void WM_OT_window_new(wmOperatorType *ot)
{
ot->name = "New Window";
ot->idname = "WM_OT_window_new";
- ot->description = "Create a new Blender window";
+ ot->description = "Create a new window";
ot->exec = wm_window_new_exec;
ot->poll = wm_operator_winactive_normal;
}
+static void WM_OT_window_new_main(wmOperatorType *ot)
+{
+ ot->name = "New Main Window";
+ ot->idname = "WM_OT_window_new_main";
+ ot->description = "Create a new main window with its own workspace and scene selection";
+
+ ot->exec = wm_window_new_main_exec;
+ ot->poll = wm_operator_winactive_normal;
+}
+
static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
{
ot->name = "Toggle Window Fullscreen";
@@ -2554,12 +2094,12 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
RNA_property_float_get_array(fill_ptr, fill_prop, col);
}
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (rc->gltex) {
- unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, rc->gltex);
@@ -2578,12 +2118,12 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
/* set up rotation if available */
if (rc->rot_prop) {
rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
- gpuPushMatrix();
- gpuRotate2D(RAD2DEGF(rot));
+ GPU_matrix_push();
+ GPU_matrix_rotate_2d(RAD2DEGF(rot));
}
/* draw textured quad */
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texCoord, 0, 0);
immVertex2f(pos, -radius, -radius);
@@ -2601,7 +2141,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
/* undo rotation */
if (rc->rot_prop)
- gpuPopMatrix();
+ GPU_matrix_pop();
}
else {
/* flat color if no texture available */
@@ -2668,7 +2208,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
/* Keep cursor in the original place */
x = rc->initial_mouse[0];
y = rc->initial_mouse[1];
- gpuTranslate2f((float)x, (float)y);
+ GPU_matrix_translate_2f((float)x, (float)y);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
@@ -2676,7 +2216,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
/* apply zoom if available */
if (rc->zoom_prop) {
RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
- gpuScale2fv(zoom);
+ GPU_matrix_scale_2fv(zoom);
}
/* draw rotated texture */
@@ -2686,30 +2226,30 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
if (rc->col_prop)
RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fvAlpha(col, 0.5f);
if (rc->subtype == PROP_ANGLE) {
- gpuPushMatrix();
+ GPU_matrix_push();
/* draw original angle line */
- gpuRotate2D(RAD2DEGF(rc->initial_value));
- immBegin(GWN_PRIM_LINES, 2);
+ GPU_matrix_rotate_2d(RAD2DEGF(rc->initial_value));
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f);
immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f);
immEnd();
/* draw new angle line */
- gpuRotate2D(RAD2DEGF(rc->current_value - rc->initial_value));
- immBegin(GWN_PRIM_LINES, 2);
+ GPU_matrix_rotate_2d(RAD2DEGF(rc->current_value - rc->initial_value));
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f);
immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f);
immEnd();
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/* draw circles on top */
@@ -3544,7 +3084,7 @@ static const EnumPropertyItem preview_id_type_items[] = {
{FILTER_ID_GR, "GROUP", 0, "Groups", ""},
{FILTER_ID_OB, "OBJECT", 0, "Objects", ""},
{FILTER_ID_MA, "MATERIAL", 0, "Materials", ""},
- {FILTER_ID_LA, "LAMP", 0, "Lamps", ""},
+ {FILTER_ID_LA, "LIGHT", 0, "Lights", ""},
{FILTER_ID_WO, "WORLD", 0, "Worlds", ""},
{FILTER_ID_TE, "TEXTURE", 0, "Textures", ""},
{FILTER_ID_IM, "IMAGE", 0, "Images", ""},
@@ -3635,24 +3175,6 @@ static void WM_OT_doc_view_manual_ui_context(wmOperatorType *ot)
}
/* ******************************************************* */
-
-static void operatortype_ghash_free_cb(wmOperatorType *ot)
-{
- if (ot->last_properties) {
- IDP_FreeProperty(ot->last_properties);
- MEM_freeN(ot->last_properties);
- }
-
- if (ot->macro.first)
- wm_operatortype_free_macro(ot);
-
- if (ot->ext.srna) /* python operator, allocs own string */
- MEM_freeN((void *)ot->idname);
-
- MEM_freeN(ot);
-}
-
-/* ******************************************************* */
/* toggle 3D for current window, turning it fullscreen if needed */
static void WM_OT_stereo3d_set(wmOperatorType *ot)
{
@@ -3683,22 +3205,11 @@ static void WM_OT_stereo3d_set(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-/* ******************************************************* */
-/* called on initialize WM_exit() */
-void wm_operatortype_free(void)
-{
- BLI_ghash_free(global_ops_hash, NULL, (GHashValFreeFP)operatortype_ghash_free_cb);
- global_ops_hash = NULL;
-}
-
-/* called on initialize WM_init() */
-void wm_operatortype_init(void)
+void wm_operatortypes_register(void)
{
- /* reserve size is set based on blender default setup */
- global_ops_hash = BLI_ghash_str_new_ex("wm_operatortype_init gh", 2048);
-
WM_operatortype_append(WM_OT_window_close);
WM_operatortype_append(WM_OT_window_new);
+ WM_operatortype_append(WM_OT_window_new_main);
WM_operatortype_append(WM_OT_read_history);
WM_operatortype_append(WM_OT_read_homefile);
WM_operatortype_append(WM_OT_read_factory_settings);
@@ -3737,9 +3248,9 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_previews_clear);
WM_operatortype_append(WM_OT_doc_view_manual_ui_context);
- /* manipulators */
- WM_operatortype_append(MANIPULATORGROUP_OT_manipulator_select);
- WM_operatortype_append(MANIPULATORGROUP_OT_manipulator_tweak);
+ /* gizmos */
+ WM_operatortype_append(GIZMOGROUP_OT_gizmo_select);
+ WM_operatortype_append(GIZMOGROUP_OT_gizmo_tweak);
}
/* circleselect-like modal operators */
@@ -3981,6 +3492,11 @@ void wm_window_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "WM_OT_quit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
+ /* F-Keys are a hassle on some macos systems. */
+#ifdef __APPLE__
+ WM_keymap_add_item(keymap, "WM_OT_search_menu", FKEY, KM_PRESS, KM_OSKEY, 0);
+#endif
+
#ifdef USE_WM_KEYMAP_27X
WM_keymap_add_item(keymap, "WM_OT_doc_view_manual_ui_context", F1KEY, KM_PRESS, KM_ALT, 0);
@@ -3995,8 +3511,6 @@ void wm_window_keymap(wmKeyConfig *keyconf)
#endif
/* menus that can be accessed anywhere in blender */
- WM_keymap_add_item(keymap, "WM_OT_search_menu", ACCENTGRAVEKEY, KM_CLICK, 0, 0);
-
WM_keymap_add_menu(keymap, "SCREEN_MT_user_menu", QKEY, KM_PRESS, 0, 0);
#ifdef WITH_INPUT_NDOF
@@ -4066,7 +3580,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
RNA_float_set(kmi->ptr, "value", 1.0f / 1.5f);
#endif /* WITH_INPUT_NDOF */
- wm_manipulators_keymap(keyconf);
+ wm_gizmos_keymap(keyconf);
gesture_circle_modal_keymap(keyconf);
gesture_border_modal_keymap(keyconf);
gesture_zoom_border_modal_keymap(keyconf);
diff --git a/source/blender/windowmanager/intern/wm_panel_type.c b/source/blender/windowmanager/intern/wm_panel_type.c
new file mode 100644
index 00000000000..2c541db55a6
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_panel_type.c
@@ -0,0 +1,88 @@
+/*
+ * ***** 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/windowmanager/intern/wm_panel_type.c
+ * \ingroup wm
+ *
+ * Panel Registry.
+ *
+ * \note Unlike menu, and other registries, this doesn't *own* the PanelType.
+ *
+ * For popups/popovers only, regions handle panel types by including them in local lists.
+ */
+
+#include <stdio.h>
+
+#include "BLI_sys_types.h"
+
+#include "DNA_windowmanager_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+
+#include "BKE_screen.h"
+
+#include "WM_api.h"
+
+static GHash *g_paneltypes_hash = NULL;
+
+PanelType *WM_paneltype_find(const char *idname, bool quiet)
+{
+ PanelType *pt;
+
+ if (idname[0]) {
+ pt = BLI_ghash_lookup(g_paneltypes_hash, idname);
+ if (pt)
+ return pt;
+ }
+
+ if (!quiet)
+ printf("search for unknown paneltype %s\n", idname);
+
+ return NULL;
+}
+
+bool WM_paneltype_add(PanelType *pt)
+{
+ BLI_ghash_insert(g_paneltypes_hash, pt->idname, pt);
+ return true;
+}
+
+void WM_paneltype_remove(PanelType *pt)
+{
+ bool ok;
+
+ ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL);
+
+ BLI_assert(ok);
+ (void)ok;
+}
+
+/* called on initialize WM_init() */
+void WM_paneltype_init(void)
+{
+ /* reserve size is set based on blender default setup */
+ g_paneltypes_hash = BLI_ghash_str_new_ex("g_paneltypes_hash gh", 512);
+}
+
+void WM_paneltype_clear(void)
+{
+ BLI_ghash_free(g_paneltypes_hash, NULL, NULL);
+}
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 8c062be2a00..6317cca8094 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -28,8 +28,11 @@
/** \file blender/windowmanager/intern/wm_playanim.c
* \ingroup wm
*
+ * Animation player for image sequences & video's with sound support.
+ * Launched in a separate process from Blender's #RENDER_OT_play_rendered_anim
+ *
* \note This file uses ghost directly and none of the WM definitions.
- * this could be made into its own module, alongside creator/
+ * this could be made into its own module, alongside creator.
*/
#include <sys/types.h>
@@ -66,7 +69,7 @@
#include "GPU_matrix.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
-#include "GPU_batch.h"
+#include "GPU_context.h"
#include "GPU_init_exit.h"
#include "DNA_scene_types.h"
@@ -139,6 +142,9 @@ typedef struct PlayState {
/* restarts player for file drop */
char dropped_file[FILE_MAX];
+
+ bool need_frame_update;
+ int frame_cursor_x;
} PlayState;
/* for debugging */
@@ -181,7 +187,7 @@ typedef enum eWS_Qual {
static struct WindowStateGlobal {
GHOST_SystemHandle ghost_system;
void *ghost_window;
- Gwn_Context *gwn_context;
+ GPUContext *gpu_context;
/* events */
eWS_Qual qual;
@@ -198,8 +204,8 @@ static void playanim_window_get_size(int *r_width, int *r_height)
static void playanim_gl_matrix(void)
{
/* unified matrix, note it affects offset for drawing */
- /* note! cannot use gpuOrtho2D here because shader ignores. */
- gpuOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0, 1.0f);
+ /* note! cannot use GPU_matrix_ortho_2d_set here because shader ignores. */
+ GPU_matrix_ortho_set(0.0f, 1.0f, 0.0f, 1.0f, -1.0, 1.0f);
}
/* implementation */
@@ -363,25 +369,25 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
float fac = ps->picture->frame / (double)(((PlayAnimPict *)picsbase.last)->frame - ((PlayAnimPict *)picsbase.first)->frame);
fac = 2.0f * fac - 1.0f;
- gpuPushProjectionMatrix();
- gpuLoadIdentityProjectionMatrix();
- gpuPushMatrix();
- gpuLoadIdentity();
+ GPU_matrix_push_projection();
+ GPU_matrix_identity_projection_set();
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ub(0, 255, 0);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, fac, -1.0f);
immVertex2f(pos, fac, 1.0f);
immEnd();
immUnbindProgram();
- gpuPopMatrix();
- gpuPopProjectionMatrix();
+ GPU_matrix_pop();
+ GPU_matrix_pop_projection();
}
GHOST_SwapWindowBuffers(g_WS.ghost_window);
@@ -558,8 +564,18 @@ static void update_sound_fps(void)
#endif
}
-static void change_frame(PlayState *ps, int cx)
+static void tag_change_frame(PlayState *ps, int cx)
{
+ ps->need_frame_update = true;
+ ps->frame_cursor_x = cx;
+}
+
+static void change_frame(PlayState *ps)
+{
+ if (!ps->need_frame_update) {
+ return;
+ }
+
int sizex, sizey;
int i, i_last;
@@ -569,7 +585,7 @@ static void change_frame(PlayState *ps, int cx)
playanim_window_get_size(&sizex, &sizey);
i_last = ((struct PlayAnimPict *)picsbase.last)->frame;
- i = (i_last * cx) / sizex;
+ i = (i_last * ps->frame_cursor_x) / sizex;
CLAMP(i, 0, i_last);
#ifdef WITH_AUDASPACE
@@ -610,6 +626,8 @@ static void change_frame(PlayState *ps, int cx)
ps->sstep = true;
ps->wait2 = false;
ps->next_frame = 0;
+
+ ps->need_frame_update = false;
}
static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
@@ -961,7 +979,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
if (type == GHOST_kEventButtonDown) {
if (inside_window) {
g_WS.qual |= WS_QUAL_LMOUSE;
- change_frame(ps, cx);
+ tag_change_frame(ps, cx);
}
}
else
@@ -1006,7 +1024,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &cx, &cy);
- change_frame(ps, cx);
+ tag_change_frame(ps, cx);
}
break;
}
@@ -1266,8 +1284,9 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
//GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* initialize OpenGL immediate mode */
- g_WS.gwn_context = GWN_context_create();
+ g_WS.gpu_context = GPU_context_create();
GPU_init();
+ immActivate();
/* initialize the font */
BLF_init();
@@ -1442,23 +1461,18 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
ps.next_frame = ps.direction;
- while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, ps.wait2))) {
- if (hasevent) {
- GHOST_DispatchEvents(g_WS.ghost_system);
- }
- /* Note, this still draws for mousemoves on pause */
- if (ps.wait2) {
- if (hasevent) {
- if (ibuf) {
- while (pupdate_time()) PIL_sleep_ms(1);
- ptottime -= swaptime;
- playanim_toscreen(&ps, ps.picture, ibuf, ps.fontid, ps.fstep);
- }
- }
- }
- if (ps.go == false) {
- break;
- }
+ while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) {
+ GHOST_DispatchEvents(g_WS.ghost_system);
+ }
+ if (ps.go == false) {
+ break;
+ }
+ change_frame(&ps);
+ if (!hasevent) {
+ PIL_sleep_ms(1);
+ }
+ if (ps.wait2) {
+ continue;
}
ps.wait2 = ps.sstep;
@@ -1541,16 +1555,17 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
GPU_shader_free_builtin_shaders();
- GPU_exit();
-
- if (g_WS.gwn_context) {
- GWN_context_active_set(g_WS.gwn_context);
- GWN_context_discard(g_WS.gwn_context);
- g_WS.gwn_context = NULL;
+ if (g_WS.gpu_context) {
+ GPU_context_active_set(g_WS.gpu_context);
+ GPU_context_discard(g_WS.gpu_context);
+ g_WS.gpu_context = NULL;
}
BLF_exit();
+ immDeactivate();
+ GPU_exit();
+
GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window);
/* early exit, IMB and BKE should be exited only in end */
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 4450d18a5df..577145aff95 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -87,9 +87,9 @@ void wm_stereo3d_draw_interlace(wmWindow *win, ARegion *ar)
float halfx = GLA_PIXEL_OFS / ar->winx;
float halfy = GLA_PIXEL_OFS / ar->winy;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
/* leave GL_TEXTURE0 as the latest active texture */
for (int view = 1; view >= 0; view--) {
@@ -104,7 +104,7 @@ void wm_stereo3d_draw_interlace(wmWindow *win, ARegion *ar)
immUniform1i("interlace_id", interlace_gpu_id_from_type(interlace_type));
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texcoord, halfx, halfy);
immVertex2f(pos, ar->winrct.xmin, ar->winrct.ymin);
@@ -163,9 +163,9 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
{
bool cross_eyed = (win->stereo3d_format->flag & S3D_SIDEBYSIDE_CROSSEYED) != 0;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE);
@@ -188,7 +188,7 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texcoord, halfx, halfy);
immVertex2f(pos, soffx, 0.0f);
@@ -209,9 +209,9 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
void wm_stereo3d_draw_topbottom(wmWindow *win, int view)
{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE);
@@ -232,7 +232,7 @@ void wm_stereo3d_draw_topbottom(wmWindow *win, int view)
immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texcoord, halfx, halfy);
immVertex2f(pos, 0.0f, soffy);
@@ -404,7 +404,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
prev_display_mode != win_src->stereo3d_format->display_mode)
{
/* in case the hardward supports pageflip but not the display */
- if ((win_dst = wm_window_copy_test(C, win_src, false))) {
+ if ((win_dst = wm_window_copy_test(C, win_src, false, false))) {
/* pass */
}
else {
@@ -423,7 +423,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
ok = false;
}
/* pageflip requires a new window to be created with the proper OS flags */
- else if ((win_dst = wm_window_copy_test(C, win_src, false))) {
+ else if ((win_dst = wm_window_copy_test(C, win_src, false, false))) {
if (wm_stereo3d_quadbuffer_supported()) {
BKE_report(op->reports, RPT_INFO, "Quad-buffer window successfully created");
}
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index f55eee69f71..ff3c712dae0 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -50,7 +50,7 @@ void wmViewport(const rcti *winrct)
glScissor(winrct->xmin, winrct->ymin, width, height);
wmOrtho2_pixelspace(width, height);
- gpuLoadIdentity();
+ GPU_matrix_identity_set();
}
void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct)
@@ -89,7 +89,7 @@ void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct
glScissor(x, y, scissor_width, scissor_height);
wmOrtho2_pixelspace(width, height);
- gpuLoadIdentity();
+ GPU_matrix_identity_set();
}
void wmWindowViewport(wmWindow *win)
@@ -101,7 +101,7 @@ void wmWindowViewport(wmWindow *win)
glScissor(0, 0, width, height);
wmOrtho2_pixelspace(width, height);
- gpuLoadIdentity();
+ GPU_matrix_identity_set();
}
void wmOrtho2(float x1, float x2, float y1, float y2)
@@ -110,7 +110,7 @@ void wmOrtho2(float x1, float x2, float y1, float y2)
if (x1 == x2) x2 += 1.0f;
if (y1 == y2) y2 += 1.0f;
- gpuOrtho(x1, x2, y1, y2, -100, 100);
+ GPU_matrix_ortho_set(x1, x2, y1, y2, -100, 100);
}
static void wmOrtho2_offset(const float x, const float y, const float ofs)
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index cee5079a02f..dcb33376f05 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -69,11 +69,11 @@ static void toolsystem_refresh_screen_from_active_tool(
struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C)
{
WorkSpace *workspace = CTX_wm_workspace(C);
- Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
ScrArea *sa = CTX_wm_area(C);
const bToolKey tkey = {
.space_type = sa->spacetype,
- .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype),
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
};
bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
/* We could return 'sa->runtime.tool' in this case. */
@@ -131,9 +131,9 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t
{
bToolRef_Runtime *tref_rt = tref->runtime;
- if (tref_rt->manipulator_group[0]) {
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(tref_rt->manipulator_group, false);
- if (wgt != NULL) {
+ if (tref_rt->gizmo_group[0]) {
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false);
+ if (gzgt != NULL) {
bool found = false;
/* TODO(campbell) */
@@ -144,7 +144,7 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t
for (wmWindow *win = wm->windows.first; win; win = win->next) {
const WorkSpace *workspace_iter = WM_window_get_active_workspace(win);
if (workspace != workspace_iter) {
- if (STREQ(workspace->tool.manipulator_group, workspace_iter->tool.manipulator_group)) {
+ if (STREQ(workspace->tool.gizmo_group, workspace_iter->tool.gizmo_group)) {
found = true;
break;
}
@@ -154,8 +154,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t
UNUSED_VARS(workspace);
#endif
if (!found) {
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
- WM_manipulatormaptype_group_unlink(C, bmain, mmap_type, wgt);
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
+ WM_gizmomaptype_group_unlink(C, bmain, gzmap_type, gzgt);
}
}
}
@@ -171,11 +171,11 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tke
static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tref)
{
bToolRef_Runtime *tref_rt = tref->runtime;
- if (tref_rt->manipulator_group[0]) {
- const char *idname = tref_rt->manipulator_group;
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
- if (wgt != NULL) {
- WM_manipulator_group_type_ensure_ptr(wgt);
+ if (tref_rt->gizmo_group[0]) {
+ const char *idname = tref_rt->gizmo_group;
+ wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
+ if (gzgt != NULL) {
+ WM_gizmo_group_type_ensure_ptr(gzgt);
}
else {
CLOG_WARN(WM_LOG_TOOLS, "'%s' widget not found", idname);
@@ -192,8 +192,8 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
wmWindowManager *wm = bmain->wm.first;
for (wmWindow *win = wm->windows.first; win; win = win->next) {
if (workspace == WM_window_get_active_workspace(win)) {
- Scene *scene = win->scene;
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
+ Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Paint *paint = BKE_paint_get_active(scene, view_layer);
if (paint) {
if (brush) {
@@ -261,12 +261,12 @@ void WM_toolsystem_refresh_all(struct bContext *C, struct WorkSpace *workspace)
void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win)
{
bScreen *screen = WM_window_get_active_screen(win);
- Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
WorkSpace *workspace = WM_window_get_active_workspace(win);
const bToolKey tkey = {
.space_type = sa->spacetype,
- .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype),
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
};
bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
if (tref) {
@@ -331,11 +331,11 @@ void WM_toolsystem_init(bContext *C)
CTX_wm_window_set(C, win);
WorkSpace *workspace = WM_window_get_active_workspace(win);
bScreen *screen = WM_window_get_active_screen(win);
- Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
const bToolKey tkey = {
.space_type = sa->spacetype,
- .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype),
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
};
bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
if (tref) {
@@ -351,15 +351,13 @@ void WM_toolsystem_init(bContext *C)
}
int WM_toolsystem_mode_from_spacetype(
- WorkSpace *workspace, Scene *scene, ScrArea *sa,
- int spacetype)
+ ViewLayer *view_layer, ScrArea *sa, int spacetype)
{
int mode = -1;
switch (spacetype) {
case SPACE_VIEW3D:
{
/* 'sa' may be NULL in this case. */
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
Object *obact = OBACT(view_layer);
if (obact != NULL) {
Object *obedit = OBEDIT_FROM_OBACT(obact);
@@ -381,15 +379,14 @@ int WM_toolsystem_mode_from_spacetype(
}
bool WM_toolsystem_key_from_context(
- WorkSpace *workspace, Scene *scene, ScrArea *sa,
- bToolKey *tkey)
+ ViewLayer *view_layer, ScrArea *sa, bToolKey *tkey)
{
int space_type = SPACE_EMPTY;
int mode = -1;
if (sa != NULL) {
space_type = sa->spacetype;
- mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, space_type);
+ mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, space_type);
}
if (mode != -1) {
@@ -400,11 +397,11 @@ bool WM_toolsystem_key_from_context(
return false;
}
-void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, Scene *scene, ScrArea *sa)
+void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_layer, ScrArea *sa)
{
sa->runtime.tool = NULL;
sa->runtime.is_tool_set = true;
- const int mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype);
+ const int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype);
for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
if (tref->space_type == sa->spacetype) {
if (tref->mode == mode) {
@@ -426,12 +423,12 @@ void WM_toolsystem_refresh_screen_all(Main *bmain)
space_type_has_tools[tref->space_type] = true;
}
bScreen *screen = WM_window_get_active_screen(win);
- Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
sa->runtime.tool = NULL;
sa->runtime.is_tool_set = true;
if (space_type_has_tools[sa->spacetype]) {
- WM_toolsystem_refresh_screen_area(workspace, scene, sa);
+ WM_toolsystem_refresh_screen_area(workspace, view_layer, sa);
}
}
}
@@ -446,10 +443,10 @@ static void toolsystem_refresh_screen_from_active_tool(
for (wmWindow *win = wm->windows.first; win; win = win->next) {
if (workspace == WM_window_get_active_workspace(win)) {
bScreen *screen = WM_window_get_active_screen(win);
- Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == tref->space_type) {
- int mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype);
+ int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype);
if (mode == tref->mode) {
sa->runtime.tool = tref;
sa->runtime.is_tool_set = true;
@@ -477,9 +474,9 @@ bToolRef *WM_toolsystem_ref_set_by_name(
/* Will get from context if not set. */
bToolKey tkey_from_context;
if (tkey == NULL) {
- Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
ScrArea *sa = CTX_wm_area(C);
- WM_toolsystem_key_from_context(workspace, scene, sa, &tkey_from_context);
+ WM_toolsystem_key_from_context(view_layer, sa, &tkey_from_context);
tkey = &tkey_from_context;
}
@@ -526,11 +523,11 @@ static void toolsystem_reinit_ensure_toolref(
void WM_toolsystem_update_from_context_view3d(bContext *C)
{
WorkSpace *workspace = CTX_wm_workspace(C);
- Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
int space_type = SPACE_VIEW3D;
const bToolKey tkey = {
.space_type = space_type,
- .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, NULL, space_type),
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, NULL, space_type),
};
toolsystem_reinit_ensure_toolref(C, workspace, &tkey, "Cursor");
}
@@ -549,12 +546,12 @@ void WM_toolsystem_do_msg_notify_tag_refresh(
bContext *C, wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val)
{
WorkSpace *workspace = CTX_wm_workspace(C);
- Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
ScrArea *sa = msg_val->user_data;
int space_type = sa->spacetype;
const bToolKey tkey = {
.space_type = space_type,
- .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype),
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
};
WM_toolsystem_refresh(C, workspace, &tkey);
}
diff --git a/source/blender/windowmanager/intern/wm_uilist_type.c b/source/blender/windowmanager/intern/wm_uilist_type.c
new file mode 100644
index 00000000000..52619a09218
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_uilist_type.c
@@ -0,0 +1,98 @@
+/*
+ * ***** 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/windowmanager/intern/wm_uilist_type.c
+ * \ingroup wm
+ *
+ * UI List Registry.
+ */
+
+#include "BLI_sys_types.h"
+
+#include "DNA_windowmanager_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+
+#include "BKE_context.h"
+#include "BKE_library.h"
+#include "BKE_screen.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+static GHash *uilisttypes_hash = NULL;
+
+uiListType *WM_uilisttype_find(const char *idname, bool quiet)
+{
+ uiListType *ult;
+
+ if (idname[0]) {
+ ult = BLI_ghash_lookup(uilisttypes_hash, idname);
+ if (ult) {
+ return ult;
+ }
+ }
+
+ if (!quiet) {
+ printf("search for unknown uilisttype %s\n", idname);
+ }
+
+ return NULL;
+}
+
+bool WM_uilisttype_add(uiListType *ult)
+{
+ BLI_ghash_insert(uilisttypes_hash, ult->idname, ult);
+ return 1;
+}
+
+void WM_uilisttype_freelink(uiListType *ult)
+{
+ bool ok;
+
+ ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN);
+
+ BLI_assert(ok);
+ (void)ok;
+}
+
+/* called on initialize WM_init() */
+void WM_uilisttype_init(void)
+{
+ uilisttypes_hash = BLI_ghash_str_new_ex("uilisttypes_hash gh", 16);
+}
+
+void WM_uilisttype_free(void)
+{
+ GHashIterator gh_iter;
+
+ GHASH_ITER (gh_iter, uilisttypes_hash) {
+ uiListType *ult = BLI_ghashIterator_getValue(&gh_iter);
+ if (ult->ext.free) {
+ ult->ext.free(ult->ext.data);
+ }
+ }
+
+ BLI_ghash_free(uilisttypes_hash, NULL, MEM_freeN);
+ uilisttypes_hash = NULL;
+}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 43231855162..c1006db34ef 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -53,6 +53,7 @@
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_icons.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_global.h"
#include "BKE_main.h"
@@ -81,6 +82,7 @@
#include "PIL_time.h"
#include "GPU_batch.h"
+#include "GPU_batch_presets.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_framebuffer.h"
@@ -88,12 +90,11 @@
#include "GPU_immediate.h"
#include "GPU_material.h"
#include "GPU_texture.h"
+#include "GPU_context.h"
#include "BLF_api.h"
#include "UI_resources.h"
-#include "../../../intern/gawain/gawain/gwn_context.h"
-
/* for assert */
#ifndef NDEBUG
# include "BLI_threads.h"
@@ -121,6 +122,9 @@ static struct WMInitStruct {
/* ******** win open & close ************ */
+static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate);
+static void wm_window_clear_drawable(wmWindowManager *wm);
+
/* XXX this one should correctly check for apple top header...
* done for Cocoa : returns window contents (and not frame) max size*/
void wm_get_screensize(int *r_width, int *r_height)
@@ -175,24 +179,30 @@ static void wm_window_check_position(rcti *rect)
if (rect->ymin < 0) rect->ymin = 0;
}
-
static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
{
if (win->ghostwin) {
+ /* Prevents non-drawable state of main windows (bugs #22967,
+ * #25071 and possibly #22477 too). Always clear it even if
+ * this window was not the drawable one, because we mess with
+ * drawing context to discard the GW context. */
+ wm_window_clear_drawable(wm);
+
+ if (win == wm->winactive) {
+ wm->winactive = NULL;
+ }
+
/* We need this window's opengl context active to discard it. */
GHOST_ActivateWindowDrawingContext(win->ghostwin);
- GWN_context_active_set(win->gwnctx);
+ GPU_context_active_set(win->gpuctx);
- /* Delete local gawain objects. */
- GWN_context_discard(win->gwnctx);
+ /* Delete local gpu context. */
+ GPU_context_discard(win->gpuctx);
GHOST_DisposeWindow(g_system, win->ghostwin);
win->ghostwin = NULL;
- win->gwnctx = NULL;
+ win->gpuctx = NULL;
- /* prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */
- wm->windrawable = NULL;
- wm->winactive = NULL;
}
}
@@ -256,7 +266,7 @@ static int find_free_winid(wmWindowManager *wm)
}
/* don't change context itself */
-wmWindow *wm_window_new(bContext *C)
+wmWindow *wm_window_new(bContext *C, wmWindow *parent)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
@@ -265,6 +275,7 @@ wmWindow *wm_window_new(bContext *C)
BLI_addtail(&wm->windows, win);
win->winid = find_free_winid(wm);
+ win->parent = (parent && parent->parent) ? parent->parent : parent;
win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo 3D Format (window)");
win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
@@ -272,13 +283,13 @@ wmWindow *wm_window_new(bContext *C)
}
/* part of wm_window.c api */
-wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_layout)
+wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child)
{
Main *bmain = CTX_data_main(C);
- wmWindow *win_dst = wm_window_new(C);
+ wmWindow *win_parent = (child) ? win_src : win_src->parent;
+ wmWindow *win_dst = wm_window_new(C, win_parent);
WorkSpace *workspace = WM_window_get_active_workspace(win_src);
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src);
- Scene *scene = WM_window_get_active_scene(win_src);
WorkSpaceLayout *layout_new;
win_dst->posx = win_src->posx + 10;
@@ -286,10 +297,11 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la
win_dst->sizex = win_src->sizex;
win_dst->sizey = win_src->sizey;
- win_dst->scene = scene;
- WM_window_set_active_workspace(win_dst, workspace);
+ win_dst->scene = win_src->scene;
+ STRNCPY(win_dst->view_layer_name, win_src->view_layer_name);
+ BKE_workspace_active_set(win_dst->workspace_hook, workspace);
layout_new = duplicate_layout ? ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) : layout_old;
- WM_window_set_active_layout(win_dst, workspace, layout_new);
+ BKE_workspace_hook_layout_for_workspace_set(win_dst->workspace_hook, workspace, layout_new);
*win_dst->stereo3d_format = *win_src->stereo3d_format;
@@ -300,12 +312,12 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la
* A higher level version of copy that tests the new window can be added.
* (called from the operator directly)
*/
-wmWindow *wm_window_copy_test(bContext *C, wmWindow *win_src, const bool duplicate_layout)
+wmWindow *wm_window_copy_test(bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win_dst;
- win_dst = wm_window_copy(C, win_src, duplicate_layout);
+ win_dst = wm_window_copy(C, win_src, duplicate_layout, child);
WM_check(C);
@@ -471,58 +483,53 @@ void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win)
/* this is event from ghost, or exit-blender op */
void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
{
- wmWindow *tmpwin;
-
- /* first check if we have to quit (there are non-temp remaining windows) */
- for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) {
- if (tmpwin == win)
- continue;
- if (WM_window_is_temp_screen(tmpwin) == false)
+ /* First check if there is another main window remaining. */
+ wmWindow *win_other;
+ for (win_other = wm->windows.first; win_other; win_other = win_other->next) {
+ if (win_other != win &&
+ win_other->parent == NULL &&
+ !WM_window_is_temp_screen(win_other))
+ {
break;
+ }
}
- if (tmpwin == NULL) {
+ if (win->parent == NULL && win_other == NULL) {
wm_quit_with_optional_confirmation_prompt(C, win);
+ return;
}
- else {
- bScreen *screen = WM_window_get_active_screen(win);
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- WorkSpaceLayout *layout = BKE_workspace_active_layout_get(win->workspace_hook);
- BLI_remlink(&wm->windows, win);
+ /* close child windows */
+ for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
+ if (win_child->parent == win) {
+ wm_window_close(C, wm, win_child);
+ }
+ }
- CTX_wm_window_set(C, win); /* needed by handlers */
- WM_event_remove_handlers(C, &win->handlers);
- WM_event_remove_handlers(C, &win->modalhandlers);
+ bScreen *screen = WM_window_get_active_screen(win);
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
+ WorkSpaceLayout *layout = BKE_workspace_active_layout_get(win->workspace_hook);
- /* for regular use this will _never_ be NULL,
- * however we may be freeing an improperly initialized window. */
- if (screen) {
- ED_screen_exit(C, win, screen);
- }
+ BLI_remlink(&wm->windows, win);
- if (tmpwin) {
- BLF_batch_reset();
- gpu_batch_presets_reset();
- immDeactivate();
- }
+ CTX_wm_window_set(C, win); /* needed by handlers */
+ WM_event_remove_handlers(C, &win->handlers);
+ WM_event_remove_handlers(C, &win->modalhandlers);
- wm_window_free(C, wm, win);
+ /* for regular use this will _never_ be NULL,
+ * however we may be freeing an improperly initialized window. */
+ if (screen) {
+ ED_screen_exit(C, win, screen);
+ }
- /* keep imediatemode active before the next `wm_window_make_drawable` call */
- if (tmpwin) {
- GHOST_ActivateWindowDrawingContext(tmpwin->ghostwin);
- GWN_context_active_set(tmpwin->gwnctx);
- immActivate();
- }
+ wm_window_free(C, wm, win);
- /* if temp screen, delete it after window free (it stops jobs that can access it) */
- if (screen && screen->temp) {
- Main *bmain = CTX_data_main(C);
+ /* if temp screen, delete it after window free (it stops jobs that can access it) */
+ if (screen && screen->temp) {
+ Main *bmain = CTX_data_main(C);
- BLI_assert(BKE_workspace_layout_screen_get(layout) == screen);
- BKE_workspace_layout_remove(bmain, workspace, layout);
- }
+ BLI_assert(BKE_workspace_layout_screen_get(layout) == screen);
+ BKE_workspace_layout_remove(bmain, workspace, layout);
}
}
@@ -635,19 +642,19 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
if (ghostwin) {
GHOST_RectangleHandle bounds;
- /* XXX Fix crash when a new window is created.
- * However this should be move somewhere else. (fclem) */
- BLF_batch_reset();
- gpu_batch_presets_reset();
-
- win->gwnctx = GWN_context_create();
+ /* Clear drawable so we can set the new window. */
+ wm_window_clear_drawable(wm);
- /* the new window has already been made drawable upon creation */
- wm->windrawable = win;
+ win->gpuctx = GPU_context_create();
/* needed so we can detect the graphics card below */
GPU_init();
+ /* Set window as drawable upon creation. Note this has already been
+ * it has already been activated by GHOST_CreateWindow. */
+ bool activate = false;
+ wm_window_set_drawable(wm, win, activate);
+
win->ghostwin = ghostwin;
GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
@@ -809,7 +816,7 @@ void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm)
wmWindow *WM_window_open(bContext *C, const rcti *rect)
{
wmWindow *win_prev = CTX_wm_window(C);
- wmWindow *win = wm_window_new(C);
+ wmWindow *win = wm_window_new(C, win_prev);
win->posx = rect->xmin;
win->posy = rect->ymin;
@@ -843,6 +850,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
bScreen *screen;
ScrArea *sa;
Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
const char *title;
/* convert to native OS window coordinates */
@@ -869,7 +877,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
/* add new window? */
if (win == NULL) {
- win = wm_window_new(C);
+ win = wm_window_new(C, win_prev);
win->posx = rect.xmin;
win->posy = rect.ymin;
@@ -887,7 +895,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
if (WM_window_get_active_workspace(win) == NULL) {
WorkSpace *workspace = WM_window_get_active_workspace(win_prev);
- WM_window_set_active_workspace(win, workspace);
+ BKE_workspace_active_set(win->workspace_hook, workspace);
}
if (screen == NULL) {
@@ -899,12 +907,10 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
WM_window_set_active_layout(win, workspace, layout);
}
- if (win->scene == NULL) {
- win->scene = scene;
- }
- /* In case we reuse an already existing temp window (see win lookup above). */
- else if (WM_window_get_active_scene(win) != scene) {
- WM_window_change_active_scene(bmain, C, win, scene);
+ /* Set scene and view layer to match original window. */
+ STRNCPY(win->view_layer_name, view_layer->name);
+ if (WM_window_get_active_scene(win) != scene) {
+ ED_screen_scene_change(C, win, scene);
}
screen->temp = 1;
@@ -976,17 +982,25 @@ int wm_window_close_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-/* operator callback */
int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win_src = CTX_wm_window(C);
bool ok;
- ok = (wm_window_copy_test(C, win_src, true) != NULL);
+ ok = (wm_window_copy_test(C, win_src, true, true) != NULL);
return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
+int wm_window_new_main_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ wmWindow *win_src = CTX_wm_window(C);
+ bool ok;
+
+ ok = (wm_window_copy_test(C, win_src, true, false) != NULL);
+
+ return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+}
/* fullscreen operator callback */
int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1077,24 +1091,41 @@ static int query_qual(modifierKeyType qual)
return val;
}
+static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate)
+{
+ BLI_assert(ELEM(wm->windrawable, NULL, win));
+
+ wm->windrawable = win;
+ if (activate) {
+ GHOST_ActivateWindowDrawingContext(win->ghostwin);
+ }
+ GPU_context_active_set(win->gpuctx);
+ immActivate();
+}
+
+static void wm_window_clear_drawable(wmWindowManager *wm)
+{
+ if (wm->windrawable) {
+ BLF_batch_reset();
+ gpu_batch_presets_reset();
+ immDeactivate();
+ wm->windrawable = NULL;
+ }
+}
+
void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
{
BLI_assert(GPU_framebuffer_current_get() == 0);
if (win != wm->windrawable && win->ghostwin) {
// win->lmbut = 0; /* keeps hanging when mousepressed while other window opened */
+ wm_window_clear_drawable(wm);
- wm->windrawable = win;
if (G.debug & G_DEBUG_EVENTS) {
printf("%s: set drawable %d\n", __func__, win->winid);
}
- BLF_batch_reset();
- gpu_batch_presets_reset();
- immDeactivate();
- GHOST_ActivateWindowDrawingContext(win->ghostwin);
- GWN_context_active_set(win->gwnctx);
- immActivate();
+ wm_window_set_drawable(wm, win, true);
/* this can change per window */
WM_window_set_dpi(win);
@@ -1114,12 +1145,8 @@ void wm_window_reset_drawable(void)
wmWindow *win = wm->windrawable;
if (win && win->ghostwin) {
- BLF_batch_reset();
- gpu_batch_presets_reset();
- immDeactivate();
- GHOST_ActivateWindowDrawingContext(win->ghostwin);
- GWN_context_active_set(win->gwnctx);
- immActivate();
+ wm_window_clear_drawable(wm);
+ wm_window_set_drawable(wm, win, true);
}
}
@@ -1894,8 +1921,6 @@ void wm_window_raise(wmWindow *win)
void wm_window_swap_buffers(wmWindow *win)
{
- GPU_texture_orphans_delete(); /* XXX should be done elsewhere. */
- GPU_material_orphans_delete(); /* XXX Amen to that. */
GHOST_SwapWindowBuffers(win->ghostwin);
}
@@ -2103,21 +2128,95 @@ Scene *WM_window_get_active_scene(const wmWindow *win)
/**
* \warning Only call outside of area/region loops
*/
-void WM_window_change_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene_new)
+void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene)
{
- const bScreen *screen = WM_window_get_active_screen(win);
- Scene *scene_old = win->scene;
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win_parent = (win->parent) ? win->parent : win;
+ bool changed = false;
+
+ /* Set scene in parent and its child windows. */
+ if (win_parent->scene != scene) {
+ ED_screen_scene_change(C, win_parent, scene);
+ changed = true;
+ }
+
+ for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
+ if (win_child->parent == win_parent && win_child->scene != scene) {
+ ED_screen_scene_change(C, win_child, scene);
+ changed = true;
+ }
+ }
- ED_scene_change_update(bmain, C, win, screen, scene_old, scene_new);
+ if (changed) {
+ /* Update depsgraph and renderers for scene change. */
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win_parent);
+ ED_scene_change_update(bmain, scene, view_layer);
+
+ /* Complete redraw. */
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+ }
+}
+
+ViewLayer *WM_window_get_active_view_layer(const wmWindow *win)
+{
+ Scene *scene = WM_window_get_active_scene(win);
+ if (scene == NULL) {
+ return NULL;
+ }
+
+ ViewLayer *view_layer = BKE_view_layer_find(scene, win->view_layer_name);
+ if (view_layer) {
+ return view_layer;
+ }
+
+ return BKE_view_layer_default_view(scene);
+}
+
+void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
+{
+ BLI_assert(BKE_view_layer_find(WM_window_get_active_scene(win), view_layer->name) != NULL);
+
+ wmWindowManager *wm = G_MAIN->wm.first;
+ wmWindow *win_parent = (win->parent) ? win->parent : win;
+
+ /* Set view layer in parent and child windows. */
+ STRNCPY(win->view_layer_name, view_layer->name);
+
+ for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
+ if (win_child->parent == win_parent) {
+ STRNCPY(win_child->view_layer_name, view_layer->name);
+ }
+ }
+}
+
+void WM_window_ensure_active_view_layer(wmWindow *win)
+{
+ /* Update layer name is correct after scene changes, load without UI, etc. */
+ Scene *scene = WM_window_get_active_scene(win);
+
+ if (scene && BKE_view_layer_find(scene, win->view_layer_name) == NULL) {
+ ViewLayer *view_layer = BKE_view_layer_default_view(scene);
+ STRNCPY(win->view_layer_name, view_layer->name);
+ }
}
WorkSpace *WM_window_get_active_workspace(const wmWindow *win)
{
return BKE_workspace_active_get(win->workspace_hook);
}
-void WM_window_set_active_workspace(wmWindow *win, WorkSpace *workspace)
+
+void WM_window_set_active_workspace(bContext *C, wmWindow *win, WorkSpace *workspace)
{
- BKE_workspace_active_set(win->workspace_hook, workspace);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win_parent = (win->parent) ? win->parent : win;
+
+ ED_workspace_change(workspace, C, wm, win);
+
+ for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
+ if (win_child->parent == win_parent) {
+ ED_workspace_change(workspace, C, wm, win_child);
+ }
+ }
}
WorkSpaceLayout *WM_window_get_active_layout(const wmWindow *win)
@@ -2144,26 +2243,6 @@ void WM_window_set_active_screen(wmWindow *win, WorkSpace *workspace, bScreen *s
BKE_workspace_active_screen_set(win->workspace_hook, workspace, screen);
}
-struct ViewLayer *WM_window_get_active_view_layer_ex(const wmWindow *win, Scene **r_scene)
-{
- const WorkSpace *workspace = WM_window_get_active_workspace(win);
- Scene *scene = WM_window_get_active_scene(win);
- /* May be NULL in rare cases like closing Blender */
- bScreen *screen = (LIKELY(workspace != NULL) ? BKE_workspace_active_screen_get(win->workspace_hook) : NULL);
- if (screen != NULL) {
- if (r_scene) {
- *r_scene = scene;
- }
- return BKE_workspace_view_layer_get(workspace, scene);
- }
- return NULL;
-}
-
-struct ViewLayer *WM_window_get_active_view_layer(const wmWindow *win)
-{
- return WM_window_get_active_view_layer_ex(win, NULL);
-}
-
bool WM_window_is_temp_screen(const wmWindow *win)
{
const bScreen *screen = WM_window_get_active_screen(win);
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
deleted file mode 100644
index b88956ac28d..00000000000
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ /dev/null
@@ -1,343 +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) 2016 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/manipulators/WM_manipulator_api.h
- * \ingroup wm
- *
- * \name Manipulator API
- * \brief API for external use of wmManipulator types.
- *
- * Only included in WM_api.h
- */
-
-
-#ifndef __WM_MANIPULATOR_API_H__
-#define __WM_MANIPULATOR_API_H__
-
-struct ARegion;
-struct GHashIterator;
-struct IDProperty;
-struct Main;
-struct PropertyRNA;
-struct wmKeyConfig;
-struct wmManipulator;
-struct wmManipulatorProperty;
-struct wmManipulatorPropertyType;
-struct wmManipulatorType;
-struct wmManipulatorGroup;
-struct wmManipulatorGroupType;
-struct wmManipulatorMap;
-struct wmManipulatorMapType;
-struct wmManipulatorMapType_Params;
-struct wmMsgSubscribeKey;
-struct wmMsgSubscribeValue;
-
-#include "wm_manipulator_fn.h"
-
-/* -------------------------------------------------------------------- */
-/* wmManipulator */
-
-struct wmManipulator *WM_manipulator_new_ptr(
- const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup,
- struct PointerRNA *properties);
-struct wmManipulator *WM_manipulator_new(
- const char *idname, struct wmManipulatorGroup *mgroup,
- struct PointerRNA *properties);
-void WM_manipulator_free(struct wmManipulator *mpr);
-void WM_manipulator_unlink(
- ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr,
- struct bContext *C);
-
-void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name);
-
-bool WM_manipulator_select_unlink(struct wmManipulatorMap *mmap, struct wmManipulator *mpr);
-bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select);
-void WM_manipulator_highlight_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr);
-
-void WM_manipulator_modal_set_from_setup(
- struct wmManipulatorMap *mmap, struct bContext *C,
- struct wmManipulator *mpr, int part_index, const struct wmEvent *event);
-
-struct wmManipulatorOpElem *WM_manipulator_operator_get(
- struct wmManipulator *mpr, int part_index);
-struct PointerRNA *WM_manipulator_operator_set(
- struct wmManipulator *mpr, int part_index,
- struct wmOperatorType *ot, struct IDProperty *properties);
-
-/* callbacks */
-void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn);
-
-void WM_manipulator_set_matrix_location(
- struct wmManipulator *mpr, const float origin[3]);
-void WM_manipulator_set_matrix_rotation_from_z_axis(
- struct wmManipulator *mpr, const float z_axis[3]);
-void WM_manipulator_set_matrix_rotation_from_yz_axis(
- struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]);
-
-void WM_manipulator_set_matrix_offset_location(
- struct wmManipulator *mpr, const float origin[3]);
-void WM_manipulator_set_matrix_offset_rotation_from_z_axis(
- struct wmManipulator *mpr, const float z_axis[3]);
-void WM_manipulator_set_matrix_offset_rotation_from_yz_axis(
- struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]);
-
-void WM_manipulator_set_flag(struct wmManipulator *mpr, const int flag, const bool enable);
-void WM_manipulator_set_scale(struct wmManipulator *mpr, float scale);
-void WM_manipulator_set_line_width(struct wmManipulator *mpr, const float line_width);
-
-void WM_manipulator_get_color(const struct wmManipulator *mpr, float color[4]);
-void WM_manipulator_set_color(struct wmManipulator *mpr, const float color[4]);
-void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float color_hi[4]);
-void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float color[4]);
-
-/**
- * Leaving values NULL use values from #wmManipulator.
- */
-struct WM_ManipulatorMatrixParams {
- const float(*matrix_space)[4];
- const float(*matrix_basis)[4];
- const float(*matrix_offset)[4];
- const float *scale_final;
-};
-
-void WM_manipulator_calc_matrix_final_params(
- const struct wmManipulator *mpr, const struct WM_ManipulatorMatrixParams *params,
- float r_mat[4][4]);
-void WM_manipulator_calc_matrix_final_no_offset(
- const struct wmManipulator *mpr, float r_mat[4][4]);
-
-void WM_manipulator_calc_matrix_final(
- const struct wmManipulator *mpr, float r_mat[4][4]);
-
-/* properties */
-void WM_manipulator_properties_create_ptr(struct PointerRNA *ptr, struct wmManipulatorType *wt);
-void WM_manipulator_properties_create(struct PointerRNA *ptr, const char *opstring);
-void WM_manipulator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring);
-void WM_manipulator_properties_sanitize(struct PointerRNA *ptr, const bool no_context);
-bool WM_manipulator_properties_default(struct PointerRNA *ptr, const bool do_update);
-void WM_manipulator_properties_reset(struct wmManipulator *op);
-void WM_manipulator_properties_clear(struct PointerRNA *ptr);
-void WM_manipulator_properties_free(struct PointerRNA *ptr);
-
-
-/* wm_manipulator_type.c */
-const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet);
-void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *));
-void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata);
-bool WM_manipulatortype_remove(struct bContext *C, struct Main *bmain, const char *idname);
-void WM_manipulatortype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmManipulatorType *wt);
-void WM_manipulatortype_iter(struct GHashIterator *ghi);
-
-/* wm_manipulator_group_type.c */
-struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet);
-struct wmManipulatorGroupType *WM_manipulatorgrouptype_append(void (*wtfunc)(struct wmManipulatorGroupType *));
-struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata);
-bool WM_manipulatorgrouptype_free(const char *idname);
-void WM_manipulatorgrouptype_free_ptr(struct wmManipulatorGroupType *wt);
-void WM_manipulatorgrouptype_iter(struct GHashIterator *ghi);
-
-struct wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link(
- struct wmManipulatorMapType *mmap_type,
- void (*wtfunc)(struct wmManipulatorGroupType *));
-
-/* wm_manipulator_map.c */
-
-/* Dynamic Updates (for RNA runtime registration) */
-void WM_manipulatorconfig_update_tag_init(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt);
-void WM_manipulatorconfig_update_tag_remove(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt);
-void WM_manipulatorconfig_update(struct Main *bmain);
-
-
-/* wm_maniulator_target_props.c */
-struct wmManipulatorProperty *WM_manipulator_target_property_array(struct wmManipulator *mpr);
-struct wmManipulatorProperty *WM_manipulator_target_property_at_index(
- struct wmManipulator *mpr, int index);
-struct wmManipulatorProperty *WM_manipulator_target_property_find(
- struct wmManipulator *mpr, const char *idname);
-
-void WM_manipulator_target_property_def_rna_ptr(
- struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type,
- struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
-void WM_manipulator_target_property_def_rna(
- struct wmManipulator *mpr, const char *idname,
- struct PointerRNA *ptr, const char *propname, int index);
-
-void WM_manipulator_target_property_def_func_ptr(
- struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type,
- const struct wmManipulatorPropertyFnParams *params);
-void WM_manipulator_target_property_def_func(
- struct wmManipulator *mpr, const char *idname,
- const struct wmManipulatorPropertyFnParams *params);
-
-void WM_manipulator_target_property_clear_rna_ptr(
- struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type);
-void WM_manipulator_target_property_clear_rna(
- struct wmManipulator *mpr, const char *idname);
-
-bool WM_manipulator_target_property_is_valid_any(struct wmManipulator *mpr);
-bool WM_manipulator_target_property_is_valid(
- const struct wmManipulatorProperty *mpr_prop);
-float WM_manipulator_target_property_value_get(
- const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop);
-void WM_manipulator_target_property_value_set(
- struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
- const float value);
-
-void WM_manipulator_target_property_value_get_array(
- const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
- float *value);
-void WM_manipulator_target_property_value_set_array(
- struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
- const float *value);
-
-bool WM_manipulator_target_property_range_get(
- const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
- float range[2]);
-
-int WM_manipulator_target_property_array_length(
- const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop);
-
-/* definitions */
-const struct wmManipulatorPropertyType *WM_manipulatortype_target_property_find(
- const struct wmManipulatorType *wt, const char *idname);
-void WM_manipulatortype_target_property_def(
- struct wmManipulatorType *wt, const char *idname, int data_type, int array_length);
-
-/* utilities */
-void WM_manipulator_do_msg_notify_tag_refresh(
- struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val);
-void WM_manipulator_target_property_subscribe_all(
- struct wmManipulator *mpr, struct wmMsgBus *mbus, struct ARegion *ar);
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorGroup */
-
-/* Callbacks for 'wmManipulatorGroupType.setup_keymap' */
-struct wmKeyMap *WM_manipulatorgroup_keymap_common(
- const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config);
-struct wmKeyMap *WM_manipulatorgroup_keymap_common_select(
- const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config);
-
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorMap */
-
-struct wmManipulatorMap *WM_manipulatormap_new_from_type(
- const struct wmManipulatorMapType_Params *mmap_params);
-const struct ListBase *WM_manipulatormap_group_list(struct wmManipulatorMap *mmap);
-struct wmManipulatorGroup *WM_manipulatormap_group_find(
- struct wmManipulatorMap *mmap,
- const char *idname);
-struct wmManipulatorGroup *WM_manipulatormap_group_find_ptr(
- struct wmManipulatorMap *mmap,
- const struct wmManipulatorGroupType *wgt);
-void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap);
-void WM_manipulatormap_draw(
- struct wmManipulatorMap *mmap, const struct bContext *C, const eWM_ManipulatorMapDrawStep drawstep);
-void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap *mmap);
-bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action);
-bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win);
-void WM_manipulatormap_message_subscribe(
- struct bContext *C, struct wmManipulatorMap *mmap, struct ARegion *ar, struct wmMsgBus *mbus);
-bool WM_manipulatormap_is_any_selected(const struct wmManipulatorMap *mmap);
-bool WM_manipulatormap_minmax(
- const struct wmManipulatorMap *mmap, bool use_hidden, bool use_select,
- float r_min[3], float r_max[3]);
-
-struct ARegion *WM_manipulatormap_tooltip_init(
- struct bContext *C, struct ARegion *ar, bool *r_exit_on_event);
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorMapType */
-
-struct wmManipulatorMapType *WM_manipulatormaptype_find(
- const struct wmManipulatorMapType_Params *mmap_params);
-struct wmManipulatorMapType *WM_manipulatormaptype_ensure(
- const struct wmManipulatorMapType_Params *mmap_params);
-
-struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find(
- struct wmManipulatorMapType *mmap_type,
- const char *idname);
-struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr(
- struct wmManipulatorMapType *mmap_type,
- const struct wmManipulatorGroupType *wgt);
-struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link(
- struct wmManipulatorMapType *mmap_type,
- const char *idname);
-struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr(
- struct wmManipulatorMapType *mmap_type,
- struct wmManipulatorGroupType *wgt);
-
-void WM_manipulatormaptype_group_init_runtime_keymap(
- const struct Main *bmain,
- struct wmManipulatorGroupType *wgt);
-void WM_manipulatormaptype_group_init_runtime(
- const struct Main *bmain, struct wmManipulatorMapType *mmap_type,
- struct wmManipulatorGroupType *wgt);
-void WM_manipulatormaptype_group_unlink(
- struct bContext *C, struct Main *bmain, struct wmManipulatorMapType *mmap_type,
- const struct wmManipulatorGroupType *wgt);
-
-void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt);
-
-/* -------------------------------------------------------------------- */
-/* ManipulatorGroup */
-
-/* Add/Ensure/Remove (High level API) */
-
-void WM_manipulator_group_type_add_ptr_ex(
- struct wmManipulatorGroupType *wgt,
- struct wmManipulatorMapType *mmap_type);
-void WM_manipulator_group_type_add_ptr(
- struct wmManipulatorGroupType *wgt);
-void WM_manipulator_group_type_add(const char *idname);
-
-void WM_manipulator_group_type_ensure_ptr_ex(
- struct wmManipulatorGroupType *wgt,
- struct wmManipulatorMapType *mmap_type);
-void WM_manipulator_group_type_ensure_ptr(
- struct wmManipulatorGroupType *wgt);
-void WM_manipulator_group_type_ensure(const char *idname);
-
-void WM_manipulator_group_type_remove_ptr_ex(
- struct Main *bmain, struct wmManipulatorGroupType *wgt,
- struct wmManipulatorMapType *mmap_type);
-void WM_manipulator_group_type_remove_ptr(
- struct Main *bmain, struct wmManipulatorGroupType *wgt);
-void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname);
-
-void WM_manipulator_group_type_unlink_delayed_ptr_ex(
- struct wmManipulatorGroupType *wgt,
- struct wmManipulatorMapType *mmap_type);
-void WM_manipulator_group_type_unlink_delayed_ptr(
- struct wmManipulatorGroupType *wgt);
-void WM_manipulator_group_type_unlink_delayed(const char *idname);
-
-/* Utilities */
-bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step);
-
-bool WM_manipulator_group_type_poll(const struct bContext *C, const struct wmManipulatorGroupType *wgt);
-
-#endif /* __WM_MANIPULATOR_API_H__ */
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
deleted file mode 100644
index e4482e797e3..00000000000
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ /dev/null
@@ -1,420 +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) 2016 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/manipulators/WM_manipulator_types.h
- * \ingroup wm
- *
- * \name Manipulator Types
- * \brief Manipulator defines for external use.
- *
- * Only included in WM_types.h and lower level files.
- */
-
-
-#ifndef __WM_MANIPULATOR_TYPES_H__
-#define __WM_MANIPULATOR_TYPES_H__
-
-#include "BLI_compiler_attrs.h"
-
-struct wmManipulatorMapType;
-struct wmManipulatorGroupType;
-struct wmManipulatorGroup;
-struct wmManipulator;
-struct wmManipulatorProperty;
-struct wmKeyConfig;
-
-#include "DNA_listBase.h"
-
-
-/* -------------------------------------------------------------------- */
-/* Enum Typedef's */
-
-
-/**
- * #wmManipulator.state
- */
-typedef enum eWM_ManipulatorState {
- WM_MANIPULATOR_STATE_HIGHLIGHT = (1 << 0), /* while hovered */
- WM_MANIPULATOR_STATE_MODAL = (1 << 1), /* while dragging */
- WM_MANIPULATOR_STATE_SELECT = (1 << 2),
-} eWM_ManipulatorState;
-
-
-/**
- * #wmManipulator.flag
- * Flags for individual manipulators.
- */
-typedef enum eWM_ManipulatorFlag {
- WM_MANIPULATOR_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */
- WM_MANIPULATOR_DRAW_MODAL = (1 << 1), /* draw while dragging */
- WM_MANIPULATOR_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */
- WM_MANIPULATOR_HIDDEN = (1 << 3),
- /**
- * When set 'scale_final' value also scales the offset.
- * Use when offset is to avoid screen-space overlap instead of absolute positioning. */
- WM_MANIPULATOR_DRAW_OFFSET_SCALE = (1 << 4),
- /**
- * User should still use 'scale_final' for any handles and UI elements.
- * This simply skips scale when calculating the final matrix.
- * Needed when the manipulator needs to align with the interface underneath it. */
- WM_MANIPULATOR_DRAW_NO_SCALE = (1 << 5),
- /**
- * Hide the cursor and lock it's position while interacting with this manipulator.
- */
- WM_MANIPULATOR_GRAB_CURSOR = (1 << 6),
-} eWM_ManipulatorFlag;
-
-/**
- * #wmManipulatorGroupType.flag
- * Flags that influence the behavior of all manipulators in the group.
- */
-typedef enum eWM_ManipulatorGroupTypeFlag {
- /* Mark manipulator-group as being 3D */
- WM_MANIPULATORGROUPTYPE_3D = (1 << 0),
- /* Scale manipulators as 3D object that respects zoom (otherwise zoom independent draw size).
- * note: currently only for 3D views, 2D support needs adding. */
- WM_MANIPULATORGROUPTYPE_SCALE = (1 << 1),
- /* Manipulators can be depth culled with scene objects (covered by other geometry - TODO) */
- WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2),
- /* Manipulators can be selected */
- WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3),
- /* The manipulator group is to be kept (not removed on loading a new file for eg). */
- WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4),
- /* Show all other manipulators when interacting. */
- WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL = (1 << 5),
-} eWM_ManipulatorGroupTypeFlag;
-
-
-/**
- * #wmManipulatorGroup.init_flag
- */
-typedef enum eWM_ManipulatorGroupInitFlag {
- /* mgroup has been initialized */
- WM_MANIPULATORGROUP_INIT_SETUP = (1 << 0),
- WM_MANIPULATORGROUP_INIT_REFRESH = (1 << 1),
-} eWM_ManipulatorGroupInitFlag;
-
-/**
- * #wmManipulatorMapType.type_update_flag
- * Manipulator-map type update flag
- */
-typedef enum eWM_ManipulatorMapTypeUpdateFlag {
- /* A new type has been added, needs to be initialized for all views. */
- WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0),
- WM_MANIPULATORMAPTYPE_UPDATE_REMOVE = (1 << 1),
-
- /* Needed because keymap may be registered before and after window initialization.
- * So we need to keep track of keymap initialization separately. */
- WM_MANIPULATORMAPTYPE_KEYMAP_INIT = (1 << 2),
-} eWM_ManipulatorMapTypeUpdateFlag;
-
-/* -------------------------------------------------------------------- */
-/* wmManipulator */
-
-/**
- * \brief Manipulator tweak flag.
- * Bitflag passed to manipulator while tweaking.
- *
- * \note Manipulators are responsible for handling this #wmManipulator.modal callback!.
- */
-typedef enum {
- /* Drag with extra precision (Shift). */
- WM_MANIPULATOR_TWEAK_PRECISE = (1 << 0),
- /* Drag with snap enabled (Ctrl). */
- WM_MANIPULATOR_TWEAK_SNAP = (1 << 1),
-} eWM_ManipulatorTweak;
-
-#include "wm_manipulator_fn.h"
-
-typedef struct wmManipulatorOpElem {
- struct wmOperatorType *type;
- /* operator properties if manipulator spawns and controls an operator,
- * or owner pointer if manipulator spawns and controls a property */
- PointerRNA ptr;
-
- bool is_redo;
-} wmManipulatorOpElem;
-
-/* manipulators are set per region by registering them on manipulator-maps */
-struct wmManipulator {
- struct wmManipulator *next, *prev;
-
- /* While we don't have a real type, use this to put type-like vars. */
- const struct wmManipulatorType *type;
-
- /* Overrides 'type->modal' when set.
- * Note that this is a workaround, remove if we can. */
- wmManipulatorFnModal custom_modal;
-
- /* pointer back to group this manipulator is in (just for quick access) */
- struct wmManipulatorGroup *parent_mgroup;
-
- void *py_instance;
-
- /* rna pointer to access properties */
- struct PointerRNA *ptr;
-
- /* flags that influence the behavior or how the manipulators are drawn */
- eWM_ManipulatorFlag flag;
- /* state flags (active, highlighted, selected) */
- eWM_ManipulatorState state;
-
- /* Optional ID for highlighting different parts of this manipulator.
- * -1 when unset, otherwise a valid index. (Used as index to 'op_data'). */
- int highlight_part;
- /* For single click button manipulators, use a different part as a fallback, -1 when unused. */
- int drag_part;
-
- /* Transformation of the manipulator in 2d or 3d space.
- * - Matrix axis are expected to be unit length (scale is applied after).
- * - Behavior when axis aren't orthogonal depends on each manipulator.
- * - Typically the +Z is the primary axis for manipulators to use.
- * - 'matrix[3]' must be used for location,
- * besides this it's up to the manipulators internal code how the
- * rotation components are used for drawing and interaction.
- */
-
- /* The space this manipulator is being modified in. */
- float matrix_space[4][4];
- /* Transformation of this manipulator. */
- float matrix_basis[4][4];
- /* custom offset from origin */
- float matrix_offset[4][4];
- /* runtime property, set the scale while drawing on the viewport */
- float scale_final;
- /* user defined scale, in addition to the original one */
- float scale_basis;
- /* user defined width for line drawing */
- float line_width;
- /* manipulator colors (uses default fallbacks if not defined) */
- float color[4], color_hi[4];
-
- /* data used during interaction */
- void *interaction_data;
-
- /* Operator to spawn when activating the manipulator (overrides property editing),
- * an array of items (aligned with #wmManipulator.highlight_part). */
- wmManipulatorOpElem *op_data;
- int op_data_len;
-
- struct IDProperty *properties;
-
- /* over alloc target_properties after 'wmManipulatorType.struct_size' */
-};
-
-/* Similar to PropertyElemRNA, but has an identifier. */
-typedef struct wmManipulatorProperty {
- const struct wmManipulatorPropertyType *type;
-
- PointerRNA ptr;
- PropertyRNA *prop;
- int index;
-
-
- /* Optional functions for converting to/from RNA */
- struct {
- wmManipulatorPropertyFnGet value_get_fn;
- wmManipulatorPropertyFnSet value_set_fn;
- wmManipulatorPropertyFnRangeGet range_get_fn;
- wmManipulatorPropertyFnFree free_fn;
- void *user_data;
- } custom_func;
-} wmManipulatorProperty;
-
-typedef struct wmManipulatorPropertyType {
- struct wmManipulatorPropertyType *next, *prev;
- /* PropertyType, typically 'PROP_FLOAT' */
- int data_type;
- int array_length;
-
- /* index within 'wmManipulatorType' */
- int index_in_type;
-
- /* over alloc */
- char idname[0];
-} wmManipulatorPropertyType;
-
-
-/**
- * Simple utility wrapper for storing a single manipulator as wmManipulatorGroup.customdata (which gets freed).
- */
-typedef struct wmManipulatorWrapper {
- struct wmManipulator *manipulator;
-} wmManipulatorWrapper;
-
-struct wmManipulatorMapType_Params {
- short spaceid;
- short regionid;
-};
-
-typedef struct wmManipulatorType {
-
- const char *idname; /* MAX_NAME */
-
- /* Set to 'sizeof(wmManipulator)' or larger for instances of this type,
- * use so we can cant to other types without the hassle of a custom-data pointer. */
- uint struct_size;
-
- /* Initialize struct (calloc'd 'struct_size' region). */
- wmManipulatorFnSetup setup;
-
- /* draw manipulator */
- wmManipulatorFnDraw draw;
-
- /* determines 3d intersection by rendering the manipulator in a selection routine. */
- wmManipulatorFnDrawSelect draw_select;
-
- /* Determine if the mouse intersects with the manipulator.
- * The calculation should be done in the callback itself, -1 for no seleciton. */
- wmManipulatorFnTestSelect test_select;
-
- /* handler used by the manipulator. Usually handles interaction tied to a manipulator type */
- wmManipulatorFnModal modal;
-
- /* manipulator-specific handler to update manipulator attributes based on the property value */
- wmManipulatorFnPropertyUpdate property_update;
-
- /* Returns the final transformation which may be different from the 'matrix',
- * depending on the manipulator.
- * Notes:
- * - Scale isn't applied (wmManipulator.scale/user_scale).
- * - Offset isn't applied (wmManipulator.matrix_offset).
- */
- wmManipulatorFnMatrixBasisGet matrix_basis_get;
-
- /* activate a manipulator state when the user clicks on it */
- wmManipulatorFnInvoke invoke;
-
- /* called when manipulator tweaking is done - used to free data and reset property when cancelling */
- wmManipulatorFnExit exit;
-
- wmManipulatorFnCursorGet cursor_get;
-
- /* called when manipulator selection state changes */
- wmManipulatorFnSelectRefresh select_refresh;
-
- /* Free data (not the manipulator it's self), use when the manipulator allocates it's own members. */
- wmManipulatorFnFree free;
-
- /* RNA for properties */
- struct StructRNA *srna;
-
- /* RNA integration */
- ExtensionRNA ext;
-
- ListBase target_property_defs;
- int target_property_defs_len;
-
-} wmManipulatorType;
-
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorGroup */
-
-/* factory class for a manipulator-group type, gets called every time a new area is spawned */
-typedef struct wmManipulatorGroupTypeRef {
- struct wmManipulatorGroupTypeRef *next, *prev;
- struct wmManipulatorGroupType *type;
-} wmManipulatorGroupTypeRef;
-
-/* factory class for a manipulator-group type, gets called every time a new area is spawned */
-typedef struct wmManipulatorGroupType {
- const char *idname; /* MAX_NAME */
- const char *name; /* manipulator-group name - displayed in UI (keymap editor) */
- char owner_id[64]; /* MAX_NAME */
-
- /* poll if manipulator-map should be visible */
- wmManipulatorGroupFnPoll poll;
- /* initially create manipulators and set permanent data - stuff you only need to do once */
- wmManipulatorGroupFnInit setup;
- /* refresh data, only called if recreate flag is set (WM_manipulatormap_tag_refresh) */
- wmManipulatorGroupFnRefresh refresh;
- /* refresh data for drawing, called before each redraw */
- wmManipulatorGroupFnDrawPrepare draw_prepare;
-
- /* Keymap init callback for this manipulator-group (optional),
- * will fall back to default tweak keymap when left NULL. */
- wmManipulatorGroupFnSetupKeymap setup_keymap;
-
- /* Optionally subscribe to wmMsgBus events,
- * these are calculated automatically from RNA properties,
- * only needed if manipulators depend indirectly on properties. */
- wmManipulatorGroupFnMsgBusSubscribe message_subscribe;
-
- /* keymap created with callback from above */
- struct wmKeyMap *keymap;
- /* Only for convenient removal. */
- struct wmKeyConfig *keyconf;
-
- /* Disable for now, maybe some day we want properties. */
-#if 0
- /* rna for properties */
- struct StructRNA *srna;
-#endif
-
- /* RNA integration */
- ExtensionRNA ext;
-
- eWM_ManipulatorGroupTypeFlag flag;
-
- /* So we know which group type to update. */
- eWM_ManipulatorMapTypeUpdateFlag type_update_flag;
-
- /* same as manipulator-maps, so registering/unregistering goes to the correct region */
- struct wmManipulatorMapType_Params mmap_params;
-
-} wmManipulatorGroupType;
-
-typedef struct wmManipulatorGroup {
- struct wmManipulatorGroup *next, *prev;
-
- struct wmManipulatorGroupType *type;
- ListBase manipulators;
-
- struct wmManipulatorMap *parent_mmap;
-
- void *py_instance; /* python stores the class instance here */
- struct ReportList *reports; /* errors and warnings storage */
-
- void *customdata;
- void (*customdata_free)(void *); /* for freeing customdata from above */
- eWM_ManipulatorGroupInitFlag init_flag;
-} wmManipulatorGroup;
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorMap */
-
-/**
- * Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw.
- */
-typedef enum eWM_ManipulatorMapDrawStep {
- /** Draw 2D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D not set). */
- WM_MANIPULATORMAP_DRAWSTEP_2D = 0,
- /** Draw 3D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D set). */
- WM_MANIPULATORMAP_DRAWSTEP_3D,
-} eWM_ManipulatorMapDrawStep;
-#define WM_MANIPULATORMAP_DRAWSTEP_MAX 2
-
-#endif /* __WM_MANIPULATOR_TYPES_H__ */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
deleted file mode 100644
index d6eb110dca0..00000000000
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ /dev/null
@@ -1,800 +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) 2014 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/manipulators/intern/wm_manipulator.c
- * \ingroup wm
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
-#include "BLI_string_utils.h"
-
-#include "BKE_context.h"
-
-#include "GPU_batch.h"
-#include "GPU_glew.h"
-#include "GPU_immediate.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_idprop.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_screen.h"
-#include "ED_view3d.h"
-
-#include "UI_interface.h"
-
-#ifdef WITH_PYTHON
-#include "BPY_extern.h"
-#endif
-
-/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */
-#include "wm.h"
-
-/* own includes */
-#include "wm_manipulator_wmapi.h"
-#include "wm_manipulator_intern.h"
-
-static void wm_manipulator_register(
- wmManipulatorGroup *mgroup, wmManipulator *mpr);
-
-/**
- * \note Follow #wm_operator_create convention.
- */
-static wmManipulator *wm_manipulator_create(
- const wmManipulatorType *wt,
- PointerRNA *properties)
-{
- BLI_assert(wt != NULL);
- BLI_assert(wt->struct_size >= sizeof(wmManipulator));
-
- wmManipulator *mpr = MEM_callocN(
- wt->struct_size + (sizeof(wmManipulatorProperty) * wt->target_property_defs_len), __func__);
- mpr->type = wt;
-
- /* initialize properties, either copy or create */
- mpr->ptr = MEM_callocN(sizeof(PointerRNA), "wmManipulatorPtrRNA");
- if (properties && properties->data) {
- mpr->properties = IDP_CopyProperty(properties->data);
- }
- else {
- IDPropertyTemplate val = {0};
- mpr->properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties");
- }
- RNA_pointer_create(G_MAIN->wm.first, wt->srna, mpr->properties, mpr->ptr);
-
- WM_manipulator_properties_sanitize(mpr->ptr, 0);
-
- unit_m4(mpr->matrix_space);
- unit_m4(mpr->matrix_basis);
- unit_m4(mpr->matrix_offset);
-
- mpr->drag_part = -1;
-
- return mpr;
-}
-
-wmManipulator *WM_manipulator_new_ptr(
- const wmManipulatorType *wt, wmManipulatorGroup *mgroup,
- PointerRNA *properties)
-{
- wmManipulator *mpr = wm_manipulator_create(wt, properties);
-
- wm_manipulator_register(mgroup, mpr);
-
- if (mpr->type->setup != NULL) {
- mpr->type->setup(mpr);
- }
-
- return mpr;
-}
-
-/**
- * \param wt: Must be valid,
- * if you need to check it exists use #WM_manipulator_new_ptr
- * because callers of this function don't NULL check the return value.
- */
-wmManipulator *WM_manipulator_new(
- const char *idname, wmManipulatorGroup *mgroup,
- PointerRNA *properties)
-{
- const wmManipulatorType *wt = WM_manipulatortype_find(idname, false);
- return WM_manipulator_new_ptr(wt, mgroup, properties);
-}
-
-/**
- * Initialize default values and allocate needed memory for members.
- */
-static void manipulator_init(wmManipulator *mpr)
-{
- const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f};
-
- mpr->scale_basis = 1.0f;
- mpr->line_width = 1.0f;
-
- /* defaults */
- copy_v4_v4(mpr->color, color_default);
- copy_v4_v4(mpr->color_hi, color_default);
-}
-
-/**
- * Register \a manipulator.
- *
- * \param name: name used to create a unique idname for \a manipulator in \a mgroup
- *
- * \note Not to be confused with type registration from RNA.
- */
-static void wm_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr)
-{
- manipulator_init(mpr);
- wm_manipulatorgroup_manipulator_register(mgroup, mpr);
-}
-
-/**
- * \warning this doesn't check #wmManipulatorMap (highlight, selection etc).
- * Typical use is when freeing the windowing data,
- * where caller can manage clearing selection, highlight... etc.
- */
-void WM_manipulator_free(wmManipulator *mpr)
-{
- if (mpr->type->free != NULL) {
- mpr->type->free(mpr);
- }
-
-#ifdef WITH_PYTHON
- if (mpr->py_instance) {
- /* do this first in case there are any __del__ functions or
- * similar that use properties */
- BPY_DECREF_RNA_INVALIDATE(mpr->py_instance);
- }
-#endif
-
- if (mpr->op_data) {
- for (int i = 0; i < mpr->op_data_len; i++) {
- WM_operator_properties_free(&mpr->op_data[i].ptr);
- }
- MEM_freeN(mpr->op_data);
- }
-
- if (mpr->ptr != NULL) {
- WM_manipulator_properties_free(mpr->ptr);
- MEM_freeN(mpr->ptr);
- }
-
- if (mpr->type->target_property_defs_len != 0) {
- wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr);
- for (int i = 0; i < mpr->type->target_property_defs_len; i++) {
- wmManipulatorProperty *mpr_prop = &mpr_prop_array[i];
- if (mpr_prop->custom_func.free_fn) {
- mpr_prop->custom_func.free_fn(mpr, mpr_prop);
- }
- }
- }
-
- MEM_freeN(mpr);
-}
-
-/**
- * Free \a manipulator and unlink from \a manipulatorlist.
- * \a manipulatorlist is allowed to be NULL.
- */
-void WM_manipulator_unlink(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmManipulator *mpr, bContext *C)
-{
- if (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) {
- wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
- }
- if (mpr->state & WM_MANIPULATOR_STATE_MODAL) {
- wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false);
- }
- /* Unlink instead of setting so we don't run callbacks. */
- if (mpr->state & WM_MANIPULATOR_STATE_SELECT) {
- WM_manipulator_select_unlink(mmap, mpr);
- }
-
- if (manipulatorlist) {
- BLI_remlink(manipulatorlist, mpr);
- }
-
- BLI_assert(mmap->mmap_context.highlight != mpr);
- BLI_assert(mmap->mmap_context.modal != mpr);
-
- WM_manipulator_free(mpr);
-}
-
-/* -------------------------------------------------------------------- */
-/** \name Manipulator Creation API
- *
- * API for defining data on manipulator creation.
- *
- * \{ */
-
-struct wmManipulatorOpElem *WM_manipulator_operator_get(
- wmManipulator *mpr, int part_index)
-{
- if (mpr->op_data && ((part_index >= 0) && (part_index < mpr->op_data_len))) {
- return &mpr->op_data[part_index];
- }
- return NULL;
-}
-
-PointerRNA *WM_manipulator_operator_set(
- wmManipulator *mpr, int part_index,
- wmOperatorType *ot, IDProperty *properties)
-{
- BLI_assert(part_index < 255);
- /* We could pre-allocate these but using multiple is such a rare thing. */
- if (part_index >= mpr->op_data_len) {
- mpr->op_data_len = part_index + 1;
- mpr->op_data = MEM_recallocN(mpr->op_data, sizeof(*mpr->op_data) * mpr->op_data_len);
- }
- wmManipulatorOpElem *mpop = &mpr->op_data[part_index];
- mpop->type = ot;
-
- if (mpop->ptr.data) {
- WM_operator_properties_free(&mpop->ptr);
- }
- WM_operator_properties_create_ptr(&mpop->ptr, ot);
-
- if (properties) {
- mpop->ptr.data = properties;
- }
-
- return &mpop->ptr;
-}
-
-static void wm_manipulator_set_matrix_rotation_from_z_axis__internal(
- float matrix[4][4], const float z_axis[3])
-{
- /* old code, seems we can use simpler method */
-#if 0
- const float z_global[3] = {0.0f, 0.0f, 1.0f};
- float rot[3][3];
-
- rotation_between_vecs_to_mat3(rot, z_global, z_axis);
- copy_v3_v3(matrix[0], rot[0]);
- copy_v3_v3(matrix[1], rot[1]);
- copy_v3_v3(matrix[2], rot[2]);
-#else
- normalize_v3_v3(matrix[2], z_axis);
- ortho_basis_v3v3_v3(matrix[0], matrix[1], matrix[2]);
-#endif
-
-}
-
-static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal(
- float matrix[4][4], const float y_axis[3], const float z_axis[3])
-{
- normalize_v3_v3(matrix[1], y_axis);
- normalize_v3_v3(matrix[2], z_axis);
- cross_v3_v3v3(matrix[0], matrix[1], matrix[2]);
- normalize_v3(matrix[0]);
-}
-
-/**
- * wmManipulator.matrix utils.
- */
-void WM_manipulator_set_matrix_rotation_from_z_axis(
- wmManipulator *mpr, const float z_axis[3])
-{
- wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis);
-}
-void WM_manipulator_set_matrix_rotation_from_yz_axis(
- wmManipulator *mpr, const float y_axis[3], const float z_axis[3])
-{
- wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis);
-}
-void WM_manipulator_set_matrix_location(wmManipulator *mpr, const float origin[3])
-{
- copy_v3_v3(mpr->matrix_basis[3], origin);
-}
-
-/**
- * wmManipulator.matrix_offset utils.
- */
-void WM_manipulator_set_matrix_offset_rotation_from_z_axis(
- wmManipulator *mpr, const float z_axis[3])
-{
- wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis);
-}
-void WM_manipulator_set_matrix_offset_rotation_from_yz_axis(
- wmManipulator *mpr, const float y_axis[3], const float z_axis[3])
-{
- wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis);
-}
-void WM_manipulator_set_matrix_offset_location(wmManipulator *mpr, const float offset[3])
-{
- copy_v3_v3(mpr->matrix_offset[3], offset);
-}
-
-void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enable)
-{
- if (enable) {
- mpr->flag |= flag;
- }
- else {
- mpr->flag &= ~flag;
- }
-}
-
-void WM_manipulator_set_scale(wmManipulator *mpr, const float scale)
-{
- mpr->scale_basis = scale;
-}
-
-void WM_manipulator_set_line_width(wmManipulator *mpr, const float line_width)
-{
- mpr->line_width = line_width;
-}
-
-/**
- * Set manipulator rgba colors.
- *
- * \param col Normal state color.
- * \param col_hi Highlighted state color.
- */
-void WM_manipulator_get_color(const wmManipulator *mpr, float color[4])
-{
- copy_v4_v4(color, mpr->color);
-}
-void WM_manipulator_set_color(wmManipulator *mpr, const float color[4])
-{
- copy_v4_v4(mpr->color, color);
-}
-
-void WM_manipulator_get_color_highlight(const wmManipulator *mpr, float color_hi[4])
-{
- copy_v4_v4(color_hi, mpr->color_hi);
-}
-void WM_manipulator_set_color_highlight(wmManipulator *mpr, const float color_hi[4])
-{
- copy_v4_v4(mpr->color_hi, color_hi);
-}
-
-
-/** \} */ // Manipulator Creation API
-
-
-/* -------------------------------------------------------------------- */
-/** \name Manipulator Callback Assignment
- *
- * \{ */
-
-void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn)
-{
- mpr->custom_modal = fn;
-}
-
-/** \} */
-
-
-/* -------------------------------------------------------------------- */
-
-/**
- * Add/Remove \a manipulator to selection.
- * Reallocates memory for selected manipulators so better not call for selecting multiple ones.
- *
- * \return if the selection has changed.
- */
-bool wm_manipulator_select_set_ex(
- wmManipulatorMap *mmap, wmManipulator *mpr, bool select,
- bool use_array, bool use_callback)
-{
- bool changed = false;
-
- if (select) {
- if ((mpr->state & WM_MANIPULATOR_STATE_SELECT) == 0) {
- if (use_array) {
- wm_manipulatormap_select_array_push_back(mmap, mpr);
- }
- mpr->state |= WM_MANIPULATOR_STATE_SELECT;
- changed = true;
- }
- }
- else {
- if (mpr->state & WM_MANIPULATOR_STATE_SELECT) {
- if (use_array) {
- wm_manipulatormap_select_array_remove(mmap, mpr);
- }
- mpr->state &= ~WM_MANIPULATOR_STATE_SELECT;
- changed = true;
- }
- }
-
- /* In the case of unlinking we only want to remove from the array
- * and not write to the external state */
- if (use_callback && changed) {
- if (mpr->type->select_refresh) {
- mpr->type->select_refresh(mpr);
- }
- }
-
- return changed;
-}
-
-/* Remove from selection array without running callbacks. */
-bool WM_manipulator_select_unlink(wmManipulatorMap *mmap, wmManipulator *mpr)
-{
- return wm_manipulator_select_set_ex(mmap, mpr, false, true, false);
-}
-
-bool WM_manipulator_select_set(wmManipulatorMap *mmap, wmManipulator *mpr, bool select)
-{
- return wm_manipulator_select_set_ex(mmap, mpr, select, true, true);
-}
-
-void WM_manipulator_highlight_set(wmManipulatorMap *mmap, wmManipulator *mpr)
-{
- wm_manipulatormap_highlight_set(mmap, NULL, mpr, mpr ? mpr->highlight_part : 0);
-}
-
-bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr)
-{
- if (WM_manipulator_select_set(mmap, mpr, true)) {
- wm_manipulatormap_highlight_set(mmap, C, mpr, mpr->highlight_part);
- return true;
- }
- else {
- return false;
- }
-}
-
-/**
- * Special function to run from setup so manipulators start out interactive.
- *
- * We could do this when linking them, but this complicates things since the window update code needs to run first.
- */
-void WM_manipulator_modal_set_from_setup(
- struct wmManipulatorMap *mmap, struct bContext *C,
- struct wmManipulator *mpr, int part_index, const wmEvent *event)
-{
- mpr->highlight_part = part_index;
- WM_manipulator_highlight_set(mmap, mpr);
- if (false) {
- wm_manipulatormap_modal_set(mmap, C, mpr, event, true);
- }
- else {
- /* WEAK: but it works. */
- WM_operator_name_call(C, "MANIPULATORGROUP_OT_manipulator_tweak", WM_OP_INVOKE_DEFAULT, NULL);
- }
-}
-
-void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
-{
- const RegionView3D *rv3d = CTX_wm_region_view3d(C);
- float scale = UI_DPI_FAC;
-
- if ((mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE) == 0) {
- scale *= U.manipulator_size;
- if (rv3d) {
- /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */
- float matrix_world[4][4];
- if (mpr->type->matrix_basis_get) {
- float matrix_basis[4][4];
- mpr->type->matrix_basis_get(mpr, matrix_basis);
- mul_m4_m4m4(matrix_world, mpr->matrix_space, matrix_basis);
- }
- else {
- mul_m4_m4m4(matrix_world, mpr->matrix_space, mpr->matrix_basis);
- }
-
- /* Exclude matrix_offset from scale. */
- scale *= ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_world[3]);
- }
- else {
- scale *= 0.02f;
- }
- }
-
- mpr->scale_final = mpr->scale_basis * scale;
-}
-
-static void manipulator_update_prop_data(wmManipulator *mpr)
-{
- /* manipulator property might have been changed, so update manipulator */
- if (mpr->type->property_update) {
- wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr);
- for (int i = 0; i < mpr->type->target_property_defs_len; i++) {
- wmManipulatorProperty *mpr_prop = &mpr_prop_array[i];
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- mpr->type->property_update(mpr, mpr_prop);
- }
- }
- }
-}
-
-void wm_manipulator_update(wmManipulator *mpr, const bContext *C, const bool refresh_map)
-{
- if (refresh_map) {
- manipulator_update_prop_data(mpr);
- }
- wm_manipulator_calculate_scale(mpr, C);
-}
-
-int wm_manipulator_is_visible(wmManipulator *mpr)
-{
- if (mpr->flag & WM_MANIPULATOR_HIDDEN) {
- return 0;
- }
- if ((mpr->state & WM_MANIPULATOR_STATE_MODAL) &&
- !(mpr->flag & (WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_VALUE)))
- {
- /* don't draw while modal (dragging) */
- return 0;
- }
- if ((mpr->flag & WM_MANIPULATOR_DRAW_HOVER) &&
- !(mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) &&
- !(mpr->state & WM_MANIPULATOR_STATE_SELECT)) /* still draw selected manipulators */
- {
- /* update but don't draw */
- return WM_MANIPULATOR_IS_VISIBLE_UPDATE;
- }
-
- return WM_MANIPULATOR_IS_VISIBLE_UPDATE | WM_MANIPULATOR_IS_VISIBLE_DRAW;
-}
-
-void WM_manipulator_calc_matrix_final_params(
- const wmManipulator *mpr,
- const struct WM_ManipulatorMatrixParams *params,
- float r_mat[4][4])
-{
- const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : mpr->matrix_space;
- const float (* const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis : mpr->matrix_basis;
- const float (* const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset : mpr->matrix_offset;
- const float *scale_final = params->scale_final ? params->scale_final : &mpr->scale_final;
-
- float final_matrix[4][4];
- if (params->matrix_basis == NULL && mpr->type->matrix_basis_get) {
- mpr->type->matrix_basis_get(mpr, final_matrix);
- }
- else {
- copy_m4_m4(final_matrix, matrix_basis);
- }
-
- if (mpr->flag & WM_MANIPULATOR_DRAW_NO_SCALE) {
- mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
- }
- else {
- if (mpr->flag & WM_MANIPULATOR_DRAW_OFFSET_SCALE) {
- mul_mat3_m4_fl(final_matrix, *scale_final);
- mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
- }
- else {
- mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
- mul_mat3_m4_fl(final_matrix, *scale_final);
- }
- }
-
- mul_m4_m4m4(r_mat, matrix_space, final_matrix);
-}
-
-void WM_manipulator_calc_matrix_final_no_offset(const wmManipulator *mpr, float r_mat[4][4])
-{
- float mat_identity[4][4];
- unit_m4(mat_identity);
-
- WM_manipulator_calc_matrix_final_params(
- mpr,
- &((struct WM_ManipulatorMatrixParams) {
- .matrix_space = NULL,
- .matrix_basis = NULL,
- .matrix_offset = mat_identity,
- .scale_final = NULL,
- }), r_mat
- );
-}
-
-void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4])
-{
- WM_manipulator_calc_matrix_final_params(
- mpr,
- &((struct WM_ManipulatorMatrixParams) {
- .matrix_space = NULL,
- .matrix_basis = NULL,
- .matrix_offset = NULL,
- .scale_final = NULL,
- }), r_mat
- );
-}
-
-/** \name Manipulator Propery Access
- *
- * Matches `WM_operator_properties` conventions.
- *
- * \{ */
-
-
-void WM_manipulator_properties_create_ptr(PointerRNA *ptr, wmManipulatorType *wt)
-{
- RNA_pointer_create(NULL, wt->srna, NULL, ptr);
-}
-
-void WM_manipulator_properties_create(PointerRNA *ptr, const char *wtstring)
-{
- const wmManipulatorType *wt = WM_manipulatortype_find(wtstring, false);
-
- if (wt)
- WM_manipulator_properties_create_ptr(ptr, (wmManipulatorType *)wt);
- else
- RNA_pointer_create(NULL, &RNA_ManipulatorProperties, NULL, ptr);
-}
-
-/* similar to the function above except its uses ID properties
- * used for keymaps and macros */
-void WM_manipulator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *wtstring)
-{
- if (*properties == NULL) {
- IDPropertyTemplate val = {0};
- *properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
- }
-
- if (*ptr == NULL) {
- *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
- WM_manipulator_properties_create(*ptr, wtstring);
- }
-
- (*ptr)->data = *properties;
-
-}
-
-void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context)
-{
- RNA_STRUCT_BEGIN (ptr, prop)
- {
- switch (RNA_property_type(prop)) {
- case PROP_ENUM:
- if (no_context)
- RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT);
- else
- RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT);
- break;
- case PROP_POINTER:
- {
- StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
-
- /* recurse into manipulator properties */
- if (RNA_struct_is_a(ptype, &RNA_ManipulatorProperties)) {
- PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
- WM_manipulator_properties_sanitize(&opptr, no_context);
- }
- break;
- }
- default:
- break;
- }
- }
- RNA_STRUCT_END;
-}
-
-
-/** set all props to their default,
- * \param do_update Only update un-initialized props.
- *
- * \note, theres nothing specific to manipulators here.
- * this could be made a general function.
- */
-bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update)
-{
- bool changed = false;
- RNA_STRUCT_BEGIN (ptr, prop)
- {
- switch (RNA_property_type(prop)) {
- case PROP_POINTER:
- {
- StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
- if (ptype != &RNA_Struct) {
- PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
- changed |= WM_manipulator_properties_default(&opptr, do_update);
- }
- break;
- }
- default:
- if ((do_update == false) || (RNA_property_is_set(ptr, prop) == false)) {
- if (RNA_property_reset(ptr, prop, -1)) {
- changed = true;
- }
- }
- break;
- }
- }
- RNA_STRUCT_END;
-
- return changed;
-}
-
-/* remove all props without PROP_SKIP_SAVE */
-void WM_manipulator_properties_reset(wmManipulator *mpr)
-{
- if (mpr->ptr->data) {
- PropertyRNA *iterprop;
- iterprop = RNA_struct_iterator_property(mpr->type->srna);
-
- RNA_PROP_BEGIN (mpr->ptr, itemptr, iterprop)
- {
- PropertyRNA *prop = itemptr.data;
-
- if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
- const char *identifier = RNA_property_identifier(prop);
- RNA_struct_idprops_unset(mpr->ptr, identifier);
- }
- }
- RNA_PROP_END;
- }
-}
-
-void WM_manipulator_properties_clear(PointerRNA *ptr)
-{
- IDProperty *properties = ptr->data;
-
- if (properties) {
- IDP_ClearProperty(properties);
- }
-}
-
-void WM_manipulator_properties_free(PointerRNA *ptr)
-{
- IDProperty *properties = ptr->data;
-
- if (properties) {
- IDP_FreeProperty(properties);
- MEM_freeN(properties);
- ptr->data = NULL; /* just in case */
- }
-}
-
-/** \} */
-
-/** \name General Utilities
- *
- * \{ */
-
-bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step)
-{
- switch (step) {
- case WM_MANIPULATORMAP_DRAWSTEP_2D:
- {
- break;
- }
- case WM_MANIPULATORMAP_DRAWSTEP_3D:
- {
- wmWindowManager *wm = CTX_wm_manager(C);
- if (ED_screen_animation_playing(wm)) {
- return false;
- }
- break;
- }
- }
- return true;
-}
-
-/** \} */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
deleted file mode 100644
index f9b55865bf0..00000000000
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
+++ /dev/null
@@ -1,949 +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) 2014 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/manipulators/intern/wm_manipulator_group.c
- * \ingroup wm
- *
- * \name Manipulator-Group
- *
- * Manipulator-groups store and manage groups of manipulators. They can be
- * attached to modal handlers and have own keymaps.
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_listbase.h"
-#include "BLI_string.h"
-#include "BLI_math.h"
-
-#include "BKE_context.h"
-#include "BKE_main.h"
-#include "BKE_report.h"
-#include "BKE_workspace.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-#include "wm_event_system.h"
-
-#include "ED_screen.h"
-#include "ED_undo.h"
-
-/* own includes */
-#include "wm_manipulator_wmapi.h"
-#include "wm_manipulator_intern.h"
-
-#ifdef WITH_PYTHON
-# include "BPY_extern.h"
-#endif
-
-/* Allow manipulator part's to be single click only,
- * dragging falls back to activating their 'drag_part' action. */
-#define USE_DRAG_DETECT
-
-/* -------------------------------------------------------------------- */
-/** \name wmManipulatorGroup
- *
- * \{ */
-
-/**
- * Create a new manipulator-group from \a wgt.
- */
-wmManipulatorGroup *wm_manipulatorgroup_new_from_type(
- wmManipulatorMap *mmap, wmManipulatorGroupType *wgt)
-{
- wmManipulatorGroup *mgroup = MEM_callocN(sizeof(*mgroup), "manipulator-group");
- mgroup->type = wgt;
-
- /* keep back-link */
- mgroup->parent_mmap = mmap;
-
- BLI_addtail(&mmap->groups, mgroup);
-
- return mgroup;
-}
-
-void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup)
-{
- wmManipulatorMap *mmap = mgroup->parent_mmap;
-
- /* Similar to WM_manipulator_unlink, but only to keep mmap state correct,
- * we don't want to run callbacks. */
- if (mmap->mmap_context.highlight && mmap->mmap_context.highlight->parent_mgroup == mgroup) {
- wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
- }
- if (mmap->mmap_context.modal && mmap->mmap_context.modal->parent_mgroup == mgroup) {
- wm_manipulatormap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false);
- }
-
- for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) {
- mpr_next = mpr->next;
- if (mmap->mmap_context.select.len) {
- WM_manipulator_select_unlink(mmap, mpr);
- }
- WM_manipulator_free(mpr);
- }
- BLI_listbase_clear(&mgroup->manipulators);
-
-#ifdef WITH_PYTHON
- if (mgroup->py_instance) {
- /* do this first in case there are any __del__ functions or
- * similar that use properties */
- BPY_DECREF_RNA_INVALIDATE(mgroup->py_instance);
- }
-#endif
-
- if (mgroup->reports && (mgroup->reports->flag & RPT_FREE)) {
- BKE_reports_clear(mgroup->reports);
- MEM_freeN(mgroup->reports);
- }
-
- if (mgroup->customdata_free) {
- mgroup->customdata_free(mgroup->customdata);
- }
- else {
- MEM_SAFE_FREE(mgroup->customdata);
- }
-
- BLI_remlink(&mmap->groups, mgroup);
-
- MEM_freeN(mgroup);
-}
-
-/**
- * Add \a manipulator to \a mgroup and make sure its name is unique within the group.
- */
-void wm_manipulatorgroup_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr)
-{
- BLI_assert(BLI_findindex(&mgroup->manipulators, mpr) == -1);
- BLI_addtail(&mgroup->manipulators, mpr);
- mpr->parent_mgroup = mgroup;
-}
-
-wmManipulator *wm_manipulatorgroup_find_intersected_manipulator(
- const wmManipulatorGroup *mgroup, bContext *C, const wmEvent *event,
- int *r_part)
-{
- for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
- if (mpr->type->test_select && (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) {
- if ((*r_part = mpr->type->test_select(C, mpr, event)) != -1) {
- return mpr;
- }
- }
- }
-
- return NULL;
-}
-
-/**
- * Adds all manipulators of \a mgroup that can be selected to the head of \a listbase. Added items need freeing!
- */
-void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorGroup *mgroup, ListBase *listbase)
-{
- for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
- if ((mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) {
- if (((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) && mpr->type->draw_select) ||
- ((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0 && mpr->type->test_select))
- {
- BLI_addhead(listbase, BLI_genericNodeN(mpr));
- }
- }
- }
-}
-
-void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bContext *C)
-{
- /* prepare for first draw */
- if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0)) {
- mgroup->type->setup(C, mgroup);
-
- /* Not ideal, initialize keymap here, needed for RNA runtime generated manipulators. */
- wmManipulatorGroupType *wgt = mgroup->type;
- if (wgt->keymap == NULL) {
- wmWindowManager *wm = CTX_wm_manager(C);
- wm_manipulatorgrouptype_setup_keymap(wgt, wm->defaultconf);
- BLI_assert(wgt->keymap != NULL);
- }
- mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_SETUP;
- }
-
- /* refresh may be called multiple times, this just ensures its called at least once before we draw. */
- if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_REFRESH) == 0)) {
- if (mgroup->type->refresh) {
- mgroup->type->refresh(C, mgroup);
- }
- mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_REFRESH;
- }
-}
-
-bool WM_manipulator_group_type_poll(const bContext *C, const struct wmManipulatorGroupType *wgt)
-{
- /* If we're tagged, only use compatible. */
- if (wgt->owner_id[0] != '\0') {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if (BKE_workspace_owner_id_check(workspace, wgt->owner_id) == false) {
- return false;
- }
- }
- /* Check for poll function, if manipulator-group belongs to an operator, also check if the operator is running. */
- return (!wgt->poll || wgt->poll(C, (wmManipulatorGroupType *)wgt));
-}
-
-bool wm_manipulatorgroup_is_visible_in_drawstep(
- const wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep)
-{
- switch (drawstep) {
- case WM_MANIPULATORMAP_DRAWSTEP_2D:
- return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0;
- case WM_MANIPULATORMAP_DRAWSTEP_3D:
- return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D);
- default:
- BLI_assert(0);
- return false;
- }
-}
-
-bool wm_manipulatorgroup_is_any_selected(const wmManipulatorGroup *mgroup)
-{
- if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT) {
- for (const wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
- if (mpr->state & WM_MANIPULATOR_STATE_SELECT) {
- return true;
- }
- }
- }
- return false;
-}
-
-/** \} */
-
-/** \name Manipulator operators
- *
- * Basic operators for manipulator interaction with user configurable keymaps.
- *
- * \{ */
-
-static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- ARegion *ar = CTX_wm_region(C);
- wmManipulatorMap *mmap = ar->manipulator_map;
- wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
- wmManipulator *highlight = mmap->mmap_context.highlight;
-
- bool extend = RNA_boolean_get(op->ptr, "extend");
- bool deselect = RNA_boolean_get(op->ptr, "deselect");
- bool toggle = RNA_boolean_get(op->ptr, "toggle");
-
- /* deselect all first */
- if (extend == false && deselect == false && toggle == false) {
- wm_manipulatormap_deselect_all(mmap);
- BLI_assert(msel->items == NULL && msel->len == 0);
- UNUSED_VARS_NDEBUG(msel);
- }
-
- if (highlight) {
- const bool is_selected = (highlight->state & WM_MANIPULATOR_STATE_SELECT);
- bool redraw = false;
-
- if (toggle) {
- /* toggle: deselect if already selected, else select */
- deselect = is_selected;
- }
-
- if (deselect) {
- if (is_selected && WM_manipulator_select_set(mmap, highlight, false)) {
- redraw = true;
- }
- }
- else if (wm_manipulator_select_and_highlight(C, mmap, highlight)) {
- redraw = true;
- }
-
- if (redraw) {
- ED_region_tag_redraw(ar);
- }
-
- return OPERATOR_FINISHED;
- }
- else {
- BLI_assert(0);
- return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
- }
-
- return OPERATOR_PASS_THROUGH;
-}
-
-void MANIPULATORGROUP_OT_manipulator_select(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Manipulator Select";
- ot->description = "Select the currently highlighted manipulator";
- ot->idname = "MANIPULATORGROUP_OT_manipulator_select";
-
- /* api callbacks */
- ot->invoke = manipulator_select_invoke;
-
- ot->flag = OPTYPE_UNDO;
-
- WM_operator_properties_mouse_select(ot);
-}
-
-typedef struct ManipulatorTweakData {
- wmManipulatorMap *mmap;
- wmManipulatorGroup *mgroup;
- wmManipulator *mpr_modal;
-
- int init_event; /* initial event type */
- int flag; /* tweak flags */
-
-#ifdef USE_DRAG_DETECT
- /* True until the mouse is moved (only use when the operator has no modal).
- * this allows some manipulators to be click-only. */
- enum {
- /* Don't detect dragging. */
- DRAG_NOP = 0,
- /* Detect dragging (wait until a drag or click is detected). */
- DRAG_DETECT,
- /* Drag has started, idle until there is no active modal operator.
- * This is needed because finishing the modal operator also exits
- * the modal manipulator state (un-grabbs the cursor).
- * Ideally this workaround could be removed later. */
- DRAG_IDLE,
- } drag_state;
-#endif
-
-} ManipulatorTweakData;
-
-static bool manipulator_tweak_start(
- bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event)
-{
- /* activate highlighted manipulator */
- wm_manipulatormap_modal_set(mmap, C, mpr, event, true);
-
- return (mpr->state & WM_MANIPULATOR_STATE_MODAL);
-}
-
-static bool manipulator_tweak_start_and_finish(
- bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event, bool *r_is_modal)
-{
- wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part);
- if (r_is_modal) {
- *r_is_modal = false;
- }
- if (mpop && mpop->type) {
-
- /* Undo/Redo */
- if (mpop->is_redo) {
- wmWindowManager *wm = CTX_wm_manager(C);
- wmOperator *op = WM_operator_last_redo(C);
-
- /* We may want to enable this, for now the manipulator can manage it's own properties. */
-#if 0
- IDP_MergeGroup(mpop->ptr.data, op->properties, false);
-#endif
-
- WM_operator_free_all_after(wm, op);
- ED_undo_pop_op(C, op);
- }
-
- /* XXX temporary workaround for modal manipulator operator
- * conflicting with modal operator attached to manipulator */
- if (mpop->type->modal) {
- /* activate highlighted manipulator */
- wm_manipulatormap_modal_set(mmap, C, mpr, event, true);
- if (r_is_modal) {
- *r_is_modal = true;
- }
- }
- else {
- /* Allow for 'button' manipulators, single click to run an action. */
- WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr);
- }
- return true;
- }
- else {
- return false;
- }
-}
-
-static void manipulator_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal)
-{
- ManipulatorTweakData *mtweak = op->customdata;
- if (mtweak->mpr_modal->type->exit) {
- mtweak->mpr_modal->type->exit(C, mtweak->mpr_modal, cancel);
- }
- if (clear_modal) {
- /* The manipulator may have been removed. */
- if ((BLI_findindex(&mtweak->mmap->groups, mtweak->mgroup) != -1) &&
- (BLI_findindex(&mtweak->mgroup->manipulators, mtweak->mpr_modal) != -1))
- {
- wm_manipulatormap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false);
- }
- }
- MEM_freeN(mtweak);
-}
-
-static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- ManipulatorTweakData *mtweak = op->customdata;
- wmManipulator *mpr = mtweak->mpr_modal;
- int retval = OPERATOR_PASS_THROUGH;
- bool clear_modal = true;
-
- if (mpr == NULL) {
- BLI_assert(0);
- return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
- }
-
-#ifdef USE_DRAG_DETECT
- wmManipulatorMap *mmap = mtweak->mmap;
- if (mtweak->drag_state == DRAG_DETECT) {
- if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
- if (len_manhattan_v2v2_int(&event->x, mmap->mmap_context.event_xy) > 2) {
- mtweak->drag_state = DRAG_IDLE;
- mpr->highlight_part = mpr->drag_part;
- }
- }
- else if (event->type == mtweak->init_event && event->val == KM_RELEASE) {
- mtweak->drag_state = DRAG_NOP;
- retval = OPERATOR_FINISHED;
- }
-
- if (mtweak->drag_state != DRAG_DETECT) {
- /* Follow logic in 'manipulator_tweak_invoke' */
- bool is_modal = false;
- if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, &is_modal)) {
- if (is_modal) {
- clear_modal = false;
- }
- }
- else {
- if (!manipulator_tweak_start(C, mmap, mpr, event)) {
- retval = OPERATOR_FINISHED;
- }
- }
- }
- }
- if (mtweak->drag_state == DRAG_IDLE) {
- if (mmap->mmap_context.modal != NULL) {
- return OPERATOR_PASS_THROUGH;
- }
- else {
- manipulator_tweak_finish(C, op, false, false);
- return OPERATOR_FINISHED;
- }
- }
-#endif /* USE_DRAG_DETECT */
-
- if (retval == OPERATOR_FINISHED) {
- /* pass */
- }
- else if (event->type == mtweak->init_event && event->val == KM_RELEASE) {
- retval = OPERATOR_FINISHED;
- }
- else if (event->type == EVT_MODAL_MAP) {
- switch (event->val) {
- case TWEAK_MODAL_CANCEL:
- retval = OPERATOR_CANCELLED;
- break;
- case TWEAK_MODAL_CONFIRM:
- retval = OPERATOR_FINISHED;
- break;
- case TWEAK_MODAL_PRECISION_ON:
- mtweak->flag |= WM_MANIPULATOR_TWEAK_PRECISE;
- break;
- case TWEAK_MODAL_PRECISION_OFF:
- mtweak->flag &= ~WM_MANIPULATOR_TWEAK_PRECISE;
- break;
-
- case TWEAK_MODAL_SNAP_ON:
- mtweak->flag |= WM_MANIPULATOR_TWEAK_SNAP;
- break;
- case TWEAK_MODAL_SNAP_OFF:
- mtweak->flag &= ~WM_MANIPULATOR_TWEAK_SNAP;
- break;
- }
- }
-
- if (retval != OPERATOR_PASS_THROUGH) {
- manipulator_tweak_finish(C, op, retval != OPERATOR_FINISHED, clear_modal);
- return retval;
- }
-
- /* handle manipulator */
- wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal;
- if (modal_fn) {
- int modal_retval = modal_fn(C, mpr, event, mtweak->flag);
-
- if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) {
- manipulator_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true);
- return OPERATOR_FINISHED;
- }
-
- /* Ugly hack to send manipulator events */
- ((wmEvent *)event)->type = EVT_MANIPULATOR_UPDATE;
- }
-
- /* always return PASS_THROUGH so modal handlers
- * with manipulators attached can update */
- BLI_assert(retval == OPERATOR_PASS_THROUGH);
- return OPERATOR_PASS_THROUGH;
-}
-
-static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- ARegion *ar = CTX_wm_region(C);
- wmManipulatorMap *mmap = ar->manipulator_map;
- wmManipulator *mpr = mmap->mmap_context.highlight;
-
- /* Needed for single click actions which don't enter modal state. */
- WM_tooltip_clear(C, CTX_wm_window(C));
-
- if (!mpr) {
- /* wm_handlers_do_intern shouldn't let this happen */
- BLI_assert(0);
- return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
- }
-
- bool use_drag_fallback = false;
-
-#ifdef USE_DRAG_DETECT
- use_drag_fallback = !ELEM(mpr->drag_part, -1, mpr->highlight_part);
-#endif
-
- if (use_drag_fallback == false) {
- if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, NULL)) {
- return OPERATOR_FINISHED;
- }
- }
-
- bool use_drag_detect = false;
-#ifdef USE_DRAG_DETECT
- if (use_drag_fallback) {
- wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part);
- if (mpop && mpop->type) {
- if (mpop->type->modal == NULL) {
- use_drag_detect = true;
- }
- }
- }
-#endif
-
- if (use_drag_detect == false) {
- if (!manipulator_tweak_start(C, mmap, mpr, event)) {
- /* failed to start */
- return OPERATOR_PASS_THROUGH;
- }
- }
-
- ManipulatorTweakData *mtweak = MEM_mallocN(sizeof(ManipulatorTweakData), __func__);
-
- mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type);
- mtweak->mpr_modal = mmap->mmap_context.highlight;
- mtweak->mgroup = mtweak->mpr_modal->parent_mgroup;
- mtweak->mmap = mmap;
- mtweak->flag = 0;
-
-#ifdef USE_DRAG_DETECT
- mtweak->drag_state = use_drag_detect ? DRAG_DETECT : DRAG_NOP;
-#endif
-
- op->customdata = mtweak;
-
- WM_event_add_modal_handler(C, op);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Manipulator Tweak";
- ot->description = "Tweak the active manipulator";
- ot->idname = "MANIPULATORGROUP_OT_manipulator_tweak";
-
- /* api callbacks */
- ot->invoke = manipulator_tweak_invoke;
- ot->modal = manipulator_tweak_modal;
-
- /* TODO(campbell) This causes problems tweaking settings for operators,
- * need to find a way to support this. */
-#if 0
- ot->flag = OPTYPE_UNDO;
-#endif
-}
-
-/** \} */ // Manipulator operators
-
-
-static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname)
-{
- wmKeyMap *keymap;
- char name[KMAP_MAX_NAME];
-
- static EnumPropertyItem modal_items[] = {
- {TWEAK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
- {TWEAK_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
- {TWEAK_MODAL_PRECISION_ON, "PRECISION_ON", 0, "Enable Precision", ""},
- {TWEAK_MODAL_PRECISION_OFF, "PRECISION_OFF", 0, "Disable Precision", ""},
- {TWEAK_MODAL_SNAP_ON, "SNAP_ON", 0, "Enable Snap", ""},
- {TWEAK_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Disable Snap", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
-
- BLI_snprintf(name, sizeof(name), "%s Tweak Modal Map", mgroupname);
- keymap = WM_modalkeymap_get(keyconf, name);
-
- /* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
- return NULL;
-
- keymap = WM_modalkeymap_add(keyconf, name, modal_items);
-
-
- /* items for modal map */
- WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL);
- WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL);
-
- WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM);
- WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM);
-
- WM_modalkeymap_add_item(keymap, RIGHTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON);
- WM_modalkeymap_add_item(keymap, RIGHTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF);
- WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON);
- WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF);
-
- WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON);
- WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF);
- WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON);
- WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF);
-
- WM_modalkeymap_assign(keymap, "MANIPULATORGROUP_OT_manipulator_tweak");
-
- return keymap;
-}
-
-/**
- * Common default keymap for manipulator groups
- */
-wmKeyMap *WM_manipulatorgroup_keymap_common(
- const wmManipulatorGroupType *wgt, wmKeyConfig *config)
-{
- /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */
- wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid);
-
- WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
- manipulatorgroup_tweak_modal_keymap(config, wgt->name);
-
- return km;
-}
-
-/**
- * Variation of #WM_manipulatorgroup_keymap_common but with keymap items for selection
- */
-wmKeyMap *WM_manipulatorgroup_keymap_common_select(
- const wmManipulatorGroupType *wgt, wmKeyConfig *config)
-{
- /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */
- wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid);
-
- WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
- WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", EVT_TWEAK_S, KM_ANY, 0, 0);
- manipulatorgroup_tweak_modal_keymap(config, wgt->name);
-
- wmKeyMapItem *kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, 0, 0);
- RNA_boolean_set(kmi->ptr, "extend", false);
- RNA_boolean_set(kmi->ptr, "deselect", false);
- RNA_boolean_set(kmi->ptr, "toggle", false);
- kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
- RNA_boolean_set(kmi->ptr, "extend", false);
- RNA_boolean_set(kmi->ptr, "deselect", false);
- RNA_boolean_set(kmi->ptr, "toggle", true);
-
- return km;
-}
-
-/** \} */ /* wmManipulatorGroup */
-
-/* -------------------------------------------------------------------- */
-/** \name wmManipulatorGroupType
- *
- * \{ */
-
-struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr(
- struct wmManipulatorMapType *mmap_type,
- const wmManipulatorGroupType *wgt)
-{
- /* could use hash lookups as operator types do, for now simple search. */
- for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first;
- wgt_ref;
- wgt_ref = wgt_ref->next)
- {
- if (wgt_ref->type == wgt) {
- return wgt_ref;
- }
- }
- return NULL;
-}
-
-struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find(
- struct wmManipulatorMapType *mmap_type,
- const char *idname)
-{
- /* could use hash lookups as operator types do, for now simple search. */
- for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first;
- wgt_ref;
- wgt_ref = wgt_ref->next)
- {
- if (STREQ(idname, wgt_ref->type->idname)) {
- return wgt_ref;
- }
- }
- return NULL;
-}
-
-/**
- * Use this for registering manipulators on startup. For runtime, use #WM_manipulatormaptype_group_link_runtime.
- */
-wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link(
- wmManipulatorMapType *mmap_type, const char *idname)
-{
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
- BLI_assert(wgt != NULL);
- return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt);
-}
-
-wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr(
- wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt)
-{
- wmManipulatorGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmManipulatorGroupTypeRef), "manipulator-group-ref");
- wgt_ref->type = wgt;
- BLI_addtail(&mmap_type->grouptype_refs, wgt_ref);
- return wgt_ref;
-}
-
-void WM_manipulatormaptype_group_init_runtime_keymap(
- const Main *bmain,
- wmManipulatorGroupType *wgt)
-{
- /* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */
- wm_manipulatorgrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf);
-}
-
-void WM_manipulatormaptype_group_init_runtime(
- const Main *bmain, wmManipulatorMapType *mmap_type,
- wmManipulatorGroupType *wgt)
-{
- /* now create a manipulator for all existing areas */
- for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- for (ARegion *ar = lb->first; ar; ar = ar->next) {
- wmManipulatorMap *mmap = ar->manipulator_map;
- if (mmap && mmap->type == mmap_type) {
- wm_manipulatorgroup_new_from_type(mmap, wgt);
-
- /* just add here, drawing will occur on next update */
- wm_manipulatormap_highlight_set(mmap, NULL, NULL, 0);
- ED_region_tag_redraw(ar);
- }
- }
- }
- }
- }
-}
-
-
-/**
- * Unlike #WM_manipulatormaptype_group_unlink this doesn't maintain correct state, simply free.
- */
-void WM_manipulatormaptype_group_free(wmManipulatorGroupTypeRef *wgt_ref)
-{
- MEM_freeN(wgt_ref);
-}
-
-void WM_manipulatormaptype_group_unlink(
- bContext *C, Main *bmain, wmManipulatorMapType *mmap_type,
- const wmManipulatorGroupType *wgt)
-{
- /* Free instances. */
- for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- for (ARegion *ar = lb->first; ar; ar = ar->next) {
- wmManipulatorMap *mmap = ar->manipulator_map;
- if (mmap && mmap->type == mmap_type) {
- wmManipulatorGroup *mgroup, *mgroup_next;
- for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup_next) {
- mgroup_next = mgroup->next;
- if (mgroup->type == wgt) {
- BLI_assert(mgroup->parent_mmap == mmap);
- wm_manipulatorgroup_free(C, mgroup);
- ED_region_tag_redraw(ar);
- }
- }
- }
- }
- }
- }
- }
-
- /* Free types. */
- wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt);
- if (wgt_ref) {
- BLI_remlink(&mmap_type->grouptype_refs, wgt_ref);
- WM_manipulatormaptype_group_free(wgt_ref);
- }
-
- /* Note, we may want to keep this keymap for editing */
- WM_keymap_remove(wgt->keyconf, wgt->keymap);
-
- BLI_assert(WM_manipulatormaptype_group_find_ptr(mmap_type, wgt) == NULL);
-}
-
-void wm_manipulatorgrouptype_setup_keymap(
- wmManipulatorGroupType *wgt, wmKeyConfig *keyconf)
-{
- /* Use flag since setup_keymap may return NULL,
- * in that case we better not keep calling it. */
- if (wgt->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) {
- wgt->keymap = wgt->setup_keymap(wgt, keyconf);
- wgt->keyconf = keyconf;
- wgt->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT;
- }
-}
-
-/** \} */ /* wmManipulatorGroupType */
-
-/* -------------------------------------------------------------------- */
-/** \name High Level Add/Remove API
- *
- * For use directly from operators & RNA registration.
- *
- * \note In context of manipulator API these names are a bit misleading,
- * but for general use terms its OK.
- * `WM_manipulator_group_type_add` would be more correctly called:
- * `WM_manipulatormaptype_grouptype_reference_link`
- * but for general purpose API this is too detailed & annoying.
- *
- * \note We may want to return a value if there is nothing to remove.
- *
- * \{ */
-
-void WM_manipulator_group_type_add_ptr_ex(
- wmManipulatorGroupType *wgt,
- wmManipulatorMapType *mmap_type)
-{
- WM_manipulatormaptype_group_link_ptr(mmap_type, wgt);
-
- WM_manipulatorconfig_update_tag_init(mmap_type, wgt);
-}
-void WM_manipulator_group_type_add_ptr(
- wmManipulatorGroupType *wgt)
-{
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
- WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type);
-}
-void WM_manipulator_group_type_add(const char *idname)
-{
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
- BLI_assert(wgt != NULL);
- WM_manipulator_group_type_add_ptr(wgt);
-}
-
-void WM_manipulator_group_type_ensure_ptr_ex(
- wmManipulatorGroupType *wgt,
- wmManipulatorMapType *mmap_type)
-{
- wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt);
- if (wgt_ref == NULL) {
- WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type);
- }
-}
-void WM_manipulator_group_type_ensure_ptr(
- wmManipulatorGroupType *wgt)
-{
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
- WM_manipulator_group_type_ensure_ptr_ex(wgt, mmap_type);
-}
-void WM_manipulator_group_type_ensure(const char *idname)
-{
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
- BLI_assert(wgt != NULL);
- WM_manipulator_group_type_ensure_ptr(wgt);
-}
-
-void WM_manipulator_group_type_remove_ptr_ex(
- struct Main *bmain, wmManipulatorGroupType *wgt,
- wmManipulatorMapType *mmap_type)
-{
- WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt);
- WM_manipulatorgrouptype_free_ptr(wgt);
-}
-void WM_manipulator_group_type_remove_ptr(
- struct Main *bmain, wmManipulatorGroupType *wgt)
-{
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
- WM_manipulator_group_type_remove_ptr_ex(bmain, wgt, mmap_type);
-}
-void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname)
-{
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
- BLI_assert(wgt != NULL);
- WM_manipulator_group_type_remove_ptr(bmain, wgt);
-}
-
-/* delayed versions */
-
-void WM_manipulator_group_type_unlink_delayed_ptr_ex(
- wmManipulatorGroupType *wgt,
- wmManipulatorMapType *mmap_type)
-{
- WM_manipulatorconfig_update_tag_remove(mmap_type, wgt);
-}
-
-void WM_manipulator_group_type_unlink_delayed_ptr(
- wmManipulatorGroupType *wgt)
-{
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
- WM_manipulator_group_type_unlink_delayed_ptr_ex(wgt, mmap_type);
-}
-
-void WM_manipulator_group_type_unlink_delayed(const char *idname)
-{
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
- BLI_assert(wgt != NULL);
- WM_manipulator_group_type_unlink_delayed_ptr(wgt);
-}
-
-/** \} */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c
deleted file mode 100644
index b32eb84e289..00000000000
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c
+++ /dev/null
@@ -1,197 +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/windowmanager/manipulators/intern/wm_manipulator_group_type.c
- * \ingroup wm
- */
-
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BLI_string.h"
-#include "BLI_string_utils.h"
-
-#include "BKE_context.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "RNA_access.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-/* only for own init/exit calls (wm_manipulatorgrouptype_init/wm_manipulatorgrouptype_free) */
-#include "wm.h"
-
-/* own includes */
-#include "wm_manipulator_wmapi.h"
-#include "wm_manipulator_intern.h"
-
-
-/** \name ManipulatorGroup Type Append
- *
- * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
- * \{ */
-
-static GHash *global_manipulatorgrouptype_hash = NULL;
-
-wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet)
-{
- if (idname[0]) {
- wmManipulatorGroupType *wgt;
-
- wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname);
- if (wgt) {
- return wgt;
- }
-
- if (!quiet) {
- printf("search for unknown manipulator group '%s'\n", idname);
- }
- }
- else {
- if (!quiet) {
- printf("search for empty manipulator group\n");
- }
- }
-
- return NULL;
-}
-
-/* caller must free */
-void WM_manipulatorgrouptype_iter(GHashIterator *ghi)
-{
- BLI_ghashIterator_init(ghi, global_manipulatorgrouptype_hash);
-}
-
-static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void)
-{
- wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulatorgrouptype");
-
- return wgt;
-}
-static void wm_manipulatorgrouptype_append__end(wmManipulatorGroupType *wgt)
-{
- BLI_assert(wgt->name != NULL);
- BLI_assert(wgt->idname != NULL);
-
- wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_KEYMAP_INIT;
-
- /* if not set, use default */
- if (wgt->setup_keymap == NULL) {
- if (wgt->flag & WM_MANIPULATORGROUPTYPE_SELECT) {
- wgt->setup_keymap = WM_manipulatorgroup_keymap_common_select;
- }
- else {
- wgt->setup_keymap = WM_manipulatorgroup_keymap_common;
- }
- }
-
- BLI_ghash_insert(global_manipulatorgrouptype_hash, (void *)wgt->idname, wgt);
-}
-
-wmManipulatorGroupType *WM_manipulatorgrouptype_append(
- void (*wtfunc)(struct wmManipulatorGroupType *))
-{
- wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin();
- wtfunc(wgt);
- wm_manipulatorgrouptype_append__end(wgt);
- return wgt;
-}
-
-wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(
- void (*wtfunc)(struct wmManipulatorGroupType *, void *), void *userdata)
-{
- wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin();
- wtfunc(wgt, userdata);
- wm_manipulatorgrouptype_append__end(wgt);
- return wgt;
-}
-
-/**
- * Append and insert into a manipulator typemap.
- * This is most common for C manipulators which are enabled by default.
- */
-wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link(
- wmManipulatorMapType *mmap_type,
- void (*wtfunc)(struct wmManipulatorGroupType *))
-{
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(wtfunc);
-
- wgt->mmap_params.spaceid = mmap_type->spaceid;
- wgt->mmap_params.regionid = mmap_type->regionid;
-
- return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt);
-}
-
-/**
- * Free but don't remove from ghash.
- */
-static void manipulatorgrouptype_free(wmManipulatorGroupType *wgt)
-{
- if (wgt->ext.srna) { /* python manipulator group, allocs own string */
- MEM_freeN((void *)wgt->idname);
- }
-
- MEM_freeN(wgt);
-}
-
-void WM_manipulatorgrouptype_free_ptr(wmManipulatorGroupType *wgt)
-{
- BLI_assert(wgt == WM_manipulatorgrouptype_find(wgt->idname, false));
-
- BLI_ghash_remove(global_manipulatorgrouptype_hash, wgt->idname, NULL, NULL);
-
- manipulatorgrouptype_free(wgt);
-
- /* XXX, TODO, update the world! */
-}
-
-bool WM_manipulatorgrouptype_free(const char *idname)
-{
- wmManipulatorGroupType *wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname);
-
- if (wgt == NULL) {
- return false;
- }
-
- WM_manipulatorgrouptype_free_ptr(wgt);
-
- return true;
-}
-
-static void wm_manipulatorgrouptype_ghash_free_cb(wmManipulatorGroupType *wgt)
-{
- manipulatorgrouptype_free(wgt);
-}
-
-void wm_manipulatorgrouptype_free(void)
-{
- BLI_ghash_free(global_manipulatorgrouptype_hash, NULL, (GHashValFreeFP)wm_manipulatorgrouptype_ghash_free_cb);
- global_manipulatorgrouptype_hash = NULL;
-}
-
-/* called on initialize WM_init() */
-void wm_manipulatorgrouptype_init(void)
-{
- /* reserve size is set based on blender default setup */
- global_manipulatorgrouptype_hash = BLI_ghash_str_new_ex("wm_manipulatorgrouptype_init gh", 128);
-}
-
-/** \} */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
deleted file mode 100644
index a131c6c5069..00000000000
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
+++ /dev/null
@@ -1,142 +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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
- * \ingroup wm
- */
-
-
-#ifndef __WM_MANIPULATOR_INTERN_H__
-#define __WM_MANIPULATOR_INTERN_H__
-
-struct wmKeyConfig;
-struct wmManipulatorMap;
-struct ManipulatorGeomInfo;
-struct GHashIterator;
-
-#include "wm_manipulator_fn.h"
-
-/* -------------------------------------------------------------------- */
-/* wmManipulator */
-
-
-bool wm_manipulator_select_set_ex(
- struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select,
- bool use_array, bool use_callback);
-bool wm_manipulator_select_and_highlight(bContext *C, struct wmManipulatorMap *mmap, struct wmManipulator *mpr);
-
-void wm_manipulator_calculate_scale(struct wmManipulator *mpr, const bContext *C);
-void wm_manipulator_update(struct wmManipulator *mpr, const bContext *C, const bool refresh_map);
-
-int wm_manipulator_is_visible(struct wmManipulator *mpr);
-enum {
- WM_MANIPULATOR_IS_VISIBLE_UPDATE = (1 << 0),
- WM_MANIPULATOR_IS_VISIBLE_DRAW = (1 << 1),
-};
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorGroup */
-
-enum {
- TWEAK_MODAL_CANCEL = 1,
- TWEAK_MODAL_CONFIRM,
- TWEAK_MODAL_PRECISION_ON,
- TWEAK_MODAL_PRECISION_OFF,
- TWEAK_MODAL_SNAP_ON,
- TWEAK_MODAL_SNAP_OFF,
-};
-
-struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type(
- struct wmManipulatorMap *mmap, struct wmManipulatorGroupType *wgt);
-void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorGroup *mgroup);
-void wm_manipulatorgroup_manipulator_register(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr);
-struct wmManipulator *wm_manipulatorgroup_find_intersected_manipulator(
- const struct wmManipulatorGroup *mgroup, struct bContext *C, const struct wmEvent *event,
- int *r_part);
-void wm_manipulatorgroup_intersectable_manipulators_to_list(
- const struct wmManipulatorGroup *mgroup, struct ListBase *listbase);
-void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, const struct bContext *C);
-bool wm_manipulatorgroup_is_visible_in_drawstep(
- const struct wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep);
-
-void wm_manipulatorgrouptype_setup_keymap(
- struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf);
-
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorMap */
-
-typedef struct wmManipulatorMapSelectState {
- struct wmManipulator **items;
- int len, len_alloc;
-} wmManipulatorMapSelectState;
-
-struct wmManipulatorMap {
-
- struct wmManipulatorMapType *type;
- ListBase groups; /* wmManipulatorGroup */
-
- /* private, update tagging (enum defined in C source). */
- char update_flag[WM_MANIPULATORMAP_DRAWSTEP_MAX];
-
- /**
- * \brief Manipulator map runtime context
- *
- * Contains information about this manipulator-map. Currently
- * highlighted manipulator, currently selected manipulators, ...
- */
- struct {
- /* we redraw the manipulator-map when this changes */
- struct wmManipulator *highlight;
- /* User has clicked this manipulator and it gets all input. */
- struct wmManipulator *modal;
- /* array for all selected manipulators */
- struct wmManipulatorMapSelectState select;
- /* cursor location at point of entering modal (see: WM_MANIPULATOR_GRAB_CURSOR) */
- int event_xy[2];
- short event_grabcursor;
- } mmap_context;
-};
-
-/**
- * This is a container for all manipulator types that can be instantiated in a region.
- * (similar to dropboxes).
- *
- * \note There is only ever one of these for every (area, region) combination.
- */
-struct wmManipulatorMapType {
- struct wmManipulatorMapType *next, *prev;
- short spaceid, regionid;
- /* types of manipulator-groups for this manipulator-map type */
- ListBase grouptype_refs;
-
- /* eManipulatorMapTypeUpdateFlags */
- eWM_ManipulatorMapTypeUpdateFlag type_update_flag;
-};
-
-void wm_manipulatormap_select_array_clear(struct wmManipulatorMap *mmap);
-bool wm_manipulatormap_deselect_all(struct wmManipulatorMap *mmap);
-void wm_manipulatormap_select_array_shrink(struct wmManipulatorMap *mmap, int len_subtract);
-void wm_manipulatormap_select_array_push_back(struct wmManipulatorMap *mmap, wmManipulator *mpr);
-void wm_manipulatormap_select_array_remove(struct wmManipulatorMap *mmap, wmManipulator *mpr);
-
-#endif
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
deleted file mode 100644
index 7b06382b029..00000000000
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
+++ /dev/null
@@ -1,1196 +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) 2014 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/manipulators/intern/wm_manipulator_map.c
- * \ingroup wm
- */
-
-#include <string.h>
-
-#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_rect.h"
-#include "BLI_string.h"
-#include "BLI_ghash.h"
-
-#include "BKE_context.h"
-#include "BKE_global.h"
-
-#include "ED_screen.h"
-#include "ED_view3d.h"
-
-#include "GPU_glew.h"
-#include "GPU_matrix.h"
-#include "GPU_select.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-#include "wm_event_system.h"
-
-/* for tool-tips */
-#include "UI_interface.h"
-
-#include "DEG_depsgraph.h"
-
-/* own includes */
-#include "wm_manipulator_wmapi.h"
-#include "wm_manipulator_intern.h"
-
-/**
- * Store all manipulator-maps here. Anyone who wants to register a manipulator for a certain
- * area type can query the manipulator-map to do so.
- */
-static ListBase manipulatormaptypes = {NULL, NULL};
-
-/**
- * Update when manipulator-map types change.
- */
-/* so operator removal can trigger update */
-typedef enum eWM_ManipulatorGroupTypeGlobalFlag {
- WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0),
- WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1),
-} eWM_ManipulatorGroupTypeGlobalFlag;
-
-static eWM_ManipulatorGroupTypeGlobalFlag wm_mmap_type_update_flag = 0;
-
-/**
- * Manipulator-map update tagging.
- */
-enum {
- /** #manipulatormap_prepare_drawing has run */
- MANIPULATORMAP_IS_PREPARE_DRAW = (1 << 0),
- MANIPULATORMAP_IS_REFRESH_CALLBACK = (1 << 1),
-};
-
-
-/* -------------------------------------------------------------------- */
-/** \name wmManipulatorMap Selection Array API
- *
- * Just handle ``wm_manipulatormap_select_array_*``, not flags or callbacks.
- *
- * \{ */
-
-static void wm_manipulatormap_select_array_ensure_len_alloc(wmManipulatorMap *mmap, int len)
-{
- wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
- if (len <= msel->len_alloc) {
- return;
- }
- msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * len);
- msel->len_alloc = len;
-}
-
-void wm_manipulatormap_select_array_clear(wmManipulatorMap *mmap)
-{
- wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
- MEM_SAFE_FREE(msel->items);
- msel->len = 0;
- msel->len_alloc = 0;
-}
-
-void wm_manipulatormap_select_array_shrink(wmManipulatorMap *mmap, int len_subtract)
-{
- wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
- msel->len -= len_subtract;
- if (msel->len <= 0) {
- wm_manipulatormap_select_array_clear(mmap);
- }
- else {
- if (msel->len < msel->len_alloc / 2) {
- msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len);
- msel->len_alloc = msel->len;
- }
- }
-}
-
-void wm_manipulatormap_select_array_push_back(wmManipulatorMap *mmap, wmManipulator *mpr)
-{
- wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
- BLI_assert(msel->len <= msel->len_alloc);
- if (msel->len == msel->len_alloc) {
- msel->len_alloc = (msel->len + 1) * 2;
- msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len_alloc);
- }
- msel->items[msel->len++] = mpr;
-}
-
-void wm_manipulatormap_select_array_remove(wmManipulatorMap *mmap, wmManipulator *mpr)
-{
- wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
- /* remove manipulator from selected_manipulators array */
- for (int i = 0; i < msel->len; i++) {
- if (msel->items[i] == mpr) {
- for (int j = i; j < (msel->len - 1); j++) {
- msel->items[j] = msel->items[j + 1];
- }
- wm_manipulatormap_select_array_shrink(mmap, 1);
- break;
- }
- }
-
-}
-
-/** \} */
-
-
-/* -------------------------------------------------------------------- */
-/** \name wmManipulatorMap
- *
- * \{ */
-
-/**
- * Creates a manipulator-map with all registered manipulators for that type
- */
-wmManipulatorMap *WM_manipulatormap_new_from_type(
- const struct wmManipulatorMapType_Params *mmap_params)
-{
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(mmap_params);
- wmManipulatorMap *mmap;
-
- mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap");
- mmap->type = mmap_type;
- WM_manipulatormap_tag_refresh(mmap);
-
- /* create all manipulator-groups for this manipulator-map. We may create an empty one
- * too in anticipation of manipulators from operators etc */
- for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) {
- wm_manipulatorgroup_new_from_type(mmap, wgt_ref->type);
- }
-
- return mmap;
-}
-
-void wm_manipulatormap_remove(wmManipulatorMap *mmap)
-{
- /* Clear first so further calls don't waste time trying to maintain correct array state. */
- wm_manipulatormap_select_array_clear(mmap);
-
- for (wmManipulatorGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) {
- mgroup_next = mgroup->next;
- BLI_assert(mgroup->parent_mmap == mmap);
- wm_manipulatorgroup_free(NULL, mgroup);
- }
- BLI_assert(BLI_listbase_is_empty(&mmap->groups));
-
- MEM_freeN(mmap);
-}
-
-
-wmManipulatorGroup *WM_manipulatormap_group_find(
- struct wmManipulatorMap *mmap,
- const char *idname)
-{
- wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
- if (wgt) {
- return WM_manipulatormap_group_find_ptr(mmap, wgt);
- }
- return NULL;
-}
-
-wmManipulatorGroup *WM_manipulatormap_group_find_ptr(
- struct wmManipulatorMap *mmap,
- const struct wmManipulatorGroupType *wgt)
-{
- for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
- if (mgroup->type == wgt) {
- return mgroup;
- }
- }
- return NULL;
-}
-
-const ListBase *WM_manipulatormap_group_list(wmManipulatorMap *mmap)
-{
- return &mmap->groups;
-}
-
-bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap)
-{
- return mmap->mmap_context.select.len != 0;
-}
-
-/**
- * \note We could use a callback to define bounds, for now just use matrix location.
- */
-bool WM_manipulatormap_minmax(
- const wmManipulatorMap *mmap, bool UNUSED(use_hidden), bool use_select,
- float r_min[3], float r_max[3])
-{
- if (use_select) {
- int i;
- for (i = 0; i < mmap->mmap_context.select.len; i++) {
- minmax_v3v3_v3(r_min, r_max, mmap->mmap_context.select.items[i]->matrix_basis[3]);
- }
- return i != 0;
- }
- else {
- bool ok = false;
- BLI_assert(!"TODO");
- return ok;
- }
-}
-
-/**
- * Creates and returns idname hash table for (visible) manipulators in \a mmap
- *
- * \param poll Polling function for excluding manipulators.
- * \param data Custom data passed to \a poll
- *
- * TODO(campbell): this uses unreliable order,
- * best we use an iterator function instead of a hash.
- */
-static GHash *WM_manipulatormap_manipulator_hash_new(
- const bContext *C, wmManipulatorMap *mmap,
- bool (*poll)(const wmManipulator *, void *),
- void *data, const bool include_hidden)
-{
- GHash *hash = BLI_ghash_ptr_new(__func__);
-
- /* collect manipulators */
- for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
- if (WM_manipulator_group_type_poll(C, mgroup->type)) {
- for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
- if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) &&
- (!poll || poll(mpr, data)))
- {
- BLI_ghash_insert(hash, mpr, mpr);
- }
- }
- }
- }
-
- return hash;
-}
-
-void WM_manipulatormap_tag_refresh(wmManipulatorMap *mmap)
-{
- if (mmap) {
- /* We might want only to refresh some, for tag all steps. */
- for (int i = 0; i < WM_MANIPULATORMAP_DRAWSTEP_MAX; i++) {
- mmap->update_flag[i] |= (
- MANIPULATORMAP_IS_PREPARE_DRAW |
- MANIPULATORMAP_IS_REFRESH_CALLBACK);
- }
- }
-}
-
-static bool manipulator_prepare_drawing(
- wmManipulatorMap *mmap, wmManipulator *mpr,
- const bContext *C, ListBase *draw_manipulators,
- const eWM_ManipulatorMapDrawStep drawstep)
-{
- int do_draw = wm_manipulator_is_visible(mpr);
- if (do_draw == 0) {
- /* skip */
- }
- else {
- /* Ensure we get RNA updates */
- if (do_draw & WM_MANIPULATOR_IS_VISIBLE_UPDATE) {
- /* hover manipulators need updating, even if we don't draw them */
- wm_manipulator_update(mpr, C, (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_PREPARE_DRAW) != 0);
- }
- if (do_draw & WM_MANIPULATOR_IS_VISIBLE_DRAW) {
- BLI_addhead(draw_manipulators, BLI_genericNodeN(mpr));
- }
- return true;
- }
-
- return false;
-}
-
-/**
- * Update manipulators of \a mmap to prepare for drawing. Adds all manipulators that
- * should be drawn to list \a draw_manipulators, note that added items need freeing.
- */
-static void manipulatormap_prepare_drawing(
- wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators,
- const eWM_ManipulatorMapDrawStep drawstep)
-{
- if (!mmap || BLI_listbase_is_empty(&mmap->groups))
- return;
- wmManipulator *mpr_modal = mmap->mmap_context.modal;
-
- /* only active manipulator needs updating */
- if (mpr_modal) {
- if ((mpr_modal->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL) == 0) {
- if (wm_manipulatorgroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) {
- if (manipulator_prepare_drawing(mmap, mpr_modal, C, draw_manipulators, drawstep)) {
- mmap->update_flag[drawstep] &= ~MANIPULATORMAP_IS_PREPARE_DRAW;
- }
- }
- /* don't draw any other manipulators */
- return;
- }
- }
-
- for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
- /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */
- if (!wm_manipulatorgroup_is_visible_in_drawstep(mgroup, drawstep) ||
- !WM_manipulator_group_type_poll(C, mgroup->type))
- {
- continue;
- }
-
- /* needs to be initialized on first draw */
- /* XXX weak: Manipulator-group may skip refreshing if it's invisible (map gets untagged nevertheless) */
- if (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_REFRESH_CALLBACK) {
- /* force refresh again. */
- mgroup->init_flag &= ~WM_MANIPULATORGROUP_INIT_REFRESH;
- }
- /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */
- wm_manipulatorgroup_ensure_initialized(mgroup, C);
-
- /* prepare drawing */
- if (mgroup->type->draw_prepare) {
- mgroup->type->draw_prepare(C, mgroup);
- }
-
- for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
- manipulator_prepare_drawing(mmap, mpr, C, draw_manipulators, drawstep);
- }
- }
-
- mmap->update_flag[drawstep] &=
- ~(MANIPULATORMAP_IS_REFRESH_CALLBACK |
- MANIPULATORMAP_IS_PREPARE_DRAW);
-}
-
-/**
- * Draw all visible manipulators in \a mmap.
- * Uses global draw_manipulators listbase.
- */
-static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators)
-{
- /* Can be empty if we're dynamically added and removed. */
- if ((mmap == NULL) || BLI_listbase_is_empty(&mmap->groups)) {
- return;
- }
-
- /* TODO this will need it own shader probably? don't think it can be handled from that point though. */
-/* const bool use_lighting = (U.manipulator_flag & V3D_MANIPULATOR_SHADED) != 0; */
-
- bool is_depth_prev = false;
-
- /* draw_manipulators contains all visible manipulators - draw them */
- for (LinkData *link = draw_manipulators->first, *link_next; link; link = link_next) {
- wmManipulator *mpr = link->data;
- link_next = link->next;
-
- bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0;
-
- /* Weak! since we don't 100% support depth yet (select ignores depth) always show highlighted */
- if (is_depth && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)) {
- is_depth = false;
- }
-
- if (is_depth == is_depth_prev) {
- /* pass */
- }
- else {
- if (is_depth) {
- glEnable(GL_DEPTH_TEST);
- }
- else {
- glDisable(GL_DEPTH_TEST);
- }
- is_depth_prev = is_depth;
- }
-
- /* XXX force AntiAlias Manipulators. */
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_POLYGON_SMOOTH);
-
- mpr->type->draw(C, mpr);
-
- glDisable(GL_LINE_SMOOTH);
- glDisable(GL_POLYGON_SMOOTH);
-
- /* free/remove manipulator link after drawing */
- BLI_freelinkN(draw_manipulators, link);
- }
-
- if (is_depth_prev) {
- glDisable(GL_DEPTH_TEST);
- }
-}
-
-void WM_manipulatormap_draw(
- wmManipulatorMap *mmap, const bContext *C,
- const eWM_ManipulatorMapDrawStep drawstep)
-{
- if (!WM_manipulator_context_check_drawstep(C, drawstep)) {
- return;
- }
-
- ListBase draw_manipulators = {NULL};
-
- manipulatormap_prepare_drawing(mmap, C, &draw_manipulators, drawstep);
- manipulators_draw_list(mmap, C, &draw_manipulators);
- BLI_assert(BLI_listbase_is_empty(&draw_manipulators));
-}
-
-static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible_manipulators)
-{
- int select_id = 0;
- wmManipulator *mpr;
-
- /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */
- bool is_depth_prev = false;
-
- for (LinkData *link = visible_manipulators->first; link; link = link->next) {
- mpr = link->data;
-
- bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0;
- if (is_depth == is_depth_prev) {
- /* pass */
- }
- else {
- if (is_depth) {
- glEnable(GL_DEPTH_TEST);
- }
- else {
- glDisable(GL_DEPTH_TEST);
- }
- is_depth_prev = is_depth;
- }
-
- /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected manipulator part id */
-
- mpr->type->draw_select(C, mpr, select_id << 8);
-
-
- select_id++;
- }
-
- if (is_depth_prev) {
- glDisable(GL_DEPTH_TEST);
- }
-}
-
-static int manipulator_find_intersected_3d_intern(
- ListBase *visible_manipulators, const bContext *C, const int co[2],
- const int hotspot)
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = CTX_wm_region(C);
- View3D *v3d = sa->spacedata.first;
- rcti rect;
- /* Almost certainly overkill, but allow for many custom manipulators. */
- GLuint buffer[MAXPICKBUF];
- short hits;
- const bool do_passes = GPU_select_query_check_active();
-
- BLI_rcti_init_pt_radius(&rect, co, hotspot);
-
- ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, &rect);
-
- if (do_passes)
- GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0);
- else
- GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_ALL, 0);
- /* do the drawing */
- manipulator_draw_select_3D_loop(C, visible_manipulators);
-
- hits = GPU_select_end();
-
- if (do_passes && (hits > 0)) {
- GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits);
- manipulator_draw_select_3D_loop(C, visible_manipulators);
- GPU_select_end();
- }
-
- ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, NULL);
-
- const GLuint *hit_near = GPU_select_buffer_near(buffer, hits);
-
- return hit_near ? hit_near[3] : -1;
-}
-
-/**
- * Try to find a 3D manipulator at screen-space coordinate \a co. Uses OpenGL picking.
- */
-static wmManipulator *manipulator_find_intersected_3d(
- bContext *C, const int co[2], ListBase *visible_manipulators,
- int *r_part)
-{
- wmManipulator *result = NULL;
- int hit = -1;
-
- int hotspot_radii[] = {
- 3 * U.pixelsize,
- /* This runs on mouse move, careful doing too many tests! */
- 10 * U.pixelsize,
- };
-
- *r_part = 0;
-
- /* set up view matrices */
- view3d_operator_needs_opengl(C);
-
- hit = -1;
-
- for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) {
- hit = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, hotspot_radii[i]);
- if (hit != -1) {
- break;
- }
- }
-
- if (hit != -1) {
- LinkData *link = BLI_findlink(visible_manipulators, hit >> 8);
- if (link != NULL) {
- *r_part = hit & 255;
- result = link->data;
- }
- else {
- /* All manipulators should use selection ID they're given as part of the callback,
- * if they don't it will attempt tp lookup non-existing index. */
- BLI_assert(0);
- }
- }
-
- return result;
-}
-
-/**
- * Try to find a manipulator under the mouse position. 2D intersections have priority over
- * 3D ones (could check for smallest screen-space distance but not needed right now).
- */
-wmManipulator *wm_manipulatormap_highlight_find(
- wmManipulatorMap *mmap, bContext *C, const wmEvent *event,
- int *r_part)
-{
- wmManipulator *mpr = NULL;
- ListBase visible_3d_manipulators = {NULL};
- bool do_step[WM_MANIPULATORMAP_DRAWSTEP_MAX];
-
- for (int i = 0; i < ARRAY_SIZE(do_step); i++) {
- do_step[i] = WM_manipulator_context_check_drawstep(C, i);
- }
-
- for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
-
- /* If it were important we could initialize here,
- * but this only happens when events are handled before drawing,
- * just skip to keep code-path for initializing manipulators simple. */
- if ((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0) {
- continue;
- }
-
- if (WM_manipulator_group_type_poll(C, mgroup->type)) {
- eWM_ManipulatorMapDrawStep step;
- if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
- step = WM_MANIPULATORMAP_DRAWSTEP_3D;
- }
- else {
- step = WM_MANIPULATORMAP_DRAWSTEP_2D;
- }
-
- if (do_step[step]) {
- if ((mmap->update_flag[step] & MANIPULATORMAP_IS_REFRESH_CALLBACK) &&
- (mgroup->type->refresh != NULL))
- {
- mgroup->type->refresh(C, mgroup);
- /* cleared below */
- }
- if (step == WM_MANIPULATORMAP_DRAWSTEP_3D) {
- wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators);
- }
- else if (step == WM_MANIPULATORMAP_DRAWSTEP_2D) {
- if ((mpr = wm_manipulatorgroup_find_intersected_manipulator(mgroup, C, event, r_part))) {
- break;
- }
- }
- }
- }
- }
-
- if (!BLI_listbase_is_empty(&visible_3d_manipulators)) {
- /* 2D manipulators get priority. */
- if (mpr == NULL) {
- mpr = manipulator_find_intersected_3d(C, event->mval, &visible_3d_manipulators, r_part);
- }
- BLI_freelistN(&visible_3d_manipulators);
- }
-
- mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_3D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK;
- mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_2D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK;
-
- return mpr;
-}
-
-void WM_manipulatormap_add_handlers(ARegion *ar, wmManipulatorMap *mmap)
-{
- wmEventHandler *handler;
-
- for (handler = ar->handlers.first; handler; handler = handler->next) {
- if (handler->manipulator_map == mmap) {
- return;
- }
- }
-
- handler = MEM_callocN(sizeof(wmEventHandler), "manipulator handler");
-
- BLI_assert(mmap == ar->manipulator_map);
- handler->manipulator_map = mmap;
- BLI_addtail(&ar->handlers, handler);
-}
-
-void wm_manipulatormaps_handled_modal_update(
- bContext *C, wmEvent *event, wmEventHandler *handler)
-{
- const bool modal_running = (handler->op != NULL);
-
- /* happens on render or when joining areas */
- if (!handler->op_region || !handler->op_region->manipulator_map) {
- return;
- }
-
- wmManipulatorMap *mmap = handler->op_region->manipulator_map;
- wmManipulator *mpr = wm_manipulatormap_modal_get(mmap);
- ScrArea *area = CTX_wm_area(C);
- ARegion *region = CTX_wm_region(C);
-
- wm_manipulatormap_handler_context(C, handler);
-
- /* regular update for running operator */
- if (modal_running) {
- wmManipulatorOpElem *mpop = mpr ? WM_manipulator_operator_get(mpr, mpr->highlight_part) : NULL;
- if (mpr && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) {
- wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal;
- if (modal_fn != NULL) {
- int retval = modal_fn(C, mpr, event, 0);
- /* The manipulator is tried to the operator, we can't choose when to exit. */
- BLI_assert(retval & OPERATOR_RUNNING_MODAL);
- UNUSED_VARS_NDEBUG(retval);
- }
- }
- }
- /* operator not running anymore */
- else {
- wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
- if (mpr) {
- /* This isn't defined if it ends because of success of cancel, we may want to change. */
- bool cancel = true;
- if (mpr->type->exit) {
- mpr->type->exit(C, mpr, cancel);
- }
- wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false);
- }
- }
-
- /* restore the area */
- CTX_wm_area_set(C, area);
- CTX_wm_region_set(C, region);
-}
-
-/**
- * Deselect all selected manipulators in \a mmap.
- * \return if selection has changed.
- */
-bool wm_manipulatormap_deselect_all(wmManipulatorMap *mmap)
-{
- wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
-
- if (msel->items == NULL || msel->len == 0) {
- return false;
- }
-
- for (int i = 0; i < msel->len; i++) {
- wm_manipulator_select_set_ex(mmap, msel->items[i], false, false, true);
- }
-
- wm_manipulatormap_select_array_clear(mmap);
-
- /* always return true, we already checked
- * if there's anything to deselect */
- return true;
-}
-
-BLI_INLINE bool manipulator_selectable_poll(const wmManipulator *mpr, void *UNUSED(data))
-{
- return (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT);
-}
-
-/**
- * Select all selectable manipulators in \a mmap.
- * \return if selection has changed.
- */
-static bool wm_manipulatormap_select_all_intern(
- bContext *C, wmManipulatorMap *mmap)
-{
- wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
- /* GHash is used here to avoid having to loop over all manipulators twice (once to
- * get tot_sel for allocating, once for actually selecting). Instead we collect
- * selectable manipulators in hash table and use this to get tot_sel and do selection */
-
- GHash *hash = WM_manipulatormap_manipulator_hash_new(C, mmap, manipulator_selectable_poll, NULL, true);
- GHashIterator gh_iter;
- int i;
- bool changed = false;
-
- wm_manipulatormap_select_array_ensure_len_alloc(mmap, BLI_ghash_len(hash));
-
- GHASH_ITER_INDEX (gh_iter, hash, i) {
- wmManipulator *mpr_iter = BLI_ghashIterator_getValue(&gh_iter);
- WM_manipulator_select_set(mmap, mpr_iter, true);
- }
- /* highlight first manipulator */
- wm_manipulatormap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part);
-
- BLI_assert(BLI_ghash_len(hash) == msel->len);
-
- BLI_ghash_free(hash, NULL, NULL);
- return changed;
-}
-
-/**
- * Select/Deselect all selectable manipulators in \a mmap.
- * \return if selection has changed.
- *
- * TODO select all by type
- */
-bool WM_manipulatormap_select_all(bContext *C, wmManipulatorMap *mmap, const int action)
-{
- bool changed = false;
-
- switch (action) {
- case SEL_SELECT:
- changed = wm_manipulatormap_select_all_intern(C, mmap);
- break;
- case SEL_DESELECT:
- changed = wm_manipulatormap_deselect_all(mmap);
- break;
- default:
- BLI_assert(0);
- break;
- }
-
- if (changed)
- WM_event_add_mousemove(C);
-
- return changed;
-}
-
-/**
- * Prepare context for manipulator handling (but only if area/region is
- * part of screen). Version of #wm_handler_op_context for manipulators.
- */
-void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler)
-{
- bScreen *screen = CTX_wm_screen(C);
-
- if (screen) {
- if (handler->op_area == NULL) {
- /* do nothing in this context */
- }
- else {
- ScrArea *sa;
-
- for (sa = screen->areabase.first; sa; sa = sa->next)
- if (sa == handler->op_area)
- break;
- if (sa == NULL) {
- /* when changing screen layouts with running modal handlers (like render display), this
- * is not an error to print */
- if (handler->manipulator_map == NULL)
- printf("internal error: modal manipulator-map handler has invalid area\n");
- }
- else {
- ARegion *ar;
- CTX_wm_area_set(C, sa);
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar == handler->op_region)
- break;
- /* XXX no warning print here, after full-area and back regions are remade */
- if (ar)
- CTX_wm_region_set(C, ar);
- }
- }
- }
-}
-
-bool WM_manipulatormap_cursor_set(const wmManipulatorMap *mmap, wmWindow *win)
-{
- wmManipulator *mpr = mmap->mmap_context.highlight;
- if (mpr && mpr->type->cursor_get) {
- WM_cursor_set(win, mpr->type->cursor_get(mpr));
- return true;
- }
-
- return false;
-}
-
-bool wm_manipulatormap_highlight_set(
- wmManipulatorMap *mmap, const bContext *C, wmManipulator *mpr, int part)
-{
- if ((mpr != mmap->mmap_context.highlight) ||
- (mpr && part != mpr->highlight_part))
- {
- if (mmap->mmap_context.highlight) {
- mmap->mmap_context.highlight->state &= ~WM_MANIPULATOR_STATE_HIGHLIGHT;
- mmap->mmap_context.highlight->highlight_part = -1;
- }
-
- mmap->mmap_context.highlight = mpr;
-
- if (mpr) {
- mpr->state |= WM_MANIPULATOR_STATE_HIGHLIGHT;
- mpr->highlight_part = part;
-
- if (C && mpr->type->cursor_get) {
- wmWindow *win = CTX_wm_window(C);
- win->lastcursor = win->cursor;
- WM_cursor_set(win, mpr->type->cursor_get(mpr));
- }
- }
- else {
- if (C) {
- wmWindow *win = CTX_wm_window(C);
- WM_cursor_set(win, win->lastcursor);
- }
- }
-
- /* tag the region for redraw */
- if (C) {
- ARegion *ar = CTX_wm_region(C);
- ED_region_tag_redraw(ar);
- }
-
- return true;
- }
-
- return false;
-}
-
-wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap)
-{
- return mmap->mmap_context.highlight;
-}
-
-/**
- * Caller should call exit when (enable == False).
- */
-void wm_manipulatormap_modal_set(
- wmManipulatorMap *mmap, bContext *C, wmManipulator *mpr, const wmEvent *event, bool enable)
-{
- if (enable) {
- BLI_assert(mmap->mmap_context.modal == NULL);
- wmWindow *win = CTX_wm_window(C);
-
- WM_tooltip_clear(C, win);
-
- if (mpr->type->invoke &&
- (mpr->type->modal || mpr->custom_modal))
- {
- const int retval = mpr->type->invoke(C, mpr, event);
- if ((retval & OPERATOR_RUNNING_MODAL) == 0) {
- return;
- }
- }
-
- mpr->state |= WM_MANIPULATOR_STATE_MODAL;
- mmap->mmap_context.modal = mpr;
-
- if ((mpr->flag & WM_MANIPULATOR_GRAB_CURSOR) &&
- (event->is_motion_absolute == false))
- {
- WM_cursor_grab_enable(win, true, true, NULL);
- copy_v2_v2_int(mmap->mmap_context.event_xy, &event->x);
- mmap->mmap_context.event_grabcursor = win->grabcursor;
- }
- else {
- mmap->mmap_context.event_xy[0] = INT_MAX;
- }
-
- struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part);
- if (mpop && mpop->type) {
- const int retval = WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr);
- if ((retval & OPERATOR_RUNNING_MODAL) == 0) {
- wm_manipulatormap_modal_set(mmap, C, mpr, event, false);
- }
-
- /* we failed to hook the manipulator to the operator handler or operator was cancelled, return */
- if (!mmap->mmap_context.modal) {
- mpr->state &= ~WM_MANIPULATOR_STATE_MODAL;
- MEM_SAFE_FREE(mpr->interaction_data);
- }
- return;
- }
- }
- else {
- BLI_assert(ELEM(mmap->mmap_context.modal, NULL, mpr));
-
- /* deactivate, manipulator but first take care of some stuff */
- if (mpr) {
- mpr->state &= ~WM_MANIPULATOR_STATE_MODAL;
- MEM_SAFE_FREE(mpr->interaction_data);
- }
- mmap->mmap_context.modal = NULL;
-
- if (C) {
- wmWindow *win = CTX_wm_window(C);
- if (mmap->mmap_context.event_xy[0] != INT_MAX) {
- /* Check if some other part of Blender (typically operators)
- * have adjusted the grab mode since it was set.
- * If so: warp, so we have a predictable outcome. */
- if (mmap->mmap_context.event_grabcursor == win->grabcursor) {
- WM_cursor_grab_disable(win, mmap->mmap_context.event_xy);
- }
- else {
- WM_cursor_warp(win, UNPACK2(mmap->mmap_context.event_xy));
- }
- }
- ED_region_tag_redraw(CTX_wm_region(C));
- WM_event_add_mousemove(C);
- }
-
- mmap->mmap_context.event_xy[0] = INT_MAX;
- }
-}
-
-wmManipulator *wm_manipulatormap_modal_get(wmManipulatorMap *mmap)
-{
- return mmap->mmap_context.modal;
-}
-
-wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len)
-{
- *r_selected_len = mmap->mmap_context.select.len;
- return mmap->mmap_context.select.items;
-}
-
-ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap)
-{
- return &mmap->groups;
-}
-
-void WM_manipulatormap_message_subscribe(
- bContext *C, wmManipulatorMap *mmap, ARegion *ar, struct wmMsgBus *mbus)
-{
- for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
- if (!WM_manipulator_group_type_poll(C, mgroup->type)) {
- continue;
- }
- for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
- if (mpr->flag & WM_MANIPULATOR_HIDDEN) {
- continue;
- }
- WM_manipulator_target_property_subscribe_all(mpr, mbus, ar);
- }
- if (mgroup->type->message_subscribe != NULL) {
- mgroup->type->message_subscribe(C, mgroup, mbus);
- }
- }
-}
-
-/** \} */ /* wmManipulatorMap */
-
-
-/* -------------------------------------------------------------------- */
-/** \name Tooltip Handling
- *
- * \{ */
-
-struct ARegion *WM_manipulatormap_tooltip_init(
- struct bContext *C, struct ARegion *ar, bool *r_exit_on_event)
-{
- wmManipulatorMap *mmap = ar->manipulator_map;
- *r_exit_on_event = true;
- if (mmap) {
- wmManipulator *mpr = mmap->mmap_context.highlight;
- if (mpr) {
- return UI_tooltip_create_from_manipulator(C, mpr);
- }
- }
- return NULL;
-}
-
-/** \} */ /* wmManipulatorMapType */
-
-/* -------------------------------------------------------------------- */
-/** \name wmManipulatorMapType
- *
- * \{ */
-
-wmManipulatorMapType *WM_manipulatormaptype_find(
- const struct wmManipulatorMapType_Params *mmap_params)
-{
- for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) {
- if (mmap_type->spaceid == mmap_params->spaceid &&
- mmap_type->regionid == mmap_params->regionid)
- {
- return mmap_type;
- }
- }
-
- return NULL;
-}
-
-wmManipulatorMapType *WM_manipulatormaptype_ensure(
- const struct wmManipulatorMapType_Params *mmap_params)
-{
- wmManipulatorMapType *mmap_type = WM_manipulatormaptype_find(mmap_params);
-
- if (mmap_type) {
- return mmap_type;
- }
-
- mmap_type = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list");
- mmap_type->spaceid = mmap_params->spaceid;
- mmap_type->regionid = mmap_params->regionid;
- BLI_addhead(&manipulatormaptypes, mmap_type);
-
- return mmap_type;
-}
-
-void wm_manipulatormaptypes_free(void)
-{
- for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first, *mmap_type_next;
- mmap_type;
- mmap_type = mmap_type_next)
- {
- mmap_type_next = mmap_type->next;
- for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next;
- wgt_ref;
- wgt_ref = wgt_next)
- {
- wgt_next = wgt_ref->next;
- WM_manipulatormaptype_group_free(wgt_ref);
- }
- MEM_freeN(mmap_type);
- }
-}
-
-/**
- * Initialize keymaps for all existing manipulator-groups
- */
-void wm_manipulators_keymap(wmKeyConfig *keyconf)
-{
- /* we add this item-less keymap once and use it to group manipulator-group keymaps into it */
- WM_keymap_find(keyconf, "Manipulators", 0, 0);
-
- for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) {
- for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) {
- wm_manipulatorgrouptype_setup_keymap(wgt_ref->type, keyconf);
- }
- }
-}
-
-/** \} */ /* wmManipulatorMapType */
-
-/* -------------------------------------------------------------------- */
-/** \name Updates for Dynamic Type Registraion
- *
- * \{ */
-
-
-void WM_manipulatorconfig_update_tag_init(
- wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt)
-{
- /* tag for update on next use */
- mmap_type->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT);
- wgt->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT);
-
- wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT;
-}
-
-void WM_manipulatorconfig_update_tag_remove(
- wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt)
-{
- /* tag for update on next use */
- mmap_type->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE;
- wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE;
-
- wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE;
-}
-
-/**
- * Run incase new types have been added (runs often, early exit where possible).
- * Follows #WM_keyconfig_update concentions.
- */
-void WM_manipulatorconfig_update(struct Main *bmain)
-{
- if (G.background)
- return;
-
- if (wm_mmap_type_update_flag == 0)
- return;
-
- if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) {
- for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first;
- mmap_type;
- mmap_type = mmap_type->next)
- {
- if (mmap_type->type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) {
- mmap_type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE;
- for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_ref_next;
- wgt_ref;
- wgt_ref = wgt_ref_next)
- {
- wgt_ref_next = wgt_ref->next;
- if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_REMOVE) {
- wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE;
- WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type);
- }
- }
- }
- }
-
- wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE;
- }
-
- if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT) {
- for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first;
- mmap_type;
- mmap_type = mmap_type->next)
- {
- const uchar type_update_all = WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT;
- if (mmap_type->type_update_flag & type_update_all) {
- mmap_type->type_update_flag &= ~type_update_all;
- for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first;
- wgt_ref;
- wgt_ref = wgt_ref->next)
- {
- if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) {
- WM_manipulatormaptype_group_init_runtime_keymap(bmain, wgt_ref->type);
- wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT;
- }
-
- if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) {
- WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type);
- wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT;
- }
- }
- }
- }
-
- wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT;
- }
-}
-
-/** \} */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
deleted file mode 100644
index 137e8f5639d..00000000000
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
+++ /dev/null
@@ -1,364 +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/windowmanager/manipulators/intern/wm_manipulator_target_props.c
- * \ingroup wm
- */
-
-#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
-#include "BLI_string_utils.h"
-
-#include "BKE_context.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "RNA_access.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-#include "WM_message.h"
-
-#include "wm.h"
-
-#include "ED_screen.h"
-#include "ED_view3d.h"
-
-/* own includes */
-#include "wm_manipulator_wmapi.h"
-#include "wm_manipulator_intern.h"
-
-/* -------------------------------------------------------------------- */
-
-/** \name Property Definition
- * \{ */
-
-BLI_INLINE wmManipulatorProperty *wm_manipulator_target_property_array(wmManipulator *mpr)
-{
- return (wmManipulatorProperty *)(POINTER_OFFSET(mpr, mpr->type->struct_size));
-}
-
-wmManipulatorProperty *WM_manipulator_target_property_array(wmManipulator *mpr)
-{
- return wm_manipulator_target_property_array(mpr);
-}
-
-wmManipulatorProperty *WM_manipulator_target_property_at_index(wmManipulator *mpr, int index)
-{
- BLI_assert(index < mpr->type->target_property_defs_len);
- BLI_assert(index != -1);
- wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr);
- return &mpr_prop_array[index];
-}
-
-wmManipulatorProperty *WM_manipulator_target_property_find(wmManipulator *mpr, const char *idname)
-{
- int index = BLI_findstringindex(
- &mpr->type->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname));
- if (index != -1) {
- return WM_manipulator_target_property_at_index(mpr, index);
- }
- else {
- return NULL;
- }
-}
-
-void WM_manipulator_target_property_def_rna_ptr(
- wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type,
- PointerRNA *ptr, PropertyRNA *prop, int index)
-{
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type);
-
- /* if manipulator evokes an operator we cannot use it for property manipulation */
- BLI_assert(mpr->op_data == NULL);
-
- mpr_prop->type = mpr_prop_type;
-
- mpr_prop->ptr = *ptr;
- mpr_prop->prop = prop;
- mpr_prop->index = index;
-
- if (mpr->type->property_update) {
- mpr->type->property_update(mpr, mpr_prop);
- }
-}
-
-void WM_manipulator_target_property_def_rna(
- wmManipulator *mpr, const char *idname,
- PointerRNA *ptr, const char *propname, int index)
-{
- const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname);
- PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
- WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index);
-}
-
-void WM_manipulator_target_property_def_func_ptr(
- wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type,
- const wmManipulatorPropertyFnParams *params)
-{
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type);
-
- /* if manipulator evokes an operator we cannot use it for property manipulation */
- BLI_assert(mpr->op_data == NULL);
-
- mpr_prop->type = mpr_prop_type;
-
- mpr_prop->custom_func.value_get_fn = params->value_get_fn;
- mpr_prop->custom_func.value_set_fn = params->value_set_fn;
- mpr_prop->custom_func.range_get_fn = params->range_get_fn;
- mpr_prop->custom_func.free_fn = params->free_fn;
- mpr_prop->custom_func.user_data = params->user_data;
-
- if (mpr->type->property_update) {
- mpr->type->property_update(mpr, mpr_prop);
- }
-}
-
-void WM_manipulator_target_property_def_func(
- wmManipulator *mpr, const char *idname,
- const wmManipulatorPropertyFnParams *params)
-{
- const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname);
- WM_manipulator_target_property_def_func_ptr(mpr, mpr_prop_type, params);
-}
-
-void WM_manipulator_target_property_clear_rna_ptr(
- wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type)
-{
- wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type);
-
- /* if manipulator evokes an operator we cannot use it for property manipulation */
- BLI_assert(mpr->op_data == NULL);
-
- mpr_prop->type = NULL;
-
- mpr_prop->ptr = PointerRNA_NULL;
- mpr_prop->prop = NULL;
- mpr_prop->index = -1;
-}
-
-void WM_manipulator_target_property_clear_rna(
- wmManipulator *mpr, const char *idname)
-{
- const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname);
- WM_manipulator_target_property_clear_rna_ptr(mpr, mpr_prop_type);
-}
-
-
-/** \} */
-
-
-/* -------------------------------------------------------------------- */
-
-/** \name Property Access
- * \{ */
-
-bool WM_manipulator_target_property_is_valid_any(wmManipulator *mpr)
-{
- wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr);
- for (int i = 0; i < mpr->type->target_property_defs_len; i++) {
- wmManipulatorProperty *mpr_prop = &mpr_prop_array[i];
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- return true;
- }
- }
- return false;
-}
-
-bool WM_manipulator_target_property_is_valid(const wmManipulatorProperty *mpr_prop)
-{
- return ((mpr_prop->prop != NULL) ||
- (mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn));
-}
-
-float WM_manipulator_target_property_value_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
-{
- if (mpr_prop->custom_func.value_get_fn) {
- float value = 0.0f;
- BLI_assert(mpr_prop->type->array_length == 1);
- mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, &value);
- return value;
- }
-
- if (mpr_prop->index == -1) {
- return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
- }
- else {
- return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index);
- }
-}
-
-void WM_manipulator_target_property_value_set(
- bContext *C, const wmManipulator *mpr,
- wmManipulatorProperty *mpr_prop, const float value)
-{
- if (mpr_prop->custom_func.value_set_fn) {
- BLI_assert(mpr_prop->type->array_length == 1);
- mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, &value);
- return;
- }
-
- /* reset property */
- if (mpr_prop->index == -1) {
- RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, value);
- }
- else {
- RNA_property_float_set_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index, value);
- }
- RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
-}
-
-void WM_manipulator_target_property_value_get_array(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
- float *value)
-{
- if (mpr_prop->custom_func.value_get_fn) {
- mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, value);
- return;
- }
- RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
-}
-
-void WM_manipulator_target_property_value_set_array(
- bContext *C, const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
- const float *value)
-{
- if (mpr_prop->custom_func.value_set_fn) {
- mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, value);
- return;
- }
- RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, value);
-
- RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
-}
-
-bool WM_manipulator_target_property_range_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
- float range[2])
-{
- if (mpr_prop->custom_func.value_get_fn) {
- if (mpr_prop->custom_func.range_get_fn) {
- mpr_prop->custom_func.range_get_fn(mpr, mpr_prop, range);
- return true;
- }
- else {
- return false;
-
- }
- }
-
- float step, precision;
- RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &range[0], &range[1], &step, &precision);
- return true;
-}
-
-int WM_manipulator_target_property_array_length(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop)
-{
- if (mpr_prop->custom_func.value_get_fn) {
- return mpr_prop->type->array_length;
- }
- return RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop);
-}
-
-/** \} */
-
-
-/* -------------------------------------------------------------------- */
-
-/** \name Property Define
- * \{ */
-
-const wmManipulatorPropertyType *WM_manipulatortype_target_property_find(
- const wmManipulatorType *wt, const char *idname)
-{
- return BLI_findstring(&wt->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname));
-}
-
-void WM_manipulatortype_target_property_def(
- wmManipulatorType *wt, const char *idname, int data_type, int array_length)
-{
- wmManipulatorPropertyType *mpt;
-
- BLI_assert(WM_manipulatortype_target_property_find(wt, idname) == NULL);
-
- const uint idname_size = strlen(idname) + 1;
- mpt = MEM_callocN(sizeof(wmManipulatorPropertyType) + idname_size, __func__);
- memcpy(mpt->idname, idname, idname_size);
- mpt->data_type = data_type;
- mpt->array_length = array_length;
- mpt->index_in_type = wt->target_property_defs_len;
- wt->target_property_defs_len += 1;
- BLI_addtail(&wt->target_property_defs, mpt);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-
-/** \name Property Utilities
- * \{ */
-
-void WM_manipulator_do_msg_notify_tag_refresh(
- bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val)
-{
- ARegion *ar = msg_val->owner;
- wmManipulatorMap *mmap = msg_val->user_data;
-
- ED_region_tag_redraw(ar);
- WM_manipulatormap_tag_refresh(mmap);
-}
-
-/**
- * Runs on the "prepare draw" pass,
- * drawing the region clears.
- */
-void WM_manipulator_target_property_subscribe_all(
- wmManipulator *mpr, struct wmMsgBus *mbus, ARegion *ar)
-{
- if (mpr->type->target_property_defs_len) {
- wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr);
- for (int i = 0; i < mpr->type->target_property_defs_len; i++) {
- wmManipulatorProperty *mpr_prop = &mpr_prop_array[i];
- if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- if (mpr_prop->prop) {
- WM_msg_subscribe_rna(
- mbus, &mpr_prop->ptr, mpr_prop->prop,
- &(const wmMsgSubscribeValue){
- .owner = ar,
- .user_data = ar,
- .notify = ED_region_do_msg_notify_tag_redraw,
- }, __func__);
- WM_msg_subscribe_rna(
- mbus, &mpr_prop->ptr, mpr_prop->prop,
- &(const wmMsgSubscribeValue){
- .owner = ar,
- .user_data = mpr->parent_mgroup->parent_mmap,
- .notify = WM_manipulator_do_msg_notify_tag_refresh,
- }, __func__);
- }
- }
- }
- }
-}
-
-/** \} */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c
deleted file mode 100644
index fd7f31db903..00000000000
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c
+++ /dev/null
@@ -1,212 +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/windowmanager/manipulators/intern/wm_manipulator_type.c
- * \ingroup wm
- */
-
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BLI_listbase.h"
-#include "BLI_string.h"
-#include "BLI_string_utils.h"
-
-#include "BKE_context.h"
-#include "BKE_main.h"
-
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_screen.h"
-
-/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */
-#include "wm.h"
-
-/* own includes */
-#include "wm_manipulator_wmapi.h"
-#include "wm_manipulator_intern.h"
-
-
-/** \name Manipulator Type Append
- *
- * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
- * \{ */
-
-static GHash *global_manipulatortype_hash = NULL;
-
-const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet)
-{
- if (idname[0]) {
- wmManipulatorType *wt;
-
- wt = BLI_ghash_lookup(global_manipulatortype_hash, idname);
- if (wt) {
- return wt;
- }
-
- if (!quiet) {
- printf("search for unknown manipulator '%s'\n", idname);
- }
- }
- else {
- if (!quiet) {
- printf("search for empty manipulator\n");
- }
- }
-
- return NULL;
-}
-
-/* caller must free */
-void WM_manipulatortype_iter(GHashIterator *ghi)
-{
- BLI_ghashIterator_init(ghi, global_manipulatortype_hash);
-}
-
-static wmManipulatorType *wm_manipulatortype_append__begin(void)
-{
- wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype");
- wt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_ManipulatorProperties);
-#if 0
- /* Set the default i18n context now, so that opfunc can redefine it if needed! */
- RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
- ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
-#endif
- return wt;
-}
-static void wm_manipulatortype_append__end(wmManipulatorType *wt)
-{
- BLI_assert(wt->struct_size >= sizeof(wmManipulator));
-
- RNA_def_struct_identifier(&BLENDER_RNA, wt->srna, wt->idname);
-
- BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt);
-}
-
-void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *))
-{
- wmManipulatorType *wt = wm_manipulatortype_append__begin();
- wtfunc(wt);
- wm_manipulatortype_append__end(wt);
-}
-
-void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata)
-{
- wmManipulatorType *mt = wm_manipulatortype_append__begin();
- wtfunc(mt, userdata);
- wm_manipulatortype_append__end(mt);
-}
-
-/**
- * Free but don't remove from ghash.
- */
-static void manipulatortype_free(wmManipulatorType *wt)
-{
- if (wt->ext.srna) { /* python manipulator, allocs own string */
- MEM_freeN((void *)wt->idname);
- }
-
- BLI_freelistN(&wt->target_property_defs);
- MEM_freeN(wt);
-}
-
-/**
- * \param C: May be NULL.
- */
-static void manipulatortype_unlink(
- bContext *C, Main *bmain, wmManipulatorType *wt)
-{
- /* Free instances. */
- for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- for (ARegion *ar = lb->first; ar; ar = ar->next) {
- wmManipulatorMap *mmap = ar->manipulator_map;
- if (mmap) {
- wmManipulatorGroup *mgroup;
- for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
- for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) {
- mpr_next = mpr->next;
- BLI_assert(mgroup->parent_mmap == mmap);
- if (mpr->type == wt) {
- WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C);
- ED_region_tag_redraw(ar);
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
-void WM_manipulatortype_remove_ptr(bContext *C, Main *bmain, wmManipulatorType *wt)
-{
- BLI_assert(wt == WM_manipulatortype_find(wt->idname, false));
-
- BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL);
-
- manipulatortype_unlink(C, bmain, wt);
-
- manipulatortype_free(wt);
-}
-
-bool WM_manipulatortype_remove(bContext *C, Main *bmain, const char *idname)
-{
- wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname);
-
- if (wt == NULL) {
- return false;
- }
-
- WM_manipulatortype_remove_ptr(C, bmain, wt);
-
- return true;
-}
-
-static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt)
-{
- manipulatortype_free(mt);
-}
-
-void wm_manipulatortype_free(void)
-{
- BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb);
- global_manipulatortype_hash = NULL;
-}
-
-/* called on initialize WM_init() */
-void wm_manipulatortype_init(void)
-{
- /* reserve size is set based on blender default setup */
- global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128);
-}
-
-/** \} */
diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h
deleted file mode 100644
index 305d04eab68..00000000000
--- a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h
+++ /dev/null
@@ -1,88 +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/windowmanager/manipulators/wm_manipulator_fn.h
- * \ingroup wm
- *
- * Callback function definitions, needed for both Types & API headers.
- */
-
-#ifndef __WM_MANIPULATOR_FN_H__
-#define __WM_MANIPULATOR_FN_H__
-
-#include "BLI_compiler_attrs.h"
-
-/* wmManipulatorGroup */
-typedef bool (*wmManipulatorGroupFnPoll)(
- const struct bContext *, struct wmManipulatorGroupType *)
- ATTR_WARN_UNUSED_RESULT;
-typedef void (*wmManipulatorGroupFnInit)(
- const struct bContext *, struct wmManipulatorGroup *);
-typedef void (*wmManipulatorGroupFnRefresh)(
- const struct bContext *, struct wmManipulatorGroup *);
-typedef void (*wmManipulatorGroupFnDrawPrepare)(
- const struct bContext *, struct wmManipulatorGroup *);
-typedef struct wmKeyMap *(*wmManipulatorGroupFnSetupKeymap)(
- const struct wmManipulatorGroupType *, struct wmKeyConfig *)
- ATTR_WARN_UNUSED_RESULT;
-typedef void (*wmManipulatorGroupFnMsgBusSubscribe)(
- const struct bContext *, struct wmManipulatorGroup *, struct wmMsgBus *);
-
-/* wmManipulator */
-/* See: wmManipulatorType for docs on each type. */
-
-typedef void (*wmManipulatorFnSetup)(struct wmManipulator *);
-typedef void (*wmManipulatorFnDraw)(const struct bContext *, struct wmManipulator *);
-typedef void (*wmManipulatorFnDrawSelect)(const struct bContext *, struct wmManipulator *, int);
-typedef int (*wmManipulatorFnTestSelect)(struct bContext *, struct wmManipulator *, const struct wmEvent *);
-typedef int (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, eWM_ManipulatorTweak);
-typedef void (*wmManipulatorFnPropertyUpdate)(struct wmManipulator *, struct wmManipulatorProperty *);
-typedef void (*wmManipulatorFnMatrixBasisGet)(const struct wmManipulator *, float[4][4]);
-typedef int (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *);
-typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *, const bool);
-typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *);
-typedef void (*wmManipulatorFnSelectRefresh)(struct wmManipulator *);
-typedef void (*wmManipulatorFnFree)(struct wmManipulator *);
-
-/* wmManipulatorProperty ('value' type defined by 'wmManipulatorProperty.data_type') */
-typedef void (*wmManipulatorPropertyFnGet)(
- const struct wmManipulator *, struct wmManipulatorProperty *,
- /* typically 'float *' */
- void *value);
-typedef void (*wmManipulatorPropertyFnSet)(
- const struct wmManipulator *, struct wmManipulatorProperty *,
- /* typically 'const float *' */
- const void *value);
-typedef void (*wmManipulatorPropertyFnRangeGet)(
- const struct wmManipulator *, struct wmManipulatorProperty *,
- /* typically 'float[2]' */
- void *range);
-typedef void (*wmManipulatorPropertyFnFree)(
- const struct wmManipulator *, struct wmManipulatorProperty *);
-
-typedef struct wmManipulatorPropertyFnParams {
- wmManipulatorPropertyFnGet value_get_fn;
- wmManipulatorPropertyFnSet value_set_fn;
- wmManipulatorPropertyFnRangeGet range_get_fn;
- wmManipulatorPropertyFnFree free_fn;
- void *user_data;
-} wmManipulatorPropertyFnParams;
-
-#endif /* __WM_MANIPULATOR_FN_H__ */
diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h b/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h
deleted file mode 100644
index a470c5c28ea..00000000000
--- a/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h
+++ /dev/null
@@ -1,97 +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) 2016 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/manipulators/wm_manipulator_wmapi.h
- * \ingroup wm
- *
- * \name Manipulators Window Manager API
- * API for usage in window manager code only. It should contain all functionality
- * needed to hook up the manipulator system with Blender's window manager. It's
- * mostly the event system that needs to communicate with manipulator code.
- *
- * Only included in wm.h and lower level files.
- */
-
-
-#ifndef __WM_MANIPULATOR_WMAPI_H__
-#define __WM_MANIPULATOR_WMAPI_H__
-
-struct wmEventHandler;
-struct wmManipulatorMap;
-struct wmOperatorType;
-struct wmOperator;
-
-
-/* -------------------------------------------------------------------- */
-/* wmManipulator */
-
-/* wm_manipulator_type.c, for init/exit */
-void wm_manipulatortype_free(void);
-void wm_manipulatortype_init(void);
-
-/* wm_manipulatorgroup_type.c, for init/exit */
-void wm_manipulatorgrouptype_free(void);
-void wm_manipulatorgrouptype_init(void);
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorGroup */
-
-void MANIPULATORGROUP_OT_manipulator_select(struct wmOperatorType *ot);
-void MANIPULATORGROUP_OT_manipulator_tweak(struct wmOperatorType *ot);
-
-bool wm_manipulatorgroup_is_any_selected(const struct wmManipulatorGroup *mgroup);
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorMap */
-
-void wm_manipulatormap_remove(struct wmManipulatorMap *mmap);
-
-void wm_manipulators_keymap(struct wmKeyConfig *keyconf);
-
-void wm_manipulatormaps_handled_modal_update(
- bContext *C, struct wmEvent *event, struct wmEventHandler *handler);
-void wm_manipulatormap_handler_context(bContext *C, struct wmEventHandler *handler);
-
-struct wmManipulator *wm_manipulatormap_highlight_find(
- struct wmManipulatorMap *mmap, bContext *C, const struct wmEvent *event,
- int *r_part);
-bool wm_manipulatormap_highlight_set(
- struct wmManipulatorMap *mmap, const bContext *C,
- struct wmManipulator *mpr, int part);
-struct wmManipulator *wm_manipulatormap_highlight_get(struct wmManipulatorMap *mmap);
-void wm_manipulatormap_modal_set(
- struct wmManipulatorMap *mmap, bContext *C, struct wmManipulator *mpr,
- const struct wmEvent *event, bool enable);
-
-struct wmManipulator *wm_manipulatormap_modal_get(struct wmManipulatorMap *mmap);
-struct wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len);
-struct ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap);
-
-/* -------------------------------------------------------------------- */
-/* wmManipulatorMapType */
-
-void wm_manipulatormaptypes_free(void);
-
-#endif /* __WM_MANIPULATOR_WMAPI_H__ */
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index 3605e57be36..04353b55334 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -35,7 +35,7 @@ struct ARegion;
struct wmWindow;
struct ReportList;
-#include "manipulators/wm_manipulator_wmapi.h"
+#include "gizmo/wm_gizmo_wmapi.h"
typedef struct wmPaintCursor {
struct wmPaintCursor *next, *prev;
@@ -62,6 +62,7 @@ void wm_operator_register(bContext *C, wmOperator *op);
void wm_operatortype_free(void);
void wm_operatortype_init(void);
void wm_window_keymap(wmKeyConfig *keyconf);
+void wm_operatortypes_register(void);
/* wm_gesture.c */
void wm_gesture_draw(struct wmWindow *win);
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index b9b41b0b685..1dcd0cb62d0 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -77,8 +77,8 @@ typedef struct wmEventHandler {
/* drop box handler */
ListBase *dropboxes;
- /* manipulator handler */
- struct wmManipulatorMap *manipulator_map;
+ /* gizmo handler */
+ struct wmGizmoMap *gizmo_map;
} wmEventHandler;
/* custom types for handlers, for signaling, freeing */
@@ -97,6 +97,7 @@ void wm_event_do_handlers (bContext *C);
void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata);
+void wm_event_do_depsgraph(bContext *C);
void wm_event_do_refresh_wm_and_depsgraph(bContext *C);
void wm_event_do_notifiers(bContext *C);
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 3f98b6ef512..6a0e4882830 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -339,8 +339,8 @@ enum {
EVT_DROP = 0x5023,
EVT_BUT_CANCEL = 0x5024,
- /* could become manipulator callback */
- EVT_MANIPULATOR_UPDATE = 0x5025,
+ /* could become gizmo callback */
+ EVT_GIZMO_UPDATE = 0x5025,
/* ********** End of Blender internal events. ********** */
};
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index 952ffe5c117..385d61217ad 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -45,9 +45,9 @@ void wm_ghost_exit(void);
void wm_get_screensize(int *r_width, int *r_height);
void wm_get_desktopsize(int *r_width, int *r_height);
-wmWindow *wm_window_new (bContext *C);
-wmWindow *wm_window_copy (bContext *C, wmWindow *win_src, const bool duplicate_layout);
-wmWindow *wm_window_copy_test (bContext *C, wmWindow *win_src, const bool duplicate_layout);
+wmWindow *wm_window_new (bContext *C, wmWindow *parent);
+wmWindow *wm_window_copy (bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child);
+wmWindow *wm_window_copy_test (bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child);
void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win);
void wm_window_close (bContext *C, wmWindowManager *wm, wmWindow *win);
@@ -85,6 +85,7 @@ int wm_window_fullscreen_toggle_exec(bContext *C, struct wmOperator *op);
void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win) ATTR_NONNULL();
int wm_window_new_exec(bContext *C, struct wmOperator *op);
+int wm_window_new_main_exec(bContext *C, struct wmOperator *op);
/* Initial (unmaximized) size to start with for
* systems that can't find it for themselves (X11).
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 6fd5771434c..18396149342 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -236,7 +236,7 @@ int main(
struct CreatorAtExitData app_init_data = {NULL};
BKE_blender_atexit_register(callback_main_atexit, &app_init_data);
- /* Unbuffered stdout makes stdout and stderr better synchronised, and helps
+ /* Unbuffered stdout makes stdout and stderr better synchronized, and helps
* when stepping through code in a debugger (prints are immediately
* visible). */
setvbuf(stdout, NULL, _IONBF, 0);
diff --git a/tests/check_deprecated.py b/tests/check_deprecated.py
index 6e07f8fdb31..7595bb4ff81 100644
--- a/tests/check_deprecated.py
+++ b/tests/check_deprecated.py
@@ -142,5 +142,6 @@ def main():
else:
print("\nnone found!")
+
if __name__ == '__main__':
main()
diff --git a/tests/python/alembic_tests.py b/tests/python/alembic_tests.py
index b9dc78a821f..d872e699cea 100755
--- a/tests/python/alembic_tests.py
+++ b/tests/python/alembic_tests.py
@@ -33,7 +33,6 @@ from modules.test_utils import (with_tempdir,
)
-
class AbcPropError(Exception):
"""Raised when AbstractAlembicTest.abcprop() finds an error."""
diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py
index 558db659990..95afff53ed4 100644
--- a/tests/python/bl_alembic_import_test.py
+++ b/tests/python/bl_alembic_import_test.py
@@ -109,7 +109,6 @@ class SimpleImportTest(AbstractAlembicTest):
self.assertAlmostEqual(0, y)
self.assertAlmostEqual(2, z)
-
def test_select_after_import(self):
# Add a sphere, so that there is something in the scene, selected, and active,
# before we do the Alembic import.
diff --git a/tests/python/bl_load_addons.py b/tests/python/bl_load_addons.py
index 29304400005..16ddea24756 100644
--- a/tests/python/bl_load_addons.py
+++ b/tests/python/bl_load_addons.py
@@ -33,7 +33,7 @@ import imp
BLACKLIST_DIRS = (
os.path.join(bpy.utils.resource_path('USER'), "scripts"),
- ) + tuple(addon_utils.paths()[1:])
+) + tuple(addon_utils.paths()[1:])
BLACKLIST_ADDONS = set()
@@ -54,9 +54,10 @@ def _init_addon_blacklist():
def addon_modules_sorted():
modules = addon_utils.modules({})
modules[:] = [
- mod for mod in modules
- if not (mod.__file__.startswith(BLACKLIST_DIRS))
- if not (mod.__name__ in BLACKLIST_ADDONS)]
+ mod for mod in modules
+ if not (mod.__file__.startswith(BLACKLIST_DIRS))
+ if not (mod.__name__ in BLACKLIST_ADDONS)
+ ]
modules.sort(key=lambda mod: mod.__name__)
return modules
diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py
index 39e7bd33d44..437a425a36d 100644
--- a/tests/python/bl_load_py_modules.py
+++ b/tests/python/bl_load_py_modules.py
@@ -39,20 +39,20 @@ BLACKLIST = {
# The unpacked wheel is only loaded when actually used, not directly on import:
os.path.join("io_blend_utils", "blender_bam-unpacked.whl"),
- }
+}
# Some modules need to add to the `sys.path`.
MODULE_SYS_PATHS = {
# Runs in a Python subprocess, so its expected its basedir can be imported.
"io_blend_utils.blendfile_pack": ".",
- }
+}
if not bpy.app.build_options.freestyle:
BLACKLIST.add("render_freestyle_svg")
BLACKLIST_DIRS = (
os.path.join(bpy.utils.resource_path('USER'), "scripts"),
- ) + tuple(addon_utils.paths()[1:])
+) + tuple(addon_utils.paths()[1:])
def module_names_recursive(mod_dir, *, parent=None):
@@ -168,7 +168,7 @@ def load_modules():
os.sep + "presets" + os.sep,
os.sep + "templates" + os.sep,
] + ([(os.sep + f + os.sep) for f in BLACKLIST] +
- [(os.sep + f + ".py") for f in BLACKLIST])
+ [(os.sep + f + ".py") for f in BLACKLIST])
#
# now submodules
@@ -185,7 +185,7 @@ def load_modules():
sys.path.extend([
os.path.normpath(os.path.join(mod_dir, f))
for f in MODULE_SYS_PATHS.get(mod_name_full, ())
- ])
+ ])
try:
__import__(mod_name_full)
@@ -248,6 +248,7 @@ def main():
load_addons()
load_modules()
+
if __name__ == "__main__":
# So a python error exits(1)
try:
diff --git a/tests/python/bl_mesh_modifiers.py b/tests/python/bl_mesh_modifiers.py
index 60e6d35def9..f2ab6b406bd 100644
--- a/tests/python/bl_mesh_modifiers.py
+++ b/tests/python/bl_mesh_modifiers.py
@@ -61,11 +61,11 @@ def render_gl(context, filepath, shade):
ctx_shading_type(context, shade)
- #~ # stop to inspect!
- #~ if filepath == "test_cube_shell_solidify_subsurf_wp_wire":
- #~ assert(0)
- #~ else:
- #~ return
+ # stop to inspect!
+ # if filepath == "test_cube_shell_solidify_subsurf_wp_wire":
+ # assert(0)
+ # else:
+ # return
bpy.ops.render.opengl(write_still=True,
view_context=True)
@@ -127,7 +127,7 @@ def ctx_clear_scene(): # copied from batch_import.py
# remove obdata, for now only worry about the startup scene
for bpy_data_iter in (bpy.data.objects,
bpy.data.meshes,
- bpy.data.lamps,
+ bpy.data.lights,
bpy.data.cameras,
):
@@ -219,6 +219,7 @@ def mesh_bmesh_poly_elems(poly, elems):
vert_total = poly.loop_total
return elems[vert_start:vert_start + vert_total]
+
def mesh_bmesh_poly_vertices(poly):
return [loop.vertex_index
for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)]
@@ -505,7 +506,7 @@ cube_like_vertices = (
(-1, 1, 3),
(0, 1, 3),
(0, 0, 3),
- )
+)
cube_like_faces = (
@@ -547,7 +548,7 @@ cube_like_faces = (
(31, 30, 36, 33),
(32, 31, 33, 34),
(35, 34, 33, 36),
- )
+)
# useful since its a shell for solidify and it can be mirrored
@@ -564,7 +565,7 @@ cube_shell_vertices = (
(0, -1, 0),
(0, 0, -1),
(0, 1, -1),
- )
+)
cube_shell_face = (
@@ -577,7 +578,7 @@ cube_shell_face = (
(6, 5, 11),
(7, 4, 9, 8),
(10, 7, 6, 11),
- )
+)
def make_cube(scene):
@@ -678,59 +679,77 @@ def make_monkey_extra(scene):
global_tests = []
-global_tests.append(("none",
- (),
- ))
-
+global_tests.append(
+ ("none",
+ (),
+ )
+)
# single
-global_tests.append(("subsurf_single",
- ((modifier_subsurf_add, dict(levels=2)), ),
- ))
-
-
-global_tests.append(("armature_single",
- ((modifier_armature_add, dict()), ),
- ))
-
-
-global_tests.append(("mirror_single",
- ((modifier_mirror_add, dict()), ),
- ))
-
-global_tests.append(("hook_single",
- ((modifier_hook_add, dict()), ),
- ))
-
-global_tests.append(("decimate_single",
- ((modifier_decimate_add, dict()), ),
- ))
-
-global_tests.append(("build_single",
- ((modifier_build_add, dict()), ),
- ))
-
-global_tests.append(("mask_single",
- ((modifier_mask_add, dict()), ),
- ))
+global_tests.append(
+ ("subsurf_single",
+ ((modifier_subsurf_add, dict(levels=2)), ),
+ )
+)
+
+global_tests.append(
+ ("armature_single",
+ ((modifier_armature_add, dict()), ),
+ )
+)
+
+global_tests.append(
+ ("mirror_single",
+ ((modifier_mirror_add, dict()), ),
+ )
+)
+
+global_tests.append(
+ ("hook_single",
+ ((modifier_hook_add, dict()), ),
+ )
+)
+
+global_tests.append(
+ ("decimate_single",
+ ((modifier_decimate_add, dict()), ),
+ )
+)
+
+global_tests.append(
+ ("build_single",
+ ((modifier_build_add, dict()), ),
+ )
+)
+
+global_tests.append(
+ ("mask_single",
+ ((modifier_mask_add, dict()), ),
+ )
+)
# combinations
-global_tests.append(("mirror_subsurf",
- ((modifier_mirror_add, dict()),
- (modifier_subsurf_add, dict(levels=2))),
- ))
-
-global_tests.append(("solidify_subsurf",
- ((modifier_solidify_add, dict()),
- (modifier_subsurf_add, dict(levels=2))),
- ))
-
-
-def apply_test(test, scene, obj,
- render_func=None,
- render_args=None,
- render_kwargs=None,
- ):
+global_tests.append(
+ ("mirror_subsurf",
+ ((modifier_mirror_add, dict()),
+ (modifier_subsurf_add, dict(levels=2))),
+ )
+)
+
+global_tests.append(
+ ("solidify_subsurf",
+ ((modifier_solidify_add, dict()),
+ (modifier_subsurf_add, dict(levels=2))),
+ )
+)
+
+
+def apply_test(
+ test, scene, obj,
+ render_func=None,
+ render_args=None,
+ render_kwargs=None,
+):
test_name, test_funcs = test
@@ -756,10 +775,12 @@ def test_cube(context, test):
obj = make_cube_extra(scene)
ctx_camera_setup(context, location=(3, 3, 3))
- apply_test(test, scene, obj,
- render_func=render_gl_all_modes,
- render_args=(context, obj),
- render_kwargs=dict(filepath=whoami()))
+ apply_test(
+ test, scene, obj,
+ render_func=render_gl_all_modes,
+ render_args=(context, obj),
+ render_kwargs=dict(filepath=whoami())
+ )
def test_cube_like(context, test):
@@ -767,10 +788,12 @@ def test_cube_like(context, test):
obj = make_cube_like_extra(scene)
ctx_camera_setup(context, location=(5, 5, 5))
- apply_test(test, scene, obj,
- render_func=render_gl_all_modes,
- render_args=(context, obj),
- render_kwargs=dict(filepath=whoami()))
+ apply_test(
+ test, scene, obj,
+ render_func=render_gl_all_modes,
+ render_args=(context, obj),
+ render_kwargs=dict(filepath=whoami())
+ )
def test_cube_shell(context, test):
@@ -778,10 +801,12 @@ def test_cube_shell(context, test):
obj = make_cube_shell_extra(scene)
ctx_camera_setup(context, location=(4, 4, 4))
- apply_test(test, scene, obj,
- render_func=render_gl_all_modes,
- render_args=(context, obj),
- render_kwargs=dict(filepath=whoami()))
+ apply_test(
+ test, scene, obj,
+ render_func=render_gl_all_modes,
+ render_args=(context, obj),
+ render_kwargs=dict(filepath=whoami())
+ )
# -----------------------------------------------------------------------------
diff --git a/tests/python/bl_mesh_validate.py b/tests/python/bl_mesh_validate.py
index ac5be7d08d7..e1dd097b2e0 100644
--- a/tests/python/bl_mesh_validate.py
+++ b/tests/python/bl_mesh_validate.py
@@ -45,20 +45,20 @@ MESHES = {
( # Edges
),
( # Loops
- 0, 1, 4, 3,
- 3, 4, 6,
- 1, 2, 5, 4,
- 3, 4, 6,
- 4, 7, 6,
- 4, 5, 9, 4, 8, 7,
+ 0, 1, 4, 3,
+ 3, 4, 6,
+ 1, 2, 5, 4,
+ 3, 4, 6,
+ 4, 7, 6,
+ 4, 5, 9, 4, 8, 7,
),
( # Polygons
- (0, 4),
- (4, 3),
- (7, 4),
- (11, 3),
- (14, 3),
- (16, 6),
+ (0, 4),
+ (4, 3),
+ (7, 4),
+ (11, 3),
+ (14, 3),
+ (16, 6),
),
),
),
@@ -66,17 +66,17 @@ MESHES = {
BUILTINS = (
- "primitive_plane_add",
- "primitive_cube_add",
- "primitive_circle_add",
- "primitive_uv_sphere_add",
- "primitive_ico_sphere_add",
- "primitive_cylinder_add",
- "primitive_cone_add",
- "primitive_grid_add",
- "primitive_monkey_add",
- "primitive_torus_add",
- )
+ "primitive_plane_add",
+ "primitive_cube_add",
+ "primitive_circle_add",
+ "primitive_uv_sphere_add",
+ "primitive_ico_sphere_add",
+ "primitive_cylinder_add",
+ "primitive_cone_add",
+ "primitive_grid_add",
+ "primitive_monkey_add",
+ "primitive_torus_add",
+)
BUILTINS_NBR = 4
BUILTINS_NBRCHANGES = 5
diff --git a/tests/python/bl_pyapi_bpy_utils_units.py b/tests/python/bl_pyapi_bpy_utils_units.py
index 251419cb9ef..88d5cb941bd 100644
--- a/tests/python/bl_pyapi_bpy_utils_units.py
+++ b/tests/python/bl_pyapi_bpy_utils_units.py
@@ -5,25 +5,26 @@ import unittest
from bpy.utils import units
+
class UnitsTesting(unittest.TestCase):
# From user typing to 'internal' Blender value.
INPUT_TESTS = (
# system, type, ref, input, value
- ##### LENGTH
+ # LENGTH
('IMPERIAL', 'LENGTH', "", "1ft", 0.3048),
('IMPERIAL', 'LENGTH', "", "(1+1)ft", 0.3048 * 2),
('IMPERIAL', 'LENGTH', "", "1mi4\"", 1609.344 + 0.0254 * 4),
- ('METRIC', 'LENGTH', "", "0.005µm", 0.000001 * 0.005),
- ('METRIC', 'LENGTH', "", "1e6km", 1000.0 * 1e6),
+ ('METRIC', 'LENGTH', "", "0.005µm", 0.000001 * 0.005),
+ ('METRIC', 'LENGTH', "", "1e6km", 1000.0 * 1e6),
('IMPERIAL', 'LENGTH', "", "1ft5cm", 0.3048 + 0.01 * 5),
- ('METRIC', 'LENGTH', "", "1ft5cm", 0.3048 + 0.01 * 5),
+ ('METRIC', 'LENGTH', "", "1ft5cm", 0.3048 + 0.01 * 5),
# Using reference string to find a unit when none is given.
('IMPERIAL', 'LENGTH', "33.3ft", "1", 0.3048),
- ('METRIC', 'LENGTH', "33.3dm", "1", 0.1),
+ ('METRIC', 'LENGTH', "33.3dm", "1", 0.1),
('IMPERIAL', 'LENGTH', "33.3cm", "1", 0.3048), # ref unit is not in IMPERIAL system, default to feet...
('IMPERIAL', 'LENGTH', "33.3ft", "1\"", 0.0254), # unused ref unit, since one is given already!
('IMPERIAL', 'LENGTH', "", "1+1ft", 0.3048 * 2), # default unit taken from current string (feet).
- ('METRIC', 'LENGTH', "", "1+1ft", 1.3048), # no metric units, we default to meters.
+ ('METRIC', 'LENGTH', "", "1+1ft", 1.3048), # no metric units, we default to meters.
('IMPERIAL', 'LENGTH', "", "3+1in+1ft", 0.3048 * 4 + 0.0254), # bigger unit becomes default one!
('IMPERIAL', 'LENGTH', "", "(3+1)in+1ft", 0.3048 + 0.0254 * 4),
)
@@ -31,18 +32,18 @@ class UnitsTesting(unittest.TestCase):
# From 'internal' Blender value to user-friendly printing
OUTPUT_TESTS = (
# system, type, prec, sep, compat, value, output
- ##### LENGTH
+ # LENGTH
# Note: precision handling is a bit complicated when using multi-units...
('IMPERIAL', 'LENGTH', 3, False, False, 0.3048, "1'"),
- ('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"),
- ('IMPERIAL', 'LENGTH', 4, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""),
+ ('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"),
+ ('IMPERIAL', 'LENGTH', 4, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""),
('IMPERIAL', 'LENGTH', 3, False, False, 1609.344 * 1e6, "1000000mi"),
('IMPERIAL', 'LENGTH', 6, False, False, 1609.344 * 1e6, "1000000mi"),
- ('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2km 2cm"),
- ('METRIC', 'LENGTH', 5, True, False, 1234.56789, "1km 234.6m"),
- ('METRIC', 'LENGTH', 6, True, False, 1234.56789, "1km 234.57m"),
- ('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.234568km"),
- ('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1km 0.123mm"),
+ ('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2km 2cm"),
+ ('METRIC', 'LENGTH', 5, True, False, 1234.56789, "1km 234.6m"),
+ ('METRIC', 'LENGTH', 6, True, False, 1234.56789, "1km 234.57m"),
+ ('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.234568km"),
+ ('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1km 0.123mm"),
)
def test_units_inputs(self):
@@ -63,9 +64,13 @@ class UnitsTesting(unittest.TestCase):
def test_units_outputs(self):
for usys, utype, prec, sep, compat, val, output in self.OUTPUT_TESTS:
opt_str = units.to_string(usys, utype, val, prec, sep, compat)
- self.assertEqual(opt_str, output,
- msg="%s, %s: %f (precision: %d, separate units: %d, compat units: %d) => "
- "\"%s\", expected \"%s\"" % (usys, utype, val, prec, sep, compat, opt_str, output))
+ self.assertEqual(
+ opt_str, output,
+ msg=(
+ "%s, %s: %f (precision: %d, separate units: %d, compat units: %d) => "
+ "\"%s\", expected \"%s\""
+ ) % (usys, utype, val, prec, sep, compat, opt_str, output)
+ )
if __name__ == '__main__':
diff --git a/tests/python/bl_pyapi_idprop.py b/tests/python/bl_pyapi_idprop.py
index 7bf68c16cc7..063d68fae20 100644
--- a/tests/python/bl_pyapi_idprop.py
+++ b/tests/python/bl_pyapi_idprop.py
@@ -198,6 +198,7 @@ class TestBufferProtocol(TestHelper, unittest.TestCase):
self.assertEqual(list(view1), list(view2))
self.assertEqual(view1.tobytes(), view2.tobytes())
+
if __name__ == '__main__':
import sys
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
diff --git a/tests/python/bl_pyapi_idprop_datablock.py b/tests/python/bl_pyapi_idprop_datablock.py
index 4acfb83bd95..8ff597dda31 100644
--- a/tests/python/bl_pyapi_idprop_datablock.py
+++ b/tests/python/bl_pyapi_idprop_datablock.py
@@ -61,8 +61,10 @@ class TestClass(bpy.types.PropertyGroup):
def get_scene(lib_name, sce_name):
for s in bpy.data.scenes:
if s.name == sce_name:
- if (s.library and s.library.name == lib_name) or \
- (lib_name == None and s.library == None):
+ if (
+ (s.library and s.library.name == lib_name) or
+ (lib_name is None and s.library is None)
+ ):
return s
@@ -88,10 +90,10 @@ def make_lib():
# datablock pointer to the Camera object
bpy.data.objects["Cube"].prop = bpy.data.objects['Camera']
- # array of datablock pointers to the Lamp object
+ # array of datablock pointers to the Light object
for i in range(0, arr_len):
a = bpy.data.objects["Cube"].prop_array.add()
- a.test_prop = bpy.data.objects['Lamp']
+ a.test_prop = bpy.data.objects['Light']
a.name = a.test_prop.name
# make unique named copy of the cube
@@ -122,7 +124,7 @@ def check_lib():
# check array of pointers in duplicated object
for i in range(0, arr_len):
abort_if_false(bpy.data.objects["Cube.001"].prop_array[i].test_prop ==
- bpy.data.objects['Lamp'])
+ bpy.data.objects['Light'])
def check_lib_linking():
@@ -135,7 +137,7 @@ def check_lib_linking():
o = bpy.data.scenes["Scene_lib"].objects['Unique_Cube']
- abort_if_false(o.prop_array[0].test_prop == bpy.data.scenes["Scene_lib"].objects['Lamp'])
+ abort_if_false(o.prop_array[0].test_prop == bpy.data.scenes["Scene_lib"].objects['Light'])
abort_if_false(o.prop == bpy.data.scenes["Scene_lib"].objects['Camera'])
abort_if_false(o.prop.library == o.library)
@@ -185,15 +187,15 @@ def check_scene_copying():
# count users
def test_users_counting():
bpy.ops.wm.read_factory_settings()
- lamp_us = bpy.data.objects["Lamp"].data.users
+ Light_us = bpy.data.objects["Light"].data.users
n = 1000
for i in range(0, n):
- bpy.data.objects["Cube"]["a%s" % i] = bpy.data.objects["Lamp"].data
- abort_if_false(bpy.data.objects["Lamp"].data.users == lamp_us + n)
+ bpy.data.objects["Cube"]["a%s" % i] = bpy.data.objects["Light"].data
+ abort_if_false(bpy.data.objects["Light"].data.users == Light_us + n)
for i in range(0, int(n / 2)):
bpy.data.objects["Cube"]["a%s" % i] = 1
- abort_if_false(bpy.data.objects["Lamp"].data.users == lamp_us + int(n / 2))
+ abort_if_false(bpy.data.objects["Light"].data.users == Light_us + int(n / 2))
# linking
@@ -257,13 +259,13 @@ def test_restrictions1():
bpy.types.Scene.prop2 = bpy.props.PointerProperty(type=bpy.types.NodeTree, poll=poll1)
# check poll effect on UI (poll returns false => red alert)
- bpy.context.scene.prop = bpy.data.objects["Lamp.001"]
- bpy.context.scene.prop1 = bpy.data.objects["Lamp.001"]
+ bpy.context.scene.prop = bpy.data.objects["Light.001"]
+ bpy.context.scene.prop1 = bpy.data.objects["Light.001"]
# check incorrect type assignment
def sub_test():
# NodeTree id_prop
- bpy.context.scene.prop2 = bpy.data.objects["Lamp.001"]
+ bpy.context.scene.prop2 = bpy.data.objects["Light.001"]
check_crash(sub_test)
@@ -309,6 +311,7 @@ def test_restrictions2():
class TestUIList(UIList):
test = bpy.props.PointerProperty(type=bpy.types.Object)
+
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
layout.prop(item, "name", text="", emboss=False, icon_value=icon)
diff --git a/tests/python/bl_pyapi_mathutils.py b/tests/python/bl_pyapi_mathutils.py
index b2d3d79fd56..57bbbc7e73e 100644
--- a/tests/python/bl_pyapi_mathutils.py
+++ b/tests/python/bl_pyapi_mathutils.py
@@ -21,22 +21,22 @@ vector_data = (
(-0.854645, 0.518036, 0.033936),
(0.42514, -0.437866, -0.792114),
(-0.358948, 0.597046, 0.717377),
- (-0.985413,0.144714, 0.089294),
- )
+ (-0.985413, 0.144714, 0.089294),
+)
# get data at different scales
vector_data = sum(
(tuple(tuple(a * scale for a in v) for v in vector_data)
- for scale in (s * sign for s in (0.0001, 0.1, 1.0, 10.0, 1000.0, 100000.0)
- for sign in (1.0, -1.0))), ()) + ((0.0, 0.0, 0.0),)
+ for scale in (s * sign for s in (0.0001, 0.1, 1.0, 10.0, 1000.0, 100000.0)
+ for sign in (1.0, -1.0))), ()) + ((0.0, 0.0, 0.0),)
class MatrixTesting(unittest.TestCase):
def test_matrix_column_access(self):
- #mat =
- #[ 1 2 3 4 ]
- #[ 1 2 3 4 ]
- #[ 1 2 3 4 ]
+ # mat =
+ # [ 1 2 3 4 ]
+ # [ 1 2 3 4 ]
+ # [ 1 2 3 4 ]
mat = Matrix(((1, 11, 111),
(2, 22, 222),
(3, 33, 333),
@@ -81,11 +81,11 @@ class MatrixTesting(unittest.TestCase):
self.assertIn(item, indices)
def test_matrix_to_3x3(self):
- #mat =
- #[ 1 2 3 4 ]
- #[ 2 4 6 8 ]
- #[ 3 6 9 12 ]
- #[ 4 8 12 16 ]
+ # mat =
+ # [ 1 2 3 4 ]
+ # [ 2 4 6 8 ]
+ # [ 3 6 9 12 ]
+ # [ 4 8 12 16 ]
mat = Matrix(tuple((i, 2 * i, 3 * i, 4 * i) for i in range(1, 5)))
mat_correct = Matrix(((1, 2, 3), (2, 4, 6), (3, 6, 9)))
self.assertEqual(mat.to_3x3(), mat_correct)
@@ -372,7 +372,6 @@ class KDTreeTesting(unittest.TestCase):
ret_filter = k_all.find(co, lambda i: (i % 2) == 0)
self.assertAlmostEqualVector(ret_regular, ret_filter)
-
# filter out all values (search odd tree for even values and the reverse)
co = (0,) * 3
ret_filter = k_odd.find(co, lambda i: (i % 2) == 0)
diff --git a/tests/python/bl_rna_defaults.py b/tests/python/bl_rna_defaults.py
index 72f50a827f0..fc895dbddfc 100644
--- a/tests/python/bl_rna_defaults.py
+++ b/tests/python/bl_rna_defaults.py
@@ -8,7 +8,7 @@ DUMMY_NAME = "Untitled"
DUMMY_PATH = __file__
GLOBALS = {
"error_num": 0,
- }
+}
def as_float_32(f):
@@ -125,8 +125,8 @@ test_World = _test_id_gen("worlds")
ns = globals()
for t in bpy.data.curves.bl_rna.functions["new"].parameters["type"].enum_items.keys():
ns["test_Curve_%s" % t] = _test_id_gen("curves", args_create=(DUMMY_NAME, t))
-for t in bpy.data.lamps.bl_rna.functions["new"].parameters["type"].enum_items.keys():
- ns["test_Lamp_%s" % t] = _test_id_gen("lamps", args_create=(DUMMY_NAME, t))
+for t in bpy.data.lights.bl_rna.functions["new"].parameters["type"].enum_items.keys():
+ ns["test_Light_%s" % t] = _test_id_gen("lights", args_create=(DUMMY_NAME, t))
# types are a dynamic enum, have to hard-code.
for t in "ShaderNodeTree", "CompositorNodeTree", "TextureNodeTree":
ns["test_NodeGroup_%s" % t] = _test_id_gen("node_groups", args_create=(DUMMY_NAME, t))
@@ -142,5 +142,6 @@ def main():
print("Error (total): %d" % GLOBALS["error_num"])
+
if __name__ == "__main__":
main()
diff --git a/tests/python/bl_rna_manual_reference.py b/tests/python/bl_rna_manual_reference.py
index c67b6c1532b..00e40fe571b 100644
--- a/tests/python/bl_rna_manual_reference.py
+++ b/tests/python/bl_rna_manual_reference.py
@@ -155,5 +155,6 @@ def main():
test_language_coverage()
test_urls()
+
if __name__ == "__main__":
main()
diff --git a/tests/python/bl_run_operators.py b/tests/python/bl_run_operators.py
index 7b6b97e5ad1..aae78a84132 100644
--- a/tests/python/bl_run_operators.py
+++ b/tests/python/bl_run_operators.py
@@ -36,7 +36,7 @@ RANDOM_MULTIPLY = 10
STATE = {
"counter": 0,
- }
+}
op_blacklist = (
@@ -91,7 +91,7 @@ op_blacklist = (
"wm.keymap_restore", # another annoying one
"wm.addon_*", # harmless, but dont change state
"console.*", # just annoying - but harmless
- )
+)
def blend_list(mainpath):
@@ -114,6 +114,7 @@ def blend_list(mainpath):
return list(sorted(file_list(mainpath, is_blend)))
+
if USE_FILES:
USE_FILES_LS = blend_list(USE_FILES)
# print(USE_FILES_LS)
@@ -176,7 +177,7 @@ if USE_ATTRSET:
CLS_BLACKLIST = (
bpy.types.BrushTextureSlot,
bpy.types.Brush,
- )
+ )
property_typemap = build_property_typemap(CLS_BLACKLIST)
bpy_struct_type = bpy.types.Struct.__base__
@@ -228,7 +229,7 @@ if USE_ATTRSET:
{0: "", 1: "hello", 2: "test"}, {"": 0, "hello": 1, "test": 2},
set(), {"", "test", "."}, {None, ..., type},
range(10), (" " * i for i in range(10)),
- )
+ )
def attrset_data():
for attr in dir(bpy.data):
@@ -480,8 +481,9 @@ def main():
print("Finished %r" % __file__)
+
if __name__ == "__main__":
- #~ for i in range(200):
- #~ RANDOM_SEED[0] += 1
+ # ~ for i in range(200):
+ # ~ RANDOM_SEED[0] += 1
#~ main()
main()
diff --git a/tests/python/collada/animation/test_animation_simple.py b/tests/python/collada/animation/test_animation_simple.py
index bdfae03aafb..6b18313c3cd 100644
--- a/tests/python/collada/animation/test_animation_simple.py
+++ b/tests/python/collada/animation/test_animation_simple.py
@@ -31,6 +31,7 @@ import difflib
import pathlib
from pathlib import Path
+
def with_tempdir(wrapped):
"""Creates a temporary directory for the function, cleaning up after it returns normally.
@@ -56,8 +57,10 @@ def with_tempdir(wrapped):
return decorator
+
LINE = "+----------------------------------------------------------------"
+
class AbstractColladaTest(unittest.TestCase):
@classmethod
@@ -71,33 +74,33 @@ class AbstractColladaTest(unittest.TestCase):
ref = open(reference)
exp = open(export)
- diff=difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0)
+ diff = difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0)
ref.close()
exp.close()
- diff_count = 0;
+ diff_count = 0
for line in diff:
error = True
for prefix in ('---', '+++', '@@'):
# Ignore diff metadata
if line.startswith(prefix):
- error=False
+ error = False
break
else:
# Ignore time stamps
for ignore in ('<created>', '<modified>', '<authoring_tool>'):
if line[1:].strip().startswith(ignore):
- error=False
+ error = False
break
if error:
- diff_count +=1
+ diff_count += 1
pline = line.strip()
if diff_count == 1:
print("\n%s" % LINE)
print("|Test has errors:")
print(LINE)
pre = "reference" if pline[0] == "-" else "generated"
- print ("| %s:%s"% (pre, pline[1:]))
+ print("| %s:%s" % (pre, pline[1:]))
if diff_count > 0:
print(LINE)
@@ -107,14 +110,16 @@ class AbstractColladaTest(unittest.TestCase):
return diff_count == 0
+
class MeshExportTest4(AbstractColladaTest):
@with_tempdir
def test_export_animation_suzannes_sample_matrix(self, tempdir: pathlib.Path):
test = "suzannes_parent_inverse_sample_10_matrix"
reference_dae = self.testdir / Path("%s.dae" % test)
- outfile = tempdir / Path("%s_out.dae" % test)
+ outfile = tempdir / Path("%s_out.dae" % test)
- bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
+ bpy.ops.wm.collada_export(
+ filepath="%s" % str(outfile),
check_existing=True,
filemode=8,
display_type='DEFAULT',
@@ -142,20 +147,23 @@ class MeshExportTest4(AbstractColladaTest):
export_texture_type_selection='mat',
open_sim=False,
limit_precision=True,
- keep_bind_info=False)
+ keep_bind_info=False,
+ )
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
+
class MeshExportTest3(AbstractColladaTest):
@with_tempdir
def test_export_animation_suzannes_sample_locrotscale(self, tempdir: pathlib.Path):
test = "suzannes_parent_inverse_sample_10_channels"
reference_dae = self.testdir / Path("%s.dae" % test)
- outfile = tempdir / Path("%s_out.dae" % test)
+ outfile = tempdir / Path("%s_out.dae" % test)
- bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
+ bpy.ops.wm.collada_export(
+ filepath="%s" % str(outfile),
check_existing=True,
filemode=8,
display_type='DEFAULT',
@@ -183,20 +191,23 @@ class MeshExportTest3(AbstractColladaTest):
export_texture_type_selection='mat',
open_sim=False,
limit_precision=True,
- keep_bind_info=False)
+ keep_bind_info=False,
+ )
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
+
class MeshExportTest2(AbstractColladaTest):
@with_tempdir
def test_export_animation_suzannes_keyframe_matrix(self, tempdir: pathlib.Path):
test = "suzannes_parent_inverse_keyframes_matrix"
reference_dae = self.testdir / Path("%s.dae" % test)
- outfile = tempdir / Path("%s_out.dae" % test)
+ outfile = tempdir / Path("%s_out.dae" % test)
- bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
+ bpy.ops.wm.collada_export(
+ filepath="%s" % str(outfile),
check_existing=True,
filemode=8,
display_type='DEFAULT',
@@ -224,20 +235,23 @@ class MeshExportTest2(AbstractColladaTest):
export_texture_type_selection='mat',
open_sim=False,
limit_precision=True,
- keep_bind_info=False)
+ keep_bind_info=False,
+ )
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
+
class MeshExportTest1(AbstractColladaTest):
@with_tempdir
def test_export_animation_suzannes_keyframe_locrotscale(self, tempdir: pathlib.Path):
test = "suzannes_parent_inverse_keyframes_channels"
reference_dae = self.testdir / Path("%s.dae" % test)
- outfile = tempdir / Path("%s_out.dae" % test)
+ outfile = tempdir / Path("%s_out.dae" % test)
- bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
+ bpy.ops.wm.collada_export(
+ filepath="%s" % str(outfile),
check_existing=True,
filemode=8,
display_type='DEFAULT',
@@ -265,7 +279,8 @@ class MeshExportTest1(AbstractColladaTest):
export_texture_type_selection='mat',
open_sim=False,
limit_precision=True,
- keep_bind_info=False)
+ keep_bind_info=False,
+ )
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
@@ -277,4 +292,4 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--testdir', required=True)
args, remaining = parser.parse_known_args()
- unittest.main(argv=sys.argv[0:1]+remaining)
+ unittest.main(argv=sys.argv[0:1] + remaining)
diff --git a/tests/python/collada/mesh/test_mesh_simple.py b/tests/python/collada/mesh/test_mesh_simple.py
index 213c6177fde..5899d986a14 100644
--- a/tests/python/collada/mesh/test_mesh_simple.py
+++ b/tests/python/collada/mesh/test_mesh_simple.py
@@ -31,6 +31,7 @@ import difflib
import pathlib
from pathlib import Path
+
def with_tempdir(wrapped):
"""Creates a temporary directory for the function, cleaning up after it returns normally.
@@ -56,8 +57,10 @@ def with_tempdir(wrapped):
return decorator
+
LINE = "+----------------------------------------------------------------"
+
class AbstractColladaTest(unittest.TestCase):
@classmethod
@@ -71,33 +74,33 @@ class AbstractColladaTest(unittest.TestCase):
ref = open(reference)
exp = open(export)
- diff=difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0)
+ diff = difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0)
ref.close()
exp.close()
- diff_count = 0;
+ diff_count = 0
for line in diff:
error = True
for prefix in ('---', '+++', '@@'):
# Ignore diff metadata
if line.startswith(prefix):
- error=False
+ error = False
break
else:
# Ignore time stamps
for ignore in ('<created>', '<modified>', '<authoring_tool>'):
if line[1:].strip().startswith(ignore):
- error=False
+ error = False
break
if error:
- diff_count +=1
+ diff_count += 1
pline = line.strip()
if diff_count == 1:
print("\n%s" % LINE)
print("|Test has errors:")
print(LINE)
pre = "reference" if pline[0] == "-" else "generated"
- print ("| %s:%s"% (pre, pline[1:]))
+ print("| %s:%s" % (pre, pline[1:]))
if diff_count > 0:
print(LINE)
@@ -107,14 +110,16 @@ class AbstractColladaTest(unittest.TestCase):
return diff_count == 0
+
class MeshExportTest(AbstractColladaTest):
@with_tempdir
def test_export_single_mesh(self, tempdir: pathlib.Path):
test = "mesh_simple_001"
reference_dae = self.testdir / Path("%s.dae" % test)
- outfile = tempdir / Path("%s_out.dae" % test)
+ outfile = tempdir / Path("%s_out.dae" % test)
- bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
+ bpy.ops.wm.collada_export(
+ filepath="%s" % str(outfile),
check_existing=True,
filemode=8,
display_type="DEFAULT",
@@ -140,15 +145,17 @@ class MeshExportTest(AbstractColladaTest):
export_texture_type_selection="mat",
open_sim=False,
limit_precision=False,
- keep_bind_info=False)
+ keep_bind_info=False,
+ )
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
+
if __name__ == '__main__':
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
parser = argparse.ArgumentParser()
parser.add_argument('--testdir', required=True)
args, remaining = parser.parse_known_args()
- unittest.main(argv=sys.argv[0:1]+remaining)
+ unittest.main(argv=sys.argv[0:1] + remaining)
diff --git a/tests/python/eevee_render_tests.py b/tests/python/eevee_render_tests.py
index 74e716dc8e6..48751e6bbcb 100755
--- a/tests/python/eevee_render_tests.py
+++ b/tests/python/eevee_render_tests.py
@@ -8,6 +8,7 @@ import shutil
import subprocess
import sys
+
def setup():
import bpy
@@ -29,6 +30,7 @@ def setup():
mat.use_screen_refraction = True
mat.use_screen_subsurface = True
+
# When run from inside Blender, render and exit.
try:
import bpy
diff --git a/tests/python/modules/render_report.py b/tests/python/modules/render_report.py
index 425e6d59fa0..1f0022f13b6 100755
--- a/tests/python/modules/render_report.py
+++ b/tests/python/modules/render_report.py
@@ -23,6 +23,7 @@ class COLORS_DUMMY:
GREEN = ''
ENDC = ''
+
COLORS = COLORS_DUMMY
@@ -55,10 +56,12 @@ def blend_list(dirpath):
filepath = os.path.join(dirpath, filename)
yield filepath
+
def test_get_name(filepath):
filename = os.path.basename(filepath)
return os.path.splitext(filename)[0]
+
def test_get_images(output_dir, filepath, reference_dir):
testname = test_get_name(filepath)
dirpath = os.path.dirname(filepath)
@@ -99,7 +102,7 @@ class Report:
'passed_tests',
'compare_tests',
'compare_engines'
- )
+ )
def __init__(self, title, output_dir, idiff):
self.title = title
@@ -158,7 +161,7 @@ class Report:
filepath = os.path.join(outdir, "compare.data")
pathlib.Path(filepath).write_text(self.compare_tests)
- def _write_html(self, comparison = False):
+ def _write_html(self, comparison=False):
# Gather intermediate data for all tests.
if comparison:
failed_data = []
@@ -307,7 +310,6 @@ class Report:
self.compare_tests += test_html
-
def _diff_output(self, filepath, tmp_filepath):
old_img, ref_img, new_img, diff_img = test_get_images(self.output_dir, filepath, self.reference_dir)
@@ -330,7 +332,7 @@ class Report:
"-failpercent", "1",
ref_img,
tmp_filepath,
- )
+ )
try:
subprocess.check_output(command)
failed = False
@@ -357,7 +359,7 @@ class Report:
"-abs", "-scale", "16",
ref_img,
tmp_filepath
- )
+ )
try:
subprocess.check_output(command)
@@ -367,7 +369,6 @@ class Report:
return not failed
-
def _run_test(self, filepath, render_cb):
testname = test_get_name(filepath)
print_message(testname, 'SUCCESS', 'RUN')
@@ -394,7 +395,7 @@ class Report:
return error
elif error == "NO_START":
print_message('Can not perform tests because blender fails to start.',
- 'Make sure INSTALL target was run.')
+ 'Make sure INSTALL target was run.')
return error
elif error == 'VERIFY':
print_message("Rendered result is different from reference image")
@@ -404,7 +405,6 @@ class Report:
'FAILURE', 'FAILED')
return error
-
def _run_all_tests(self, dirname, dirpath, render_cb):
passed_tests = []
failed_tests = []
@@ -437,8 +437,8 @@ class Report:
'SUCCESS', 'PASSED')
if failed_tests:
print_message("{} tests, listed below:" .
- format(len(failed_tests)),
- 'FAILURE', 'FAILED')
+ format(len(failed_tests)),
+ 'FAILURE', 'FAILED')
failed_tests.sort()
for test in failed_tests:
print_message("{}" . format(test), 'FAILURE', "FAILED")
diff --git a/tests/python/modules/test_utils.py b/tests/python/modules/test_utils.py
index 2b762b4122c..47d720684ba 100755
--- a/tests/python/modules/test_utils.py
+++ b/tests/python/modules/test_utils.py
@@ -62,7 +62,6 @@ class AbstractBlenderRunnerTest(unittest.TestCase):
blender: pathlib.Path = None
testdir: pathlib.Path = None
-
def run_blender(self, filepath: str, python_script: str, timeout: int=300) -> str:
"""Runs Blender by opening a blendfile and executing a script.
@@ -92,7 +91,7 @@ class AbstractBlenderRunnerTest(unittest.TestCase):
'-E', 'CYCLES',
'--python-exit-code', '47',
'--python-expr', python_script,
- ]
+ ]
)
proc = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
diff --git a/tests/python/opengl_draw_tests.py b/tests/python/opengl_draw_tests.py
index 999304570df..ae7f0dabf74 100755
--- a/tests/python/opengl_draw_tests.py
+++ b/tests/python/opengl_draw_tests.py
@@ -8,6 +8,7 @@ import shutil
import subprocess
import sys
+
def screenshot():
import bpy
@@ -19,6 +20,7 @@ def screenshot():
bpy.ops.wm.quit_blender()
+
# When run from inside Blender, take screenshot and exit.
try:
import bpy
@@ -93,5 +95,6 @@ def main():
sys.exit(not ok)
+
if __name__ == "__main__":
main()
diff --git a/tests/python/pep8.py b/tests/python/pep8.py
index ebf2c5eabb7..ccc2dddbbd9 100644
--- a/tests/python/pep8.py
+++ b/tests/python/pep8.py
@@ -93,7 +93,7 @@ def check_files_flake8(files):
# times types are compared,
# I rather keep them specific
"E721",
- )
+ )
for f, pep8_type in files:
@@ -129,10 +129,10 @@ def check_files_pylint(files):
"C0413," # import should be placed at the top
"W0613," # unused argument, may add this back
# but happens a lot for 'context' for eg.
- "W0232," # class has no __init__, Operator/Panel/Menu etc
+ "W0232," # class has no __init__, Operator/Panel/Menu etc
"W0142," # Used * or ** magic
# even needed in some cases
- "R0902," # Too many instance attributes
+ "R0902," # Too many instance attributes
"R0903," # Too many statements
"R0911," # Too many return statements
"R0912," # Too many branches
@@ -204,6 +204,5 @@ def main():
print("Skipping pylint checks (command not found)")
-
if __name__ == "__main__":
main()
diff --git a/tests/python/rna_array.py b/tests/python/rna_array.py
index 0f6c0ce0a57..e0d63cf75ea 100644
--- a/tests/python/rna_array.py
+++ b/tests/python/rna_array.py
@@ -3,7 +3,7 @@
import unittest
import random
-test= bpy.data.test
+test = bpy.data.test
# farr - 1-dimensional array of float
# fdarr - dynamic 1-dimensional array of float
@@ -12,6 +12,7 @@ test= bpy.data.test
# same as above for other types except that the first letter is "i" for int and "b" for bool
+
class TestArray(unittest.TestCase):
# test that assignment works by: assign -> test value
# - rvalue = list of float
@@ -20,14 +21,14 @@ class TestArray(unittest.TestCase):
# bpy.data.test.farr[3], iarr[3], barr[...], fmarr, imarr, bmarr
def setUp(self):
- test.farr= (1.0, 2.0, 3.0)
- test.iarr= (7, 8, 9)
- test.barr= (False, True, False)
+ test.farr = (1.0, 2.0, 3.0)
+ test.iarr = (7, 8, 9)
+ test.barr = (False, True, False)
# test access
# test slice access, negative indices
def test_access(self):
- rvals= ([1.0, 2.0, 3.0], [7, 8, 9], [False, True, False])
+ rvals = ([1.0, 2.0, 3.0], [7, 8, 9], [False, True, False])
for arr, rval in zip((test.farr, test.iarr, test.barr), rvals):
self.assertEqual(prop_to_list(arr), rval)
self.assertEqual(arr[0:3], rval)
@@ -39,12 +40,12 @@ class TestArray(unittest.TestCase):
# fail when index out of bounds
def test_access_fail(self):
for arr in (test.farr, test.iarr, test.barr):
- self.assertRaises(IndexError, lambda : arr[4])
+ self.assertRaises(IndexError, lambda: arr[4])
# test assignment of a whole array
def test_assign_array(self):
# should accept int as float
- test.farr= (1, 2, 3)
+ test.farr = (1, 2, 3)
# fail when: unexpected no. of items, invalid item type
def test_assign_array_fail(self):
@@ -55,20 +56,20 @@ class TestArray(unittest.TestCase):
self.assertRaises(ValueError, assign_empty_list, arr)
def assign_invalid_float():
- test.farr= (1.0, 2.0, "3.0")
+ test.farr = (1.0, 2.0, "3.0")
def assign_invalid_int():
- test.iarr= ("1", 2, 3)
+ test.iarr = ("1", 2, 3)
def assign_invalid_bool():
- test.barr= (True, 0.123, False)
+ test.barr = (True, 0.123, False)
for func in [assign_invalid_float, assign_invalid_int, assign_invalid_bool]:
self.assertRaises(TypeError, func)
# shouldn't accept float as int
def assign_float_as_int():
- test.iarr= (1, 2, 3.0)
+ test.iarr = (1, 2, 3.0)
self.assertRaises(TypeError, assign_float_as_int)
# non-dynamic arrays cannot change size
@@ -81,14 +82,14 @@ class TestArray(unittest.TestCase):
def test_assign_item(self):
for arr, rand_func in zip((test.farr, test.iarr, test.barr), (rand_float, rand_int, rand_bool)):
for i in range(len(arr)):
- val= rand_func()
+ val = rand_func()
arr[i] = val
self.assertEqual(arr[i], val)
# float prop should accept also int
for i in range(len(test.farr)):
- val= rand_int()
+ val = rand_int()
test.farr[i] = val
self.assertEqual(test.farr[i], float(val))
@@ -112,7 +113,7 @@ class TestArray(unittest.TestCase):
# test various lengths here
for arr, rand_func in zip(("fdarr", "idarr", "bdarr"), (rand_float, rand_int, rand_bool)):
for length in range(1, 64):
- rval= make_random_array(length, rand_func)
+ rval = make_random_array(length, rand_func)
setattr(test, arr, rval)
self.assertEqual(prop_to_list(getattr(test, arr)), rval)
@@ -136,7 +137,7 @@ class TestMArray(unittest.TestCase):
def test_assign_array(self):
for arr, func in zip(("fmarr", "imarr", "bmarr"), (rand_float, rand_int, rand_bool)):
# assignment of [3][4][5]
- rval= make_random_3d_array((3, 4, 5), func)
+ rval = make_random_3d_array((3, 4, 5), func)
setattr(test, arr, rval)
self.assertEqual(prop_to_list(getattr(test, arr)), rval)
@@ -144,7 +145,7 @@ class TestMArray(unittest.TestCase):
def test_assign_array_fail(self):
def assign_empty_array():
- test.fmarr= ()
+ test.fmarr = ()
self.assertRaises(ValueError, assign_empty_array)
def assign_invalid_size(arr, rval):
@@ -152,19 +153,19 @@ class TestMArray(unittest.TestCase):
# assignment of 3,4,4 or 3,3,5 should raise ex
for arr, func in zip(("fmarr", "imarr", "bmarr"), (rand_float, rand_int, rand_bool)):
- rval= make_random_3d_array((3, 4, 4), func)
+ rval = make_random_3d_array((3, 4, 4), func)
self.assertRaises(ValueError, assign_invalid_size, arr, rval)
- rval= make_random_3d_array((3, 3, 5), func)
+ rval = make_random_3d_array((3, 3, 5), func)
self.assertRaises(ValueError, assign_invalid_size, arr, rval)
- rval= make_random_3d_array((3, 3, 3), func)
+ rval = make_random_3d_array((3, 3, 3), func)
self.assertRaises(ValueError, assign_invalid_size, arr, rval)
def test_assign_item(self):
# arr[i] = x
for arr, func in zip(("fmarr", "imarr", "bmarr", "fdmarr", "idmarr", "bdmarr"), (rand_float, rand_int, rand_bool) * 2):
- rval= make_random_2d_array((4, 5), func)
+ rval = make_random_2d_array((4, 5), func)
for i in range(3):
getattr(test, arr)[i] = rval
@@ -173,23 +174,22 @@ class TestMArray(unittest.TestCase):
# arr[i][j] = x
for arr, func in zip(("fmarr", "imarr", "bmarr", "fdmarr", "idmarr", "bdmarr"), (rand_float, rand_int, rand_bool) * 2):
- arr= getattr(test, arr)
- rval= make_random_array(5, func)
+ arr = getattr(test, arr)
+ rval = make_random_array(5, func)
for i in range(3):
for j in range(4):
arr[i][j] = rval
self.assertEqual(prop_to_list(arr[i][j]), rval)
-
def test_assign_item_fail(self):
def assign_wrong_size(arr, i, rval):
getattr(test, arr)[i] = rval
# assign wrong size at level 2
for arr, func in zip(("fmarr", "imarr", "bmarr"), (rand_float, rand_int, rand_bool)):
- rval1= make_random_2d_array((3, 5), func)
- rval2= make_random_2d_array((4, 3), func)
+ rval1 = make_random_2d_array((3, 5), func)
+ rval2 = make_random_2d_array((4, 3), func)
for i in range(3):
self.assertRaises(ValueError, assign_wrong_size, arr, i, rval1)
@@ -198,22 +198,22 @@ class TestMArray(unittest.TestCase):
def test_dynamic_assign_array(self):
for arr, func in zip(("fdmarr", "idmarr", "bdmarr"), (rand_float, rand_int, rand_bool)):
# assignment of [3][4][5]
- rval= make_random_3d_array((3, 4, 5), func)
+ rval = make_random_3d_array((3, 4, 5), func)
setattr(test, arr, rval)
self.assertEqual(prop_to_list(getattr(test, arr)), rval)
# [2][4][5]
- rval= make_random_3d_array((2, 4, 5), func)
+ rval = make_random_3d_array((2, 4, 5), func)
setattr(test, arr, rval)
self.assertEqual(prop_to_list(getattr(test, arr)), rval)
# [1][4][5]
- rval= make_random_3d_array((1, 4, 5), func)
+ rval = make_random_3d_array((1, 4, 5), func)
setattr(test, arr, rval)
self.assertEqual(prop_to_list(getattr(test, arr)), rval)
-
# test access
+
def test_access(self):
pass
@@ -221,26 +221,32 @@ class TestMArray(unittest.TestCase):
def test_access_fail(self):
pass
+
random.seed()
+
def rand_int():
return random.randint(-1000, 1000)
+
def rand_float():
return float(rand_int())
+
def rand_bool():
return bool(random.randint(0, 1))
+
def make_random_array(len, rand_func):
- arr= []
+ arr = []
for i in range(len):
arr.append(rand_func())
return arr
+
def make_random_2d_array(dimsize, rand_func):
- marr= []
+ marr = []
for i in range(dimsize[0]):
marr.append([])
@@ -249,8 +255,9 @@ def make_random_2d_array(dimsize, rand_func):
return marr
+
def make_random_3d_array(dimsize, rand_func):
- marr= []
+ marr = []
for i in range(dimsize[0]):
marr.append([])
@@ -262,8 +269,9 @@ def make_random_3d_array(dimsize, rand_func):
return marr
+
def prop_to_list(prop):
- ret= []
+ ret = []
for x in prop:
if type(x) not in {bool, int, float}:
@@ -273,8 +281,10 @@ def prop_to_list(prop):
return ret
+
def suite():
return unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestArray), unittest.TestLoader().loadTestsFromTestCase(TestMArray)])
+
if __name__ == "__main__":
unittest.TextTestRunner(verbosity=2).run(suite())
diff --git a/tests/python/view_layer/test_active_collection.py b/tests/python/view_layer/test_active_collection.py
index 10df71f77ce..1c6c3cd1983 100644
--- a/tests/python/view_layer/test_active_collection.py
+++ b/tests/python/view_layer/test_active_collection.py
@@ -42,23 +42,23 @@ class UnitTesting(ViewLayerTesting):
layer.collections.link(subzero)
lookup = [
- 'Master Collection',
- '1',
- 'sub-zero',
- 'scorpion',
- '2',
- '3',
- '4',
- '5',
- 'sub-zero',
- 'scorpion']
+ 'Master Collection',
+ '1',
+ 'sub-zero',
+ 'scorpion',
+ '2',
+ '3',
+ '4',
+ '5',
+ 'sub-zero',
+ 'scorpion']
for i, name in enumerate(lookup):
layer.collections.active_index = i
self.assertEqual(
- name, layer.collections.active.name,
- "Collection index mismatch: [{0}] : {1} != {2}".format(
- i, name, layer.collections.active.name))
+ name, layer.collections.active.name,
+ "Collection index mismatch: [{0}] : {1} != {2}".format(
+ i, name, layer.collections.active.name))
# ############################################################
diff --git a/tests/python/view_layer/test_collection_new_sync.py b/tests/python/view_layer/test_collection_new_sync.py
index 582e6c13d89..46b63c64f45 100644
--- a/tests/python/view_layer/test_collection_new_sync.py
+++ b/tests/python/view_layer/test_collection_new_sync.py
@@ -26,16 +26,16 @@ class UnitTesting(ViewLayerTesting):
self.assertEqual(view_layer.collections[0].collection, scene.master_collection)
self.assertEqual(
- {collection.name for collection in view_layer.collections[0].collections},
- {'Collection 1'})
+ {collection.name for collection in view_layer.collections[0].collections},
+ {'Collection 1'})
self.assertEqual(
- bpy.ops.outliner.collection_new(),
- {'FINISHED'})
+ bpy.ops.outliner.collection_new(),
+ {'FINISHED'})
self.assertEqual(
- {collection.name for collection in view_layer.collections[0].collections},
- {'Collection 1', 'Collection 2'})
+ {collection.name for collection in view_layer.collections[0].collections},
+ {'Collection 1', 'Collection 2'})
# ############################################################
diff --git a/tests/python/view_layer/test_group_d.py b/tests/python/view_layer/test_group_d.py
index 6f54ca5340a..709d27df184 100644
--- a/tests/python/view_layer/test_group_d.py
+++ b/tests/python/view_layer/test_group_d.py
@@ -46,7 +46,6 @@ class UnitTesting(ViewLayerTesting):
self.assertEqual(1, bpy.data.groups[0].users)
self.assertEqual(3, len(bpy.data.groups[0].objects))
-
# empty the group of objects
group = bpy.data.groups[0]
while group.objects:
diff --git a/tests/python/view_layer/test_layer_linking.py b/tests/python/view_layer/test_layer_linking.py
index 4c66c564d7c..43c88aa65f9 100644
--- a/tests/python/view_layer/test_layer_linking.py
+++ b/tests/python/view_layer/test_layer_linking.py
@@ -67,7 +67,7 @@ class UnitTesting(ViewLayerTesting):
self.assertTrue(compare_files(
filepath_nested_json,
filepath_json,
- ),
+ ),
"Scene dump files differ")
def test_syncing_layer_new(self):
diff --git a/tests/python/view_layer/test_layer_syncing.py b/tests/python/view_layer/test_layer_syncing.py
index d8175c4850f..9baf25f9e9e 100644
--- a/tests/python/view_layer/test_layer_syncing.py
+++ b/tests/python/view_layer/test_layer_syncing.py
@@ -68,7 +68,7 @@ class UnitTesting(ViewLayerTesting):
self.assertTrue(compare_files(
filepath_nested_json,
filepath_json,
- ),
+ ),
"Scene dump files differ")
def test_syncing_link(self):
diff --git a/tests/python/view_layer/test_make_single_user.py b/tests/python/view_layer/test_make_single_user.py
index 2a8a479bab2..292c2d50605 100644
--- a/tests/python/view_layer/test_make_single_user.py
+++ b/tests/python/view_layer/test_make_single_user.py
@@ -33,7 +33,7 @@ class UnitTesting(ViewLayerTesting):
while master_collection.collections:
master_collection.collections.remove(
- master_collection.collections[0])
+ master_collection.collections[0])
view_layer.collections.link(master_collection)
ob.select_set('SELECT')
diff --git a/tests/python/view_layer/test_move_above_below_layer_collection_f.py b/tests/python/view_layer/test_move_above_below_layer_collection_f.py
index 77d65ef8671..036486bf55a 100644
--- a/tests/python/view_layer/test_move_above_below_layer_collection_f.py
+++ b/tests/python/view_layer/test_move_above_below_layer_collection_f.py
@@ -16,36 +16,36 @@ from view_layer_common import *
class UnitTesting(MoveLayerCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ['2', None],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ['2', None],
+ ]],
+ ]
return reference_tree_map
def get_reference_layers_tree_map(self):
reference_layers_map = [
- ['Layer 1', [
- 'Master Collection',
- 'C',
- '3',
- ]],
- ['Layer 2', [
- 'C',
- 'dog',
- 'cat',
- ]],
- ]
+ ['Layer 1', [
+ 'Master Collection',
+ 'C',
+ '3',
+ ]],
+ ['Layer 2', [
+ 'C',
+ 'dog',
+ 'cat',
+ ]],
+ ]
return reference_layers_map
def test_layer_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_layer_collection_g.py b/tests/python/view_layer/test_move_above_below_layer_collection_g.py
index 16cd628edfc..aca6c5d5ff6 100644
--- a/tests/python/view_layer/test_move_above_below_layer_collection_g.py
+++ b/tests/python/view_layer/test_move_above_below_layer_collection_g.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveLayerCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['cat', None],
- ['dog', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['cat', None],
+ ['dog', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def get_reference_layers_tree_map(self):
diff --git a/tests/python/view_layer/test_move_above_below_layer_collection_i.py b/tests/python/view_layer/test_move_above_below_layer_collection_i.py
index 0134d11adcd..dada882a412 100644
--- a/tests/python/view_layer/test_move_above_below_layer_collection_i.py
+++ b/tests/python/view_layer/test_move_above_below_layer_collection_i.py
@@ -20,18 +20,18 @@ class UnitTesting(MoveLayerCollectionTesting):
def get_reference_layers_tree_map(self):
reference_layers_map = [
- ['Layer 1', [
- 'Master Collection',
- 'C',
- '3',
- ]],
- ['Layer 2', [
- '3',
- 'C',
- 'dog',
- 'cat',
- ]],
- ]
+ ['Layer 1', [
+ 'Master Collection',
+ 'C',
+ '3',
+ ]],
+ ['Layer 2', [
+ '3',
+ 'C',
+ 'dog',
+ 'cat',
+ ]],
+ ]
return reference_layers_map
def test_layer_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_layer_collection_l.py b/tests/python/view_layer/test_move_above_below_layer_collection_l.py
index 2bc1054ec7e..a8fad414685 100644
--- a/tests/python/view_layer/test_move_above_below_layer_collection_l.py
+++ b/tests/python/view_layer/test_move_above_below_layer_collection_l.py
@@ -20,18 +20,18 @@ class UnitTesting(MoveLayerCollectionTesting):
def get_reference_layers_tree_map(self):
reference_layers_map = [
- ['Layer 1', [
- 'Master Collection',
- 'C',
- '3',
- ]],
- ['Layer 2', [
- 'C',
- 'cat',
- '3',
- 'dog',
- ]],
- ]
+ ['Layer 1', [
+ 'Master Collection',
+ 'C',
+ '3',
+ ]],
+ ['Layer 2', [
+ 'C',
+ 'cat',
+ '3',
+ 'dog',
+ ]],
+ ]
return reference_layers_map
def test_layer_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_a.py b/tests/python/view_layer/test_move_above_below_scene_collection_a.py
index 3e45102e0b2..f558491527e 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_a.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_a.py
@@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
# original tree, no changes
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_b.py b/tests/python/view_layer/test_move_above_below_scene_collection_b.py
index 83980705846..037ee01e205 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_b.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_b.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ['1', None],
- ['2', None],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ['1', None],
+ ['2', None],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_c.py b/tests/python/view_layer/test_move_above_below_scene_collection_c.py
index cceb2bb235b..07b67092d3e 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_c.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_c.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_d.py b/tests/python/view_layer/test_move_above_below_scene_collection_d.py
index 5917e9ceb6c..9923d917abf 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_d.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_d.py
@@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
# original tree, no changes
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['B', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['B', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_e.py b/tests/python/view_layer/test_move_above_below_scene_collection_e.py
index 12778ff9131..b9076826551 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_e.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_e.py
@@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
# original tree, no changes
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['iii', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['iii', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_f.py b/tests/python/view_layer/test_move_above_below_scene_collection_f.py
index b9d5e8eff24..3343d0d774b 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_f.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_f.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['dog', None],
- ['cat', None],
- ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
]],
- ]
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py
index d36930dcbc5..73c79b0de87 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py
@@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
# original tree, no changes
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py
index 79718e1168a..552ca0d5c9b 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ['1', None],
- ['2', None],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ['1', None],
+ ['2', None],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py
index ef23b722b8b..c54115b0d13 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py
index 05c3bcdbcbb..bb770f61344 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py
@@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
# original tree, no changes
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['B', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['B', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py
index ebab970ba19..88a77bf8385 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py
@@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
# original tree, no changes
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['iii', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['iii', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move_a(self):
diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py
index 7e4f0bc4a9c..013165986f4 100644
--- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py
+++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['dog', None],
- ['cat', None],
- ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
]],
- ]
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_move(self):
diff --git a/tests/python/view_layer/test_move_into_layer_collection_a.py b/tests/python/view_layer/test_move_into_layer_collection_a.py
index ef5a839a44a..85e24e53463 100644
--- a/tests/python/view_layer/test_move_into_layer_collection_a.py
+++ b/tests/python/view_layer/test_move_into_layer_collection_a.py
@@ -17,38 +17,38 @@ class UnitTesting(MoveLayerCollectionTesting):
def get_reference_scene_tree_map(self):
# original tree, no changes
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def get_reference_layers_tree_map(self):
# original tree, no changes
reference_layers_map = [
- ['Layer 1', [
- 'Master Collection',
- 'C',
- '3',
- ]],
- ['Layer 2', [
- 'C',
- '3',
- 'dog',
- 'cat',
- ]],
- ]
+ ['Layer 1', [
+ 'Master Collection',
+ 'C',
+ '3',
+ ]],
+ ['Layer 2', [
+ 'C',
+ '3',
+ 'dog',
+ 'cat',
+ ]],
+ ]
return reference_layers_map
def test_layer_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_layer_collection_f.py b/tests/python/view_layer/test_move_into_layer_collection_f.py
index 7bf007d2724..7595619f42a 100644
--- a/tests/python/view_layer/test_move_into_layer_collection_f.py
+++ b/tests/python/view_layer/test_move_into_layer_collection_f.py
@@ -16,36 +16,36 @@ from view_layer_common import *
class UnitTesting(MoveLayerCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ]],
+ ]
return reference_tree_map
def get_reference_layers_tree_map(self):
reference_layers_map = [
- ['Layer 1', [
- 'Master Collection',
- 'C',
- ]],
- ['Layer 2', [
- 'C',
- '3',
- 'dog',
- 'cat',
- ]],
- ]
+ ['Layer 1', [
+ 'Master Collection',
+ 'C',
+ ]],
+ ['Layer 2', [
+ 'C',
+ '3',
+ 'dog',
+ 'cat',
+ ]],
+ ]
return reference_layers_map
def test_layer_collection_into_a(self):
diff --git a/tests/python/view_layer/test_move_into_layer_collection_g.py b/tests/python/view_layer/test_move_into_layer_collection_g.py
index efcdd44da97..90f6739d249 100644
--- a/tests/python/view_layer/test_move_into_layer_collection_g.py
+++ b/tests/python/view_layer/test_move_into_layer_collection_g.py
@@ -20,17 +20,17 @@ class UnitTesting(MoveLayerCollectionTesting):
def get_reference_layers_tree_map(self):
reference_layers_map = [
- ['Layer 1', [
- 'Master Collection',
- 'C',
- '3',
- ]],
- ['Layer 2', [
- 'C',
- 'dog',
- 'cat',
- ]],
- ]
+ ['Layer 1', [
+ 'Master Collection',
+ 'C',
+ '3',
+ ]],
+ ['Layer 2', [
+ 'C',
+ 'dog',
+ 'cat',
+ ]],
+ ]
return reference_layers_map
def test_layer_collection_into_a(self):
diff --git a/tests/python/view_layer/test_move_into_layer_collection_h.py b/tests/python/view_layer/test_move_into_layer_collection_h.py
index 82f5d70dceb..0e5a86c57ae 100644
--- a/tests/python/view_layer/test_move_into_layer_collection_h.py
+++ b/tests/python/view_layer/test_move_into_layer_collection_h.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveLayerCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', [
- ['dog', None],
- ]],
- ['2', None],
- ['3', [
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', [
+ ['dog', None],
+ ]],
+ ['2', None],
+ ['3', [
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def get_reference_layers_tree_map(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_a.py b/tests/python/view_layer/test_move_into_scene_collection_a.py
index c5671d46316..ab997ddf9b6 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_a.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_a.py
@@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
# original tree, no changes
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_b.py b/tests/python/view_layer/test_move_into_scene_collection_b.py
index 08cacde6f0c..4254a736b40 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_b.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_b.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', [
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ['C', [
- ['1', None],
- ['2', None],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', [
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_c.py b/tests/python/view_layer/test_move_into_scene_collection_c.py
index 83b1d2fc52b..1c9aa295f72 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_c.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_c.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', [
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', [
['cat', None],
- ]],
- ]],
]],
- ]
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_e.py b/tests/python/view_layer/test_move_into_scene_collection_e.py
index 00a4274c564..f8d37eb769d 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_e.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_e.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', [
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', [
['B', None],
- ]],
- ]],
]],
- ]
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_f.py b/tests/python/view_layer/test_move_into_scene_collection_f.py
index 4cba04c35a5..a89c7dd81e9 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_f.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_f.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ['B', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ['B', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_g.py b/tests/python/view_layer/test_move_into_scene_collection_g.py
index 5ca2658407f..04919ca720b 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_g.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_g.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', [
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', [
['A', [
['i', None],
['ii', None],
['iii', None],
- ]],
]],
- ['cat', None],
- ]],
]],
- ]
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_h.py b/tests/python/view_layer/test_move_into_scene_collection_h.py
index 1524dbad7bc..57b15c4ef44 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_h.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_h.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', [
- ['ii', None],
- ]],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', [
+ ['ii', None],
+ ]],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_i.py b/tests/python/view_layer/test_move_into_scene_collection_i.py
index 2240ba50d75..7b4076f3fd9 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_i.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_i.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', [
+ ['A', [
+ ['i', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', [
['ii', None],
- ]],
- ['cat', None],
- ]],
]],
- ]
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_b.py b/tests/python/view_layer/test_move_into_scene_collection_sync_b.py
index a4d05b57f77..a485d7160d6 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_sync_b.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_sync_b.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', [
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ['C', [
- ['1', None],
- ['2', None],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', [
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_c.py b/tests/python/view_layer/test_move_into_scene_collection_sync_c.py
index 3f125d513ce..e68e1d04a56 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_sync_c.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_sync_c.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', [
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', [
['cat', None],
- ]],
- ]],
]],
- ]
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_e.py b/tests/python/view_layer/test_move_into_scene_collection_sync_e.py
index 689b4976dab..fac8d46e471 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_sync_e.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_sync_e.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', [
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', [
['B', None],
- ]],
- ]],
]],
- ]
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_f.py b/tests/python/view_layer/test_move_into_scene_collection_sync_f.py
index e486f48aac1..bce9e45a764 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_sync_f.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_sync_f.py
@@ -16,21 +16,21 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ['B', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ['B', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_g.py b/tests/python/view_layer/test_move_into_scene_collection_sync_g.py
index 3792e9429a3..8b08eb9f210 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_sync_g.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_sync_g.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', [
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', [
['A', [
['i', None],
['ii', None],
['iii', None],
- ]],
]],
- ['cat', None],
- ]],
]],
- ]
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_h.py b/tests/python/view_layer/test_move_into_scene_collection_sync_h.py
index 8b3ceb14d73..f7eeb00b150 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_sync_h.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_sync_h.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', [
- ['ii', None],
- ]],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', [
+ ['ii', None],
+ ]],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_i.py b/tests/python/view_layer/test_move_into_scene_collection_sync_i.py
index 8262dcc06c1..373665dd732 100644
--- a/tests/python/view_layer/test_move_into_scene_collection_sync_i.py
+++ b/tests/python/view_layer/test_move_into_scene_collection_sync_i.py
@@ -16,22 +16,22 @@ from view_layer_common import *
class UnitTesting(MoveSceneCollectionSyncTesting):
def get_reference_scene_tree_map(self):
reference_tree_map = [
- ['A', [
- ['i', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', [
+ ['A', [
+ ['i', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', [
['ii', None],
- ]],
- ['cat', None],
- ]],
]],
- ]
+ ['cat', None],
+ ]],
+ ]],
+ ]
return reference_tree_map
def test_scene_collection_into(self):
diff --git a/tests/python/view_layer/test_object_copy.py b/tests/python/view_layer/test_object_copy.py
index 15d863f3138..19a7c56b989 100644
--- a/tests/python/view_layer/test_object_copy.py
+++ b/tests/python/view_layer/test_object_copy.py
@@ -68,7 +68,7 @@ class UnitTesting(ViewLayerTesting):
self.assertTrue(compare_files(
filepath_objects_json,
filepath_json,
- ),
+ ),
"Scene dump files differ")
def test_copy_object(self):
diff --git a/tests/python/view_layer/test_operator_context.py b/tests/python/view_layer/test_operator_context.py
index 38379aa2a75..d11666de118 100644
--- a/tests/python/view_layer/test_operator_context.py
+++ b/tests/python/view_layer/test_operator_context.py
@@ -27,19 +27,19 @@ class UnitTesting(ViewLayerTesting):
bl_label = "Sample Operator"
view_layer = bpy.props.StringProperty(
- default="Not Set",
- options={'SKIP_SAVE'},
- )
+ default="Not Set",
+ options={'SKIP_SAVE'},
+ )
scene_collection = bpy.props.StringProperty(
- default="",
- options={'SKIP_SAVE'},
- )
+ default="",
+ options={'SKIP_SAVE'},
+ )
use_verbose = bpy.props.BoolProperty(
- default=False,
- options={'SKIP_SAVE'},
- )
+ default=False,
+ options={'SKIP_SAVE'},
+ )
def execute(self, context):
view_layer = context.view_layer
diff --git a/tests/python/view_layer/test_scene_copy_a.py b/tests/python/view_layer/test_scene_copy_a.py
index 8cccb26a92d..8f0f2316ce1 100644
--- a/tests/python/view_layer/test_scene_copy_a.py
+++ b/tests/python/view_layer/test_scene_copy_a.py
@@ -23,9 +23,9 @@ class UnitTesting(ViewLayerTesting):
filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full_simple.json')
self.do_scene_copy(
- filepath_layers_json_copy,
- 'FULL_COPY',
- (get_scene_collections,))
+ filepath_layers_json_copy,
+ 'FULL_COPY',
+ (get_scene_collections,))
# ############################################################
diff --git a/tests/python/view_layer/test_scene_copy_b.py b/tests/python/view_layer/test_scene_copy_b.py
index 1d53b56719d..73c6976c32c 100644
--- a/tests/python/view_layer/test_scene_copy_b.py
+++ b/tests/python/view_layer/test_scene_copy_b.py
@@ -24,9 +24,9 @@ class UnitTesting(ViewLayerTesting):
# note: nothing should change, so using `layers_simple.json`
filepath_layers_json_copy = os.path.join(ROOT, 'layers_simple.json')
self.do_scene_copy(
- filepath_layers_json_copy,
- 'LINK_OBJECTS',
- (get_scene_collections,))
+ filepath_layers_json_copy,
+ 'LINK_OBJECTS',
+ (get_scene_collections,))
# ############################################################
diff --git a/tests/python/view_layer/test_scene_copy_c.py b/tests/python/view_layer/test_scene_copy_c.py
index c9bb0924848..57c875c047c 100644
--- a/tests/python/view_layer/test_scene_copy_c.py
+++ b/tests/python/view_layer/test_scene_copy_c.py
@@ -23,9 +23,9 @@ class UnitTesting(ViewLayerTesting):
filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full.json')
self.do_scene_copy(
- filepath_layers_json_copy,
- 'FULL_COPY',
- (get_scene_collections, get_layers))
+ filepath_layers_json_copy,
+ 'FULL_COPY',
+ (get_scene_collections, get_layers))
# ############################################################
diff --git a/tests/python/view_layer/test_scene_copy_d.py b/tests/python/view_layer/test_scene_copy_d.py
index 6efd93c7659..6db3fb797e5 100644
--- a/tests/python/view_layer/test_scene_copy_d.py
+++ b/tests/python/view_layer/test_scene_copy_d.py
@@ -23,9 +23,9 @@ class UnitTesting(ViewLayerTesting):
filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_link.json')
self.do_scene_copy(
- filepath_layers_json_copy,
- 'LINK_OBJECTS',
- (get_scene_collections, get_layers))
+ filepath_layers_json_copy,
+ 'LINK_OBJECTS',
+ (get_scene_collections, get_layers))
# ############################################################
diff --git a/tests/python/view_layer/test_scene_write_read.py b/tests/python/view_layer/test_scene_write_read.py
index 6c750d87987..92f3395d819 100644
--- a/tests/python/view_layer/test_scene_write_read.py
+++ b/tests/python/view_layer/test_scene_write_read.py
@@ -46,7 +46,7 @@ class UnitTesting(ViewLayerTesting):
self.assertTrue(compare_files(
filepath_doversion_json,
filepath_layers_json,
- ),
+ ),
"Run: test_scene_write_layers")
if do_read:
@@ -65,7 +65,7 @@ class UnitTesting(ViewLayerTesting):
self.assertTrue(compare_files(
filepath_read_json,
filepath_layers_json,
- ),
+ ),
"Scene dump files differ")
def test_scene_write_collections(self):
@@ -79,10 +79,10 @@ class UnitTesting(ViewLayerTesting):
filepath_layers_json = os.path.join(ROOT, 'layers_simple.json')
self.do_scene_write_read(
- filepath_layers,
- filepath_layers_json,
- (get_scene_collections,),
- False)
+ filepath_layers,
+ filepath_layers_json,
+ (get_scene_collections,),
+ False)
def test_scene_write_layers(self):
"""
@@ -95,10 +95,10 @@ class UnitTesting(ViewLayerTesting):
filepath_layers_json = os.path.join(ROOT, 'layers.json')
self.do_scene_write_read(
- filepath_layers,
- filepath_layers_json,
- (get_scene_collections, get_layers),
- False)
+ filepath_layers,
+ filepath_layers_json,
+ (get_scene_collections, get_layers),
+ False)
def test_scene_read_collections(self):
"""
@@ -112,10 +112,10 @@ class UnitTesting(ViewLayerTesting):
filepath_layers_json = os.path.join(ROOT, 'layers_simple.json')
self.do_scene_write_read(
- filepath_layers,
- filepath_layers_json,
- (get_scene_collections,),
- True)
+ filepath_layers,
+ filepath_layers_json,
+ (get_scene_collections,),
+ True)
def test_scene_read_layers(self):
"""
@@ -129,10 +129,10 @@ class UnitTesting(ViewLayerTesting):
filepath_layers_json = os.path.join(ROOT, 'layers.json')
self.do_scene_write_read(
- filepath_layers,
- filepath_layers_json,
- (get_scene_collections, get_layers),
- True)
+ filepath_layers,
+ filepath_layers_json,
+ (get_scene_collections, get_layers),
+ True)
# ############################################################
diff --git a/tests/python/view_layer/view_layer_common.py b/tests/python/view_layer/view_layer_common.py
index 8dcc094a1c6..25cf7c80d96 100644
--- a/tests/python/view_layer/view_layer_common.py
+++ b/tests/python/view_layer/view_layer_common.py
@@ -157,11 +157,11 @@ def query_scene(filepath, name, callbacks):
def dump(data):
import json
return json.dumps(
- data,
- sort_keys=True,
- indent=4,
- separators=(',', ': '),
- )
+ data,
+ sort_keys=True,
+ indent=4,
+ separators=(',', ': '),
+ )
# ############################################################
@@ -170,7 +170,7 @@ def dump(data):
PDB = False
DUMP_DIFF = True
-UPDATE_DIFF = False # HACK used to update tests when something change
+UPDATE_DIFF = False # HACK used to update tests when something change
def compare_files(file_a, file_b):
@@ -188,7 +188,6 @@ def compare_files(file_a, file_b):
import subprocess
subprocess.call(["cp", "-u", file_a, file_b])
-
if PDB:
import pdb
print("Files differ:", file_b, file_a)
@@ -239,8 +238,8 @@ class ViewLayerTesting(unittest.TestCase):
def path_exists(self, filepath):
import os
self.assertTrue(
- os.path.exists(filepath),
- "Test file \"{0}\" not found".format(filepath))
+ os.path.exists(filepath),
+ "Test file \"{0}\" not found".format(filepath))
def do_object_add(self, filepath_json, add_mode):
"""
@@ -307,7 +306,7 @@ class ViewLayerTesting(unittest.TestCase):
self.assertTrue(compare_files(
filepath_objects_json,
filepath_json,
- ),
+ ),
"Scene dump files differ")
def do_object_add_no_collection(self, add_mode):
@@ -356,7 +355,7 @@ class ViewLayerTesting(unittest.TestCase):
(self.path_exists(f) for f in (
filepath_layers,
filepath_json_reference,
- ))
+ ))
filepath_saved = os.path.join(dirpath, '{0}.blend'.format(copy_mode))
filepath_json = os.path.join(dirpath, "{0}.json".format(copy_mode))
@@ -376,7 +375,7 @@ class ViewLayerTesting(unittest.TestCase):
self.assertTrue(compare_files(
filepath_json,
filepath_json_reference,
- ),
+ ),
"Scene copy \"{0}\" test failed".format(copy_mode.title()))
def do_object_delete(self, del_mode):
@@ -437,7 +436,7 @@ class ViewLayerTesting(unittest.TestCase):
self.assertTrue(compare_files(
filepath_generated_json,
filepath_reference_json,
- ),
+ ),
"Scene dump files differ")
def do_visibility_object_add(self, add_mode):
@@ -517,23 +516,24 @@ class MoveSceneCollectionTesting(ViewLayerTesting):
"""
To be used by tests of view_layer_move_into_scene_collection
"""
+
def get_initial_scene_tree_map(self):
collections_map = [
- ['A', [
- ['i', None],
- ['ii', None],
- ['iii', None],
- ]],
- ['B', None],
- ['C', [
- ['1', None],
- ['2', None],
- ['3', [
- ['dog', None],
- ['cat', None],
- ]],
- ]],
- ]
+ ['A', [
+ ['i', None],
+ ['ii', None],
+ ['iii', None],
+ ]],
+ ['B', None],
+ ['C', [
+ ['1', None],
+ ['2', None],
+ ['3', [
+ ['dog', None],
+ ['cat', None],
+ ]],
+ ]],
+ ]
return collections_map
def build_scene_tree(self, tree_map, collection=None, ret_dict=None):
@@ -565,8 +565,8 @@ class MoveSceneCollectionTesting(ViewLayerTesting):
"""
self.cleanup_tree()
self.assertTrue(
- hasattr(self, "get_initial_scene_tree_map"),
- "Test class has no get_initial_scene_tree_map method implemented")
+ hasattr(self, "get_initial_scene_tree_map"),
+ "Test class has no get_initial_scene_tree_map method implemented")
return self.build_scene_tree(self.get_initial_scene_tree_map())
@@ -605,20 +605,21 @@ class MoveSceneCollectionSyncTesting(MoveSceneCollectionTesting):
"""
To be used by tests of view_layer_move_into_scene_collection_sync
"""
+
def get_initial_layers_tree_map(self):
layers_map = [
- ['Layer 1', [
- 'Master Collection',
- 'C',
- '3',
- ]],
- ['Layer 2', [
- 'C',
- '3',
- 'dog',
- 'cat',
- ]],
- ]
+ ['Layer 1', [
+ 'Master Collection',
+ 'C',
+ '3',
+ ]],
+ ['Layer 2', [
+ 'C',
+ '3',
+ 'dog',
+ 'cat',
+ ]],
+ ]
return layers_map
def get_reference_layers_tree_map(self):
@@ -634,8 +635,8 @@ class MoveSceneCollectionSyncTesting(MoveSceneCollectionTesting):
scene = bpy.context.scene
self.assertTrue(
- hasattr(self, "get_initial_layers_tree_map"),
- "Test class has no get_initial_layers_tree_map method implemented")
+ hasattr(self, "get_initial_layers_tree_map"),
+ "Test class has no get_initial_layers_tree_map method implemented")
layers_map = self.get_initial_layers_tree_map()
@@ -684,6 +685,7 @@ class MoveLayerCollectionTesting(MoveSceneCollectionSyncTesting):
"""
To be used by tests of view_layer_move_into_layer_collection
"""
+
def parse_move(self, path, sep='.'):
"""
convert 'Layer 1.C.2' into:
@@ -739,15 +741,15 @@ class Clay:
# store the variables
self._scene_collections = {
- 'grandma': scene_collection_grandma,
- 'mom': scene_collection_mom,
- 'kid': scene_collection_kid,
- }
+ 'grandma': scene_collection_grandma,
+ 'mom': scene_collection_mom,
+ 'kid': scene_collection_kid,
+ }
self._layer_collections = {
- 'grandma': layer_collection_grandma,
- 'mom': layer_collection_mom,
- 'kid': layer_collection_kid,
- }
+ 'grandma': layer_collection_grandma,
+ 'mom': layer_collection_mom,
+ 'kid': layer_collection_kid,
+ }
if extra_kid_layer:
layer_collection_extra = self._layer.collections.link(scene_collection_kid)
@@ -765,7 +767,7 @@ class Clay:
# remove all the other collections
while self._scene.master_collection.collections:
self._scene.master_collection.collections.remove(
- self._scene.master_collection.collections[0])
+ self._scene.master_collection.collections[0])
layer = self._scene.view_layers.new('Evaluation Test')
layer.collections.unlink(layer.collections[0])
@@ -790,9 +792,9 @@ class Clay:
# change scene settings
self._properties = {
- 'scene': self._scene.collection_properties[ENGINE],
- 'object': self._object.collection_properties[ENGINE],
- }
+ 'scene': self._scene.collection_properties[ENGINE],
+ 'object': self._object.collection_properties[ENGINE],
+ }
for key, value in self._layer_collections.items():
self._properties[key] = self._layer_collections[key].engine_overrides[ENGINE]