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:
authorYimingWu <xp8110@outlook.com>2019-09-12 07:48:08 +0300
committerYimingWu <xp8110@outlook.com>2019-09-12 07:48:08 +0300
commit8757454fbc6e70dea017e92812392a70d7bc93d8 (patch)
tree256b4b5134302bed51a44d1f5ca1396d294ea9e8
parentea253238ac53c45b9efd7c3272539d010fe222b8 (diff)
parent70a934770521b538b98b8a3e27739ae6a643ebfa (diff)
Merge remote-tracking branch 'origin/master' into temp-lanpr-staging
-rwxr-xr-xbuild_files/utils/make_update.py20
-rw-r--r--intern/cycles/blender/addon/properties.py54
-rw-r--r--intern/cycles/blender/addon/ui.py20
-rw-r--r--intern/cycles/blender/blender_camera.cpp2
-rw-r--r--intern/cycles/blender/blender_shader.cpp6
-rw-r--r--intern/cycles/blender/blender_sync.cpp12
-rw-r--r--intern/cycles/blender/blender_sync.h2
-rw-r--r--intern/cycles/blender/blender_viewport.cpp36
-rw-r--r--intern/cycles/blender/blender_viewport.h10
-rw-r--r--intern/cycles/kernel/kernel_film.h100
-rw-r--r--intern/cycles/kernel/kernel_types.h8
-rw-r--r--intern/cycles/render/buffers.h1
-rw-r--r--intern/cycles/render/film.cpp44
-rw-r--r--intern/cycles/render/film.h3
-rw-r--r--intern/cycles/render/session.cpp44
-rw-r--r--intern/cycles/render/session.h6
-rw-r--r--release/datafiles/userdef/userdef_default_theme.c1
-rw-r--r--release/scripts/modules/bpy_types.py12
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/blender_default.py6
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py1
-rw-r--r--release/scripts/startup/bl_ui/space_filebrowser.py4
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py5
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py1
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py26
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py66
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc2
-rw-r--r--source/blender/blenkernel/BKE_curve.h2
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h3
-rw-r--r--source/blender/blenkernel/BKE_paint.h13
-rw-r--r--source/blender/blenkernel/BKE_scene.h3
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h5
-rw-r--r--source/blender/blenkernel/CMakeLists.txt1
-rw-r--r--source/blender/blenkernel/intern/brush.c120
-rw-r--r--source/blender/blenkernel/intern/callbacks.c41
-rw-r--r--source/blender/blenkernel/intern/camera.c21
-rw-r--r--source/blender/blenkernel/intern/context.c6
-rw-r--r--source/blender/blenkernel/intern/curve.c36
-rw-r--r--source/blender/blenkernel/intern/image.c8
-rw-r--r--source/blender/blenkernel/intern/lattice.c6
-rw-r--r--source/blender/blenkernel/intern/library.c2
-rw-r--r--source/blender/blenkernel/intern/library_override.c2
-rw-r--r--source/blender/blenkernel/intern/light.c36
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c15
-rw-r--r--source/blender/blenkernel/intern/linestyle.c28
-rw-r--r--source/blender/blenkernel/intern/mball.c8
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c8
-rw-r--r--source/blender/blenkernel/intern/paint.c4
-rw-r--r--source/blender/blenkernel/intern/scene.c126
-rw-r--r--source/blender/blenkernel/intern/sequencer.c4
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c26
-rw-r--r--source/blender/blenkernel/intern/speaker.c14
-rw-r--r--source/blender/blenkernel/intern/texture.c116
-rw-r--r--source/blender/blenkernel/intern/undo_system.c2
-rw-r--r--source/blender/blenkernel/intern/world.c12
-rw-r--r--source/blender/blenlib/intern/math_geom.c23
-rw-r--r--source/blender/blenloader/intern/readfile.c12
-rw-r--r--source/blender/blenloader/intern/versioning_270.c2
-rw-r--r--source/blender/blenloader/intern/versioning_280.c4
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c19
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c1
-rw-r--r--source/blender/blenloader/intern/writefile.c10
-rw-r--r--source/blender/collada/BlenderContext.cpp2
-rw-r--r--source/blender/depsgraph/CMakeLists.txt2
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h5
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc17
-rw-r--r--source/blender/depsgraph/intern/depsgraph.h5
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_debug.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_registry.cc74
-rw-r--r--source/blender/depsgraph/intern/depsgraph_registry.h38
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc29
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c34
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl22
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c33
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c24
-rw-r--r--source/blender/draw/intern/draw_manager.c2
-rw-r--r--source/blender/draw/modes/object_mode.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c7
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c23
-rw-r--r--source/blender/editors/include/ED_gpencil.h3
-rw-r--r--source/blender/editors/include/ED_sculpt.h5
-rw-r--r--source/blender/editors/include/ED_transform.h1
-rw-r--r--source/blender/editors/include/UI_icons.h6
-rw-r--r--source/blender/editors/include/UI_resources.h1
-rw-r--r--source/blender/editors/interface/interface_icons.c1
-rw-r--r--source/blender/editors/interface/resources.c8
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt1
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c8
-rw-r--r--source/blender/editors/mesh/editmesh_mask_extract.c272
-rw-r--r--source/blender/editors/mesh/mesh_intern.h8
-rw-r--r--source/blender/editors/mesh/mesh_ops.c2
-rw-r--r--source/blender/editors/object/object_bake_api.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c2
-rw-r--r--source/blender/editors/render/render_update.c2
-rw-r--r--source/blender/editors/scene/scene_edit.c2
-rw-r--r--source/blender/editors/screen/screen_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c46
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c897
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c7
-rw-r--r--source/blender/editors/space_file/file_draw.c19
-rw-r--r--source/blender/editors/space_file/file_ops.c18
-rw-r--r--source/blender/editors/space_file/fsmenu.c17
-rw-r--r--source/blender/editors/space_info/info_stats.c2
-rw-r--r--source/blender/editors/space_node/node_edit.c2
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c56
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c2
-rw-r--r--source/blender/editors/transform/CMakeLists.txt1
-rw-r--r--source/blender/editors/transform/transform.c449
-rw-r--r--source/blender/editors/transform/transform.h76
-rw-r--r--source/blender/editors/transform/transform_convert.c33
-rw-r--r--source/blender/editors/transform/transform_convert.h4
-rw-r--r--source/blender/editors/transform/transform_convert_mesh.c720
-rw-r--r--source/blender/editors/transform/transform_convert_object.c13
-rw-r--r--source/blender/editors/transform/transform_convert_sculpt.c101
-rw-r--r--source/blender/editors/transform/transform_generics.c72
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c13
-rw-r--r--source/blender/editors/transform/transform_snap_object.c190
-rw-r--r--source/blender/editors/undo/ed_undo.c4
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp3
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp7
-rw-r--r--source/blender/makesdna/DNA_brush_defaults.h105
-rw-r--r--source/blender/makesdna/DNA_brush_types.h7
-rw-r--r--source/blender/makesdna/DNA_cachefile_defaults.h49
-rw-r--r--source/blender/makesdna/DNA_camera_defaults.h67
-rw-r--r--source/blender/makesdna/DNA_curve_defaults.h59
-rw-r--r--source/blender/makesdna/DNA_genfile.h2
-rw-r--r--source/blender/makesdna/DNA_image_defaults.h46
-rw-r--r--source/blender/makesdna/DNA_lattice_defaults.h44
-rw-r--r--source/blender/makesdna/DNA_light_defaults.h76
-rw-r--r--source/blender/makesdna/DNA_lightprobe_defaults.h51
-rw-r--r--source/blender/makesdna/DNA_linestyle_defaults.h61
-rw-r--r--source/blender/makesdna/DNA_meta_defaults.h44
-rw-r--r--source/blender/makesdna/DNA_scene_defaults.h7
-rw-r--r--source/blender/makesdna/DNA_scene_types.h2
-rw-r--r--source/blender/makesdna/DNA_speaker_defaults.h51
-rw-r--r--source/blender/makesdna/DNA_texture_defaults.h155
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h3
-rw-r--r--source/blender/makesdna/DNA_view3d_defaults.h54
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/makesdna/DNA_world_defaults.h49
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt11
-rw-r--r--source/blender/makesdna/intern/dna_defaults.c124
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c21
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt11
-rw-r--r--source/blender/makesrna/intern/makesrna.c29
-rw-r--r--source/blender/makesrna/intern/rna_armature.c46
-rw-r--r--source/blender/makesrna/intern/rna_brush.c38
-rw-r--r--source/blender/makesrna/intern/rna_camera.c12
-rw-r--r--source/blender/makesrna/intern/rna_define.c371
-rw-r--r--source/blender/makesrna/intern/rna_internal.h10
-rw-r--r--source/blender/makesrna/intern/rna_layer.c7
-rw-r--r--source/blender/makesrna/intern/rna_light.c19
-rw-r--r--source/blender/makesrna/intern/rna_lightprobe.c12
-rw-r--r--source/blender/makesrna/intern/rna_material.c2
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c4
-rw-r--r--source/blender/makesrna/intern/rna_meta.c2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c2
-rw-r--r--source/blender/makesrna/intern/rna_object.c4
-rw-r--r--source/blender/makesrna/intern/rna_pose.c11
-rw-r--r--source/blender/makesrna/intern/rna_scene.c110
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c16
-rw-r--r--source/blender/makesrna/intern/rna_space.c41
-rw-r--r--source/blender/makesrna/intern/rna_space_api.c3
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c12
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.c3
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c45
-rw-r--r--source/blender/render/intern/source/external_engine.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c58
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c6
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c5
-rw-r--r--source/blender/windowmanager/intern/wm_files.c20
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c8
-rw-r--r--source/creator/creator_args.c12
-rw-r--r--tests/gtests/alembic/abc_export_test.cc2
181 files changed, 4891 insertions, 1809 deletions
diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py
index 6bda813c6aa..2cbbd1ffd72 100755
--- a/build_files/utils/make_update.py
+++ b/build_files/utils/make_update.py
@@ -30,22 +30,6 @@ def parse_arguments():
parser.add_argument("--git-command", default="git")
return parser.parse_args()
-args = parse_arguments()
-no_libraries = args.no_libraries
-no_blender = args.no_blender
-no_submodules = args.no_submodules
-use_tests = args.use_tests
-git_command = args.git_command
-svn_command = args.svn_command
-svn_non_interactive = [args.svn_command, '--non-interactive']
-
-def print_stage(text):
- print("")
- print(text)
- print("")
-
-# Test if we are building a specific release version.
-release_version = make_utils.git_branch_release_version(git_command)
# Setup for precompiled libraries and tests from svn.
def svn_update(args, release_version):
@@ -79,14 +63,14 @@ def svn_update(args, release_version):
svn_url_platform = svn_url + lib_platform
call(svn_non_interactive + ["checkout", svn_url_platform, lib_platform_dirpath])
- if use_tests:
+ if args.use_tests:
lib_tests = "tests"
lib_tests_dirpath = os.path.join(lib_dirpath, lib_tests)
if not os.path.exists(lib_tests_dirpath):
print_stage("Checking out Tests")
- if shutil.which(svn_command) is None:
+ if shutil.which(args.svn_command) is None:
sys.stderr.write("svn not found, can't checkout tests\n")
sys.exit(1)
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 3acdfc391a6..93f8f76cd6a 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -151,6 +151,44 @@ enum_texture_limit = (
('8192', "8192", "Limit texture size to 8192 pixels", 7),
)
+enum_view3d_shading_render_pass= (
+ ('', "General", ""),
+
+ ('COMBINED', "Combined", "Show the Combined Render pass", 1),
+ ('EMISSION', "Emission", "Show the Emission render pass", 33),
+ ('BACKGROUND', "Background", "Show the Background render pass", 34),
+ ('AO', "Ambient Occlusion", "Show the Ambient Occlusion render pass", 35),
+
+ ('', "Light", ""),
+
+ ('DIFFUSE_DIRECT', "Diffuse Direct", "Show the Diffuse Direct render pass", 38),
+ ('DIFFUSE_INDIRECT', "Diffuse Indirect", "Show the Diffuse Indirect render pass", 39),
+ ('DIFFUSE_COLOR', "Diffuse Color", "Show the Diffuse Color render pass", 40),
+
+ ('GLOSSY_DIRECT', "Glossy Direct", "Show the Glossy Direct render pass", 41),
+ ('GLOSSY_INDIRECT', "Glossy Indirect", "Show the Glossy Indirect render pass", 42),
+ ('GLOSSY_COLOR', "Glossy Color", "Show the Glossy Color render pass", 43),
+
+ ('', "", ""),
+
+ ('TRANSMISSION_DIRECT', "Transmission Direct", "Show the Transmission Direct render pass", 44),
+ ('TRANSMISSION_INDIRECT', "Transmission Indirect", "Show the Transmission Indirect render pass", 45),
+ ('TRANSMISSION_COLOR', "Transmission Color", "Show the Transmission Color render pass", 46),
+
+ ('SUBSURFACE_DIRECT', "Subsurface Direct", "Show the Subsurface Direct render pass", 47),
+ ('SUBSURFACE_INDIRECT', "Subsurface Indirect", "Show the Subsurface Indirect render pass", 48),
+ ('SUBSURFACE_COLOR', "Subsurface Color", "Show the Subsurface Color render pass", 49),
+
+ ('VOLUME_DIRECT', "Volume Direct", "Show the Volume Direct render pass", 50),
+ ('VOLUME_INDIRECT', "Volume Indirect", "Show the Volume Indirect render pass", 51),
+
+ ('', "Data", ""),
+
+ ('NORMAL', "Normal", "Show the Normal render pass", 3),
+ ('UV', "UV", "Show the UV render pass", 4),
+ ('MIST', "Mist", "Show the Mist render pass", 32),
+)
+
class CyclesRenderSettings(bpy.types.PropertyGroup):
@@ -1475,6 +1513,15 @@ class CyclesPreferences(bpy.types.AddonPreferences):
self.draw_impl(self.layout, context)
+class CyclesView3DShadingSettings(bpy.types.PropertyGroup):
+ render_pass: EnumProperty(
+ name="Render Pass",
+ description="Render pass to show in the 3D Viewport",
+ items=enum_view3d_shading_render_pass,
+ default='COMBINED',
+ )
+
+
def register():
bpy.utils.register_class(CyclesRenderSettings)
bpy.utils.register_class(CyclesCameraSettings)
@@ -1488,6 +1535,12 @@ def register():
bpy.utils.register_class(CyclesDeviceSettings)
bpy.utils.register_class(CyclesPreferences)
bpy.utils.register_class(CyclesRenderLayerSettings)
+ bpy.utils.register_class(CyclesView3DShadingSettings)
+
+ bpy.types.View3DShading.cycles = bpy.props.PointerProperty(
+ name="Cycles Settings",
+ type=CyclesView3DShadingSettings,
+ )
def unregister():
@@ -1503,3 +1556,4 @@ def unregister():
bpy.utils.unregister_class(CyclesDeviceSettings)
bpy.utils.unregister_class(CyclesPreferences)
bpy.utils.unregister_class(CyclesRenderLayerSettings)
+ bpy.utils.unregister_class(CyclesView3DShadingSettings)
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 0af59411c5c..9028100ad7a 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -2050,6 +2050,25 @@ class CYCLES_RENDER_PT_simplify_culling(CyclesButtonsPanel, Panel):
sub.prop(cscene, "distance_cull_margin", text="Distance")
+class CYCLES_VIEW3D_PT_shading_render_pass(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Render Pass"
+ bl_parent_id = 'VIEW3D_PT_shading'
+ COMPAT_ENGINES = {'CYCLES'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.engine in cls.COMPAT_ENGINES
+ and context.space_data.shading.type == 'RENDERED')
+
+ def draw(self, context):
+ shading = context.space_data.shading
+
+ layout = self.layout
+ layout.prop(shading.cycles, "render_pass", text="")
+
+
class CYCLES_VIEW3D_PT_shading_lighting(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
@@ -2172,6 +2191,7 @@ classes = (
CYCLES_RENDER_PT_simplify_render,
CYCLES_RENDER_PT_simplify_culling,
CYCLES_VIEW3D_PT_shading_lighting,
+ CYCLES_VIEW3D_PT_shading_render_pass,
CYCLES_RENDER_PT_motion_blur,
CYCLES_RENDER_PT_motion_blur_curve,
CYCLES_RENDER_PT_film,
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index da43f94708c..3b19e78894a 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -899,6 +899,8 @@ BufferParams BlenderSync::get_buffer_params(BL::RenderSettings &b_render,
params.height = height;
}
+ update_viewport_display_passes(b_v3d, params.passes, false);
+
return params;
}
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 7e784527a21..db01167cc2a 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -1165,8 +1165,10 @@ static void add_nodes(Scene *scene,
BL::NodeTree::links_iterator b_link;
for (b_ntree.links.begin(b_link); b_link != b_ntree.links.end(); ++b_link) {
- /* Ignore invalid links to avoid unwanted cycles created in graph. */
- if (!b_link->is_valid()) {
+ /* Ignore invalid links to avoid unwanted cycles created in graph.
+ * Also ignore links with unavailable sockets. */
+ if (!(b_link->is_valid() && b_link->from_socket().enabled() &&
+ b_link->to_socket().enabled())) {
continue;
}
/* get blender link data */
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index e50d96cf345..8b7c66363d9 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -206,7 +206,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
sync_view_layer(b_v3d, b_view_layer);
sync_integrator();
- sync_film();
+ sync_film(b_v3d);
sync_shaders(b_depsgraph, b_v3d);
sync_images();
sync_curve_settings();
@@ -336,13 +336,17 @@ void BlenderSync::sync_integrator()
/* Film */
-void BlenderSync::sync_film()
+void BlenderSync::sync_film(BL::SpaceView3D &b_v3d)
{
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
Film *film = scene->film;
Film prevfilm = *film;
+ if (b_v3d) {
+ film->display_pass = update_viewport_display_passes(b_v3d, film->passes, true);
+ }
+
film->exposure = get_float(cscene, "film_exposure");
film->filter_type = (FilterType)get_enum(
cscene, "pixel_filter_type", FILTER_NUM_TYPES, FILTER_BLACKMAN_HARRIS);
@@ -368,8 +372,10 @@ void BlenderSync::sync_film()
}
}
- if (film->modified(prevfilm))
+ if (film->modified(prevfilm)) {
film->tag_update(scene);
+ film->tag_passes_update(scene, prevfilm.passes, false);
+ }
}
/* Render Layer */
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index c6c7b7549cf..a80f484fb92 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -116,7 +116,7 @@ class BlenderSync {
int width,
int height,
void **python_thread_state);
- void sync_film();
+ void sync_film(BL::SpaceView3D &b_v3d);
void sync_view();
void sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all);
void sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d);
diff --git a/intern/cycles/blender/blender_viewport.cpp b/intern/cycles/blender/blender_viewport.cpp
index 93dd8faa450..a74b20f150b 100644
--- a/intern/cycles/blender/blender_viewport.cpp
+++ b/intern/cycles/blender/blender_viewport.cpp
@@ -15,6 +15,8 @@
*/
#include "blender_viewport.h"
+#include "blender_util.h"
+
CCL_NAMESPACE_BEGIN
BlenderViewportParameters::BlenderViewportParameters()
@@ -59,4 +61,38 @@ const bool BlenderViewportParameters::custom_viewport_parameters() const
return !(use_scene_world && use_scene_lights);
}
+PassType BlenderViewportParameters::get_viewport_display_render_pass(BL::SpaceView3D &b_v3d)
+{
+ PassType display_pass = PASS_NONE;
+ if (b_v3d) {
+ BL::View3DShading b_view3dshading = b_v3d.shading();
+ PointerRNA cshading = RNA_pointer_get(&b_view3dshading.ptr, "cycles");
+ display_pass = (PassType)get_enum(cshading, "render_pass", -1, -1);
+ }
+ return display_pass;
+}
+
+PassType update_viewport_display_passes(BL::SpaceView3D &b_v3d,
+ vector<Pass> &passes,
+ bool reset_passes)
+{
+ if (b_v3d) {
+ PassType display_pass = BlenderViewportParameters::get_viewport_display_render_pass(b_v3d);
+
+ if (reset_passes) {
+ passes.clear();
+ /* We always need a combined pass for now. It would be a good optimization
+ * to support rendering without combined pass. */
+ Pass::add(PASS_COMBINED, passes);
+ }
+
+ if (display_pass != PASS_COMBINED) {
+ Pass::add(display_pass, passes);
+ }
+
+ return display_pass;
+ }
+ return PASS_NONE;
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/blender/blender_viewport.h b/intern/cycles/blender/blender_viewport.h
index 6b2f8ea4215..564c4f2b210 100644
--- a/intern/cycles/blender/blender_viewport.h
+++ b/intern/cycles/blender/blender_viewport.h
@@ -22,6 +22,7 @@
#include "RNA_access.h"
#include "RNA_blender_cpp.h"
+#include "render/film.h"
#include "util/util_param.h"
CCL_NAMESPACE_BEGIN
@@ -41,8 +42,17 @@ class BlenderViewportParameters {
const bool modified(const BlenderViewportParameters &other) const;
const bool custom_viewport_parameters() const;
friend class BlenderSync;
+
+ public:
+ /* Retrieve the render pass that needs to be displayed on the given `SpaceView3D`
+ * When the `b_v3d` parameter is not given `PASS_NONE` will be returned. */
+ static PassType get_viewport_display_render_pass(BL::SpaceView3D &b_v3d);
};
+PassType update_viewport_display_passes(BL::SpaceView3D &b_v3d,
+ vector<Pass> &passes,
+ bool reset_passes);
+
CCL_NAMESPACE_END
#endif
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h
index d20f1adf663..7a974e9d852 100644
--- a/intern/cycles/kernel/kernel_film.h
+++ b/intern/cycles/kernel/kernel_film.h
@@ -16,18 +16,66 @@
CCL_NAMESPACE_BEGIN
-ccl_device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale)
+ccl_device float4 film_get_pass_result(KernelGlobals *kg,
+ ccl_global float *buffer,
+ float sample_scale,
+ int index,
+ bool use_display_sample_scale)
{
- float exposure = kernel_data.film.exposure;
- float4 result = irradiance * scale;
+ float4 pass_result;
+
+ int display_pass_stride = kernel_data.film.display_pass_stride;
+ int display_pass_components = kernel_data.film.display_pass_components;
+
+ if (display_pass_components == 4) {
+ ccl_global float4 *in = (ccl_global float4 *)(buffer + display_pass_stride +
+ index * kernel_data.film.pass_stride);
+ float alpha = use_display_sample_scale ?
+ (kernel_data.film.use_display_pass_alpha ? in->w : 1.0f / sample_scale) :
+ 1.0f;
+
+ pass_result = make_float4(in->x, in->y, in->z, alpha);
+
+ int display_divide_pass_stride = kernel_data.film.display_divide_pass_stride;
+ if (display_divide_pass_stride != -1) {
+ ccl_global float4 *divide_in = (ccl_global float4 *)(buffer + display_divide_pass_stride +
+ index * kernel_data.film.pass_stride);
+ if (divide_in->x != 0.0f) {
+ pass_result.x /= divide_in->x;
+ }
+ if (divide_in->y != 0.0f) {
+ pass_result.y /= divide_in->y;
+ }
+ if (divide_in->z != 0.0f) {
+ pass_result.z /= divide_in->z;
+ }
+ }
+
+ if (kernel_data.film.use_display_exposure) {
+ float exposure = kernel_data.film.exposure;
+ pass_result *= make_float4(exposure, exposure, exposure, alpha);
+ }
+ }
+ else if (display_pass_components == 1) {
+ ccl_global float *in = (ccl_global float *)(buffer + display_pass_stride +
+ index * kernel_data.film.pass_stride);
+ pass_result = make_float4(*in, *in, *in, 1.0f / sample_scale);
+ }
+
+ return pass_result;
+}
+
+ccl_device float4 film_map(KernelGlobals *kg, float4 rgba_in, float scale)
+{
+ float4 result;
/* conversion to srgb */
- result.x = color_linear_to_srgb(result.x * exposure);
- result.y = color_linear_to_srgb(result.y * exposure);
- result.z = color_linear_to_srgb(result.z * exposure);
+ result.x = color_linear_to_srgb(rgba_in.x);
+ result.y = color_linear_to_srgb(rgba_in.y);
+ result.z = color_linear_to_srgb(rgba_in.z);
/* clamp since alpha might be > 1.0 due to russian roulette */
- result.w = saturate(result.w);
+ result.w = saturate(rgba_in.w);
return result;
}
@@ -57,15 +105,22 @@ ccl_device void kernel_film_convert_to_byte(KernelGlobals *kg,
/* buffer offset */
int index = offset + x + y * stride;
+ bool use_display_sample_scale = (kernel_data.film.display_divide_pass_stride == -1);
+ float4 rgba_in = film_get_pass_result(kg, buffer, sample_scale, index, use_display_sample_scale);
+
rgba += index;
- buffer += index * kernel_data.film.pass_stride;
/* map colors */
- float4 irradiance = *((ccl_global float4 *)buffer);
- float4 float_result = film_map(kg, irradiance, sample_scale);
- uchar4 byte_result = film_float_to_byte(float_result);
-
- *rgba = byte_result;
+ if (use_display_sample_scale) {
+ float4 float_result = film_map(kg, rgba_in, sample_scale);
+ uchar4 byte_result = film_float_to_byte(float_result);
+ *rgba = byte_result;
+ }
+ else {
+ float4 float_result = film_map(kg, rgba_in, 1.0);
+ uchar4 byte_result = film_float_to_byte(float_result);
+ *rgba = byte_result;
+ }
}
ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg,
@@ -79,21 +134,16 @@ ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg,
{
/* buffer offset */
int index = offset + x + y * stride;
+ bool use_display_sample_scale = (kernel_data.film.display_divide_pass_stride == -1);
+ float4 rgba_in = film_get_pass_result(kg, buffer, sample_scale, index, use_display_sample_scale);
- ccl_global float4 *in = (ccl_global float4 *)(buffer + index * kernel_data.film.pass_stride);
ccl_global half *out = (ccl_global half *)rgba + index * 4;
-
- float exposure = kernel_data.film.exposure;
-
- float4 rgba_in = *in;
-
- if (exposure != 1.0f) {
- rgba_in.x *= exposure;
- rgba_in.y *= exposure;
- rgba_in.z *= exposure;
+ if (use_display_sample_scale) {
+ float4_store_half(out, rgba_in, sample_scale);
+ }
+ else {
+ float4_store_half(out, rgba_in, 1.0f);
}
-
- float4_store_half(out, rgba_in, sample_scale);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index b3cb6ca7c19..f0054691b54 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1168,6 +1168,7 @@ static_assert_align(KernelCamera, 16);
typedef struct KernelFilm {
float exposure;
int pass_flag;
+
int light_pass_flag;
int pass_stride;
int use_light_pass;
@@ -1233,6 +1234,13 @@ typedef struct KernelFilm {
int pass_bvh_intersections;
int pass_ray_bounces;
#endif
+
+ /* viewport rendering options */
+ int display_pass_stride;
+ int display_pass_components;
+ int display_divide_pass_stride;
+ int use_display_exposure;
+ int use_display_pass_alpha;
} KernelFilm;
static_assert_align(KernelFilm, 16);
diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h
index 1c49038cd4b..74bb656c5a4 100644
--- a/intern/cycles/render/buffers.h
+++ b/intern/cycles/render/buffers.h
@@ -64,7 +64,6 @@ class BufferParams {
void get_offset_stride(int &offset, int &stride);
bool modified(const BufferParams &params);
- void add_pass(PassType type);
int get_passes_size();
int get_denoising_offset();
int get_denoising_prefiltered_offset();
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index d6c44b66117..5bf7ba97515 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -267,7 +267,7 @@ NODE_DEFINE(Film)
NodeType *type = NodeType::add("film", create);
SOCKET_FLOAT(exposure, "Exposure", 0.8f);
- SOCKET_FLOAT(pass_alpha_threshold, "Pass Alpha Threshold", 0.5f);
+ SOCKET_FLOAT(pass_alpha_threshold, "Pass Alpha Threshold", 0.0f);
static NodeEnum filter_enum;
filter_enum.insert("box", FILTER_BOX);
@@ -318,6 +318,13 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
/* update __data */
kfilm->exposure = exposure;
kfilm->pass_flag = 0;
+
+ kfilm->display_pass_stride = -1;
+ kfilm->display_pass_components = 0;
+ kfilm->display_divide_pass_stride = -1;
+ kfilm->use_display_exposure = false;
+ kfilm->use_display_pass_alpha = (display_pass == PASS_COMBINED);
+
kfilm->light_pass_flag = 0;
kfilm->pass_stride = 0;
kfilm->use_light_pass = use_light_visibility || use_sample_clamp;
@@ -464,6 +471,16 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
break;
}
+ if (pass.type == display_pass) {
+ kfilm->display_pass_stride = kfilm->pass_stride;
+ kfilm->display_pass_components = pass.components;
+ kfilm->use_display_exposure = pass.exposure && (kfilm->exposure != 1.0f);
+ }
+ else if (pass.type == PASS_DIFFUSE_COLOR || pass.type == PASS_TRANSMISSION_COLOR ||
+ pass.type == PASS_GLOSSY_COLOR || pass.type == PASS_SUBSURFACE_COLOR) {
+ kfilm->display_divide_pass_stride = kfilm->pass_stride;
+ }
+
kfilm->pass_stride += pass.components;
}
@@ -485,7 +502,18 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
}
kfilm->pass_stride = align_up(kfilm->pass_stride, 4);
- kfilm->pass_alpha_threshold = pass_alpha_threshold;
+
+ /* When displaying the normal/uv pass in the viewport we need to disable
+ * transparency.
+ *
+ * We also don't need to perform light accumulations. Later we want to optimize this to suppress
+ * light calculations. */
+ if (display_pass == PASS_NORMAL || display_pass == PASS_UV) {
+ kfilm->use_light_pass = 0;
+ }
+ else {
+ kfilm->pass_alpha_threshold = pass_alpha_threshold;
+ }
/* update filter table */
vector<float> table = filter_table(filter_type, filter_width);
@@ -518,7 +546,7 @@ bool Film::modified(const Film &film)
return !Node::equals(film) || !Pass::equals(passes, film.passes);
}
-void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_)
+void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_, bool update_passes)
{
if (Pass::contains(passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) {
scene->mesh_manager->tag_update(scene);
@@ -526,10 +554,16 @@ void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_)
foreach (Shader *shader, scene->shaders)
shader->need_update_mesh = true;
}
- else if (Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION))
+ else if (Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) {
scene->mesh_manager->tag_update(scene);
+ }
+ else if (Pass::contains(passes, PASS_AO) != Pass::contains(passes_, PASS_AO)) {
+ scene->integrator->tag_update(scene);
+ }
- passes = passes_;
+ if (update_passes) {
+ passes = passes_;
+ }
}
void Film::tag_update(Scene * /*scene*/)
diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h
index 1cfa7c3b77d..20f6261a871 100644
--- a/intern/cycles/render/film.h
+++ b/intern/cycles/render/film.h
@@ -64,6 +64,7 @@ class Film : public Node {
int denoising_flags;
float pass_alpha_threshold;
+ PassType display_pass;
int pass_stride;
int denoising_data_offset;
int denoising_clean_offset;
@@ -90,7 +91,7 @@ class Film : public Node {
void device_free(Device *device, DeviceScene *dscene, Scene *scene);
bool modified(const Film &film);
- void tag_passes_update(Scene *scene, const vector<Pass> &passes_);
+ void tag_passes_update(Scene *scene, const vector<Pass> &passes_, bool update_passes=true);
void tag_update(Scene *scene);
};
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index 332f1fb6167..7a894c1e98a 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -83,7 +83,7 @@ Session::Session(const SessionParams &params_)
display_outdated = false;
gpu_draw_ready = false;
- gpu_need_tonemap = false;
+ gpu_need_display_buffer_update = false;
pause = false;
kernels_loaded = false;
@@ -97,8 +97,8 @@ Session::~Session()
/* wait for session thread to end */
progress.set_cancel("Exiting");
- gpu_need_tonemap = false;
- gpu_need_tonemap_cond.notify_all();
+ gpu_need_display_buffer_update = false;
+ gpu_need_display_buffer_update_cond.notify_all();
{
thread_scoped_lock pause_lock(pause_mutex);
@@ -110,12 +110,12 @@ Session::~Session()
}
if (params.write_render_cb) {
- /* tonemap and write out image if requested */
+ /* Copy to display buffer and write out image if requested */
delete display;
display = new DisplayBuffer(device, false);
display->reset(buffers->params);
- tonemap(params.samples);
+ copy_to_display_buffer(params.samples);
int w = display->draw_width;
int h = display->draw_height;
@@ -168,8 +168,8 @@ void Session::reset_gpu(BufferParams &buffer_params, int samples)
reset_(buffer_params, samples);
- gpu_need_tonemap = false;
- gpu_need_tonemap_cond.notify_all();
+ gpu_need_display_buffer_update = false;
+ gpu_need_display_buffer_update_cond.notify_all();
pause_cond.notify_all();
}
@@ -186,11 +186,11 @@ bool Session::draw_gpu(BufferParams &buffer_params, DeviceDrawParams &draw_param
if (!buffer_params.modified(display->params)) {
/* for CUDA we need to do tone-mapping still, since we can
* only access GL buffers from the main thread. */
- if (gpu_need_tonemap) {
+ if (gpu_need_display_buffer_update) {
thread_scoped_lock buffers_lock(buffers_mutex);
- tonemap(tile_manager.state.sample);
- gpu_need_tonemap = false;
- gpu_need_tonemap_cond.notify_all();
+ copy_to_display_buffer(tile_manager.state.sample);
+ gpu_need_display_buffer_update = false;
+ gpu_need_display_buffer_update_cond.notify_all();
}
display->draw(device, draw_params);
@@ -307,17 +307,17 @@ void Session::run_gpu()
/* update status and timing */
update_status_time();
- gpu_need_tonemap = true;
+ gpu_need_display_buffer_update = true;
gpu_draw_ready = true;
progress.set_update();
- /* wait for tonemap */
+ /* wait for until display buffer is updated */
if (!params.background) {
- while (gpu_need_tonemap) {
+ while (gpu_need_display_buffer_update) {
if (progress.get_cancel())
break;
- gpu_need_tonemap_cond.wait(buffers_lock);
+ gpu_need_display_buffer_update_cond.wait(buffers_lock);
}
}
@@ -561,7 +561,7 @@ void Session::run_cpu()
while (!progress.get_cancel()) {
/* advance to next tile */
bool no_tiles = !tile_manager.next();
- bool need_tonemap = false;
+ bool need_copy_to_display_buffer = false;
DeviceKernelStatus kernel_state = DEVICE_KERNEL_UNKNOWN;
if (no_tiles) {
@@ -650,7 +650,7 @@ void Session::run_cpu()
update_status_time();
if (!params.background)
- need_tonemap = true;
+ need_copy_to_display_buffer = true;
if (!device->error_message().empty())
progress.set_error(device->error_message());
@@ -668,10 +668,10 @@ void Session::run_cpu()
delayed_reset.do_reset = false;
reset_(delayed_reset.params, delayed_reset.samples);
}
- else if (need_tonemap) {
- /* tonemap only if we do not reset, we don't we don't
+ else if (need_copy_to_display_buffer) {
+ /* Only copy to display_buffer if we do not reset, we don't
* want to show the result of an incomplete sample */
- tonemap(tile_manager.state.sample);
+ copy_to_display_buffer(tile_manager.state.sample);
}
if (!device->error_message().empty())
@@ -1044,9 +1044,9 @@ void Session::render()
device->task_add(task);
}
-void Session::tonemap(int sample)
+void Session::copy_to_display_buffer(int sample)
{
- /* add tonemap task */
+ /* add film conversion task */
DeviceTask task(DeviceTask::FILM_CONVERT);
task.x = tile_manager.state.buffer.full_x;
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index 60d8f7a8b14..9fffc13dd41 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -176,7 +176,7 @@ class Session {
void update_status_time(bool show_pause = false, bool show_done = false);
- void tonemap(int sample);
+ void copy_to_display_buffer(int sample);
void render();
void reset_(BufferParams &params, int samples);
@@ -202,8 +202,8 @@ class Session {
volatile bool display_outdated;
volatile bool gpu_draw_ready;
- volatile bool gpu_need_tonemap;
- thread_condition_variable gpu_need_tonemap_cond;
+ volatile bool gpu_need_display_buffer_update;
+ thread_condition_variable gpu_need_display_buffer_update_cond;
bool pause;
thread_condition_variable pause_cond;
diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index 23b1eb570d9..ff2a5ae2739 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -254,6 +254,7 @@ const bTheme U_theme_default = {
.icon_object_data = RGBA(0x00d4a3ff),
.icon_modifier = RGBA(0x84b8ffff),
.icon_shading = RGBA(0xea7581ff),
+ .icon_folder = RGBA(0xe3c16eff),
},
.space_properties = {
.back = RGBA(0x42424200),
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index eca79795269..a3787506da4 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -252,18 +252,6 @@ class _GenericBone:
return (self.head + self.tail) * 0.5
@property
- def length(self):
- """
- The distance from head to tail,
- when set the head is moved to fit the length.
- """
- return self.vector.length
-
- @length.setter
- def length(self, value):
- self.tail = self.head + ((self.tail - self.head).normalized() * value)
-
- @property
def vector(self):
"""
The direction this bone is pointing.
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 0bc1219fa4d..b9c8e73dab2 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -1819,7 +1819,7 @@ def km_file_browser_main(params):
{"properties": [("need_active", True)]}),
("file.refresh", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'},
- {"properties": [("open", False)]}),
+ {"properties": [("open", False), ("deselect_all", not params.legacy)]}),
("file.select", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
{"properties": [("extend", True)]}),
@@ -3848,6 +3848,10 @@ def km_sculpt(params):
("paint.mask_lasso_gesture", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None),
("wm.context_toggle", {"type": 'M', "value": 'PRESS', "ctrl": True},
{"properties": [("data_path", 'scene.tool_settings.sculpt.show_mask')]}),
+ ("sculpt.mask_expand", {"type": 'A', "value": 'PRESS', "shift": True},
+ {"properties": [("use_normals", False), ("keep_previous_mask", False), ("invert", True), ("smooth_iterations", 2)]}),
+ ("sculpt.mask_expand", {"type": 'A', "value": 'PRESS', "shift": True, 'alt': True},
+ {"properties": [("use_normals", True), ("keep_previous_mask", True), ("invert", False), ("smooth_iterations", 0)]}),
# Dynamic topology
("sculpt.dynamic_topology_toggle", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
("sculpt.set_detail_size", {"type": 'D', "value": 'PRESS', "shift": True}, None),
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index a963f461dd1..29a002b2754 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -1213,7 +1213,7 @@ def km_file_browser_main(params):
("file.refresh", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
("file.select", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'},
- {"properties": [("open", False)]}),
+ {"properties": [("open", False), ("deselect_all", True)]}),
("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
{"properties": [("extend", True)]}),
("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True,},
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index f348db5158f..74632d0ab44 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -680,6 +680,7 @@ class RENDER_PT_simplify_greasepencil(RenderButtonsPanel, Panel):
col.prop(rd, "simplify_gpencil_view_modifier", text="Modifiers")
col.prop(rd, "simplify_gpencil_shader_fx", text="ShaderFX")
col.prop(rd, "simplify_gpencil_blend", text="Layers Blending")
+ col.prop(rd, "simplify_gpencil_tint", text="Layers Tinting")
col.prop(rd, "simplify_gpencil_view_fill")
sub = col.column()
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 2be5c908269..948a797e7fe 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -158,8 +158,8 @@ class FILEBROWSER_PT_filter(Panel):
def panel_poll_is_upper_region(region):
- # The upper region is left-aligned, the lower is split into it then.
- return region.alignment == 'LEFT'
+ # The upper region is left-aligned, the lower is split into it then. Note that after "Flip Regions" it's right-aligned.
+ return region.alignment in {'LEFT', 'RIGHT'}
class FILEBROWSER_UL_dir(UIList):
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 8ec2733ff34..de05a357211 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1986,6 +1986,11 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
None,
_defs_sculpt.mesh_filter,
None,
+ _defs_transform.translate,
+ _defs_transform.rotate,
+ _defs_transform.scale,
+ _defs_transform.transform,
+ None,
*_tools_annotate,
],
'PAINT_TEXTURE': [
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 8ed8eb04898..14a15ace67e 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -937,6 +937,7 @@ class USERPREF_PT_theme_interface_icons(PreferencePanel, Panel):
flow.prop(ui, "icon_object_data")
flow.prop(ui, "icon_modifier")
flow.prop(ui, "icon_shading")
+ flow.prop(ui, "icon_folder")
flow.prop(ui, "icon_border_intensity")
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index c869a41ebab..2c34c8cbafe 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2872,6 +2872,24 @@ class VIEW3D_MT_sculpt(Menu):
layout.separator()
+ props = layout.operator("sculpt.mask_expand", text="Expand Mask By Topology")
+ props.use_normals = False
+ props.keep_previous_mask = False
+ props.invert = True
+ props.smooth_iterations = 2
+
+ props = layout.operator("sculpt.mask_expand", text="Expand Mask By Curvature")
+ props.use_normals = True
+ props.keep_previous_mask = True
+ props.invert = False
+ props.smooth_iterations = 0
+
+ layout.separator()
+
+ props = layout.operator("mesh.paint_mask_extract", text="Mask Extract")
+
+ layout.separator()
+
props = layout.operator("sculpt.dirty_mask", text='Dirty Mask')
@@ -5982,14 +6000,6 @@ class VIEW3D_PT_pivot_point(Panel):
col.label(text="Pivot Point")
col.prop(tool_settings, "transform_pivot_point", expand=True)
- if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
- col.separator()
-
- col.label(text="Affect Only")
- col.prop(tool_settings, "use_transform_data_origin", text="Origins")
- col.prop(tool_settings, "use_transform_pivot_point_align", text="Locations")
- col.prop(tool_settings, "use_transform_skip_children", text="Parents (Skip Children)")
-
class VIEW3D_PT_snapping(Panel):
bl_space_type = 'VIEW_3D'
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index c39f2ea051d..ccd777f799c 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -122,6 +122,39 @@ def is_not_gpencil_edit_mode(context):
return not is_gpmode
+# ********** default tools for object mode ****************
+
+
+class VIEW3D_PT_tools_object_options(View3DPanel, Panel):
+ bl_category = "Tool"
+ bl_context = ".objectmode" # dot on purpose (access from topbar)
+ bl_label = "Options"
+
+ def draw(self, context):
+ # layout = self.layout
+ pass
+
+
+class VIEW3D_PT_tools_object_options_transform(View3DPanel, Panel):
+ bl_category = "Tool"
+ bl_context = ".objectmode" # dot on purpose (access from topbar)
+ bl_label = "Transform"
+ bl_parent_id = "VIEW3D_PT_tools_object_options"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.use_property_split = True
+ layout.use_property_decorate = False
+
+ tool_settings = context.tool_settings
+
+ layout.label(text="Affect Only")
+ layout.prop(tool_settings, "use_transform_data_origin", text="Origins")
+ layout.prop(tool_settings, "use_transform_pivot_point_align", text="Locations")
+ layout.prop(tool_settings, "use_transform_skip_children", text="Parents (Skip Children)")
+
+
# ********** default tools for editmode_mesh ****************
@@ -144,11 +177,21 @@ class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel):
ob = context.active_object
mesh = ob.data
- col = layout.column(align=True)
- col.prop(mesh, "use_mirror_x")
+ split = layout.split()
+
+ col = split.column()
+ col.alignment = 'RIGHT'
+ col.label(text="Mirror")
+
+ col = split.column()
row = col.row(align=True)
- row.active = ob.data.use_mirror_x
+ row.prop(mesh, "use_mirror_x", text="X", toggle=True)
+ row.prop(mesh, "use_mirror_y", text="Y", toggle=True)
+ row.prop(mesh, "use_mirror_z", text="Z", toggle=True)
+
+ row = layout.row(align=True)
+ row.active = ob.data.use_mirror_x or ob.data.use_mirror_y or ob.data.use_mirror_z
row.prop(mesh, "use_mirror_topology")
@@ -262,12 +305,17 @@ class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
pose = context.active_object.pose
layout = self.layout
+ tool_settings = context.tool_settings
+
layout.prop(pose, "use_auto_ik")
layout.prop(pose, "use_mirror_x")
col = layout.column()
col.active = pose.use_mirror_x
col.prop(pose, "use_mirror_relative")
+ layout.label(text="Affect Only")
+ layout.prop(tool_settings, "use_transform_pivot_point_align", text="Locations")
+
# ********** default tools for paint modes ****************
@@ -374,12 +422,17 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
row = col.row()
row.prop(brush, "elastic_deform_type")
row = col.row()
- row.prop(brush, "elastic_deform_compressibility", slider=True)
+ row.prop(brush, "elastic_deform_volume_preservation", slider=True)
col.separator()
row = col.row()
row.prop(brush, "use_automasking_topology")
+ if brush.sculpt_tool == 'GRAB':
+ col.separator()
+ row = col.row()
+ row.prop(brush, "use_grab_active_vertex")
+
# topology_rake_factor
if (
capabilities.has_topology_rake and
@@ -1943,6 +1996,9 @@ class VIEW3D_PT_tools_grease_pencil_brush_settings(View3DPanel, Panel):
col.prop(gp_settings, "random_subdiv", text="Randomness", slider=True)
col = layout.column(align=True)
+ col.prop(gp_settings, "simplify_factor")
+
+ col = layout.column(align=True)
col.prop(gp_settings, "trim")
@@ -2172,6 +2228,8 @@ class VIEW3D_PT_gpencil_brush_presets(PresetPanel, Panel):
classes = (
VIEW3D_MT_brush_context_menu,
VIEW3D_MT_brush_context_menu_paint_modes,
+ VIEW3D_PT_tools_object_options,
+ VIEW3D_PT_tools_object_options_transform,
VIEW3D_PT_tools_meshedit_options,
VIEW3D_PT_tools_meshedit_options_automerge,
VIEW3D_PT_tools_curveedit_options_stroke,
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 13533ef9972..9ace0a8faa9 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -330,7 +330,7 @@ bool ABC_export(Scene *scene,
* hardcore refactoring. */
new (&job->settings) ExportSettings();
job->settings.scene = scene;
- job->settings.depsgraph = DEG_graph_new(scene, job->view_layer, DAG_EVAL_RENDER);
+ job->settings.depsgraph = DEG_graph_new(job->bmain, scene, job->view_layer, DAG_EVAL_RENDER);
/* TODO(Sybren): for now we only export the active scene layer.
* Later in the 2.8 development process this may be replaced by using
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index be49ca150b2..aeff6007292 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -72,7 +72,7 @@ typedef struct CVKeyIndex {
/* ** Curve ** */
void BKE_curve_free(struct Curve *cu);
void BKE_curve_editfont_free(struct Curve *cu);
-void BKE_curve_init(struct Curve *cu);
+void BKE_curve_init(struct Curve *cu, const short curve_type);
struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type);
void BKE_curve_copy_data(struct Main *bmain,
struct Curve *cu_dst,
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 5bc6691df6a..18194345b83 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -58,6 +58,9 @@ struct MDeformVert;
#define GPENCIL_SIMPLIFY_BLEND(scene, playing) \
((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
(scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_BLEND)))
+#define GPENCIL_SIMPLIFY_TINT(scene, playing) \
+ ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
+ (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_TINT)))
/* ------------ Grease-Pencil API ------------------ */
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index ef798479b23..5ce16e8b906 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -267,6 +267,19 @@ typedef struct SculptSession {
float cursor_view_normal[3];
struct RegionView3D *rv3d;
+ /* Dynamic mesh preview */
+ int *preview_vert_index_list;
+ int preview_vert_index_count;
+
+ /* Transform operator */
+ float pivot_pos[3];
+ float pivot_rot[4];
+ float pivot_scale[3];
+
+ float init_pivot_pos[3];
+ float init_pivot_rot[4];
+ float init_pivot_scale[3];
+
union {
struct {
struct SculptVertexPaintGeomMap gmap;
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 7d564a232a7..2986d19edfb 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -220,7 +220,8 @@ void BKE_scene_allocate_depsgraph_hash(struct Scene *scene);
void BKE_scene_ensure_depsgraph_hash(struct Scene *scene);
void BKE_scene_free_depsgraph_hash(struct Scene *scene);
-struct Depsgraph *BKE_scene_get_depsgraph(struct Scene *scene,
+struct Depsgraph *BKE_scene_get_depsgraph(struct Main *bmain,
+ struct Scene *scene,
struct ViewLayer *view_layer,
bool allocate);
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index 9ec75c39fcf..e3d19a3d807 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -110,6 +110,11 @@ void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd,
float (*vertexCos)[3],
int numVerts);
+/* Used in editmesh_mask_extract.c to shrinkwrap the extracted mesh to the sculpt */
+void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C,
+ struct Object *ob_source,
+ struct Object *ob_target);
+
/*
* This function casts a ray in the given BVHTree.
* but it takes into consideration the space_transform, that is:
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 0e2f6e2184e..4bf2f53f8f7 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -51,6 +51,7 @@ set(INC
../../../extern/curve_fit_nd
../../../intern/smoke/extern
+ # dna_type_offsets.h
${CMAKE_CURRENT_BINARY_DIR}/../makesdna/intern
)
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index bdc836225c9..29c4ae624e9 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -24,6 +24,7 @@
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_gpencil_types.h"
+#include "DNA_defaults.h"
#include "BLI_math.h"
#include "BLI_rand.h"
@@ -60,74 +61,48 @@ void BKE_brush_system_exit(void)
static void brush_defaults(Brush *brush)
{
- brush->blend = 0;
- brush->flag = 0;
-
- brush->ob_mode = OB_MODE_ALL_PAINT;
-
- /* BRUSH SCULPT TOOL SETTINGS */
- brush->weight = 1.0f; /* weight of brush 0 - 1.0 */
- brush->size = 35; /* radius of the brush in pixels */
- brush->alpha = 0.5f; /* brush strength/intensity probably variable should be renamed? */
- brush->autosmooth_factor = 0.0f;
- brush->topology_rake_factor = 0.0f;
- brush->crease_pinch_factor = 0.5f;
- brush->normal_radius_factor = 0.5f;
- brush->sculpt_plane = SCULPT_DISP_DIR_AREA;
- /* How far above or below the plane that is found by averaging the faces. */
- brush->plane_offset = 0.0f;
- brush->plane_trim = 0.5f;
- brush->clone.alpha = 0.5f;
- brush->normal_weight = 0.0f;
- brush->fill_threshold = 0.2f;
- brush->flag |= BRUSH_ALPHA_PRESSURE;
-
- /* BRUSH PAINT TOOL SETTINGS */
- /* Default rgb color of the brush when painting - white. */
- brush->rgb[0] = 1.0f;
- brush->rgb[1] = 1.0f;
- brush->rgb[2] = 1.0f;
-
- zero_v3(brush->secondary_rgb);
-
- /* BRUSH STROKE SETTINGS */
- brush->flag |= (BRUSH_SPACE | BRUSH_SPACE_ATTEN);
- /* How far each brush dot should be spaced as a percentage of brush diameter. */
- brush->spacing = 10;
-
- brush->smooth_stroke_radius = 75;
- brush->smooth_stroke_factor = 0.9f;
-
- /* Time delay between dots of paint or sculpting when doing airbrush mode. */
- brush->rate = 0.1f;
-
- brush->jitter = 0.0f;
-
- /* BRUSH TEXTURE SETTINGS */
- BKE_texture_mtex_default(&brush->mtex);
- BKE_texture_mtex_default(&brush->mask_mtex);
-
- brush->texture_sample_bias = 0; /* value to added to texture samples */
- brush->texture_overlay_alpha = 33;
- brush->mask_overlay_alpha = 33;
- brush->cursor_overlay_alpha = 33;
- brush->overlay_flags = 0;
-
- /* brush appearance */
-
- brush->add_col[0] = 1.00; /* add mode color is light red */
- brush->add_col[1] = 0.39;
- brush->add_col[2] = 0.39;
-
- brush->sub_col[0] = 0.39; /* subtract mode color is light blue */
- brush->sub_col[1] = 0.39;
- brush->sub_col[2] = 1.00;
-
- brush->stencil_pos[0] = 256;
- brush->stencil_pos[1] = 256;
-
- brush->stencil_dimension[0] = 256;
- brush->stencil_dimension[1] = 256;
+
+ const Brush *brush_def = DNA_struct_default_get(Brush);
+
+#define FROM_DEFAULT(member) memcpy(&brush->member, &brush_def->member, sizeof(brush->member))
+#define FROM_DEFAULT_PTR(member) memcpy(brush->member, brush_def->member, sizeof(brush->member))
+
+ FROM_DEFAULT(blend);
+ FROM_DEFAULT(flag);
+ FROM_DEFAULT(weight);
+ FROM_DEFAULT(size);
+ FROM_DEFAULT(alpha);
+ FROM_DEFAULT(autosmooth_factor);
+ FROM_DEFAULT(topology_rake_factor);
+ FROM_DEFAULT(crease_pinch_factor);
+ FROM_DEFAULT(normal_radius_factor);
+ FROM_DEFAULT(sculpt_plane);
+ FROM_DEFAULT(plane_offset);
+ FROM_DEFAULT(clone.alpha);
+ FROM_DEFAULT(normal_weight);
+ FROM_DEFAULT(fill_threshold);
+ FROM_DEFAULT(flag);
+ FROM_DEFAULT_PTR(rgb);
+ FROM_DEFAULT_PTR(secondary_rgb);
+ FROM_DEFAULT(spacing);
+ FROM_DEFAULT(smooth_stroke_radius);
+ FROM_DEFAULT(smooth_stroke_factor);
+ FROM_DEFAULT(rate);
+ FROM_DEFAULT(jitter);
+ FROM_DEFAULT(texture_sample_bias);
+ FROM_DEFAULT(texture_overlay_alpha);
+ FROM_DEFAULT(mask_overlay_alpha);
+ FROM_DEFAULT(cursor_overlay_alpha);
+ FROM_DEFAULT(overlay_flags);
+ FROM_DEFAULT_PTR(add_col);
+ FROM_DEFAULT_PTR(sub_col);
+ FROM_DEFAULT(stencil_pos);
+ FROM_DEFAULT(stencil_dimension);
+ FROM_DEFAULT(mtex);
+ FROM_DEFAULT(mask_mtex);
+
+#undef FROM_DEFAULT
+#undef FROM_DEFAULT_PTR
}
/* Datablock add/copy/free/make_local */
@@ -136,16 +111,11 @@ void BKE_brush_init(Brush *brush)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(brush, id));
+ MEMCPY_STRUCT_AFTER(brush, DNA_struct_default_get(Brush), id);
+
/* enable fake user by default */
id_fake_user_set(&brush->id);
- brush_defaults(brush);
-
- brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */
-
- /* A kernel radius of 1 has almost no effect (T63233). */
- brush->blur_kernel_radius = 2;
-
/* the default alpha falloff curve */
BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
}
diff --git a/source/blender/blenkernel/intern/callbacks.c b/source/blender/blenkernel/intern/callbacks.c
index cbecba2efe1..367fed818af 100644
--- a/source/blender/blenkernel/intern/callbacks.c
+++ b/source/blender/blenkernel/intern/callbacks.c
@@ -25,18 +25,55 @@
#include "MEM_guardedalloc.h"
+#include "RNA_types.h"
+#include "RNA_access.h"
+
static ListBase callback_slots[BKE_CB_EVT_TOT] = {{NULL}};
-void BKE_callback_exec(struct Main *bmain, struct ID *self, eCbEvent evt)
+void BKE_callback_exec(struct Main *bmain,
+ struct PointerRNA **pointers,
+ const int num_pointers,
+ eCbEvent evt)
{
ListBase *lb = &callback_slots[evt];
bCallbackFuncStore *funcstore;
for (funcstore = lb->first; funcstore; funcstore = funcstore->next) {
- funcstore->func(bmain, self, funcstore->arg);
+ funcstore->func(bmain, pointers, num_pointers, funcstore->arg);
}
}
+void BKE_callback_exec_null(struct Main *bmain, eCbEvent evt)
+{
+ BKE_callback_exec(bmain, NULL, 0, evt);
+}
+
+void BKE_callback_exec_id(struct Main *bmain, struct ID *id, eCbEvent evt)
+{
+ PointerRNA id_ptr;
+ RNA_id_pointer_create(id, &id_ptr);
+
+ PointerRNA *pointers[1] = {&id_ptr};
+
+ BKE_callback_exec(bmain, pointers, 1, evt);
+}
+
+void BKE_callback_exec_id_depsgraph(struct Main *bmain,
+ struct ID *id,
+ struct Depsgraph *depsgraph,
+ eCbEvent evt)
+{
+ PointerRNA id_ptr;
+ RNA_id_pointer_create(id, &id_ptr);
+
+ PointerRNA depsgraph_ptr;
+ RNA_pointer_create(NULL, &RNA_Depsgraph, depsgraph, &depsgraph_ptr);
+
+ PointerRNA *pointers[2] = {&id_ptr, &depsgraph_ptr};
+
+ BKE_callback_exec(bmain, pointers, 2, evt);
+}
+
void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
{
ListBase *lb = &callback_slots[evt];
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index a563a8d581c..f70c5bb99d6 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -30,6 +30,7 @@
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
#include "DNA_ID.h"
+#include "DNA_defaults.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
@@ -56,25 +57,7 @@ void BKE_camera_init(Camera *cam)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cam, id));
- cam->lens = 50.0f;
- cam->sensor_x = DEFAULT_SENSOR_WIDTH;
- cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
- cam->clip_start = 0.1f;
- cam->clip_end = 1000.0f;
- cam->drawsize = 1.0f;
- cam->ortho_scale = 6.0;
- cam->flag |= CAM_SHOWPASSEPARTOUT;
- cam->passepartalpha = 0.5f;
-
- cam->dof.aperture_fstop = 2.8f;
- cam->dof.aperture_ratio = 1.0f;
- cam->dof.focus_distance = 10.0f;
-
- /* stereoscopy 3d */
- cam->stereo.interocular_distance = 0.065f;
- cam->stereo.convergence_distance = 30.f * 0.065f;
- cam->stereo.pole_merge_angle_from = DEG2RADF(60.0f);
- cam->stereo.pole_merge_angle_to = DEG2RADF(75.0f);
+ MEMCPY_STRUCT_AFTER(cam, DNA_struct_default_get(Camera), id);
}
void *BKE_camera_add(Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index bcf6bb338ff..7f2f04d7eb5 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -1351,9 +1351,10 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
Depsgraph *CTX_data_depsgraph_pointer(const bContext *C)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
/* Dependency graph might have been just allocated, and hence it will not be marked.
* This confuses redo system due to the lack of flushing changes back to the original data.
* In the future we would need to check whether the CTX_wm_window(C) is in editing mode (as an
@@ -1381,7 +1382,8 @@ Depsgraph *CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Depsgraph *CTX_data_depsgraph_on_load(const bContext *C)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- return BKE_scene_get_depsgraph(scene, view_layer, false);
+ return BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 861663fdd6b..5f9a726d34a 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -36,6 +36,7 @@
#include "DNA_anim_types.h"
#include "DNA_curve_types.h"
#include "DNA_material_types.h"
+#include "DNA_defaults.h"
/* for dereferencing pointers */
#include "DNA_key_types.h"
@@ -145,28 +146,13 @@ void BKE_curve_free(Curve *cu)
MEM_SAFE_FREE(cu->tb);
}
-void BKE_curve_init(Curve *cu)
-{
- /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cu, id)); */ /* cu->type is already initialized... */
-
- copy_v3_fl(cu->size, 1.0f);
- cu->flag = CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS;
- cu->pathlen = 100;
- cu->resolu = cu->resolv = (cu->type == OB_SURF) ? 4 : 12;
- cu->width = 1.0;
- cu->wordspace = 1.0;
- cu->spacing = cu->linedist = 1.0;
- cu->fsize = 1.0;
- cu->ulheight = 0.05;
- cu->texflag = CU_AUTOSPACE;
- cu->smallcaps_scale = 0.75f;
- /* XXX: this one seems to be the best one in most cases, at least for curve deform... */
- cu->twist_mode = CU_TWIST_MINIMUM;
- cu->bevfac1 = 0.0f;
- cu->bevfac2 = 1.0f;
- cu->bevfac1_mapping = CU_BEVFAC_MAP_RESOLU;
- cu->bevfac2_mapping = CU_BEVFAC_MAP_RESOLU;
- cu->bevresol = 4;
+void BKE_curve_init(Curve *cu, const short curve_type)
+{
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cu, id));
+
+ MEMCPY_STRUCT_AFTER(cu, DNA_struct_default_get(Curve), id);
+
+ cu->type = curve_type;
cu->bb = BKE_boundbox_alloc_unit();
@@ -182,6 +168,9 @@ void BKE_curve_init(Curve *cu)
cu->tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "textbox");
cu->tb[0].w = cu->tb[0].h = 0.0;
}
+ else if (cu->type == OB_SURF) {
+ cu->resolv = 4;
+ }
}
Curve *BKE_curve_add(Main *bmain, const char *name, int type)
@@ -189,9 +178,8 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
Curve *cu;
cu = BKE_libblock_alloc(bmain, ID_CU, name, 0);
- cu->type = type;
- BKE_curve_init(cu);
+ BKE_curve_init(cu, type);
return cu;
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 523c0199daa..3718e35176f 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -57,6 +57,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_light_types.h"
#include "DNA_world_types.h"
+#include "DNA_defaults.h"
#include "BLI_blenlib.h"
#include "BLI_math_vector.h"
@@ -298,10 +299,7 @@ static void image_init(Image *ima, short source, short type)
ima->ok = IMA_OK;
- ima->aspx = ima->aspy = 1.0;
- ima->gen_x = 1024;
- ima->gen_y = 1024;
- ima->gen_type = IMA_GENTYPE_GRID;
+ MEMCPY_STRUCT_AFTER(ima, DNA_struct_default_get(Image), id);
ima->source = source;
ima->type = type;
@@ -318,8 +316,6 @@ static void image_init(Image *ima, short source, short type)
BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings);
ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo Format");
-
- ima->gpuframenr = INT_MAX;
}
void BKE_image_init(struct Image *image)
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index e46b7ca5130..72b531c446a 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -41,6 +41,7 @@
#include "DNA_lattice_types.h"
#include "DNA_curve_types.h"
#include "DNA_key_types.h"
+#include "DNA_defaults.h"
#include "BKE_animsys.h"
#include "BKE_anim.h"
@@ -248,13 +249,10 @@ void BKE_lattice_init(Lattice *lt)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(lt, id));
- lt->flag = LT_GRID;
-
- lt->typeu = lt->typev = lt->typew = KEY_BSPLINE;
+ MEMCPY_STRUCT_AFTER(lt, DNA_struct_default_get(Lattice), id);
lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */
- lt->actbp = LT_ACTBP_NONE;
}
Lattice *BKE_lattice_add(Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index f6a5504acb2..f37d1dd5eed 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1271,7 +1271,7 @@ void BKE_libblock_init_empty(ID *id)
BKE_mesh_init((Mesh *)id);
break;
case ID_CU:
- BKE_curve_init((Curve *)id);
+ BKE_curve_init((Curve *)id, 0);
break;
case ID_MB:
BKE_mball_init((MetaBall *)id);
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 6453ad5e7e4..4f10a5bca6b 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -57,7 +57,7 @@ static void bke_override_property_operation_clear(IDOverrideLibraryPropertyOpera
/* Temp, for until library override is ready and tested enough to go 'public',
* we hide it by default in UI and such. */
-static bool _override_library_enabled = false;
+static bool _override_library_enabled = true;
void BKE_override_library_enable(const bool do_enable)
{
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index 07ec8d70af1..05fcba5c30d 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -32,6 +32,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
+#include "DNA_defaults.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -48,40 +49,9 @@ void BKE_light_init(Light *la)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(la, id));
- la->r = la->g = la->b = la->k = 1.0f;
- la->energy = 10.0f;
- la->dist = 25.0f;
- la->spotsize = DEG2RADF(45.0f);
- la->spotblend = 0.15f;
- la->att2 = 1.0f;
- la->mode = LA_SHADOW;
- la->bufsize = 512;
- la->clipsta = 0.05f;
- la->clipend = 40.0f;
- la->bleedexp = 2.5f;
- la->samp = 3;
- la->bias = 1.0f;
- la->soft = 3.0f;
- la->area_size = la->area_sizey = la->area_sizez = 0.25f;
- la->buffers = 1;
- la->preview = NULL;
- la->falloff_type = LA_FALLOFF_INVSQUARE;
- la->coeff_const = 1.0f;
- la->coeff_lin = 0.0f;
- la->coeff_quad = 0.0f;
- la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
- la->cascade_max_dist = 200.0f;
- la->cascade_count = 4;
- la->cascade_exponent = 0.8f;
- la->cascade_fade = 0.1f;
- la->contact_dist = 0.2f;
- la->contact_bias = 0.03f;
- la->contact_spread = 0.2f;
- la->contact_thickness = 0.2f;
- la->spec_fac = 1.0f;
- la->att_dist = 40.0f;
- la->sun_angle = DEG2RADF(0.526f);
+ MEMCPY_STRUCT_AFTER(la, DNA_struct_default_get(Light), id);
+ la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
BKE_curvemapping_initialize(la->curfalloff);
}
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index 1c2f8d22f3e..06f1ee5050b 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -21,8 +21,11 @@
* \ingroup bke
*/
+#include <string.h>
+
#include "DNA_object_types.h"
#include "DNA_lightprobe_types.h"
+#include "DNA_defaults.h"
#include "BLI_utildefines.h"
@@ -35,17 +38,7 @@ void BKE_lightprobe_init(LightProbe *probe)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(probe, id));
- probe->grid_resolution_x = probe->grid_resolution_y = probe->grid_resolution_z = 4;
- probe->distinf = 2.5f;
- probe->distpar = 2.5f;
- probe->falloff = 0.2f;
- probe->clipsta = 0.8f;
- probe->clipend = 40.0f;
- probe->vis_bias = 1.0f;
- probe->vis_blur = 0.2f;
- probe->intensity = 1.0f;
-
- probe->flag = LIGHTPROBE_FLAG_SHOW_INFLUENCE;
+ MEMCPY_STRUCT_AFTER(probe, DNA_struct_default_get(LightProbe), id);
}
void *BKE_lightprobe_add(Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index e5fa5ff08b0..3436bd7a978 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -30,6 +30,7 @@
#include "DNA_object_types.h"
#include "DNA_material_types.h" /* for ramp blend */
#include "DNA_texture_types.h"
+#include "DNA_defaults.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
@@ -76,34 +77,9 @@ void BKE_linestyle_init(FreestyleLineStyle *linestyle)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(linestyle, id));
- linestyle->panel = LS_PANEL_STROKES;
- linestyle->r = linestyle->g = linestyle->b = 0.0f;
- linestyle->alpha = 1.0f;
- linestyle->thickness = 3.0f;
- linestyle->thickness_position = LS_THICKNESS_CENTER;
- linestyle->thickness_ratio = 0.5f;
- linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE;
- linestyle->chaining = LS_CHAINING_PLAIN;
- linestyle->rounds = 3;
- linestyle->min_angle = DEG2RADF(0.0f);
- linestyle->max_angle = DEG2RADF(0.0f);
- linestyle->min_length = 0.0f;
- linestyle->max_length = 10000.0f;
- linestyle->split_length = 100;
- linestyle->chain_count = 10;
- linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
- linestyle->integration_type = LS_INTEGRATION_MEAN;
- linestyle->texstep = 1.0f;
- linestyle->pr_texture = TEX_PR_TEXTURE;
-
- BLI_listbase_clear(&linestyle->color_modifiers);
- BLI_listbase_clear(&linestyle->alpha_modifiers);
- BLI_listbase_clear(&linestyle->thickness_modifiers);
- BLI_listbase_clear(&linestyle->geometry_modifiers);
+ MEMCPY_STRUCT_AFTER(linestyle, DNA_struct_default_get(FreestyleLineStyle), id);
BKE_linestyle_geometry_modifier_add(linestyle, NULL, LS_MODIFIER_SAMPLING);
-
- linestyle->caps = LS_CAPS_BUTT;
}
FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 19009322975..b127d5d4d0e 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -39,6 +39,7 @@
#include "DNA_object_types.h"
#include "DNA_meta_types.h"
#include "DNA_scene_types.h"
+#include "DNA_defaults.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
@@ -79,12 +80,7 @@ void BKE_mball_init(MetaBall *mb)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(mb, id));
- mb->size[0] = mb->size[1] = mb->size[2] = 1.0;
- mb->texflag = MB_AUTOSPACE;
-
- mb->wiresize = 0.4f;
- mb->rendersize = 0.2f;
- mb->thresh = 0.6f;
+ MEMCPY_STRUCT_AFTER(mb, DNA_struct_default_get(MetaBall), id);
}
MetaBall *BKE_mball_add(Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 7983fe54be5..8ffb99dd8ab 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -822,8 +822,10 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
/* gather list of objects or single object */
int totcollection = 0;
+ const bool use_whole_collection = part->draw & PART_DRAW_WHOLE_GR;
+ const bool use_collection_count = part->draw & PART_DRAW_COUNT_GR && !use_whole_collection;
if (part->ren_as == PART_DRAW_GR) {
- if (part->draw & PART_DRAW_COUNT_GR) {
+ if (use_collection_count) {
psys_find_group_weights(part);
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -848,7 +850,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
oblist = MEM_callocN((size_t)totcollection * sizeof(Object *), "dupcollection object list");
- if (part->draw & PART_DRAW_COUNT_GR) {
+ if (use_collection_count) {
a = 0;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (
@@ -916,7 +918,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
}
/* for collections, pick the object based on settings */
- if (part->draw & PART_DRAW_RAND_GR) {
+ if (part->draw & PART_DRAW_RAND_GR && !use_whole_collection) {
b = BLI_rng_get_int(rng) % totcollection;
}
else {
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index b386a0d4483..5980aa456e2 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1060,6 +1060,10 @@ void BKE_sculptsession_free(Object *ob)
MEM_freeN(ss->deform_imats);
}
+ if (ss->preview_vert_index_list) {
+ MEM_freeN(ss->preview_vert_index_list);
+ }
+
BKE_sculptsession_free_vwpaint_data(ob->sculpt);
MEM_freeN(ss);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 1a6b289ee7f..6514f6f572b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -595,7 +595,10 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
sce->eevee.light_cache = NULL;
}
- BKE_lanpr_free_everything(sce);
+ if (sce->display.shading.prop) {
+ IDP_FreeProperty(sce->display.shading.prop);
+ sce->display.shading.prop = NULL;
+ }
/* These are freed on doversion. */
BLI_assert(sce->layer_properties == NULL);
@@ -776,79 +779,6 @@ void BKE_scene_init(Scene *sce)
BKE_view_layer_add(sce, "View Layer");
- /* SceneDisplay */
- copy_v3_v3(sce->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3});
- sce->display.shadow_shift = 0.1f;
- sce->display.shadow_focus = 0.0f;
-
- sce->display.matcap_ssao_distance = 0.2f;
- sce->display.matcap_ssao_attenuation = 1.0f;
- sce->display.matcap_ssao_samples = 16;
-
- sce->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8;
- sce->display.viewport_aa = SCE_DISPLAY_AA_FXAA;
-
- /* 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.gi_irradiance_smoothing = 0.1f;
- sce->eevee.gi_filter_quality = 3.0f;
-
- sce->eevee.taa_samples = 16;
- sce->eevee.taa_render_samples = 64;
-
- sce->eevee.sss_samples = 7;
- sce->eevee.sss_jitter_threshold = 0.3f;
-
- sce->eevee.ssr_quality = 0.25f;
- sce->eevee.ssr_max_roughness = 0.5f;
- sce->eevee.ssr_thickness = 0.2f;
- sce->eevee.ssr_border_fade = 0.075f;
- sce->eevee.ssr_firefly_fac = 10.0f;
-
- sce->eevee.volumetric_start = 0.1f;
- sce->eevee.volumetric_end = 100.0f;
- sce->eevee.volumetric_tile_size = 8;
- sce->eevee.volumetric_samples = 64;
- sce->eevee.volumetric_sample_distribution = 0.8f;
- sce->eevee.volumetric_light_clamp = 0.0f;
- sce->eevee.volumetric_shadow_samples = 16;
-
- sce->eevee.gtao_distance = 0.2f;
- sce->eevee.gtao_factor = 1.0f;
- sce->eevee.gtao_quality = 0.25f;
-
- sce->eevee.bokeh_max_size = 100.0f;
- sce->eevee.bokeh_threshold = 1.0f;
-
- copy_v3_fl(sce->eevee.bloom_color, 1.0f);
- sce->eevee.bloom_threshold = 0.8f;
- sce->eevee.bloom_knee = 0.5f;
- sce->eevee.bloom_intensity = 0.05f;
- sce->eevee.bloom_radius = 6.5f;
- sce->eevee.bloom_clamp = 0.0f;
-
- sce->eevee.motion_blur_samples = 8;
- sce->eevee.motion_blur_shutter = 0.5f;
-
- sce->eevee.shadow_cube_size = 512;
- sce->eevee.shadow_cascade_size = 1024;
-
- sce->eevee.light_cache = NULL;
- sce->eevee.light_threshold = 0.01f;
-
- sce->eevee.overscan = 3.0f;
-
- sce->eevee.flag = SCE_EEVEE_VOLUMETRIC_LIGHTS | SCE_EEVEE_GTAO_BENT_NORMALS |
- SCE_EEVEE_GTAO_BOUNCE | SCE_EEVEE_TAA_REPROJECTION |
- SCE_EEVEE_SSR_HALF_RESOLUTION | SCE_EEVEE_SHADOW_SOFT;
-
/* SceneLANPR */
sce->lanpr.crease_threshold = 0.7;
@@ -861,6 +791,7 @@ void BKE_scene_init(Scene *sce)
sce->lanpr.flags |= (LANPR_USE_CHAINING | LANPR_USE_INTERSECTIONS);
sce->lanpr.chaining_image_threshold = 0.01;
sce->lanpr.chaining_geometry_threshold = 0.1;
+
}
Scene *BKE_scene_add(Main *bmain, const char *name)
@@ -1442,7 +1373,7 @@ static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool on
bool run_callbacks = DEG_id_type_any_updated(depsgraph);
if (run_callbacks) {
- BKE_callback_exec(bmain, &scene->id, BKE_CB_EVT_DEPSGRAPH_UPDATE_PRE);
+ BKE_callback_exec_id(bmain, &scene->id, BKE_CB_EVT_DEPSGRAPH_UPDATE_PRE);
}
for (int pass = 0; pass < 2; pass++) {
@@ -1460,7 +1391,8 @@ static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool on
BKE_scene_update_sound(depsgraph, bmain);
/* Notify python about depsgraph update. */
if (run_callbacks) {
- BKE_callback_exec(bmain, &scene->id, BKE_CB_EVT_DEPSGRAPH_UPDATE_POST);
+ BKE_callback_exec_id_depsgraph(
+ bmain, &scene->id, depsgraph, BKE_CB_EVT_DEPSGRAPH_UPDATE_POST);
}
/* Inform editors about possible changes. */
DEG_ids_check_recalc(bmain, depsgraph, scene, view_layer, false);
@@ -1473,23 +1405,9 @@ static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool on
if (DEG_is_fully_evaluated(depsgraph)) {
break;
}
+
+ run_callbacks = false;
}
-
- /* TODO(sergey): Some functions here are changing global state,
- * for example, clearing update tags from bmain.
- */
- /* (Re-)build dependency graph if needed. */
- DEG_graph_relations_update(depsgraph, bmain, scene, view_layer);
- /* Uncomment this to check if graph was properly tagged for update. */
- // DEG_debug_graph_relations_validate(depsgraph, bmain, scene);
- /* Flush editing data if needed. */
- prepare_mesh_for_viewport_render(bmain, view_layer);
- /* Update all objects: drivers, matrices, displists, etc. flags set
- * by depgraph or manual, no layer check here, gets correct flushed.
- */
- DEG_evaluate_on_refresh(bmain, depsgraph);
- /* Update sound system. */
- BKE_scene_update_sound(depsgraph, bmain);
}
void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain)
@@ -1509,7 +1427,7 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
/* Keep this first. */
- BKE_callback_exec(bmain, &scene->id, BKE_CB_EVT_FRAME_CHANGE_PRE);
+ BKE_callback_exec_id(bmain, &scene->id, BKE_CB_EVT_FRAME_CHANGE_PRE);
for (int pass = 0; pass < 2; pass++) {
/* Update animated image textures for particles, modifiers, gpu, etc,
@@ -1523,15 +1441,23 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
#endif
/* Update all objects: drivers, matrices, displists, etc. flags set
* by depgraph or manual, no layer check here, gets correct flushed.
- */
- const float ctime = BKE_scene_frame_get(scene);
- DEG_evaluate_on_framechange(bmain, depsgraph, ctime);
+ *
+ * NOTE: Only update for new frame on first iteration. Second iteration is for ensuring user
+ * edits from callback are properly taken into account. Doing a time update on those would
+ * loose any possible unkeyed changes made by the handler. */
+ if (pass == 0) {
+ const float ctime = BKE_scene_frame_get(scene);
+ DEG_evaluate_on_framechange(bmain, depsgraph, ctime);
+ }
+ else {
+ DEG_evaluate_on_refresh(bmain, depsgraph);
+ }
/* Update sound system animation. */
BKE_scene_update_sound(depsgraph, bmain);
/* Notify editors and python about recalc. */
if (pass == 0) {
- BKE_callback_exec(bmain, &scene->id, BKE_CB_EVT_FRAME_CHANGE_POST);
+ BKE_callback_exec_id_depsgraph(bmain, &scene->id, depsgraph, BKE_CB_EVT_FRAME_CHANGE_POST);
}
/* Inform editors about possible changes. */
@@ -1555,7 +1481,7 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
*/
void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
DEG_make_active(depsgraph);
BKE_scene_graph_update_tagged(depsgraph, bmain);
}
@@ -2187,7 +2113,7 @@ void BKE_scene_free_depsgraph_hash(Scene *scene)
/* Query depsgraph for a specific contexts. */
-Depsgraph *BKE_scene_get_depsgraph(Scene *scene, ViewLayer *view_layer, bool allocate)
+Depsgraph *BKE_scene_get_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, bool allocate)
{
BLI_assert(scene != NULL);
BLI_assert(view_layer != NULL);
@@ -2211,7 +2137,7 @@ Depsgraph *BKE_scene_get_depsgraph(Scene *scene, ViewLayer *view_layer, bool all
scene->depsgraph_hash, &key, (void ***)&key_ptr, (void ***)&depsgraph_ptr)) {
*key_ptr = MEM_mallocN(sizeof(DepsgraphKey), __func__);
**key_ptr = key;
- *depsgraph_ptr = DEG_graph_new(scene, view_layer, DAG_EVAL_VIEWPORT);
+ *depsgraph_ptr = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_VIEWPORT);
/* TODO(sergey): Would be cool to avoid string format print,
* but is a bit tricky because we can't know in advance whether
* we will ever enable debug messages for this depsgraph.
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index b29e07bb56d..14096335626 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -3534,7 +3534,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
}
/* opengl offscreen render */
- depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ depsgraph = BKE_scene_get_depsgraph(context->bmain, scene, view_layer, true);
BKE_scene_graph_update_for_newframe(depsgraph, context->bmain);
ibuf = sequencer_view3d_cb(
/* set for OpenGL render (NULL when scrubbing) */
@@ -4933,7 +4933,7 @@ static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene,
changed = true;
}
}
- else if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ else if (seq->type == SEQ_TYPE_SOUND_RAM && seq->sound) {
const float length = BKE_sound_get_length(bmain, seq->sound);
int old = seq->len;
float fac;
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 014a2c6d6ac..992ceda7b74 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -39,6 +39,7 @@
#include "BLI_task.h"
#include "BLI_math_solvers.h"
+#include "BKE_context.h"
#include "BKE_shrinkwrap.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_DerivedMesh.h"
@@ -1480,3 +1481,28 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
ss_mesh->release(ss_mesh);
}
}
+
+void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C,
+ Object *ob_source,
+ Object *ob_target)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ struct Scene *sce = CTX_data_scene(C);
+ ShrinkwrapModifierData ssmd = {0};
+ ModifierEvalContext ctx = {depsgraph, ob_source, 0};
+ int totvert;
+
+ ssmd.target = ob_target;
+ ssmd.shrinkType = MOD_SHRINKWRAP_NEAREST_SURFACE;
+ ssmd.shrinkMode = MOD_SHRINKWRAP_ON_SURFACE;
+ ssmd.keepDist = 0.0f;
+
+ Mesh *src_me = ob_source->data;
+ float(*vertexCos)[3] = BKE_mesh_vert_coords_alloc(src_me, &totvert);
+
+ shrinkwrapModifier_deform(&ssmd, &ctx, sce, ob_source, src_me, NULL, -1, vertexCos, totvert);
+
+ BKE_mesh_vert_coords_apply(src_me, vertexCos);
+
+ MEM_freeN(vertexCos);
+}
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index c7a0d65a2a9..46a74e25b8b 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -21,6 +21,7 @@
#include "DNA_object_types.h"
#include "DNA_sound_types.h"
#include "DNA_speaker_types.h"
+#include "DNA_defaults.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -34,18 +35,7 @@ void BKE_speaker_init(Speaker *spk)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(spk, id));
- spk->attenuation = 1.0f;
- spk->cone_angle_inner = 360.0f;
- spk->cone_angle_outer = 360.0f;
- spk->cone_volume_outer = 1.0f;
- spk->distance_max = FLT_MAX;
- spk->distance_reference = 1.0f;
- spk->flag = 0;
- spk->pitch = 1.0f;
- spk->sound = NULL;
- spk->volume = 1.0f;
- spk->volume_max = 1.0f;
- spk->volume_min = 0.0f;
+ MEMCPY_STRUCT_AFTER(spk, DNA_struct_default_get(Speaker), id);
}
void *BKE_speaker_add(Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 5c03b7730aa..fb8697b1ee0 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -41,6 +41,7 @@
#include "DNA_color_types.h"
#include "DNA_particle_types.h"
#include "DNA_linestyle_types.h"
+#include "DNA_defaults.h"
#include "IMB_imbuf.h"
@@ -214,56 +215,11 @@ void BKE_texture_free(Tex *tex)
void BKE_texture_default(Tex *tex)
{
- /* Not here, can be called with some pointers set. :/ */
- /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */
-
- tex->type = TEX_IMAGE;
- tex->ima = NULL;
- tex->stype = 0;
- tex->flag = TEX_CHECKER_ODD;
- tex->imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA;
- tex->extend = TEX_REPEAT;
- tex->cropxmin = tex->cropymin = 0.0;
- tex->cropxmax = tex->cropymax = 1.0;
- tex->texfilter = TXF_EWA;
- tex->afmax = 8;
- tex->xrepeat = tex->yrepeat = 1;
- tex->sfra = 1;
- tex->frames = 0;
- tex->offset = 0;
- tex->noisesize = 0.25;
- tex->noisedepth = 2;
- tex->turbul = 5.0;
- tex->nabla = 0.025; // also in do_versions
- tex->bright = 1.0;
- tex->contrast = 1.0;
- tex->saturation = 1.0;
- tex->filtersize = 1.0;
- tex->rfac = 1.0;
- tex->gfac = 1.0;
- tex->bfac = 1.0;
- /* newnoise: init. */
- tex->noisebasis = 0;
- tex->noisebasis2 = 0;
- /* musgrave */
- tex->mg_H = 1.0;
- tex->mg_lacunarity = 2.0;
- tex->mg_octaves = 2.0;
- tex->mg_offset = 1.0;
- tex->mg_gain = 1.0;
- tex->ns_outscale = 1.0;
- /* distnoise */
- tex->dist_amount = 1.0;
- /* voronoi */
- tex->vn_w1 = 1.0;
- tex->vn_w2 = tex->vn_w3 = tex->vn_w4 = 0.0;
- tex->vn_mexp = 2.5;
- tex->vn_distm = 0;
- tex->vn_coltype = 0;
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id));
- BKE_imageuser_default(&tex->iuser);
+ MEMCPY_STRUCT_AFTER(tex, DNA_struct_default_get(Tex), id);
- tex->preview = NULL;
+ BKE_imageuser_default(&tex->iuser);
}
void BKE_texture_type_set(Tex *tex, int type)
@@ -288,69 +244,7 @@ Tex *BKE_texture_add(Main *bmain, const char *name)
void BKE_texture_mtex_default(MTex *mtex)
{
- mtex->texco = TEXCO_UV;
- mtex->mapto = MAP_COL;
- mtex->object = NULL;
- mtex->projx = PROJ_X;
- mtex->projy = PROJ_Y;
- mtex->projz = PROJ_Z;
- mtex->mapping = MTEX_FLAT;
- mtex->ofs[0] = 0.0;
- mtex->ofs[1] = 0.0;
- mtex->ofs[2] = 0.0;
- mtex->size[0] = 1.0;
- mtex->size[1] = 1.0;
- mtex->size[2] = 1.0;
- mtex->tex = NULL;
- mtex->colormodel = 0;
- mtex->r = 1.0;
- mtex->g = 0.0;
- mtex->b = 1.0;
- mtex->k = 1.0;
- mtex->def_var = 1.0;
- mtex->blendtype = MTEX_BLEND;
- mtex->colfac = 1.0;
- mtex->norfac = 1.0;
- mtex->varfac = 1.0;
- mtex->dispfac = 0.2;
- mtex->colspecfac = 1.0f;
- mtex->mirrfac = 1.0f;
- mtex->alphafac = 1.0f;
- mtex->difffac = 1.0f;
- mtex->specfac = 1.0f;
- mtex->emitfac = 1.0f;
- mtex->hardfac = 1.0f;
- mtex->raymirrfac = 1.0f;
- mtex->translfac = 1.0f;
- mtex->ambfac = 1.0f;
- mtex->colemitfac = 1.0f;
- mtex->colreflfac = 1.0f;
- mtex->coltransfac = 1.0f;
- mtex->densfac = 1.0f;
- mtex->scatterfac = 1.0f;
- mtex->reflfac = 1.0f;
- mtex->shadowfac = 1.0f;
- mtex->zenupfac = 1.0f;
- mtex->zendownfac = 1.0f;
- mtex->blendfac = 1.0f;
- mtex->timefac = 1.0f;
- mtex->lengthfac = 1.0f;
- mtex->clumpfac = 1.0f;
- mtex->kinkfac = 1.0f;
- mtex->kinkampfac = 1.0f;
- mtex->roughfac = 1.0f;
- mtex->twistfac = 1.0f;
- mtex->padensfac = 1.0f;
- mtex->lifefac = 1.0f;
- mtex->sizefac = 1.0f;
- mtex->ivelfac = 1.0f;
- mtex->dampfac = 1.0f;
- mtex->gravityfac = 1.0f;
- mtex->fieldfac = 1.0f;
- mtex->normapspace = MTEX_NSPACE_TANGENT;
- mtex->brush_map_mode = MTEX_MAP_MODE_TILED;
- mtex->random_angle = 2.0f * (float)M_PI;
- mtex->brush_angle_mode = 0;
+ memcpy(mtex, DNA_struct_default_get(MTex), sizeof(*mtex));
}
/* ------------------------------------------------------------------------- */
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 36b950fb8f9..ecae1650a51 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -503,7 +503,7 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack,
/* Might not be final place for this to be called - probably only want to call it from some
* undo handlers, not all of them? */
if (BKE_override_library_is_enabled()) {
- BKE_main_override_library_operations_create(CTX_data_main(C), false);
+ BKE_main_override_library_operations_create(G_MAIN, false);
}
/* Remove all undos after (also when 'ustack->step_active == NULL'). */
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 31fc87d7021..9ad357290c4 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -30,6 +30,7 @@
#include "DNA_world_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
+#include "DNA_defaults.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
@@ -71,16 +72,7 @@ void BKE_world_init(World *wrld)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wrld, id));
- wrld->horr = 0.05f;
- wrld->horg = 0.05f;
- wrld->horb = 0.05f;
-
- wrld->aodist = 10.0f;
- wrld->aoenergy = 1.0f;
-
- wrld->preview = NULL;
- wrld->miststa = 5.0f;
- wrld->mistdist = 25.0f;
+ MEMCPY_STRUCT_AFTER(wrld, DNA_struct_default_get(World), id);
}
World *BKE_world_add(Main *bmain, const char *name)
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index f1575ed2b2d..a81dc018ed0 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -4773,29 +4773,24 @@ void projmat_from_subregion(const float projmat[4][4],
float rect_width = (float)(x_max - x_min);
float rect_height = (float)(y_max - y_min);
+ float x_sca = (float)win_size[0] / rect_width;
+ float y_sca = (float)win_size[1] / rect_height;
+
float x_fac = (float)((x_min + x_max) - win_size[0]) / rect_width;
float y_fac = (float)((y_min + y_max) - win_size[1]) / rect_height;
copy_m4_m4(r_projmat, projmat);
- r_projmat[0][0] *= (float)win_size[0] / rect_width;
- r_projmat[1][1] *= (float)win_size[1] / rect_height;
-
-#if 0 /* TODO: check if this is more efficient. */
- r_projmat[2][0] -= x_fac * r_projmat[2][3];
- r_projmat[2][1] -= y_fac * r_projmat[2][3];
+ r_projmat[0][0] *= x_sca;
+ r_projmat[1][1] *= y_sca;
- r_projmat[3][0] -= x_fac * r_projmat[3][3];
- r_projmat[3][1] -= y_fac * r_projmat[3][3];
-#else
if (projmat[3][3] == 0.0f) {
- r_projmat[2][0] += x_fac;
- r_projmat[2][1] += y_fac;
+ r_projmat[2][0] = r_projmat[2][0] * x_sca + x_fac;
+ r_projmat[2][1] = r_projmat[2][1] * y_sca + y_fac;
}
else {
- r_projmat[3][0] -= x_fac;
- r_projmat[3][1] -= y_fac;
+ r_projmat[3][0] = r_projmat[3][0] * x_sca - x_fac;
+ r_projmat[3][1] = r_projmat[3][1] * y_sca - y_fac;
}
-#endif
}
static void i_multmatrix(float icand[4][4], float Vm[4][4])
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2a2897b34f0..d2924c7e190 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6356,6 +6356,14 @@ static void direct_link_lightcache(FileData *fd, LightCache *cache)
cache->grid_data = newdataadr(fd, cache->grid_data);
}
+static void direct_link_view3dshading(FileData *fd, View3DShading *shading)
+{
+ if (shading->prop) {
+ shading->prop = newdataadr(fd, shading->prop);
+ IDP_DirectLinkGroup_OrFree(&shading->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+}
+
/* check for cyclic set-scene,
* libs can cause this case which is normally prevented, see (T#####) */
#define USE_SETSCENE_CHECK
@@ -7014,6 +7022,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
ll->shgrp = NULL;
// ll->normal_control_object = newlibadr(fd, sce->id.lib, ll->normal_control_object);
}
+
+ direct_link_view3dshading(fd, &sce->display.shading);
sce->layer_properties = newdataadr(fd, sce->layer_properties);
IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
@@ -7283,6 +7293,8 @@ static void direct_link_area(FileData *fd, ScrArea *area)
v3d->fx_settings.ssao = newdataadr(fd, v3d->fx_settings.ssao);
}
+ direct_link_view3dshading(fd, &v3d->shading);
+
blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
}
else if (sl->spacetype == SPACE_GRAPH) {
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 3d55891bb0a..ae355e182e5 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1748,7 +1748,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "falloff_angle")) {
for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
br->falloff_angle = DEG2RADF(80);
- br->flag &= ~(BRUSH_FLAG_UNUSED_1 | BRUSH_FLAG_UNUSED_6 | BRUSH_FLAG_UNUSED_7 |
+ br->flag &= ~(BRUSH_FLAG_UNUSED_1 | BRUSH_FLAG_UNUSED_6 | BRUSH_GRAB_ACTIVE_VERTEX |
BRUSH_SCENE_SPACING | BRUSH_FRONTFACE_FALLOFF);
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 532b5d30874..700c32ae8e2 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3866,8 +3866,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Elatic deform brush */
for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
- if (br->ob_mode & OB_MODE_SCULPT && br->elastic_deform_compressibility == 0.0f) {
- br->elastic_deform_compressibility = 0.5f;
+ if (br->ob_mode & OB_MODE_SCULPT && br->elastic_deform_volume_preservation == 0.0f) {
+ br->elastic_deform_volume_preservation = 0.5f;
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 1c91871694f..87c8869622a 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -196,18 +196,13 @@ static void blo_update_defaults_screen(bScreen *screen,
}
}
- /* Show toopbar for sculpt/paint modes. */
- const bool show_tool_header = STR_ELEM(
- workspace_name, "Sculpting", "Texture Paint", "2D Animation", "2D Full Canvas");
-
- if (show_tool_header) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_TOOL_HEADER) {
- ar->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER);
- }
+ /* Show top-bar by default. */
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_TOOL_HEADER) {
+ ar->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER);
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 0182f8f6162..967820565e7 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -151,6 +151,7 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
*/
{
FROM_DEFAULT_V4_UCHAR(space_file.execution_buts);
+ FROM_DEFAULT_V4_UCHAR(tui.icon_folder);
}
#undef FROM_DEFAULT_V4_UCHAR
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 2d90a2b61d3..fc846830718 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2414,6 +2414,13 @@ static void write_view_settings(WriteData *wd, ColorManagedViewSettings *view_se
}
}
+static void write_view3dshading(WriteData *wd, View3DShading *shading)
+{
+ if (shading->prop) {
+ IDP_WriteProperty(shading->prop, wd);
+ }
+}
+
static void write_paint(WriteData *wd, Paint *p)
{
if (p->cavity_curve) {
@@ -2692,6 +2699,8 @@ static void write_scene(WriteData *wd, Scene *sce)
writestruct(wd, DATA, LANPR_LineLayerComponent, 1, llc);
}
}
+
+ write_view3dshading(wd, &sce->display.shading);
/* Freed on doversion. */
BLI_assert(sce->layer_properties == NULL);
@@ -2859,6 +2868,7 @@ static void write_area_regions(WriteData *wd, ScrArea *area)
if (v3d->fx_settings.dof) {
writestruct(wd, DATA, GPUDOFSettings, 1, v3d->fx_settings.dof);
}
+ write_view3dshading(wd, &v3d->shading);
}
else if (sl->spacetype == SPACE_GRAPH) {
SpaceGraph *sipo = (SpaceGraph *)sl;
diff --git a/source/blender/collada/BlenderContext.cpp b/source/blender/collada/BlenderContext.cpp
index 709f84c3f77..8735d71ec40 100644
--- a/source/blender/collada/BlenderContext.cpp
+++ b/source/blender/collada/BlenderContext.cpp
@@ -121,7 +121,7 @@ bContext *BlenderContext::get_context()
Depsgraph *BlenderContext::get_depsgraph()
{
if (!depsgraph) {
- depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ depsgraph = BKE_scene_get_depsgraph(main, scene, view_layer, true);
}
return depsgraph;
}
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 49c510d9d3e..21ab148496c 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -73,6 +73,7 @@ set(SRC
intern/depsgraph_query.cc
intern/depsgraph_query_foreach.cc
intern/depsgraph_query_iter.cc
+ intern/depsgraph_registry.cc
intern/depsgraph_tag.cc
intern/depsgraph_type.cc
intern/depsgraph_update.cc
@@ -107,6 +108,7 @@ set(SRC
intern/node/deg_node_time.h
intern/depsgraph.h
intern/depsgraph_physics.h
+ intern/depsgraph_registry.h
intern/depsgraph_tag.h
intern/depsgraph_type.h
intern/depsgraph_update.h
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index d4518729d99..e44dddbcf54 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -87,7 +87,10 @@ extern "C" {
/* Create new Depsgraph instance */
// TODO: what args are needed here? What's the building-graph entry point?
-Depsgraph *DEG_graph_new(struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode);
+Depsgraph *DEG_graph_new(struct Main *bmain,
+ struct Scene *scene,
+ struct ViewLayer *view_layer,
+ eEvaluationMode mode);
/* Free Depsgraph itself and all its data */
void DEG_graph_free(Depsgraph *graph);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index d3ae3da9b56..e53ac40f196 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -211,7 +211,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
}
/* Final transform properties go to the Done node for the exit. */
else if (STREQ(prop_name, "head") || STREQ(prop_name, "tail") ||
- STRPREFIX(prop_name, "matrix")) {
+ STREQ(prop_name, "length") || STRPREFIX(prop_name, "matrix")) {
if (source == RNAPointerSource::EXIT) {
node_identifier.operation_code = OperationCode::BONE_DONE;
}
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 6d3aed65a14..dcdea87fe1a 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -45,6 +45,8 @@ extern "C" {
#include "DEG_depsgraph_debug.h"
#include "intern/depsgraph_update.h"
+#include "intern/depsgraph_physics.h"
+#include "intern/depsgraph_registry.h"
#include "intern/eval/deg_eval_copy_on_write.h"
@@ -55,8 +57,6 @@ extern "C" {
#include "intern/node/deg_node_operation.h"
#include "intern/node/deg_node_time.h"
-#include "intern/depsgraph_physics.h"
-
namespace DEG {
/* TODO(sergey): Find a better place for this. */
@@ -65,10 +65,11 @@ template<typename T> static void remove_from_vector(vector<T> *vector, const T &
vector->erase(std::remove(vector->begin(), vector->end(), value), vector->end());
}
-Depsgraph::Depsgraph(Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
+Depsgraph::Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
: time_source(NULL),
need_update(true),
need_update_time(false),
+ bmain(bmain),
scene(scene),
view_layer(view_layer),
mode(mode),
@@ -313,17 +314,23 @@ ID *Depsgraph::get_cow_id(const ID *id_orig) const
/* Public Graph API */
/* Initialize a new Depsgraph */
-Depsgraph *DEG_graph_new(Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
+Depsgraph *DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
{
- DEG::Depsgraph *deg_depsgraph = OBJECT_GUARDED_NEW(DEG::Depsgraph, scene, view_layer, mode);
+ DEG::Depsgraph *deg_depsgraph = OBJECT_GUARDED_NEW(
+ DEG::Depsgraph, bmain, scene, view_layer, mode);
+ DEG::register_graph(deg_depsgraph);
return reinterpret_cast<Depsgraph *>(deg_depsgraph);
}
/* Free graph's contents and graph itself */
void DEG_graph_free(Depsgraph *graph)
{
+ if (graph == NULL) {
+ return;
+ }
using DEG::Depsgraph;
DEG::Depsgraph *deg_depsgraph = reinterpret_cast<DEG::Depsgraph *>(graph);
+ DEG::unregister_graph(deg_depsgraph);
OBJECT_GUARDED_DELETE(deg_depsgraph, Depsgraph);
}
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 96b1a2a1f8a..30ae4edde34 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -100,7 +100,7 @@ struct Depsgraph {
typedef vector<OperationNode *> OperationNodes;
typedef vector<IDNode *> IDDepsNodes;
- Depsgraph(Scene *scene, ViewLayer *view_layer, eEvaluationMode mode);
+ Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode);
~Depsgraph();
TimeSourceNode *add_time_source();
@@ -172,7 +172,8 @@ struct Depsgraph {
* Mainly used by graph evaluation. */
SpinLock lock;
- /* Scene, layer, mode this dependency graph is built for. */
+ /* Main, scene, layer, mode this dependency graph is built for. */
+ Main *bmain;
Scene *scene;
ViewLayer *view_layer;
eEvaluationMode mode;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index dd2d7f70ed5..968ed8ef403 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -358,7 +358,7 @@ void DEG_relations_tag_update(Main *bmain)
DEG_GLOBAL_DEBUG_PRINTF(TAG, "%s: Tagging relations for update.\n", __func__);
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
- Depsgraph *depsgraph = (Depsgraph *)BKE_scene_get_depsgraph(scene, view_layer, false);
+ Depsgraph *depsgraph = (Depsgraph *)BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
if (depsgraph != NULL) {
DEG_graph_tag_relations_update(depsgraph);
}
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index c5a756102ca..d079c958e04 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -91,7 +91,7 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph,
Scene *scene,
ViewLayer *view_layer)
{
- Depsgraph *temp_depsgraph = DEG_graph_new(scene, view_layer, DEG_get_mode(graph));
+ Depsgraph *temp_depsgraph = DEG_graph_new(bmain, scene, view_layer, DEG_get_mode(graph));
bool valid = true;
DEG_graph_build_from_view_layer(temp_depsgraph, bmain, scene, view_layer);
if (!DEG_debug_compare(temp_depsgraph, graph)) {
diff --git a/source/blender/depsgraph/intern/depsgraph_registry.cc b/source/blender/depsgraph/intern/depsgraph_registry.cc
new file mode 100644
index 00000000000..ad60b1bc4cf
--- /dev/null
+++ b/source/blender/depsgraph/intern/depsgraph_registry.cc
@@ -0,0 +1,74 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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) 2019 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#include "intern/depsgraph_registry.h"
+
+#include "BLI_utildefines.h"
+
+#include "intern/depsgraph.h"
+
+namespace DEG {
+
+typedef set<Depsgraph *> DepsgraphStorage;
+typedef map<Main *, DepsgraphStorage> MainDepsgraphMap;
+
+static MainDepsgraphMap g_graph_registry;
+
+void register_graph(Depsgraph *depsgraph)
+{
+ Main *bmain = depsgraph->bmain;
+ MainDepsgraphMap::iterator it = g_graph_registry.find(bmain);
+ if (it == g_graph_registry.end()) {
+ it = g_graph_registry.insert(make_pair(bmain, DepsgraphStorage())).first;
+ }
+ DepsgraphStorage &storage = it->second;
+ storage.insert(depsgraph);
+}
+
+void unregister_graph(Depsgraph *depsgraph)
+{
+ Main *bmain = depsgraph->bmain;
+ MainDepsgraphMap::iterator it = g_graph_registry.find(bmain);
+ BLI_assert(it != g_graph_registry.end());
+
+ // Remove dependency graph from storage.
+ DepsgraphStorage &storage = it->second;
+ storage.erase(depsgraph);
+
+ // If this was the last depsgraph associated with the main, remove the main entry as well.
+ if (storage.empty()) {
+ g_graph_registry.erase(bmain);
+ }
+}
+
+const set<Depsgraph *> &get_all_registered_graphs(Main *bmain)
+{
+ MainDepsgraphMap::iterator it = g_graph_registry.find(bmain);
+ if (it == g_graph_registry.end()) {
+ static DepsgraphStorage empty_storage;
+ return empty_storage;
+ }
+ return it->second;
+}
+
+} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_registry.h b/source/blender/depsgraph/intern/depsgraph_registry.h
new file mode 100644
index 00000000000..7517b6a0b2a
--- /dev/null
+++ b/source/blender/depsgraph/intern/depsgraph_registry.h
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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) 2019 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "intern/depsgraph_type.h"
+
+struct Main;
+
+namespace DEG {
+
+struct Depsgraph;
+
+void register_graph(Depsgraph *depsgraph);
+void unregister_graph(Depsgraph *depsgraph);
+const set<Depsgraph *> &get_all_registered_graphs(Main *bmain);
+
+} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 647837bd758..2fdce0e30a5 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -30,7 +30,6 @@
#include <queue>
#include "BLI_utildefines.h"
-#include "BLI_listbase.h"
#include "BLI_math_bits.h"
#include "BLI_task.h"
@@ -64,6 +63,7 @@ extern "C" {
#include "intern/builder/deg_builder.h"
#include "intern/depsgraph.h"
#include "intern/depsgraph_update.h"
+#include "intern/depsgraph_registry.h"
#include "intern/eval/deg_eval_copy_on_write.h"
#include "intern/eval/deg_eval_flush.h"
#include "intern/node/deg_node.h"
@@ -605,13 +605,8 @@ NodeType geometry_tag_to_component(const ID *id)
void id_tag_update(Main *bmain, ID *id, int flag, eUpdateSource update_source)
{
graph_id_tag_update(bmain, NULL, id, flag, update_source);
- LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
- LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
- Depsgraph *depsgraph = (Depsgraph *)BKE_scene_get_depsgraph(scene, view_layer, false);
- if (depsgraph != NULL) {
- graph_id_tag_update(bmain, depsgraph, id, flag, update_source);
- }
- }
+ for (DEG::Depsgraph *depsgraph : DEG::get_all_registered_graphs(bmain)) {
+ graph_id_tag_update(bmain, depsgraph, id, flag, update_source);
}
}
@@ -769,13 +764,8 @@ void DEG_graph_id_type_tag(Depsgraph *depsgraph, short id_type)
void DEG_id_type_tag(Main *bmain, short id_type)
{
- LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
- LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
- Depsgraph *depsgraph = (Depsgraph *)BKE_scene_get_depsgraph(scene, view_layer, false);
- if (depsgraph != NULL) {
- DEG_graph_id_type_tag(depsgraph, id_type);
- }
- }
+ for (DEG::Depsgraph *depsgraph : DEG::get_all_registered_graphs(bmain)) {
+ DEG_graph_id_type_tag(reinterpret_cast<::Depsgraph *>(depsgraph), id_type);
}
}
@@ -788,13 +778,8 @@ void DEG_graph_on_visible_update(Main *bmain, Depsgraph *depsgraph, const bool d
void DEG_on_visible_update(Main *bmain, const bool do_time)
{
- LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
- LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
- Depsgraph *depsgraph = (Depsgraph *)BKE_scene_get_depsgraph(scene, view_layer, false);
- if (depsgraph != NULL) {
- DEG_graph_on_visible_update(bmain, depsgraph, do_time);
- }
- }
+ for (DEG::Depsgraph *depsgraph : DEG::get_all_registered_graphs(bmain)) {
+ DEG_graph_on_visible_update(bmain, reinterpret_cast<::Depsgraph *>(depsgraph), do_time);
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index f75bff6a914..261b7f00e42 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -561,7 +561,7 @@ wmJob *EEVEE_lightbake_job_create(struct wmWindowManager *wm,
/* 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->depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER);
lbake->mutex = BLI_mutex_alloc();
@@ -612,7 +612,7 @@ void *EEVEE_lightbake_job_data_alloc(struct Main *bmain,
EEVEE_LightBake *lbake = MEM_callocN(sizeof(EEVEE_LightBake), "EEVEE_LightBake");
- lbake->depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
+ lbake->depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER);
lbake->scene = scene;
lbake->bmain = bmain;
lbake->view_layer_input = view_layer;
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index 1ff14f83231..726082c0f02 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -82,6 +82,8 @@ extern char datatoc_volumetric_integration_frag_glsl[];
extern char datatoc_volumetric_lib_glsl[];
extern char datatoc_common_fullscreen_vert_glsl[];
+#define USE_VOLUME_OPTI (GLEW_ARB_shader_image_load_store && GLEW_ARB_shading_language_420pack)
+
static void eevee_create_shader_volumes(void)
{
e_data.volumetric_common_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
@@ -123,7 +125,10 @@ static void eevee_create_shader_volumes(void)
datatoc_volumetric_geom_glsl,
datatoc_volumetric_integration_frag_glsl,
e_data.volumetric_common_lib,
- NULL);
+ USE_VOLUME_OPTI ? "#extension GL_ARB_shader_image_load_store: enable\n"
+ "#extension GL_ARB_shading_language_420pack: enable\n"
+ "#define USE_VOLUME_OPTI\n" :
+ NULL);
e_data.volumetric_resolve_sh = DRW_shader_create_with_lib(datatoc_common_fullscreen_vert_glsl,
NULL,
datatoc_volumetric_resolve_frag_glsl,
@@ -509,7 +514,8 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_shgroup_uniform_texture_ref(grp, "volumeExtinction", &txl->volume_transmit);
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
- DRW_shgroup_call_procedural_triangles(grp, NULL, common_data->vol_tex_size[2]);
+ DRW_shgroup_call_procedural_triangles(
+ grp, NULL, USE_VOLUME_OPTI ? 1 : common_data->vol_tex_size[2]);
DRW_PASS_CREATE(psl->volumetric_resolve_ps, DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM);
grp = DRW_shgroup_create(e_data.volumetric_resolve_sh, psl->volumetric_resolve_ps);
@@ -621,9 +627,31 @@ void EEVEE_volumes_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
GPU_framebuffer_bind(fbl->volumetric_scat_fb);
DRW_draw_pass(psl->volumetric_scatter_ps);
- GPU_framebuffer_bind(fbl->volumetric_integ_fb);
+ if (USE_VOLUME_OPTI) {
+ int tex_scatter = GPU_texture_opengl_bindcode(txl->volume_scatter_history);
+ int tex_transmit = GPU_texture_opengl_bindcode(txl->volume_transmit_history);
+ /* TODO(fclem) Encapsulate these GL calls into DRWManager. */
+ glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
+ /* Subtility here! we need to tell the GL that the texture is layered (GL_TRUE)
+ * in order to bind the full 3D texture and not just a 2D slice. */
+ glBindImageTexture(0, tex_scatter, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F);
+ glBindImageTexture(1, tex_transmit, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F);
+
+ GPU_framebuffer_bind(fbl->volumetric_fb);
+ }
+ else {
+ GPU_framebuffer_bind(fbl->volumetric_integ_fb);
+ }
+
DRW_draw_pass(psl->volumetric_integration_ps);
+ if (USE_VOLUME_OPTI) {
+ glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
+
+ glBindImageTexture(0, 0, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F);
+ glBindImageTexture(1, 0, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F);
+ }
+
SWAP(struct GPUFrameBuffer *, fbl->volumetric_scat_fb, fbl->volumetric_integ_fb);
SWAP(GPUTexture *, txl->volume_scatter, txl->volume_scatter_history);
SWAP(GPUTexture *, txl->volume_transmit, txl->volume_transmit_history);
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl
index 1ae6a258d3d..c3c442e7b69 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl
@@ -8,10 +8,17 @@
uniform sampler3D volumeScattering; /* Result of the scatter step */
uniform sampler3D volumeExtinction;
+#ifdef USE_VOLUME_OPTI
+uniform layout(binding = 0, r11f_g11f_b10f) writeonly restrict image3D finalScattering_img;
+uniform layout(binding = 1, r11f_g11f_b10f) writeonly restrict image3D finalTransmittance_img;
+vec3 finalScattering;
+vec3 finalTransmittance;
+#else
flat in int slice;
layout(location = 0) out vec3 finalScattering;
layout(location = 1) out vec3 finalTransmittance;
+#endif
void main()
{
@@ -36,10 +43,11 @@ void main()
orig_ray_len = prev_ray_len / view_cell.z;
}
- /* Without compute shader and arbitrary write we need to
- * accumulate from the beginning of the ray for each cell. */
- float integration_end = float(slice);
- for (int i = 0; i < slice; i++) {
+#ifdef USE_VOLUME_OPTI
+ int slice = textureSize(volumeScattering, 0).z;
+ ivec2 texco = ivec2(gl_FragCoord.xy);
+#endif
+ for (int i = 0; i <= slice; i++) {
ivec3 volume_cell = ivec3(gl_FragCoord.xy, i);
vec3 Lscat = texelFetch(volumeScattering, volume_cell, 0).rgb;
@@ -63,5 +71,11 @@ void main()
finalScattering += finalTransmittance * Lscat;
finalTransmittance *= Tr;
+
+#ifdef USE_VOLUME_OPTI
+ ivec3 coord = ivec3(texco, i);
+ imageStore(finalScattering_img, coord, vec4(finalScattering, 0.0));
+ imageStore(finalTransmittance_img, coord, vec4(finalTransmittance, 0.0));
+#endif
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index d49cc728551..882f2285296 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1922,6 +1922,7 @@ void gpencil_populate_multiedit(GPENCIL_e_data *e_data,
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
int cfra_eval = (int)DEG_get_ctime(draw_ctx->depsgraph);
GpencilBatchCache *cache = gpencil_batch_cache_get(ob, cfra_eval);
@@ -1937,39 +1938,23 @@ void gpencil_populate_multiedit(GPENCIL_e_data *e_data,
if (gpl->flag & GP_LAYER_HIDE) {
continue;
}
+ const float alpha = GPENCIL_SIMPLIFY_TINT(scene, playing) ? 0.0f : gpl->tintcolor[3];
+ const float tintcolor[4] = {gpl->tintcolor[0], gpl->tintcolor[1], gpl->tintcolor[2], alpha};
/* list of frames to draw */
if (!playing) {
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || (gpf->flag & GP_FRAME_SELECT)) {
- gpencil_draw_strokes(cache,
- e_data,
- vedata,
- ob,
- gpd,
- gpl,
- gpf,
- gpl->opacity,
- gpl->tintcolor,
- false,
- cache_ob);
+ gpencil_draw_strokes(
+ cache, e_data, vedata, ob, gpd, gpl, gpf, gpl->opacity, tintcolor, false, cache_ob);
}
}
}
else {
gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
if (gpf) {
- gpencil_draw_strokes(cache,
- e_data,
- vedata,
- ob,
- gpd,
- gpl,
- gpf,
- gpl->opacity,
- gpl->tintcolor,
- false,
- cache_ob);
+ gpencil_draw_strokes(
+ cache, e_data, vedata, ob, gpd, gpl, gpf, gpl->opacity, tintcolor, false, cache_ob);
}
}
}
@@ -2091,8 +2076,10 @@ void gpencil_populate_datablock(GPENCIL_e_data *e_data,
}
}
/* draw normal strokes */
+ const float alpha = GPENCIL_SIMPLIFY_TINT(scene, playing) ? 0.0f : gpl->tintcolor[3];
+ const float tintcolor[4] = {gpl->tintcolor[0], gpl->tintcolor[1], gpl->tintcolor[2], alpha};
gpencil_draw_strokes(
- cache, e_data, vedata, ob, gpd, gpl, gpf_eval, opacity, gpl->tintcolor, false, cache_ob);
+ cache, e_data, vedata, ob, gpd, gpl, gpf_eval, opacity, tintcolor, false, cache_ob);
}
/* create batchs and shading groups */
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 3afdd77b6a7..ed78f7d07f9 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -1551,6 +1551,9 @@ static void ensure_edit_inner_points_count(const PTCacheEdit *edit, ParticleBatc
cache->edit_inner_point_len = 0;
for (int point_index = 0; point_index < edit->totpoint; point_index++) {
const PTCacheEditPoint *point = &edit->points[point_index];
+ if (point->flag & PEP_HIDE) {
+ continue;
+ }
BLI_assert(point->totkey >= 1);
cache->edit_inner_point_len += (point->totkey - 1);
}
@@ -1572,6 +1575,9 @@ static void particle_batch_cache_ensure_edit_inner_pos(PTCacheEdit *edit,
int global_key_index = 0;
for (int point_index = 0; point_index < edit->totpoint; point_index++) {
const PTCacheEditPoint *point = &edit->points[point_index];
+ if (point->flag & PEP_HIDE) {
+ continue;
+ }
for (int key_index = 0; key_index < point->totkey - 1; key_index++) {
PTCacheEditKey *key = &point->keys[key_index];
float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
@@ -1602,7 +1608,14 @@ static void ensure_edit_tip_points_count(const PTCacheEdit *edit, ParticleBatchC
if (cache->edit_tip_pos != NULL) {
return;
}
- cache->edit_tip_point_len = edit->totpoint;
+ cache->edit_tip_point_len = 0;
+ for (int point_index = 0; point_index < edit->totpoint; point_index++) {
+ const PTCacheEditPoint *point = &edit->points[point_index];
+ if (point->flag & PEP_HIDE) {
+ continue;
+ }
+ cache->edit_tip_point_len += 1;
+ }
}
static void particle_batch_cache_ensure_edit_tip_pos(PTCacheEdit *edit, ParticleBatchCache *cache)
@@ -1617,13 +1630,18 @@ static void particle_batch_cache_ensure_edit_tip_pos(PTCacheEdit *edit, Particle
cache->edit_tip_pos = GPU_vertbuf_create_with_format(edit_point_format);
GPU_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len);
+ int global_point_index = 0;
for (int point_index = 0; point_index < edit->totpoint; point_index++) {
const PTCacheEditPoint *point = &edit->points[point_index];
+ if (point->flag & PEP_HIDE) {
+ continue;
+ }
PTCacheEditKey *key = &point->keys[point->totkey - 1];
float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
- GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co);
- GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, &color);
+ GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, global_point_index, key->world_co);
+ GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, global_point_index, &color);
+ global_point_index++;
}
}
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 73981e62ada..4279ec4baf8 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1026,7 +1026,7 @@ void DRW_cache_free_old_batches(Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
if (depsgraph == NULL) {
continue;
}
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 663624aa050..37b271e4778 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -3687,11 +3687,13 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
}
/* Helpers for when we're transforming origins. */
- if (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) {
- if (ob->base_flag & BASE_SELECTED) {
- const float color[4] = {0.75, 0.75, 0.75, 0.5};
- float axes_size = 1.0f;
- DRW_buffer_add_entry(sgl->origin_xform, color, &axes_size, ob->obmat);
+ if (draw_ctx->object_mode == OB_MODE_OBJECT) {
+ if (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) {
+ if (ob->base_flag & BASE_SELECTED) {
+ const float color[4] = {0.75, 0.75, 0.75, 0.5};
+ float axes_size = 1.0f;
+ DRW_buffer_add_entry(sgl->origin_xform, color, &axes_size, ob->obmat);
+ }
}
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index d5c701488c9..0a4b068a926 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1235,6 +1235,13 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
reduce += 0.25f; /* reduce the factor */
}
}
+
+ /* Simplify adaptive */
+ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) &&
+ (brush->gpencil_settings->simplify_f > 0.0f)) {
+ BKE_gpencil_simplify_stroke(gps, brush->gpencil_settings->simplify_f);
+ }
+
/* smooth thickness */
if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) &&
(brush->gpencil_settings->thick_smoothfac > 0.0f)) {
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index d7492b5be4d..3ee7aed0a02 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -46,6 +46,7 @@
#include "BKE_action.h"
#include "BKE_colortools.h"
+#include "BKE_collection.h"
#include "BKE_deform.h"
#include "BKE_main.h"
#include "BKE_brush.h"
@@ -57,6 +58,7 @@
#include "BKE_tracking.h"
#include "WM_api.h"
+#include "WM_types.h"
#include "WM_toolsystem.h"
#include "RNA_access.h"
@@ -2559,3 +2561,24 @@ tGPspoint *ED_gpencil_sbuffer_ensure(tGPspoint *buffer_array,
return buffer_array;
}
+
+/* Tag all scene grease pencil object to update. */
+void ED_gpencil_tag_scene_gpencil(Scene *scene)
+{
+ /* mark all grease pencil datablocks of the scene */
+ FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) {
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (collection, ob) {
+ if (ob->type == OB_GPENCIL) {
+ bGPdata *gpd = (bGPdata *)ob->data;
+ gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ }
+ }
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
+ }
+ FOREACH_SCENE_COLLECTION_END;
+
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+
+ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+}
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 470eb58c72b..63ddc669ab2 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -288,4 +288,7 @@ struct tGPspoint *ED_gpencil_sbuffer_ensure(struct tGPspoint *buffer_array,
short *buffer_size,
short *buffer_used,
const bool clear);
+/* Tag all scene grease pencil object to update. */
+void ED_gpencil_tag_scene_gpencil(struct Scene *scene);
+
#endif /* __ED_GPENCIL_H__ */
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index d907ba4e581..0273c8c73ab 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -39,6 +39,11 @@ bool ED_sculpt_mask_box_select(struct bContext *C,
const struct rcti *rect,
bool select);
+/* transform */
+void ED_sculpt_update_modal_transform(struct bContext *C);
+void ED_sculpt_init_transform(struct bContext *C);
+void ED_sculpt_end_transform(struct bContext *C);
+
/* sculpt_undo.c */
void ED_sculpt_undosys_type(struct UndoType *ut);
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index d8b65aa5975..8c70fc9a157 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -94,6 +94,7 @@ enum TfmMode {
#define CTX_OBMODE_XFORM_OBDATA (1 << 11)
/** Transform object parents without moving their children. */
#define CTX_OBMODE_XFORM_SKIP_CHILDREN (1 << 12)
+#define CTX_SCULPT (1 << 13)
/* Standalone call to get the transformation center corresponding to the current situation
* returns 1 if successful, 0 otherwise (usually means there's no selection)
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 29892657086..dd052a8256b 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -42,6 +42,9 @@
#ifndef DEF_ICON_SHADING
# define DEF_ICON_SHADING DEF_ICON
#endif
+#ifndef DEF_ICON_FOLDER
+# define DEF_ICON_FOLDER DEF_ICON
+#endif
#ifndef DEF_ICON_COLOR
# define DEF_ICON_COLOR DEF_ICON
#endif
@@ -793,7 +796,7 @@ DEF_ICON(NEWFOLDER)
DEF_ICON_BLANK(794)
DEF_ICON(FILE_PARENT)
DEF_ICON(FILE_REFRESH)
-DEF_ICON(FILE_FOLDER)
+DEF_ICON_FOLDER(FILE_FOLDER)
DEF_ICON(FILE_BLANK)
DEF_ICON(FILE_BLEND)
DEF_ICON(FILE_IMAGE)
@@ -1034,6 +1037,7 @@ DEF_ICON_COLOR(EVENT_RETURN)
#undef DEF_ICON_OBJECT_DATA
#undef DEF_ICON_MODIFIER
#undef DEF_ICON_SHADING
+#undef DEF_ICON_FOLDER
#undef DEF_ICON_VECTOR
#undef DEF_ICON_COLOR
#undef DEF_ICON_FUND
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index a73e2655b7d..efa35c84b9e 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -273,6 +273,7 @@ typedef enum ThemeColorID {
TH_ICON_OBJECT_DATA,
TH_ICON_MODIFIER,
TH_ICON_SHADING,
+ TH_ICON_FOLDER,
TH_ICON_FUND,
TH_SCROLL_TEXT,
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 7ada4755a64..085ae5bdb93 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -169,6 +169,7 @@ static const IconType icontypes[] = {
# define DEF_ICON_OBJECT_DATA(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_OBJECT_DATA},
# define DEF_ICON_MODIFIER(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_MODIFIER},
# define DEF_ICON_SHADING(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_SHADING},
+# define DEF_ICON_FOLDER(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_FOLDER},
# define DEF_ICON_FUND(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_FUND},
# define DEF_ICON_VECTOR(name) {ICON_TYPE_VECTOR, 0},
# define DEF_ICON_COLOR(name) {ICON_TYPE_COLOR_TEXTURE, 0},
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 93a93fb6918..bea9af99c2e 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -905,6 +905,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
case TH_ICON_SHADING:
cp = btheme->tui.icon_shading;
break;
+ case TH_ICON_FOLDER:
+ cp = btheme->tui.icon_folder;
+ break;
case TH_ICON_FUND: {
/* Development fund icon color is not part of theme. */
static const uchar red[4] = {204, 48, 72, 255};
@@ -1391,8 +1394,9 @@ bool UI_GetIconThemeColor4ubv(int colorid, uchar col[4])
/* Always color development fund icon. */
}
else if (!((theme_spacetype == SPACE_OUTLINER && theme_regionid == RGN_TYPE_WINDOW) ||
- (theme_spacetype == SPACE_PROPERTIES && theme_regionid == RGN_TYPE_NAV_BAR))) {
- /* Only colored icons in outliner and popups, overall UI is intended
+ (theme_spacetype == SPACE_PROPERTIES && theme_regionid == RGN_TYPE_NAV_BAR) ||
+ (theme_spacetype == SPACE_FILE && theme_regionid == RGN_TYPE_WINDOW))) {
+ /* Only colored icons in specific places, overall UI is intended
* to stay monochrome and out of the way except a few places where it
* is important to communicate different data types. */
return false;
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index d7d020ae19d..88da40b947f 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -55,6 +55,7 @@ set(SRC
editmesh_knife.c
editmesh_knife_project.c
editmesh_loopcut.c
+ editmesh_mask_extract.c
editmesh_path.c
editmesh_polybuild.c
editmesh_preselect_edgering.c
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index 5b16cfd00f5..c1c8a208471 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -145,10 +145,10 @@ static bool edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const ch
}
/* extrudes individual edges */
-static bool edbm_extrude_edges_indiv(BMEditMesh *em,
- wmOperator *op,
- const char hflag,
- const bool use_normal_flip)
+bool edbm_extrude_edges_indiv(BMEditMesh *em,
+ wmOperator *op,
+ const char hflag,
+ const bool use_normal_flip)
{
BMesh *bm = em->bm;
BMOperator bmop;
diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c
new file mode 100644
index 00000000000..6d51e1d3393
--- /dev/null
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -0,0 +1,272 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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) 2019 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edmesh
+ */
+
+#include "DNA_mesh_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_math.h"
+
+#include "BKE_context.h"
+#include "BKE_editmesh.h"
+#include "BKE_layer.h"
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
+#include "BKE_paint.h"
+#include "BKE_report.h"
+#include "BKE_shrinkwrap.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
+#include "RNA_define.h"
+#include "RNA_access.h"
+
+#include "WM_types.h"
+#include "WM_api.h"
+
+#include "ED_mesh.h"
+#include "ED_screen.h"
+#include "ED_object.h"
+#include "ED_sculpt.h"
+#include "ED_view3d.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "mesh_intern.h" /* own include */
+
+static bool paint_mask_extract_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ if (ob->mode == OB_MODE_SCULPT) {
+ if (ob->sculpt->bm) {
+ CTX_wm_operator_poll_msg_set(C, "The mask can not be extracted with dyntopo activated.");
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+ return ED_operator_object_active_editable_mesh(C);
+}
+
+static int paint_mask_extract_exec(bContext *C, wmOperator *op)
+{
+ struct Main *bmain = CTX_data_main(C);
+ Object *ob = CTX_data_active_object(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
+
+ Mesh *mesh = ob->data;
+ Mesh *new_mesh = BKE_mesh_copy(bmain, mesh);
+
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh);
+ BMesh *bm;
+ bm = BM_mesh_create(&allocsize,
+ &((struct BMeshCreateParams){
+ .use_toolflags = true,
+ }));
+
+ BM_mesh_bm_from_me(bm,
+ new_mesh,
+ (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ }));
+
+ BMEditMesh *em = BKE_editmesh_create(bm, false);
+ BMVert *v;
+ BMEdge *ed;
+ BMFace *f;
+ BMIter iter;
+ BMIter face_iter;
+
+ /* Delete all unmasked faces */
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
+
+ float mask_threshold = RNA_float_get(op->ptr, "mask_threshold");
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ bool delete_face = false;
+ BM_ITER_ELEM (v, &face_iter, f, BM_VERTS_OF_FACE) {
+ float mask = BM_elem_float_data_get(&bm->vdata, v, CD_PAINT_MASK);
+ delete_face = mask < mask_threshold;
+ }
+ BM_elem_flag_set(f, BM_ELEM_TAG, delete_face);
+ }
+
+ BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_FACES);
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
+
+ if (RNA_boolean_get(op->ptr, "add_boundary_loop")) {
+ BM_ITER_MESH (ed, &iter, bm, BM_EDGES_OF_MESH) {
+ BM_elem_flag_set(ed, BM_ELEM_TAG, BM_edge_is_boundary(ed));
+ }
+ edbm_extrude_edges_indiv(em, op, BM_ELEM_TAG, false);
+
+ int smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations");
+ for (int repeat = 0; repeat < smooth_iterations; repeat++) {
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_elem_flag_set(v, BM_ELEM_TAG, !BM_vert_is_boundary(v));
+ }
+ for (int i = 0; i < 3; i++) {
+ if (!EDBM_op_callf(em,
+ op,
+ "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b "
+ "mirror_clip_z=%b "
+ "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b",
+ BM_ELEM_TAG,
+ 1.0,
+ false,
+ false,
+ false,
+ 0.1,
+ true,
+ true,
+ true)) {
+ continue;
+ }
+ }
+
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_elem_flag_set(v, BM_ELEM_TAG, BM_vert_is_boundary(v));
+ }
+ for (int i = 0; i < 1; i++) {
+ if (!EDBM_op_callf(em,
+ op,
+ "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b "
+ "mirror_clip_z=%b "
+ "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b",
+ BM_ELEM_TAG,
+ 0.5,
+ false,
+ false,
+ false,
+ 0.1,
+ true,
+ true,
+ true)) {
+ continue;
+ }
+ }
+ }
+ }
+
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
+ BKE_editmesh_free_derivedmesh(em);
+
+ BKE_mesh_free(new_mesh);
+ new_mesh = BKE_mesh_from_bmesh_nomain(bm,
+ (&(struct BMeshToMeshParams){
+ .calc_object_remap = false,
+ }));
+
+ BM_mesh_free(bm);
+
+ if (new_mesh->totvert == 0) {
+ BKE_mesh_free(new_mesh);
+ return OPERATOR_FINISHED;
+ }
+
+ ushort local_view_bits = 0;
+ if (v3d && v3d->localvd) {
+ local_view_bits = v3d->local_view_uuid;
+ }
+ Object *new_ob = ED_object_add_type(C, OB_MESH, NULL, ob->loc, ob->rot, false, local_view_bits);
+ BKE_mesh_nomain_to_mesh(new_mesh, new_ob->data, new_ob, &CD_MASK_EVERYTHING, true);
+
+ BKE_mesh_free(new_mesh);
+
+ if (RNA_boolean_get(op->ptr, "apply_shrinkwrap")) {
+ BKE_shrinkwrap_mesh_nearest_surface_deform(C, new_ob, ob);
+ }
+
+ if (RNA_boolean_get(op->ptr, "add_solidify")) {
+ ED_object_modifier_add(
+ op->reports, bmain, scene, new_ob, "mask_extract_solidify", eModifierType_Solidify);
+ SolidifyModifierData *sfmd = (SolidifyModifierData *)modifiers_findByName(
+ new_ob, "mask_extract_solidify");
+ if (sfmd) {
+ sfmd->offset = -0.05f;
+ }
+ }
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, new_ob);
+ BKE_mesh_batch_cache_dirty_tag(new_ob->data, BKE_MESH_BATCH_DIRTY_ALL);
+ DEG_relations_tag_update(bmain);
+ DEG_id_tag_update(&new_ob->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, new_ob->data);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_paint_mask_extract(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Mask Extract";
+ ot->description = "Create a new mesh object from the current paint mask";
+ ot->idname = "MESH_OT_paint_mask_extract";
+
+ /* api callbacks */
+ ot->poll = paint_mask_extract_poll;
+ ot->invoke = WM_operator_props_popup_confirm;
+ ot->exec = paint_mask_extract_exec;
+
+ ot->flag = OPTYPE_REGISTER;
+
+ RNA_def_float(
+ ot->srna,
+ "mask_threshold",
+ 0.5f,
+ 0.0f,
+ 1.0f,
+ "Threshold",
+ "Minimum mask value to consider the vertex valid to extract a face from the original mesh",
+ 0.0f,
+ 1.0f);
+ RNA_def_boolean(ot->srna,
+ "add_boundary_loop",
+ true,
+ "Add Boundary Loop",
+ "Add an extra edge loop to better preserve the shape when applying a "
+ "subdivision surface modifier");
+ RNA_def_int(ot->srna,
+ "smooth_iterations",
+ 4,
+ 0,
+ INT_MAX,
+ "Smooth Iterations",
+ "Smooth iterations applied to the extracted mesh",
+ 0,
+ 20);
+ RNA_def_boolean(ot->srna,
+ "apply_shrinkwrap",
+ true,
+ "Project to Sculpt",
+ "Project the extracted mesh into the original sculpt");
+ RNA_def_boolean(ot->srna,
+ "add_solidify",
+ true,
+ "Extract as Solid",
+ "Extract the mask as a solid object with a solidify modifier");
+}
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index 3558a07c6fb..bab5e35df53 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -79,6 +79,11 @@ struct BMElem *EDBM_elem_from_selectmode(struct BMEditMesh *em,
int EDBM_elem_to_index_any(struct BMEditMesh *em, struct BMElem *ele);
struct BMElem *EDBM_elem_from_index_any(struct BMEditMesh *em, int index);
+bool edbm_extrude_edges_indiv(struct BMEditMesh *em,
+ struct wmOperator *op,
+ const char hflag,
+ const bool use_normal_flip);
+
/* *** editmesh_add.c *** */
void MESH_OT_primitive_plane_add(struct wmOperatorType *ot);
void MESH_OT_primitive_cube_add(struct wmOperatorType *ot);
@@ -246,6 +251,9 @@ void MESH_OT_average_normals(struct wmOperatorType *ot);
void MESH_OT_smoothen_normals(struct wmOperatorType *ot);
void MESH_OT_mod_weighted_strength(struct wmOperatorType *ot);
+/* *** editmesh_mask_extract.c *** */
+void MESH_OT_paint_mask_extract(struct wmOperatorType *ot);
+
struct wmKeyMap *point_normals_modal_keymap(wmKeyConfig *keyconf);
void MESH_OT_mark_lanpr_edge(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 9b6e991a9f5..fc1c91dbeef 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -191,6 +191,8 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_symmetrize);
WM_operatortype_append(MESH_OT_symmetry_snap);
+ WM_operatortype_append(MESH_OT_paint_mask_extract);
+
WM_operatortype_append(MESH_OT_point_normals);
WM_operatortype_append(MESH_OT_merge_normals);
WM_operatortype_append(MESH_OT_split_normals);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 410ccccbd0d..d9baec7c3ca 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -745,7 +745,7 @@ static int bake(Render *re,
{
/* We build a depsgraph for the baking,
* so we don't need to change the original data to adjust visibility and modifiers. */
- Depsgraph *depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
+ Depsgraph *depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER);
DEG_graph_build_from_view_layer(depsgraph, bmain, scene, view_layer);
int op_result = OPERATOR_CANCELLED;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 0807468fbaf..7a781999dfc 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -1377,7 +1377,7 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit)
BLI_task_parallel_range(0, edit->totpoint, &iter_data, iterate_lengths_iter, &settings);
}
-/* set current distances to be kept between neighbouting keys */
+/* set current distances to be kept between neighboring keys */
void recalc_lengths(PTCacheEdit *edit)
{
POINT_P;
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 3254b8d9f8a..67b7502d426 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -199,7 +199,7 @@ void ED_render_engine_changed(Main *bmain)
update_ctx.scene = scene;
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
/* TDODO(sergey): Iterate over depsgraphs instead? */
- update_ctx.depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ update_ctx.depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
update_ctx.view_layer = view_layer;
ED_render_id_flush_update(&update_ctx, &scene->id);
}
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index b04719d7782..84d6610242a 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -121,7 +121,7 @@ bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene)
/* Depsgraph updates after scene becomes active in a window. */
void ED_scene_change_update(Main *bmain, Scene *scene, ViewLayer *layer)
{
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, layer, true);
BKE_scene_set_background(bmain, scene);
DEG_graph_relations_update(depsgraph, bmain, scene, layer);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 50e5597ac0c..f29535a7f0b 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -4359,7 +4359,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
Scene *scene_eval = (depsgraph != NULL) ? DEG_get_evaluated_scene(depsgraph) : NULL;
wmTimer *wt = screen->animtimer;
ScreenAnimData *sad = wt->customdata;
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index a000da57383..9464bdb901e 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1180,6 +1180,20 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr,
}
}
+static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession *ss)
+{
+ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.6f);
+ GPU_depth_test(true);
+ GPU_line_width(1.0f);
+ if (ss->preview_vert_index_count > 0) {
+ immBegin(GPU_PRIM_LINES, ss->preview_vert_index_count);
+ for (int i = 0; i < ss->preview_vert_index_count; i++) {
+ immVertex3fv(gpuattr, sculpt_vertex_co_get(ss, ss->preview_vert_index_list[i]));
+ }
+ immEnd();
+ }
+}
+
static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
{
Scene *scene = CTX_data_scene(C);
@@ -1348,6 +1362,17 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
imm_draw_circle_wire_3d(pos, 0, 0, rds, 40);
GPU_matrix_pop();
+ /* Update and draw dynamic mesh preview lines */
+ GPU_matrix_push();
+ GPU_matrix_mul(vc.obact->obmat);
+ if (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) {
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && ss->modifiers_active) {
+ sculpt_geometry_preview_lines_update(C, ss, rds);
+ sculpt_geometry_preview_lines_draw(pos, ss);
+ }
+ }
+ GPU_matrix_pop();
+
GPU_matrix_pop_projection();
wmWindowViewport(win);
@@ -1370,6 +1395,27 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
add_v3_v3(cursor_location, ss->cache->grab_delta);
}
cursor_draw_point_with_symmetry(pos, ar, cursor_location, sd, vc.obact, ss->cache->radius);
+
+ /* Draw cached dynamic mesh preview lines */
+ if (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) {
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && ss->modifiers_active) {
+ GPU_matrix_push_projection();
+ ED_view3d_draw_setup_view(CTX_wm_window(C),
+ CTX_data_depsgraph_pointer(C),
+ CTX_data_scene(C),
+ ar,
+ CTX_wm_view3d(C),
+ NULL,
+ NULL,
+ NULL);
+ GPU_matrix_push();
+ GPU_matrix_mul(vc.obact->obmat);
+ sculpt_geometry_preview_lines_draw(pos, ss);
+ GPU_matrix_pop();
+ GPU_matrix_pop_projection();
+ }
+ }
+
wmWindowViewport(win);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index e511a19b341..ab557dc59b5 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -30,8 +30,8 @@
#include "BLI_hash.h"
#include "BLI_gsqueue.h"
#include "BLI_stack.h"
-#include "BLI_gsqueue.h"
#include "BLI_task.h"
+#include "BLI_stack.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
@@ -100,7 +100,7 @@
/* Do not use these functions while working with PBVH_GRIDS data in SculptSession */
-static float *sculpt_vertex_co_get(SculptSession *ss, int index)
+float *sculpt_vertex_co_get(SculptSession *ss, int index)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
@@ -1142,6 +1142,7 @@ static bool sculpt_automasking_is_constrained_by_radius(Brush *br)
typedef struct VertexTopologyIterator {
int v;
int it;
+ float edge_factor;
} VertexTopologyIterator;
static float *sculpt_topology_automasking_init(Sculpt *sd, Object *ob, float *automask_factor)
@@ -3344,7 +3345,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
radius_scaled[2] = radius_scaled[1] * radius_e[2];
float shear_modulus = 1.0f;
- float poisson_ratio = brush->elastic_deform_compressibility;
+ float poisson_ratio = brush->elastic_deform_volume_preservation;
float a = 1.0f / (4.0f * (float)M_PI * shear_modulus);
float b = a / (4.0f * (1.0f - poisson_ratio));
@@ -3520,6 +3521,10 @@ static void do_pose_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
float pose_initial_co[3];
float transform_rot[4][4], transform_trans[4][4], transform_trans_inv[4][4];
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ return;
+ }
+
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
copy_v3_v3(pose_origin, ss->cache->pose_origin);
@@ -5071,7 +5076,9 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
if (brush->sculpt_tool == SCULPT_TOOL_POSE && ss->cache->first_time &&
ss->cache->mirror_symmetry_pass == 0) {
- sculpt_pose_brush_init(sd, ob, ss, brush);
+ if (BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS) {
+ sculpt_pose_brush_init(sd, ob, ss, brush);
+ }
}
/* Apply one type of brush action */
@@ -5902,7 +5909,13 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
float grab_location[3], imat[4][4], delta[3], loc[3];
if (cache->first_time) {
- copy_v3_v3(cache->orig_grab_location, cache->true_location);
+ if (tool == SCULPT_TOOL_GRAB && brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) {
+ copy_v3_v3(cache->orig_grab_location,
+ sculpt_vertex_co_get(ss, sculpt_active_vertex_get(ss)));
+ }
+ else {
+ copy_v3_v3(cache->orig_grab_location, cache->true_location);
+ }
}
else if (tool == SCULPT_TOOL_SNAKE_HOOK) {
add_v3_v3(cache->true_location, cache->grab_delta);
@@ -5955,6 +5968,14 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
copy_v3_v3(cache->old_grab_location, grab_location);
if (tool == SCULPT_TOOL_GRAB) {
+ if (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) {
+ copy_v3_v3(cache->anchored_location, cache->orig_grab_location);
+ }
+ else {
+ copy_v3_v3(cache->anchored_location, cache->true_location);
+ }
+ }
+ else if (tool == SCULPT_TOOL_ELASTIC_DEFORM) {
copy_v3_v3(cache->anchored_location, cache->true_location);
}
else if (tool == SCULPT_TOOL_ELASTIC_DEFORM) {
@@ -7932,6 +7953,12 @@ static void sculpt_filter_cache_free(SculptSession *ss)
if (ss->filter_cache->mask_update_it) {
MEM_freeN(ss->filter_cache->mask_update_it);
}
+ if (ss->filter_cache->prev_mask) {
+ MEM_freeN(ss->filter_cache->prev_mask);
+ }
+ if (ss->filter_cache->normal_factor) {
+ MEM_freeN(ss->filter_cache->normal_factor);
+ }
MEM_freeN(ss->filter_cache);
ss->filter_cache = NULL;
}
@@ -8118,6 +8145,10 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
SculptSession *ss = ob->sculpt;
PBVH *pbvh = ob->sculpt->pbvh;
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ return OPERATOR_CANCELLED;
+ }
+
int deform_axis = RNA_enum_get(op->ptr, "deform_axis");
if (deform_axis == 0) {
return OPERATOR_CANCELLED;
@@ -8321,6 +8352,10 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
int totnode;
int filter_type = RNA_enum_get(op->ptr, "filter_type");
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ return OPERATOR_CANCELLED;
+ }
+
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
sculpt_vertex_random_access_init(ss);
@@ -8483,6 +8518,10 @@ static int sculpt_dirty_mask_exec(bContext *C, wmOperator *op)
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
int totnode;
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ return OPERATOR_CANCELLED;
+ }
+
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
sculpt_vertex_random_access_init(ss);
@@ -8581,6 +8620,852 @@ static void SCULPT_OT_dirty_mask(struct wmOperatorType *ot)
ot->srna, "dirty_only", false, "Dirty Only", "Don't calculate cleans for convex areas");
}
+static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op)
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+
+ MEM_freeN(op->customdata);
+
+ int vert_count = sculpt_vertex_count_get(ss);
+ for (int i = 0; i < vert_count; i++) {
+ sculpt_vertex_mask_set(ss, i, ss->filter_cache->prev_mask[i]);
+ }
+
+ for (int i = 0; i < ss->filter_cache->totnode; i++) {
+ BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
+ }
+
+ sculpt_flush_update_step(C);
+ sculpt_filter_cache_free(ss);
+ sculpt_undo_push_end();
+ sculpt_flush_update_done(C, ob);
+ ED_workspace_status_text(C, NULL);
+}
+
+static void sculpt_expand_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+ PBVHVertexIter vd;
+ int update_it = data->mask_expand_update_it;
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL)
+ {
+ int vi = vd.index;
+ float final_mask = *vd.mask;
+ if (data->mask_expand_use_normals) {
+ if (ss->filter_cache->normal_factor[sculpt_active_vertex_get(ss)] <
+ ss->filter_cache->normal_factor[vd.index]) {
+ final_mask = 1.0f;
+ }
+ else {
+ final_mask = 0.0f;
+ }
+ }
+ else {
+ if (ss->filter_cache->mask_update_it[vi] <= update_it &&
+ ss->filter_cache->mask_update_it[vi] != 0) {
+ final_mask = 1.0f;
+ }
+ else {
+ final_mask = 0.0f;
+ }
+ }
+
+ if (data->mask_expand_keep_prev_mask) {
+ final_mask = MAX2(ss->filter_cache->prev_mask[vd.index], final_mask);
+ }
+
+ if (data->mask_expand_invert_mask) {
+ final_mask = 1.0f - final_mask;
+ }
+
+ if (*vd.mask != final_mask) {
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ *vd.mask = final_mask;
+ BKE_pbvh_node_mark_redraw(node);
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ float prevclick_f[2];
+ copy_v2_v2(prevclick_f, op->customdata);
+ int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]};
+ int len = (int)len_v2v2_int(prevclick, event->mval);
+ len = ABS(len);
+ int mask_speed = RNA_int_get(op->ptr, "mask_speed");
+ int mask_expand_update_it = len / mask_speed;
+ mask_expand_update_it = mask_expand_update_it + 1;
+
+ if (RNA_boolean_get(op->ptr, "use_cursor")) {
+ SculptCursorGeometryInfo sgi;
+ float mouse[2];
+ mouse[0] = event->mval[0];
+ mouse[1] = event->mval[1];
+ sculpt_cursor_geometry_info_update(C, &sgi, mouse, false);
+ mask_expand_update_it = ss->filter_cache->mask_update_it[(int)sculpt_active_vertex_get(ss)];
+ }
+
+ if ((event->type == ESCKEY && event->val == KM_PRESS) ||
+ (event->type == RIGHTMOUSE && event->val == KM_PRESS)) {
+ sculpt_mask_expand_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+
+ if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) ||
+ (event->type == RETKEY && event->val == KM_PRESS) ||
+ (event->type == PADENTER && event->val == KM_PRESS)) {
+
+ /* Smooth iterations */
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ .filter_type = MASK_FILTER_SMOOTH,
+ };
+
+ int smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations");
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false);
+ for (int i = 0; i < smooth_iterations; i++) {
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) &&
+ ss->filter_cache->totnode > SCULPT_THREADED_LIMIT);
+ BLI_task_parallel_range(0, ss->filter_cache->totnode, &data, mask_filter_task_cb, &settings);
+ }
+
+ /* Pivot position */
+ if (RNA_boolean_get(op->ptr, "update_pivot")) {
+ const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ float avg[3];
+ int total = 0;
+ float threshold = 0.2f;
+ zero_v3(avg);
+ int vertex_count = sculpt_vertex_count_get(ss);
+ for (int i = 0; i < vertex_count; i++) {
+ if (sculpt_vertex_mask_get(ss, i) < (0.5f + threshold) &&
+ sculpt_vertex_mask_get(ss, i) > (0.5f - threshold) &&
+ check_vertex_pivot_symmetry(
+ sculpt_vertex_co_get(ss, i), ss->filter_cache->mask_expand_initial_co, symm)) {
+ total++;
+ add_v3_v3(avg, sculpt_vertex_co_get(ss, i));
+ }
+ }
+ if (total > 0) {
+ mul_v3_fl(avg, 1.0f / total);
+ copy_v3_v3(ss->pivot_pos, avg);
+ }
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+ }
+
+ MEM_freeN(op->customdata);
+
+ for (int i = 0; i < ss->filter_cache->totnode; i++) {
+ BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
+ }
+
+ sculpt_filter_cache_free(ss);
+
+ sculpt_undo_push_end();
+ sculpt_flush_update_done(C, ob);
+ ED_workspace_status_text(C, NULL);
+ return OPERATOR_FINISHED;
+ }
+
+ if (event->type != MOUSEMOVE) {
+ return OPERATOR_RUNNING_MODAL;
+ }
+
+ if (mask_expand_update_it == ss->filter_cache->mask_update_current_it) {
+ return OPERATOR_RUNNING_MODAL;
+ }
+
+ if (mask_expand_update_it < ss->filter_cache->mask_update_last_it) {
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ .mask_expand_update_it = mask_expand_update_it,
+ .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"),
+ .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"),
+ .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"),
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) &&
+ ss->filter_cache->totnode > SCULPT_THREADED_LIMIT);
+
+ BLI_task_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings);
+ ss->filter_cache->mask_update_current_it = mask_expand_update_it;
+ }
+
+ sculpt_flush_update_step(C);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ PBVH *pbvh = ob->sculpt->pbvh;
+ float original_normal[3];
+
+ bool use_normals = RNA_boolean_get(op->ptr, "use_normals");
+ int edge_sensitivity = RNA_int_get(op->ptr, "edge_sensitivity");
+
+ SculptCursorGeometryInfo sgi;
+ float mouse[2];
+ mouse[0] = event->mval[0];
+ mouse[1] = event->mval[1];
+
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ return OPERATOR_CANCELLED;
+ }
+
+ sculpt_vertex_random_access_init(ss);
+
+ op->customdata = MEM_mallocN(2 * sizeof(float), "initial mouse position");
+ copy_v2_v2(op->customdata, mouse);
+
+ sculpt_cursor_geometry_info_update(C, &sgi, mouse, false);
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
+
+ int vertex_count = sculpt_vertex_count_get(ss);
+
+ ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache");
+
+ SculptSearchSphereData searchdata = {
+ .ss = ss,
+ .sd = sd,
+ .radius_squared = FLT_MAX,
+ };
+ BKE_pbvh_search_gather(pbvh,
+ sculpt_search_sphere_cb,
+ &searchdata,
+ &ss->filter_cache->nodes,
+ &ss->filter_cache->totnode);
+
+ sculpt_undo_push_begin("Mask Expand");
+
+ for (int i = 0; i < ss->filter_cache->totnode; i++) {
+ sculpt_undo_push_node(ob, ss->filter_cache->nodes[i], SCULPT_UNDO_MASK);
+ BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
+ }
+
+ ss->filter_cache->mask_update_it = MEM_callocN(sizeof(int) * vertex_count,
+ "mask update iteration");
+ if (use_normals) {
+ ss->filter_cache->normal_factor = MEM_callocN(sizeof(float) * vertex_count,
+ "mask update normal factor");
+ }
+
+ ss->filter_cache->prev_mask = MEM_callocN(sizeof(float) * vertex_count, "prev mask");
+ for (int i = 0; i < vertex_count; i++) {
+ ss->filter_cache->prev_mask[i] = sculpt_vertex_mask_get(ss, i);
+ }
+
+ ss->filter_cache->mask_update_last_it = 1;
+ ss->filter_cache->mask_update_current_it = 1;
+ ss->filter_cache->mask_update_it[(int)sculpt_active_vertex_get(ss)] = 1;
+
+ copy_v3_v3(ss->filter_cache->mask_expand_initial_co,
+ sculpt_vertex_co_get(ss, sculpt_active_vertex_get(ss)));
+
+ char *visited_vertices = MEM_callocN(vertex_count * sizeof(char), "visited vertices");
+
+ sculpt_vertex_normal_get(ss, sculpt_active_vertex_get(ss), original_normal);
+
+ GSQueue *queue = BLI_gsqueue_new(sizeof(VertexTopologyIterator));
+ VertexTopologyIterator mevit;
+
+ const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ for (char i = 0; i <= symm; ++i) {
+ if (is_symmetry_iteration_valid(i, symm)) {
+ float location[3];
+ flip_v3_v3(location, sculpt_vertex_co_get(ss, sculpt_active_vertex_get(ss)), i);
+ if (i == 0) {
+ mevit.v = sculpt_active_vertex_get(ss);
+ mevit.edge_factor = 1.0f;
+ }
+ else {
+ mevit.v = sculpt_nearest_vertex_get(sd, ob, location, FLT_MAX, false);
+ mevit.edge_factor = 1.0f;
+ }
+ if (mevit.v != -1) {
+ sculpt_vertex_mask_set(ss, mevit.v, 1.0f);
+ mevit.it = 0;
+ BLI_gsqueue_push(queue, &mevit);
+ }
+ }
+ }
+
+ while (!BLI_gsqueue_is_empty(queue)) {
+ VertexTopologyIterator c_mevit;
+ BLI_gsqueue_pop(queue, &c_mevit);
+ SculptVertexNeighborIter ni;
+ sculpt_vertex_neighbors_iter_begin(ss, c_mevit.v, ni)
+ {
+ if (visited_vertices[(int)ni.index] == 0) {
+ VertexTopologyIterator new_entry;
+ new_entry.v = ni.index;
+ new_entry.it = c_mevit.it + 1;
+ ss->filter_cache->mask_update_it[(int)new_entry.v] = new_entry.it;
+ visited_vertices[(int)ni.index] = 1;
+ if (ss->filter_cache->mask_update_last_it < new_entry.it) {
+ ss->filter_cache->mask_update_last_it = new_entry.it;
+ }
+ if (use_normals) {
+ float current_normal[3], prev_normal[3];
+ sculpt_vertex_normal_get(ss, ni.index, current_normal);
+ sculpt_vertex_normal_get(ss, c_mevit.v, prev_normal);
+ new_entry.edge_factor = dot_v3v3(current_normal, prev_normal) * c_mevit.edge_factor;
+ ss->filter_cache->normal_factor[ni.index] = dot_v3v3(original_normal, current_normal) *
+ powf(c_mevit.edge_factor, edge_sensitivity);
+ CLAMP(ss->filter_cache->normal_factor[ni.index], 0, 1);
+ }
+ BLI_gsqueue_push(queue, &new_entry);
+ }
+ }
+ sculpt_vertex_neighbors_iter_end(ni)
+ }
+
+ if (use_normals) {
+ for (int repeat = 0; repeat < 2; repeat++) {
+ for (int i = 0; i < vertex_count; i++) {
+ float avg = 0;
+ SculptVertexNeighborIter ni;
+ sculpt_vertex_neighbors_iter_begin(ss, i, ni)
+ {
+ avg += ss->filter_cache->normal_factor[ni.index];
+ }
+ sculpt_vertex_neighbors_iter_end(ni);
+ ss->filter_cache->normal_factor[i] = avg / ni.size;
+ }
+ }
+ }
+
+ BLI_gsqueue_free(queue);
+
+ MEM_freeN(visited_vertices);
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ .mask_expand_update_it = 0,
+ .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"),
+ .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"),
+ .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"),
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) &&
+ ss->filter_cache->totnode > SCULPT_THREADED_LIMIT);
+
+ BLI_task_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings);
+
+ const char *status_str = TIP_(
+ "Move the mouse to expand the mask from the active vertex. LBM: confirm mask, ESC/RMB: "
+ "cancel");
+ ED_workspace_status_text(C, status_str);
+
+ sculpt_flush_update_step(C);
+ WM_event_add_modal_handler(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static void SCULPT_OT_mask_expand(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Mask Expand";
+ ot->idname = "SCULPT_OT_mask_expand";
+ ot->description = "Expands a mask from the initial active vertex under the cursor";
+
+ /* api callbacks */
+ ot->invoke = sculpt_mask_expand_invoke;
+ ot->modal = sculpt_mask_expand_modal;
+ ot->cancel = sculpt_mask_expand_cancel;
+ ot->poll = sculpt_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->prop = RNA_def_boolean(ot->srna, "invert", true, "Invert", "Invert the new mask");
+ ot->prop = RNA_def_boolean(
+ ot->srna, "use_cursor", true, "Use Cursor", "Expand the mask to the cursor position");
+ ot->prop = RNA_def_boolean(ot->srna,
+ "update_pivot",
+ true,
+ "Update Pivot Position",
+ "Set the pivot position to the mask border after creating the mask");
+ ot->prop = RNA_def_int(ot->srna, "smooth_iterations", 2, 0, 10, "Smooth iterations", "", 0, 10);
+ ot->prop = RNA_def_int(ot->srna, "mask_speed", 5, 1, 10, "Mask speed", "", 1, 10);
+
+ ot->prop = RNA_def_boolean(ot->srna,
+ "use_normals",
+ true,
+ "Use Normals",
+ "Generate the mask using the normals and curvature of the model");
+ ot->prop = RNA_def_boolean(ot->srna,
+ "keep_previous_mask",
+ false,
+ "Keep Previous Mask",
+ "Generate the new mask on top of the current one");
+ ot->prop = RNA_def_int(ot->srna,
+ "edge_sensitivity",
+ 300,
+ 0,
+ 2000,
+ "Edge Detection Sensitivity",
+ "Sensitivity for expanding the mask across sculpted sharp edges when "
+ "using normals to generate the mask",
+ 0,
+ 2000);
+}
+
+void sculpt_geometry_preview_lines_update(bContext *C, SculptSession *ss, float radius)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Object *ob = CTX_data_active_object(C);
+
+ ss->preview_vert_index_count = 0;
+ int totpoints = 0;
+
+ /* This function is called from the cursor drawing code, so the PBVH may not be build yet */
+ if (!ss->pbvh) {
+ return;
+ }
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
+
+ if (!ss->pmap) {
+ return;
+ }
+
+ float brush_co[3];
+ copy_v3_v3(brush_co, sculpt_vertex_co_get(ss, sculpt_active_vertex_get(ss)));
+
+ char *visited_vertices = MEM_callocN(sculpt_vertex_count_get(ss) * sizeof(char),
+ "visited vertices");
+
+ if (ss->preview_vert_index_list == NULL) {
+ ss->preview_vert_index_list = MEM_callocN(4 * sizeof(int) * sculpt_vertex_count_get(ss),
+ "preview lines");
+ }
+
+ BLI_Stack *not_visited_vertices = BLI_stack_new(sizeof(VertexTopologyIterator),
+ "Not visited vertices stack");
+ VertexTopologyIterator mevit;
+ mevit.v = sculpt_active_vertex_get(ss);
+ BLI_stack_push(not_visited_vertices, &mevit);
+
+ while (!BLI_stack_is_empty(not_visited_vertices)) {
+ VertexTopologyIterator c_mevit;
+ BLI_stack_pop(not_visited_vertices, &c_mevit);
+ SculptVertexNeighborIter ni;
+ sculpt_vertex_neighbors_iter_begin(ss, c_mevit.v, ni)
+ {
+ VertexTopologyIterator new_entry;
+ new_entry.v = ni.index;
+ new_entry.it = c_mevit.it + 1;
+ ss->preview_vert_index_list[totpoints] = c_mevit.v;
+ totpoints++;
+ ss->preview_vert_index_list[totpoints] = new_entry.v;
+ totpoints++;
+ if (visited_vertices[(int)ni.index] == 0) {
+ visited_vertices[(int)ni.index] = 1;
+ if (len_squared_v3v3(brush_co, sculpt_vertex_co_get(ss, new_entry.v)) < radius * radius) {
+ BLI_stack_push(not_visited_vertices, &new_entry);
+ }
+ }
+ }
+ sculpt_vertex_neighbors_iter_end(ni)
+ }
+
+ BLI_stack_free(not_visited_vertices);
+
+ MEM_freeN(visited_vertices);
+
+ ss->preview_vert_index_count = totpoints;
+}
+void ED_sculpt_init_transform(struct bContext *C)
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+
+ copy_v3_v3(ss->init_pivot_pos, ss->pivot_pos);
+ copy_v4_v4(ss->init_pivot_rot, ss->pivot_rot);
+
+ ss->init_pivot_scale[0] = 1.0f;
+ ss->init_pivot_scale[1] = 1.0f;
+ ss->init_pivot_scale[2] = 1.0f;
+
+ ss->pivot_scale[0] = 1.0f;
+ ss->pivot_scale[1] = 1.0f;
+ ss->pivot_scale[2] = 1.0f;
+
+ sculpt_undo_push_begin("Transform");
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
+
+ ss->pivot_rot[3] = 1.0f;
+
+ sculpt_vertex_random_access_init(ss);
+ sculpt_filter_cache_init(ob, sd);
+}
+
+typedef enum PaintSymmetryAreas {
+ AREA_SYMM_X = (1 << 0),
+ AREA_SYMM_Y = (1 << 1),
+ AREA_SYMM_Z = (1 << 2),
+} PaintSymmetryAreas;
+
+static char sculpt_get_vertex_symm_area(float co[3])
+{
+ float vco[3];
+ char symm_area = 0;
+ copy_v3_v3(vco, co);
+ if (vco[0] < 0) {
+ symm_area |= AREA_SYMM_X;
+ }
+ if (vco[1] < 0) {
+ symm_area |= AREA_SYMM_Y;
+ }
+ if (vco[2] < 0) {
+ symm_area |= AREA_SYMM_Z;
+ }
+ return symm_area;
+}
+
+static void flip_qt(float qt[4], char symm)
+{
+ float euler[3];
+ if (symm & PAINT_SYMM_X) {
+ quat_to_eul(euler, qt);
+ euler[1] = -euler[1];
+ euler[2] = -euler[2];
+ eul_to_quat(qt, euler);
+ }
+ if (symm & PAINT_SYMM_Y) {
+ quat_to_eul(euler, qt);
+ euler[0] = -euler[0];
+ euler[2] = -euler[2];
+ eul_to_quat(qt, euler);
+ }
+ if (symm & PAINT_SYMM_Z) {
+ quat_to_eul(euler, qt);
+ euler[0] = -euler[0];
+ euler[1] = -euler[1];
+ eul_to_quat(qt, euler);
+ }
+}
+
+static void sculpt_flip_transform_by_symm_area(
+ float disp[3], float rot[4], char symm, char symmarea, float pivot[3])
+{
+
+ for (char i = 0; i < 3; i++) {
+ char symm_it = 1 << i;
+ if (symm & symm_it) {
+ if (symmarea & symm_it) {
+ if (disp) {
+ flip_v3(disp, symm_it);
+ }
+ if (rot) {
+ flip_qt(rot, symm_it);
+ }
+ }
+ if (pivot[0] < 0) {
+ if (disp) {
+ flip_v3(disp, symm_it);
+ }
+ if (rot) {
+ flip_qt(rot, symm_it);
+ }
+ }
+ }
+ }
+}
+
+static void sculpt_transform_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+
+ SculptOrigVertData orig_data;
+ sculpt_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]);
+
+ PBVHVertexIter vd;
+
+ sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS);
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL)
+ {
+ sculpt_orig_vert_data_update(&orig_data, &vd);
+ float transformed_co[3], orig_co[3], disp[3];
+ float fade = vd.mask ? *vd.mask : 0.0f;
+ copy_v3_v3(orig_co, orig_data.co);
+ char symm_area = sculpt_get_vertex_symm_area(orig_co);
+
+ copy_v3_v3(transformed_co, orig_co);
+ mul_m4_v3(data->transform_mats[(int)symm_area], transformed_co);
+ sub_v3_v3v3(disp, transformed_co, orig_co);
+ mul_v3_fl(disp, 1.0f - fade);
+
+ add_v3_v3v3(vd.co, orig_co, disp);
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+
+ BKE_pbvh_node_mark_redraw(node);
+ BKE_pbvh_node_mark_normals_update(node);
+}
+
+void ED_sculpt_update_modal_transform(struct bContext *C)
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+
+ sculpt_vertex_random_access_init(ss);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ };
+
+ float final_pivot_pos[3], d_t[3], d_r[4];
+ float t_mat[4][4], r_mat[4][4], s_mat[4][4], pivot_mat[4][4], pivot_imat[4][4],
+ transform_mat[4][4];
+
+ copy_v3_v3(final_pivot_pos, ss->pivot_pos);
+ for (int i = 0; i < 8; i++) {
+ copy_v3_v3(final_pivot_pos, ss->pivot_pos);
+
+ unit_m4(pivot_mat);
+
+ unit_m4(t_mat);
+ unit_m4(r_mat);
+ unit_m4(s_mat);
+
+ /* Translation matrix */
+ sub_v3_v3v3(d_t, ss->pivot_pos, ss->init_pivot_pos);
+ sculpt_flip_transform_by_symm_area(d_t, NULL, symm, (char)i, ss->init_pivot_pos);
+ translate_m4(t_mat, d_t[0], d_t[1], d_t[2]);
+
+ /* Rotation matrix */
+ sub_qt_qtqt(d_r, ss->pivot_rot, ss->init_pivot_rot);
+ normalize_qt(d_r);
+ sculpt_flip_transform_by_symm_area(NULL, d_r, symm, (char)i, ss->init_pivot_pos);
+ quat_to_mat4(r_mat, d_r);
+
+ /* Scale matrix */
+ size_to_mat4(s_mat, ss->pivot_scale);
+
+ /* Pivot matrix */
+ sculpt_flip_transform_by_symm_area(final_pivot_pos, NULL, symm, (char)i, ss->init_pivot_pos);
+ translate_m4(pivot_mat, final_pivot_pos[0], final_pivot_pos[1], final_pivot_pos[2]);
+ invert_m4_m4(pivot_imat, pivot_mat);
+
+ /* Final transform matrix */
+ mul_m4_m4m4(transform_mat, r_mat, t_mat);
+ mul_m4_m4m4(transform_mat, transform_mat, s_mat);
+ mul_m4_m4m4(data.transform_mats[i], transform_mat, pivot_imat);
+ mul_m4_m4m4(data.transform_mats[i], pivot_mat, data.transform_mats[i]);
+ }
+
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) &&
+ ss->filter_cache->totnode > SCULPT_THREADED_LIMIT);
+ BLI_task_parallel_range(
+ 0, ss->filter_cache->totnode, &data, sculpt_transform_task_cb, &settings);
+
+ if (ss->modifiers_active || ss->kb) {
+ sculpt_flush_stroke_deform(sd, ob, true);
+ }
+
+ sculpt_flush_update_step(C);
+}
+
+void ED_sculpt_end_transform(struct bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ if (ss->filter_cache) {
+ sculpt_filter_cache_free(ss);
+ }
+ sculpt_undo_push_end();
+ sculpt_flush_update_done(C, ob);
+}
+
+typedef enum eSculptPivotPositionModes {
+ SCULPT_PIVOT_POSITION_ORIGIN = 0,
+ SCULPT_PIVOT_POSITION_UNMASKED = 1,
+ SCULPT_PIVOT_POSITION_MASK_BORDER = 2,
+ SCULPT_PIVOT_POSITION_ACTIVE_VERTEX = 3,
+ SCULPT_PIVOT_POSITION_CURSOR_SURFACE = 4,
+} eSculptPivotPositionModes;
+
+EnumPropertyItem prop_sculpt_pivot_position_types[] = {
+ {SCULPT_PIVOT_POSITION_ORIGIN,
+ "ORIGIN",
+ 0,
+ "Origin",
+ "Sets the pivot to the origin of the sculpt"},
+ {SCULPT_PIVOT_POSITION_UNMASKED,
+ "UNMASKED",
+ 0,
+ "Unmasked",
+ "Sets the pivot position to the average position of the unmasked vertices"},
+ {SCULPT_PIVOT_POSITION_MASK_BORDER,
+ "BORDER",
+ 0,
+ "Mask border",
+ "Sets the pivot position to the center of the border of the mask"},
+ {SCULPT_PIVOT_POSITION_ACTIVE_VERTEX,
+ "ACTIVE",
+ 0,
+ "Active vertex",
+ "Sets the pivot position to the active vertex position"},
+ {SCULPT_PIVOT_POSITION_CURSOR_SURFACE,
+ "SURFACE",
+ 0,
+ "Surface",
+ "Sets the pivot position to the surface under the cursor"},
+ {0, NULL, 0, NULL, NULL},
+};
+
+static int sculpt_set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ ARegion *ar = CTX_wm_region(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ return OPERATOR_CANCELLED;
+ }
+
+ int mode = RNA_enum_get(op->ptr, "mode");
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true);
+
+ int vert_count = sculpt_vertex_count_get(ss);
+
+ /* Pivot to center */
+ if (mode == SCULPT_PIVOT_POSITION_ORIGIN) {
+ zero_v3(ss->pivot_pos);
+ }
+
+ /* Pivot to unmasked */
+ if (mode == SCULPT_PIVOT_POSITION_UNMASKED) {
+ float avg[3];
+ int total = 0;
+ zero_v3(avg);
+ for (int i = 0; i < vert_count; i++) {
+ if (sculpt_vertex_mask_get(ss, i) < 1.0f &&
+ check_vertex_pivot_symmetry(sculpt_vertex_co_get(ss, i), ss->pivot_pos, symm)) {
+ total++;
+ add_v3_v3(avg, sculpt_vertex_co_get(ss, i));
+ }
+ }
+ if (total > 0) {
+ mul_v3_fl(avg, 1.0f / total);
+ copy_v3_v3(ss->pivot_pos, avg);
+ }
+ }
+
+ /* Pivot to mask border */
+ if (mode == SCULPT_PIVOT_POSITION_MASK_BORDER) {
+ float avg[3];
+ int total = 0;
+ float threshold = 0.2f;
+ zero_v3(avg);
+ for (int i = 0; i < vert_count; i++) {
+ if (sculpt_vertex_mask_get(ss, i) < (0.5f + threshold) &&
+ sculpt_vertex_mask_get(ss, i) > (0.5f - threshold) &&
+ check_vertex_pivot_symmetry(sculpt_vertex_co_get(ss, i), ss->pivot_pos, symm)) {
+ total++;
+ add_v3_v3(avg, sculpt_vertex_co_get(ss, i));
+ }
+ }
+ if (total > 0) {
+ mul_v3_fl(avg, 1.0f / total);
+ copy_v3_v3(ss->pivot_pos, avg);
+ }
+ }
+
+ /* Pivot to active vertex */
+ if (mode == SCULPT_PIVOT_POSITION_ACTIVE_VERTEX) {
+ copy_v3_v3(ss->pivot_pos, sculpt_vertex_co_get(ss, sculpt_active_vertex_get(ss)));
+ }
+
+ /* Pivot to raycast surface */
+ if (mode == SCULPT_PIVOT_POSITION_CURSOR_SURFACE) {
+ float stroke_location[3];
+ float mouse[2];
+ mouse[0] = event->mval[0];
+ mouse[1] = event->mval[1];
+ if (sculpt_stroke_get_location(C, stroke_location, mouse)) {
+ copy_v3_v3(ss->pivot_pos, stroke_location);
+ }
+ }
+
+ ED_region_tag_redraw(ar);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+
+ return OPERATOR_FINISHED;
+}
+
+static void SCULPT_OT_set_pivot_position(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set Pivot Position";
+ ot->idname = "SCULPT_OT_set_pivot_position";
+ ot->description = "Sets the sculpt transform pivot position";
+
+ /* api callbacks */
+ ot->invoke = sculpt_set_pivot_position_invoke;
+ ot->poll = sculpt_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ RNA_def_enum(ot->srna,
+ "mode",
+ prop_sculpt_pivot_position_types,
+ SCULPT_PIVOT_POSITION_UNMASKED,
+ "Mode",
+ "");
+}
+
void ED_operatortypes_sculpt(void)
{
WM_operatortype_append(SCULPT_OT_brush_stroke);
@@ -8595,4 +9480,6 @@ void ED_operatortypes_sculpt(void)
WM_operatortype_append(SCULPT_OT_mesh_filter);
WM_operatortype_append(SCULPT_OT_mask_filter);
WM_operatortype_append(SCULPT_OT_dirty_mask);
+ WM_operatortype_append(SCULPT_OT_mask_expand);
+ WM_operatortype_append(SCULPT_OT_set_pivot_position);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 8d009b64b6b..b814e87fcb0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -57,6 +57,10 @@ bool sculpt_cursor_geometry_info_update(bContext *C,
SculptCursorGeometryInfo *out,
const float mouse[2],
bool use_sampled_normal);
+void sculpt_geometry_preview_lines_update(bContext *C, struct SculptSession *ss, float radius);
+
+/* Sculpt PBVH abstraction API */
+float *sculpt_vertex_co_get(struct SculptSession *ss, int index);
/* Dynamic topology */
void sculpt_pbvh_clear(Object *ob);
@@ -118,6 +122,10 @@ typedef struct SculptUndoNode {
int geom_totloop;
int geom_totpoly;
+ /* pivot */
+ float pivot_pos[3];
+ float pivot_rot[4];
+
size_t undo_size;
} SculptUndoNode;
@@ -169,16 +177,16 @@ typedef struct SculptThreadedTaskData {
float (*mat)[4];
float (*vertCos)[3];
+ int filter_type;
+ float filter_strength;
+ int *node_mask;
+
/* 0=towards view, 1=flipped */
float (*area_cos)[3];
float (*area_nos)[3];
int *count;
bool any_vertex_sampled;
- int filter_type;
- float filter_strength;
- int *node_mask;
-
float *prev_mask;
float *pose_origin;
@@ -189,6 +197,13 @@ typedef struct SculptThreadedTaskData {
float nearest_vertex_search_co[3];
int nearest_vertex_index;
+ int mask_expand_update_it;
+ bool mask_expand_invert_mask;
+ bool mask_expand_use_normals;
+ bool mask_expand_keep_prev_mask;
+
+ float transform_mats[8][4][4];
+
ThreadMutex mutex;
} SculptThreadedTaskData;
@@ -376,6 +391,9 @@ typedef struct FilterCache {
int mask_update_current_it;
int mask_update_last_it;
int *mask_update_it;
+ float *normal_factor;
+ float *prev_mask;
+ float mask_expand_initial_co[3];
} FilterCache;
void sculpt_cache_calc_brushdata_symm(StrokeCache *cache,
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index cb8afd5d7fa..3783eb17562 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -494,6 +494,9 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
bool partial_update = true;
for (unode = lb->first; unode; unode = unode->next) {
+ /* restore pivot */
+ copy_v3_v3(ss->pivot_pos, unode->pivot_pos);
+ copy_v3_v3(ss->pivot_rot, unode->pivot_rot);
if (STREQ(unode->idname, ob->id.name)) {
if (unode->type == SCULPT_UNDO_MASK) {
/* is possible that we can't do the mask undo (below)
@@ -1055,6 +1058,10 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
break;
}
+ /* store sculpt pivot */
+ copy_v3_v3(unode->pivot_pos, ss->pivot_pos);
+ copy_v3_v3(unode->pivot_rot, ss->pivot_rot);
+
/* store active shape key */
if (ss->kb) {
BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name));
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index ca26a56a26e..0aec6d5e6a0 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -138,13 +138,10 @@ static void file_draw_icon(
{
uiBut *but;
int x, y;
- // float alpha = 1.0f;
x = sx;
y = sy - height;
- /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/
-
but = uiDefIconBut(
block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL);
UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path));
@@ -265,15 +262,11 @@ static void file_draw_preview(uiBlock *block,
float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
if (is_icon) {
- /* File and Folder icons draw with lowered opacity until we add themes */
- col[3] = 0.6f;
- /* Use dark images if background is light */
- float bg[3];
- UI_GetThemeColor3fv(TH_BACK, bg);
- if (rgb_to_grayscale(bg) > 0.5f) {
- col[0] = 0;
- col[1] = 0;
- col[2] = 0;
+ if (typeflags & FILE_TYPE_DIR) {
+ UI_GetThemeColor4fv(TH_ICON_FOLDER, col);
+ }
+ else {
+ UI_GetThemeColor4fv(TH_TEXT, col);
}
}
else if (typeflags & FILE_TYPE_FTFONT) {
@@ -314,7 +307,7 @@ static void file_draw_preview(uiBlock *block,
float icon_opacity = 0.3f;
uchar icon_color[4] = {0, 0, 0, 255};
float bgcolor[4];
- UI_GetThemeColor4fv(TH_TEXT, bgcolor);
+ UI_GetThemeColor4fv(TH_ICON_FOLDER, bgcolor);
if (rgb_to_grayscale(bgcolor) < 0.5f) {
icon_color[0] = 255;
icon_color[1] = 255;
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index c6061cb6f58..127196cca74 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -489,6 +489,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const bool extend = RNA_boolean_get(op->ptr, "extend");
const bool fill = RNA_boolean_get(op->ptr, "fill");
const bool do_diropen = RNA_boolean_get(op->ptr, "open");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
if (ar->regiontype != RGN_TYPE_WINDOW) {
return OPERATOR_CANCELLED;
@@ -521,10 +522,15 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
filelist_entry_parent_select_set(sfile->files, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
}
- if (FILE_SELECT_DIR == ret) {
+ if (ret == FILE_SELECT_NOTHING) {
+ if (deselect_all) {
+ file_deselect_all(sfile, FILE_SEL_SELECTED);
+ }
+ }
+ else if (ret == FILE_SELECT_DIR) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
- else if (FILE_SELECT_FILE == ret) {
+ else if (ret == FILE_SELECT_FILE) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
}
@@ -540,8 +546,8 @@ void FILE_OT_select(wmOperatorType *ot)
/* identifiers */
ot->name = "Select";
- ot->description = "Activate/select file";
ot->idname = "FILE_OT_select";
+ ot->description = "Handle mouse clicks to select and activate items";
/* api callbacks */
ot->invoke = file_select_invoke;
@@ -559,6 +565,12 @@ void FILE_OT_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "open", true, "Open", "Open a directory when selecting it");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/**
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index c7a139a8b24..7faa2b883f2 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -492,20 +492,17 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
/* Flee from horrible win querying hover floppy drives! */
if (i > 1) {
- /* Try to get volume label as well... */
+ /* Try to get a friendly drive description. */
+ SHFILEINFOW shFile = {0};
BLI_strncpy_wchar_from_utf8(wline, tmps, 4);
- if (GetVolumeInformationW(
- wline, wline + 4, FILE_MAXDIR - 4, NULL, NULL, NULL, NULL, 0)) {
- size_t label_len;
-
- BLI_strncpy_wchar_as_utf8(line, wline + 4, FILE_MAXDIR - 4);
-
- label_len = MIN2(strlen(line), FILE_MAXDIR - 6);
- BLI_snprintf(line + label_len, 6, " (%.2s)", tmps);
-
+ if (SHGetFileInfoW(wline, 0, &shFile, sizeof(SHFILEINFOW), SHGFI_DISPLAYNAME)) {
+ BLI_strncpy_wchar_as_utf8(line, shFile.szDisplayName, FILE_MAXDIR);
name = line;
}
}
+ if (name == NULL) {
+ name = tmps;
+ }
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, name, FS_INSERT_SORTED);
}
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index c76f02129a5..b51aec90e4f 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -581,7 +581,7 @@ const char *ED_info_stats_string(Main *bmain, Scene *scene, ViewLayer *view_laye
if (wm->is_interface_locked) {
return "";
}
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
if (!view_layer->stats) {
stats_update(depsgraph, view_layer);
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 2b0627251cd..8811918b552 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -204,7 +204,7 @@ static void compo_initjob(void *cjv)
Scene *scene = cj->scene;
ViewLayer *view_layer = cj->view_layer;
- cj->compositor_depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
+ cj->compositor_depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER);
DEG_graph_build_for_compositor_preview(
cj->compositor_depsgraph, bmain, scene, view_layer, cj->ntree);
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index dc375958eb4..7c75f0ea907 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -33,6 +33,9 @@ set(INC
../../../../intern/glew-mx
../../../../intern/guardedalloc
../../../../intern/smoke/extern
+
+ # dna_type_offsets.h
+ ${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
)
set(INC_SYS
@@ -96,3 +99,6 @@ if(WITH_MOD_SMOKE)
endif()
blender_add_lib(bf_editor_space_view3d "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+# Needed so we can use dna_type_offsets.h for defaults initialization.
+add_dependencies(bf_editor_space_view3d bf_dna)
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 8c4f2f62602..b28927a0833 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -29,6 +29,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_gpencil_types.h"
+#include "DNA_defaults.h"
#include "MEM_guardedalloc.h"
@@ -39,6 +40,7 @@
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_icons.h"
+#include "BKE_idprop.h"
#include "BKE_lattice.h"
#include "BKE_main.h"
#include "BKE_mball.h"
@@ -246,56 +248,11 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
View3D *v3d;
RegionView3D *rv3d;
- v3d = MEM_callocN(sizeof(View3D), "initview3d");
- v3d->spacetype = SPACE_VIEW3D;
+ v3d = DNA_struct_default_alloc(View3D);
+
if (scene) {
v3d->camera = scene->camera;
}
- v3d->scenelock = true;
- v3d->grid = 1.0f;
- v3d->gridlines = 16;
- v3d->gridsubdiv = 10;
- BKE_screen_view3d_shading_init(&v3d->shading);
-
- v3d->overlay.wireframe_threshold = 1.0f;
- v3d->overlay.xray_alpha_bone = 0.5f;
- v3d->overlay.texture_paint_mode_opacity = 1.0f;
- v3d->overlay.weight_paint_mode_opacity = 1.0f;
- v3d->overlay.vertex_paint_mode_opacity = 1.0f;
- /* Intentionally different to vertex/paint mode,
- * we typically want to see shading too. */
- v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
-
- v3d->overlay.edit_flag = V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS |
- V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE |
- V3D_OVERLAY_EDIT_FREESTYLE_FACE | V3D_OVERLAY_EDIT_EDGES |
- V3D_OVERLAY_EDIT_CREASES | V3D_OVERLAY_EDIT_BWEIGHTS |
- V3D_OVERLAY_EDIT_CU_HANDLES | V3D_OVERLAY_EDIT_CU_NORMALS;
-
- v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID;
-
- v3d->flag = V3D_SELECT_OUTLINE;
- v3d->flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_ANNOTATION;
-
- v3d->lens = 50.0f;
- v3d->clip_start = 0.01f;
- v3d->clip_end = 1000.0f;
-
- v3d->overlay.gpencil_paper_opacity = 0.5f;
- v3d->overlay.gpencil_grid_opacity = 0.9f;
-
- v3d->bundle_size = 0.2f;
- v3d->bundle_drawtype = OB_PLAINAXES;
-
- /* stereo */
- v3d->stereo3d_camera = STEREO_3D_ID;
- v3d->stereo3d_flag |= V3D_S3D_DISPPLANE;
- v3d->stereo3d_convergence_alpha = 0.15f;
- v3d->stereo3d_volume_alpha = 0.05f;
-
- /* grease pencil settings */
- v3d->vertex_opacity = 1.0f;
- v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
/* tool header */
ar = MEM_callocN(sizeof(ARegion), "tool header for view3d");
@@ -363,6 +320,11 @@ static void view3d_free(SpaceLink *sl)
if (vd->fx_settings.dof) {
MEM_freeN(vd->fx_settings.dof);
}
+
+ if (vd->shading.prop) {
+ IDP_FreeProperty(vd->shading.prop);
+ vd->shading.prop = NULL;
+ }
}
/* spacetype; init callback */
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 1ace1198795..9ab56dba72d 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -1466,6 +1466,7 @@ static void v3d_editarmature_buts(uiLayout *layout, Object *ob)
uiItemR(col, &eboneptr, "tail_radius", 0, IFACE_("Radius"), ICON_NONE);
uiItemR(col, &eboneptr, "roll", 0, NULL, ICON_NONE);
+ uiItemR(col, &eboneptr, "length", 0, NULL, ICON_NONE);
uiItemR(col, &eboneptr, "envelope_distance", 0, IFACE_("Envelope"), ICON_NONE);
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index e76ef2b0458..4bc74ab8fba 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -2997,7 +2997,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
ok = paintface_minmax(ob_eval, min, max);
}
else if (ob_eval && (ob_eval->mode & OB_MODE_PARTICLE_EDIT)) {
- ok = PE_minmax(scene, view_layer_eval, min, max);
+ ok = PE_minmax(scene, CTX_data_view_layer(C), min, max);
}
else if (ob_eval && (ob_eval->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT |
OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 210cc5cbca7..e3ff8b92081 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -56,6 +56,7 @@ set(SRC
transform_convert_object.c
transform_convert_paintcurve.c
transform_convert_particle.c
+ transform_convert_sculpt.c
transform_convert_sequencer.c
transform_convert_tracking.c
transform_generics.c
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 019db4f74fa..21ef44752ac 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -79,6 +79,7 @@
#include "ED_clip.h"
#include "ED_node.h"
#include "ED_gpencil.h"
+#include "ED_sculpt.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -2299,6 +2300,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
+ if (t->options & CTX_SCULPT) {
+ ED_sculpt_end_transform(C);
+ }
+
if ((prop = RNA_struct_find_property(op->ptr, "correct_uv"))) {
RNA_property_boolean_set(
op->ptr, prop, (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) != 0);
@@ -2342,6 +2347,11 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
+ Object *ob = CTX_data_active_object(C);
+ if (ob && ob->mode == OB_MODE_SCULPT && ob->sculpt) {
+ options |= CTX_SCULPT;
+ }
+
t->options = options;
t->mode = mode;
@@ -2404,6 +2414,10 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
createTransData(C, t); // make TransData structs from selection
+ if (t->options & CTX_SCULPT) {
+ ED_sculpt_init_transform(C);
+ }
+
if (t->data_len_all == 0) {
postTrans(C, t);
return 0;
@@ -6376,367 +6390,6 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
/** \} */
/* -------------------------------------------------------------------- */
-/* Original Data Store */
-
-/** \name Orig-Data Store Utility Functions
- * \{ */
-
-static void slide_origdata_init_flag(TransInfo *t, TransDataContainer *tc, SlideOrigData *sod)
-{
- BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
- BMesh *bm = em->bm;
- const bool has_layer_math = CustomData_has_math(&bm->ldata);
- const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
-
- if ((t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) &&
- /* don't do this at all for non-basis shape keys, too easy to
- * accidentally break uv maps or vertex colors then */
- (bm->shapenr <= 1) && (has_layer_math || (cd_loop_mdisp_offset != -1))) {
- sod->use_origfaces = true;
- sod->cd_loop_mdisp_offset = cd_loop_mdisp_offset;
- }
- else {
- sod->use_origfaces = false;
- sod->cd_loop_mdisp_offset = -1;
- }
-}
-
-static void slide_origdata_init_data(TransDataContainer *tc, SlideOrigData *sod)
-{
- if (sod->use_origfaces) {
- BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
- BMesh *bm = em->bm;
-
- sod->origfaces = BLI_ghash_ptr_new(__func__);
- sod->bm_origfaces = BM_mesh_create(&bm_mesh_allocsize_default,
- &((struct BMeshCreateParams){
- .use_toolflags = false,
- }));
- /* we need to have matching customdata */
- BM_mesh_copy_init_customdata(sod->bm_origfaces, bm, NULL);
- }
-}
-
-static void slide_origdata_create_data_vert(BMesh *bm,
- SlideOrigData *sod,
- TransDataGenericSlideVert *sv)
-{
- BMIter liter;
- int j, l_num;
- float *loop_weights;
-
- /* copy face data */
- // BM_ITER_ELEM (l, &liter, sv->v, BM_LOOPS_OF_VERT) {
- BM_iter_init(&liter, bm, BM_LOOPS_OF_VERT, sv->v);
- l_num = liter.count;
- loop_weights = BLI_array_alloca(loop_weights, l_num);
- for (j = 0; j < l_num; j++) {
- BMLoop *l = BM_iter_step(&liter);
- BMLoop *l_prev, *l_next;
- void **val_p;
- if (!BLI_ghash_ensure_p(sod->origfaces, l->f, &val_p)) {
- BMFace *f_copy = BM_face_copy(sod->bm_origfaces, bm, l->f, true, true);
- *val_p = f_copy;
- }
-
- if ((l_prev = BM_loop_find_prev_nodouble(l, l->next, FLT_EPSILON)) &&
- (l_next = BM_loop_find_next_nodouble(l, l_prev, FLT_EPSILON))) {
- loop_weights[j] = angle_v3v3v3(l_prev->v->co, l->v->co, l_next->v->co);
- }
- else {
- loop_weights[j] = 0.0f;
- }
- }
-
- /* store cd_loop_groups */
- if (sod->layer_math_map_num && (l_num != 0)) {
- sv->cd_loop_groups = BLI_memarena_alloc(sod->arena, sod->layer_math_map_num * sizeof(void *));
- for (j = 0; j < sod->layer_math_map_num; j++) {
- const int layer_nr = sod->layer_math_map[j];
- sv->cd_loop_groups[j] = BM_vert_loop_groups_data_layer_create(
- bm, sv->v, layer_nr, loop_weights, sod->arena);
- }
- }
- else {
- sv->cd_loop_groups = NULL;
- }
-
- BLI_ghash_insert(sod->origverts, sv->v, sv);
-}
-
-static void slide_origdata_create_data(TransDataContainer *tc,
- SlideOrigData *sod,
- TransDataGenericSlideVert *sv_array,
- unsigned int v_stride,
- unsigned int v_num)
-{
- if (sod->use_origfaces) {
- BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
- BMesh *bm = em->bm;
- unsigned int i;
- TransDataGenericSlideVert *sv;
-
- int layer_index_dst;
- int j;
-
- layer_index_dst = 0;
-
- /* TODO: We don't need `sod->layer_math_map` when there are no loops linked
- * to one of the sliding vertices. */
- if (CustomData_has_math(&bm->ldata)) {
- /* over alloc, only 'math' layers are indexed */
- sod->layer_math_map = MEM_mallocN(bm->ldata.totlayer * sizeof(int), __func__);
- for (j = 0; j < bm->ldata.totlayer; j++) {
- if (CustomData_layer_has_math(&bm->ldata, j)) {
- sod->layer_math_map[layer_index_dst++] = j;
- }
- }
- BLI_assert(layer_index_dst != 0);
- }
-
- sod->layer_math_map_num = layer_index_dst;
-
- sod->arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
-
- sod->origverts = BLI_ghash_ptr_new_ex(__func__, v_num);
-
- for (i = 0, sv = sv_array; i < v_num; i++, sv = POINTER_OFFSET(sv, v_stride)) {
- slide_origdata_create_data_vert(bm, sod, sv);
- }
-
- if (tc->mirror.axis_flag) {
- TransData *td = tc->data;
- TransDataGenericSlideVert *sv_mirror;
-
- sod->sv_mirror = MEM_callocN(sizeof(*sv_mirror) * tc->data_len, __func__);
- sod->totsv_mirror = tc->data_len;
-
- sv_mirror = sod->sv_mirror;
-
- for (i = 0; i < tc->data_len; i++, td++) {
- BMVert *eve = td->extra;
- /* Check the vertex has been used since both sides
- * of the mirror may be selected & sliding. */
- if (eve && !BLI_ghash_haskey(sod->origverts, eve)) {
- sv_mirror->v = eve;
- copy_v3_v3(sv_mirror->co_orig_3d, eve->co);
-
- slide_origdata_create_data_vert(bm, sod, sv_mirror);
- sv_mirror++;
- }
- else {
- sod->totsv_mirror--;
- }
- }
-
- if (sod->totsv_mirror == 0) {
- MEM_freeN(sod->sv_mirror);
- sod->sv_mirror = NULL;
- }
- }
- }
-}
-
-/**
- * If we're sliding the vert, return its original location, if not, the current location is good.
- */
-static const float *slide_origdata_orig_vert_co(SlideOrigData *sod, BMVert *v)
-{
- TransDataGenericSlideVert *sv = BLI_ghash_lookup(sod->origverts, v);
- return sv ? sv->co_orig_3d : v->co;
-}
-
-static void slide_origdata_interp_data_vert(SlideOrigData *sod,
- BMesh *bm,
- bool is_final,
- TransDataGenericSlideVert *sv)
-{
- BMIter liter;
- int j, l_num;
- float *loop_weights;
- const bool is_moved = (len_squared_v3v3(sv->v->co, sv->co_orig_3d) > FLT_EPSILON);
- const bool do_loop_weight = sod->layer_math_map_num && is_moved;
- const bool do_loop_mdisps = is_final && is_moved && (sod->cd_loop_mdisp_offset != -1);
- const float *v_proj_axis = sv->v->no;
- /* original (l->prev, l, l->next) projections for each loop ('l' remains unchanged) */
- float v_proj[3][3];
-
- if (do_loop_weight || do_loop_mdisps) {
- project_plane_normalized_v3_v3v3(v_proj[1], sv->co_orig_3d, v_proj_axis);
- }
-
- // BM_ITER_ELEM (l, &liter, sv->v, BM_LOOPS_OF_VERT)
- BM_iter_init(&liter, bm, BM_LOOPS_OF_VERT, sv->v);
- l_num = liter.count;
- loop_weights = do_loop_weight ? BLI_array_alloca(loop_weights, l_num) : NULL;
- for (j = 0; j < l_num; j++) {
- BMFace *f_copy; /* the copy of 'f' */
- BMLoop *l = BM_iter_step(&liter);
-
- f_copy = BLI_ghash_lookup(sod->origfaces, l->f);
-
- /* only loop data, no vertex data since that contains shape keys,
- * and we do not want to mess up other shape keys */
- BM_loop_interp_from_face(bm, l, f_copy, false, false);
-
- /* make sure face-attributes are correct (e.g. #MLoopUV, #MLoopCol) */
- BM_elem_attrs_copy_ex(sod->bm_origfaces, bm, f_copy, l->f, 0x0, CD_MASK_NORMAL);
-
- /* weight the loop */
- if (do_loop_weight) {
- const float eps = 1.0e-8f;
- const BMLoop *l_prev = l->prev;
- const BMLoop *l_next = l->next;
- const float *co_prev = slide_origdata_orig_vert_co(sod, l_prev->v);
- const float *co_next = slide_origdata_orig_vert_co(sod, l_next->v);
- bool co_prev_ok;
- bool co_next_ok;
-
- /* In the unlikely case that we're next to a zero length edge -
- * walk around the to the next.
- *
- * Since we only need to check if the vertex is in this corner,
- * its not important _which_ loop - as long as its not overlapping
- * 'sv->co_orig_3d', see: T45096. */
- project_plane_normalized_v3_v3v3(v_proj[0], co_prev, v_proj_axis);
- while (UNLIKELY(((co_prev_ok = (len_squared_v3v3(v_proj[1], v_proj[0]) > eps)) == false) &&
- ((l_prev = l_prev->prev) != l->next))) {
- co_prev = slide_origdata_orig_vert_co(sod, l_prev->v);
- project_plane_normalized_v3_v3v3(v_proj[0], co_prev, v_proj_axis);
- }
- project_plane_normalized_v3_v3v3(v_proj[2], co_next, v_proj_axis);
- while (UNLIKELY(((co_next_ok = (len_squared_v3v3(v_proj[1], v_proj[2]) > eps)) == false) &&
- ((l_next = l_next->next) != l->prev))) {
- co_next = slide_origdata_orig_vert_co(sod, l_next->v);
- project_plane_normalized_v3_v3v3(v_proj[2], co_next, v_proj_axis);
- }
-
- if (co_prev_ok && co_next_ok) {
- const float dist = dist_signed_squared_to_corner_v3v3v3(
- sv->v->co, UNPACK3(v_proj), v_proj_axis);
-
- loop_weights[j] = (dist >= 0.0f) ? 1.0f : ((dist <= -eps) ? 0.0f : (1.0f + (dist / eps)));
- if (UNLIKELY(!isfinite(loop_weights[j]))) {
- loop_weights[j] = 0.0f;
- }
- }
- else {
- loop_weights[j] = 0.0f;
- }
- }
- }
-
- if (sod->layer_math_map_num && sv->cd_loop_groups) {
- if (do_loop_weight) {
- for (j = 0; j < sod->layer_math_map_num; j++) {
- BM_vert_loop_groups_data_layer_merge_weights(
- bm, sv->cd_loop_groups[j], sod->layer_math_map[j], loop_weights);
- }
- }
- else {
- for (j = 0; j < sod->layer_math_map_num; j++) {
- BM_vert_loop_groups_data_layer_merge(bm, sv->cd_loop_groups[j], sod->layer_math_map[j]);
- }
- }
- }
-
- /* Special handling for multires
- *
- * Interpolate from every other loop (not ideal)
- * However values will only be taken from loops which overlap other mdisps.
- * */
- if (do_loop_mdisps) {
- float(*faces_center)[3] = BLI_array_alloca(faces_center, l_num);
- BMLoop *l;
-
- BM_ITER_ELEM_INDEX (l, &liter, sv->v, BM_LOOPS_OF_VERT, j) {
- BM_face_calc_center_median(l->f, faces_center[j]);
- }
-
- BM_ITER_ELEM_INDEX (l, &liter, sv->v, BM_LOOPS_OF_VERT, j) {
- BMFace *f_copy = BLI_ghash_lookup(sod->origfaces, l->f);
- float f_copy_center[3];
- BMIter liter_other;
- BMLoop *l_other;
- int j_other;
-
- BM_face_calc_center_median(f_copy, f_copy_center);
-
- BM_ITER_ELEM_INDEX (l_other, &liter_other, sv->v, BM_LOOPS_OF_VERT, j_other) {
- BM_face_interp_multires_ex(bm,
- l_other->f,
- f_copy,
- faces_center[j_other],
- f_copy_center,
- sod->cd_loop_mdisp_offset);
- }
- }
- }
-}
-
-static void slide_origdata_interp_data(Object *obedit,
- SlideOrigData *sod,
- TransDataGenericSlideVert *sv,
- unsigned int v_stride,
- unsigned int v_num,
- bool is_final)
-{
- if (sod->use_origfaces) {
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMesh *bm = em->bm;
- unsigned int i;
- const bool has_mdisps = (sod->cd_loop_mdisp_offset != -1);
-
- for (i = 0; i < v_num; i++, sv = POINTER_OFFSET(sv, v_stride)) {
-
- if (sv->cd_loop_groups || has_mdisps) {
- slide_origdata_interp_data_vert(sod, bm, is_final, sv);
- }
- }
-
- if (sod->sv_mirror) {
- sv = sod->sv_mirror;
- for (i = 0; i < v_num; i++, sv++) {
- if (sv->cd_loop_groups || has_mdisps) {
- slide_origdata_interp_data_vert(sod, bm, is_final, sv);
- }
- }
- }
- }
-}
-
-static void slide_origdata_free_date(SlideOrigData *sod)
-{
- if (sod->use_origfaces) {
- if (sod->bm_origfaces) {
- BM_mesh_free(sod->bm_origfaces);
- sod->bm_origfaces = NULL;
- }
-
- if (sod->origfaces) {
- BLI_ghash_free(sod->origfaces, NULL, NULL);
- sod->origfaces = NULL;
- }
-
- if (sod->origverts) {
- BLI_ghash_free(sod->origverts, NULL, NULL);
- sod->origverts = NULL;
- }
-
- if (sod->arena) {
- BLI_memarena_free(sod->arena);
- sod->arena = NULL;
- }
-
- MEM_SAFE_FREE(sod->layer_math_map);
-
- MEM_SAFE_FREE(sod->sv_mirror);
- }
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/* Transform (Edge Slide) */
/** \name Transform Edge Slide
@@ -7187,8 +6840,6 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
View3D *v3d = NULL;
RegionView3D *rv3d = NULL;
- slide_origdata_init_flag(t, tc, &sld->orig_data);
-
sld->curr_sv_index = 0;
/*ensure valid selection*/
@@ -7519,18 +7170,10 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, true);
- /* create copies of faces for customdata projection */
- bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
- slide_origdata_init_data(tc, &sld->orig_data);
- slide_origdata_create_data(
- tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
-
if (rv3d) {
calcEdgeSlide_even(t, tc, sld, mval);
}
- sld->em = em;
-
tc->custom.mode.data = sld;
MEM_freeN(sv_table);
@@ -7564,8 +7207,6 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t
rv3d = t->ar ? t->ar->regiondata : NULL;
}
- slide_origdata_init_flag(t, tc, &sld->orig_data);
-
sld->curr_sv_index = 0;
/* ensure valid selection */
{
@@ -7714,18 +7355,10 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t
calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, false);
- /* create copies of faces for customdata projection */
- bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
- slide_origdata_init_data(tc, &sld->orig_data);
- slide_origdata_create_data(
- tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
-
if (rv3d) {
calcEdgeSlide_even(t, tc, sld, mval);
}
- sld->em = em;
-
tc->custom.mode.data = sld;
MEM_freeN(sv_table);
@@ -7742,25 +7375,10 @@ void projectEdgeSlideData(TransInfo *t, bool is_final)
continue;
}
- SlideOrigData *sod = &sld->orig_data;
- if (sod->use_origfaces == false) {
- continue;
- }
-
- slide_origdata_interp_data(tc->obedit,
- sod,
- (TransDataGenericSlideVert *)sld->sv,
- sizeof(*sld->sv),
- sld->totsv,
- is_final);
+ trans_mesh_customdata_correction_apply(tc, is_final);
}
}
-void freeEdgeSlideTempFaces(EdgeSlideData *sld)
-{
- slide_origdata_free_date(&sld->orig_data);
-}
-
void freeEdgeSlideVerts(TransInfo *UNUSED(t),
TransDataContainer *UNUSED(tc),
TransCustomData *custom_data)
@@ -7771,10 +7389,6 @@ void freeEdgeSlideVerts(TransInfo *UNUSED(t),
return;
}
- freeEdgeSlideTempFaces(sld);
-
- bmesh_edit_end(sld->em->bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
-
MEM_freeN(sld->sv);
MEM_freeN(sld);
@@ -7833,6 +7447,8 @@ static void initEdgeSlide_ex(
tc->custom.mode.free_cb = freeEdgeSlideVerts;
}
+ trans_mesh_customdata_correction_init(t);
+
/* set custom point first if you want value to be initialized by init */
calcEdgeSlideCustomPoints(t);
initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO_FLIP);
@@ -8308,8 +7924,6 @@ static bool createVertSlideVerts(TransInfo *t, TransDataContainer *tc)
VertSlideData *sld = MEM_callocN(sizeof(*sld), "sld");
int j;
- slide_origdata_init_flag(t, tc, &sld->orig_data);
-
sld->curr_sv_index = 0;
j = 0;
@@ -8373,13 +7987,6 @@ static bool createVertSlideVerts(TransInfo *t, TransDataContainer *tc)
sld->sv = sv_array;
sld->totsv = j;
- bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
- slide_origdata_init_data(tc, &sld->orig_data);
- slide_origdata_create_data(
- tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
-
- sld->em = em;
-
tc->custom.mode.data = sld;
/* most likely will be set below */
@@ -8408,24 +8015,10 @@ static bool createVertSlideVerts(TransInfo *t, TransDataContainer *tc)
void projectVertSlideData(TransInfo *t, bool is_final)
{
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- VertSlideData *sld = tc->custom.mode.data;
- SlideOrigData *sod = &sld->orig_data;
- if (sod->use_origfaces == true) {
- slide_origdata_interp_data(tc->obedit,
- sod,
- (TransDataGenericSlideVert *)sld->sv,
- sizeof(*sld->sv),
- sld->totsv,
- is_final);
- }
+ trans_mesh_customdata_correction_apply(tc, is_final);
}
}
-void freeVertSlideTempFaces(VertSlideData *sld)
-{
- slide_origdata_free_date(&sld->orig_data);
-}
-
void freeVertSlideVerts(TransInfo *UNUSED(t),
TransDataContainer *UNUSED(tc),
TransCustomData *custom_data)
@@ -8436,10 +8029,6 @@ void freeVertSlideVerts(TransInfo *UNUSED(t),
return;
}
- freeVertSlideTempFaces(sld);
-
- bmesh_edit_end(sld->em->bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
-
if (sld->totsv > 0) {
TransDataVertSlideVert *sv = sld->sv;
int i = 0;
@@ -8489,6 +8078,8 @@ static void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use
return;
}
+ trans_mesh_customdata_correction_init(t);
+
/* set custom point first if you want value to be initialized by init */
calcVertSlideCustomPoints(t);
initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 92db32fa836..b90fff29a84 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -294,38 +294,11 @@ typedef struct TransDataEdgeSlideVert {
int loop_nr;
} TransDataEdgeSlideVert;
-/* store original data so we can correct UV's and similar when sliding */
-typedef struct SlideOrigData {
- /** Set when #origfaces is initialized. */
- bool use_origfaces;
- int cd_loop_mdisp_offset;
-
- /** map {BMVert: TransDataGenericSlideVert} */
- struct GHash *origverts;
- struct GHash *origfaces;
- struct BMesh *bm_origfaces;
-
- struct MemArena *arena;
- /** Number of math BMLoop layers. */
- int layer_math_map_num;
- /** Array size of 'layer_math_map_num'
- * maps TransDataVertSlideVert.cd_group index to absolute CustomData layer index */
- int *layer_math_map;
-
- /** Array of slide vert data especially for mirror verts. */
- TransDataGenericSlideVert *sv_mirror;
- int totsv_mirror;
-} SlideOrigData;
-
typedef struct EdgeSlideData {
TransDataEdgeSlideVert *sv;
int totsv;
int mval_start[2], mval_end[2];
- struct BMEditMesh *em;
-
- SlideOrigData orig_data;
-
int curr_sv_index;
/** when un-clamped - use this index: #TransDataEdgeSlideVert.dir_side */
@@ -354,11 +327,6 @@ typedef struct TransDataVertSlideVert {
typedef struct VertSlideData {
TransDataVertSlideVert *sv;
int totsv;
-
- struct BMEditMesh *em;
-
- SlideOrigData orig_data;
-
int curr_sv_index;
/* result of ED_view3d_ob_project_mat_get */
@@ -449,6 +417,18 @@ typedef struct TransData {
short protectflag;
} TransData;
+typedef struct TransDataMirror {
+ /** location of mirrored reference data. */
+ const float *loc_src;
+ /** Location of the data to transform. */
+ float *loc_dst;
+ void *extra;
+ /* `sign` can be -2, -1, 0 or 1. */
+ int sign_x : 2;
+ int sign_y : 2;
+ int sign_z : 2;
+} TransDataMirror;
+
typedef struct MouseInput {
void (*apply)(struct TransInfo *t, struct MouseInput *mi, const double mval[2], float output[3]);
void (*post)(struct TransInfo *t, float values[3]);
@@ -549,10 +529,18 @@ typedef struct TransDataContainer {
* Mirror option
*/
struct {
- /* Currently for mesh X mirror only. */
- int axis_flag;
- /** Set to -1.0f or 1.0 when use_mirror is set. */
- float sign;
+ union {
+ struct {
+ uint axis_x : 1;
+ uint axis_y : 1;
+ uint axis_z : 1;
+ };
+ /* For easy checking. */
+ char use_mirror_any;
+ };
+ /** Mirror data array. */
+ TransDataMirror *data;
+ int data_len;
} mirror;
TransCustomDataContainer custom;
@@ -860,16 +848,18 @@ enum {
/** For Graph Editor - curves that can only have int-values
* need their keyframes tagged with this. */
TD_INTVALUES = 1 << 15,
- /** For editmode mirror, clamp to x = 0 */
- TD_MIRROR_EDGE = 1 << 16,
+ /** For editmode mirror, clamp axis to 0 */
+ TD_MIRROR_EDGE_X = 1 << 16,
+ TD_MIRROR_EDGE_Y = 1 << 17,
+ TD_MIRROR_EDGE_Z = 1 << 18,
/** For fcurve handles, move them along with their keyframes */
- TD_MOVEHANDLE1 = 1 << 17,
- TD_MOVEHANDLE2 = 1 << 18,
+ TD_MOVEHANDLE1 = 1 << 19,
+ TD_MOVEHANDLE2 = 1 << 20,
/** Exceptional case with pose bone rotating when a parent bone has 'Local Location'
* option enabled and rotating also transforms it. */
- TD_PBONE_LOCAL_MTX_P = 1 << 19,
+ TD_PBONE_LOCAL_MTX_P = 1 << 21,
/** Same as above but for a child bone. */
- TD_PBONE_LOCAL_MTX_C = 1 << 20,
+ TD_PBONE_LOCAL_MTX_C = 1 << 22,
};
/** #TransSnap.status */
@@ -1091,11 +1081,9 @@ int getTransformOrientation(const struct bContext *C, float normal[3], float pla
void freeCustomNormalArray(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
-void freeEdgeSlideTempFaces(EdgeSlideData *sld);
void freeEdgeSlideVerts(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
void projectEdgeSlideData(TransInfo *t, bool is_final);
-void freeVertSlideTempFaces(VertSlideData *sld);
void freeVertSlideVerts(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
void projectVertSlideData(TransInfo *t, bool is_final);
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 6da03d917a6..1e783e0e7b8 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1778,18 +1778,16 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
char hflag;
bool has_face_sel = (bm->totfacesel != 0);
- if (tc->mirror.axis_flag) {
- TransData *td;
+ if (tc->mirror.use_mirror_any) {
+ TransDataMirror *tdm;
int i;
/* Rather then adjusting the selection (which the user would notice)
* tag all mirrored verts, then auto-merge those. */
BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
- for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
- if (td->extra) {
- BM_elem_flag_enable((BMVert *)td->extra, BM_ELEM_TAG);
- }
+ for (i = tc->mirror.data_len, tdm = tc->mirror.data; i--; tdm++) {
+ BM_elem_flag_enable((BMVert *)tdm->extra, BM_ELEM_TAG);
}
hflag = BM_ELEM_SELECT | BM_ELEM_TAG;
@@ -1850,26 +1848,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* on transform completion since it's
* really slow -joeedh */
projectEdgeSlideData(t, true);
-
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- EdgeSlideData *sld = tc->custom.mode.data;
-
- if (sld == NULL) {
- continue;
- }
-
- /* Free temporary faces to avoid auto-merging and deleting
- * during cleanup - psy-fi. */
- freeEdgeSlideTempFaces(sld);
- }
}
else if (t->mode == TFM_VERT_SLIDE) {
/* as above */
projectVertSlideData(t, true);
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- VertSlideData *sld = tc->custom.mode.data;
- freeVertSlideTempFaces(sld);
- }
}
if (t->obedit_type == OB_MESH) {
@@ -2264,6 +2246,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if (t->options & CTX_PAINT_CURVE) {
/* pass */
}
+ else if (t->options & CTX_SCULPT) {
+ /* pass */
+ }
else if ((t->view_layer->basact) && (ob = t->view_layer->basact->object) &&
(ob->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, ob)) {
/* do nothing */
@@ -2414,6 +2399,10 @@ void createTransData(bContext *C, TransInfo *t)
}
countAndCleanTransDataContainer(t);
}
+ else if (t->options & CTX_SCULPT) {
+ createTransSculpt(t);
+ countAndCleanTransDataContainer(t);
+ }
else if (t->options & CTX_TEXTURE) {
t->flag |= T_TEXTURE;
t->obedit_type = -1;
diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h
index ee6f181a133..53ff9952d05 100644
--- a/source/blender/editors/transform/transform_convert.h
+++ b/source/blender/editors/transform/transform_convert.h
@@ -69,6 +69,8 @@ void flushTransGraphData(TransInfo *t);
void flushTransMasking(TransInfo *t);
/* transform_convert_mesh.c */
void flushTransUVs(TransInfo *t);
+void trans_mesh_customdata_correction_init(TransInfo *t);
+void trans_mesh_customdata_correction_apply(struct TransDataContainer *tc, bool is_final);
/* transform_convert_node.c */
void flushTransNodes(TransInfo *t);
/* transform_convert_object.c */
@@ -129,6 +131,8 @@ void createTransTexspace(TransInfo *t);
void createTransPaintCurveVerts(bContext *C, TransInfo *t);
/* transform_convert_particle.c */
void createTransParticleVerts(bContext *C, TransInfo *t);
+/* transform_convert_sculpt.c */
+void createTransSculpt(TransInfo *t);
/* transform_convert_sequence.c */
void createTransSeqData(bContext *C, TransInfo *t);
/* transform_convert_tracking.c */
diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c
index 98ae15ed2dc..32239dd0bd7 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -27,8 +27,10 @@
#include "MEM_guardedalloc.h"
+#include "BLI_alloca.h"
#include "BLI_bitmap.h"
#include "BLI_math.h"
+#include "BLI_memarena.h"
#include "BLI_linklist_stack.h"
#include "BKE_context.h"
@@ -52,6 +54,9 @@
#include "transform_convert.h"
#include "bmesh.h"
+/* Used for both mirror epsilon and TD_MIRROR_EDGE_ */
+#define TRANSFORM_MAXDIST_MIRROR 0.00002f
+
/* when transforming islands */
struct TransIslandData {
float co[3];
@@ -395,6 +400,164 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em,
return trans_islands;
}
+static bool is_in_quadrant_v3(const float co[3], const int quadrant[3], const float epsilon)
+{
+ if (quadrant[0] && ((co[0] * quadrant[0]) < -epsilon)) {
+ return false;
+ }
+ if (quadrant[1] && ((co[1] * quadrant[1]) < -epsilon)) {
+ return false;
+ }
+ if (quadrant[2] && ((co[2] * quadrant[2]) < -epsilon)) {
+ return false;
+ }
+ return true;
+}
+
+static TransDataMirror *editmesh_mirror_data_calc(BMEditMesh *em,
+ bool use_select,
+ const bool use_topology,
+ const bool mirror_axis[3],
+ int *r_mirror_data_len,
+ BLI_bitmap **r_mirror_bitmap)
+{
+ BMesh *bm = em->bm;
+ int *index[3] = {NULL};
+ int i;
+
+ bool test_selected_only = use_select && (mirror_axis[0] + mirror_axis[1] + mirror_axis[2]) == 1;
+ for (i = 0; i < 3; i++) {
+ if (mirror_axis[i]) {
+ index[i] = MEM_mallocN(bm->totvert * sizeof(int), __func__);
+ EDBM_verts_mirror_cache_begin_ex(
+ em, i, false, test_selected_only, use_topology, TRANSFORM_MAXDIST_MIRROR, index[i]);
+ }
+ }
+
+ BMVert *eve;
+ BMIter iter;
+
+ int quadrant[3];
+ {
+ float select_sum[3] = {0};
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ continue;
+ }
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ add_v3_v3(select_sum, eve->co);
+ }
+ }
+
+ for (i = 0; i < 3; i++) {
+ if (mirror_axis[i]) {
+ quadrant[i] = select_sum[i] >= 0.0f ? 1 : -1;
+ }
+ else {
+ quadrant[i] = 0;
+ }
+ }
+ }
+
+ /* Tag only elements that will be transformed within the quadrant. */
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
+ if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ continue;
+ }
+ if ((!use_select || BM_elem_flag_test(eve, BM_ELEM_SELECT)) &&
+ is_in_quadrant_v3(eve->co, quadrant, TRANSFORM_MAXDIST_MIRROR)) {
+ BM_elem_flag_enable(eve, BM_ELEM_TAG);
+ BM_elem_index_set(eve, i);
+ }
+ else {
+ BM_elem_flag_disable(eve, BM_ELEM_TAG);
+ BM_elem_index_set(eve, -1);
+ }
+ }
+
+ for (int a = 0; a < 3; a++) {
+ int *index_iter = index[a];
+ if (index_iter == NULL) {
+ continue;
+ }
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
+ if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ continue;
+ }
+ if (test_selected_only && !BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ continue;
+ }
+ int elem_index = BM_elem_index_get(eve);
+ if (elem_index != -1) {
+ int i_mirr = index_iter[i];
+ if (i_mirr >= 0) {
+ BMVert *vmir = BM_vert_at_index(bm, i_mirr);
+ BM_elem_index_set(vmir, elem_index);
+
+ /* The slot of this element in the index array no longer needs to be read.
+ * Use to set the mirror sign. */
+ if (index[0] && a > 0) {
+ index[0][i_mirr] = index[0][i];
+ }
+ if (index[1] && a > 1) {
+ index[1][i_mirr] = index[1][i];
+ }
+ /* Use -2 to differ from -1, but both can work. */
+ index_iter[i_mirr] = -2;
+ }
+ }
+ }
+ }
+
+ /* Count mirror elements. */
+ uint mirror_elem_len = 0;
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
+ if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN | BM_ELEM_TAG)) {
+ /* Not a mirror element. */
+ BM_elem_index_set(eve, -1);
+ continue;
+ }
+ int elem_index = BM_elem_index_get(eve);
+ if (elem_index != -1) {
+ mirror_elem_len++;
+ }
+ }
+
+ TransDataMirror *mirror_data_iter, *mirror_data = NULL;
+ if (mirror_elem_len != 0) {
+ mirror_data = MEM_mallocN(mirror_elem_len * sizeof(*mirror_data), __func__);
+ mirror_data_iter = &mirror_data[0];
+
+ *r_mirror_bitmap = BLI_BITMAP_NEW(bm->totvert, __func__);
+
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
+ int elem_index = BM_elem_index_get(eve);
+ if (elem_index != -1) {
+ BMVert *v_src = BM_vert_at_index(bm, elem_index);
+
+ mirror_data_iter->loc_src = v_src->co;
+ mirror_data_iter->loc_dst = eve->co;
+ mirror_data_iter->sign_x = index[0] && index[0][i] == -2 ? -1 : 1;
+ mirror_data_iter->sign_y = index[1] && index[1][i] == -2 ? -1 : 1;
+ mirror_data_iter->sign_z = index[2] && index[2][i] == -2 ? -1 : 1;
+ mirror_data_iter->extra = eve;
+
+ mirror_data_iter++;
+
+ BLI_BITMAP_ENABLE(*r_mirror_bitmap, i);
+ }
+ }
+ }
+
+ MEM_SAFE_FREE(index[0]);
+ MEM_SAFE_FREE(index[1]);
+ MEM_SAFE_FREE(index[2]);
+
+ bm->elem_index_dirty |= BM_VERT;
+ *r_mirror_data_len = mirror_elem_len;
+ return mirror_data;
+}
+
/* way to overwrite what data is edited with transform */
static void VertsToTransData(TransInfo *t,
TransData *td,
@@ -448,7 +611,7 @@ static void VertsToTransData(TransInfo *t,
td->ext = NULL;
td->val = NULL;
- td->extra = NULL;
+ td->extra = eve;
if (t->mode == TFM_BWEIGHT) {
td->val = bweight;
td->ival = *bweight;
@@ -487,9 +650,7 @@ void createTransEditVerts(TransInfo *t)
float *dists = NULL;
int a;
const int prop_mode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0;
- int mirror = 0;
int cd_vert_bweight_offset = -1;
- bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
struct TransIslandData *island_info = NULL;
int island_info_tot;
@@ -510,11 +671,6 @@ void createTransEditVerts(TransInfo *t)
* Optional, allocate if needed. */
int *dists_index = NULL;
- if (tc->mirror.axis_flag) {
- EDBM_verts_mirror_cache_begin(em, 0, false, (t->flag & T_PROP_EDIT) == 0, use_topology);
- mirror = 1;
- }
-
/**
* Quick check if we can transform.
*
@@ -531,16 +687,23 @@ void createTransEditVerts(TransInfo *t)
cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
}
+ BLI_bitmap *mirror_bitmap = NULL;
+ if (tc->mirror.use_mirror_any) {
+ bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
+ bool use_select = (t->flag & T_PROP_EDIT) == 0;
+ bool mirror_axis[3] = {tc->mirror.axis_x, tc->mirror.axis_y, tc->mirror.axis_z};
+ tc->mirror.data = editmesh_mirror_data_calc(
+ em, use_select, use_topology, mirror_axis, &tc->mirror.data_len, &mirror_bitmap);
+ }
+
+ int data_len = 0;
if (prop_mode) {
- unsigned int count = 0;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- count++;
+ data_len++;
}
}
- tc->data_len = count;
-
/* allocating scratch arrays */
if (prop_mode & T_PROP_CONNECTED) {
dists = MEM_mallocN(em->bm->totvert * sizeof(float), __func__);
@@ -550,10 +713,23 @@ void createTransEditVerts(TransInfo *t)
}
}
else {
- tc->data_len = bm->totvertsel;
+ data_len = bm->totvertsel;
+ }
+
+ if (mirror_bitmap) {
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
+ if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ if (BLI_BITMAP_TEST(mirror_bitmap, a)) {
+ data_len--;
+ }
+ }
+ }
}
- tob = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Mesh EditMode)");
+ BLI_assert(data_len != 0);
+
+ tc->data_len = data_len;
+ tc->data = tob = MEM_callocN(data_len * sizeof(TransData), "TransObData(Mesh EditMode)");
if (ELEM(t->mode, TFM_SKIN_RESIZE, TFM_SHRINKFATTEN)) {
/* warning, this is overkill, we only need 2 extra floats,
* but this stores loads of extra stuff, for TFM_SHRINKFATTEN its even more overkill
@@ -622,95 +798,91 @@ void createTransEditVerts(TransInfo *t)
}
}
- /* find out which half we do */
- if (mirror) {
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && eve->co[0] != 0.0f) {
- if (eve->co[0] < 0.0f) {
- tc->mirror.sign = -1.0f;
- mirror = -1;
- }
- break;
- }
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
+ if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ continue;
}
- }
+ if (mirror_bitmap && BLI_BITMAP_TEST(mirror_bitmap, a)) {
+ continue;
+ }
+ if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ struct TransIslandData *v_island = NULL;
+ float *bweight = (cd_vert_bweight_offset != -1) ?
+ BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) :
+ NULL;
+
+ if (island_info) {
+ const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a;
+ v_island = (island_vert_map[connected_index] != -1) ?
+ &island_info[island_vert_map[connected_index]] :
+ NULL;
+ }
- BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
- if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- struct TransIslandData *v_island = NULL;
- float *bweight = (cd_vert_bweight_offset != -1) ?
- BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) :
- NULL;
-
- if (island_info) {
- const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a;
- v_island = (island_vert_map[connected_index] != -1) ?
- &island_info[island_vert_map[connected_index]] :
- NULL;
- }
+ /* Do not use the island center in case we are using islands
+ * only to get axis for snap/rotate to normal... */
+ VertsToTransData(t, tob, tx, em, eve, bweight, v_island, is_snap_rotate);
+ if (tx) {
+ tx++;
+ }
- /* Do not use the island center in case we are using islands
- * only to get axis for snap/rotate to normal... */
- VertsToTransData(t, tob, tx, em, eve, bweight, v_island, is_snap_rotate);
- if (tx) {
- tx++;
- }
+ /* selected */
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ tob->flag |= TD_SELECTED;
+ }
- /* selected */
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- tob->flag |= TD_SELECTED;
+ if (prop_mode) {
+ if (prop_mode & T_PROP_CONNECTED) {
+ tob->dist = dists[a];
}
-
- if (prop_mode) {
- if (prop_mode & T_PROP_CONNECTED) {
- tob->dist = dists[a];
- }
- else {
- tob->flag |= TD_NOTCONNECTED;
- tob->dist = FLT_MAX;
- }
+ else {
+ tob->flag |= TD_NOTCONNECTED;
+ tob->dist = FLT_MAX;
}
+ }
- /* CrazySpace */
- const bool use_quats = quats && BM_elem_flag_test(eve, BM_ELEM_TAG);
- if (use_quats || defmats) {
- float mat[3][3], qmat[3][3], imat[3][3];
+ /* CrazySpace */
+ const bool use_quats = quats && BM_elem_flag_test(eve, BM_ELEM_TAG);
+ if (use_quats || defmats) {
+ float mat[3][3], qmat[3][3], imat[3][3];
- /* Use both or either quat and defmat correction. */
- if (use_quats) {
- quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]);
+ /* Use both or either quat and defmat correction. */
+ if (use_quats) {
+ quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]);
- if (defmats) {
- mul_m3_series(mat, defmats[a], qmat, mtx);
- }
- else {
- mul_m3_m3m3(mat, mtx, qmat);
- }
+ if (defmats) {
+ mul_m3_series(mat, defmats[a], qmat, mtx);
}
else {
- mul_m3_m3m3(mat, mtx, defmats[a]);
+ mul_m3_m3m3(mat, mtx, qmat);
}
-
- invert_m3_m3(imat, mat);
-
- copy_m3_m3(tob->smtx, imat);
- copy_m3_m3(tob->mtx, mat);
}
else {
- copy_m3_m3(tob->smtx, smtx);
- copy_m3_m3(tob->mtx, mtx);
+ mul_m3_m3m3(mat, mtx, defmats[a]);
}
- /* Mirror? */
- if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) {
- BMVert *vmir = EDBM_verts_mirror_get(em, eve); // t->obedit, em, eve, tob->iloc, a);
- if (vmir && vmir != eve) {
- tob->extra = vmir;
- }
+ invert_m3_m3(imat, mat);
+
+ copy_m3_m3(tob->smtx, imat);
+ copy_m3_m3(tob->mtx, mat);
+ }
+ else {
+ copy_m3_m3(tob->smtx, smtx);
+ copy_m3_m3(tob->mtx, mtx);
+ }
+
+ if (tc->mirror.use_mirror_any) {
+ if (tc->mirror.axis_x && fabsf(tob->loc[0]) < TRANSFORM_MAXDIST_MIRROR) {
+ tob->flag |= TD_MIRROR_EDGE_X;
+ }
+ if (tc->mirror.axis_y && fabsf(tob->loc[1]) < TRANSFORM_MAXDIST_MIRROR) {
+ tob->flag |= TD_MIRROR_EDGE_Y;
+ }
+ if (tc->mirror.axis_z && fabsf(tob->loc[2]) < TRANSFORM_MAXDIST_MIRROR) {
+ tob->flag |= TD_MIRROR_EDGE_Z;
}
- tob++;
}
+
+ tob++;
}
}
@@ -719,15 +891,6 @@ void createTransEditVerts(TransInfo *t)
MEM_freeN(island_vert_map);
}
- if (mirror != 0) {
- tob = tc->data;
- for (a = 0; a < tc->data_len; a++, tob++) {
- if (ABS(tob->loc[0]) <= 0.00001f) {
- tob->flag |= TD_MIRROR_EDGE;
- }
- }
- }
-
cleanup:
/* crazy space free */
if (quats) {
@@ -742,9 +905,374 @@ void createTransEditVerts(TransInfo *t)
if (dists_index) {
MEM_freeN(dists_index);
}
+ if (mirror_bitmap) {
+ MEM_freeN(mirror_bitmap);
+ }
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name CustomData Layer Correction (for meshes)
+ *
+ * \{ */
+
+struct TransCustomDataLayerVert {
+ BMVert *v;
+ float co_orig_3d[3];
+ struct LinkNode **cd_loop_groups;
+};
+
+struct TransCustomDataLayer {
+ BMesh *bm;
+
+ int cd_loop_mdisp_offset;
+
+ /** map {BMVert: TransCustomDataLayerVert} */
+ struct GHash *origverts;
+ struct GHash *origfaces;
+ struct BMesh *bm_origfaces;
+
+ struct MemArena *arena;
+ /** Number of math BMLoop layers. */
+ int layer_math_map_num;
+ /** Array size of 'layer_math_map_num'
+ * maps TransCustomDataLayerVert.cd_group index to absolute CustomData layer index */
+ int *layer_math_map;
+
+ /* Array with all elements transformed. */
+ struct TransCustomDataLayerVert *data;
+ int data_len;
+};
+
+static void trans_mesh_customdata_free_cb(struct TransInfo *t,
+ struct TransDataContainer *tc,
+ struct TransCustomData *custom_data)
+{
+ struct TransCustomDataLayer *tcld = custom_data->data;
+ bmesh_edit_end(tcld->bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
+
+ if (tcld->bm_origfaces) {
+ BM_mesh_free(tcld->bm_origfaces);
+ }
+ if (tcld->origfaces) {
+ BLI_ghash_free(tcld->origfaces, NULL, NULL);
+ }
+ if (tcld->origverts) {
+ BLI_ghash_free(tcld->origverts, NULL, NULL);
+ }
+ if (tcld->arena) {
+ BLI_memarena_free(tcld->arena);
+ }
+ if (tcld->layer_math_map) {
+ MEM_freeN(tcld->layer_math_map);
+ }
+
+ MEM_freeN(tcld);
+ custom_data->data = NULL;
+}
+
+static void create_trans_vert_customdata_layer(BMVert *v,
+ struct TransCustomDataLayer *tcld,
+ struct TransCustomDataLayerVert *r_tcld_vert)
+{
+ BMesh *bm = tcld->bm;
+ BMIter liter;
+ int j, l_num;
+ float *loop_weights;
+
+ /* copy face data */
+ // BM_ITER_ELEM (l, &liter, sv->v, BM_LOOPS_OF_VERT) {
+ BM_iter_init(&liter, bm, BM_LOOPS_OF_VERT, v);
+ l_num = liter.count;
+ loop_weights = BLI_array_alloca(loop_weights, l_num);
+ for (j = 0; j < l_num; j++) {
+ BMLoop *l = BM_iter_step(&liter);
+ BMLoop *l_prev, *l_next;
+ void **val_p;
+ if (!BLI_ghash_ensure_p(tcld->origfaces, l->f, &val_p)) {
+ BMFace *f_copy = BM_face_copy(tcld->bm_origfaces, bm, l->f, true, true);
+ *val_p = f_copy;
+ }
+
+ if ((l_prev = BM_loop_find_prev_nodouble(l, l->next, FLT_EPSILON)) &&
+ (l_next = BM_loop_find_next_nodouble(l, l_prev, FLT_EPSILON))) {
+ loop_weights[j] = angle_v3v3v3(l_prev->v->co, l->v->co, l_next->v->co);
+ }
+ else {
+ loop_weights[j] = 0.0f;
+ }
+ }
+
+ /* store cd_loop_groups */
+ if (tcld->layer_math_map_num && (l_num != 0)) {
+ r_tcld_vert->cd_loop_groups = BLI_memarena_alloc(tcld->arena,
+ tcld->layer_math_map_num * sizeof(void *));
+ for (j = 0; j < tcld->layer_math_map_num; j++) {
+ const int layer_nr = tcld->layer_math_map[j];
+ r_tcld_vert->cd_loop_groups[j] = BM_vert_loop_groups_data_layer_create(
+ bm, v, layer_nr, loop_weights, tcld->arena);
+ }
+ }
+ else {
+ r_tcld_vert->cd_loop_groups = NULL;
+ }
+
+ r_tcld_vert->v = v;
+ copy_v3_v3(r_tcld_vert->co_orig_3d, v->co);
+ BLI_ghash_insert(tcld->origverts, v, r_tcld_vert);
+}
+
+void trans_mesh_customdata_correction_init(TransInfo *t)
+{
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ BLI_assert(tc->custom.type.data == NULL);
+ int i;
+
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
+ BMesh *bm = em->bm;
+
+ bool use_origfaces;
+ int cd_loop_mdisp_offset;
+ {
+ const bool has_layer_math = CustomData_has_math(&bm->ldata);
+ cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
+ if ((t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) &&
+ /* don't do this at all for non-basis shape keys, too easy to
+ * accidentally break uv maps or vertex colors then */
+ (bm->shapenr <= 1) && (has_layer_math || (cd_loop_mdisp_offset != -1))) {
+ use_origfaces = true;
+ cd_loop_mdisp_offset = cd_loop_mdisp_offset;
+ }
+ else {
+ use_origfaces = false;
+ cd_loop_mdisp_offset = -1;
+ }
+ }
+
+ if (use_origfaces) {
+ /* create copies of faces for customdata projection */
+ bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
+
+ struct GHash *origfaces = BLI_ghash_ptr_new(__func__);
+ struct BMesh *bm_origfaces = BM_mesh_create(&bm_mesh_allocsize_default,
+ &((struct BMeshCreateParams){
+ .use_toolflags = false,
+ }));
+
+ /* we need to have matching customdata */
+ BM_mesh_copy_init_customdata(bm_origfaces, bm, NULL);
+
+ int *layer_math_map = NULL;
+ int layer_index_dst = 0;
+ {
+ /* TODO: We don't need `sod->layer_math_map` when there are no loops linked
+ * to one of the sliding vertices. */
+ if (CustomData_has_math(&bm->ldata)) {
+ /* over alloc, only 'math' layers are indexed */
+ layer_math_map = MEM_mallocN(bm->ldata.totlayer * sizeof(int), __func__);
+ for (i = 0; i < bm->ldata.totlayer; i++) {
+ if (CustomData_layer_has_math(&bm->ldata, i)) {
+ layer_math_map[layer_index_dst++] = i;
+ }
+ }
+ BLI_assert(layer_index_dst != 0);
+ }
+ }
+
+ struct TransCustomDataLayer *tcld;
+ tc->custom.type.data = tcld = MEM_mallocN(sizeof(*tcld), __func__);
+ tc->custom.type.free_cb = trans_mesh_customdata_free_cb;
+
+ tcld->bm = bm;
+ tcld->origfaces = origfaces;
+ tcld->bm_origfaces = bm_origfaces;
+ tcld->cd_loop_mdisp_offset = cd_loop_mdisp_offset;
+ tcld->layer_math_map = layer_math_map;
+ tcld->layer_math_map_num = layer_index_dst;
+ tcld->arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
+
+ int data_len = tc->data_len + tc->mirror.data_len;
+ struct GHash *origverts = BLI_ghash_ptr_new_ex(__func__, data_len);
+ tcld->origverts = origverts;
+
+ struct TransCustomDataLayerVert *tcld_vert, *tcld_vert_iter;
+ tcld_vert = BLI_memarena_alloc(tcld->arena, data_len * sizeof(*tcld_vert));
+ tcld_vert_iter = &tcld_vert[0];
+
+ TransData *tob;
+ for (i = tc->data_len, tob = tc->data; i--; tob++, tcld_vert_iter++) {
+ BMVert *v = tob->extra;
+ create_trans_vert_customdata_layer(v, tcld, tcld_vert_iter);
+ }
+
+ TransDataMirror *tdm;
+ for (i = tc->mirror.data_len, tdm = tc->mirror.data; i--; tdm++, tcld_vert_iter++) {
+ BMVert *v = tdm->extra;
+ create_trans_vert_customdata_layer(v, tcld, tcld_vert_iter);
+ }
+
+ tcld->data = tcld_vert;
+ tcld->data_len = data_len;
+ }
+ }
+}
+
+/**
+ * If we're sliding the vert, return its original location, if not, the current location is good.
+ */
+static const float *trans_vert_orig_co_get(struct TransCustomDataLayer *tcld, BMVert *v)
+{
+ struct TransCustomDataLayerVert *tcld_vert = BLI_ghash_lookup(tcld->origverts, v);
+ return tcld_vert ? tcld_vert->co_orig_3d : v->co;
+}
+
+static void trans_mesh_customdata_correction_apply_vert(struct TransCustomDataLayer *tcld,
+ struct TransCustomDataLayerVert *tcld_vert,
+ bool is_final)
+{
+ BMesh *bm = tcld->bm;
+ BMVert *v = tcld_vert->v;
+ const float *co_orig_3d = tcld_vert->co_orig_3d;
+ struct LinkNode **cd_loop_groups = tcld_vert->cd_loop_groups;
+
+ BMIter liter;
+ int j, l_num;
+ float *loop_weights;
+ const bool is_moved = (len_squared_v3v3(v->co, co_orig_3d) > FLT_EPSILON);
+ const bool do_loop_weight = tcld->layer_math_map_num && is_moved;
+ const bool do_loop_mdisps = is_final && is_moved && (tcld->cd_loop_mdisp_offset != -1);
+ const float *v_proj_axis = v->no;
+ /* original (l->prev, l, l->next) projections for each loop ('l' remains unchanged) */
+ float v_proj[3][3];
+
+ if (do_loop_weight || do_loop_mdisps) {
+ project_plane_normalized_v3_v3v3(v_proj[1], co_orig_3d, v_proj_axis);
+ }
+
+ // BM_ITER_ELEM (l, &liter, sv->v, BM_LOOPS_OF_VERT)
+ BM_iter_init(&liter, bm, BM_LOOPS_OF_VERT, v);
+ l_num = liter.count;
+ loop_weights = do_loop_weight ? BLI_array_alloca(loop_weights, l_num) : NULL;
+ for (j = 0; j < l_num; j++) {
+ BMFace *f_copy; /* the copy of 'f' */
+ BMLoop *l = BM_iter_step(&liter);
+
+ f_copy = BLI_ghash_lookup(tcld->origfaces, l->f);
+
+ /* only loop data, no vertex data since that contains shape keys,
+ * and we do not want to mess up other shape keys */
+ BM_loop_interp_from_face(bm, l, f_copy, false, false);
+
+ /* make sure face-attributes are correct (e.g. #MLoopUV, #MLoopCol) */
+ BM_elem_attrs_copy_ex(tcld->bm_origfaces, bm, f_copy, l->f, 0x0, CD_MASK_NORMAL);
+
+ /* weight the loop */
+ if (do_loop_weight) {
+ const float eps = 1.0e-8f;
+ const BMLoop *l_prev = l->prev;
+ const BMLoop *l_next = l->next;
+ const float *co_prev = trans_vert_orig_co_get(tcld, l_prev->v);
+ const float *co_next = trans_vert_orig_co_get(tcld, l_next->v);
+ bool co_prev_ok;
+ bool co_next_ok;
+
+ /* In the unlikely case that we're next to a zero length edge -
+ * walk around the to the next.
+ *
+ * Since we only need to check if the vertex is in this corner,
+ * its not important _which_ loop - as long as its not overlapping
+ * 'sv->co_orig_3d', see: T45096. */
+ project_plane_normalized_v3_v3v3(v_proj[0], co_prev, v_proj_axis);
+ while (UNLIKELY(((co_prev_ok = (len_squared_v3v3(v_proj[1], v_proj[0]) > eps)) == false) &&
+ ((l_prev = l_prev->prev) != l->next))) {
+ co_prev = trans_vert_orig_co_get(tcld, l_prev->v);
+ project_plane_normalized_v3_v3v3(v_proj[0], co_prev, v_proj_axis);
+ }
+ project_plane_normalized_v3_v3v3(v_proj[2], co_next, v_proj_axis);
+ while (UNLIKELY(((co_next_ok = (len_squared_v3v3(v_proj[1], v_proj[2]) > eps)) == false) &&
+ ((l_next = l_next->next) != l->prev))) {
+ co_next = trans_vert_orig_co_get(tcld, l_next->v);
+ project_plane_normalized_v3_v3v3(v_proj[2], co_next, v_proj_axis);
+ }
+
+ if (co_prev_ok && co_next_ok) {
+ const float dist = dist_signed_squared_to_corner_v3v3v3(
+ v->co, UNPACK3(v_proj), v_proj_axis);
+
+ loop_weights[j] = (dist >= 0.0f) ? 1.0f : ((dist <= -eps) ? 0.0f : (1.0f + (dist / eps)));
+ if (UNLIKELY(!isfinite(loop_weights[j]))) {
+ loop_weights[j] = 0.0f;
+ }
+ }
+ else {
+ loop_weights[j] = 0.0f;
+ }
+ }
+ }
+
+ if (tcld->layer_math_map_num && cd_loop_groups) {
+ if (do_loop_weight) {
+ for (j = 0; j < tcld->layer_math_map_num; j++) {
+ BM_vert_loop_groups_data_layer_merge_weights(
+ bm, cd_loop_groups[j], tcld->layer_math_map[j], loop_weights);
+ }
+ }
+ else {
+ for (j = 0; j < tcld->layer_math_map_num; j++) {
+ BM_vert_loop_groups_data_layer_merge(bm, cd_loop_groups[j], tcld->layer_math_map[j]);
+ }
+ }
+ }
+
+ /* Special handling for multires
+ *
+ * Interpolate from every other loop (not ideal)
+ * However values will only be taken from loops which overlap other mdisps.
+ * */
+ if (do_loop_mdisps) {
+ float(*faces_center)[3] = BLI_array_alloca(faces_center, l_num);
+ BMLoop *l;
+
+ BM_ITER_ELEM_INDEX (l, &liter, v, BM_LOOPS_OF_VERT, j) {
+ BM_face_calc_center_median(l->f, faces_center[j]);
+ }
+
+ BM_ITER_ELEM_INDEX (l, &liter, v, BM_LOOPS_OF_VERT, j) {
+ BMFace *f_copy = BLI_ghash_lookup(tcld->origfaces, l->f);
+ float f_copy_center[3];
+ BMIter liter_other;
+ BMLoop *l_other;
+ int j_other;
+
+ BM_face_calc_center_median(f_copy, f_copy_center);
+
+ BM_ITER_ELEM_INDEX (l_other, &liter_other, v, BM_LOOPS_OF_VERT, j_other) {
+ BM_face_interp_multires_ex(bm,
+ l_other->f,
+ f_copy,
+ faces_center[j_other],
+ f_copy_center,
+ tcld->cd_loop_mdisp_offset);
+ }
+ }
+ }
+}
+
+void trans_mesh_customdata_correction_apply(struct TransDataContainer *tc, bool is_final)
+{
+ struct TransCustomDataLayer *tcld = tc->custom.type.data;
+ if (!tcld) {
+ return;
+ }
+
+ const bool has_mdisps = (tcld->cd_loop_mdisp_offset != -1);
+ struct TransCustomDataLayerVert *tcld_vert_iter = &tcld->data[0];
- if (tc->mirror.axis_flag) {
- EDBM_verts_mirror_cache_end(em);
+ for (int i = tcld->data_len; i--; tcld_vert_iter++) {
+ if (tcld_vert_iter->cd_loop_groups || has_mdisps) {
+ trans_mesh_customdata_correction_apply_vert(tcld, tcld_vert_iter, is_final);
}
}
}
diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c
index 6fe3c74e233..6142e9628a4 100644
--- a/source/blender/editors/transform/transform_convert_object.c
+++ b/source/blender/editors/transform/transform_convert_object.c
@@ -148,7 +148,13 @@ void trans_obdata_in_obmode_update_all(TransInfo *t)
invert_m4(dmat);
ED_object_data_xform_by_mat4(xf->xod, dmat);
- DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
+ if (xf->ob->type == OB_ARMATURE) {
+ /* TODO: none of the current flags properly update armatures, needs investigation. */
+ DEG_id_tag_update(id, 0);
+ }
+ else {
+ DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
+ }
}
}
@@ -519,7 +525,7 @@ static void set_trans_object_base_flags(TransInfo *t)
ViewLayer *view_layer = t->view_layer;
View3D *v3d = t->view;
Scene *scene = t->scene;
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
/* NOTE: if Base selected and has parent selected:
* base->flag_legacy = BA_WAS_SEL
*/
@@ -592,8 +598,9 @@ static int count_proportional_objects(TransInfo *t)
int total = 0;
ViewLayer *view_layer = t->view_layer;
View3D *v3d = t->view;
+ struct Main *bmain = CTX_data_main(t->context);
Scene *scene = t->scene;
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
/* Clear all flags we need. It will be used to detect dependencies. */
trans_object_base_deps_flag_prepare(view_layer);
/* Rotations around local centers are allowed to propagate, so we take all objects. */
diff --git a/source/blender/editors/transform/transform_convert_sculpt.c b/source/blender/editors/transform/transform_convert_sculpt.c
new file mode 100644
index 00000000000..b02ad71da07
--- /dev/null
+++ b/source/blender/editors/transform/transform_convert_sculpt.c
@@ -0,0 +1,101 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edtransform
+ */
+
+#include "DNA_space_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "BKE_context.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
+#include "BKE_paint.h"
+
+#include "transform.h"
+#include "transform_convert.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Sculpt Transform Creation
+ *
+ * \{ */
+
+void createTransSculpt(TransInfo *t)
+{
+ TransData *td;
+
+ Scene *scene = t->scene;
+ if (ID_IS_LINKED(scene)) {
+ BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
+ return;
+ }
+
+ Object *ob = CTX_data_active_object(t->context);
+ SculptSession *ss = ob->sculpt;
+
+ {
+ BLI_assert(t->data_container_len == 1);
+ TransDataContainer *tc = t->data_container;
+ tc->data_len = 1;
+ tc->is_active = 1;
+ td = tc->data = MEM_callocN(sizeof(TransData), "TransTexspace");
+ td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
+ }
+
+ td->flag = TD_SELECTED;
+ copy_v3_v3(td->center, ss->pivot_pos);
+ td->ob = NULL;
+
+ float tquat[4];
+ normalize_qt_qt(tquat, ss->pivot_rot);
+ quat_to_mat3(td->axismtx, tquat);
+
+ td->loc = ss->pivot_pos;
+ copy_v3_v3(td->iloc, ss->pivot_pos);
+
+ if (is_zero_v4(ss->pivot_rot)) {
+ ss->pivot_rot[3] = 1.0f;
+ }
+
+ td->ext->rot = NULL;
+ td->ext->rotAxis = NULL;
+ td->ext->rotAngle = NULL;
+ td->ext->quat = ss->pivot_rot;
+
+ copy_qt_qt(td->ext->iquat, ss->pivot_rot);
+ td->ext->rotOrder = ROT_MODE_QUAT;
+
+ ss->pivot_scale[0] = 1.0f;
+ ss->pivot_scale[1] = 1.0f;
+ ss->pivot_scale[2] = 1.0f;
+ td->ext->size = ss->pivot_scale;
+ copy_v3_v3(td->ext->isize, ss->pivot_scale);
+
+ float obmat_inv[3][3];
+ copy_m3_m4(obmat_inv, ob->obmat);
+ invert_m3(obmat_inv);
+ copy_m3_m3(td->smtx, obmat_inv);
+ copy_m3_m4(td->mtx, ob->obmat);
+}
+
+/** \} */
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index c4da7780a22..e4d3c9abceb 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -99,6 +99,7 @@
#include "ED_clip.h"
#include "ED_screen.h"
#include "ED_gpencil.h"
+#include "ED_sculpt.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -223,35 +224,31 @@ static void clipMirrorModifier(TransInfo *t)
}
/* assumes obedit set to mesh object */
-static void editbmesh_apply_to_mirror(TransInfo *t)
+static void transform_apply_to_mirror(TransInfo *t)
{
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- if (tc->mirror.axis_flag) {
- TransData *td = tc->data;
- BMVert *eve;
+ if (tc->mirror.use_mirror_any) {
int i;
-
- for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION) {
- break;
- }
- if (td->loc == NULL) {
- break;
- }
- if (td->flag & TD_SKIP) {
- continue;
- }
-
- eve = td->extra;
- if (eve) {
- eve->co[0] = -td->loc[0];
- eve->co[1] = td->loc[1];
- eve->co[2] = td->loc[2];
+ TransData *td;
+ for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
+ if (td->flag & (TD_MIRROR_EDGE_X | TD_MIRROR_EDGE_Y | TD_MIRROR_EDGE_Z)) {
+ if (td->flag & TD_MIRROR_EDGE_X) {
+ td->loc[0] = 0.0f;
+ }
+ if (td->flag & TD_MIRROR_EDGE_Y) {
+ td->loc[1] = 0.0f;
+ }
+ if (td->flag & TD_MIRROR_EDGE_Z) {
+ td->loc[2] = 0.0f;
+ }
}
+ }
- if (td->flag & TD_MIRROR_EDGE) {
- td->loc[0] = 0;
- }
+ TransDataMirror *tdm;
+ for (i = 0, tdm = tc->mirror.data; i < tc->mirror.data_len; i++, tdm++) {
+ tdm->loc_dst[0] = tdm->loc_src[0] * tdm->sign_x;
+ tdm->loc_dst[1] = tdm->loc_src[1] * tdm->sign_y;
+ tdm->loc_dst[2] = tdm->loc_src[2] * tdm->sign_z;
}
}
}
@@ -888,7 +885,7 @@ static void recalcData_objects(TransInfo *t)
clipMirrorModifier(t);
}
if ((t->flag & T_NO_MIRROR) == 0 && (t->options & CTX_NO_MIRROR) == 0) {
- editbmesh_apply_to_mirror(t);
+ transform_apply_to_mirror(t);
}
if (t->mode == TFM_EDGE_SLIDE) {
@@ -1206,6 +1203,11 @@ static void recalcData_gpencil_strokes(TransInfo *t)
}
}
+static void recalcData_sculpt(TransInfo *t)
+{
+ ED_sculpt_update_modal_transform(t->context);
+}
+
/* called for updating while transform acts, once per redraw */
void recalcData(TransInfo *t)
{
@@ -1226,6 +1228,9 @@ void recalcData(TransInfo *t)
/* set recalc triangle cache flag */
recalcData_gpencil_strokes(t);
}
+ if (t->options & CTX_SCULPT) {
+ recalcData_sculpt(t);
+ }
else if (t->spacetype == SPACE_IMAGE) {
recalcData_image(t);
}
@@ -1352,11 +1357,12 @@ void initTransDataContainers_FromObjectData(TransInfo *t,
for (int i = 0; i < objects_len; i++) {
TransDataContainer *tc = &t->data_container[i];
- /* TODO, multiple axes. */
- tc->mirror.axis_flag = (((t->flag & T_NO_MIRROR) == 0) &&
- ((t->options & CTX_NO_MIRROR) == 0) &&
- (objects[i]->type == OB_MESH) &&
- (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_X) != 0);
+ if (((t->flag & T_NO_MIRROR) == 0) && ((t->options & CTX_NO_MIRROR) == 0) &&
+ (objects[i]->type == OB_MESH)) {
+ tc->mirror.axis_x = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_X) != 0;
+ tc->mirror.axis_y = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_Y) != 0;
+ tc->mirror.axis_z = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_Z) != 0;
+ }
if (object_mode & OB_MODE_EDIT) {
tc->obedit = objects[i];
@@ -1893,6 +1899,7 @@ void postTrans(bContext *C, TransInfo *t)
MEM_SAFE_FREE(tc->data_ext);
MEM_SAFE_FREE(tc->data_2d);
+ MEM_SAFE_FREE(tc->mirror.data);
}
}
@@ -2340,11 +2347,6 @@ void calculatePropRatio(TransInfo *t)
if (td->flag & TD_SELECTED) {
td->factor = 1.0f;
}
- else if (tc->mirror.axis_flag && (td->loc[0] * tc->mirror.sign) < -0.00001f) {
- td->flag |= TD_SKIP;
- td->factor = 0.0f;
- restoreElement(td);
- }
else if ((connected && (td->flag & TD_NOTCONNECTED || td->dist > t->prop_size)) ||
(connected == 0 && td->rdist > t->prop_size)) {
/*
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 64fdbe5f8b1..bd8cf047db7 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -55,6 +55,7 @@
#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "BKE_object.h"
+#include "BKE_paint.h"
#include "DEG_depsgraph.h"
@@ -1056,7 +1057,13 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
}
}
else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
- /* pass */
+ if (ob->mode & OB_MODE_SCULPT) {
+ totsel = 1;
+ calc_tw_center_with_matrix(tbounds, ob->sculpt->pivot_pos, false, ob->obmat);
+ mul_m4_v3(ob->obmat, tbounds->center);
+ mul_m4_v3(ob->obmat, tbounds->min);
+ mul_m4_v3(ob->obmat, tbounds->max);
+ }
}
else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
PTCacheEdit *edit = PE_get_current(scene, ob);
@@ -1168,6 +1175,10 @@ static void gizmo_prepare_mat(const bContext *C,
if (gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)) {
/* pass */
}
+ else if (ob->sculpt) {
+ SculptSession *ss = ob->sculpt;
+ copy_v3_v3(rv3d->twmat[3], ss->pivot_pos);
+ }
else if (ob != NULL) {
ED_object_calc_active_center(ob, false, rv3d->twmat[3]);
}
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index a601a1fad21..76797339cea 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1272,8 +1272,7 @@ static short snap_mesh_polygon(SnapObjectContext *sctx,
const MPoly *mp = &((SnapObjectData_Mesh *)sod)->poly[*r_index];
const MLoop *ml = &treedata->loop[mp->loopstart];
- if (snapdata->snap_to_flag &
- (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
elem = SCE_SNAP_MODE_EDGE;
BLI_assert(treedata->edge != NULL);
for (int i = mp->totloop; i--; ml++) {
@@ -1310,8 +1309,7 @@ static short snap_mesh_polygon(SnapObjectContext *sctx,
BMFace *f = BM_face_at_index(em->bm, *r_index);
BMLoop *l_iter, *l_first;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- if (snapdata->snap_to_flag &
- (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
elem = SCE_SNAP_MODE_EDGE;
BM_mesh_elem_index_ensure(em->bm, BM_EDGE);
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE);
@@ -1380,22 +1378,6 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx,
return elem;
}
- float lpmat[4][4];
- mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
-
- struct DistProjectedAABBPrecalc neasrest_precalc;
- dist_squared_to_projected_aabb_precalc(
- &neasrest_precalc, lpmat, snapdata->win_size, snapdata->mval);
-
- Nearest2dUserData nearest2d = {
- .is_persp = snapdata->view_proj == VIEW_PROJ_PERSP,
- };
-
- BVHTreeNearest nearest = {
- .index = -1,
- .dist_sq = SQUARE(original_dist_px),
- };
-
SnapObjectData *sod = BLI_ghash_lookup(sctx->cache.object_map, ob);
if (sod == NULL) {
/* The object is in edit mode, and the key used
@@ -1406,18 +1388,22 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx,
BLI_assert(sod != NULL);
- if (sod->type == SNAP_MESH) {
- nearest2d.userdata = &((SnapObjectData_Mesh *)sod)->treedata;
- nearest2d.get_vert_co = (Nearest2DGetVertCoCallback)cb_mvert_co_get;
- nearest2d.get_edge_verts_index = (Nearest2DGetEdgeVertsCallback)cb_medge_verts_get;
- nearest2d.copy_vert_no = (Nearest2DCopyVertNoCallback)cb_mvert_no_copy;
- }
- else {
- BLI_assert(sod->type == SNAP_EDIT_MESH);
- nearest2d.userdata = BKE_editmesh_from_object(ob);
- nearest2d.get_vert_co = (Nearest2DGetVertCoCallback)cb_bvert_co_get;
- nearest2d.get_edge_verts_index = (Nearest2DGetEdgeVertsCallback)cb_bedge_verts_get;
- nearest2d.copy_vert_no = (Nearest2DCopyVertNoCallback)cb_bvert_no_copy;
+ Nearest2dUserData nearest2d;
+ {
+ nearest2d.is_persp = snapdata->view_proj == VIEW_PROJ_PERSP;
+ if (sod->type == SNAP_MESH) {
+ nearest2d.userdata = &((SnapObjectData_Mesh *)sod)->treedata;
+ nearest2d.get_vert_co = (Nearest2DGetVertCoCallback)cb_mvert_co_get;
+ nearest2d.get_edge_verts_index = (Nearest2DGetEdgeVertsCallback)cb_medge_verts_get;
+ nearest2d.copy_vert_no = (Nearest2DCopyVertNoCallback)cb_mvert_no_copy;
+ }
+ else {
+ BLI_assert(sod->type == SNAP_EDIT_MESH);
+ nearest2d.userdata = BKE_editmesh_from_object(ob);
+ nearest2d.get_vert_co = (Nearest2DGetVertCoCallback)cb_bvert_co_get;
+ nearest2d.get_edge_verts_index = (Nearest2DGetEdgeVertsCallback)cb_bedge_verts_get;
+ nearest2d.copy_vert_no = (Nearest2DCopyVertNoCallback)cb_bvert_no_copy;
+ }
}
int vindex[2];
@@ -1427,6 +1413,20 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx,
nearest2d.get_vert_co(vindex[0], &v_pair[0], nearest2d.userdata);
nearest2d.get_vert_co(vindex[1], &v_pair[1], nearest2d.userdata);
+ struct DistProjectedAABBPrecalc neasrest_precalc;
+ {
+ float lpmat[4][4];
+ mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
+
+ dist_squared_to_projected_aabb_precalc(
+ &neasrest_precalc, lpmat, snapdata->win_size, snapdata->mval);
+ }
+
+ BVHTreeNearest nearest = {
+ .index = -1,
+ .dist_sq = SQUARE(original_dist_px),
+ };
+
float lambda;
if (!isect_ray_seg_v3(neasrest_precalc.ray_origin,
neasrest_precalc.ray_direction,
@@ -1493,21 +1493,25 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx,
if (IN_RANGE(lambda, 0.0f, 1.0f)) {
interp_v3_v3v3(v_near, va_g, vb_g, lambda);
- if ((len_squared_v3v3(prev_co, v_near) > FLT_EPSILON) &&
- test_projected_vert_dist(&neasrest_precalc,
- NULL,
- 0,
- nearest2d.is_persp,
- v_near,
- &nearest.dist_sq,
- nearest.co)) {
- float v_nor[2][3];
- nearest2d.copy_vert_no(vindex[0], v_nor[0], nearest2d.userdata);
- nearest2d.copy_vert_no(vindex[1], v_nor[1], nearest2d.userdata);
- mid_v3_v3v3(nearest.no, v_nor[0], v_nor[1]);
+ if (len_squared_v3v3(prev_co, v_near) > FLT_EPSILON) {
+ dist_squared_to_projected_aabb_precalc(
+ &neasrest_precalc, snapdata->pmat, snapdata->win_size, snapdata->mval);
- nearest.index = *r_index;
- elem = SCE_SNAP_MODE_EDGE_PERPENDICULAR;
+ if (test_projected_vert_dist(&neasrest_precalc,
+ NULL,
+ 0,
+ nearest2d.is_persp,
+ v_near,
+ &nearest.dist_sq,
+ nearest.co)) {
+ float v_nor[2][3];
+ nearest2d.copy_vert_no(vindex[0], v_nor[0], nearest2d.userdata);
+ nearest2d.copy_vert_no(vindex[1], v_nor[1], nearest2d.userdata);
+ mid_v3_v3v3(nearest.no, v_nor[0], v_nor[1]);
+
+ nearest.index = *r_index;
+ elem = SCE_SNAP_MODE_EDGE_PERPENDICULAR;
+ }
}
}
}
@@ -2139,8 +2143,7 @@ static short snapMesh(SnapObjectContext *sctx,
last_index = nearest.index;
}
- if (snapdata->snap_to_flag &
- (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
if (bvhtree[0]) {
/* snap to loose edges */
BLI_bvhtree_find_nearest_projected(bvhtree[0],
@@ -2306,8 +2309,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
}
}
- if (snapdata->snap_to_flag &
- (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
if (sod->bvh_trees[1] == NULL) {
sod->bvh_trees[1] = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(**sod->bvh_trees));
}
@@ -2363,7 +2365,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
mul_v4_m4v4(clip_planes_local[i], tobmat, snapdata->clip_plane[i]);
}
- if (treedata_vert && snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
+ if (treedata_vert && (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX)) {
BM_mesh_elem_table_ensure(em->bm, BM_VERT);
BLI_bvhtree_find_nearest_projected(treedata_vert->tree,
lpmat,
@@ -2376,8 +2378,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
&nearest2d);
}
- if (treedata_edge && snapdata->snap_to_flag & (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT |
- SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
+ if (treedata_edge && (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE)) {
int last_index = nearest.index;
nearest.index = -1;
BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_VERT);
@@ -2791,11 +2792,11 @@ static short transform_snap_context_project_view3d_mixed_impl(
0);
short retval = 0;
- bool has_hit = false;
- int index = -1;
- float loc[3], no[3], obmat[4][4];
+ bool has_hit = false;
Object *ob = NULL;
+ float loc[3], no[3], obmat[4][4];
+ int index = -1;
const ARegion *ar = sctx->v3d_data.ar;
const RegionView3D *rv3d = ar->regiondata;
@@ -2804,7 +2805,6 @@ static short transform_snap_context_project_view3d_mixed_impl(
if (snap_to_flag & SCE_SNAP_MODE_FACE || use_occlusion_test) {
float ray_start[3], ray_normal[3];
-
if (!ED_view3d_win_to_ray_clipped_ex(sctx->depsgraph,
sctx->v3d_data.ar,
sctx->v3d_data.v3d,
@@ -2823,12 +2823,26 @@ static short transform_snap_context_project_view3d_mixed_impl(
if (has_hit && (snap_to_flag & SCE_SNAP_MODE_FACE)) {
retval = SCE_SNAP_MODE_FACE;
+
+ copy_v3_v3(r_loc, loc);
+ if (r_no) {
+ copy_v3_v3(r_no, no);
+ }
+ if (r_ob) {
+ *r_ob = ob;
+ }
+ if (r_obmat) {
+ copy_m4_m4(r_obmat, obmat);
+ }
+ if (r_index) {
+ *r_index = index;
+ }
}
}
if (snap_to_flag & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT |
SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
- short elem;
+ short elem_test, elem = 0;
float dist_px_tmp = *dist_px;
SnapData snapdata;
@@ -2836,9 +2850,14 @@ static short transform_snap_context_project_view3d_mixed_impl(
snapdata.win_size[0] = ar->winx;
snapdata.win_size[1] = ar->winy;
copy_v2_v2(snapdata.mval, mval);
- snapdata.snap_to_flag = snap_to_flag;
snapdata.view_proj = rv3d->is_persp ? VIEW_PROJ_PERSP : VIEW_PROJ_ORTHO;
+ /* First snap to edge instead of middle or perpendicular. */
+ snapdata.snap_to_flag = snap_to_flag & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE);
+ if (snap_to_flag & (SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
+ snapdata.snap_to_flag |= SCE_SNAP_MODE_EDGE;
+ }
+
planes_from_projmat(
snapdata.pmat, NULL, NULL, NULL, NULL, snapdata.clip_plane[0], snapdata.clip_plane[1]);
@@ -2859,10 +2878,9 @@ static short transform_snap_context_project_view3d_mixed_impl(
new_clipplane[3] += 0.01f;
/* Try to snap only to the polygon. */
- elem = snap_mesh_polygon(sctx, &snapdata, ob, obmat, &dist_px_tmp, loc, no, &index);
-
- if (elem) {
- retval = elem;
+ elem_test = snap_mesh_polygon(sctx, &snapdata, ob, obmat, &dist_px_tmp, loc, no, &index);
+ if (elem_test) {
+ elem = elem_test;
}
/* Add the new clip plane to the beginning of the list. */
@@ -2874,45 +2892,41 @@ static short transform_snap_context_project_view3d_mixed_impl(
snapdata.has_occlusion_plane = true;
}
- elem = snapObjectsRay(sctx, &snapdata, params, &dist_px_tmp, loc, no, &index, &ob, obmat);
-
- if (elem) {
- retval = elem;
+ elem_test = snapObjectsRay(sctx, &snapdata, params, &dist_px_tmp, loc, no, &index, &ob, obmat);
+ if (elem_test) {
+ elem = elem_test;
}
- if ((retval == SCE_SNAP_MODE_EDGE) &&
+ if ((elem == SCE_SNAP_MODE_EDGE) &&
(snap_to_flag & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE_MIDPOINT |
SCE_SNAP_MODE_EDGE_PERPENDICULAR))) {
+ snapdata.snap_to_flag = snap_to_flag;
elem = snap_mesh_edge_verts_mixed(
sctx, &snapdata, ob, obmat, *dist_px, prev_co, &dist_px_tmp, loc, no, &index);
}
- if (elem) {
+ if (elem & snap_to_flag) {
retval = elem;
- }
- retval &= snap_to_flag;
- *dist_px = dist_px_tmp;
- }
+ copy_v3_v3(r_loc, loc);
+ if (r_no) {
+ copy_v3_v3(r_no, no);
+ }
+ if (r_ob) {
+ *r_ob = ob;
+ }
+ if (r_obmat) {
+ copy_m4_m4(r_obmat, obmat);
+ }
+ if (r_index) {
+ *r_index = index;
+ }
- if (retval) {
- copy_v3_v3(r_loc, loc);
- if (r_no) {
- copy_v3_v3(r_no, no);
+ *dist_px = dist_px_tmp;
}
- if (r_ob) {
- *r_ob = ob;
- }
- if (r_obmat) {
- copy_m4_m4(r_obmat, obmat);
- }
- if (r_index) {
- *r_index = index;
- }
- return retval;
}
- return 0;
+ return retval;
}
short ED_transform_snap_object_project_view3d_ex(SnapObjectContext *sctx,
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index df927726e82..315a4c73e5f 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -172,7 +172,7 @@ static int ed_undo_step_impl(
/* Note: ignore grease pencil for now. */
Main *bmain = CTX_data_main(C);
wm->op_undo_depth++;
- BKE_callback_exec(
+ BKE_callback_exec_id(
bmain, &scene->id, (step_for_callback > 0) ? BKE_CB_EVT_UNDO_PRE : BKE_CB_EVT_REDO_PRE);
wm->op_undo_depth--;
}
@@ -220,7 +220,7 @@ static int ed_undo_step_impl(
Main *bmain = CTX_data_main(C);
scene = CTX_data_scene(C);
wm->op_undo_depth++;
- BKE_callback_exec(
+ BKE_callback_exec_id(
bmain, &scene->id, step_for_callback > 0 ? BKE_CB_EVT_UNDO_POST : BKE_CB_EVT_REDO_POST);
wm->op_undo_depth--;
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index eb4c16a7cfb..06087cd7fa6 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -160,7 +160,8 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
_nodetree_hash = BLI_ghash_ptr_new("BlenderStrokeRenderer::_nodetree_hash");
// Depsgraph
- freestyle_depsgraph = DEG_graph_new(freestyle_scene, view_layer, DAG_EVAL_RENDER);
+ freestyle_depsgraph = DEG_graph_new(
+ freestyle_bmain, freestyle_scene, view_layer, DAG_EVAL_RENDER);
DEG_graph_id_tag_update(freestyle_bmain, freestyle_depsgraph, &freestyle_scene->id, 0);
DEG_graph_id_tag_update(freestyle_bmain, freestyle_depsgraph, &object_camera->id, 0);
DEG_graph_tag_relations_update(freestyle_depsgraph);
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 9fee340e62e..07839ac6e61 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -80,7 +80,10 @@ static AppView *view = NULL;
static FreestyleLineSet lineset_buffer;
static bool lineset_copied = false;
-static void load_post_callback(struct Main * /*main*/, struct ID * /*id*/, void * /*arg*/)
+static void load_post_callback(struct Main * /*main*/,
+ struct PointerRNA ** /*pointers*/,
+ const int /*num_pointers*/,
+ void * /*arg*/)
{
lineset_copied = false;
}
@@ -649,7 +652,7 @@ Render *FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer, int render)
/* Create depsgraph and evaluate scene. */
ViewLayer *scene_view_layer = (ViewLayer *)BLI_findstring(
&re->scene->view_layers, view_layer->name, offsetof(ViewLayer, name));
- Depsgraph *depsgraph = DEG_graph_new(re->scene, scene_view_layer, DAG_EVAL_RENDER);
+ Depsgraph *depsgraph = DEG_graph_new(re->main, re->scene, scene_view_layer, DAG_EVAL_RENDER);
BKE_scene_graph_update_for_newframe(depsgraph, re->main);
// prepare Freestyle:
diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h
new file mode 100644
index 00000000000..cf4e74dfd41
--- /dev/null
+++ b/source/blender/makesdna/DNA_brush_defaults.h
@@ -0,0 +1,105 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_BRUSH_DEFAULTS_H__
+#define __DNA_BRUSH_DEFAULTS_H__
+
+#include "DNA_texture_defaults.h"
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Brush Struct
+ * \{ */
+
+#define _DNA_DEFAULT_Brush \
+ { \
+ .blend = 0, \
+ .flag = (BRUSH_ALPHA_PRESSURE | BRUSH_SPACE | BRUSH_SPACE_ATTEN), \
+ \
+ .ob_mode = OB_MODE_ALL_PAINT, \
+ \
+ /* BRUSH SCULPT TOOL SETTINGS */ \
+ .weight = 1.0f, /* weight of brush 0 - 1.0 */ \
+ .size = 35, /* radius of the brush in pixels */ \
+ .alpha = 0.5f, /* brush strength/intensity probably variable should be renamed? */ \
+ .autosmooth_factor = 0.0f, \
+ .topology_rake_factor = 0.0f, \
+ .crease_pinch_factor = 0.5f, \
+ .normal_radius_factor = 0.5f, \
+ .sculpt_plane = SCULPT_DISP_DIR_AREA, \
+ /* How far above or below the plane that is found by averaging the faces. */ \
+ .plane_offset = 0.0f, \
+ .plane_trim = 0.5f, \
+ .clone.alpha = 0.5f, \
+ .normal_weight = 0.0f, \
+ .fill_threshold = 0.2f, \
+ \
+ /* BRUSH PAINT TOOL SETTINGS */ \
+ /* Default rgb color of the brush when painting - white. */ \
+ .rgb = {1.0f, 1.0f, 1.0f}, \
+ \
+ .secondary_rgb = {0, 0, 0}, \
+ \
+ /* BRUSH STROKE SETTINGS */ \
+ /* How far each brush dot should be spaced as a percentage of brush diameter. */ \
+ .spacing = 10, \
+ \
+ .smooth_stroke_radius = 75, \
+ .smooth_stroke_factor = 0.9f, \
+ \
+ /* Time delay between dots of paint or sculpting when doing airbrush mode. */ \
+ .rate = 0.1f, \
+ \
+ .jitter = 0.0f, \
+ \
+ .texture_sample_bias = 0, /* value to added to texture samples */ \
+ .texture_overlay_alpha = 33, \
+ .mask_overlay_alpha = 33, \
+ .cursor_overlay_alpha = 33, \
+ .overlay_flags = 0, \
+ \
+ /* brush appearance */ \
+ \
+ /* add mode color is light red */ \
+ .add_col = {1.0, 0.39, 0.39}, \
+ \
+ /* subtract mode color is light blue */ \
+ .sub_col = {0.39, 0.39, 1.0}, \
+ \
+ .stencil_pos = {256, 256}, \
+ .stencil_dimension = {256, 256}, \
+ \
+ /* sculpting defaults to the draw tool for new brushes */ \
+ .sculpt_tool = SCULPT_TOOL_DRAW, \
+ \
+ /* A kernel radius of 1 has almost no effect (T63233). */ \
+ .blur_kernel_radius = 2, \
+ \
+ .mtex = _DNA_DEFAULT_MTex, \
+ .mask_mtex = _DNA_DEFAULT_MTex, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_BRUSH_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 56e255b132a..957f5b75974 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -113,7 +113,8 @@ typedef struct BrushGpencilSettings {
float gradient_f;
/** factor xy of shape for dots gradients */
float gradient_s[2];
- char _pad_2[4];
+ /** Simplify adaptive factor */
+ float simplify_f;
struct CurveMapping *curve_sensitivity;
struct CurveMapping *curve_strength;
@@ -321,7 +322,7 @@ typedef struct Brush {
char _pad1[4];
int elastic_deform_type;
- float elastic_deform_compressibility;
+ float elastic_deform_volume_preservation;
/* overlay */
int texture_overlay_alpha;
@@ -404,7 +405,7 @@ typedef enum eBrushFlags {
BRUSH_JITTER_PRESSURE = (1 << 4),
BRUSH_SPACING_PRESSURE = (1 << 5),
BRUSH_FLAG_UNUSED_6 = (1 << 6), /* cleared */
- BRUSH_FLAG_UNUSED_7 = (1 << 7), /* cleared */
+ BRUSH_GRAB_ACTIVE_VERTEX = (1 << 7),
BRUSH_ANCHORED = (1 << 8),
BRUSH_DIR_IN = (1 << 9),
BRUSH_SPACE = (1 << 10),
diff --git a/source/blender/makesdna/DNA_cachefile_defaults.h b/source/blender/makesdna/DNA_cachefile_defaults.h
new file mode 100644
index 00000000000..4c4ff53ed90
--- /dev/null
+++ b/source/blender/makesdna/DNA_cachefile_defaults.h
@@ -0,0 +1,49 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_CACHEFILE_DEFAULTS_H__
+#define __DNA_CACHEFILE_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name CacheFile Struct
+ * \{ */
+
+#define _DNA_DEFAULT_CacheFile \
+ { \
+ .filepath[0] = '\0', \
+ .override_frame = false, \
+ .frame = 0.0f, \
+ .is_sequence = false, \
+ .scale = 1.0f, \
+ .object_paths ={NULL, NULL}, \
+ \
+ .handle = NULL, \
+ .handle_filepath[0] = '\0', \
+ .handle_readers = NULL, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_CACHEFILE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_camera_defaults.h b/source/blender/makesdna/DNA_camera_defaults.h
new file mode 100644
index 00000000000..7a28f673ee4
--- /dev/null
+++ b/source/blender/makesdna/DNA_camera_defaults.h
@@ -0,0 +1,67 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_CAMERA_DEFAULTS_H__
+#define __DNA_CAMERA_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Camera Struct
+ * \{ */
+
+#define _DNA_DEFAULT_CameraDOFSettings \
+ { \
+ .aperture_fstop = 2.8f, \
+ .aperture_ratio = 1.0f, \
+ .focus_distance = 10.0f, \
+ }
+
+#define _DNA_DEFAULT_CameraStereoSettings \
+ { \
+ .interocular_distance = 0.065f, \
+ .convergence_distance = 30.f * 0.065f, \
+ .pole_merge_angle_from = DEG2RADF(60.0f), \
+ .pole_merge_angle_to = DEG2RADF(75.0f), \
+ }
+
+#define _DNA_DEFAULT_Camera \
+ { \
+ .lens = 50.0f, \
+ .sensor_x = DEFAULT_SENSOR_WIDTH, \
+ .sensor_y = DEFAULT_SENSOR_HEIGHT, \
+ .clip_start = 0.1f, \
+ .clip_end = 1000.0f, \
+ .drawsize = 1.0f, \
+ .ortho_scale = 6.0, \
+ .flag = CAM_SHOWPASSEPARTOUT, \
+ .passepartalpha = 0.5f, \
+ \
+ .dof = _DNA_DEFAULT_CameraDOFSettings, \
+ \
+ .stereo = _DNA_DEFAULT_CameraStereoSettings, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_CAMERA_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_curve_defaults.h b/source/blender/makesdna/DNA_curve_defaults.h
new file mode 100644
index 00000000000..0fdfd5713e9
--- /dev/null
+++ b/source/blender/makesdna/DNA_curve_defaults.h
@@ -0,0 +1,59 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_CURVE_DEFAULTS_H__
+#define __DNA_CURVE_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Curve Struct
+ * \{ */
+
+#define _DNA_DEFAULT_Curve \
+ { \
+ .size = {1, 1, 1}, \
+ .flag = CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS, \
+ .pathlen = 100, \
+ .resolu = 12, \
+ .resolv = 12, \
+ .width = 1.0, \
+ .wordspace = 1.0, \
+ .spacing = 1.0f, \
+ .linedist = 1.0, \
+ .fsize = 1.0, \
+ .ulheight = 0.05, \
+ .texflag = CU_AUTOSPACE, \
+ .smallcaps_scale = 0.75f, \
+ /* This one seems to be the best one in most cases, at least for curve deform. */ \
+ .twist_mode = CU_TWIST_MINIMUM, \
+ .bevfac1 = 0.0f, \
+ .bevfac2 = 1.0f, \
+ .bevfac1_mapping = CU_BEVFAC_MAP_RESOLU, \
+ .bevfac2_mapping = CU_BEVFAC_MAP_RESOLU, \
+ .bevresol = 4, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_CURVE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h
index dc4f5512b1a..db65da6fa75 100644
--- a/source/blender/makesdna/DNA_genfile.h
+++ b/source/blender/makesdna/DNA_genfile.h
@@ -103,6 +103,8 @@ void *DNA_struct_reconstruct(const struct SDNA *newsdna,
int DNA_elem_offset(struct SDNA *sdna, const char *stype, const char *vartype, const char *name);
+int DNA_elem_size_nr(const struct SDNA *sdna, short type, short name);
+
bool DNA_struct_find(const struct SDNA *sdna, const char *stype);
bool DNA_struct_elem_find(const struct SDNA *sdna,
const char *stype,
diff --git a/source/blender/makesdna/DNA_image_defaults.h b/source/blender/makesdna/DNA_image_defaults.h
new file mode 100644
index 00000000000..e115f9e2b16
--- /dev/null
+++ b/source/blender/makesdna/DNA_image_defaults.h
@@ -0,0 +1,46 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_IMAGE_DEFAULTS_H__
+#define __DNA_IMAGE_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Image Struct
+ * \{ */
+
+#define _DNA_DEFAULT_Image \
+ { \
+ .aspx = 1.0, \
+ .aspy = 1.0, \
+ .gen_x = 1024, \
+ .gen_y = 1024, \
+ .gen_type = IMA_GENTYPE_GRID, \
+ \
+ .gpuframenr = INT_MAX, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_IMAGE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_lattice_defaults.h b/source/blender/makesdna/DNA_lattice_defaults.h
new file mode 100644
index 00000000000..052aaba51d7
--- /dev/null
+++ b/source/blender/makesdna/DNA_lattice_defaults.h
@@ -0,0 +1,44 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_LATTICE_DEFAULTS_H__
+#define __DNA_LATTICE_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Lattice Struct
+ * \{ */
+
+#define _DNA_DEFAULT_Lattice \
+ { \
+ .flag = LT_GRID, \
+ .typeu = KEY_BSPLINE, \
+ .typev = KEY_BSPLINE, \
+ .typew = KEY_BSPLINE, \
+ .actbp = LT_ACTBP_NONE, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_LATTICE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_light_defaults.h b/source/blender/makesdna/DNA_light_defaults.h
new file mode 100644
index 00000000000..dceaaf7c278
--- /dev/null
+++ b/source/blender/makesdna/DNA_light_defaults.h
@@ -0,0 +1,76 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_LIGHT_DEFAULTS_H__
+#define __DNA_LIGHT_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Light Struct
+ * \{ */
+
+#define _DNA_DEFAULT_Light \
+ { \
+ .r = 1.0f, \
+ .g = 1.0f, \
+ .b = 1.0f, \
+ .k = 1.0f, \
+ .energy = 10.0f, \
+ .dist = 25.0f, \
+ .spotsize = DEG2RADF(45.0f), \
+ .spotblend = 0.15f, \
+ .att2 = 1.0f, \
+ .mode = LA_SHADOW, \
+ .bufsize = 512, \
+ .clipsta = 0.05f, \
+ .clipend = 40.0f, \
+ .bleedexp = 2.5f, \
+ .samp = 3, \
+ .bias = 1.0f, \
+ .soft = 3.0f, \
+ .area_size = 0.25f, \
+ .area_sizey = 0.25f, \
+ .area_sizez = 0.25f, \
+ .buffers = 1, \
+ .preview = NULL, \
+ .falloff_type = LA_FALLOFF_INVSQUARE, \
+ .coeff_const = 1.0f, \
+ .coeff_lin = 0.0f, \
+ .coeff_quad = 0.0f, \
+ .cascade_max_dist = 200.0f, \
+ .cascade_count = 4, \
+ .cascade_exponent = 0.8f, \
+ .cascade_fade = 0.1f, \
+ .contact_dist = 0.2f, \
+ .contact_bias = 0.03f, \
+ .contact_spread = 0.2f, \
+ .contact_thickness = 0.2f, \
+ .spec_fac = 1.0f, \
+ .att_dist = 40.0f, \
+ .sun_angle = DEG2RADF(0.526f), \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_LIGHT_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_lightprobe_defaults.h b/source/blender/makesdna/DNA_lightprobe_defaults.h
new file mode 100644
index 00000000000..7c7732d17e4
--- /dev/null
+++ b/source/blender/makesdna/DNA_lightprobe_defaults.h
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_LIGHTPROBE_DEFAULTS_H__
+#define __DNA_LIGHTPROBE_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name LightProbe Struct
+ * \{ */
+
+#define _DNA_DEFAULT_LightProbe \
+ { \
+ .grid_resolution_x = 4, \
+ .grid_resolution_y = 4, \
+ .grid_resolution_z = 4, \
+ .distinf = 2.5f, \
+ .distpar = 2.5f, \
+ .falloff = 0.2f, \
+ .clipsta = 0.8f, \
+ .clipend = 40.0f, \
+ .vis_bias = 1.0f, \
+ .vis_blur = 0.2f, \
+ .intensity = 1.0f, \
+ .flag = LIGHTPROBE_FLAG_SHOW_INFLUENCE, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_LIGHTPROBE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_linestyle_defaults.h b/source/blender/makesdna/DNA_linestyle_defaults.h
new file mode 100644
index 00000000000..2f9203050d1
--- /dev/null
+++ b/source/blender/makesdna/DNA_linestyle_defaults.h
@@ -0,0 +1,61 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_LINESTYLE_DEFAULTS_H__
+#define __DNA_LINESTYLE_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name FreestyleLineStyle Struct
+ * \{ */
+
+#define _DNA_DEFAULT_FreestyleLineStyle \
+ { \
+ .panel = LS_PANEL_STROKES, \
+ .r = 0, \
+ .g = 0, \
+ .b = 0, \
+ .alpha = 1.0f, \
+ .thickness = 3.0f, \
+ .thickness_position = LS_THICKNESS_CENTER, \
+ .thickness_ratio = 0.5f, \
+ .flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE, \
+ .chaining = LS_CHAINING_PLAIN, \
+ .rounds = 3, \
+ .min_angle = DEG2RADF(0.0f), \
+ .max_angle = DEG2RADF(0.0f), \
+ .min_length = 0.0f, \
+ .max_length = 10000.0f, \
+ .split_length = 100, \
+ .chain_count = 10, \
+ .sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA, \
+ .integration_type = LS_INTEGRATION_MEAN, \
+ .texstep = 1.0f, \
+ .pr_texture = TEX_PR_TEXTURE, \
+ .caps = LS_CAPS_BUTT, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_LINESTYLE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_meta_defaults.h b/source/blender/makesdna/DNA_meta_defaults.h
new file mode 100644
index 00000000000..723f178ed58
--- /dev/null
+++ b/source/blender/makesdna/DNA_meta_defaults.h
@@ -0,0 +1,44 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_META_DEFAULTS_H__
+#define __DNA_META_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name MetaBall Struct
+ * \{ */
+
+#define _DNA_DEFAULT_MetaBall \
+ { \
+ .size = {1, 1, 1}, \
+ .texflag = MB_AUTOSPACE, \
+ .wiresize = 0.4f, \
+ .rendersize = 0.2f, \
+ .thresh = 0.6f, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_META_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_scene_defaults.h b/source/blender/makesdna/DNA_scene_defaults.h
index c2ec290252f..a49da9e3761 100644
--- a/source/blender/makesdna/DNA_scene_defaults.h
+++ b/source/blender/makesdna/DNA_scene_defaults.h
@@ -41,6 +41,8 @@
#define _DNA_DEFAULT_BakeData \
{ \
+ .im_format = _DNA_DEFAULT_ImageFormatData, \
+ .filepath = "//", \
.flag = R_BAKE_CLEAR, \
.pass_filter = R_BAKE_PASS_FILTER_ALL, \
.width = 512, \
@@ -48,8 +50,6 @@
.margin = 16, \
.normal_space = R_BAKE_SPACE_TANGENT, \
.normal_swizzle = {R_BAKE_POSX, R_BAKE_POSY, R_BAKE_POSZ}, \
- \
- .im_format = _DNA_DEFAULT_ImageFormatData, \
}
#define _DNA_DEFAULT_FFMpegCodecData \
@@ -113,6 +113,9 @@
.bake = _DNA_DEFAULT_BakeData, \
\
.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION, \
+ \
+ .pic = "//", \
+ \
.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | \
R_STAMP_FILENAME | R_STAMP_RENDERTIME | R_STAMP_MEMORY, \
.stamp_font_id = 12, \
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index ee460e91a89..cabc271e304 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -2368,6 +2368,8 @@ typedef enum eGPencil_SimplifyFlags {
SIMPLIFY_GPENCIL_FX = (1 << 5),
/* Simplify layer blending */
SIMPLIFY_GPENCIL_BLEND = (1 << 6),
+ /* Simplify layer tint */
+ SIMPLIFY_GPENCIL_TINT = (1 << 7),
} eGPencil_SimplifyFlags;
/* ToolSettings.gpencil_*_align - Stroke Placement mode flags */
diff --git a/source/blender/makesdna/DNA_speaker_defaults.h b/source/blender/makesdna/DNA_speaker_defaults.h
new file mode 100644
index 00000000000..d252a447701
--- /dev/null
+++ b/source/blender/makesdna/DNA_speaker_defaults.h
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_SPEAKER_DEFAULTS_H__
+#define __DNA_SPEAKER_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Speaker Struct
+ * \{ */
+
+#define _DNA_DEFAULT_Speaker \
+ { \
+ .attenuation = 1.0f, \
+ .cone_angle_inner = 360.0f, \
+ .cone_angle_outer = 360.0f, \
+ .cone_volume_outer = 1.0f, \
+ .distance_max = FLT_MAX, \
+ .distance_reference = 1.0f, \
+ .flag = 0, \
+ .pitch = 1.0f, \
+ .sound = NULL, \
+ .volume = 1.0f, \
+ .volume_max = 1.0f, \
+ .volume_min = 0.0f, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_SPEAKER_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_texture_defaults.h b/source/blender/makesdna/DNA_texture_defaults.h
new file mode 100644
index 00000000000..d5097c5ea21
--- /dev/null
+++ b/source/blender/makesdna/DNA_texture_defaults.h
@@ -0,0 +1,155 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_TEXTURE_DEFAULTS_H__
+#define __DNA_TEXTURE_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Texture Struct
+ * \{ */
+
+#define _DNA_DEFAULT_MTex \
+ { \
+ .texco = TEXCO_UV, \
+ .mapto = MAP_COL, \
+ .object = NULL, \
+ .projx = PROJ_X, \
+ .projy = PROJ_Y, \
+ .projz = PROJ_Z, \
+ .mapping = MTEX_FLAT, \
+ .ofs[0] = 0.0, \
+ .ofs[1] = 0.0, \
+ .ofs[2] = 0.0, \
+ .size[0] = 1.0, \
+ .size[1] = 1.0, \
+ .size[2] = 1.0, \
+ .tex = NULL, \
+ .colormodel = 0, \
+ .r = 1.0, \
+ .g = 0.0, \
+ .b = 1.0, \
+ .k = 1.0, \
+ .def_var = 1.0, \
+ .blendtype = MTEX_BLEND, \
+ .colfac = 1.0, \
+ .norfac = 1.0, \
+ .varfac = 1.0, \
+ .dispfac = 0.2, \
+ .colspecfac = 1.0f, \
+ .mirrfac = 1.0f, \
+ .alphafac = 1.0f, \
+ .difffac = 1.0f, \
+ .specfac = 1.0f, \
+ .emitfac = 1.0f, \
+ .hardfac = 1.0f, \
+ .raymirrfac = 1.0f, \
+ .translfac = 1.0f, \
+ .ambfac = 1.0f, \
+ .colemitfac = 1.0f, \
+ .colreflfac = 1.0f, \
+ .coltransfac = 1.0f, \
+ .densfac = 1.0f, \
+ .scatterfac = 1.0f, \
+ .reflfac = 1.0f, \
+ .shadowfac = 1.0f, \
+ .zenupfac = 1.0f, \
+ .zendownfac = 1.0f, \
+ .blendfac = 1.0f, \
+ .timefac = 1.0f, \
+ .lengthfac = 1.0f, \
+ .clumpfac = 1.0f, \
+ .kinkfac = 1.0f, \
+ .kinkampfac = 1.0f, \
+ .roughfac = 1.0f, \
+ .twistfac = 1.0f, \
+ .padensfac = 1.0f, \
+ .lifefac = 1.0f, \
+ .sizefac = 1.0f, \
+ .ivelfac = 1.0f, \
+ .dampfac = 1.0f, \
+ .gravityfac = 1.0f, \
+ .fieldfac = 1.0f, \
+ .normapspace = MTEX_NSPACE_TANGENT, \
+ .brush_map_mode = MTEX_MAP_MODE_TILED, \
+ .random_angle = 2.0f * (float)M_PI, \
+ .brush_angle_mode = 0, \
+ } \
+
+#define _DNA_DEFAULT_Tex \
+ { \
+ .type = TEX_IMAGE, \
+ .ima = NULL, \
+ .stype = 0, \
+ .flag = TEX_CHECKER_ODD, \
+ .imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA, \
+ .extend = TEX_REPEAT, \
+ .cropxmin = 0.0, \
+ .cropymin = 0.0, \
+ .cropxmax = 1.0, \
+ .cropymax = 1.0, \
+ .texfilter = TXF_EWA, \
+ .afmax = 8, \
+ .xrepeat = 1, \
+ .yrepeat = 1, \
+ .sfra = 1, \
+ .frames = 0, \
+ .offset = 0, \
+ .noisesize = 0.25, \
+ .noisedepth = 2, \
+ .turbul = 5.0, \
+ .nabla = 0.025, /* also in do_versions. */ \
+ .bright = 1.0, \
+ .contrast = 1.0, \
+ .saturation = 1.0, \
+ .filtersize = 1.0, \
+ .rfac = 1.0, \
+ .gfac = 1.0, \
+ .bfac = 1.0, \
+ /* newnoise: init. */ \
+ .noisebasis = 0, \
+ .noisebasis2 = 0, \
+ /* musgrave */ \
+ .mg_H = 1.0, \
+ .mg_lacunarity = 2.0, \
+ .mg_octaves = 2.0, \
+ .mg_offset = 1.0, \
+ .mg_gain = 1.0, \
+ .ns_outscale = 1.0, \
+ /* distnoise */ \
+ .dist_amount = 1.0, \
+ /* voronoi */ \
+ .vn_w1 = 1.0, \
+ .vn_w2 = 0.0, \
+ .vn_w3 = 0.0, \
+ .vn_w4 = 0.0, \
+ .vn_mexp = 2.5, \
+ .vn_distm = 0, \
+ .vn_coltype = 0, \
+ .preview = NULL, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_TEXTURE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 9e69cd6fda2..6e44c51970d 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -196,6 +196,9 @@ typedef struct ThemeUI {
unsigned char icon_modifier[4];
/** Shading related items. */
unsigned char icon_shading[4];
+ /** File folders. */
+ unsigned char icon_folder[4];
+ char _pad2[4];
/** Intensity of the border icons. >0 will render an border around themed
* icons. */
float icon_border_intensity;
diff --git a/source/blender/makesdna/DNA_view3d_defaults.h b/source/blender/makesdna/DNA_view3d_defaults.h
index 2964e77a421..365b1993d80 100644
--- a/source/blender/makesdna/DNA_view3d_defaults.h
+++ b/source/blender/makesdna/DNA_view3d_defaults.h
@@ -48,6 +48,27 @@
.studiolight_intensity = 1.0f, \
}
+#define _DNA_DEFAULT_View3DOverlay \
+ { \
+ .wireframe_threshold = 1.0f, \
+ .xray_alpha_bone = 0.5f, \
+ .texture_paint_mode_opacity = 1.0f, \
+ .weight_paint_mode_opacity = 1.0f, \
+ .vertex_paint_mode_opacity = 1.0f, \
+ /* Intentionally different to vertex/paint mode, \
+ * we typically want to see shading too. */ \
+ .sculpt_mode_mask_opacity = 0.75f, \
+ \
+ .edit_flag = V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS | \
+ V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE | \
+ V3D_OVERLAY_EDIT_FREESTYLE_FACE | V3D_OVERLAY_EDIT_EDGES | \
+ V3D_OVERLAY_EDIT_CREASES | V3D_OVERLAY_EDIT_BWEIGHTS | \
+ V3D_OVERLAY_EDIT_CU_HANDLES | V3D_OVERLAY_EDIT_CU_NORMALS, \
+ \
+ .gpencil_paper_opacity = 0.5f, \
+ .gpencil_grid_opacity = 0.9f, \
+ }
+
#define _DNA_DEFAULT_View3DCursor \
{ \
.rotation_mode = ROT_MODE_XYZ, \
@@ -55,6 +76,39 @@
.rotation_axis = {0, 1, 0}, \
}
+#define _DNA_DEFAULT_View3D \
+ { \
+ .spacetype = SPACE_VIEW3D, \
+ .scenelock = true, \
+ .grid = 1.0f, \
+ .gridlines = 16, \
+ .gridsubdiv = 10, \
+ .shading = _DNA_DEFAULT_View3DShading, \
+ .overlay = _DNA_DEFAULT_View3DOverlay, \
+ \
+ .gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID, \
+ \
+ .flag = V3D_SELECT_OUTLINE, \
+ .flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_ANNOTATION, \
+ \
+ .lens = 50.0f, \
+ .clip_start = 0.01f, \
+ .clip_end = 1000.0f, \
+ \
+ .bundle_size = 0.2f, \
+ .bundle_drawtype = OB_PLAINAXES, \
+ \
+ /* stereo */ \
+ .stereo3d_camera = STEREO_3D_ID, \
+ .stereo3d_flag = V3D_S3D_DISPPLANE, \
+ .stereo3d_convergence_alpha = 0.15f, \
+ .stereo3d_volume_alpha = 0.05f, \
+ \
+ /* Grease pencil settings. */ \
+ .vertex_opacity = 1.0f, \
+ .gp_flag = V3D_GP_SHOW_EDIT_LINES, \
+ }
+
/** \} */
/* clang-format on */
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 3a7675eb92a..106bf1252b2 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -179,6 +179,8 @@ typedef struct View3DShading {
float curvature_ridge_factor;
float curvature_valley_factor;
+
+ struct IDProperty *prop;
} View3DShading;
/** 3D Viewport Overlay settings. */
diff --git a/source/blender/makesdna/DNA_world_defaults.h b/source/blender/makesdna/DNA_world_defaults.h
new file mode 100644
index 00000000000..c4d934381b4
--- /dev/null
+++ b/source/blender/makesdna/DNA_world_defaults.h
@@ -0,0 +1,49 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_WORLD_DEFAULTS_H__
+#define __DNA_WORLD_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name World Struct
+ * \{ */
+
+#define _DNA_DEFAULT_World \
+ { \
+ .horr = 0.05f, \
+ .horg = 0.05f, \
+ .horb = 0.05f, \
+ \
+ .aodist = 10.0f, \
+ .aoenergy = 1.0f, \
+ \
+ .preview = NULL, \
+ .miststa = 5.0f, \
+ .mistdist = 25.0f, \
+ }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_WORLD_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 342e466c3f7..bca27442e65 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -128,10 +128,21 @@ set(SRC
../../blenlib/intern/hash_mm2a.c
../../blenlib/intern/listbase.c
+ ../DNA_brush_defaults.h
+ ../DNA_cachefile_defaults.h
+ ../DNA_camera_defaults.h
+ ../DNA_curve_defaults.h
+ ../DNA_image_defaults.h
+ ../DNA_lattice_defaults.h
+ ../DNA_light_defaults.h
+ ../DNA_lightprobe_defaults.h
+ ../DNA_linestyle_defaults.h
../DNA_material_defaults.h
../DNA_mesh_defaults.h
+ ../DNA_meta_defaults.h
../DNA_object_defaults.h
../DNA_scene_defaults.h
+ ../DNA_texture_defaults.h
../DNA_vec_defaults.h
../DNA_view3d_defaults.h
)
diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c
index 4662f3a0b01..bae0df7e1e6 100644
--- a/source/blender/makesdna/intern/dna_defaults.c
+++ b/source/blender/makesdna/intern/dna_defaults.c
@@ -54,33 +54,104 @@
#include "DNA_defaults.h"
+#include "DNA_brush_types.h"
+#include "DNA_cachefile_types.h"
+#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
+#include "DNA_image_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_light_types.h"
+#include "DNA_lightprobe_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
+#include "DNA_speaker_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_world_types.h"
+#include "DNA_brush_defaults.h"
+#include "DNA_cachefile_defaults.h"
+#include "DNA_camera_defaults.h"
+#include "DNA_curve_defaults.h"
+#include "DNA_image_defaults.h"
+#include "DNA_lattice_defaults.h"
+#include "DNA_light_defaults.h"
+#include "DNA_lightprobe_defaults.h"
+#include "DNA_linestyle_defaults.h"
#include "DNA_material_defaults.h"
#include "DNA_mesh_defaults.h"
+#include "DNA_meta_defaults.h"
#include "DNA_object_defaults.h"
#include "DNA_scene_defaults.h"
+#include "DNA_speaker_defaults.h"
+#include "DNA_texture_defaults.h"
+#include "DNA_world_defaults.h"
#define SDNA_DEFAULT_DECL_STRUCT(struct_name) \
const struct_name DNA_DEFAULT_##struct_name = _DNA_DEFAULT_##struct_name
-/* DNA_scene_material.h */
+/* DNA_brush_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Brush);
+
+/* DNA_cachefile_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(CacheFile);
+
+/* DNA_camera_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Camera);
+SDNA_DEFAULT_DECL_STRUCT(CameraDOFSettings);
+SDNA_DEFAULT_DECL_STRUCT(CameraStereoSettings);
+
+/* DNA_curve_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Curve);
+
+/* DNA_image_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Image);
+
+/* DNA_lattice_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Lattice);
+
+/* DNA_light_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Light);
+
+/* DNA_lightprobe_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(LightProbe);
+
+/* DNA_linestyle_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(FreestyleLineStyle);
+
+/* DNA_material_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Material);
-/* DNA_scene_mesh.h */
+/* DNA_mesh_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Mesh);
-/* DNA_scene_object.h */
+/* DNA_meta_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(MetaBall);
+
+/* DNA_object_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Object);
/* DNA_scene_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Scene);
SDNA_DEFAULT_DECL_STRUCT(ToolSettings);
+/* DNA_speaker_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Speaker);
+
+/* DNA_texture_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Tex);
+
+/* DNA_view3d_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(View3D);
+
+/* DNA_world_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(World);
+
#undef SDNA_DEFAULT_DECL_STRUCT
/* Reuse existing definitions. */
@@ -108,12 +179,44 @@ extern const bTheme U_theme_default;
/** Keep headers sorted. */
const void *DNA_default_table[SDNA_TYPE_MAX] = {
+ /* DNA_brush_defaults.h */
+ SDNA_DEFAULT_DECL(Brush),
+
+ /* DNA_cachefile_defaults.h */
+ SDNA_DEFAULT_DECL(CacheFile),
+
+ /* DNA_camera_defaults.h */
+ SDNA_DEFAULT_DECL(Camera),
+ SDNA_DEFAULT_DECL_EX(CameraDOFSettings, Camera.dof),
+ SDNA_DEFAULT_DECL_EX(CameraStereoSettings, Camera.stereo),
+
+ /* DNA_curve_defaults.h */
+ SDNA_DEFAULT_DECL(Curve),
+
+ /* DNA_image_defaults.h */
+ SDNA_DEFAULT_DECL(Image),
+
+ /* DNA_lattice_defaults.h */
+ SDNA_DEFAULT_DECL(Lattice),
+
+ /* DNA_light_defaults.h */
+ SDNA_DEFAULT_DECL(Light),
+
+ /* DNA_lightprobe_defaults.h */
+ SDNA_DEFAULT_DECL(LightProbe),
+
+ /* DNA_linestyle_defaults.h */
+ SDNA_DEFAULT_DECL(FreestyleLineStyle),
+
/* DNA_material_defaults.h */
SDNA_DEFAULT_DECL(Material),
/* DNA_mesh_defaults.h */
SDNA_DEFAULT_DECL(Mesh),
+ /* DNA_meta_defaults.h */
+ SDNA_DEFAULT_DECL(MetaBall),
+
/* DNA_object_defaults.h */
SDNA_DEFAULT_DECL(Object),
@@ -127,6 +230,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL_EX(AudioData, Scene.audio),
SDNA_DEFAULT_DECL_EX(PhysicsSettings, Scene.physics_settings),
SDNA_DEFAULT_DECL_EX(SceneDisplay, Scene.display),
+ SDNA_DEFAULT_DECL_EX(SceneEEVEE, Scene.eevee),
SDNA_DEFAULT_DECL(ToolSettings),
SDNA_DEFAULT_DECL_EX(CurvePaintSettings, ToolSettings.curve_paint_settings),
@@ -137,6 +241,13 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL_EX(GP_Sculpt_Settings, ToolSettings.gp_sculpt),
SDNA_DEFAULT_DECL_EX(GP_Sculpt_Guide, ToolSettings.gp_sculpt.guide),
+ /* DNA_speaker_defaults.h */
+ SDNA_DEFAULT_DECL(Speaker),
+
+ /* DNA_texture_defaults.h */
+ SDNA_DEFAULT_DECL(Tex),
+ SDNA_DEFAULT_DECL_EX(MTex, Brush.mtex),
+
/* DNA_userdef_types.h */
SDNA_DEFAULT_DECL(UserDef),
SDNA_DEFAULT_DECL(bTheme),
@@ -144,8 +255,13 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL_EX(WalkNavigation, UserDef.walk_navigation),
/* DNA_view3d_defaults.h */
- SDNA_DEFAULT_DECL_EX(View3DShading, Scene.display.shading),
+ SDNA_DEFAULT_DECL(View3D),
+ SDNA_DEFAULT_DECL_EX(View3DOverlay, View3D.overlay),
+ SDNA_DEFAULT_DECL_EX(View3DShading, View3D.shading),
SDNA_DEFAULT_DECL_EX(View3DCursor, Scene.cursor),
+
+ /* DNA_world_defaults.h */
+ SDNA_DEFAULT_DECL(World),
};
#undef SDNA_DEFAULT_DECL
#undef SDNA_DEFAULT_DECL_EX
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 09a7a157996..6b3095c7925 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -184,7 +184,7 @@ static bool ispointer(const char *name)
* \param name: Index into sdna->names,
* needed to extract possible pointer/array information.
*/
-static int elementsize(const SDNA *sdna, short type, short name)
+int DNA_elem_size_nr(const SDNA *sdna, short type, short name)
{
int len;
const char *cp = sdna->names[name];
@@ -1059,7 +1059,7 @@ static const char *find_elem(const SDNA *sdna,
otype = sdna->types[old[0]];
oname = sdna->names[old[1]];
- len = elementsize(sdna, old[0], old[1]);
+ len = DNA_elem_size_nr(sdna, old[0], old[1]);
if (elem_strcmp(name, oname) == 0) { /* name equal */
if (strcmp(type, otype) == 0) { /* type equal */
@@ -1128,7 +1128,7 @@ static void reconstruct_elem(const SDNA *newsdna,
const int old_name_nr = old[1];
otype = oldsdna->types[old[0]];
oname = oldsdna->names[old[1]];
- len = elementsize(oldsdna, old[0], old[1]);
+ len = DNA_elem_size_nr(oldsdna, old[0], old[1]);
if (strcmp(name, oname) == 0) { /* name equal */
@@ -1247,7 +1247,7 @@ static void reconstruct_struct(const SDNA *newsdna,
type = newsdna->types[spc[0]];
name = newsdna->names[spc[1]];
- elen = elementsize(newsdna, spc[0], spc[1]);
+ elen = DNA_elem_size_nr(newsdna, spc[0], spc[1]);
/* Skip pad bytes which must start with '_pad', see makesdna.c 'is_name_legal'.
* for exact rules. Note that if we fail to skip a pad byte it's harmless,
@@ -1269,7 +1269,7 @@ static void reconstruct_struct(const SDNA *newsdna,
mul = newsdna->names_array_len[spc[1]];
mulo = oldsdna->names_array_len[sppo[1]];
- eleno = elementsize(oldsdna, sppo[0], sppo[1]);
+ eleno = DNA_elem_size_nr(oldsdna, sppo[0], sppo[1]);
elen /= mul;
eleno /= mulo;
@@ -1333,8 +1333,8 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
name = oldsdna->names[spc[1]];
const int old_name_array_len = oldsdna->names_array_len[spc[1]];
- /* elementsize = including arraysize */
- elen = elementsize(oldsdna, spc[0], spc[1]);
+ /* DNA_elem_size_nr = including arraysize */
+ elen = DNA_elem_size_nr(oldsdna, spc[0], spc[1]);
/* test: is type a struct? */
if (spc[0] >= firststructtypenr && !ispointer(name)) {
@@ -1639,6 +1639,8 @@ static void sdna_expand_names(SDNA *sdna)
names_expand_len += sp[1];
}
const char **names_expand = MEM_mallocN(sizeof(*names_expand) * names_expand_len, __func__);
+ short *names_array_len_expand = MEM_mallocN(sizeof(*names_array_len_expand) * names_expand_len,
+ __func__);
int names_expand_index = 0;
for (int struct_nr = 0; struct_nr < sdna->structs_len; struct_nr++) {
@@ -1652,6 +1654,7 @@ static void sdna_expand_names(SDNA *sdna)
sp_expand += 2;
for (int i = 0; i < names_len; i++, sp += 2, sp_expand += 2) {
names_expand[names_expand_index] = sdna->names[sp[1]];
+ names_array_len_expand[names_expand_index] = sdna->names_array_len[sp[1]];
BLI_assert(names_expand_index < SHRT_MAX);
sp_expand[1] = names_expand_index;
names_expand_index++;
@@ -1659,6 +1662,10 @@ static void sdna_expand_names(SDNA *sdna)
}
MEM_freeN((void *)sdna->names);
sdna->names = names_expand;
+
+ MEM_freeN((void *)sdna->names_array_len);
+ sdna->names_array_len = names_array_len_expand;
+
sdna->names_len = names_expand_len;
}
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 89fa80e6dd6..cbd40f28c38 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -165,10 +165,19 @@ set(SRC
../../../../intern/guardedalloc/intern/mallocn_guarded_impl.c
../../../../intern/guardedalloc/intern/mallocn_lockfree_impl.c
../../../../intern/guardedalloc/intern/mmap_win.c
+
+ # Needed for defaults.
+ ../../../../release/datafiles/userdef/userdef_default.c
+ ../../../../release/datafiles/userdef/userdef_default_theme.c
)
set(INC
- ../../../../intern/clog
+ ../../../../intern/clog
+
+ # Needed for defaults forward declarations.
+ ../../../blender/blenloader
+
+ ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
)
set(INC_SYS
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 1617d85b6c2..ff4b7bb5f22 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -409,23 +409,30 @@ static void rna_construct_wrapper_function_name(
}
}
+void *rna_alloc_from_buffer(const char *buffer, int buffer_len)
+{
+ AllocDefRNA *alloc = MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
+ alloc->mem = MEM_mallocN(buffer_len, __func__);
+ memcpy(alloc->mem, buffer, buffer_len);
+ rna_addtail(&DefRNA.allocs, alloc);
+ return alloc->mem;
+}
+
+void *rna_calloc(int buffer_len)
+{
+ AllocDefRNA *alloc = MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
+ alloc->mem = MEM_callocN(buffer_len, __func__);
+ rna_addtail(&DefRNA.allocs, alloc);
+ return alloc->mem;
+}
+
static char *rna_alloc_function_name(const char *structname,
const char *propname,
const char *type)
{
- AllocDefRNA *alloc;
char buffer[2048];
- char *result;
-
rna_construct_function_name(buffer, sizeof(buffer), structname, propname, type);
- result = MEM_callocN(sizeof(char) * strlen(buffer) + 1, "rna_alloc_function_name");
- strcpy(result, buffer);
-
- alloc = MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
- alloc->mem = result;
- rna_addtail(&DefRNA.allocs, alloc);
-
- return result;
+ return rna_alloc_from_buffer(buffer, strlen(buffer) + 1);
}
static StructRNA *rna_find_struct(const char *identifier)
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index cfcc37adf6c..4dc383a2460 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -36,6 +36,8 @@
#ifdef RNA_RUNTIME
+# include "BLI_math_vector.h"
+
# include "BKE_action.h"
# include "BKE_context.h"
# include "BKE_global.h"
@@ -483,6 +485,22 @@ static void rna_EditBone_matrix_set(PointerRNA *ptr, const float *values)
ED_armature_ebone_from_mat4(ebone, (float(*)[4])values);
}
+static float rna_EditBone_length_get(PointerRNA *ptr)
+{
+ EditBone *ebone = (EditBone *)(ptr->data);
+ return len_v3v3(ebone->head, ebone->tail);
+}
+
+static void rna_EditBone_length_set(PointerRNA *ptr, float length)
+{
+ EditBone *ebone = (EditBone *)(ptr->data);
+ float delta[3];
+
+ sub_v3_v3v3(delta, ebone->tail, ebone->head);
+ normalize_v3(delta);
+ madd_v3_v3v3fl(ebone->tail, ebone->head, delta, length);
+}
+
static void rna_Bone_bbone_handle_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bArmature *arm = (bArmature *)ptr->owner_id;
@@ -1141,27 +1159,28 @@ static void rna_def_bone(BlenderRNA *brna)
prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "bone_mat");
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Bone Matrix", "3x3 bone matrix");
prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "arm_mat");
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(
prop, "Bone Armature-Relative Matrix", "4x4 bone matrix relative to armature");
prop = RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "tail");
RNA_def_property_array(prop, 3);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(
+ prop, "Tail", "Location of tail end of the bone relative to its parent");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
prop = RNA_def_property(srna, "tail_local", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "arm_tail");
RNA_def_property_array(prop, 3);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(
prop, "Armature-Relative Tail", "Location of tail end of the bone relative to armature");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
@@ -1169,7 +1188,7 @@ static void rna_def_bone(BlenderRNA *brna)
prop = RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "head");
RNA_def_property_array(prop, 3);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(
prop, "Head", "Location of head end of the bone relative to its parent");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
@@ -1177,11 +1196,16 @@ static void rna_def_bone(BlenderRNA *brna)
prop = RNA_def_property(srna, "head_local", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "arm_head");
RNA_def_property_array(prop, 3);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(
prop, "Armature-Relative Head", "Location of head end of the bone relative to armature");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_sdna(prop, NULL, "length");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Length", "Length of the bone");
+
RNA_api_bone(srna);
}
@@ -1227,6 +1251,14 @@ static void rna_def_edit_bone(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
+ prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_funcs(prop, "rna_EditBone_length_get", "rna_EditBone_length_set", NULL);
+ RNA_def_property_range(prop, 0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ RNA_def_property_ui_text(prop, "Length", "Length of the bone. Changing moves the tail end");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
+
rna_def_bone_common(srna, 1);
rna_def_bone_curved_common(srna, false, true);
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 3aa96749512..b5f4582d844 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -385,6 +385,7 @@ static bool rna_BrushCapabilitiesSculpt_has_direction_get(PointerRNA *ptr)
Brush *br = (Brush *)ptr->data;
return !ELEM(br->sculpt_tool,
SCULPT_TOOL_DRAW,
+ SCULPT_TOOL_DRAW_SHARP,
SCULPT_TOOL_CLAY,
SCULPT_TOOL_CLAY_STRIPS,
SCULPT_TOOL_LAYER,
@@ -648,6 +649,7 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
case PAINT_MODE_SCULPT:
switch (me->sculpt_tool) {
case SCULPT_TOOL_DRAW:
+ case SCULPT_TOOL_DRAW_SHARP:
case SCULPT_TOOL_CREASE:
case SCULPT_TOOL_BLOB:
case SCULPT_TOOL_LAYER:
@@ -1187,6 +1189,14 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+ /* Simplify factor */
+ prop = RNA_def_property(srna, "simplify_factor", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "simplify_f");
+ RNA_def_property_range(prop, 0, 100.0);
+ RNA_def_property_ui_range(prop, 0, 100.0, 1.0f, 3);
+ RNA_def_property_ui_text(prop, "Simplify", "Factor of Simplify using adaptive algorithm");
+ RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+
/* Curves for pressure */
prop = RNA_def_property(srna, "curve_sensitivity", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "curve_sensitivity");
@@ -1771,7 +1781,6 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
RNA_def_property_ui_text(prop, "Weight", "Vertex weight when brush is applied");
@@ -1779,7 +1788,6 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "alpha");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
RNA_def_property_ui_text(
@@ -1799,7 +1807,6 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "plane_trim", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "plane_trim");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0, 1.0f);
RNA_def_property_ui_text(
prop,
@@ -1830,12 +1837,14 @@ static void rna_def_brush(BlenderRNA *brna)
prop, "Normal Weight", "How much grab will pull vertexes out of surface during a grab");
RNA_def_property_update(prop, 0, "rna_Brush_update");
- prop = RNA_def_property(srna, "elastic_deform_compressibility", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "elastic_deform_compressibility");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01f, 3);
- RNA_def_property_ui_text(
- prop, "Compressibility", "Material compressibility when simulating the elasticity");
+ prop = RNA_def_property(srna, "elastic_deform_volume_preservation", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "elastic_deform_volume_preservation");
+ RNA_def_property_range(prop, 0.0f, 0.9f);
+ RNA_def_property_ui_range(prop, 0.0f, 0.9f, 0.01f, 3);
+ RNA_def_property_ui_text(prop,
+ "Volume Preservation",
+ "Poisson ratio for elastic deformation. Higher values preserve volume "
+ "more, but also lead to more bulging");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "rake_factor", PROP_FLOAT, PROP_FACTOR);
@@ -1848,7 +1857,6 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "crease_pinch_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "crease_pinch_factor");
- RNA_def_property_float_default(prop, 2.0f / 3.0f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Crease Brush Pinch Factor", "How much the crease brush pinches");
RNA_def_property_update(prop, 0, "rna_Brush_update");
@@ -1876,7 +1884,6 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "normal_radius_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "normal_radius_factor");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
RNA_def_property_ui_text(prop,
@@ -1929,7 +1936,6 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "blur_kernel_radius", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "blur_kernel_radius");
RNA_def_property_range(prop, 1, 10000);
- RNA_def_property_int_default(prop, 2);
RNA_def_property_ui_range(prop, 1, 50, 1, -1);
RNA_def_property_ui_text(
prop, "Kernel Radius", "Radius of kernel used for soften and sharpen in pixels");
@@ -1984,6 +1990,14 @@ static void rna_def_brush(BlenderRNA *brna)
prop, "Spacing distance", "Calculate the brush spacing using view or scene distance");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "use_grab_active_vertex", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_GRAB_ACTIVE_VERTEX);
+ RNA_def_property_ui_text(
+ prop,
+ "Grab Active Vertex",
+ "Apply the maximum grab strength to the active vertex instead of the cursor location");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ALPHA_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c
index 88083f600f8..47a09233769 100644
--- a/source/blender/makesrna/intern/rna_camera.c
+++ b/source/blender/makesrna/intern/rna_camera.c
@@ -436,7 +436,6 @@ static void rna_def_camera_dof_settings_data(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update");
prop = RNA_def_property(srna, "focus_distance", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_default(prop, 10.0f);
// RNA_def_property_pointer_sdna(prop, NULL, "focus_distance");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, 5000.0f, 1, 2);
@@ -449,7 +448,6 @@ static void rna_def_camera_dof_settings_data(BlenderRNA *brna)
prop,
"F-Stop",
"F-Stop ratio (lower numbers give more defocus, higher numbers give a sharper image)");
- RNA_def_property_float_default(prop, 5.6f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.1f, 128.0f, 10, 1);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
@@ -468,7 +466,6 @@ static void rna_def_camera_dof_settings_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "aperture_ratio", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.01f, FLT_MAX);
RNA_def_property_ui_range(prop, 1.0f, 2.0f, 0.1, 3);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
@@ -525,7 +522,6 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "passepartout_alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "passepartalpha");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(
prop, "Passepartout Alpha", "Opacity (alpha) of the darkened overlay in Camera view");
RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
@@ -552,14 +548,12 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_default(prop, 0.1f);
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", "Camera near clipping distance");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_default(prop, 1000.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", "Camera far clipping distance");
@@ -567,7 +561,6 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_DISTANCE_CAMERA);
RNA_def_property_float_sdna(prop, NULL, "lens");
- RNA_def_property_float_default(prop, 50.0f);
RNA_def_property_range(prop, 1.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 100, 4);
RNA_def_property_ui_text(prop, "Focal Length", "Perspective Camera lens value in millimeters");
@@ -575,7 +568,6 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_DISTANCE_CAMERA);
RNA_def_property_float_sdna(prop, NULL, "sensor_x");
- RNA_def_property_float_default(prop, 36.0f);
RNA_def_property_range(prop, 1.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 1.0f, 100.f, 100, 4);
RNA_def_property_ui_text(
@@ -584,7 +576,6 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "sensor_height", PROP_FLOAT, PROP_DISTANCE_CAMERA);
RNA_def_property_float_sdna(prop, NULL, "sensor_y");
- RNA_def_property_float_default(prop, 34.0f);
RNA_def_property_range(prop, 1.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 1.0f, 100.f, 100, 4);
RNA_def_property_ui_text(
@@ -593,7 +584,6 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ortho_scale");
- RNA_def_property_float_default(prop, 6.0f);
RNA_def_property_range(prop, FLT_MIN, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, 10000.0f, 10, 3);
RNA_def_property_ui_text(
@@ -602,7 +592,6 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "display_size", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "drawsize");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.01f, 1000.0f);
RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
RNA_def_property_ui_text(
@@ -645,7 +634,6 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_passepartout", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWPASSEPARTOUT);
- RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(
prop, "Show Passepartout", "Show a darkened overlay outside the image area in Camera view");
RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 03ab9da2eff..8fc3bee83e6 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -31,6 +31,7 @@
#include "DNA_genfile.h"
#include "DNA_sdna_types.h"
+#include "DNA_defaults.h"
#include "BLI_listbase.h"
#include "BLI_ghash.h"
@@ -68,6 +69,25 @@ static struct {
} g_version_data;
#endif
+#ifndef RNA_RUNTIME
+/**
+ * When set, report details about which defaults are used.
+ * Noisy but handy when investigating default extraction.
+ */
+static bool debugSRNA_defaults = false;
+
+static void print_defult_info(const PropertyDefRNA *dp)
+{
+ fprintf(stderr,
+ "dna_type=%s, dna_offset=%d, dna_struct=%s, dna_name=%s, id=%s\n",
+ dp->dnatype,
+ dp->dnaoffset,
+ dp->dnastructname,
+ dp->dnaname,
+ dp->prop->identifier);
+}
+#endif /* RNA_RUNTIME */
+
/* Duplicated code since we can't link in blenkernel or blenlib */
/* pedantic check for final '.', note '...' are allowed though. */
@@ -378,6 +398,8 @@ typedef struct DNAStructMember {
const char *name;
int arraylength;
int pointerlevel;
+ int offset;
+ int size;
} DNAStructMember;
static int rna_member_cmp(const char *name, const char *oname)
@@ -420,7 +442,8 @@ static int rna_member_cmp(const char *name, const char *oname)
static int rna_find_sdna_member(SDNA *sdna,
const char *structname,
const char *membername,
- DNAStructMember *smember)
+ DNAStructMember *smember,
+ int *offset)
{
const char *dnaname;
const short *sp;
@@ -432,7 +455,11 @@ static int rna_find_sdna_member(SDNA *sdna,
}
structnr = DNA_struct_find_nr_wrapper(sdna, structname);
+ smember->offset = -1;
if (structnr == -1) {
+ if (offset) {
+ *offset = -1;
+ }
return 0;
}
@@ -441,12 +468,15 @@ static int rna_find_sdna_member(SDNA *sdna,
sp += 2;
for (a = 0; a < totmember; a++, sp += 2) {
+ const int size = DNA_elem_size_nr(sdna, sp[0], sp[1]);
dnaname = sdna->alias.names[sp[1]];
cmp = rna_member_cmp(dnaname, membername);
if (cmp == 1) {
smember->type = sdna->alias.types[sp[0]];
smember->name = dnaname;
+ smember->offset = *offset;
+ smember->size = size;
if (strstr(membername, "[")) {
smember->arraylength = 0;
@@ -465,25 +495,36 @@ static int rna_find_sdna_member(SDNA *sdna,
else if (cmp == 2) {
smember->type = "";
smember->name = dnaname;
+ smember->offset = *offset;
+ smember->size = size;
smember->pointerlevel = 0;
smember->arraylength = 0;
membername = strstr(membername, ".") + strlen(".");
- rna_find_sdna_member(sdna, sdna->alias.types[sp[0]], membername, smember);
+ rna_find_sdna_member(sdna, sdna->alias.types[sp[0]], membername, smember, offset);
return 1;
}
else if (cmp == 3) {
smember->type = "";
smember->name = dnaname;
+ smember->offset = *offset;
+ smember->size = size;
smember->pointerlevel = 0;
smember->arraylength = 0;
+ if (offset) {
+ *offset = -1;
+ }
membername = strstr(membername, "->") + strlen("->");
- rna_find_sdna_member(sdna, sdna->alias.types[sp[0]], membername, smember);
+ rna_find_sdna_member(sdna, sdna->alias.types[sp[0]], membername, smember, offset);
return 1;
}
+
+ if (offset && *offset != -1) {
+ *offset += size;
+ }
}
return 0;
@@ -1835,6 +1876,12 @@ void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
case PROP_BOOLEAN: {
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
BLI_assert(ELEM(value, false, true));
+#ifndef RNA_RUNTIME
+ /* Default may be set from items. */
+ if (bprop->defaultvalue) {
+ CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
+ }
+#endif
bprop->defaultvalue = value;
break;
}
@@ -1869,6 +1916,11 @@ void RNA_def_property_int_default(PropertyRNA *prop, int value)
switch (prop->type) {
case PROP_INT: {
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
+#ifndef RNA_RUNTIME
+ if (iprop->defaultvalue != 0) {
+ CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
+ }
+#endif
iprop->defaultvalue = value;
break;
}
@@ -1886,6 +1938,11 @@ void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
switch (prop->type) {
case PROP_INT: {
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
+#ifndef RNA_RUNTIME
+ if (iprop->defaultarray != NULL) {
+ CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
+ }
+#endif
iprop->defaultarray = array;
break;
}
@@ -1903,6 +1960,11 @@ void RNA_def_property_float_default(PropertyRNA *prop, float value)
switch (prop->type) {
case PROP_FLOAT: {
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
+#ifndef RNA_RUNTIME
+ if (fprop->defaultvalue != 0) {
+ CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
+ }
+#endif
fprop->defaultvalue = value;
break;
}
@@ -1920,6 +1982,11 @@ void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
switch (prop->type) {
case PROP_FLOAT: {
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
+#ifndef RNA_RUNTIME
+ if (fprop->defaultarray != NULL) {
+ CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
+ }
+#endif
fprop->defaultarray = array; /* WARNING, this array must not come from the stack and lost */
break;
}
@@ -1956,7 +2023,11 @@ void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
// BLI_assert(0);
break;
}
-
+#ifndef RNA_RUNTIME
+ if (sprop->defaultvalue != NULL && sprop->defaultvalue[0]) {
+ CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
+ }
+#endif
sprop->defaultvalue = value;
break;
}
@@ -2047,7 +2118,8 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop,
propname = prop->identifier;
}
- if (!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember)) {
+ int dnaoffset = 0;
+ if (!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember, &dnaoffset)) {
if (DefRNA.silent) {
return NULL;
}
@@ -2061,6 +2133,7 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop,
if (prop->type == PROP_POINTER) {
dp->dnapointerlevel = 1;
}
+ dp->dnaoffset = smember.offset;
return dp;
}
else {
@@ -2091,6 +2164,8 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop,
dp->dnatype = smember.type;
dp->dnaarraylength = smember.arraylength;
dp->dnapointerlevel = smember.pointerlevel;
+ dp->dnaoffset = smember.offset;
+ dp->dnasize = smember.size;
return dp;
}
@@ -2101,6 +2176,7 @@ void RNA_def_property_boolean_sdna(PropertyRNA *prop,
int bit)
{
PropertyDefRNA *dp;
+ BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
StructRNA *srna = DefRNA.laststruct;
if (!DefRNA.preprocess) {
@@ -2131,6 +2207,57 @@ void RNA_def_property_boolean_sdna(PropertyRNA *prop,
}
dp->booleanbit = bit;
+
+#ifndef RNA_RUNTIME
+ /* Set the default if possible. */
+ if (dp->dnaoffset != -1) {
+ int SDNAnr = DNA_struct_find_nr_wrapper(DefRNA.sdna, dp->dnastructname);
+ if (SDNAnr != -1) {
+ const void *default_data = DNA_default_table[SDNAnr];
+ if (default_data) {
+ default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
+ bool has_default = true;
+ if (prop->totarraylength > 0) {
+ has_default = false;
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "%s default: unsupported boolean array default\n", __func__);
+ }
+ }
+ else {
+ if (STREQ(dp->dnatype, "char")) {
+ bprop->defaultvalue = *(const char *)default_data & bit;
+ }
+ else if (STREQ(dp->dnatype, "short")) {
+ bprop->defaultvalue = *(const short *)default_data & bit;
+ }
+ else if (STREQ(dp->dnatype, "int")) {
+ bprop->defaultvalue = *(const int *)default_data & bit;
+ }
+ else {
+ has_default = false;
+ if (debugSRNA_defaults) {
+ fprintf(
+ stderr, "%s default: unsupported boolean type (%s)\n", __func__, dp->dnatype);
+ }
+ }
+
+ if (has_default) {
+ if (dp->booleannegative) {
+ bprop->defaultvalue = !bprop->defaultvalue;
+ }
+
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "value=%d, ", bprop->defaultvalue);
+ print_defult_info(dp);
+ }
+ }
+ }
+ }
+ }
+ }
+#else
+ UNUSED_VARS(bprop);
+#endif
}
}
@@ -2204,6 +2331,96 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
prop->subtype == PROP_FACTOR) {
iprop->hardmin = iprop->softmin = 0;
}
+
+#ifndef RNA_RUNTIME
+ /* Set the default if possible. */
+ if (dp->dnaoffset != -1) {
+ int SDNAnr = DNA_struct_find_nr_wrapper(DefRNA.sdna, dp->dnastructname);
+ if (SDNAnr != -1) {
+ const void *default_data = DNA_default_table[SDNAnr];
+ if (default_data) {
+ default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
+ /* NOTE: Currently doesn't store sign, assume chars are unsigned because
+ * we build with this enabled, otherwise check 'PROP_UNSIGNED'. */
+ bool has_default = true;
+ if (prop->totarraylength > 0) {
+ const void *default_data_end = POINTER_OFFSET(default_data, dp->dnasize);
+ const int size_final = sizeof(int) * prop->totarraylength;
+ if (STREQ(dp->dnatype, "char")) {
+ int *defaultarray = rna_calloc(size_final);
+ for (int i = 0; i < prop->totarraylength && default_data < default_data_end; i++) {
+ defaultarray[i] = *(const char *)default_data;
+ default_data = POINTER_OFFSET(default_data, sizeof(char));
+ }
+ iprop->defaultarray = defaultarray;
+ }
+ else if (STREQ(dp->dnatype, "short")) {
+
+ int *defaultarray = rna_calloc(size_final);
+ for (int i = 0; i < prop->totarraylength && default_data < default_data_end; i++) {
+ defaultarray[i] = (prop->subtype != PROP_UNSIGNED) ? *(const short *)default_data :
+ *(const ushort *)default_data;
+ default_data = POINTER_OFFSET(default_data, sizeof(short));
+ }
+ iprop->defaultarray = defaultarray;
+ }
+ else if (STREQ(dp->dnatype, "int")) {
+ int *defaultarray = rna_calloc(size_final);
+ memcpy(defaultarray, default_data, MIN2(size_final, dp->dnasize));
+ iprop->defaultarray = defaultarray;
+ }
+ else {
+ has_default = false;
+ if (debugSRNA_defaults) {
+ fprintf(stderr,
+ "%s default: unsupported int array type (%s)\n",
+ __func__,
+ dp->dnatype);
+ }
+ }
+
+ if (has_default) {
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "value=(");
+ for (int i = 0; i < prop->totarraylength; i++) {
+ fprintf(stderr, "%d, ", iprop->defaultarray[i]);
+ }
+ fprintf(stderr, "), ");
+ print_defult_info(dp);
+ }
+ }
+ }
+ else {
+ if (STREQ(dp->dnatype, "char")) {
+ iprop->defaultvalue = *(const char *)default_data;
+ }
+ else if (STREQ(dp->dnatype, "short")) {
+ iprop->defaultvalue = (prop->subtype != PROP_UNSIGNED) ?
+ *(const short *)default_data :
+ *(const ushort *)default_data;
+ }
+ else if (STREQ(dp->dnatype, "int")) {
+ iprop->defaultvalue = (prop->subtype != PROP_UNSIGNED) ? *(const int *)default_data :
+ *(const uint *)default_data;
+ }
+ else {
+ has_default = false;
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "%s default: unsupported int type (%s)\n", __func__, dp->dnatype);
+ }
+ }
+
+ if (has_default) {
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "value=%d, ", iprop->defaultvalue);
+ print_defult_info(dp);
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
}
}
@@ -2246,6 +2463,70 @@ void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, cons
fprop->hardmin = fprop->softmin = 0.0f;
fprop->hardmax = fprop->softmax = 1.0f;
}
+
+#ifndef RNA_RUNTIME
+ /* Set the default if possible. */
+ if (dp->dnaoffset != -1) {
+ int SDNAnr = DNA_struct_find_nr_wrapper(DefRNA.sdna, dp->dnastructname);
+ if (SDNAnr != -1) {
+ const void *default_data = DNA_default_table[SDNAnr];
+ if (default_data) {
+ default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
+ bool has_default = true;
+ if (prop->totarraylength > 0) {
+ if (STREQ(dp->dnatype, "float")) {
+ const int size_final = sizeof(float) * prop->totarraylength;
+ float *defaultarray = rna_calloc(size_final);
+ memcpy(defaultarray, default_data, MIN2(size_final, dp->dnasize));
+ fprop->defaultarray = defaultarray;
+ }
+ else {
+ has_default = false;
+ if (debugSRNA_defaults) {
+ fprintf(stderr,
+ "%s default: unsupported float array type (%s)\n",
+ __func__,
+ dp->dnatype);
+ }
+ }
+
+ if (has_default) {
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "value=(");
+ for (int i = 0; i < prop->totarraylength; i++) {
+ fprintf(stderr, "%g, ", fprop->defaultarray[i]);
+ }
+ fprintf(stderr, "), ");
+ print_defult_info(dp);
+ }
+ }
+ }
+ else {
+ if (STREQ(dp->dnatype, "float")) {
+ fprop->defaultvalue = *(const float *)default_data;
+ }
+ else if (STREQ(dp->dnatype, "char")) {
+ fprop->defaultvalue = (float)*(const char *)default_data * (1.0f / 255.0f);
+ }
+ else {
+ has_default = false;
+ if (debugSRNA_defaults) {
+ fprintf(
+ stderr, "%s default: unsupported float type (%s)\n", __func__, dp->dnatype);
+ }
+ }
+
+ if (has_default) {
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "value=%g, ", fprop->defaultvalue);
+ print_defult_info(dp);
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
}
rna_def_property_sdna(prop, structname, propname);
@@ -2253,7 +2534,8 @@ void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, cons
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
{
- /* PropertyDefRNA *dp; */
+ PropertyDefRNA *dp;
+ EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
StructRNA *srna = DefRNA.laststruct;
if (!DefRNA.preprocess) {
@@ -2267,7 +2549,7 @@ void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const
return;
}
- if ((/* dp= */ rna_def_property_sdna(prop, structname, propname))) {
+ if ((dp = rna_def_property_sdna(prop, structname, propname))) {
if (prop->arraydimension) {
prop->arraydimension = 0;
prop->totarraylength = 0;
@@ -2277,6 +2559,44 @@ void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const
DefRNA.error = 1;
}
}
+
+#ifndef RNA_RUNTIME
+ /* Set the default if possible. */
+ if (dp->dnaoffset != -1) {
+ int SDNAnr = DNA_struct_find_nr_wrapper(DefRNA.sdna, dp->dnastructname);
+ if (SDNAnr != -1) {
+ const void *default_data = DNA_default_table[SDNAnr];
+ if (default_data) {
+ default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
+ bool has_default = true;
+ if (STREQ(dp->dnatype, "char")) {
+ eprop->defaultvalue = *(const char *)default_data;
+ }
+ else if (STREQ(dp->dnatype, "short")) {
+ eprop->defaultvalue = *(const short *)default_data;
+ }
+ else if (STREQ(dp->dnatype, "int")) {
+ eprop->defaultvalue = *(const int *)default_data;
+ }
+ else {
+ has_default = false;
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "%s default: unsupported enum type (%s)\n", __func__, dp->dnatype);
+ }
+ }
+
+ if (has_default) {
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "value=%d, ", eprop->defaultvalue);
+ print_defult_info(dp);
+ }
+ }
+ }
+ }
+ }
+#else
+ UNUSED_VARS(eprop);
+#endif
}
}
@@ -2292,12 +2612,23 @@ void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop,
if (dp) {
dp->enumbitflags = 1;
+
+#ifndef RNA_RUNTIME
+ int defaultvalue_mask = 0;
+ EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
+ for (int i = 0; i < eprop->totitem; i++) {
+ if (eprop->item[i].identifier[0]) {
+ defaultvalue_mask |= eprop->defaultvalue & eprop->item[i].value;
+ }
+ }
+ eprop->defaultvalue = defaultvalue_mask;
+#endif
}
}
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
{
- /* PropertyDefRNA *dp; */
+ PropertyDefRNA *dp;
StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
StructRNA *srna = DefRNA.laststruct;
@@ -2312,12 +2643,31 @@ void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, con
return;
}
- if ((/* dp= */ rna_def_property_sdna(prop, structname, propname))) {
+ if ((dp = rna_def_property_sdna(prop, structname, propname))) {
if (prop->arraydimension) {
sprop->maxlength = prop->totarraylength;
prop->arraydimension = 0;
prop->totarraylength = 0;
}
+
+#ifndef RNA_RUNTIME
+ /* Set the default if possible. */
+ if ((dp->dnaoffset != -1) && (dp->dnapointerlevel != 0)) {
+ int SDNAnr = DNA_struct_find_nr_wrapper(DefRNA.sdna, dp->dnastructname);
+ if (SDNAnr != -1) {
+ const void *default_data = DNA_default_table[SDNAnr];
+ if (default_data) {
+ default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
+ sprop->defaultvalue = default_data;
+
+ if (debugSRNA_defaults) {
+ fprintf(stderr, "value=\"%s\", ", sprop->defaultvalue);
+ print_defult_info(dp);
+ }
+ }
+ }
+ }
+#endif
}
}
@@ -2396,8 +2746,9 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop,
structname = ds->dnaname;
}
+ int dnaoffset = 0;
if (lengthpropname[0] == 0 ||
- rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember)) {
+ rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember, &dnaoffset)) {
if (lengthpropname[0] == 0) {
dp->dnalengthfixed = prop->totarraylength;
prop->arraydimension = 0;
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index e5058626180..a7a7dde7a15 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -74,6 +74,11 @@ typedef struct PropertyDefRNA {
const char *dnatype;
int dnaarraylength;
int dnapointerlevel;
+ /**
+ * Offset in bytes within `dnastructname`.
+ * -1 when unusable (follows pointer for e.g.). */
+ int dnaoffset;
+ int dnasize;
/* for finding length of array collections */
const char *dnalengthstructname;
@@ -544,6 +549,11 @@ PointerRNA rna_array_lookup_int(
/* Duplicated code since we can't link in blenlib */
+#ifndef RNA_RUNTIME
+void *rna_alloc_from_buffer(const char *buffer, int buffer_len);
+void *rna_calloc(int buffer_len);
+#endif
+
void rna_addtail(struct ListBase *listbase, void *vlink);
void rna_freelinkN(struct ListBase *listbase, void *vlink);
void rna_freelistN(struct ListBase *listbase);
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 1ad006cbc37..3c1b30ab7bd 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -156,7 +156,10 @@ static PointerRNA rna_ViewLayer_depsgraph_get(PointerRNA *ptr)
if (GS(id->name) == ID_SCE) {
Scene *scene = (Scene *)id;
ViewLayer *view_layer = (ViewLayer *)ptr->data;
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
+ // NOTE: We don't allocate new depsgraph here, so the bmain is ignored. So it's easier to pass
+ // NULL.
+ // Still weak though.
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(NULL, scene, view_layer, false);
return rna_pointer_inherit_refine(ptr, &RNA_Depsgraph, depsgraph);
}
return PointerRNA_NULL;
@@ -177,7 +180,7 @@ static void rna_ViewLayer_update_tagged(ID *id_ptr, ViewLayer *view_layer, Main
# endif
Scene *scene = (Scene *)id_ptr;
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
/* NOTE: This is similar to CTX_data_depsgraph_pointer(). Ideally such access would be
* de-duplicated across all possible cases, but for now this is safest and easiest way to go.
*
diff --git a/source/blender/makesrna/intern/rna_light.c b/source/blender/makesrna/intern/rna_light.c
index 7357bd870fb..ecee413a8e0 100644
--- a/source/blender/makesrna/intern/rna_light.c
+++ b/source/blender/makesrna/intern/rna_light.c
@@ -150,7 +150,6 @@ static void rna_def_light(BlenderRNA *brna)
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");
@@ -165,7 +164,6 @@ static void rna_def_light(BlenderRNA *brna)
prop = RNA_def_property(srna, "cutoff_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "att_dist");
- RNA_def_property_float_default(prop, 40.0f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.01f, 100.0f, 1.0, 2);
RNA_def_property_ui_text(
@@ -196,7 +194,6 @@ static void rna_def_light_energy(StructRNA *srna, bool distant)
/* Distant light strength has no unit defined, it's proportional to
* Watt/m^2 and is not sensitive to scene unit scale. */
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.0f, 10.0f, 1, 3);
RNA_def_property_ui_text(prop, "Strength", "Amount of light emitted");
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
@@ -205,7 +202,6 @@ static void rna_def_light_energy(StructRNA *srna, bool distant)
/* Lights with a location have power in Watt, which is sensitive to
* scene unit scale. */
prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_POWER);
- RNA_def_property_float_default(prop, 10.0f);
RNA_def_property_ui_range(prop, 0.0f, 1000000.0f, 10, 5);
RNA_def_property_ui_text(prop, "Power", "Amount of light emitted");
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
@@ -289,7 +285,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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.05f);
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,
@@ -299,7 +294,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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");
@@ -319,7 +313,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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(
@@ -338,7 +331,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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",
@@ -348,7 +340,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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");
@@ -356,7 +347,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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(
@@ -366,7 +356,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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, 200.0f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop,
"Cascade Max Distance",
@@ -375,7 +364,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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");
@@ -383,7 +371,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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",
@@ -392,7 +379,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
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");
@@ -444,7 +430,6 @@ static void rna_def_area_light(BlenderRNA *brna)
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(
@@ -453,7 +438,6 @@ static void rna_def_area_light(BlenderRNA *brna)
prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE);
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(
@@ -484,14 +468,12 @@ static void rna_def_spot_light(BlenderRNA *brna)
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_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_Light_draw_update");
@@ -517,7 +499,6 @@ static void rna_def_sun_light(BlenderRNA *brna)
prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "sun_angle");
- RNA_def_property_float_default(prop, DEG2RADF(0.526f));
RNA_def_property_range(prop, DEG2RADF(0.0f), DEG2RADF(180.0f));
RNA_def_property_ui_text(prop, "Angle", "Angular diameter of the Sun as seen from the Earth");
RNA_def_property_update(prop, 0, "rna_Light_update");
diff --git a/source/blender/makesrna/intern/rna_lightprobe.c b/source/blender/makesrna/intern/rna_lightprobe.c
index 463cefdf3f0..d448bdd9401 100644
--- a/source/blender/makesrna/intern/rna_lightprobe.c
+++ b/source/blender/makesrna/intern/rna_lightprobe.c
@@ -86,7 +86,6 @@ 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(
@@ -95,7 +94,6 @@ 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(
@@ -120,13 +118,11 @@ 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);
@@ -149,7 +145,6 @@ 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);
@@ -157,28 +152,24 @@ 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");
@@ -186,7 +177,6 @@ static void rna_def_lightprobe(BlenderRNA *brna)
prop = RNA_def_property(srna, "visibility_bleed_bias", PROP_FLOAT, PROP_FACTOR);
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");
@@ -194,14 +184,12 @@ static void rna_def_lightprobe(BlenderRNA *brna)
prop = RNA_def_property(srna, "visibility_blur", PROP_FLOAT, PROP_FACTOR);
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 visibility 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(
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 8f627ce36ef..9da17c5f0b1 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -370,7 +370,6 @@ static void rna_def_material_display(StructRNA *srna)
prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "roughness");
- RNA_def_property_float_default(prop, 0.25f);
RNA_def_property_range(prop, 0, 1);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Roughness", "Roughness of the material");
@@ -378,7 +377,6 @@ static void rna_def_material_display(StructRNA *srna)
prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "spec");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0, 1);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Specular", "How intense (bright) the specular reflection is");
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 704bb11fc8a..3b01c2a944b 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -2994,7 +2994,6 @@ static void rna_def_mesh(BlenderRNA *brna)
/* Remesh */
prop = RNA_def_property(srna, "remesh_voxel_size", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "remesh_voxel_size");
- RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_range(prop, 0.00001f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0001f, FLT_MAX, 0.01, 4);
RNA_def_property_ui_text(prop,
@@ -3026,7 +3025,6 @@ static void rna_def_mesh(BlenderRNA *brna)
prop = RNA_def_property(srna, "auto_smooth_angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "smoothresh");
- RNA_def_property_float_default(prop, DEG2RADF(180.0f));
RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
RNA_def_property_ui_text(prop,
"Auto Smooth Angle",
@@ -3088,7 +3086,6 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "X Mirror", "X Axis mirror editing");
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
-# if 0
prop = RNA_def_property(srna, "use_mirror_y", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_Y);
RNA_def_property_ui_text(prop, "Y Mirror", "Y Axis mirror editing");
@@ -3096,7 +3093,6 @@ static void rna_def_mesh(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_mirror_z", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_Z);
RNA_def_property_ui_text(prop, "Z Mirror", "Z Axis mirror editing");
-# endif
prop = RNA_def_property(srna, "use_mirror_topology", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_TOPO);
diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c
index 451bdda45f5..2b2a928e280 100644
--- a/source/blender/makesrna/intern/rna_meta.c
+++ b/source/blender/makesrna/intern/rna_meta.c
@@ -332,7 +332,6 @@ static void rna_def_metaball(BlenderRNA *brna)
/* number values */
prop = RNA_def_property(srna, "resolution", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "wiresize");
- RNA_def_property_float_default(prop, 0.4f);
RNA_def_property_range(prop, 0.005f, 10000.0f);
RNA_def_property_ui_range(prop, 0.05f, 1000.0f, 2.5f, 3);
RNA_def_property_ui_text(prop, "Wire Size", "Polygonization resolution in the 3D viewport");
@@ -340,7 +339,6 @@ static void rna_def_metaball(BlenderRNA *brna)
prop = RNA_def_property(srna, "render_resolution", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "rendersize");
- RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_range(prop, 0.005f, 10000.0f);
RNA_def_property_ui_range(prop, 0.025f, 1000.0f, 2.5f, 3);
RNA_def_property_ui_text(prop, "Render Size", "Polygonization resolution in rendering");
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index a6481341868..c2c937a75f8 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -5729,7 +5729,7 @@ static void def_cmp_inpaint(StructRNA *srna)
prop = RNA_def_property(srna, "distance", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom2");
- RNA_def_property_range(prop, 1, 10000);
+ RNA_def_property_range(prop, 0, 10000);
RNA_def_property_ui_text(prop, "Distance", "Distance to inpaint (number of iterations)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index f12607c8515..d27b74d9be4 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2664,7 +2664,6 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "quat");
RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
- RNA_def_property_float_array_default(prop, rna_default_quaternion);
RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
@@ -2701,7 +2700,6 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
- RNA_def_property_float_array_default(prop, rna_default_scale_3d);
RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
@@ -2738,7 +2736,6 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
RNA_def_property_float_sdna(prop, NULL, "dquat");
- RNA_def_property_float_array_default(prop, rna_default_quaternion);
RNA_def_property_ui_text(
prop,
"Delta Rotation (Quaternion)",
@@ -2761,7 +2758,6 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "dscale");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
- RNA_def_property_float_array_default(prop, rna_default_scale_3d);
RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 2f460e79ec9..e514fd82aca 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -274,6 +274,12 @@ static void rna_PoseChannel_rotation_mode_set(PointerRNA *ptr, int value)
pchan->rotmode = value;
}
+static float rna_PoseChannel_length_get(PointerRNA *ptr)
+{
+ bPoseChannel *pchan = ptr->data;
+ return len_v3v3(pchan->pose_head, pchan->pose_tail);
+}
+
static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value)
{
Object *ob = (Object *)ptr->owner_id;
@@ -1135,6 +1141,11 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_funcs(prop, "rna_PoseChannel_length_get", NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Length", "Length of the bone");
+
/* IK Settings */
prop = RNA_def_property(srna, "is_in_ik_chain", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_PoseChannel_has_ik_get", NULL);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index f13f588455d..3f4250930fc 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -713,20 +713,7 @@ static void rna_ToolSettings_snap_mode_set(struct PointerRNA *ptr, int value)
/* Grease Pencil update cache */
static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
- /* mark all grease pencil datablocks of the scene */
- FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) {
- FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (collection, ob) {
- if (ob->type == OB_GPENCIL) {
- bGPdata *gpd = (bGPdata *)ob->data;
- gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- }
- }
- FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
- }
- FOREACH_SCENE_COLLECTION_END;
-
- WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+ ED_gpencil_tag_scene_gpencil(scene);
}
/* Grease Pencil Interpolation settings */
@@ -2713,7 +2700,6 @@ static void rna_def_view3d_cursor(BlenderRNA *brna)
prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_float_sdna(prop, NULL, "rotation_quaternion");
- RNA_def_property_float_array_default(prop, rna_default_quaternion);
RNA_def_property_ui_text(
prop, "Quaternion Rotation", "Rotation in quaternions (keep normalized)");
RNA_def_property_update(prop, NC_WINDOW, NULL);
@@ -3636,7 +3622,6 @@ static void rna_def_statvis(BlenderRNA *brna)
/* overhang */
prop = RNA_def_property(srna, "overhang_min", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "overhang_min");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "Overhang Min", "Minimum angle to display");
@@ -3645,7 +3630,6 @@ static void rna_def_statvis(BlenderRNA *brna)
prop = RNA_def_property(srna, "overhang_max", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "overhang_max");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "Overhang Max", "Maximum angle to display");
@@ -3662,7 +3646,6 @@ static void rna_def_statvis(BlenderRNA *brna)
/* thickness */
prop = RNA_def_property(srna, "thickness_min", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "thickness_min");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, 1000.0);
RNA_def_property_ui_range(prop, 0.0f, 100.0, 0.001, 3);
RNA_def_property_ui_text(prop, "Thickness Min", "Minimum for measuring thickness");
@@ -3671,7 +3654,6 @@ static void rna_def_statvis(BlenderRNA *brna)
prop = RNA_def_property(srna, "thickness_max", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "thickness_max");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, 1000.0);
RNA_def_property_ui_range(prop, 0.0f, 100.0, 0.001, 3);
RNA_def_property_ui_text(prop, "Thickness Max", "Maximum for measuring thickness");
@@ -3688,7 +3670,6 @@ static void rna_def_statvis(BlenderRNA *brna)
/* distort */
prop = RNA_def_property(srna, "distort_min", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "distort_min");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "Distort Min", "Minimum angle to display");
@@ -3697,7 +3678,6 @@ static void rna_def_statvis(BlenderRNA *brna)
prop = RNA_def_property(srna, "distort_max", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "distort_max");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "Distort Max", "Maximum angle to display");
@@ -3707,7 +3687,6 @@ static void rna_def_statvis(BlenderRNA *brna)
/* sharp */
prop = RNA_def_property(srna, "sharp_min", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "sharp_min");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, -DEG2RADF(180.0f), DEG2RADF(180.0f));
RNA_def_property_ui_range(prop, -DEG2RADF(180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "Distort Min", "Minimum angle to display");
@@ -3716,7 +3695,6 @@ static void rna_def_statvis(BlenderRNA *brna)
prop = RNA_def_property(srna, "sharp_max", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "sharp_max");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, -DEG2RADF(180.0f), DEG2RADF(180.0f));
RNA_def_property_ui_range(prop, -DEG2RADF(180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "Distort Max", "Maximum angle to display");
@@ -5733,7 +5711,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "preview_start_resolution", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 8, 16384);
- RNA_def_property_int_default(prop, 64);
RNA_def_property_ui_text(prop,
"Start Resolution",
"Resolution to start rendering preview at, "
@@ -6087,7 +6064,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "bake_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "bake_samples");
RNA_def_property_range(prop, 64, 1024);
- RNA_def_property_int_default(prop, 256);
RNA_def_property_ui_text(
prop, "Samples", "Number of samples used for ambient occlusion baking from multires");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
@@ -6400,6 +6376,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Layers Blending", "Do not display blend layers");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "simplify_gpencil_tint", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_TINT);
+ RNA_def_property_ui_text(prop, "Layers Tinting", "Do not display layer tint");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
/* persistent data */
prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_PERSISTENT_DATA);
@@ -6597,12 +6578,6 @@ static void rna_def_display_safe_areas(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static float default_title[2] = {0.1f, 0.05f};
- static float default_action[2] = {0.035f, 0.035f};
-
- static float default_title_center[2] = {0.175f, 0.05f};
- static float default_action_center[2] = {0.15f, 0.05f};
-
srna = RNA_def_struct(brna, "DisplaySafeAreas", NULL);
RNA_def_struct_ui_text(srna, "Safe Areas", "Safe areas used in 3D view and the sequencer");
RNA_def_struct_sdna(srna, "DisplaySafeAreas");
@@ -6612,14 +6587,12 @@ static void rna_def_display_safe_areas(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "title");
RNA_def_property_array(prop, 2);
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_float_array_default(prop, default_title);
RNA_def_property_ui_text(prop, "Title Safe Margins", "Safe area for text and graphics");
RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL);
prop = RNA_def_property(srna, "action", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "action");
RNA_def_property_array(prop, 2);
- RNA_def_property_float_array_default(prop, default_action);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Action Safe Margins", "Safe area for general elements");
RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL);
@@ -6627,7 +6600,6 @@ static void rna_def_display_safe_areas(BlenderRNA *brna)
prop = RNA_def_property(srna, "title_center", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "title_center");
RNA_def_property_array(prop, 2);
- RNA_def_property_float_array_default(prop, default_title_center);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop,
"Center Title Safe Margins",
@@ -6637,7 +6609,6 @@ static void rna_def_display_safe_areas(BlenderRNA *brna)
prop = RNA_def_property(srna, "action_center", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "action_center");
RNA_def_property_array(prop, 2);
- RNA_def_property_float_array_default(prop, default_action_center);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop,
"Center Action Safe Margins",
@@ -6650,8 +6621,6 @@ static void rna_def_scene_display(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static float default_light_direction[3] = {-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3};
-
srna = RNA_def_struct(brna, "SceneDisplay", NULL);
RNA_def_struct_ui_text(srna, "Scene Display", "Scene display settings for 3d viewport");
RNA_def_struct_sdna(srna, "SceneDisplay");
@@ -6660,13 +6629,11 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "light_direction");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_array(prop, 3);
- RNA_def_property_float_array_default(prop, default_light_direction);
RNA_def_property_ui_text(
prop, "Light Direction", "Direction of the light for shadows and highlights");
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
prop = RNA_def_property(srna, "shadow_shift", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_default(prop, 0.1);
RNA_def_property_ui_text(prop, "Shadow Shift", "Shadow termination angle");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 2);
@@ -6682,20 +6649,17 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
prop = RNA_def_property(srna, "matcap_ssao_distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_ui_text(
prop, "Distance", "Distance of object that contribute to the Cavity/Edge effect");
RNA_def_property_range(prop, 0.0f, 100000.0f);
RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
prop = RNA_def_property(srna, "matcap_ssao_attenuation", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Attenuation", "Attenuation constant");
RNA_def_property_range(prop, 1.0f, 100000.0f);
RNA_def_property_ui_range(prop, 1.0f, 100.0f, 1, 3);
prop = RNA_def_property(srna, "matcap_ssao_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_default(prop, 16);
RNA_def_property_ui_text(prop, "Samples", "Number of samples");
RNA_def_property_range(prop, 1, 500);
@@ -6748,15 +6712,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- static float default_bloom_color[3] = {1.0f, 1.0f, 1.0f};
-
srna = RNA_def_struct(brna, "SceneEEVEE", NULL);
RNA_def_struct_path_func(srna, "rna_SceneEEVEE_path");
RNA_def_struct_ui_text(srna, "Scene Display", "Scene display settings for 3d viewport");
/* Indirect Lighting */
prop = RNA_def_property(srna, "gi_diffuse_bounces", PROP_INT, PROP_NONE);
- RNA_def_property_int_default(prop, 3);
RNA_def_property_ui_text(prop,
"Diffuse Bounces",
"Number of time the light is reinjected inside light grids, "
@@ -6766,13 +6727,11 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "gi_cubemap_resolution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, eevee_shadow_size_items);
- RNA_def_property_enum_default(prop, 512);
RNA_def_property_ui_text(prop, "Cubemap Size", "Size of every cubemaps");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "gi_visibility_resolution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, eevee_gi_visibility_size_items);
- RNA_def_property_enum_default(prop, 32);
RNA_def_property_ui_text(prop,
"Irradiance Visibility Size",
"Size of the shadow map applied to each irradiance sample");
@@ -6781,7 +6740,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "gi_irradiance_smoothing", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 5, 2);
- RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_ui_text(prop,
"Irradiance Smoothing",
"Smoother irradiance interpolation but introduce light bleeding");
@@ -6789,7 +6747,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "gi_glossy_clamp", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_ui_text(prop,
"Clamp Glossy",
"Clamp pixel intensity to reduce noise inside glossy reflections "
@@ -6798,7 +6755,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "gi_filter_quality", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_default(prop, 3.0f);
RNA_def_property_ui_text(
prop, "Filter Quality", "Take more samples during cubemap filtering to remove artifacts");
RNA_def_property_range(prop, 1.0f, 8.0f);
@@ -6806,7 +6762,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
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_icon(prop, ICON_HIDE_ON, 1);
RNA_def_property_ui_text(
prop, "Show Irradiance Cache", "Display irradiance samples in the viewport");
@@ -6815,7 +6770,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
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_icon(prop, ICON_HIDE_ON, 1);
RNA_def_property_ui_text(
prop, "Show Cubemap Cache", "Display captured cubemaps in the viewport");
@@ -6825,7 +6779,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "gi_irradiance_display_size", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "gi_irradiance_draw_size");
RNA_def_property_range(prop, 0.05f, 10.0f);
- RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_ui_text(prop,
"Irradiance Display Size",
"Size of the irradiance sample spheres to debug captured light");
@@ -6834,14 +6787,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "gi_cubemap_display_size", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "gi_cubemap_draw_size");
RNA_def_property_range(prop, 0.05f, 10.0f);
- RNA_def_property_float_default(prop, 0.3f);
RNA_def_property_ui_text(
prop, "Cubemap Display Size", "Size of the cubemap spheres to debug captured light");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
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);
@@ -6851,14 +6802,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Temporal Anti-Aliasing (super sampling) */
prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_default(prop, 16);
RNA_def_property_ui_text(prop, "Viewport Samples", "Number of samples, unlimited if 0");
RNA_def_property_range(prop, 0, INT_MAX);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "taa_render_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_default(prop, 64);
RNA_def_property_ui_text(prop, "Render Samples", "Number of samples per pixels for rendering");
RNA_def_property_range(prop, 1, INT_MAX);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
@@ -6866,7 +6815,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_taa_reprojection", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_TAA_REPROJECTION);
- RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop,
"Viewport Denoising",
"Denoise image using temporal reprojection "
@@ -6876,14 +6824,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Screen Space Subsurface Scattering */
prop = RNA_def_property(srna, "sss_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_default(prop, 7);
RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute the scattering effect");
RNA_def_property_range(prop, 1, 32);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "sss_jitter_threshold", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.3f);
RNA_def_property_ui_text(
prop, "Jitter Threshold", "Rotate samples that are below this threshold");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -6893,34 +6839,29 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Screen Space Reflection */
prop = RNA_def_property(srna, "use_ssr", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_ENABLED);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Screen Space Reflections", "Enable screen space reflection");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "use_ssr_refraction", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_REFRACTION);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Screen Space Refractions", "Enable screen space Refractions");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "use_ssr_halfres", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_HALF_RESOLUTION);
- RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop, "Half Res Trace", "Raytrace at a lower resolution");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "ssr_quality", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.25f);
RNA_def_property_ui_text(prop, "Trace Precision", "Precision of the screen space raytracing");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "ssr_max_roughness", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(
prop, "Max Roughness", "Do not raytrace reflections for roughness above this value");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -6928,7 +6869,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "ssr_thickness", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_ui_text(prop, "Thickness", "Pixel thickness used to detect intersection");
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 5, 3);
@@ -6936,14 +6876,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "ssr_border_fade", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.075f);
RNA_def_property_ui_text(prop, "Edge Fading", "Screen percentage used to fade the SSR");
RNA_def_property_range(prop, 0.0f, 0.5f);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "ssr_firefly_fac", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_default(prop, 10.0f);
RNA_def_property_ui_text(prop, "Clamp", "Clamp pixel intensity to remove noise (0 to disabled)");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
@@ -6951,7 +6889,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Volumetrics */
prop = RNA_def_property(srna, "volumetric_start", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_ui_text(prop, "Start", "Start distance of the volumetric effect");
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
@@ -6959,7 +6896,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "volumetric_end", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_default(prop, 100.0f);
RNA_def_property_ui_text(prop, "End", "End distance of the volumetric effect");
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
@@ -6967,7 +6903,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "volumetric_tile_size", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_default(prop, 8);
RNA_def_property_enum_items(prop, eevee_volumetric_tile_size_items);
RNA_def_property_ui_text(prop,
"Tile Size",
@@ -6977,14 +6912,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "volumetric_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_default(prop, 64);
RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute volumetric effects");
RNA_def_property_range(prop, 1, 256);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "volumetric_sample_distribution", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_ui_text(
prop, "Exponential Sampling", "Distribute more samples closer to the camera");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
@@ -6992,14 +6925,12 @@ 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 light interactions with volumetrics");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Clamp", "Maximum light contribution, reducing noise");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
@@ -7007,14 +6938,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_volumetric_shadows", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_SHADOWS);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(
prop, "Volumetric Shadows", "Generate shadows from volumetric material (Very expensive)");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "volumetric_shadow_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_default(prop, 16);
RNA_def_property_range(prop, 1, 128);
RNA_def_property_ui_text(
prop, "Volumetric Shadow Samples", "Number of samples to compute volumetric shadowing");
@@ -7024,7 +6953,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Ambient Occlusion */
prop = RNA_def_property(srna, "use_gtao", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_ENABLED);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop,
"Ambient Occlusion",
"Enable ambient occlusion to simulate medium scale indirect shadowing");
@@ -7033,7 +6961,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_gtao_bent_normals", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_BENT_NORMALS);
- RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(
prop, "Bent Normals", "Compute main non occluded direction to sample the environment");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
@@ -7041,7 +6968,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_gtao_bounce", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_BOUNCE);
- RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop,
"Bounces Approximation",
"An approximation to simulate light bounces "
@@ -7050,7 +6976,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "gtao_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 2);
@@ -7058,14 +6983,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "gtao_quality", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.25f);
RNA_def_property_ui_text(prop, "Trace Precision", "Precision of the horizon search");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "gtao_distance", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_ui_text(
prop, "Distance", "Distance of object that contribute to the ambient occlusion effect");
RNA_def_property_range(prop, 0.0f, 100000.0f);
@@ -7075,7 +6998,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Depth of Field */
prop = RNA_def_property(srna, "bokeh_max_size", PROP_FLOAT, PROP_PIXEL);
- RNA_def_property_float_default(prop, 100.0f);
RNA_def_property_ui_text(
prop, "Max Size", "Max size of the bokeh shape for the depth of field (lower is faster)");
RNA_def_property_range(prop, 0.0f, 2000.0f);
@@ -7083,7 +7005,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "bokeh_threshold", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(
prop, "Sprite Threshold", "Brightness threshold for using sprite base depth of field");
RNA_def_property_range(prop, 0.0f, 100000.0f);
@@ -7094,13 +7015,11 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Bloom */
prop = RNA_def_property(srna, "use_bloom", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_BLOOM_ENABLED);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Bloom", "High brightness pixels generate a glowing effect");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "bloom_threshold", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_ui_text(prop, "Threshold", "Filters out pixels under this level of brightness");
RNA_def_property_range(prop, 0.0f, 100000.0f);
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
@@ -7108,21 +7027,18 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "bloom_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_array_default(prop, default_bloom_color);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Color", "Color applied to the bloom effect");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "bloom_knee", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Knee", "Makes transition between under/over-threshold gradual");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "bloom_radius", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 6.5f);
RNA_def_property_ui_text(prop, "Radius", "Bloom spread distance");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
@@ -7130,7 +7046,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "bloom_clamp", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_ui_text(
prop, "Clamp", "Maximum intensity a bloom pixel can have (0 to disabled)");
RNA_def_property_range(prop, 0.0f, 100000.0f);
@@ -7139,7 +7054,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "bloom_intensity", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 0.05f);
RNA_def_property_ui_text(prop, "Intensity", "Blend factor");
RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_ui_range(prop, 0.0f, 0.1f, 1, 3);
@@ -7149,20 +7063,17 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Motion blur */
prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_MOTION_BLUR_ENABLED);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Motion Blur", "Enable motion blur effect (only in camera view)");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_default(prop, 8);
RNA_def_property_ui_text(prop, "Samples", "Number of samples to take with motion blur");
RNA_def_property_range(prop, 1, 64);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 2);
@@ -7171,7 +7082,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Shadows */
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 light shadow maps");
@@ -7179,7 +7089,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
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 light shadow maps");
@@ -7188,21 +7097,18 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHADOW_HIGH_BITDEPTH);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "High Bitdepth", "Use 32bit shadows");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "use_soft_shadows", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHADOW_SOFT);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(
prop, "Soft Shadows", "Randomize shadowmaps origin to create soft shadows");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "light_threshold", PROP_FLOAT, PROP_UNSIGNED);
- RNA_def_property_float_default(prop, 0.01f);
RNA_def_property_ui_text(prop,
"Light Threshold",
"Minimum light intensity for a light to contribute to the lighting");
@@ -7214,7 +7120,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
/* Overscan */
prop = RNA_def_property(srna, "use_overscan", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_OVERSCAN);
- RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop,
"Overscan",
"Internally render past the image border to avoid "
@@ -7223,7 +7128,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "overscan_size", PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_sdna(prop, NULL, "overscan");
- RNA_def_property_float_default(prop, 3.0f);
RNA_def_property_ui_text(prop,
"Overscan Size",
"Percentage of render size to add as overscan to the "
@@ -7558,7 +7462,6 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "r.sfra");
RNA_def_property_int_funcs(prop, NULL, "rna_Scene_start_frame_set", NULL);
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
- RNA_def_property_int_default(prop, 1);
RNA_def_property_ui_text(prop, "Start Frame", "First frame of the playback/rendering range");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL);
@@ -7567,7 +7470,6 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "r.efra");
RNA_def_property_int_funcs(prop, NULL, "rna_Scene_end_frame_set", NULL);
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
- RNA_def_property_int_default(prop, 250);
RNA_def_property_ui_text(prop, "End Frame", "Final frame of the playback/rendering range");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL);
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index bea22d465a9..2b1b23a40f4 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -80,7 +80,7 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf
for (ViewLayer *view_layer = scene->view_layers.first; view_layer != NULL;
view_layer = view_layer->next) {
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
}
@@ -156,7 +156,7 @@ static void rna_Scene_ray_cast(Scene *scene,
{
normalize_v3(direction);
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, depsgraph, 0);
bool ret = ED_transform_snap_object_project_ray_ex(sctx,
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 7ec666ada1c..5d735524f36 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -162,24 +162,13 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
# include "DEG_depsgraph.h"
+# include "ED_gpencil.h"
# include "ED_particle.h"
static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
/* mark all grease pencil datablocks of the scene */
- FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) {
- FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (collection, ob) {
- if (ob->type == OB_GPENCIL) {
- bGPdata *gpd = (bGPdata *)ob->data;
- gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- }
- }
- FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
- }
- FOREACH_SCENE_COLLECTION_END;
-
- WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+ ED_gpencil_tag_scene_gpencil(scene);
}
const EnumPropertyItem rna_enum_particle_edit_disconnected_hair_brush_items[] = {
@@ -1361,7 +1350,6 @@ static void rna_def_gpencil_guides(BlenderRNA *brna)
prop = RNA_def_property(srna, "spacing", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "spacing");
- RNA_def_property_float_default(prop, 0.01f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 3);
RNA_def_property_ui_text(prop, "Spacing", "Guide spacing");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 8f64bd691ce..e01432c7261 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -456,6 +456,7 @@ const EnumPropertyItem rna_enum_file_sort_items[] = {
# include "BKE_brush.h"
# include "BKE_colortools.h"
# include "BKE_context.h"
+# include "BKE_idprop.h"
# include "BKE_layer.h"
# include "BKE_global.h"
# include "BKE_nla.h"
@@ -936,6 +937,18 @@ static bool rna_RegionView3D_is_orthographic_side_view_get(PointerRNA *ptr)
return RV3D_VIEW_IS_AXIS(rv3d->view);
}
+static IDProperty *rna_View3DShading_idprops(PointerRNA *ptr, bool create)
+{
+ View3DShading *shading = ptr->data;
+
+ if (create && !shading->prop) {
+ IDPropertyTemplate val = {0};
+ shading->prop = IDP_New(IDP_GROUP, &val, "View3DShading ID properties");
+ }
+
+ return shading->prop;
+}
+
static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ID *id = ptr->owner_id;
@@ -2990,7 +3003,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
"Use a custom color limited to this viewport only"},
{0, NULL, 0, NULL, NULL},
};
- static const float default_background_color[] = {0.05f, 0.05f, 0.05f};
static const EnumPropertyItem cavity_type_items[] = {
{V3D_SHADING_CAVITY_SSAO,
@@ -3013,6 +3025,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
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");
+ RNA_def_struct_idprops_func(srna, "rna_View3DShading_idprops");
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_shading_type_items);
@@ -3072,7 +3085,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "curvature_ridge_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "curvature_ridge_factor");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Curvature Ridge", "Factor for the curvature ridges");
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -3080,7 +3092,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "curvature_valley_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "curvature_valley_factor");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Curvature Valley", "Factor for the curvature valleys");
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -3088,7 +3099,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "cavity_ridge_factor", PROP_FLOAT, PROP_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, "Cavity Ridge", "Factor for the cavity ridges");
RNA_def_property_range(prop, 0.0f, 250.0f);
RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3);
@@ -3097,7 +3107,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "cavity_valley_factor", PROP_FLOAT, PROP_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, "Cavity Valley", "Factor for the cavity valleys");
RNA_def_property_range(prop, 0.0f, 250.0f);
RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3);
@@ -3115,7 +3124,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "studiolight_rotate_z", PROP_FLOAT, PROP_ANGLE);
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);
@@ -3124,7 +3132,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "studiolight_intensity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "studiolight_intensity");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Strength", "Strength of the studiolight");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
@@ -3133,7 +3140,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "studiolight_background_alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "studiolight_background");
- RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_ui_text(prop, "Background", "Show the studiolight in the background");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
@@ -3169,7 +3175,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "background_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 3);
- RNA_def_property_float_array_default(prop, default_background_color);
RNA_def_property_ui_text(prop, "Background Color", "Color for custom background color");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -3194,7 +3199,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "xray_alpha", PROP_FLOAT, PROP_FACTOR);
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);
@@ -3202,7 +3206,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "xray_alpha_wireframe", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "xray_alpha_wire");
- 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);
@@ -3233,14 +3236,12 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_scene_lights_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_LIGHTS_RENDER);
- RNA_def_property_boolean_default(prop, true);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
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_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_WORLD_RENDER);
- RNA_def_property_boolean_default(prop, true);
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);
@@ -3260,7 +3261,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "shadow_intensity", PROP_FLOAT, PROP_FACTOR);
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);
RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
@@ -3315,7 +3315,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Grid Scale", "Distance between 3D View grid lines");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, 1000.0f, 0.1f, 3);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "grid_lines", PROP_INT, PROP_NONE);
@@ -3323,14 +3322,12 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Grid Lines", "Number of grid lines to display in perspective view");
RNA_def_property_range(prop, 0, 1024);
- RNA_def_property_int_default(prop, 16);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "grid_subdivisions", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gridsubdiv");
RNA_def_property_ui_text(prop, "Grid Subdivisions", "Number of subdivisions between grid lines");
RNA_def_property_range(prop, 1, 1024);
- RNA_def_property_int_default(prop, 10);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "grid_scale_unit", PROP_FLOAT, PROP_NONE);
@@ -3403,7 +3400,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "xray_alpha_bone", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.xray_alpha_bone");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Opacity", "Opacity to use for bone selection");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -3436,7 +3432,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "wireframe_threshold", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.wireframe_threshold");
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(
prop, "Wireframe Threshold", "Adjust the number of wires displayed (1 for all wires)");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -3603,7 +3598,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "texture_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.texture_paint_mode_opacity");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(
prop, "Stencil Opacity", "Opacity of the texture paint mode stencil mask overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -3611,7 +3605,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "vertex_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.vertex_paint_mode_opacity");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(
prop, "Vertex Paint Opacity", "Opacity of the vertex paint mode overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -3619,7 +3612,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "weight_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.weight_paint_mode_opacity");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(
prop, "Weight Paint Opacity", "Opacity of the weight paint mode overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -3627,7 +3619,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "sculpt_mode_mask_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_mode_mask_opacity");
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Sculpt Mask Opacity", "");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -3666,7 +3657,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "gpencil_grid_opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_grid_opacity");
RNA_def_property_range(prop, 0.1f, 1.0f);
- RNA_def_property_float_default(prop, 0.9f);
RNA_def_property_ui_text(prop, "Opacity", "Canvas grid opacity");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -3674,7 +3664,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "gpencil_paper_opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_paper_opacity");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Opacity", "Fade factor");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -3823,7 +3812,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
- RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_ui_text(
prop, "Clip Start", "3D View near clipping distance (perspective view only)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -3831,7 +3819,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
- RNA_def_property_float_default(prop, 1000.0f);
RNA_def_property_ui_text(prop, "Clip End", "3D View far clipping distance");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c
index 52a197240da..cbaa407646f 100644
--- a/source/blender/makesrna/intern/rna_space_api.c
+++ b/source/blender/makesrna/intern/rna_space_api.c
@@ -40,6 +40,7 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C)
area_region_from_regiondata(sc, rv3d, &sa, &ar);
if (sa && ar && sa->spacetype == SPACE_VIEW3D) {
+ Main *bmain = CTX_data_main(C);
View3D *v3d = sa->spacedata.first;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
@@ -48,7 +49,7 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C)
if (WM_window_get_active_screen(win) == sc) {
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL, false);
break;
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 37fee576fde..548111500ad 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -1504,6 +1504,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Shading", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+ prop = RNA_def_property(srna, "icon_folder", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "icon_folder");
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_ui_text(prop, "File Folders", "Color of folders in the file browser");
+ RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+
prop = RNA_def_property(srna, "icon_border_intensity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "icon_border_intensity");
RNA_def_property_ui_text(
@@ -4053,7 +4059,6 @@ static void rna_def_userdef_view(BlenderRNA *brna)
prop, "UI Scale", "Changes the size of the fonts and widgets in the interface");
RNA_def_property_range(prop, 0.25f, 4.0f);
RNA_def_property_ui_range(prop, 0.5f, 2.0f, 1, 2);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
prop = RNA_def_property(srna, "ui_line_width", PROP_ENUM, PROP_NONE);
@@ -4319,7 +4324,6 @@ static void rna_def_userdef_view(BlenderRNA *brna)
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, "Gizmo Size", "Diameter of the gizmo");
RNA_def_property_update(prop, 0, "rna_userdef_update");
@@ -4327,7 +4331,6 @@ static void rna_def_userdef_view(BlenderRNA *brna)
prop = RNA_def_property(srna, "lookdev_sphere_size", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "lookdev_sphere_size");
RNA_def_property_range(prop, 50, 400);
- RNA_def_property_int_default(prop, 150);
RNA_def_property_ui_text(
prop, "Look Dev Spheres Size", "Maximum diameter of the look development sphere size");
RNA_def_property_update(prop, 0, "rna_userdef_update");
@@ -5257,7 +5260,6 @@ static void rna_def_userdef_input(BlenderRNA *brna)
prop = RNA_def_property(srna, "view_rotate_sensitivity_turntable", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_range(prop, DEG2RADF(0.001f), DEG2RADF(15.0f));
- RNA_def_property_float_default(prop, DEG2RADF(0.4f));
RNA_def_property_ui_range(prop, DEG2RADF(0.001f), DEG2RADF(15.0f), 1.0f, 2);
RNA_def_property_ui_text(prop,
"Orbit Sensitivity",
@@ -5265,7 +5267,6 @@ static void rna_def_userdef_input(BlenderRNA *brna)
prop = RNA_def_property(srna, "view_rotate_sensitivity_trackball", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.1f, 10.0f);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_range(prop, 0.1f, 2.0f, 0.01f, 2);
RNA_def_property_ui_text(prop, "Orbit Sensitivity", "Scale trackball orbit sensitivity");
@@ -5305,7 +5306,6 @@ static void rna_def_userdef_input(BlenderRNA *brna)
/* tablet pressure curve */
prop = RNA_def_property(srna, "pressure_threshold_max", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01f, 3);
RNA_def_property_ui_text(
prop, "Max Threshold", "Raw input pressure value that is interpreted as 100% by Blender");
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index b5f4d26220a..70f76896898 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -32,6 +32,7 @@
#include "BLI_utildefines.h"
+#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_scene.h"
@@ -238,7 +239,7 @@ static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self,
BLI_assert(BKE_id_is_in_global_main(&scene->id));
- depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ depsgraph = BKE_scene_get_depsgraph(G_MAIN, scene, view_layer, true);
rv3d_mats = ED_view3d_mats_rv3d_backup(ar->regiondata);
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 77d036532f4..2fbefe3be74 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -36,7 +36,10 @@
#include "BPY_extern.h"
-void bpy_app_generic_callback(struct Main *main, struct ID *id, void *arg);
+void bpy_app_generic_callback(struct Main *main,
+ struct PointerRNA **pointers,
+ const int num_pointers,
+ void *arg);
static PyTypeObject BlenderAppCbType;
@@ -290,32 +293,55 @@ void BPY_app_handlers_reset(const short do_all)
PyGILState_Release(gilstate);
}
+static PyObject *choose_arguments(PyObject *func, PyObject *args_all, PyObject *args_single)
+{
+ if (!PyFunction_Check(func)) {
+ return args_all;
+ }
+ PyCodeObject *code = (PyCodeObject *)PyFunction_GetCode(func);
+ if (code->co_argcount == 1) {
+ return args_single;
+ }
+ return args_all;
+}
+
/* the actual callback - not necessarily called from py */
-void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *arg)
+void bpy_app_generic_callback(struct Main *UNUSED(main),
+ struct PointerRNA **pointers,
+ const int num_pointers,
+ void *arg)
{
PyObject *cb_list = py_cb_array[POINTER_AS_INT(arg)];
if (PyList_GET_SIZE(cb_list) > 0) {
PyGILState_STATE gilstate = PyGILState_Ensure();
- PyObject *args = PyTuple_New(1); /* save python creating each call */
+ const int num_arguments = 2;
+ PyObject *args_all = PyTuple_New(num_arguments); /* save python creating each call */
+ PyObject *args_single = PyTuple_New(1);
PyObject *func;
PyObject *ret;
Py_ssize_t pos;
/* setup arguments */
- if (id) {
- PointerRNA id_ptr;
- RNA_id_pointer_create(id, &id_ptr);
- PyTuple_SET_ITEM(args, 0, pyrna_struct_CreatePyObject(&id_ptr));
+ for (int i = 0; i < num_pointers; ++i) {
+ PyTuple_SET_ITEM(args_all, i, pyrna_struct_CreatePyObject(pointers[i]));
+ }
+ for (int i = num_pointers; i < num_arguments; ++i) {
+ PyTuple_SET_ITEM(args_all, i, Py_INCREF_RET(Py_None));
+ }
+
+ if (num_pointers == 0) {
+ PyTuple_SET_ITEM(args_single, 0, Py_INCREF_RET(Py_None));
}
else {
- PyTuple_SET_ITEM(args, 0, Py_INCREF_RET(Py_None));
+ PyTuple_SET_ITEM(args_single, 0, pyrna_struct_CreatePyObject(pointers[0]));
}
/* Iterate the list and run the callbacks
* note: don't store the list size since the scripts may remove themselves */
for (pos = 0; pos < PyList_GET_SIZE(cb_list); pos++) {
func = PyList_GET_ITEM(cb_list, pos);
+ PyObject *args = choose_arguments(func, args_all, args_single);
ret = PyObject_Call(func, args, NULL);
if (ret == NULL) {
/* Don't set last system variables because they might cause some
@@ -332,7 +358,8 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
}
}
- Py_DECREF(args);
+ Py_DECREF(args_all);
+ Py_DECREF(args_single);
PyGILState_Release(gilstate);
}
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index 0db1a4b81ae..d3080ebe3ed 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -509,7 +509,7 @@ static void engine_depsgraph_init(RenderEngine *engine, ViewLayer *view_layer)
Main *bmain = engine->re->main;
Scene *scene = engine->re->scene;
- engine->depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
+ engine->depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER);
DEG_debug_name_set(engine->depsgraph, "RENDER");
if (engine->re->r.scemode & R_BUTS_PREVIEW) {
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index e7ac70dd57f..fdb90a6e91e 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -134,6 +134,24 @@ static struct {
ListBase renderlist;
} RenderGlobal = {{NULL, NULL}};
+/* ********* callbacks ******** */
+
+static void render_callback_exec_null(Render *re, Main *bmain, eCbEvent evt)
+{
+ if (re->r.scemode & R_BUTS_PREVIEW) {
+ return;
+ }
+ BKE_callback_exec_null(bmain, evt);
+}
+
+static void render_callback_exec_id(Render *re, Main *bmain, ID *id, eCbEvent evt)
+{
+ if (re->r.scemode & R_BUTS_PREVIEW) {
+ return;
+ }
+ BKE_callback_exec_id(bmain, id, evt);
+}
+
/* ********* alloc and free ******** */
static int do_write_image_or_movie(Render *re,
@@ -226,7 +244,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
/* NOTE: using G_MAIN seems valid here???
* Not sure it's actually even used anyway, we could as well pass NULL? */
- BKE_callback_exec(G_MAIN, NULL, BKE_CB_EVT_RENDER_STATS);
+ BKE_callback_exec_null(G_MAIN, BKE_CB_EVT_RENDER_STATS);
fputc('\n', stdout);
fflush(stdout);
@@ -1953,7 +1971,7 @@ static void update_physics_cache(Render *re,
baker.bmain = re->main;
baker.scene = scene;
baker.view_layer = view_layer;
- baker.depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ baker.depsgraph = BKE_scene_get_depsgraph(re->main, scene, view_layer, true);
baker.bake = 0;
baker.render = 1;
baker.anim_init = 1;
@@ -2069,7 +2087,7 @@ static void render_init_depsgraph(Render *re)
Scene *scene = re->scene;
ViewLayer *view_layer = BKE_view_layer_default_render(re->scene);
- re->pipeline_depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
+ re->pipeline_depsgraph = DEG_graph_new(re->main, scene, view_layer, DAG_EVAL_RENDER);
DEG_debug_name_set(re->pipeline_depsgraph, "RENDER PIPELINE");
/* Make sure there is a correct evaluated scene pointer. */
@@ -2090,7 +2108,7 @@ void RE_RenderFrame(Render *re,
int frame,
const bool write_still)
{
- BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_INIT);
+ render_callback_exec_id(re, re->main, &scene->id, BKE_CB_EVT_RENDER_INIT);
/* Ugly global still...
* is to prevent preview events and signal subsurfs etc to make full resol. */
@@ -2103,9 +2121,9 @@ void RE_RenderFrame(Render *re,
const RenderData rd = scene->r;
MEM_reset_peak_memory();
- render_init_depsgraph(re);
+ render_callback_exec_id(re, re->main, &scene->id, BKE_CB_EVT_RENDER_PRE);
- BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_PRE);
+ render_init_depsgraph(re);
do_render_all_options(re);
@@ -2131,14 +2149,16 @@ void RE_RenderFrame(Render *re,
}
/* keep after file save */
- BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_POST);
+ render_callback_exec_id(re, re->main, &scene->id, BKE_CB_EVT_RENDER_POST);
if (write_still) {
- BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_WRITE);
+ render_callback_exec_id(re, re->main, &scene->id, BKE_CB_EVT_RENDER_WRITE);
}
}
- BKE_callback_exec(
- re->main, (ID *)scene, G.is_break ? BKE_CB_EVT_RENDER_CANCEL : BKE_CB_EVT_RENDER_COMPLETE);
+ render_callback_exec_id(re,
+ re->main,
+ &scene->id,
+ G.is_break ? BKE_CB_EVT_RENDER_CANCEL : BKE_CB_EVT_RENDER_COMPLETE);
RE_CleanAfterRender(re);
@@ -2429,7 +2449,7 @@ static int do_write_image_or_movie(Render *re,
/* NOTE: using G_MAIN seems valid here???
* Not sure it's actually even used anyway, we could as well pass NULL? */
- BKE_callback_exec(G_MAIN, NULL, BKE_CB_EVT_RENDER_STATS);
+ render_callback_exec_null(re, G_MAIN, BKE_CB_EVT_RENDER_STATS);
BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime - render_time);
printf(" (Saving: %s)\n", name);
@@ -2495,7 +2515,7 @@ void RE_RenderAnim(Render *re,
const bool is_multiview_name = ((rd.scemode & R_MULTIVIEW) != 0 &&
(rd.im_format.views_format == R_IMF_VIEWS_INDIVIDUAL));
- BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_INIT);
+ render_callback_exec_id(re, re->main, &scene->id, BKE_CB_EVT_RENDER_INIT);
/* do not fully call for each frame, it initializes & pops output window */
if (!render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1)) {
@@ -2660,8 +2680,8 @@ void RE_RenderAnim(Render *re,
re->r.cfra = scene->r.cfra; /* weak.... */
- /* run callbacs before rendering, before the scene is updated */
- BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_PRE);
+ /* run callbacks before rendering, before the scene is updated */
+ render_callback_exec_id(re, re->main, &scene->id, BKE_CB_EVT_RENDER_PRE);
do_render_all_options(re);
totrendered++;
@@ -2712,8 +2732,8 @@ void RE_RenderAnim(Render *re,
if (G.is_break == false) {
/* keep after file save */
- BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_POST);
- BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_WRITE);
+ render_callback_exec_id(re, re->main, &scene->id, BKE_CB_EVT_RENDER_POST);
+ render_callback_exec_id(re, re->main, &scene->id, BKE_CB_EVT_RENDER_WRITE);
}
}
}
@@ -2731,8 +2751,10 @@ void RE_RenderAnim(Render *re,
re->flag &= ~R_ANIMATION;
- BKE_callback_exec(
- re->main, (ID *)scene, G.is_break ? BKE_CB_EVT_RENDER_CANCEL : BKE_CB_EVT_RENDER_COMPLETE);
+ render_callback_exec_id(re,
+ re->main,
+ &scene->id,
+ G.is_break ? BKE_CB_EVT_RENDER_CANCEL : BKE_CB_EVT_RENDER_COMPLETE);
BKE_sound_reset_scene_specs(re->pipeline_scene_eval);
RE_CleanAfterRender(re);
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 0266a30dea6..f0254f937ac 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -831,11 +831,11 @@ static void wm_draw_window(bContext *C, wmWindow *win)
/****************** main update call **********************/
/* quick test to prevent changing window drawable */
-static bool wm_draw_update_test_window(wmWindow *win)
+static bool wm_draw_update_test_window(Main *bmain, wmWindow *win)
{
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
bScreen *screen = WM_window_get_active_screen(win);
ARegion *ar;
bool do_draw = false;
@@ -936,7 +936,7 @@ void wm_draw_update(bContext *C)
}
#endif
- if (wm_draw_update_test_window(win)) {
+ if (wm_draw_update_test_window(bmain, win)) {
bScreen *screen = WM_window_get_active_screen(win);
CTX_wm_window_set(C, win);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 21c6c2ae60b..27b3eb71330 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -360,7 +360,7 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file)
* 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);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
if (is_after_open_file) {
DEG_graph_relations_update(depsgraph, bmain, scene, view_layer);
DEG_graph_on_visible_update(bmain, depsgraph, true);
@@ -3260,9 +3260,10 @@ void wm_event_do_handlers(bContext *C)
wm_event_free_all(win);
}
else {
+ Main *bmain = CTX_data_main(C);
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
Scene *scene_eval = (depsgraph != NULL) ? DEG_get_evaluated_scene(depsgraph) : NULL;
if (scene_eval != NULL) {
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index ae5235c7f58..6a5166d3dec 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -537,16 +537,16 @@ static void wm_file_read_post(bContext *C,
if (use_userdef) {
if (is_factory_startup) {
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_FACTORY_USERDEF_POST);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_FACTORY_USERDEF_POST);
}
}
if (use_data) {
/* important to do before NULL'ing the context */
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_VERSION_UPDATE);
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_POST);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_VERSION_UPDATE);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_POST);
if (is_factory_startup) {
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST);
}
}
@@ -609,7 +609,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
WM_cursor_wait(1);
- BKE_callback_exec(CTX_data_main(C), NULL, BKE_CB_EVT_LOAD_PRE);
+ BKE_callback_exec_null(CTX_data_main(C), BKE_CB_EVT_LOAD_PRE);
BLI_timer_on_file_load();
UI_view2d_zoom_cache_reset();
@@ -807,7 +807,7 @@ void wm_homefile_read(bContext *C,
}
if (use_data) {
- BKE_callback_exec(CTX_data_main(C), NULL, BKE_CB_EVT_LOAD_PRE);
+ BKE_callback_exec_null(CTX_data_main(C), BKE_CB_EVT_LOAD_PRE);
BLI_timer_on_file_load();
G.relbase_valid = 0;
@@ -1368,7 +1368,7 @@ static bool wm_file_write(bContext *C, const char *filepath, int fileflags, Repo
/* Call pre-save callbacks before writing preview,
* that way you can generate custom file thumbnail. */
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_PRE);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_PRE);
/* Enforce full override check/generation on file save. */
BKE_main_override_library_operations_create(bmain, true);
@@ -1421,7 +1421,7 @@ static bool wm_file_write(bContext *C, const char *filepath, int fileflags, Repo
wm_history_file_update();
}
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_POST);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_POST);
/* run this function after because the file cant be written before the blend is */
if (ibuf_thumb) {
@@ -1646,7 +1646,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_PRE);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_PRE);
/* check current window and close it if temp */
if (win && WM_window_is_temp_screen(win)) {
@@ -1674,7 +1674,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
G.save_over = 0;
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_POST);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_POST);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 736a3315efa..12f07b8d10e 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -215,7 +215,7 @@ static void sound_jack_sync_callback(Main *bmain, int mode, float time)
continue;
}
ViewLayer *view_layer = WM_window_get_active_view_layer(window);
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
if (depsgraph == NULL) {
continue;
}
@@ -378,10 +378,10 @@ void WM_init(bContext *C, int argc, const char **argv)
* note that recovering the last session does its own callbacks. */
CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_VERSION_UPDATE);
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_POST);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_VERSION_UPDATE);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_POST);
if (is_factory_startup) {
- BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST);
+ BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST);
}
wm_file_read_report(C, bmain);
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index e175dbfbb96..f0b2ea45888 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -1109,14 +1109,14 @@ static int arg_handle_factory_startup_set(int UNUSED(argc),
return 0;
}
-static const char arg_handle_enable_override_library_doc[] =
+static const char arg_handle_disable_override_library_doc[] =
"\n\t"
"Enable Library Override features in the UI.";
-static int arg_handle_enable_override_library(int UNUSED(argc),
- const char **UNUSED(argv),
- void *UNUSED(data))
+static int arg_handle_disable_override_library(int UNUSED(argc),
+ const char **UNUSED(argv),
+ void *UNUSED(data))
{
- BKE_override_library_enable(true);
+ BKE_override_library_enable(false);
return 0;
}
@@ -2174,7 +2174,7 @@ void main_args_setup(bContext *C, bArgs *ba)
BLI_argsAdd(ba, 1, NULL, "--app-template", CB(arg_handle_app_template), NULL);
BLI_argsAdd(ba, 1, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL);
BLI_argsAdd(
- ba, 1, NULL, "--enable-library-override", CB(arg_handle_enable_override_library), NULL);
+ ba, 1, NULL, "--disable-library-override", CB(arg_handle_disable_override_library), NULL);
BLI_argsAdd(ba, 1, NULL, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), NULL);
/* TODO, add user env vars? */
diff --git a/tests/gtests/alembic/abc_export_test.cc b/tests/gtests/alembic/abc_export_test.cc
index f8010b02c96..3bddd2df6ba 100644
--- a/tests/gtests/alembic/abc_export_test.cc
+++ b/tests/gtests/alembic/abc_export_test.cc
@@ -54,7 +54,7 @@ class AlembicExportTest : public testing::Test {
/* TODO(sergey): Pass scene layer somehow? */
ViewLayer *view_layer = (ViewLayer *)scene.view_layers.first;
- settings.depsgraph = depsgraph = DEG_graph_new(&scene, view_layer, DAG_EVAL_VIEWPORT);
+ settings.depsgraph = depsgraph = DEG_graph_new(bmain, &scene, view_layer, DAG_EVAL_VIEWPORT);
settings.scene = &scene;
settings.view_layer = view_layer;