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 /source/blender
parentb6b185691f018f6b175ffb58c65418991cda75f2 (diff)
parente361e9e99c5b6140b6284e81fa315bdcc48cee58 (diff)
Merge branch 'blender2.8' into soc-2018-bevel
Diffstat (limited to 'source/blender')
-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.h61
-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.h50
-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
828 files changed, 37416 insertions, 23290 deletions
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/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h
new file mode 100644
index 00000000000..3acc7fad5c2
--- /dev/null
+++ b/source/blender/gpu/GPU_common.h
@@ -0,0 +1,61 @@
+/*
+ * ***** 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_common.h
+ * \ingroup gpu
+ */
+
+#ifndef __GPU_COMMON_H__
+#define __GPU_COMMON_H__
+
+#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>
+#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 /* __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/source/blender/gpu/intern/gpu_batch_private.h b/source/blender/gpu/intern/gpu_batch_private.h
new file mode 100644
index 00000000000..3a05e243065
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_batch_private.h
@@ -0,0 +1,50 @@
+/*
+ * ***** 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_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 "GPU_batch.h"
+#include "GPU_context.h"
+#include "GPU_shader_interface.h"
+
+void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface);
+
+#ifdef __cplusplus
+}
+#endif
+
+#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).