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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intern/clog/CLG_log.h2
-rw-r--r--intern/clog/clog.c14
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py12
-rw-r--r--release/scripts/startup/bl_ui/space_time.py5
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py9
-rw-r--r--source/blender/blenkernel/BKE_armature.h1
-rw-r--r--source/blender/blenkernel/BKE_bvhutils.h9
-rw-r--r--source/blender/blenkernel/BKE_idprop.h7
-rw-r--r--source/blender/blenkernel/BKE_library.h6
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c5
-rw-r--r--source/blender/blenkernel/intern/armature.c9
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c27
-rw-r--r--source/blender/blenkernel/intern/constraint.c14
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c2
-rw-r--r--source/blender/blenkernel/intern/font.c4
-rw-r--r--source/blender/blenkernel/intern/idprop.c19
-rw-r--r--source/blender/blenkernel/intern/library.c37
-rw-r--r--source/blender/blenkernel/intern/mesh.c22
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c4
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c58
-rw-r--r--source/blender/blenkernel/intern/modifier.c43
-rw-r--r--source/blender/blenkernel/intern/paint.c3
-rw-r--r--source/blender/blenkernel/intern/scene.c1
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c26
-rw-r--r--source/blender/blenkernel/intern/smoke.c4
-rw-r--r--source/blender/blenlib/BLI_kdopbvh.h2
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c8
-rw-r--r--source/blender/blenloader/intern/versioning_280.c3
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c5
-rw-r--r--source/blender/bmesh/tools/bmesh_wireframe.c1
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp5
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_map.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc41
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h1
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc12
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc19
-rw-r--r--source/blender/draw/CMakeLists.txt2
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c34
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl6
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl51
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl23
-rw-r--r--source/blender/draw/engines/workbench/solid_mode.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c149
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h7
-rw-r--r--source/blender/draw/intern/DRW_render.h8
-rw-r--r--source/blender/draw/intern/draw_common.c2
-rw-r--r--source/blender/draw/intern/draw_manager.h3
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c38
-rw-r--r--source/blender/draw/intern/draw_manager_texture.c2
-rw-r--r--source/blender/draw/intern/draw_view.c2
-rw-r--r--source/blender/editors/armature/armature_add.c2
-rw-r--r--source/blender/editors/armature/meshlaplacian.c83
-rw-r--r--source/blender/editors/armature/pose_edit.c43
-rw-r--r--source/blender/editors/curve/editcurve_paint.c2
-rw-r--r--source/blender/editors/curve/editcurve_select.c1
-rw-r--r--source/blender/editors/interface/interface_utils.c1
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c239
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c8
-rw-r--r--source/blender/editors/physics/particle_edit.c2
-rw-r--r--source/blender/editors/physics/particle_object.c4
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c2
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/transform/transform.c4
-rw-r--r--source/blender/editors/transform/transform_snap_object.c6
-rw-r--r--source/blender/makesdna/DNA_group_types.h3
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_layer.c57
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_scene.c5
-rw-r--r--source/blender/makesrna/intern/rna_space.c19
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c12
-rw-r--r--source/blender/modifiers/intern/MOD_array.c7
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c22
-rw-r--r--source/blender/modifiers/intern/MOD_build.c4
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c7
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c11
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c24
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c8
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c13
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c4
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c6
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c32
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_select.c5
-rw-r--r--source/blender/python/generic/idprop_py_api.c58
-rw-r--r--source/blender/render/intern/source/bake_api.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c164
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c12
-rw-r--r--source/creator/creator_args.c7
93 files changed, 1029 insertions, 646 deletions
diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h
index 8afa9edd75b..ff8f983b10c 100644
--- a/intern/clog/CLG_log.h
+++ b/intern/clog/CLG_log.h
@@ -150,6 +150,8 @@ void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle));
void CLG_type_filter_include(const char *type_filter, int type_filter_len);
void CLG_type_filter_exclude(const char *type_filter, int type_filter_len);
+void CLG_level_set(int level);
+
void CLG_logref_init(CLG_LogRef *clg_ref);
/** Declare outside function, declare as extern in header. */
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index dc0229e0748..e93ba9ec2b7 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -492,6 +492,14 @@ static void CLG_ctx_type_filter_include(CLogContext *ctx, const char *type_match
clg_ctx_type_filter_append(&ctx->filters[1], type_match, type_match_len);
}
+static void CLG_ctx_level_set(CLogContext *ctx, int level)
+{
+ ctx->default_type.level = level;
+ for (CLG_LogType *ty = ctx->types; ty; ty = ty->next) {
+ ty->level = level;
+ }
+}
+
static CLogContext *CLG_ctx_init(void)
{
CLogContext *ctx = MEM_callocN(sizeof(*ctx), __func__);
@@ -569,6 +577,12 @@ void CLG_type_filter_include(const char *type_match, int type_match_len)
CLG_ctx_type_filter_include(g_ctx, type_match, type_match_len);
}
+void CLG_level_set(int level)
+{
+ CLG_ctx_level_set(g_ctx, level);
+}
+
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 9a9b973650c..08f19a02ecc 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -755,17 +755,7 @@ class RENDER_PT_workbench_environment_light(RenderButtonsPanel, Panel):
layout = self.layout
scene = context.scene
props = scene.layer_properties['BLENDER_WORKBENCH']
-
- row = layout.row(align=True)
- col = row.column(align=True)
- col.prop(props, "diffuse_light_x_neg", text="Left/Right")
- col.prop(props, "diffuse_light_x_pos", text="")
- col = row.column(align=True)
- col.prop(props, "diffuse_light_y_pos", text="Up/Down")
- col.prop(props, "diffuse_light_y_neg", text="")
- col = row.column(align=True)
- col.prop(props, "diffuse_light_z_pos", text="Front/Back")
- col.prop(props, "diffuse_light_z_neg", text="")
+ layout.prop(props, "light_direction", text="")
classes = (
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index a1f0f5a7cc8..6710ed634b9 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -77,8 +77,6 @@ class TIME_HT_editor_buttons(Header):
row.operator("screen.keyframe_jump", text="", icon='NEXT_KEYFRAME').next = True
row.operator("screen.frame_jump", text="", icon='FF').end = True
- layout.prop(scene, "sync_mode", text="")
-
layout.separator()
row = layout.row(align=True)
@@ -218,10 +216,9 @@ class TIME_MT_playback(Menu):
layout.prop(screen, "use_follow")
layout.separator()
- layout.prop(scene, "use_frame_drop", text="Frame Dropping")
- layout.prop(scene, "use_audio_sync", text="AV-sync", icon='SPEAKER')
layout.prop(scene, "use_audio")
layout.prop(scene, "use_audio_scrub")
+ layout.prop_menu_enum(scene, "sync_mode")
class TIME_MT_autokey(Menu):
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 5b06f512abe..bba39867079 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3552,8 +3552,13 @@ class VIEW3D_PT_shading(Panel):
col.row().prop(shading, "light", expand=True)
if shading.light == 'STUDIO':
col.row().template_icon_view(shading, "studiolight")
+ col.separator()
+
+ col.prop(shading, "show_shadows")
+ if shading.show_shadows:
+ col.prop(shading, "ambient_light_intensity")
+ col.separator()
- col.separator()
col.prop(shading, "show_object_overlap")
@@ -3582,7 +3587,7 @@ class VIEW3D_PT_overlay(Panel):
col = layout.column()
col.active = display_all
- col.prop(overlay, "show_3dcursor")
+ col.prop(overlay, "show_cursor")
if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
engine_type = {
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 2ecab73ac79..b8d9e5a9af9 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -99,6 +99,7 @@ float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3
void BKE_armature_where_is(struct bArmature *arm);
void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion);
void BKE_pose_clear_pointers(struct bPose *pose);
+void BKE_pose_remap_bone_pointers(struct bArmature *armature, struct bPose *pose);
void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm);
void BKE_pose_where_is(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_pose_where_is_bone(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index 33e88a6b8f8..57a6c413ce0 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -126,9 +126,6 @@ BVHTree *bvhtree_from_editmesh_edges_ex(
const BLI_bitmap *edges_mask, int edges_num_active,
float epsilon, int tree_type, int axis);
-BVHTree *bvhtree_from_mesh_edges(
- struct BVHTreeFromMesh *data, struct DerivedMesh *mesh,
- float epsilon, int tree_type, int axis);
BVHTree *bvhtree_from_mesh_edges_ex(
struct BVHTreeFromMesh *data,
const struct MVert *vert, const bool vert_allocated,
@@ -151,8 +148,6 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(
const BLI_bitmap *mask, int looptri_num_active,
float epsilon, int tree_type, int axis, BVHCache **bvhCache);
-BVHTree *bvhtree_from_mesh_looptri(
- struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis);
BVHTree *bvhtree_from_mesh_looptri_ex(
struct BVHTreeFromMesh *data,
const struct MVert *vert, const bool vert_allocated,
@@ -161,7 +156,9 @@ BVHTree *bvhtree_from_mesh_looptri_ex(
const BLI_bitmap *mask, int looptri_num_active,
float epsilon, int tree_type, int axis);
-BVHTree *bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, int type);
+BVHTree *bvhtree_from_mesh_get(
+ struct BVHTreeFromMesh *data, struct DerivedMesh *mesh,
+ const int type, const int tree_type);
/**
* Frees data allocated by a call to bvhtree_from_mesh_*.
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 02912739e86..c686fa41e7e 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -152,10 +152,9 @@ void IDP_Reset(IDProperty *prop, const IDProperty *reference);
# define IDP_Id(prop) ((ID *) (prop)->data.pointer)
#endif
-#ifndef NDEBUG
-/* for printout only */
-void IDP_spit(IDProperty *prop);
-#endif
+/* for printout/logging only */
+char *IDP_reprN(const struct IDProperty *prop);
+void IDP_print(const struct IDProperty *prop);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index c34571fdd7a..0cd5e032f68 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -52,9 +52,13 @@ struct PropertyRNA;
size_t BKE_libblock_get_alloc_info(short type, const char **name);
void *BKE_libblock_alloc_notest(short type) ATTR_WARN_UNUSED_RESULT;
-void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name, const int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name, const int flag) ATTR_WARN_UNUSED_RESULT;
void BKE_libblock_init_empty(struct ID *id) ATTR_NONNULL(1);
+void *BKE_id_new(struct Main *bmain, const short type, const char *name);
+void *BKE_id_new_nomain(const short type, const char *name);
+
+
/**
* New ID creation/copying options.
*/
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index d2ab4f3164c..31b4b5cecc5 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -90,7 +90,7 @@ void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Object
* (where each tree was built on its own coords space)
*/
bool BKE_shrinkwrap_project_normal(
- char options, const float vert[3], const float dir[3],
+ char options, const float vert[3], const float dir[3], const float ray_radius,
const struct SpaceTransform *transf, BVHTree *tree, BVHTreeRayHit *hit,
BVHTree_RayCastCallback callback, void *userdata);
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
index c26112d3724..c1a4f8dba53 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
@@ -232,6 +232,9 @@ bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss,
CHECK_COMPUTE_TYPE(CUDA)
CHECK_COMPUTE_TYPE(GLSL_TRANSFORM_FEEDBACK)
CHECK_COMPUTE_TYPE(GLSL_COMPUTE)
+ default:
+ compute_type = OPENSUBDIV_EVALUATOR_CPU;
+ break;
#undef CHECK_COMPUTE_TYPE
}
@@ -739,7 +742,7 @@ static void opensubdiv_evaluateNGonFaceGrids(CCGSubSurf *ss,
/* Evaluate edges. */
for (S = 0; S < face->numVerts; S++) {
CCGEdge *edge = FACE_getEdges(face)[S];
- int x, S0, S1;
+ int x, S0 = 0, S1 = 0;
bool flip;
for (x = 0; x < face->numVerts; ++x) {
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 2ded32b3ec9..63846b31c33 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1943,6 +1943,15 @@ void BKE_pose_clear_pointers(bPose *pose)
}
}
+void BKE_pose_remap_bone_pointers(bArmature *armature, bPose *pose)
+{
+ GHash *bone_hash = BKE_armature_bone_from_name_map(armature);
+ for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ pchan->bone = BLI_ghash_lookup(bone_hash, pchan->name);
+ }
+ BLI_ghash_free(bone_hash, NULL, NULL);
+}
+
/* only after leave editmode, duplicating, validating older files, library syncing */
/* NOTE: pose->flag is set for it */
void BKE_pose_rebuild(Object *ob, bArmature *arm)
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 90a75b8d3cc..440db911298 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -709,7 +709,7 @@ BVHTree *bvhtree_from_editmesh_edges(
}
/* Builds a bvh tree where nodes are the edges of the given dm */
-BVHTree *bvhtree_from_mesh_edges(
+static BVHTree *bvhtree_from_mesh_edges(
BVHTreeFromMesh *data, DerivedMesh *dm,
float epsilon, int tree_type, int axis)
{
@@ -1127,7 +1127,7 @@ BVHTree *bvhtree_from_editmesh_looptri(
*
* \note for editmesh this is currently a duplicate of bvhtree_from_mesh_faces
*/
-BVHTree *bvhtree_from_mesh_looptri(
+static BVHTree *bvhtree_from_mesh_looptri(
BVHTreeFromMesh *data, DerivedMesh *dm,
float epsilon, int tree_type, int axis)
{
@@ -1229,19 +1229,30 @@ BVHTree *bvhtree_from_mesh_looptri_ex(
* Builds or queries a bvhcache for the cache bvhtree of the request type.
*/
BVHTree *bvhtree_from_mesh_get(
- struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, int type)
+ struct BVHTreeFromMesh *data, struct DerivedMesh *mesh,
+ const int type, const int tree_type)
{
+ BVHTree *tree = NULL;
switch (type) {
case BVHTREE_FROM_VERTS:
- return bvhtree_from_mesh_verts(data, mesh, 0.0f, 2, 6);
+ tree = bvhtree_from_mesh_verts(data, mesh, 0.0f, tree_type, 6);
+ break;
case BVHTREE_FROM_EDGES:
- return bvhtree_from_mesh_edges(data, mesh, 0.0f, 2, 6);
+ tree = bvhtree_from_mesh_edges(data, mesh, 0.0f, tree_type, 6);
+ break;
case BVHTREE_FROM_FACES:
- return bvhtree_from_mesh_faces(data, mesh, 0.0f, 2, 6);
+ tree = bvhtree_from_mesh_faces(data, mesh, 0.0f, tree_type, 6);
+ break;
case BVHTREE_FROM_LOOPTRI:
- return bvhtree_from_mesh_looptri(data, mesh, 0.0f, 2, 6);
+ tree = bvhtree_from_mesh_looptri(data, mesh, 0.0f, tree_type, 6);
+ break;
}
- return NULL;
+#ifdef DEBUG
+ if (BLI_bvhtree_get_tree_type(tree) != tree_type) {
+ printf("tree_type %d obtained instead of %d\n", BLI_bvhtree_get_tree_type(tree), tree_type);
+ }
+#endif
+ return tree;
}
/** \} */
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 3ad385bb609..cd8226b57ad 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -3431,9 +3431,9 @@ static void shrinkwrap_get_tarmat(struct Depsgraph *UNUSED(depsgraph), bConstrai
nearest.dist_sq = FLT_MAX;
if (scon->shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX)
- bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_VERTS, 2);
else
- bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 2);
if (treeData.tree == NULL) {
fail = true;
@@ -3485,15 +3485,15 @@ static void shrinkwrap_get_tarmat(struct Depsgraph *UNUSED(depsgraph), bConstrai
break;
}
- bvhtree_from_mesh_looptri(&treeData, target, scon->dist, 4, 6);
+ bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 4);
if (treeData.tree == NULL) {
fail = true;
break;
}
-
- if (BKE_shrinkwrap_project_normal(0, co, no, &transform, treeData.tree, &hit,
- treeData.raycast_callback, &treeData) == false)
+ treeData.sphere_radius = scon->dist;
+ if (BKE_shrinkwrap_project_normal(0, co, no, treeData.sphere_radius, &transform, treeData.tree,
+ &hit, treeData.raycast_callback, &treeData) == false)
{
fail = true;
break;
@@ -4095,7 +4095,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
sub_v3_v3v3(ray_nor, ray_end, ray_start);
normalize_v3(ray_nor);
- bvhtree_from_mesh_looptri(&treeData, target, 0.0f, 4, 6);
+ bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 4);
hit.dist = BVH_RAYCAST_DIST_MAX;
hit.index = -1;
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 187edd5b4a5..c91d3b32e75 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -4164,7 +4164,7 @@ static int dynamicPaint_paintMesh(struct Depsgraph *depsgraph, DynamicPaintSurfa
/* check bounding box collision */
if (grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius)) {
/* Build a bvh tree from transformed vertices */
- if (bvhtree_from_mesh_looptri(&treeData, dm, 0.0f, 4, 8)) {
+ if (bvhtree_from_mesh_get(&treeData, dm, BVHTREE_FROM_LOOPTRI, 4)) {
int c_index;
int total_cells = grid->dim[0] * grid->dim[1] * grid->dim[2];
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 5545eba8764..34b185417e3 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -1022,7 +1022,7 @@ makebreak:
/* top and top-baseline are the same when text-boxes are used */
if (cu->align_y != CU_ALIGN_Y_TOP && i_textbox < slen) {
/* all previous textboxes are 'full', only align the last used text-box */
- float yoff;
+ float yoff = 0.0f;
int lines;
struct CharTrans *ct_last, *ct_textbox;
@@ -1051,7 +1051,7 @@ makebreak:
else {
/* non text-box case handled separately */
ct = chartransdata;
- float yoff;
+ float yoff = 0.0f;
if (cu->align_y == CU_ALIGN_Y_TOP) {
yoff = -linedist;
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 87e5ed8cc1e..b3b5afa88a9 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -859,9 +859,9 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is
if ((p1 != p2) && ((fabsf(p1 - p2) / max_ff(p1, p2)) < 0.001f)) {
printf("WARNING: Comparing two float properties that have nearly the same value (%f vs. %f)\n", p1, p2);
printf(" p1: ");
- IDP_spit(prop1);
+ IDP_print(prop1);
printf(" p2: ");
- IDP_spit(prop2);
+ IDP_print(prop2);
}
}
#endif
@@ -1107,3 +1107,18 @@ void IDP_Reset(IDProperty *prop, const IDProperty *reference)
}
/** \} */
+
+/* We could write a C version, see: idprop_py_api.c */
+#ifndef WITH_PYTHON
+char *IDP_reprN(IDProperty *UNUSED(prop))
+{
+ return BLI_strdup("<unsupported>");
+}
+
+void IDP_print(IDProperty *prop)
+{
+ char *repr = IDP_reprN(prop);
+ printf("IDProperty(%p): %s\n", prop, repr);
+ MEM_freeN(repr);
+}
+#endif /* WITH_PYTHON */
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index d23d48752b6..2e56ed9d247 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -80,8 +80,8 @@
#include "BLI_memarena.h"
#include "BLI_mempool.h"
#include "BLI_string_utils.h"
-
#include "BLI_threads.h"
+
#include "BLT_translation.h"
#include "BKE_action.h"
@@ -1368,6 +1368,41 @@ void BKE_libblock_init_empty(ID *id)
}
}
+/** Generic helper to create a new empty datablock of given type in given \a bmain database.
+ *
+ * \param name can be NULL, in which case we get default name for this ID type. */
+void *BKE_id_new(Main *bmain, const short type, const char *name)
+{
+ BLI_assert(bmain != NULL);
+
+ if (name == NULL) {
+ name = DATA_(BKE_idcode_to_name(type));
+ }
+
+ ID *id = BKE_libblock_alloc(bmain, type, name, 0);
+ BKE_libblock_init_empty(id);
+
+ return id;
+}
+
+/** Generic helper to create a new temporary empty datablock of given type, *outside* of any Main database.
+ *
+ * \param name can be NULL, in which case we get default name for this ID type. */
+void *BKE_id_new_nomain(const short type, const char *name)
+{
+ if (name == NULL) {
+ name = DATA_(BKE_idcode_to_name(type));
+ }
+
+ ID *id = BKE_libblock_alloc(NULL, type, name,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG);
+ BKE_libblock_init_empty(id);
+
+ return id;
+}
+
/* by spec, animdata is first item after ID */
/* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */
static void id_copy_animdata(Main *bmain, ID *id, const bool do_action)
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 9bd1b587abd..3163ea6551e 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -47,6 +47,7 @@
#include "BLI_utildefines_stack.h"
#include "BKE_animsys.h"
+#include "BKE_idcode.h"
#include "BKE_main.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
@@ -621,8 +622,7 @@ static Mesh *mesh_from_template_ex(
{
const bool do_tessface = ((me_src->totface != 0) && (me_src->totpoly == 0)); /* only do tessface if we have no polys */
- Mesh *me_dst = MEM_callocN(sizeof(struct Mesh), "Mesh");
- BKE_mesh_init(me_dst);
+ Mesh *me_dst = BKE_id_new_nomain(ID_ME, NULL);
me_dst->mat = MEM_dupallocN(me_src->mat);
me_dst->mselect = MEM_dupallocN(me_dst->mselect);
@@ -691,19 +691,19 @@ BMesh *BKE_mesh_to_bmesh(
Mesh *me, Object *ob,
const bool add_key_index, const struct BMeshCreateParams *params)
{
- struct BMeshFromMeshParams convert_params = {
- .calc_face_normal = false,
- .add_key_index = add_key_index,
- .use_shapekey = true,
- .active_shapekey = ob->shapenr,
- };
- return BKE_mesh_to_bmesh_ex(me, params, &convert_params);
+ return BKE_mesh_to_bmesh_ex(
+ me, params,
+ &(struct BMeshFromMeshParams){
+ .calc_face_normal = false,
+ .add_key_index = add_key_index,
+ .use_shapekey = true,
+ .active_shapekey = ob->shapenr,
+ });
}
Mesh *BKE_bmesh_to_mesh(BMesh *bm, const struct BMeshToMeshParams *params)
{
- Mesh *mesh = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh);
+ Mesh *mesh = BKE_id_new_nomain(ID_ME, NULL);
BM_mesh_bm_to_me(bm, mesh, params);
return mesh;
}
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index 78e470dda4e..899de970fdd 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -39,6 +39,7 @@
#include "BLI_ghash.h"
#include "BKE_customdata.h"
+#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
@@ -677,8 +678,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, const int *vtargetmap, const int tot_vtar
if (poly_map_mem != NULL)
MEM_freeN(poly_map_mem);
- BKE_mesh_free(mesh);
- MEM_freeN(mesh);
+ BKE_id_free(NULL, mesh);
return result;
}
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index f99dd5574b2..1b05745550d 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -131,7 +131,7 @@ float BKE_mesh_remap_calc_difference_from_dm(
float result = 0.0f;
int i;
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2);
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
@@ -422,9 +422,6 @@ typedef struct IslandResult {
#define MREMAP_RAYCAST_APPROXIMATE_NR 3
/* Each approximated raycasts will have n times bigger radius than previous one. */
#define MREMAP_RAYCAST_APPROXIMATE_FAC 5.0f
-/* BVH epsilon value we have to give to bvh 'constructor' when doing approximated raycasting. */
-#define MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON(_ray_radius) \
- ((float)MREMAP_RAYCAST_APPROXIMATE_NR * MREMAP_RAYCAST_APPROXIMATE_FAC * (_ray_radius))
/* min 16 rays/face, max 400. */
#define MREMAP_RAYCAST_TRI_SAMPLES_MIN 4
@@ -460,7 +457,7 @@ void BKE_mesh_remap_calc_verts_from_dm(
float tmp_co[3], tmp_no[3];
if (mode == MREMAP_MODE_VERT_NEAREST) {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2);
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
@@ -485,7 +482,7 @@ void BKE_mesh_remap_calc_verts_from_dm(
float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)dm_src->getNumVerts(dm_src), __func__);
dm_src->getVertCos(dm_src, vcos_src);
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES, 2);
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
@@ -543,15 +540,11 @@ void BKE_mesh_remap_calc_verts_from_dm(
float *weights = MEM_mallocN(sizeof(*weights) * tmp_buff_size, __func__);
dm_src->getVertCos(dm_src, vcos_src);
- if (mode & MREMAP_USE_NORPROJ) {
- bvhtree_from_mesh_looptri(
- &treedata, dm_src, ray_radius, 2, 6);
- }
- else {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI);
- }
+
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2);
if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) {
+ treedata.sphere_radius = ray_radius;
for (i = 0; i < numverts_dst; i++) {
copy_v3_v3(tmp_co, verts_dst[i].co);
normal_short_to_float_v3(tmp_no, verts_dst[i].no);
@@ -682,7 +675,7 @@ void BKE_mesh_remap_calc_edges_from_dm(
dm_src->getVertCos(dm_src, vcos_src);
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2);
nearest.index = -1;
for (i = 0; i < numedges_dst; i++) {
@@ -782,7 +775,7 @@ void BKE_mesh_remap_calc_edges_from_dm(
MEM_freeN(vert_to_edge_src_map_mem);
}
else if (mode == MREMAP_MODE_EDGE_NEAREST) {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES, 2);
nearest.index = -1;
for (i = 0; i < numedges_dst; i++) {
@@ -809,7 +802,7 @@ void BKE_mesh_remap_calc_edges_from_dm(
float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)dm_src->getNumVerts(dm_src), __func__);
dm_src->getVertCos(dm_src, vcos_src);
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2);
for (i = 0; i < numedges_dst; i++) {
interp_v3_v3v3(tmp_co, verts_dst[edges_dst[i].v1].co, verts_dst[edges_dst[i].v2].co, 0.5f);
@@ -862,7 +855,7 @@ void BKE_mesh_remap_calc_edges_from_dm(
/* Here it's simpler to just allocate for all edges :/ */
float *weights = MEM_mallocN(sizeof(*weights) * (size_t)numedges_src, __func__);
- bvhtree_from_mesh_edges(&treedata, dm_src, MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON(ray_radius), 2, 6);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES, 2);
for (i = 0; i < numedges_dst; i++) {
/* For each dst edge, we sample some rays from it (interpolated from its vertices)
@@ -916,8 +909,10 @@ void BKE_mesh_remap_calc_edges_from_dm(
interp_v3_v3v3_slerp_safe(tmp_no, v1_no, v2_no, fac);
while (n--) {
+ float radius = (ray_radius / w);
+ treedata.sphere_radius = radius;
if (mesh_remap_bvhtree_query_raycast(
- &treedata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist))
+ &treedata, &rayhit, tmp_co, tmp_no, radius, max_dist, &hit_dist))
{
weights[rayhit.index] += w;
totweights += w;
@@ -1205,8 +1200,6 @@ void BKE_mesh_remap_calc_loops_from_dm(
IslandResult **islands_res;
size_t islands_res_buff_size = MREMAP_DEFAULT_BUFSIZE;
- const float bvh_epsilon = (mode & MREMAP_USE_NORPROJ) ? MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON(ray_radius) : 0.0f;
-
if (!use_from_vert) {
vcos_src = MEM_mallocN(sizeof(*vcos_src) * (size_t)num_verts_src, __func__);
dm_src->getVertCos(dm_src, vcos_src);
@@ -1356,7 +1349,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
}
/* verts 'ownership' is transfered to treedata here, which will handle its freeing. */
bvhtree_from_mesh_verts_ex(&treedata[tindex], verts_src, num_verts_src, verts_allocated_src,
- verts_active, num_verts_active, bvh_epsilon, 2, 6);
+ verts_active, num_verts_active, 0.0, 2, 6);
if (verts_allocated_src) {
verts_allocated_src = false; /* Only 'give' our verts once, to first tree! */
}
@@ -1366,7 +1359,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
}
else {
BLI_assert(num_trees == 1);
- bvhtree_from_mesh_get(&treedata[0], dm_src, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treedata[0], dm_src, BVHTREE_FROM_VERTS, 2);
}
}
else { /* We use polygons. */
@@ -1403,7 +1396,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
verts_src, verts_allocated_src,
loops_src, loops_allocated_src,
looptri_src, num_looptri_src, false,
- looptri_active, num_looptri_active, bvh_epsilon, 2, 6);
+ looptri_active, num_looptri_active, 0.0, 2, 6);
if (verts_allocated_src) {
verts_allocated_src = false; /* Only 'give' our verts once, to first tree! */
}
@@ -1416,7 +1409,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
}
else {
BLI_assert(num_trees == 1);
- bvhtree_from_mesh_looptri(&treedata[0], dm_src, bvh_epsilon, 2, 6);
+ bvhtree_from_mesh_get(&treedata[0], dm_src, BVHTREE_FROM_LOOPTRI, 2);
}
}
@@ -1572,8 +1565,10 @@ void BKE_mesh_remap_calc_loops_from_dm(
}
while (n--) {
+ float radius = ray_radius / w;
+ tdata->sphere_radius = radius;
if (mesh_remap_bvhtree_query_raycast(
- tdata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist))
+ tdata, &rayhit, tmp_co, tmp_no, radius, max_dist, &hit_dist))
{
islands_res[tindex][plidx_dst].factor = (hit_dist ? (1.0f / hit_dist) : 1e18f) * w;
islands_res[tindex][plidx_dst].hit_dist = hit_dist;
@@ -2013,13 +2008,7 @@ void BKE_mesh_remap_calc_polys_from_dm(
BVHTreeRayHit rayhit = {0};
float hit_dist;
- if (mode & MREMAP_USE_NORPROJ) {
- bvhtree_from_mesh_looptri(
- &treedata, dm_src, MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON(ray_radius), 2, 6);
- }
- else {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI);
- }
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2);
if (mode == MREMAP_MODE_POLY_NEAREST) {
nearest.index = -1;
@@ -2062,6 +2051,7 @@ void BKE_mesh_remap_calc_polys_from_dm(
BLI_space_transform_apply_normal(space_transform, tmp_no);
}
+ treedata.sphere_radius = ray_radius;
if (mesh_remap_bvhtree_query_raycast(
&treedata, &rayhit, tmp_co, tmp_no, ray_radius, max_dist, &hit_dist))
{
@@ -2211,8 +2201,9 @@ void BKE_mesh_remap_calc_polys_from_dm(
/* At this point, tmp_co is a point on our poly surface, in mesh_src space! */
while (n--) {
+ treedata.sphere_radius = ray_radius / w;
if (mesh_remap_bvhtree_query_raycast(
- &treedata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist))
+ &treedata, &rayhit, tmp_co, tmp_no, treedata.sphere_radius, max_dist, &hit_dist))
{
const MLoopTri *lt = &treedata.looptri[rayhit.index];
@@ -2262,7 +2253,6 @@ void BKE_mesh_remap_calc_polys_from_dm(
#undef MREMAP_RAYCAST_APPROXIMATE_NR
#undef MREMAP_RAYCAST_APPROXIMATE_FAC
-#undef MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON
#undef MREMAP_RAYCAST_TRI_SAMPLES_MIN
#undef MREMAP_RAYCAST_TRI_SAMPLES_MAX
#undef MREMAP_DEFAULT_BUFSIZE
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 5153951d2a2..29a4fcbb9c7 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -60,6 +60,7 @@
#include "BKE_appdir.h"
#include "BKE_cdderivedmesh.h"
+#include "BKE_idcode.h"
#include "BKE_key.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
@@ -1003,16 +1004,14 @@ void modifier_deformVerts_DM_deprecated(struct ModifierData *md, const ModifierE
/* TODO(sybren): deduplicate all the copies of this code in this file. */
Mesh *mesh = NULL;
if (dm != NULL) {
- mesh = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh);
+ mesh = BKE_id_new_nomain(ID_ME, NULL);
DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
mti->deformVerts(md, ctx, mesh, vertexCos, numVerts);
if (mesh != NULL) {
- BKE_mesh_free(mesh);
- MEM_freeN(mesh);
+ BKE_id_free(NULL, mesh);
}
}
}
@@ -1031,16 +1030,14 @@ void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, const Modifi
/* TODO(sybren): deduplicate all the copies of this code in this file. */
Mesh *mesh = NULL;
if (dm != NULL) {
- mesh = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh);
+ mesh = BKE_id_new_nomain(ID_ME, NULL);
DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
mti->deformMatrices(md, ctx, mesh, vertexCos, defMats, numVerts);
if (mesh != NULL) {
- BKE_mesh_free(mesh);
- MEM_freeN(mesh);
+ BKE_id_free(NULL, mesh);
}
}
}
@@ -1058,16 +1055,14 @@ void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, const Modifie
/* TODO(sybren): deduplicate all the copies of this code in this file. */
Mesh *mesh = NULL;
if (dm != NULL) {
- mesh = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh);
+ mesh = BKE_id_new_nomain(ID_ME, NULL);
DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
mti->deformVertsEM(md, ctx, editData, mesh, vertexCos, numVerts);
if (mesh != NULL) {
- BKE_mesh_free(mesh);
- MEM_freeN(mesh);
+ BKE_id_free(NULL, mesh);
}
}
}
@@ -1085,16 +1080,14 @@ void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, const Modi
/* TODO(sybren): deduplicate all the copies of this code in this file. */
Mesh *mesh = NULL;
if (dm != NULL) {
- mesh = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh);
+ mesh = BKE_id_new_nomain(ID_ME, NULL);
DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
mti->deformMatricesEM(md, ctx, editData, mesh, vertexCos, defMats, numVerts);
if (mesh != NULL) {
- BKE_mesh_free(mesh);
- MEM_freeN(mesh);
+ BKE_id_free(NULL, mesh);
}
}
}
@@ -1111,8 +1104,7 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md
/* TODO(sybren): deduplicate all the copies of this code in this file. */
Mesh *mesh = NULL;
if (dm != NULL) {
- mesh = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh);
+ mesh = BKE_id_new_nomain(ID_ME, NULL);
DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
@@ -1122,12 +1114,10 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE);
if(new_mesh != mesh) {
- BKE_mesh_free(new_mesh);
- MEM_freeN(new_mesh);
+ BKE_id_free(NULL, new_mesh);
}
if (mesh != NULL) {
- BKE_mesh_free(mesh);
- MEM_freeN(mesh);
+ BKE_id_free(NULL, mesh);
}
return ndm;
@@ -1147,8 +1137,7 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *
/* TODO(sybren): deduplicate all the copies of this code in this file. */
Mesh *mesh = NULL;
if (dm != NULL) {
- mesh = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh);
+ mesh = BKE_id_new_nomain(ID_ME, NULL);
DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
@@ -1158,12 +1147,10 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE);
if(new_mesh != mesh) {
- BKE_mesh_free(new_mesh);
- MEM_freeN(new_mesh);
+ BKE_id_free(NULL, new_mesh);
}
if (mesh != NULL) {
- BKE_mesh_free(mesh);
- MEM_freeN(mesh);
+ BKE_id_free(NULL, mesh);
}
return ndm;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index a63777dd5ad..4056a15fe47 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -214,8 +214,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
}
}
else {
- /* default to image paint */
- return &ts->imapaint.paint;
+ return BKE_paint_get_active(sce, view_layer);
}
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index f3f08aec3cd..a11c7320da5 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -717,6 +717,7 @@ void BKE_scene_init(Scene *sce)
sce->audio.doppler_factor = 1.0f;
sce->audio.speed_of_sound = 343.3f;
sce->audio.volume = 1.0f;
+ sce->audio.flag = AUDIO_SYNC;
BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic));
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 0d381248ef2..bf22b106cf8 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -158,7 +158,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
return;
}
- TIMEIT_BENCH(bvhtree_from_mesh_get(&treeData, calc->target, BVHTREE_FROM_VERTS), bvhtree_verts);
+ TIMEIT_BENCH(bvhtree_from_mesh_get(&treeData, calc->target, BVHTREE_FROM_VERTS, 2), bvhtree_verts);
if (treeData.tree == NULL) {
OUT_OF_MEMORY();
return;
@@ -191,8 +191,8 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
* MOD_SHRINKWRAP_CULL_TARGET_BACKFACE (back faces hits are ignored)
*/
bool BKE_shrinkwrap_project_normal(
- char options, const float vert[3],
- const float dir[3], const SpaceTransform *transf,
+ char options, const float vert[3], const float dir[3],
+ const float ray_radius, const SpaceTransform *transf,
BVHTree *tree, BVHTreeRayHit *hit,
BVHTree_RayCastCallback callback, void *userdata)
{
@@ -229,7 +229,7 @@ bool BKE_shrinkwrap_project_normal(
hit_tmp.index = -1;
- BLI_bvhtree_ray_cast(tree, co, no, 0.0f, &hit_tmp, callback, userdata);
+ BLI_bvhtree_ray_cast(tree, co, no, ray_radius, &hit_tmp, callback, userdata);
if (hit_tmp.index != -1) {
/* invert the normal first so face culling works on rotated objects */
@@ -322,13 +322,13 @@ static void shrinkwrap_calc_normal_projection_cb_ex(
if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) {
if (aux_tree) {
BKE_shrinkwrap_project_normal(
- 0, tmp_co, tmp_no,
+ 0, tmp_co, tmp_no, 0.0,
local2aux, aux_tree, hit,
aux_callback, auxData);
}
BKE_shrinkwrap_project_normal(
- calc->smd->shrinkOpts, tmp_co, tmp_no,
+ calc->smd->shrinkOpts, tmp_co, tmp_no, 0.0,
&calc->local2target, targ_tree, hit,
targ_callback, treeData);
}
@@ -340,13 +340,13 @@ static void shrinkwrap_calc_normal_projection_cb_ex(
if (aux_tree) {
BKE_shrinkwrap_project_normal(
- 0, tmp_co, inv_no,
+ 0, tmp_co, inv_no, 0.0,
local2aux, aux_tree, hit,
aux_callback, auxData);
}
BKE_shrinkwrap_project_normal(
- calc->smd->shrinkOpts, tmp_co, inv_no,
+ calc->smd->shrinkOpts, tmp_co, inv_no, 0.0,
&calc->local2target, targ_tree, hit,
targ_callback, treeData);
}
@@ -437,8 +437,8 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
}
}
else {
- if ((targ_tree = bvhtree_from_mesh_looptri(
- &treedata_stack.dmtreedata, calc->target, 0.0, 4, 6)))
+ if ((targ_tree = bvhtree_from_mesh_get(
+ &treedata_stack.dmtreedata, calc->target, BVHTREE_FROM_LOOPTRI, 4)))
{
targ_callback = treedata_stack.dmtreedata.raycast_callback;
treeData = &treedata_stack.dmtreedata;
@@ -459,7 +459,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
}
}
else {
- if ((aux_tree = bvhtree_from_mesh_looptri(&auxdata_stack.dmtreedata, auxMesh, 0.0, 4, 6)) != NULL) {
+ if ((aux_tree = bvhtree_from_mesh_get(
+ &auxdata_stack.dmtreedata, auxMesh, BVHTREE_FROM_LOOPTRI, 4)) != NULL)
+ {
aux_callback = auxdata_stack.dmtreedata.raycast_callback;
auxData = &auxdata_stack.dmtreedata;
}
@@ -588,7 +590,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
}
/* Create a bvh-tree of the given target */
- bvhtree_from_mesh_get(&treeData, calc->target, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treeData, calc->target, BVHTREE_FROM_LOOPTRI, 2);
if (treeData.tree == NULL) {
OUT_OF_MEMORY();
return;
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index f99bd773ebc..2c601e9429a 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -867,7 +867,7 @@ static void obstacles_from_derivedmesh(
copy_v3_v3(&scs->verts_old[i * 3], co);
}
- if (bvhtree_from_mesh_looptri(&treeData, dm, 0.0f, 4, 6)) {
+ if (bvhtree_from_mesh_get(&treeData, dm, BVHTREE_FROM_LOOPTRI, 4)) {
ObstaclesFromDMData data = {
.sds = sds, .mvert = mvert, .mloop = mloop, .looptri = looptri,
.tree = &treeData, .obstacle_map = obstacle_map,
@@ -1738,7 +1738,7 @@ static void emit_from_derivedmesh(Object *flow_ob, SmokeDomainSettings *sds, Smo
res[i] = em->res[i] * hires_multiplier;
}
- if (bvhtree_from_mesh_looptri(&treeData, dm, 0.0f, 4, 6)) {
+ if (bvhtree_from_mesh_get(&treeData, dm, BVHTREE_FROM_LOOPTRI, 4)) {
const float hr = 1.0f / ((float)hires_multiplier);
EmitFromDMData data = {
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index db53035dc7b..c92f40c67bf 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -130,7 +130,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(
BVHTree_OverlapCallback callback, void *userdata);
int BLI_bvhtree_get_len(const BVHTree *tree);
-
+int BLI_bvhtree_get_tree_type(const BVHTree *tree);
float BLI_bvhtree_get_epsilon(const BVHTree *tree);
/* find nearest node to the given coordinates
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 44ff78ea71a..027c6e084f5 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1151,6 +1151,14 @@ int BLI_bvhtree_get_len(const BVHTree *tree)
return tree->totleaf;
}
+/**
+ * Maximum number of children that a node can have.
+ */
+int BLI_bvhtree_get_tree_type(const BVHTree *tree)
+{
+ return tree->tree_type;
+}
+
float BLI_bvhtree_get_epsilon(const BVHTree *tree)
{
return tree->epsilon;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index c9619137b9a..b0cfadacb2c 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1070,7 +1070,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- v3d->overlays |= V3D_OVERLAY_3DCURSOR;
+ v3d->drawtype_ambient_intensity = 0.5;
+ v3d->overlays |= V3D_OVERLAY_HIDE_CURSOR;
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 1e27ab64f48..3211ed4fc11 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -210,6 +210,11 @@ void BLO_update_defaults_startup_blend(Main *bmain)
}
scene->r.ffcodecdata.audio_mixrate = 48000;
+
+ /* set av sync by default */
+ printf("setting new default audio\n");
+ scene->audio.flag |= AUDIO_SYNC;
+ scene->flag &= ~SCE_FRAME_DROP;
}
for (FreestyleLineStyle *linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) {
diff --git a/source/blender/bmesh/tools/bmesh_wireframe.c b/source/blender/bmesh/tools/bmesh_wireframe.c
index e79ef52797b..c45e617dd39 100644
--- a/source/blender/bmesh/tools/bmesh_wireframe.c
+++ b/source/blender/bmesh/tools/bmesh_wireframe.c
@@ -91,6 +91,7 @@ static void bm_vert_boundary_tangent(
/* average edge face normal */
add_v3_v3v3(no_face, l_a->f->no, l_b->f->no);
+ normalize_v3(no_face);
/* average edge direction */
v_a = BM_edge_other_vert(e_a, v);
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index e16aca3fdee..4b52c0469aa 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -157,6 +157,11 @@ void RenderLayersNode::missingSocketLink(NodeConverter &converter,
operation = value_operation;
break;
}
+ default:
+ {
+ BLI_assert("!Unexpected data type");
+ return;
+ }
}
converter.mapOutputSocket(output, operation->getOutputSocket());
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_map.cc b/source/blender/depsgraph/intern/builder/deg_builder_map.cc
index 67cb04d1b98..218483d1dc5 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_map.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_map.cc
@@ -33,6 +33,8 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
+#include "DNA_ID.h"
+
namespace DEG {
BuilderMap::BuilderMap() {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
index 208462713a5..c48381481f5 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
@@ -166,7 +166,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object)
* mechanism in-between here to ensure that we can use same rig
* multiple times in same scene.
*/
- if (!built_map_.checkIsBuilt(armature)) {
+ if (!built_map_.checkIsBuiltAndTag(armature)) {
build_animdata(&armature->id);
/* Make sure pose is up-to-date with armature updates. */
add_operation_node(&armature->id,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 45e05c6f928..94c9f0cdd57 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -390,6 +390,40 @@ void DepsgraphRelationBuilder::begin_build()
{
}
+void DepsgraphRelationBuilder::build_id(ID* id) {
+ if (id == NULL) {
+ return;
+ }
+ switch (GS(id->name)) {
+ case ID_GR:
+ build_group(NULL, (Group *)id);
+ break;
+ case ID_OB:
+ build_object(NULL, (Object *)id);
+ break;
+ case ID_NT:
+ build_nodetree((bNodeTree *)id);
+ break;
+ case ID_MA:
+ build_material((Material *)id);
+ break;
+ case ID_TE:
+ build_texture((Tex *)id);
+ break;
+ case ID_WO:
+ build_world((World *)id);
+ break;
+ case ID_MSK:
+ build_mask((Mask *)id);
+ break;
+ case ID_MC:
+ build_movieclip((MovieClip *)id);
+ break;
+ default:
+ fprintf(stderr, "Unhandled ID %s\n", id->name);
+ }
+}
+
void DepsgraphRelationBuilder::build_group(Object *object, Group *group)
{
const bool group_done = built_map_.checkIsBuiltAndTag(group);
@@ -539,7 +573,9 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
}
ID *obdata_id = (ID *)object->data;
/* Object data animation. */
- build_animdata(obdata_id);
+ if (!built_map_.checkIsBuilt(obdata_id)) {
+ build_animdata(obdata_id);
+ }
/* type-specific data. */
switch (object->type) {
case OB_MESH:
@@ -557,7 +593,7 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
build_proxy_rig(object);
}
else {
- build_rig(object);
+ build_rig(object);
}
break;
case OB_LAMP:
@@ -1212,6 +1248,7 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
if (dtar->id == NULL) {
continue;
}
+ build_id(dtar->id);
/* Special handling for directly-named bones. */
if ((dtar->flag & DTAR_FLAG_STRUCT_REF) &&
(((Object *)dtar->id)->type == OB_ARMATURE) &&
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 7c88eea6f72..9e45d01fd79 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -194,6 +194,7 @@ struct DepsgraphRelationBuilder
const char *description,
bool check_unique = false);
+ void build_id(ID* id);
void build_view_layer(Scene *scene, ViewLayer *view_layer);
void build_group(Object *object, Group *group);
void build_object(Base *base, Object *object);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index 126aa85edd3..a9895eb3af1 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -317,11 +317,13 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
add_relation(init_ik_key, flush_key, "Pose Init IK -> Pose Cleanup");
/* Make sure pose is up-to-date with armature updates. */
- OperationKey armature_key(&arm->id,
- DEG_NODE_TYPE_PARAMETERS,
- DEG_OPCODE_PLACEHOLDER,
- "Armature Eval");
- add_relation(armature_key, init_key, "Data dependency");
+ if (!built_map_.checkIsBuiltAndTag(arm)) {
+ OperationKey armature_key(&arm->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ DEG_OPCODE_PLACEHOLDER,
+ "Armature Eval");
+ add_relation(armature_key, init_key, "Data dependency");
+ }
/* IK Solvers...
* - These require separate processing steps are pose-level
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index a827e428fdf..18f1d6edbaf 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -198,7 +198,7 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph,
Scene *scene,
ViewLayer *view_layer)
{
- double start_time;
+ double start_time = 0.0;
if (G.debug & G_DEBUG_DEPSGRAPH_BUILD) {
start_time = PIL_check_seconds_timer();
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 99c24506a7b..7321b394636 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -63,6 +63,7 @@
extern "C" {
#include "DNA_ID.h"
#include "DNA_anim_types.h"
+#include "DNA_armature_types.h"
#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -81,6 +82,7 @@ extern "C" {
#include "BKE_action.h"
#include "BKE_animsys.h"
+#include "BKE_armature.h"
#include "BKE_editmesh.h"
#include "BKE_library_query.h"
#include "BKE_object.h"
@@ -419,6 +421,17 @@ void update_special_pointers(const Depsgraph *depsgraph,
BLI_assert(object_cow->derivedFinal == NULL);
BLI_assert(object_cow->derivedDeform == NULL);
object_cow->mode = object_orig->mode;
+ if (object_cow->type == OB_ARMATURE) {
+ BKE_pose_remap_bone_pointers((bArmature *)object_cow->data,
+ object_cow->pose);
+ }
+ break;
+ }
+ case ID_AR:
+ {
+ const bArmature *armature_orig = (const bArmature *)id_orig;
+ bArmature *armature_cow = (bArmature *)id_cow;
+ armature_cow->edbo = armature_orig->edbo;
break;
}
case ID_ME:
@@ -750,6 +763,12 @@ void deg_free_copy_on_write_datablock(ID *id_cow)
ob_cow->data = NULL;
break;
}
+ case ID_AR:
+ {
+ bArmature *armature_cow = (bArmature *)id_cow;
+ armature_cow->edbo = NULL;
+ break;
+ }
case ID_ME:
{
Mesh *mesh_cow = (Mesh *)id_cow;
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index e3b6e6fb1f9..3c4d7da29fb 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -212,6 +212,8 @@ data_to_c_simple(engines/eevee/shaders/volumetric_integration_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_prepass_vert.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_prepass_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_composite_frag.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_shadow_vert.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_shadow_geom.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_background_lib.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_common_lib.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_data_lib.glsl SRC)
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index 3508a425eb0..b7adcbf0835 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -726,8 +726,10 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE
/* obmat = Object Space > World Space */
/* viewmat = World Space > View Space */
float (*viewmat)[4] = sh_data->viewmat;
- invert_m4_m4(viewmat, ob->obmat);
- normalize_m4(viewmat);
+#if 0 /* done at culling time */
+ normalize_m4_m4(viewmat, ob->obmat);
+#endif
+ invert_m4(viewmat);
invert_m4_m4(sh_data->viewinv, viewmat);
/* The technique consists into splitting
@@ -993,6 +995,28 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
DRWMatrixState saved_mats;
+ /* Precompute all shadow/view test before rendering and trashing the culling cache. */
+ bool cube_visible[MAX_SHADOW_CUBE];
+ for (i = 0; (ob = linfo->shadow_cube_ref[i]) && (i < MAX_SHADOW_CUBE); i++) {
+ Lamp *la = (Lamp *)ob->data;
+ BoundSphere bsphere = {
+ .center = {ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2]},
+ .radius = la->dist
+ };
+ cube_visible[i] = DRW_culling_sphere_test(&bsphere);
+ }
+ bool cascade_visible[MAX_SHADOW_CASCADE];
+ for (i = 0; (ob = linfo->shadow_cascade_ref[i]) && (i < MAX_SHADOW_CASCADE); i++) {
+ EEVEE_LampEngineData *led = EEVEE_lamp_data_get(ob);
+ EEVEE_ShadowCascadeData *sh_data = &led->data.scad;
+ float plane[4];
+ normalize_m4_m4(sh_data->viewmat, ob->obmat);
+ plane_from_point_normal_v3(plane, sh_data->viewmat[3], sh_data->viewmat[2]);
+ /* TODO: check against near/far instead of "local Z = 0" plane.
+ * Or even the cascades AABB. */
+ cascade_visible[i] = DRW_culling_plane_test(plane);
+ }
+
/* We need to save the Matrices before overidding them */
DRW_viewport_matrix_get_all(&saved_mats);
@@ -1003,7 +1027,7 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
EEVEE_LampEngineData *led = EEVEE_lamp_data_ensure(ob);
Lamp *la = (Lamp *)ob->data;
- if (!led->need_update) {
+ if (!led->need_update || !cube_visible[i]) {
continue;
}
@@ -1099,6 +1123,10 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
/* Cascaded Shadow Maps */
DRW_stats_group_start("Cascaded Shadow Maps");
for (i = 0; (ob = linfo->shadow_cascade_ref[i]) && (i < MAX_SHADOW_CASCADE); i++) {
+ if (!cascade_visible[i]) {
+ continue;
+ }
+
EEVEE_LampEngineData *led = EEVEE_lamp_data_ensure(ob);
Lamp *la = (Lamp *)ob->data;
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
index 38211239d01..b032bb6a7b5 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
@@ -6,8 +6,8 @@ uniform sampler2D colorBuffer;
uniform sampler2D normalBuffer;
/* normalBuffer contains viewport normals */
uniform vec2 invertedViewportSize;
-
uniform vec3 objectOverlapColor = vec3(0.0);
+uniform float lightMultiplier;
layout(std140) uniform world_block {
WorldData world_data;
@@ -52,11 +52,11 @@ void main()
vec3 normal_viewport = texelFetch(normalBuffer, texel, 0).rgb;
#endif /* WORKBENCH_ENCODE_NORMALS */
vec3 diffuse_light = get_world_diffuse_light(world_data, normal_viewport);
- vec3 shaded_color = diffuse_light * diffuse_color.rgb;
+ vec3 shaded_color = diffuse_light * diffuse_color.rgb * lightMultiplier;
#else /* V3D_LIGHTING_STUDIO */
vec3 diffuse_color = texelFetch(colorBuffer, texel, 0).rgb;
- vec3 shaded_color = diffuse_color;
+ vec3 shaded_color = diffuse_color * lightMultiplier;
#endif /* V3D_LIGHTING_STUDIO */
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl
new file mode 100644
index 00000000000..a1abfb3fe1c
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl
@@ -0,0 +1,51 @@
+layout(triangles) in;
+layout(triangle_strip, max_vertices=9) out;
+
+uniform mat4 ModelMatrix;
+uniform mat4 ModelViewProjectionMatrix;
+
+uniform vec3 lightDirection = vec3(0.57, 0.57, -0.57);
+
+in VertexData {
+ flat vec4 lightDirectionMS;
+ vec4 frontPosition;
+ vec4 backPosition;
+} vertexData[];
+
+vec3 face_normal(vec3 v1, vec3 v2, vec3 v3) {
+ return normalize(cross(v2 - v1, v3 - v1));
+}
+void main()
+{
+ vec4 light_direction = vertexData[0].lightDirectionMS;
+ vec4 v1 = gl_in[0].gl_Position;
+ vec4 v2 = gl_in[1].gl_Position;
+ vec4 v3 = gl_in[2].gl_Position;
+ bool backface = dot(face_normal(v1.xyz, v2.xyz, v3.xyz), light_direction.xyz) > 0.0;
+
+ int index0 = backface?0:2;
+ int index2 = backface?2:0;
+
+ /* back cap */
+ gl_Position = vertexData[index0].backPosition;
+ EmitVertex();
+ gl_Position = vertexData[1].backPosition;
+ EmitVertex();
+ gl_Position = vertexData[index2].backPosition;
+ EmitVertex();
+
+ /* sides */
+ gl_Position = vertexData[index2].frontPosition;
+ EmitVertex();
+ gl_Position = vertexData[index0].backPosition;
+ EmitVertex();
+ gl_Position = vertexData[index0].frontPosition;
+ EmitVertex();
+ gl_Position = vertexData[1].backPosition;
+ EmitVertex();
+ gl_Position = vertexData[1].frontPosition;
+ EmitVertex();
+ gl_Position = vertexData[index2].frontPosition;
+ EmitVertex();
+ EndPrimitive();
+}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl
new file mode 100644
index 00000000000..7322266a956
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl
@@ -0,0 +1,23 @@
+#define EPSILON 0.000001
+#define INFINITE 100.0
+
+uniform mat4 ModelMatrixInverse;
+uniform mat4 ModelViewProjectionMatrix;
+uniform vec3 lightDirection = vec3(0.57, 0.57, -0.57);
+
+in vec4 pos;
+
+out VertexData {
+ flat vec4 lightDirectionMS;
+ vec4 frontPosition;
+ vec4 backPosition;
+} vertexData;
+
+void main()
+{
+ gl_Position = pos;
+ vertexData.lightDirectionMS = normalize(ModelMatrixInverse * vec4(lightDirection, 0.0));
+ vertexData.lightDirectionMS.w = 0.0;
+ vertexData.frontPosition = ModelViewProjectionMatrix * (pos + vertexData.lightDirectionMS * EPSILON);
+ vertexData.backPosition = ModelViewProjectionMatrix * (pos + vertexData.lightDirectionMS * INFINITE);
+}
diff --git a/source/blender/draw/engines/workbench/solid_mode.c b/source/blender/draw/engines/workbench/solid_mode.c
index 2a1b5eecc27..c001cd13bb8 100644
--- a/source/blender/draw/engines/workbench/solid_mode.c
+++ b/source/blender/draw/engines/workbench/solid_mode.c
@@ -59,8 +59,10 @@ static void workbench_solid_cache_finish(void *vedata)
workbench_materials_cache_finish(data);
}
-static void workbench_solid_draw_background(void *UNUSED(vedata))
+static void workbench_solid_draw_background(void *vedata)
{
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+ workbench_materials_draw_background(data);
}
static void workbench_solid_draw_scene(void *vedata)
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
index f758918d577..40d5c2b12f9 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.c
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -58,7 +58,9 @@ static void workbench_view_layer_settings_create(RenderEngine *UNUSED(engine), I
BLI_assert(props &&
props->type == IDP_GROUP &&
props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
- UNUSED_VARS_NDEBUG(props);
+
+ const float light_direction[3] = {-0.577350269, -0.577350269, 0.577350269};
+ BKE_collection_engine_property_add_float_array(props, "light_direction", light_direction, 3); UNUSED_VARS_NDEBUG(props);
}
/* Note: currently unused, we may want to register so we can see this when debugging the view. */
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 69d983b96c7..04a12d992b3 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -25,8 +25,9 @@
#include "workbench_private.h"
-#include "BLI_dynstr.h"
#include "BLI_alloca.h"
+#include "BLI_dynstr.h"
+#include "BLI_utildefines.h"
#include "BKE_particle.h"
@@ -37,23 +38,31 @@
#include "UI_resources.h"
/* *********** STATIC *********** */
+
+// #define DEBUG_SHADOW_VOLUME
#define MAX_SHADERS 255
+
static struct {
struct GPUShader *prepass_sh_cache[MAX_SHADERS];
struct GPUShader *composite_sh_cache[MAX_SHADERS];
+ struct GPUShader *shadow_sh;
struct GPUTexture *object_id_tx; /* ref only, not alloced */
struct GPUTexture *color_buffer_tx; /* ref only, not alloced */
struct GPUTexture *normal_buffer_tx; /* ref only, not alloced */
+ float light_direction[3]; /* world light direction for shadows */
int next_object_id;
-} e_data = {{NULL}};
+} e_data = {NULL};
/* Shaders */
extern char datatoc_workbench_prepass_vert_glsl[];
extern char datatoc_workbench_prepass_frag_glsl[];
extern char datatoc_workbench_composite_frag_glsl[];
+extern char datatoc_workbench_shadow_vert_glsl[];
+extern char datatoc_workbench_shadow_geom_glsl[];
+
extern char datatoc_workbench_background_lib_glsl[];
extern char datatoc_workbench_common_lib_glsl[];
extern char datatoc_workbench_data_lib_glsl[];
@@ -64,7 +73,7 @@ extern DrawEngineType draw_engine_workbench_solid;
#define OBJECT_ID_PASS_ENABLED(wpd) (wpd->drawtype_options & V3D_DRAWOPTION_OBJECT_OVERLAP)
#define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (wpd->drawtype_lighting & V3D_LIGHTING_STUDIO)
-
+#define SHADOW_ENABLED(wpd) (wpd->drawtype_options & V3D_DRAWOPTION_SHADOW)
static char *workbench_build_defines(WORKBENCH_PrivateData *wpd)
{
char *str = NULL;
@@ -127,7 +136,8 @@ static char *workbench_build_prepass_frag(void)
static int get_shader_index(WORKBENCH_PrivateData *wpd)
{
- return (wpd->drawtype_options << 2) + wpd->drawtype_lighting;
+ const int DRAWOPTIONS_MASK = V3D_DRAWOPTION_OBJECT_OVERLAP;
+ return ((wpd->drawtype_options & DRAWOPTIONS_MASK) << 2) + wpd->drawtype_lighting;
}
static void select_deferred_shaders(WORKBENCH_PrivateData *wpd)
@@ -209,6 +219,7 @@ void workbench_materials_engine_init(WORKBENCH_Data *vedata)
memset(e_data.prepass_sh_cache, 0x00, sizeof(struct GPUShader *) * MAX_SHADERS);
memset(e_data.composite_sh_cache, 0x00, sizeof(struct GPUShader *) * MAX_SHADERS);
e_data.next_object_id = 1;
+ e_data.shadow_sh = DRW_shader_create(datatoc_workbench_shadow_vert_glsl, datatoc_workbench_shadow_geom_glsl, NULL, NULL);
}
if (!stl->g_data) {
@@ -248,6 +259,22 @@ void workbench_materials_engine_free()
DRW_SHADER_FREE_SAFE(e_data.prepass_sh_cache[index]);
DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]);
}
+ DRW_SHADER_FREE_SAFE(e_data.shadow_sh);
+}
+
+static void workbench_composite_uniforms(WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp)
+{
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
+ DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data.color_buffer_tx);
+ if (OBJECT_ID_PASS_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx);
+ }
+ if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &e_data.normal_buffer_tx);
+ }
+ DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
+ DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
}
void workbench_materials_cache_init(WORKBENCH_Data *vedata)
@@ -255,8 +282,12 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
- DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
DRWShadingGroup *grp;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ ViewLayer *view_layer = draw_ctx->view_layer;
+ IDProperty *props = BKE_view_layer_engine_evaluated_get(view_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_WORKBENCH);
+ static float light_multiplier = 1.0f;
+
const DRWContextState *DCS = DRW_context_state_get();
wpd->material_hash = BLI_ghash_ptr_new(__func__);
@@ -266,11 +297,13 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
wpd->drawtype_lighting = v3d->drawtype_lighting;
wpd->drawtype_options = v3d->drawtype_options;
wpd->drawtype_studiolight = v3d->drawtype_studiolight;
+ wpd->drawtype_ambient_intensity = v3d->drawtype_ambient_intensity;
}
else {
wpd->drawtype_lighting = V3D_LIGHTING_STUDIO;
wpd->drawtype_options = 0;
wpd->drawtype_studiolight = 0;
+ wpd->drawtype_ambient_intensity = 0.5;
}
select_deferred_shaders(wpd);
@@ -281,25 +314,49 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
studiolight_update_world(wpd->drawtype_studiolight, wd);
- psl->composite_pass = DRW_pass_create("Composite", DRW_STATE_WRITE_COLOR);
- grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass);
- DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
- DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data.color_buffer_tx);
- if (OBJECT_ID_PASS_ENABLED(wpd)) {
- DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx);
- }
- if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
- DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &e_data.normal_buffer_tx);
- }
wpd->world_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_World), NULL);
- DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
DRW_uniformbuffer_update(wpd->world_ubo, &wpd->world_data);
- DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
- DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ copy_v3_v3(e_data.light_direction, BKE_collection_engine_property_value_get_float_array(props, "light_direction"));
+ negate_v3(e_data.light_direction);
+
+ if (SHADOW_ENABLED(wpd)) {
+ psl->composite_pass = DRW_pass_create("Composite", DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_EQUAL);
+ grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass);
+ workbench_composite_uniforms(wpd, grp);
+ DRW_shgroup_stencil_mask(grp, 0x00);
+ DRW_shgroup_uniform_float(grp, "lightMultiplier", &light_multiplier, 1);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+
+#ifdef DEBUG_SHADOW_VOLUME
+ psl->shadow_pass = DRW_pass_create("Shadow", DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK | DRW_STATE_WRITE_COLOR);
+ grp = DRW_shgroup_create(e_data.shadow_sh, psl->shadow_pass);
+ DRW_shgroup_uniform_vec3(grp, "lightDirection", e_data.light_direction, 1);
+ DRW_shgroup_stencil_mask(grp, 0xFF);
+ wpd->shadow_shgrp = grp;
+#else
+ psl->shadow_pass = DRW_pass_create("Shadow", DRW_STATE_DEPTH_GREATER | DRW_STATE_WRITE_STENCIL_SHADOW);
+ grp = DRW_shgroup_create(e_data.shadow_sh, psl->shadow_pass);
+ DRW_shgroup_uniform_vec3(grp, "lightDirection", e_data.light_direction, 1);
+ DRW_shgroup_stencil_mask(grp, 0xFF);
+ wpd->shadow_shgrp = grp;
+
+ psl->composite_shadow_pass = DRW_pass_create("Composite Shadow", DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_NEQUAL);
+ grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_shadow_pass);
+ DRW_shgroup_stencil_mask(grp, 0x00);
+ workbench_composite_uniforms(wpd, grp);
+ DRW_shgroup_uniform_float(grp, "lightMultiplier", &wpd->drawtype_ambient_intensity, 1);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+#endif
+ }
+ else {
+ psl->composite_pass = DRW_pass_create("Composite", DRW_STATE_WRITE_COLOR);
+ grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass);
+ workbench_composite_uniforms(wpd, grp);
+ DRW_shgroup_uniform_float(grp, "lightMultiplier", &light_multiplier, 1);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ }
}
-
-
}
static WORKBENCH_MaterialData *get_or_create_material_data(WORKBENCH_Data *vedata, IDProperty *props, Object *ob, Material *mat)
{
@@ -324,6 +381,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data(WORKBENCH_Data *vedat
if (material == NULL) {
material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), __func__);
material->shgrp = DRW_shgroup_create(wpd->prepass_sh, psl->prepass_pass);
+ DRW_shgroup_stencil_mask(material->shgrp, 0xFF);
material->object_id = engine_object_data->object_id;
copy_v3_v3(material->color, material_template.color);
DRW_shgroup_uniform_vec3(material->shgrp, "object_color", material->color, 1);
@@ -366,6 +424,9 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, IDPropert
void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
{
+ WORKBENCH_StorageList *stl = vedata->stl;
+ WORKBENCH_PrivateData *wpd = stl->g_data;
+
if (!DRW_object_is_renderable(ob))
return;
@@ -409,6 +470,13 @@ void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob
}
}
}
+
+ if (SHADOW_ENABLED(wpd)) {
+ struct Gwn_Batch *geom_shadow = DRW_cache_object_surface_get(ob);
+ if (geom_shadow) {
+ DRW_shgroup_call_object_add(wpd->shadow_shgrp, geom_shadow, ob);
+ }
+ }
}
}
@@ -416,6 +484,22 @@ void workbench_materials_cache_finish(WORKBENCH_Data *UNUSED(vedata))
{
}
+void workbench_materials_draw_background(WORKBENCH_Data *vedata)
+{
+ WORKBENCH_StorageList *stl = vedata->stl;
+ WORKBENCH_FramebufferList *fbl = vedata->fbl;
+ WORKBENCH_PrivateData *wpd = stl->g_data;
+ const float clear_depth = 1.0f;
+ const float clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ unsigned int clear_stencil = 0xFF;
+
+ GPU_framebuffer_bind(fbl->prepass_fb);
+ int clear_bits = GPU_DEPTH_BIT;
+ SET_FLAG_FROM_TEST(clear_bits, OBJECT_ID_PASS_ENABLED(wpd), GPU_COLOR_BIT);
+ SET_FLAG_FROM_TEST(clear_bits, SHADOW_ENABLED(wpd), GPU_STENCIL_BIT);
+ GPU_framebuffer_clear(fbl->prepass_fb, clear_bits, clear_color, clear_depth, clear_stencil);
+}
+
void workbench_materials_draw_scene(WORKBENCH_Data *vedata)
{
WORKBENCH_PassList *psl = vedata->psl;
@@ -423,20 +507,27 @@ void workbench_materials_draw_scene(WORKBENCH_Data *vedata)
WORKBENCH_FramebufferList *fbl = vedata->fbl;
WORKBENCH_PrivateData *wpd = stl->g_data;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- const float clear_depth = 1.0f;
+ /* clear in background */
GPU_framebuffer_bind(fbl->prepass_fb);
- if (OBJECT_ID_PASS_ENABLED(wpd)) {
- const float clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- GPU_framebuffer_clear_color_depth(fbl->prepass_fb, clear_color, clear_depth);
+ DRW_draw_pass(psl->prepass_pass);
+ if (SHADOW_ENABLED(wpd)) {
+#ifdef DEBUG_SHADOW_VOLUME
+ GPU_framebuffer_bind(dfbl->default_fb);
+ DRW_draw_pass(psl->composite_pass);
+ DRW_draw_pass(psl->shadow_pass);
+#else
+ GPU_framebuffer_bind(dfbl->depth_only_fb);
+ DRW_draw_pass(psl->shadow_pass);
+ GPU_framebuffer_bind(dfbl->default_fb);
+ DRW_draw_pass(psl->composite_pass);
+ DRW_draw_pass(psl->composite_shadow_pass);
+#endif
}
else {
- GPU_framebuffer_clear_depth(fbl->prepass_fb, clear_depth);
+ GPU_framebuffer_bind(dfbl->default_fb);
+ DRW_draw_pass(psl->composite_pass);
}
- DRW_draw_pass(psl->prepass_pass);
-
- GPU_framebuffer_bind(dfbl->color_only_fb);
- DRW_draw_pass(psl->composite_pass);
BLI_ghash_free(wpd->material_hash, NULL, MEM_freeN);
DRW_UBO_FREE_SAFE(wpd->world_ubo);
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 1f66fb31095..6b8acaebc82 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -44,7 +44,10 @@ typedef struct WORKBENCH_StorageList {
typedef struct WORKBENCH_PassList {
struct DRWPass *prepass_pass;
+ struct DRWPass *shadow_pass;
struct DRWPass *composite_pass;
+ struct DRWPass *composite_shadow_pass;
+ struct DRWPass *composite_light_pass;
} WORKBENCH_PassList;
typedef struct WORKBENCH_Data {
@@ -74,7 +77,10 @@ typedef struct WORKBENCH_PrivateData {
short drawtype_lighting;
short drawtype_options;
short drawtype_studiolight;
+ short pad;
+ float drawtype_ambient_intensity;
struct GPUUniformBuffer *world_ubo;
+ struct DRWShadingGroup *shadow_shgrp;
WORKBENCH_UBO_World world_data;
} WORKBENCH_PrivateData; /* Transient data */
@@ -109,6 +115,7 @@ void workbench_solid_materials_free(void);
/* workbench_materials.c */
void workbench_materials_engine_init(WORKBENCH_Data *vedata);
void workbench_materials_engine_free(void);
+void workbench_materials_draw_background(WORKBENCH_Data *vedata);
void workbench_materials_draw_scene(WORKBENCH_Data *vedata);
void workbench_materials_cache_init(WORKBENCH_Data *vedata);
void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob);
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index c0f5a0df3bf..0912e5dde29 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -273,10 +273,11 @@ typedef enum {
DRW_STATE_ADDITIVE_FULL = (1 << 19), /* Same as DRW_STATE_ADDITIVE but let alpha accumulate without premult. */
DRW_STATE_BLEND_PREMUL = (1 << 20), /* Use that if color is already premult by alpha. */
- DRW_STATE_WRITE_STENCIL = (1 << 27),
- DRW_STATE_STENCIL_EQUAL = (1 << 28),
+ DRW_STATE_WRITE_STENCIL = (1 << 27),
+ DRW_STATE_WRITE_STENCIL_SHADOW = (1 << 28),
+ DRW_STATE_STENCIL_EQUAL = (1 << 29),
+ DRW_STATE_STENCIL_NEQUAL = (1 << 30),
} DRWState;
-
#define DRW_STATE_DEFAULT (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS)
typedef enum {
@@ -462,6 +463,7 @@ void DRW_state_clip_planes_reset(void);
/* Culling, return true if object is inside view frustum. */
bool DRW_culling_sphere_test(BoundSphere *bsphere);
bool DRW_culling_box_test(BoundBox *bbox);
+bool DRW_culling_plane_test(float plane[4]);
/* Selection */
void DRW_select_load_id(unsigned int id);
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 3acc851cd01..f4847844650 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -638,7 +638,7 @@ int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color
if (r_color != NULL) {
switch (theme_id) {
- case TH_WIRE_EDIT: *r_color = ts.colorTransform; break;
+ case TH_WIRE_EDIT: *r_color = ts.colorWireEdit; break;
case TH_ACTIVE: *r_color = ts.colorActive; break;
case TH_SELECT: *r_color = ts.colorSelect; break;
case TH_GROUP: *r_color = ts.colorGroup; break;
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index c6c2d5928d8..7a45b808651 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -262,7 +262,7 @@ typedef struct ViewUboStorage {
/* ------------- DRAW MANAGER ------------ */
#define MAX_CLIP_PLANES 6 /* GL_MAX_CLIP_PLANES is at least 6 */
-
+#define STENCIL_UNDEFINED 256
typedef struct DRWManager {
/* TODO clean up this struct a bit */
/* Cache generation */
@@ -320,6 +320,7 @@ typedef struct DRWManager {
struct {
float frustum_planes[6][4];
+ BoundBox frustum_corners;
BoundSphere frustum_bsphere;
bool updated;
} clipping;
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index a70d80257e6..434c021775a 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -278,21 +278,27 @@ void drw_state_set(DRWState state)
DRWState test;
if (CHANGED_ANY_STORE_VAR(
DRW_STATE_WRITE_STENCIL |
- DRW_STATE_STENCIL_EQUAL,
+ DRW_STATE_WRITE_STENCIL_SHADOW |
+ DRW_STATE_STENCIL_EQUAL |
+ DRW_STATE_STENCIL_NEQUAL,
test))
{
if (test) {
glEnable(GL_STENCIL_TEST);
-
/* Stencil Write */
if ((state & DRW_STATE_WRITE_STENCIL) != 0) {
glStencilMask(0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
}
+ else if ((state & DRW_STATE_WRITE_STENCIL_SHADOW) != 0) {
+ glStencilMask(0xFF);
+ glStencilOpSeparate(GL_BACK, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
+ glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_DECR_WRAP, GL_KEEP);
+ }
/* Stencil Test */
- else if ((state & DRW_STATE_STENCIL_EQUAL) != 0) {
+ else if ((state & (DRW_STATE_STENCIL_EQUAL | DRW_STATE_STENCIL_NEQUAL)) != 0) {
glStencilMask(0x00); /* disable write */
- DST.stencil_mask = 0;
+ DST.stencil_mask = STENCIL_UNDEFINED;
}
else {
BLI_assert(0);
@@ -318,15 +324,17 @@ void drw_state_set(DRWState state)
static void drw_stencil_set(unsigned int mask)
{
if (DST.stencil_mask != mask) {
+ DST.stencil_mask = mask;
/* Stencil Write */
if ((DST.state & DRW_STATE_WRITE_STENCIL) != 0) {
glStencilFunc(GL_ALWAYS, mask, 0xFF);
- DST.stencil_mask = mask;
}
/* Stencil Test */
else if ((DST.state & DRW_STATE_STENCIL_EQUAL) != 0) {
glStencilFunc(GL_EQUAL, mask, 0xFF);
- DST.stencil_mask = mask;
+ }
+ else if ((DST.state & DRW_STATE_STENCIL_NEQUAL) != 0) {
+ glStencilFunc(GL_NOTEQUAL, mask, 0xFF);
}
}
}
@@ -461,6 +469,8 @@ static void draw_clipping_setup_from_view(void)
mul_m4_v3(viewinv, bbox.vec[i]);
}
+ memcpy(&DST.clipping.frustum_corners, &bbox, sizeof(BoundBox));
+
/* Compute clip planes using the world space frustum corners. */
for (int p = 0; p < 6; p++) {
int q, r;
@@ -640,6 +650,22 @@ bool DRW_culling_box_test(BoundBox *bbox)
return true;
}
+/* Return True if the current view frustum is inside or intersect the given plane */
+bool DRW_culling_plane_test(float plane[4])
+{
+ draw_clipping_setup_from_view();
+
+ /* Test against the 8 frustum corners. */
+ for (int c = 0; c < 8; c++) {
+ float dist = plane_point_side_v3(plane, DST.clipping.frustum_corners.vec[c]);
+ if (dist < 0.0f) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/draw/intern/draw_manager_texture.c b/source/blender/draw/intern/draw_manager_texture.c
index 71d1ec0e840..607b5e19745 100644
--- a/source/blender/draw/intern/draw_manager_texture.c
+++ b/source/blender/draw/intern/draw_manager_texture.c
@@ -25,6 +25,7 @@
#include "draw_manager.h"
+#ifndef NDEBUG
/* Maybe gpu_texture.c is a better place for this. */
static bool drw_texture_format_supports_framebuffer(GPUTextureFormat format)
{
@@ -55,6 +56,7 @@ static bool drw_texture_format_supports_framebuffer(GPUTextureFormat format)
return false;
}
}
+#endif
void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags)
{
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 5a0c5d1f35c..5b705a311c9 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -615,7 +615,7 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie
{
Object *ob = OBACT(view_layer);
View3D *v3d = draw_ctx->v3d;
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) > 0 || (v3d->overlays & V3D_OVERLAY_3DCURSOR) == 0) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) > 0 || (v3d->overlays & V3D_OVERLAY_HIDE_CURSOR)) {
return false;
}
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 36dded5ed5e..8109fc27cea 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -829,7 +829,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
{
Object *obedit;
bArmature *arm;
- EditBone *newbone, *ebone, *flipbone, *first = NULL;
+ EditBone *newbone = NULL, *ebone, *flipbone, *first = NULL;
int a, totbone = 0, do_extrude;
bool forked = RNA_boolean_get(op->ptr, "forked");
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index ea7a35a4b0e..eaae7dacbba 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -879,69 +879,6 @@ typedef struct MeshDeformIsect {
/* ray intersection */
-/* our own triangle intersection, so we can fully control the epsilons and
- * prevent corner case from going wrong*/
-static int meshdeform_tri_intersect(const float orig[3], const float end[3], const float vert0[3],
- const float vert1[3], const float vert2[3],
- float r_isectco[3], float r_uvw[3])
-{
- float edge1[3], edge2[3], tvec[3], pvec[3], qvec[3];
- float det, inv_det, u, v, dir[3], isectdir[3];
-
- sub_v3_v3v3(dir, end, orig);
-
- /* find vectors for two edges sharing vert0 */
- sub_v3_v3v3(edge1, vert1, vert0);
- sub_v3_v3v3(edge2, vert2, vert0);
-
- /* begin calculating determinant - also used to calculate U parameter */
- cross_v3_v3v3(pvec, dir, edge2);
-
- /* if determinant is near zero, ray lies in plane of triangle */
- det = dot_v3v3(edge1, pvec);
-
- if (UNLIKELY(det == 0.0f)) {
- return 0;
- }
-
- inv_det = 1.0f / det;
-
- /* calculate distance from vert0 to ray origin */
- sub_v3_v3v3(tvec, orig, vert0);
-
- /* calculate U parameter and test bounds */
- u = dot_v3v3(tvec, pvec) * inv_det;
- if (u < -EPSILON || u > 1.0f + EPSILON)
- return 0;
-
- /* prepare to test V parameter */
- cross_v3_v3v3(qvec, tvec, edge1);
-
- /* calculate V parameter and test bounds */
- v = dot_v3v3(dir, qvec) * inv_det;
- if (v < -EPSILON || u + v > 1.0f + EPSILON)
- return 0;
-
- r_isectco[0] = (1.0f - u - v) * vert0[0] + u * vert1[0] + v * vert2[0];
- r_isectco[1] = (1.0f - u - v) * vert0[1] + u * vert1[1] + v * vert2[1];
- r_isectco[2] = (1.0f - u - v) * vert0[2] + u * vert1[2] + v * vert2[2];
-
- r_uvw[0] = 1.0f - u - v;
- r_uvw[1] = u;
- r_uvw[2] = v;
-
- /* check if it is within the length of the line segment */
- sub_v3_v3v3(isectdir, r_isectco, orig);
-
- if (dot_v3v3(dir, isectdir) < -EPSILON)
- return 0;
-
- if (dot_v3v3(dir, dir) + EPSILON < dot_v3v3(isectdir, isectdir))
- return 0;
-
- return 1;
-}
-
struct MeshRayCallbackData {
MeshDeformBind *mdb;
MeshDeformIsect *isec;
@@ -955,7 +892,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
const MLoopTri *looptri = mdb->cagedm_cache.looptri, *lt;
const float (*poly_nors)[3] = mdb->cagedm_cache.poly_nors;
MeshDeformIsect *isec = data->isec;
- float no[3], co[3], end[3], uvw[3], dist;
+ float no[3], co[3], dist;
float *face[3];
lt = &looptri[index];
@@ -963,11 +900,12 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
face[0] = mdb->cagecos[mloop[lt->tri[0]].v];
face[1] = mdb->cagecos[mloop[lt->tri[1]].v];
face[2] = mdb->cagecos[mloop[lt->tri[2]].v];
-
- add_v3_v3v3(end, isec->start, isec->vec);
-
- if (!meshdeform_tri_intersect(ray->origin, end, UNPACK3(face), co, uvw))
+
+ if (!isect_ray_tri_watertight_v3(
+ ray->origin, ray->isect_precalc, UNPACK3(face), &dist, NULL))
+ {
return;
+ }
if (poly_nors) {
copy_v3_v3(no, poly_nors[lt->poly]);
@@ -976,7 +914,8 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
normal_tri_v3(no, UNPACK3(face));
}
- dist = len_v3v3(ray->origin, co) / isec->vec_length;
+ madd_v3_v3v3fl(co, ray->origin, ray->direction, dist);
+ dist /= isec->vec_length;
if (dist < hit->dist) {
hit->index = index;
hit->dist = dist;
@@ -1012,8 +951,8 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, const
hit.index = -1;
hit.dist = BVH_RAYCAST_DIST_MAX;
- if (BLI_bvhtree_ray_cast(mdb->bvhtree, isect_mdef.start, vec_normal,
- 0.0, &hit, harmonic_ray_callback, &data) != -1)
+ if (BLI_bvhtree_ray_cast_ex(mdb->bvhtree, isect_mdef.start, vec_normal,
+ 0.0, &hit, harmonic_ray_callback, &data, BVH_RAYCAST_WATERTIGHT) != -1)
{
const MLoop *mloop = mdb->cagedm_cache.mloop;
const MLoopTri *lt = &mdb->cagedm_cache.looptri[hit.index];
@@ -1508,7 +1447,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa
mdb->totalphi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindTotalPhi");
mdb->boundisect = MEM_callocN(sizeof(*mdb->boundisect) * mdb->size3, "MDefBoundIsect");
mdb->semibound = MEM_callocN(sizeof(int) * mdb->size3, "MDefSemiBound");
- mdb->bvhtree = bvhtree_from_mesh_looptri(&mdb->bvhdata, mdb->cagedm, FLT_EPSILON * 100, 4, 6);
+ mdb->bvhtree = bvhtree_from_mesh_get(&mdb->bvhdata, mdb->cagedm, BVHTREE_FROM_LOOPTRI, 4);
mdb->inside = MEM_callocN(sizeof(int) * mdb->totvert, "MDefInside");
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND)
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index c1e9346efdd..4d29bef63ee 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -618,34 +618,31 @@ static void pose_copy_menu(Scene *scene)
static int pose_flip_names_exec(bContext *C, wmOperator *op)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm;
-
- /* paranoia checks */
- if (ELEM(NULL, ob, ob->pose))
- return OPERATOR_CANCELLED;
-
+ ViewLayer *view_layer = CTX_data_view_layer(C);
const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers");
-
- arm = ob->data;
-
- ListBase bones_names = {NULL};
-
- CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
+
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob)
{
- BLI_addtail(&bones_names, BLI_genericNodeN(pchan->name));
- }
- CTX_DATA_END;
+ bArmature *arm = ob->data;
+ ListBase bones_names = {NULL};
- ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers);
+ FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan)
+ {
+ BLI_addtail(&bones_names, BLI_genericNodeN(pchan->name));
+ }
+ FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
- BLI_freelistN(&bones_names);
-
- /* since we renamed stuff... */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers);
- /* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+ BLI_freelistN(&bones_names);
+
+ /* since we renamed stuff... */
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+ }
+ FOREACH_OBJECT_IN_MODE_END;
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 056e8a2668c..669c6283856 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -711,7 +711,7 @@ static void curve_draw_exec_precalc(wmOperator *op)
const struct StrokeElem *selem, *selem_first, *selem_last;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
- selem_first = BLI_mempool_iterstep(&iter);
+ selem_first = selem_last = BLI_mempool_iterstep(&iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
selem_last = selem;
}
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index 673faa37f2a..4d87503fd69 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -1599,6 +1599,7 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst
/* init heap */
heap = BLI_heap_new();
+ vert_curr = data[vert_src].vert;
BLI_heap_insert(heap, 0.0f, &data[vert_src].vert);
data[vert_src].cost = 0.0f;
data[vert_src].vert_prev = vert_src; /* nop */
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index f28da5a666b..5841a61acc5 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -212,6 +212,7 @@ eAutoPropButsReturn uiDefAutoButsRNA(
break;
}
case UI_BUT_LABEL_ALIGN_NONE:
+ default:
col = layout;
name = NULL; /* no smart label alignment, show default name with button */
break;
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 35eb6d9f631..75a3d41ef18 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -290,27 +290,39 @@ void MESH_OT_subdivide_edgering(wmOperatorType *ot)
static int edbm_unsubdivide_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMOperator bmop;
-
const int iterations = RNA_int_get(op->ptr, "iterations");
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
- EDBM_op_init(em, &bmop, op,
- "unsubdivide verts=%hv iterations=%i", BM_ELEM_SELECT, iterations);
+ if ((em->bm->totvertsel == 0) &&
+ (em->bm->totedgesel == 0) &&
+ (em->bm->totfacesel == 0))
+ {
+ continue;
+ }
- BMO_op_exec(em->bm, &bmop);
+ BMOperator bmop;
+ EDBM_op_init(em, &bmop, op,
+ "unsubdivide verts=%hv iterations=%i", BM_ELEM_SELECT, iterations);
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return 0;
- }
+ BMO_op_exec(em->bm, &bmop);
- if ((em->selectmode & SCE_SELECT_VERTEX) == 0) {
- EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); /* need to flush vert->face first */
- }
- EDBM_selectmode_flush(em);
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ continue;
+ }
- EDBM_update_generic(em, true, true);
+ if ((em->selectmode & SCE_SELECT_VERTEX) == 0) {
+ EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); /* need to flush vert->face first */
+ }
+ EDBM_selectmode_flush(em);
+
+ EDBM_update_generic(em, true, true);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -1753,71 +1765,99 @@ void MESH_OT_flip_normals(wmOperatorType *ot)
*/
static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMOperator bmop;
BMEdge *eed;
BMIter iter;
const bool use_ccw = RNA_boolean_get(op->ptr, "use_ccw");
- int tot = 0;
- if (em->bm->totedgesel == 0) {
- BKE_report(op->reports, RPT_ERROR, "Select edges or face pairs for edge loops to rotate about");
- return OPERATOR_CANCELLED;
- }
+ int tot_rotate_all = 0, tot_failed_all = 0;
+ bool no_selected_edges = true, invalid_selected_edges = true;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ int tot = 0;
- /* first see if we have two adjacent faces */
- BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- BM_elem_flag_disable(eed, BM_ELEM_TAG);
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- BMFace *fa, *fb;
- if (BM_edge_face_pair(eed, &fa, &fb)) {
- /* if both faces are selected we rotate between them,
- * otherwise - rotate between 2 unselected - but not mixed */
- if (BM_elem_flag_test(fa, BM_ELEM_SELECT) == BM_elem_flag_test(fb, BM_ELEM_SELECT)) {
- BM_elem_flag_enable(eed, BM_ELEM_TAG);
- tot++;
+ if (em->bm->totedgesel == 0) {
+ continue;
+ }
+ no_selected_edges = false;
+
+ /* first see if we have two adjacent faces */
+ BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
+ BM_elem_flag_disable(eed, BM_ELEM_TAG);
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
+ BMFace *fa, *fb;
+ if (BM_edge_face_pair(eed, &fa, &fb)) {
+ /* if both faces are selected we rotate between them,
+ * otherwise - rotate between 2 unselected - but not mixed */
+ if (BM_elem_flag_test(fa, BM_ELEM_SELECT) == BM_elem_flag_test(fb, BM_ELEM_SELECT)) {
+ BM_elem_flag_enable(eed, BM_ELEM_TAG);
+ tot++;
+ }
}
}
}
- }
- /* ok, we don't have two adjacent faces, but we do have two selected ones.
- * that's an error condition.*/
- if (tot == 0) {
- BKE_report(op->reports, RPT_ERROR, "Could not find any selected edges that can be rotated");
- return OPERATOR_CANCELLED;
- }
+ /* ok, we don't have two adjacent faces, but we do have two selected ones.
+ * that's an error condition.*/
+ if (tot == 0) {
+ continue;
+ }
+ invalid_selected_edges = false;
- EDBM_op_init(em, &bmop, op, "rotate_edges edges=%he use_ccw=%b", BM_ELEM_TAG, use_ccw);
+ BMOperator bmop;
+ EDBM_op_init(em, &bmop, op, "rotate_edges edges=%he use_ccw=%b", BM_ELEM_TAG, use_ccw);
- /* avoids leaving old verts selected which can be a problem running multiple times,
- * since this means the edges become selected around the face which then attempt to rotate */
- BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "edges", BM_EDGE, BM_ELEM_SELECT, true);
+ /* avoids leaving old verts selected which can be a problem running multiple times,
+ * since this means the edges become selected around the face which then attempt to rotate */
+ BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "edges", BM_EDGE, BM_ELEM_SELECT, true);
- BMO_op_exec(em->bm, &bmop);
- /* edges may rotate into hidden vertices, if this does _not_ run we get an ilogical state */
- BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_HIDDEN, true);
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true);
+ BMO_op_exec(em->bm, &bmop);
+ /* edges may rotate into hidden vertices, if this does _not_ run we get an ilogical state */
+ BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_HIDDEN, true);
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true);
+
+ const int tot_rotate = BMO_slot_buffer_count(bmop.slots_out, "edges.out");
+ const int tot_failed = tot - tot_rotate;
+
+ tot_rotate_all += tot_rotate;
+ tot_failed_all += tot_failed;
+
+ if (tot_failed != 0) {
+ /* If some edges fail to rotate, we need to re-select them,
+ * otherwise we can end up with invalid selection
+ * (unselected edge between 2 selected faces). */
+ BM_mesh_elem_hflag_enable_test(em->bm, BM_EDGE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);
+ }
- const int tot_rotate = BMO_slot_buffer_count(bmop.slots_out, "edges.out");
- const int tot_failed = tot - tot_rotate;
- if (tot_failed != 0) {
- /* If some edges fail to rotate, we need to re-select them,
- * otherwise we can end up with invalid selection
- * (unselected edge between 2 selected faces). */
- BM_mesh_elem_hflag_enable_test(em->bm, BM_EDGE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);
+ EDBM_selectmode_flush(em);
- BKE_reportf(op->reports, RPT_WARNING, "Unable to rotate %d edge(s)", tot_failed);
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ continue;
+ }
+
+ EDBM_update_generic(em, true, true);
}
+ MEM_freeN(objects);
- EDBM_selectmode_flush(em);
+ if (no_selected_edges) {
+ BKE_report(op->reports, RPT_ERROR, "Select edges or face pairs for edge loops to rotate about");
+ return OPERATOR_CANCELLED;
+ }
- if (!EDBM_op_finish(em, &bmop, op, true)) {
+ /* Ok, we don't have two adjacent faces, but we do have two selected ones.
+ * that's an error condition. */
+ if (invalid_selected_edges) {
+ BKE_report(op->reports, RPT_ERROR, "Could not find any selected edges that can be rotated");
return OPERATOR_CANCELLED;
}
- EDBM_update_generic(em, true, true);
+ if (tot_failed_all != 0) {
+ BKE_reportf(op->reports, RPT_WARNING, "Unable to rotate %d edge(s)", tot_failed_all);
+ }
return OPERATOR_FINISHED;
}
@@ -4851,52 +4891,65 @@ void MESH_OT_dissolve_mode(wmOperatorType *ot)
static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMesh *bm = em->bm;
const float angle_limit = RNA_float_get(op->ptr, "angle_limit");
const bool use_dissolve_boundaries = RNA_boolean_get(op->ptr, "use_dissolve_boundaries");
const int delimit = RNA_enum_get(op->ptr, "delimit");
-
char dissolve_flag;
- if (em->selectmode == SCE_SELECT_FACE) {
- /* flush selection to tags and untag edges/verts with partially selected faces */
- BMIter iter;
- BMIter liter;
-
- BMElem *ele;
- BMFace *f;
- BMLoop *l;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
- BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
- BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_SELECT));
- }
- BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
- BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_SELECT));
+ if ((bm->totvertsel == 0) &&
+ (bm->totedgesel == 0) &&
+ (bm->totfacesel == 0))
+ {
+ continue;
}
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- BM_elem_flag_disable(l->v, BM_ELEM_TAG);
- BM_elem_flag_disable(l->e, BM_ELEM_TAG);
+ if (em->selectmode == SCE_SELECT_FACE) {
+ /* flush selection to tags and untag edges/verts with partially selected faces */
+ BMIter iter;
+ BMIter liter;
+
+ BMElem *ele;
+ BMFace *f;
+ BMLoop *l;
+
+ BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_SELECT));
+ }
+ BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
+ BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_SELECT));
+ }
+
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+ BM_elem_flag_disable(l->v, BM_ELEM_TAG);
+ BM_elem_flag_disable(l->e, BM_ELEM_TAG);
+ }
}
}
- }
- dissolve_flag = BM_ELEM_TAG;
- }
- else {
- dissolve_flag = BM_ELEM_SELECT;
- }
+ dissolve_flag = BM_ELEM_TAG;
+ }
+ else {
+ dissolve_flag = BM_ELEM_SELECT;
+ }
- EDBM_op_call_and_selectf(
- em, op, "region.out", true,
- "dissolve_limit edges=%he verts=%hv angle_limit=%f use_dissolve_boundaries=%b delimit=%i",
- dissolve_flag, dissolve_flag, angle_limit, use_dissolve_boundaries, delimit);
+ EDBM_op_call_and_selectf(
+ em, op, "region.out", true,
+ "dissolve_limit edges=%he verts=%hv angle_limit=%f use_dissolve_boundaries=%b delimit=%i",
+ dissolve_flag, dissolve_flag, angle_limit, use_dissolve_boundaries, delimit);
- EDBM_update_generic(em, true, true);
+ EDBM_update_generic(em, true, true);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index af4ef00bc25..e8f3e592715 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -553,7 +553,7 @@ UvVertMap *BM_uv_vert_map_create(
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, a) {
if ((use_select == false) || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
- float (*tf_uv)[2];
+ float (*tf_uv)[2] = NULL;
if (use_winding) {
tf_uv = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa->len);
@@ -657,7 +657,7 @@ UvElementMap *BM_uv_element_map_create(
/* vars from original func */
UvElementMap *element_map;
UvElement *buf;
- bool *winding;
+ bool *winding = NULL;
BLI_buffer_declare_static(vec2f, tf_uv_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE);
MLoopUV *luv;
@@ -698,7 +698,7 @@ UvElementMap *BM_uv_element_map_create(
}
if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
- float (*tf_uv)[2];
+ float (*tf_uv)[2] = NULL;
if (use_winding) {
tf_uv = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa->len);
@@ -1002,7 +1002,7 @@ void EDBM_verts_mirror_cache_begin_ex(
BMesh *bm = em->bm;
BMIter iter;
BMVert *v;
- int cd_vmirr_offset;
+ int cd_vmirr_offset = 0;
int i;
const float maxdist_sq = SQUARE(maxdist);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index a509a909111..5c476df3dd3 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -410,7 +410,7 @@ static bool PE_create_shape_tree(PEData *data, Object *shapeob)
return false;
}
- return (bvhtree_from_mesh_looptri(&data->shape_bvh, dm, 0.0f, 4, 8) != NULL);
+ return (bvhtree_from_mesh_get(&data->shape_bvh, dm, BVHTREE_FROM_LOOPTRI, 4) != NULL);
}
static void PE_free_shape_tree(PEData *data)
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 9322f8dd487..ecebcb1ff6c 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -699,11 +699,11 @@ static bool remap_hair_emitter(
if (dm->getNumTessFaces(dm) != 0) {
mface = dm->getTessFaceArray(dm);
- bvhtree_from_mesh_get(&bvhtree, dm, BVHTREE_FROM_FACES);
+ bvhtree_from_mesh_get(&bvhtree, dm, BVHTREE_FROM_FACES, 2);
}
else if (dm->getNumEdges(dm) != 0) {
medge = dm->getEdgeArray(dm);
- bvhtree_from_mesh_get(&bvhtree, dm, BVHTREE_FROM_EDGES);
+ bvhtree_from_mesh_get(&bvhtree, dm, BVHTREE_FROM_EDGES, 2);
}
else {
dm->release(dm);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index f2bf817f502..bfce5a862d0 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -676,7 +676,7 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C,
* the mouse.
*/
if (sc->flag & SC_SHOW_MARKER_PATTERN) {
- int current_corner;
+ int current_corner = -1;
distance_squared =
mouse_to_closest_pattern_corner_distance_squared(
marker,
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 086efbe9c34..6071b8d8e94 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -323,7 +323,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->gridsubdiv = 10;
v3d->drawtype = OB_SOLID;
v3d->drawtype_lighting = V3D_LIGHTING_STUDIO;
- v3d->overlays = V3D_OVERLAY_3DCURSOR;
+ v3d->drawtype_ambient_intensity = 0.5;
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 4b415ffde9e..cc7dd08b8a9 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -5905,6 +5905,7 @@ static bool bm_loop_calc_opposite_co(BMLoop *l_tmp,
BMLoop *l_last = l_tmp->prev;
BMLoop *l_iter;
float dist = FLT_MAX;
+ bool found = false;
l_iter = l_first;
do {
@@ -5923,12 +5924,13 @@ static bool bm_loop_calc_opposite_co(BMLoop *l_tmp,
if (tdist < dist) {
copy_v3_v3(r_co, tvec);
dist = tdist;
+ found = true;
}
}
}
} while ((l_iter = l_iter->next) != l_last);
- return (dist != FLT_MAX);
+ return found;
}
/**
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 77e75900af7..fb612e8a4ff 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -450,7 +450,7 @@ static bool raycastDerivedMesh(
}
if (treedata->tree == NULL) {
- bvhtree_from_mesh_looptri(treedata, dm, 0.0f, 4, 6);
+ bvhtree_from_mesh_get(treedata, dm, BVHTREE_FROM_LOOPTRI, 4);
if (treedata->tree == NULL) {
return retval;
@@ -1694,10 +1694,10 @@ static bool snapDerivedMesh(
if (treedata->tree == NULL) {
switch (snapdata->snap_to) {
case SCE_SNAP_MODE_EDGE:
- bvhtree_from_mesh_get(treedata, dm, BVHTREE_FROM_EDGES);
+ bvhtree_from_mesh_get(treedata, dm, BVHTREE_FROM_EDGES, 2);
break;
case SCE_SNAP_MODE_VERTEX:
- bvhtree_from_mesh_get(treedata, dm, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(treedata, dm, BVHTREE_FROM_VERTS, 2);
break;
}
}
diff --git a/source/blender/makesdna/DNA_group_types.h b/source/blender/makesdna/DNA_group_types.h
index 8f15aa85e97..57db668b282 100644
--- a/source/blender/makesdna/DNA_group_types.h
+++ b/source/blender/makesdna/DNA_group_types.h
@@ -42,9 +42,6 @@ struct Object;
typedef struct GroupObject {
struct GroupObject *next, *prev;
struct Object *ob;
- void *lampren; /* used while render */
- short recalc; /* copy of ob->recalc, used to set animated groups OK */
- char pad[6];
} GroupObject;
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index dd2933b04ee..8021ed12e45 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -90,12 +90,13 @@ enum {
V3D_DRAWOPTION_OBJECT_OVERLAP = (1 << 1),
V3D_DRAWOPTION_SINGLE_COLOR = (1 << 2),
V3D_DRAWOPTION_OBJECT_COLOR = (1 << 4),
+ V3D_DRAWOPTION_SHADOW = (1 << 5),
};
#define V3D_DRAWOPTION_SOLID_COLOR_MASK (V3D_DRAWOPTION_SINGLE_COLOR | V3D_DRAWOPTION_RANDOMIZE | V3D_DRAWOPTION_OBJECT_COLOR | V3D_DRAWOPTION_MATERIAL_COLOR)
enum {
V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
- V3D_OVERLAY_3DCURSOR = (1 << 1),
+ V3D_OVERLAY_HIDE_CURSOR = (1 << 1),
};
typedef struct RegionView3D {
@@ -259,9 +260,9 @@ typedef struct View3D {
short drawtype_lighting;
short drawtype_options;
short drawtype_studiolight;
+ float drawtype_ambient_intensity;
int overlays;
- int pad6;
View3DDebug debug;
} View3D;
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 93df67306e3..e394680cddd 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -319,6 +319,9 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_INT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(int, Workbench, COLLECTION_MODE_NONE, _NAME_)
+#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_BOOL(_NAME_) \
+ RNA_LAYER_ENGINE_GET_SET(bool, Workbench, COLLECTION_MODE_NONE, _NAME_)
+
/* mode engines */
#define RNA_LAYER_MODE_OBJECT_GET_SET_FLOAT(_NAME_) \
@@ -368,12 +371,7 @@ RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(hair_brightness_randomness)
RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT(random_object_color_saturation)
RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT(random_object_color_value)
/* View Layer settings */
-RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(diffuse_light_x_pos, 3)
-RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(diffuse_light_x_neg, 3)
-RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(diffuse_light_y_pos, 3)
-RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(diffuse_light_y_neg, 3)
-RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(diffuse_light_z_pos, 3)
-RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(diffuse_light_z_neg, 3)
+RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(light_direction, 3)
/* eevee engine */
/* ViewLayer settings. */
@@ -1709,51 +1707,10 @@ static void rna_def_view_layer_engine_settings_workbench(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Workbench Scene Layer Settings", "Workbench Engine settings");
RNA_define_verify_sdna(0); /* not in sdna */
-
- prop = RNA_def_property(srna, "diffuse_light_x_pos", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_diffuse_light_x_pos_get", "rna_LayerEngineSettings_Workbench_diffuse_light_x_pos_set", NULL);
- RNA_def_property_ui_text(prop, "Diffuse +X Light", "Diffuse light color in positive X direction");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
-
- prop = RNA_def_property(srna, "diffuse_light_x_neg", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_diffuse_light_x_neg_get", "rna_LayerEngineSettings_Workbench_diffuse_light_x_neg_set", NULL);
- RNA_def_property_ui_text(prop, "Diffuse -X Light", "Diffuse light color in negative X direction");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
-
- prop = RNA_def_property(srna, "diffuse_light_y_pos", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_diffuse_light_y_pos_get", "rna_LayerEngineSettings_Workbench_diffuse_light_y_pos_set", NULL);
- RNA_def_property_ui_text(prop, "Diffuse +Y Light", "Diffuse light color in positive Y direction");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
-
- prop = RNA_def_property(srna, "diffuse_light_y_neg", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_diffuse_light_y_neg_get", "rna_LayerEngineSettings_Workbench_diffuse_light_y_neg_set", NULL);
- RNA_def_property_ui_text(prop, "Diffuse -Y Light", "Diffuse light color in negative Y direction");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
-
- prop = RNA_def_property(srna, "diffuse_light_z_pos", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_diffuse_light_z_pos_get", "rna_LayerEngineSettings_Workbench_diffuse_light_z_pos_set", NULL);
- RNA_def_property_ui_text(prop, "Diffuse +Z Light", "Diffuse light color in positive Z direction");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
-
- prop = RNA_def_property(srna, "diffuse_light_z_neg", PROP_FLOAT, PROP_COLOR);
+ prop = RNA_def_property(srna, "light_direction", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_diffuse_light_z_neg_get", "rna_LayerEngineSettings_Workbench_diffuse_light_z_neg_set", NULL);
- RNA_def_property_ui_text(prop, "Diffuse -Z Light", "Diffuse light color in negative Z direction");
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_light_direction_get", "rna_LayerEngineSettings_Workbench_light_direction_set", NULL);
+ RNA_def_property_ui_text(prop, "Light Direction", "Direction of the light for shadow calculation");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 7b04bf80af6..04507d1ed7e 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -311,7 +311,7 @@ static void rna_Object_ray_cast(
BVHTreeFromMesh treeData = {NULL};
/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
- bvhtree_from_mesh_looptri(&treeData, ob->derivedFinal, 0.0f, 4, 6);
+ bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4);
/* may fail if the mesh has no faces, in that case the ray-cast misses */
if (treeData.tree != NULL) {
@@ -360,7 +360,7 @@ static void rna_Object_closest_point_on_mesh(
}
/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
- bvhtree_from_mesh_looptri(&treeData, ob->derivedFinal, 0.0f, 4, 6);
+ bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4);
if (treeData.tree == NULL) {
BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for finding nearest point",
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 1fb4e2d8b57..b93c3cf1dc6 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5864,14 +5864,17 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
/* Frame dropping flag for playback and sync enum */
+#if 0 /* XXX: Is this actually needed? */
prop = RNA_def_property(srna, "use_frame_drop", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_FRAME_DROP);
RNA_def_property_ui_text(prop, "Frame Dropping", "Play back dropping frames if frame display is too slow");
RNA_def_property_update(prop, NC_SCENE, NULL);
+#endif
prop = RNA_def_property(srna, "sync_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_funcs(prop, "rna_Scene_sync_mode_get", "rna_Scene_sync_mode_set", NULL);
RNA_def_property_enum_items(prop, sync_mode_items);
+ RNA_def_property_enum_default(prop, AUDIO_SYNC);
RNA_def_property_ui_text(prop, "Sync Mode", "How to sync playback");
RNA_def_property_update(prop, NC_SCENE, NULL);
@@ -6007,11 +6010,13 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Audio Muted", "Play back of audio from Sequence Editor will be muted");
RNA_def_property_update(prop, NC_SCENE, NULL);
+#if 0 /* XXX: Is this actually needed? */
prop = RNA_def_property(srna, "use_audio_sync", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SYNC);
RNA_def_property_ui_text(prop, "Audio Sync",
"Play back and sync with audio clock, dropping frames if frame display is too slow");
RNA_def_property_update(prop, NC_SCENE, NULL);
+#endif
prop = RNA_def_property(srna, "use_audio_scrub", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SCRUB);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 6feec355808..bb9c711838a 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2249,6 +2249,21 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
NULL);
RNA_def_property_ui_text(prop, "Color", "Single Color Mode");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update");
+
+ prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "drawtype_options", V3D_DRAWOPTION_SHADOW);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Shadow", "Show Shadow");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update");
+
+ prop = RNA_def_property(srna, "ambient_light_intensity", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "drawtype_ambient_intensity");
+ RNA_def_property_float_default(prop, 0.5);
+ RNA_def_property_ui_text(prop, "Ambient Light", "Intensity of ambient light for shadows");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update");
}
static void rna_def_space_view3d_overlay(BlenderRNA *brna)
@@ -2267,8 +2282,8 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like manipulators and outlines");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "show_3dcursor", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "overlays", V3D_OVERLAY_3DCURSOR);
+ prop = RNA_def_property(srna, "show_cursor", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "overlays", V3D_OVERLAY_HIDE_CURSOR);
RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index d48c4e2549d..8e8b095d069 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -137,8 +137,7 @@ static void deformVertsEM(
Mesh *mesh_src = mesh;
if (!mesh) {
- struct BMeshToMeshParams params = {0};
- mesh_src = BKE_bmesh_to_mesh(em->bm, &params);
+ mesh_src = BKE_bmesh_to_mesh(em->bm, &(struct BMeshToMeshParams){0});
}
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
@@ -153,8 +152,7 @@ static void deformVertsEM(
}
if (!mesh) {
- BKE_mesh_free(mesh_src);
- MEM_freeN(mesh_src);
+ BKE_id_free(NULL, mesh_src);
}
}
@@ -167,16 +165,14 @@ static void deformMatricesEM(
Mesh *mesh_src = mesh;
if (!mesh) {
- struct BMeshToMeshParams params = {0};
- mesh_src = BKE_bmesh_to_mesh(em->bm, &params);
+ mesh_src = BKE_bmesh_to_mesh(em->bm, &(struct BMeshToMeshParams){0});
}
armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts,
amd->deformflag, NULL, amd->defgrp_name);
if (!mesh) {
- BKE_mesh_free(mesh_src);
- MEM_freeN(mesh_src);
+ BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 6dcb29abd63..01414a3dfad 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -372,7 +372,7 @@ static Mesh *arrayModifier_doArray(
int tot_doubles;
const bool use_merge = (amd->flags & MOD_ARR_MERGE) != 0;
- const bool use_recalc_normals = /* (dm->dirty & DM_DIRTY_NORMALS) || */ use_merge;
+ const bool use_recalc_normals = (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || use_merge;
const bool use_offset_ob = ((amd->offset_type & MOD_ARR_OFF_OBJ) && amd->offset_ob);
int start_cap_nverts = 0, start_cap_nedges = 0, start_cap_npolys = 0, start_cap_nloops = 0;
@@ -733,8 +733,11 @@ static Mesh *arrayModifier_doArray(
MEM_freeN(full_doubles_map);
}
+ /* In case org dm has dirty normals, or we made some merging, mark normals as dirty in new mesh!
+ * TODO: we may need to set other dirty flags as well?
+ */
if (use_recalc_normals) {
- BKE_mesh_calc_normals(result);
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
}
if (vgroup_start_cap_remap) {
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 325b70ddc5e..9e5913af6c9 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -106,14 +106,15 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const int mat = CLAMPIS(bmd->mat, -1, ctx->object->totcol - 1);
const bool loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0;
- const struct BMeshCreateParams bmcp = {0};
- const struct BMeshFromMeshParams bmfmp = {
- .calc_face_normal = true,
- .add_key_index = false,
- .use_shapekey = true,
- .active_shapekey = ctx->object->shapenr,
- };
- bm = BKE_mesh_to_bmesh_ex(mesh, &bmcp, &bmfmp);
+ bm = BKE_mesh_to_bmesh_ex(
+ mesh,
+ &(struct BMeshCreateParams){0},
+ &(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ .add_key_index = false,
+ .use_shapekey = true,
+ .active_shapekey = ctx->object->shapenr,
+ });
if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0])
modifier_get_vgroup_mesh(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup);
@@ -176,14 +177,15 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp,
dvert, vgroup, mat, loop_slide);
- struct BMeshToMeshParams bmmp = {0};
- result = BKE_bmesh_to_mesh(bm, &bmmp);
+ result = BKE_bmesh_to_mesh(bm, &(struct BMeshToMeshParams){0});
BLI_assert(bm->vtoolflagpool == NULL &&
bm->etoolflagpool == NULL &&
bm->ftoolflagpool == NULL); /* make sure we never alloc'd these */
BM_mesh_free(bm);
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index aebf63c3100..048e9ce33c0 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -297,6 +297,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
MEM_freeN(edgeMap);
MEM_freeN(faceMap);
+ if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) {
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+ }
+
/* TODO(sybren): also copy flags & tags? */
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 9688b80113b..87933558d86 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -41,6 +41,7 @@
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
+#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
@@ -123,15 +124,13 @@ static void deformVertsEM(
struct Mesh *mesh_src = mesh;
if (!mesh) {
- struct BMeshToMeshParams params = {0};
- mesh_src = BKE_bmesh_to_mesh(em->bm, &params);
+ mesh_src = BKE_bmesh_to_mesh(em->bm, &(struct BMeshToMeshParams){0});
}
deformVerts(md, ctx, mesh_src, vertexCos, numVerts);
if (!mesh) {
- BKE_mesh_free(mesh_src);
- MEM_freeN(mesh_src);
+ BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 5c5b8e4f11d..4edfbd43d7a 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -39,6 +39,7 @@
#include "BLI_math.h"
+#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
@@ -313,8 +314,7 @@ static Mesh *mirrorModifier__doMirror(MirrorModifierData *mmd,
result = doMirrorOnAxis(mmd, ob, result, 1);
if (tmp != mesh) {
/* free intermediate results */
- BKE_mesh_free(tmp);
- MEM_freeN(tmp);
+ BKE_id_free(NULL, tmp);
}
}
if (mmd->flag & MOD_MIR_AXIS_Z) {
@@ -322,8 +322,7 @@ static Mesh *mirrorModifier__doMirror(MirrorModifierData *mmd,
result = doMirrorOnAxis(mmd, ob, result, 2);
if (tmp != mesh) {
/* free intermediate results */
- BKE_mesh_free(tmp);
- MEM_freeN(tmp);
+ BKE_id_free(NULL, tmp);
}
}
@@ -337,8 +336,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
MirrorModifierData *mmd = (MirrorModifierData *) md;
result = mirrorModifier__doMirror(mmd, ctx->object, mesh);
- BKE_mesh_calc_normals(result);
+ if (result != mesh) {
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+ }
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 56f6fa57b51..b93e567fe56 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -213,8 +213,8 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
MPoly *mpoly, *orig_mpoly;
MLoop *mloop, *orig_mloop;
MVert *mvert, *orig_mvert;
- int totvert, totpoly, totloop /* , totedge */;
- int maxvert, maxpoly, maxloop, part_end = 0, part_start;
+ int totvert, totpoly, totloop , totedge;
+ int maxvert, maxpoly, maxloop, maxedge, part_end = 0, part_start;
int k, p, p_skip;
short track = ctx->object->trackflag % 3, trackneg, axis = pimd->axis;
float max_co = 0.0, min_co = 0.0, temp_co[3];
@@ -294,12 +294,13 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
totvert = dm->getNumVerts(dm);
totpoly = dm->getNumPolys(dm);
totloop = dm->getNumLoops(dm);
- /* totedge = dm->getNumEdges(dm); */ /* UNUSED */
+ totedge = dm->getNumEdges(dm);
/* count particles */
maxvert = 0;
maxpoly = 0;
maxloop = 0;
+ maxedge = 0;
for (p = part_start; p < part_end; p++) {
if (particle_skip(pimd, psys, p))
@@ -308,6 +309,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
maxvert += totvert;
maxpoly += totpoly;
maxloop += totloop;
+ maxedge += totedge;
}
psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
@@ -320,11 +322,10 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
max_co = max[track];
}
- result = CDDM_from_template(dm, maxvert, 0, 0, maxloop, maxpoly);
+ result = CDDM_from_template(dm, maxvert, maxedge, 0, maxloop, maxpoly);
mvert = result->getVertArray(result);
orig_mvert = dm->getVertArray(dm);
-
mpoly = result->getPolyArray(result);
orig_mpoly = dm->getPolyArray(dm);
mloop = result->getLoopArray(result);
@@ -471,8 +472,17 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
mul_m4_v3(spacemat, mv->co);
}
+ /* create edges and adjust edge vertex indices*/
+ DM_copy_edge_data(dm, result, 0, p_skip * totedge, totedge);
+ MEdge *me = CDDM_get_edges(result) + p_skip * totedge;
+ for (k = 0; k < totedge; k++, me++) {
+ me->v1 += p_skip * totvert;
+ me->v2 += p_skip * totvert;
+ }
+
/* create polys and loops */
for (k = 0; k < totpoly; k++) {
+
MPoly *inMP = orig_mpoly + k;
MPoly *mp = mpoly + p_skip * totpoly + k;
@@ -488,6 +498,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
DM_copy_loop_data(dm, result, inMP->loopstart, mp->loopstart, j);
for (; j; j--, ml++, inML++) {
ml->v = inML->v + (p_skip * totvert);
+ ml->e = inML->e + (p_skip * totedge);
const int ml_index = (ml - mloop);
if (mloopcols_index != NULL) {
const int part_index = vert_part_index[ml->v];
@@ -500,12 +511,9 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
}
}
}
-
p_skip++;
}
- CDDM_calc_edges(result);
-
if (psys->lattice_deform_data) {
end_latt_deform(psys->lattice_deform_data);
psys->lattice_deform_data = NULL;
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index b99d73c316d..defb661d9d8 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -72,6 +72,7 @@
#include "BLI_bitmap.h"
#include "BKE_deform.h"
+#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
@@ -1864,8 +1865,7 @@ static Mesh *base_skin(Mesh *origmesh,
if (!bm)
return NULL;
- struct BMeshToMeshParams bmtmp = {0};
- result = BKE_bmesh_to_mesh(bm, &bmtmp);
+ result = BKE_bmesh_to_mesh(bm, &(struct BMeshToMeshParams){0});
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
@@ -1886,9 +1886,7 @@ static Mesh *final_skin(SkinModifierData *smd, Mesh *mesh)
mesh = subdivide_base(mesh);
result = base_skin(mesh, smd);
- BKE_mesh_free(mesh);
- MEM_freeN(mesh);
-
+ BKE_id_free(NULL, mesh);
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 43fceaae22a..e37bcccacfd 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -105,7 +105,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_ver
EdgeFaceRef *edge_ref;
float edge_normal[3];
- /* This loop adds an edge hash if its not there, and adds the face index */
+ /* Add an edge reference if it's not there, pointing back to the face index. */
for (i = 0; i < numFaces; i++, mp++) {
int j;
@@ -138,12 +138,12 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_ver
if (edgeref_is_init(edge_ref) && (edge_ref->f1 != -1)) {
if (edge_ref->f2 != -1) {
/* We have 2 faces using this edge, calculate the edges normal
- * using the angle between the 2 faces as a weighting */
+ * using the angle between the 2 faces as a weighting */
#if 0
add_v3_v3v3(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
normalize_v3_length(
- edge_normal,
- angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
+ edge_normal,
+ angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
#else
mid_v3_v3v3_angle_weighted(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
#endif
@@ -901,15 +901,16 @@ static Mesh *applyModifier(
#ifdef SOLIDIFY_SIDE_NORMALS
if (do_side_normals) {
+ const MEdge *ed_orig = medge;
ed = medge + (numEdges * stride);
- for (i = 0; i < rimVerts; i++, ed++) {
+ for (i = 0; i < rimVerts; i++, ed++, ed_orig++) {
float nor_cpy[3];
short *nor_short;
int k;
/* note, only the first vertex (lower half of the index) is calculated */
BLI_assert(ed->v1 < numVerts);
- normalize_v3_v3(nor_cpy, edge_vert_nos[ed->v1]);
+ normalize_v3_v3(nor_cpy, edge_vert_nos[ed_orig->v1]);
for (k = 0; k < 2; k++) { /* loop over both verts of the edge */
nor_short = mvert[*(&ed->v1 + k)].no;
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index 2bcab0a4a3d..752b81a5f10 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -158,9 +158,9 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh");
if (surmd->dm->getNumPolys(surmd->dm))
- bvhtree_from_mesh_get(surmd->bvhtree, surmd->dm, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(surmd->bvhtree, surmd->dm, BVHTREE_FROM_LOOPTRI, 2);
else
- bvhtree_from_mesh_get(surmd->bvhtree, surmd->dm, BVHTREE_FROM_EDGES);
+ bvhtree_from_mesh_get(surmd->bvhtree, surmd->dm, BVHTREE_FROM_EDGES, 2);
}
}
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index e4b40fb7e2a..bedce88326e 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -949,7 +949,7 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd, float (*vertexCos)
return false;
}
- bvhtree_from_mesh_get(&treeData, tdm, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treeData, tdm, BVHTREE_FROM_LOOPTRI, 2);
if (treeData.tree == NULL) {
modifier_setError((ModifierData *)smd, "Out of memory");
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 735c8fe4d16..b0416ed9f7a 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -148,7 +148,7 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3],
if (dist_v) {
/* Create a bvh-tree of the given target's verts. */
- bvhtree_from_mesh_get(&treeData_v, target, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treeData_v, target, BVHTREE_FROM_VERTS, 2);
if (treeData_v.tree == NULL) {
OUT_OF_MEMORY();
return;
@@ -156,7 +156,7 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3],
}
if (dist_e) {
/* Create a bvh-tree of the given target's edges. */
- bvhtree_from_mesh_get(&treeData_e, target, BVHTREE_FROM_EDGES);
+ bvhtree_from_mesh_get(&treeData_e, target, BVHTREE_FROM_EDGES, 2);
if (treeData_e.tree == NULL) {
OUT_OF_MEMORY();
return;
@@ -164,7 +164,7 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3],
}
if (dist_f) {
/* Create a bvh-tree of the given target's faces. */
- bvhtree_from_mesh_get(&treeData_f, target, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treeData_f, target, BVHTREE_FROM_LOOPTRI, 2);
if (treeData_f.tree == NULL) {
OUT_OF_MEMORY();
return;
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index f50b1446dc2..3c6717d3b36 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -23,12 +23,14 @@
* \ingroup modifiers
*/
+#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
+#include "BKE_mesh.h"
#include "MOD_modifiertypes.h"
@@ -69,14 +71,22 @@ static bool dependsOnNormals(ModifierData *UNUSED(md))
return true;
}
-static DerivedMesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, DerivedMesh *dm)
+static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh *mesh)
{
- DerivedMesh *result;
+ Mesh *result;
BMesh *bm;
const int defgrp_index = defgroup_name_index(ob, wmd->defgrp_name);
- bm = DM_to_bmesh(dm, true);
+ bm = BKE_mesh_to_bmesh_ex(
+ mesh,
+ &(struct BMeshCreateParams){0},
+ &(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ .add_key_index = false,
+ .use_shapekey = true,
+ .active_shapekey = ob->shapenr,
+ });
BM_mesh_wireframe(
bm,
@@ -93,19 +103,21 @@ static DerivedMesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob,
MAX2(ob->totcol - 1, 0),
false);
- result = CDDM_from_bmesh(bm, true);
+ result = BKE_bmesh_to_mesh(bm, &(struct BMeshToMeshParams){0});
BM_mesh_free(bm);
- result->dirty |= DM_DIRTY_NORMALS;
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
return result;
}
-static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *dm)
+static Mesh *applyModifier(
+ ModifierData *md,
+ const struct ModifierEvalContext *ctx,
+ struct Mesh *mesh)
{
- return WireframeModifier_do((WireframeModifierData *)md, ctx->object, dm);
+ return WireframeModifier_do((WireframeModifierData *)md, ctx->object, mesh);
}
@@ -123,14 +135,14 @@ ModifierTypeInfo modifierType_Wireframe = {
/* deformMatrices_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ applyModifier,
+ /* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
+ /* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c
index b5a480c05b5..03d295c8ca1 100644
--- a/source/blender/python/bmesh/bmesh_py_types_select.c
+++ b/source/blender/python/bmesh/bmesh_py_types_select.c
@@ -245,14 +245,13 @@ static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self, Py_ssi
}
/* add items until stop */
- while ((ese = ese->next)) {
+ do {
PyList_APPEND(list, BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head));
-
count++;
if (count == stop) {
break;
}
- }
+ } while ((ese = ese->next));
return list;
}
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 1153e0176df..164fe656129 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -30,6 +30,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "idprop_py_api.h"
@@ -1804,39 +1805,48 @@ PyObject *BPyInit_idprop(void)
return mod;
}
-
-#ifndef NDEBUG
/* -------------------------------------------------------------------- */
/* debug only function */
-void IDP_spit(IDProperty *prop)
+char *IDP_reprN(const IDProperty *prop)
{
- if (prop) {
- PyGILState_STATE gilstate;
- bool use_gil = true; /* !PyC_IsInterpreterActive(); */
- PyObject *ret_dict;
- PyObject *ret_str;
+ if (prop == NULL) {
+ return BLI_strdup("None");
+ }
- if (use_gil) {
- gilstate = PyGILState_Ensure();
- }
+ PyGILState_STATE gilstate;
+ bool use_gil = true; /* !PyC_IsInterpreterActive(); */
+ PyObject *ret_dict;
+ PyObject *ret_str;
- /* to_dict() */
- ret_dict = BPy_IDGroup_MapDataToPy(prop);
- ret_str = PyObject_Repr(ret_dict);
- Py_DECREF(ret_dict);
+ if (use_gil) {
+ gilstate = PyGILState_Ensure();
+ }
- printf("IDProperty(%p): %s\n", prop, _PyUnicode_AsString(ret_str));
+ /* Note: non-const cast is safe here since we only repr the result. */
+ /* to_dict() */
+ ret_dict = BPy_IDGroup_MapDataToPy((IDProperty *)prop);
+ ret_str = PyObject_Repr(ret_dict);
+ Py_DECREF(ret_dict);
- Py_DECREF(ret_str);
+ Py_ssize_t res_str_len = 0;
+ char *res_str_bytes = _PyUnicode_AsStringAndSize(ret_str, &res_str_len);
- if (use_gil) {
- PyGILState_Release(gilstate);
- }
- }
- else {
- printf("IDProperty: <NIL>\n");
+ res_str_bytes = BLI_strdupn(res_str_bytes, res_str_len);
+
+ Py_DECREF(ret_str);
+
+ if (use_gil) {
+ PyGILState_Release(gilstate);
}
+ return res_str_bytes;
+}
+
+
+void IDP_print(const IDProperty *prop)
+{
+ char *repr = IDP_reprN(prop);
+ printf("IDProperty(%p): %s\n", prop, repr);
+ MEM_freeN(repr);
}
-#endif
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c
index 4405d38ae86..57846bc7443 100644
--- a/source/blender/render/intern/source/bake_api.c
+++ b/source/blender/render/intern/source/bake_api.c
@@ -548,7 +548,7 @@ bool RE_bake_pixels_populate_from_objects(
if (dm_highpoly[i]->getNumTessFaces(dm_highpoly[i]) != 0) {
/* Create a bvh-tree for each highpoly object */
- bvhtree_from_mesh_get(&treeData[i], dm_highpoly[i], BVHTREE_FROM_FACES);
+ bvhtree_from_mesh_get(&treeData[i], dm_highpoly[i], BVHTREE_FROM_FACES, 2);
if (treeData[i].tree == NULL) {
printf("Baking: out of memory while creating BHVTree for object \"%s\"\n", highpoly[i].ob->id.name + 2);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index afceb8bd700..df356bee295 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1234,96 +1234,99 @@ bool RE_allow_render_generic_object(Object *ob)
#define DEPSGRAPH_WORKAROUND_HACK
#ifdef DEPSGRAPH_WORKAROUND_HACK
-static void tag_dependend_objects_for_render(Scene *scene, int UNUSED(renderlay))
+static void tag_dependend_object_for_render(Scene *scene, Object *object);
+
+static void tag_dependend_group_for_render(Scene *scene, Group *group)
{
- FOREACH_OBJECT_RENDERABLE_BEGIN(scene, object)
- {
- if (object->type == OB_MESH) {
- if (RE_allow_render_generic_object(object)) {
- ModifierData *md;
- VirtualModifierData virtualModifierData;
-
- for (md = modifiers_getVirtualModifierList(object, &virtualModifierData);
- md;
- md = md->next)
- {
- if (!modifier_isEnabled(scene, md, eModifierMode_Render)) {
- continue;
- }
+ if (group->id.tag & LIB_TAG_DOIT) {
+ return;
+ }
+ group->id.tag |= LIB_TAG_DOIT;
- if (md->type == eModifierType_Boolean) {
- BooleanModifierData *bmd = (BooleanModifierData *)md;
- if (bmd->object && bmd->object->type == OB_MESH) {
- DEG_id_tag_update(&bmd->object->id, OB_RECALC_DATA);
- }
+ for (GroupObject *go = group->gobject.first; go != NULL; go = go->next) {
+ Object *object = go->ob;
+ tag_dependend_object_for_render(scene, object);
+ }
+}
+
+static void tag_dependend_object_for_render(Scene *scene, Object *object)
+{
+ if (object->type == OB_MESH) {
+ if (RE_allow_render_generic_object(object)) {
+ ModifierData *md;
+ VirtualModifierData virtualModifierData;
+
+ if (object->particlesystem.first) {
+ DEG_id_tag_update(&object->id, OB_RECALC_DATA);
+ }
+
+ for (md = modifiers_getVirtualModifierList(object, &virtualModifierData);
+ md;
+ md = md->next)
+ {
+ if (!modifier_isEnabled(scene, md, eModifierMode_Render)) {
+ continue;
+ }
+
+ if (md->type == eModifierType_Boolean) {
+ BooleanModifierData *bmd = (BooleanModifierData *)md;
+ if (bmd->object && bmd->object->type == OB_MESH) {
+ DEG_id_tag_update(&bmd->object->id, OB_RECALC_DATA);
}
- else if (md->type == eModifierType_Array) {
- ArrayModifierData *amd = (ArrayModifierData *)md;
- if (amd->start_cap && amd->start_cap->type == OB_MESH) {
- DEG_id_tag_update(&amd->start_cap->id, OB_RECALC_DATA);
- }
- if (amd->end_cap && amd->end_cap->type == OB_MESH) {
- DEG_id_tag_update(&amd->end_cap->id, OB_RECALC_DATA);
- }
+ }
+ else if (md->type == eModifierType_Array) {
+ ArrayModifierData *amd = (ArrayModifierData *)md;
+ if (amd->start_cap && amd->start_cap->type == OB_MESH) {
+ DEG_id_tag_update(&amd->start_cap->id, OB_RECALC_DATA);
}
- else if (md->type == eModifierType_Shrinkwrap) {
- ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
- if (smd->target && smd->target->type == OB_MESH) {
- DEG_id_tag_update(&smd->target->id, OB_RECALC_DATA);
- }
+ if (amd->end_cap && amd->end_cap->type == OB_MESH) {
+ DEG_id_tag_update(&amd->end_cap->id, OB_RECALC_DATA);
}
- else if (md->type == eModifierType_ParticleSystem) {
- ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
- ParticleSystem *psys = psmd->psys;
- ParticleSettings *part = psys->part;
- switch (part->ren_as) {
- case PART_DRAW_OB:
- if (part->dup_ob != NULL) {
- DEG_id_tag_update(&part->dup_ob->id, OB_RECALC_DATA);
- }
- break;
- case PART_DRAW_GR:
- if (part->dup_group != NULL) {
- for (GroupObject *go = part->dup_group->gobject.first;
- go != NULL;
- go = go->next)
- {
- DEG_id_tag_update(&go->ob->id, OB_RECALC_DATA);
- }
+ }
+ else if (md->type == eModifierType_Shrinkwrap) {
+ ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
+ if (smd->target && smd->target->type == OB_MESH) {
+ DEG_id_tag_update(&smd->target->id, OB_RECALC_DATA);
+ }
+ }
+ else if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
+ ParticleSystem *psys = psmd->psys;
+ ParticleSettings *part = psys->part;
+ switch (part->ren_as) {
+ case PART_DRAW_OB:
+ if (part->dup_ob != NULL) {
+ DEG_id_tag_update(&part->dup_ob->id, OB_RECALC_DATA);
+ }
+ break;
+ case PART_DRAW_GR:
+ if (part->dup_group != NULL) {
+ for (GroupObject *go = part->dup_group->gobject.first;
+ go != NULL;
+ go = go->next)
+ {
+ DEG_id_tag_update(&go->ob->id, OB_RECALC_DATA);
}
- break;
- }
+ }
+ break;
}
}
}
}
}
- FOREACH_OBJECT_RENDERABLE_END;
+ if (object->dup_group != NULL) {
+ tag_dependend_group_for_render(scene, object->dup_group);
+ }
}
-#endif
-
-#define DEPSGRAPH_WORKAROUND_GROUP_HACK
-#ifdef DEPSGRAPH_WORKAROUND_GROUP_HACK
-/**
- * Make sure the COLLECTION_VIEWPORT / COLLECTION_RENDER is considered
- * for the collections visibility.
- *
- * This won't be needed anymore once we have depsgraph per render engine.
- */
-static void tag_groups_for_render(Render *re)
+static void tag_dependend_objects_for_render(Main *bmain, Scene *scene)
{
- for (Group *group = re->main->group.first; group; group = group->id.next) {
- DEG_id_tag_update(&group->id, 0);
- }
-
-#ifdef WITH_FREESTYLE
- if (re->freestyle_bmain) {
- for (Group *group = re->freestyle_bmain->group.first; group; group = group->id.next) {
- DEG_id_tag_update(&group->id, 0);
- }
+ BKE_main_id_tag_idcode(bmain, ID_GR, LIB_TAG_DOIT, false);
+ FOREACH_OBJECT_RENDERABLE_BEGIN(scene, object)
+ {
+ tag_dependend_object_for_render(scene, object);
}
-#endif
+ FOREACH_OBJECT_RENDERABLE_END;
}
#endif
@@ -1331,14 +1334,11 @@ static void tag_scenes_for_render(Render *re)
{
bNode *node;
Scene *sce;
-#ifdef DEPSGRAPH_WORKAROUND_HACK
- int renderlay = re->lay;
-#endif
for (sce = re->main->scene.first; sce; sce = sce->id.next) {
sce->id.tag &= ~LIB_TAG_DOIT;
#ifdef DEPSGRAPH_WORKAROUND_HACK
- tag_dependend_objects_for_render(sce, renderlay);
+ tag_dependend_objects_for_render(re->main, sce);
#endif
}
@@ -1347,7 +1347,7 @@ static void tag_scenes_for_render(Render *re)
for (sce = re->freestyle_bmain->scene.first; sce; sce = sce->id.next) {
sce->id.tag &= ~LIB_TAG_DOIT;
#ifdef DEPSGRAPH_WORKAROUND_HACK
- tag_dependend_objects_for_render(sce, renderlay);
+ tag_dependend_objects_for_render(re->freestyle_bmain, sce);
#endif
}
}
@@ -1356,7 +1356,7 @@ static void tag_scenes_for_render(Render *re)
if (RE_GetCamera(re) && composite_needs_render(re->scene, 1)) {
re->scene->id.tag |= LIB_TAG_DOIT;
#ifdef DEPSGRAPH_WORKAROUND_HACK
- tag_dependend_objects_for_render(re->scene, renderlay);
+ tag_dependend_objects_for_render(re->main, re->scene);
#endif
}
@@ -1389,7 +1389,7 @@ static void tag_scenes_for_render(Render *re)
node->flag |= NODE_TEST;
node->id->tag |= LIB_TAG_DOIT;
#ifdef DEPSGRAPH_WORKAROUND_HACK
- tag_dependend_objects_for_render(scene, renderlay);
+ tag_dependend_objects_for_render(re->main, scene);
#endif
}
}
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 997701922a3..27b9710cb45 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -1134,9 +1134,9 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
if (kmi->ptr) {
if (STREQ("MESH_OT_rip_move", opname)) {
printf("OPERATOR\n");
- IDP_spit(properties);
+ IDP_print(properties);
printf("KEYMAP\n");
- IDP_spit(kmi->ptr->data);
+ IDP_print(kmi->ptr->data);
}
}
#endif
@@ -1167,9 +1167,9 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
#ifndef NDEBUG
#ifdef WITH_PYTHON
printf("OPERATOR\n");
- IDP_spit(properties);
+ IDP_print(properties);
printf("KEYMAP\n");
- IDP_spit(kmi->ptr->data);
+ IDP_print(kmi->ptr->data);
#endif
#endif
printf("\n");
@@ -1316,9 +1316,9 @@ static wmKeyMapItem *wm_keymap_item_find(
#ifndef NDEBUG
#ifdef WITH_PYTHON
printf("OPERATOR\n");
- IDP_spit(properties);
+ IDP_print(properties);
printf("KEYMAP\n");
- IDP_spit(kmi->ptr->data);
+ IDP_print(kmi->ptr->data);
#endif
#endif
printf("\n");
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 60f0ae9c543..5d49c954522 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -710,8 +710,11 @@ static int arg_handle_log_level_set(int argc, const char **argv, void *UNUSED(da
if (!parse_int_clamp(argv[1], NULL, -1, INT_MAX, &G.log.level, &err_msg)) {
printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
}
- if (G.log.level == -1) {
- G.log.level = INT_MAX;
+ else {
+ if (G.log.level == -1) {
+ G.log.level = INT_MAX;
+ }
+ CLG_level_set(G.log.level);
}
return 1;
}