[Bf-blender-cvs] [133dde41bb5] master: Improve handling of (in)direclty linked status for linked IDs.
Commit: 133dde41bb5d083b12723f1ec9053764348a Author: Bastien Montagne Date: Wed Nov 30 11:13:37 2022 +0100 Branches: master https://developer.blender.org/rB133dde41bb5d083b12723f1ec9053764348a Improve handling of (in)direclty linked status for linked IDs. This commit essentially ensures before writing .blend file that only actualy locally used linked IDs are tagged as `LIB_TAG_EXTERN` (and therefore get a reference stored in the .blend file). Previously, a linked ID tagged as directly linked would never get back to the indirectly linked status. Consequence was a lot of 'needless' references to linked data in .blend files. This commit also introduces a new flag for lib_query ID usage types, `IDWALK_CB_DIRECT_WEAK_LINK`, used currently for base's Object pointer, and for LayerCollection's Collection pointer. NOTE: A side-effect of this patch is that even IDs explicitely linked by the user won't be kept anymore when writing files, i.e. they will not be there anymore after a file reload, if they are not actually used. Overhead of new process is below 0.1% in whole file saving process in a Heist production file e.g. Reviewed By: brecht Differential Revision: https://developer.blender.org/D16605 === M source/blender/blenkernel/BKE_lib_query.h M source/blender/blenkernel/intern/scene.cc M source/blender/blenloader/intern/writefile.cc M tests/python/bl_blendfile_liblink.py === diff --git a/source/blender/blenkernel/BKE_lib_query.h b/source/blender/blenkernel/BKE_lib_query.h index a70d128cd95..69e8f58178a 100644 --- a/source/blender/blenkernel/BKE_lib_query.h +++ b/source/blender/blenkernel/BKE_lib_query.h @@ -38,44 +38,53 @@ enum { * Indicates whether this is direct (i.e. by local data) or indirect (i.e. by linked data) usage. */ IDWALK_CB_INDIRECT_USAGE = (1 << 2), + /** + * Indicates that this is a direct weak link usage, i.e. if the user is a local ID, and is using + * (pointing to) a linked ID, that usage does not make the linked ID directly linked. + * + * E.g. usages of linked collections or objects by ViewLayerCollections or Bases in scenes. + * + * See also #LIB_INDIRECT_WEAK_LINK in DNA_ID.h + */ + IDWALK_CB_DIRECT_WEAK_LINK = (1 << 3), /** * That ID is used as mere sub-data by its owner (only case currently: those root nodetrees in * materials etc., and the Scene's master collections). * This means callback shall not *do* anything, only use this as informative data if it needs it. */ - IDWALK_CB_EMBEDDED = (1 << 3), + IDWALK_CB_EMBEDDED = (1 << 4), /** * That ID is not really used by its owner, it's just an internal hint/helper. * This marks the 'from' pointers issue, like Key->from. * How to handle that kind of cases totally depends on what caller code is doing... */ - IDWALK_CB_LOOPBACK = (1 << 4), + IDWALK_CB_LOOPBACK = (1 << 5), /** That ID is used as library override's reference by its owner. */ - IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE = (1 << 5), + IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE = (1 << 6), /** That ID pointer is not overridable. */ - IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE = (1 << 6), + IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE = (1 << 7), /** * Indicates that this is an internal runtime ID pointer, like e.g. `ID.newid` or `ID.original`. * \note Those should be ignored in most cases, and won't be processed/generated anyway unless * `IDWALK_DO_INTERNAL_RUNTIME_POINTERS` option is enabled. */ - IDWALK_CB_INTERNAL = (1 << 7), + IDWALK_CB_INTERNAL = (1 << 8), /** * This ID usage is fully refcounted. * Callback is responsible to deal accordingly with #ID.us if needed. */ - IDWALK_CB_USER = (1 << 8), + IDWALK_CB_USER = (1 << 9), /** * This ID usage is not refcounted, but at least one user should be generated by it (to avoid * e.g. losing the used ID on save/reload). * Callback is responsible to deal accordingly with #ID.us if needed. */ - IDWALK_CB_USER_ONE = (1 << 9), + IDWALK_CB_USER_ONE = (1 << 10), }; enum { diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index c921cf603de..830122474e1 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -761,7 +761,8 @@ static void scene_foreach_layer_collection(LibraryForeachIDData *data, ListBase (lc->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ? IDWALK_CB_EMBEDDED : IDWALK_CB_NOP; -BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, lc->collection, cb_flag); +BKE_LIB_FOREACHID_PROCESS_IDSUPER( +data, lc->collection, cb_flag | IDWALK_CB_DIRECT_WEAK_LINK); scene_foreach_layer_collection(data, &lc->layer_collections); } } @@ -
[Bf-blender-cvs] [249acdf5291] master: Cleanup: Unused variable warning in release build
Commit: 249acdf52912d5718df8fa6f0bc4d2236a7ded68 Author: Sergey Sharybin Date: Wed Nov 30 12:49:33 2022 +0100 Branches: master https://developer.blender.org/rB249acdf52912d5718df8fa6f0bc4d2236a7ded68 Cleanup: Unused variable warning in release build === M source/blender/blenloader/intern/writefile.cc === diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index 3a776a6c7ba..38d0970b4ed 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -1097,6 +1097,7 @@ static int write_id_direct_linked_data_process_cb(LibraryIDLinkCallbackData *cb_ } BLI_assert(!ID_IS_LINKED(id_self)); BLI_assert((cb_flag & IDWALK_CB_INDIRECT_USAGE) == 0); + UNUSED_VARS_NDEBUG(id_self); if (cb_flag & IDWALK_CB_DIRECT_WEAK_LINK) { id_lib_indirect_weak_link(id); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [45bb862493c] soc-2022-many-lights-sampling: Cleanup: renaming function
Commit: 45bb862493c9a6d6e9219637dc1eb85e3a2351b1 Author: Weizhen Huang Date: Wed Nov 30 13:00:26 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB45bb862493c9a6d6e9219637dc1eb85e3a2351b1 Cleanup: renaming function === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index cf8b14b8027..e02fd033726 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -67,17 +67,17 @@ ccl_device float3 compute_v( /* This is the general function for calculating the importance of either a cluster or an emitter. * Both of the specialized functions obtain the necessary data before calling this function. */ template -ccl_device void light_tree_cluster_importance(const float3 N_or_D, - const bool has_transmission, - const float3 point_to_centroid, - const float cos_theta_u, - const BoundingCone bcone, - const float max_distance, - const float min_distance, - const float t, - const float energy, - ccl_private float &max_importance, - ccl_private float &min_importance) +ccl_device void light_tree_importance(const float3 N_or_D, + const bool has_transmission, + const float3 point_to_centroid, + const float cos_theta_u, + const BoundingCone bcone, + const float max_distance, + const float min_distance, + const float t, + const float energy, + ccl_private float &max_importance, + ccl_private float &min_importance) { max_importance = 0.0f; min_importance = 0.0f; @@ -309,17 +309,17 @@ ccl_device void light_tree_emitter_importance(KernelGlobals kg, return; } - light_tree_cluster_importance(N_or_D, - has_transmission, - point_to_centroid, - cos_theta_u, - bcone, - distance.x, - distance.y, - t, - kemitter->energy, - max_importance, - min_importance); + light_tree_importance(N_or_D, + has_transmission, + point_to_centroid, + cos_theta_u, + bcone, + distance.x, + distance.y, + t, + kemitter->energy, + max_importance, + min_importance); } template @@ -387,17 +387,17 @@ ccl_device void light_tree_node_importance(KernelGlobals kg, } /* TODO: currently max_distance = min_distance, max_importance = min_importance for the * nodes. Do we need better weights for complex scenes? */ -light_tree_cluster_importance(N_or_D, - has_transmission, - point_to_centroid, - cos_theta_u, - bcone, - distance, - distance, - t, - knode->energy, - max_importance, - min_importance); +light_tree_importance(N_or_D, + has_transmission, +
[Bf-blender-cvs] [e1289a5f33e] soc-2022-many-lights-sampling: Cleanup: use existing functions when possible
Commit: e1289a5f33e5939065d278340bc74b58eabe9c81 Author: Weizhen Huang Date: Tue Nov 29 23:35:14 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBe1289a5f33e5939065d278340bc74b58eabe9c81 Cleanup: use existing functions when possible === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index 7f78d96f3f6..cf8b14b8027 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -37,7 +37,7 @@ ccl_device float light_tree_cos_bounding_box_angle(const BoundingBox bbox, return cos_theta_u; } -ccl_device_inline float sin_from_cos(const float c) +ccl_device_forceinline float sin_from_cos(const float c) { return safe_sqrtf(1.0f - sqr(c)); } @@ -82,7 +82,7 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D, max_importance = 0.0f; min_importance = 0.0f; - const float sin_theta_u = safe_sqrtf(1.0f - sqr(cos_theta_u)); + const float sin_theta_u = sin_from_cos(cos_theta_u); float cos_theta, cos_theta_i, sin_theta_i; /* cos(theta_i') in the paper, omitted for volume */ float cos_min_incidence_angle = 1.0f; @@ -95,7 +95,7 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D, if (!in_volume_segment && !in_volume) { const float3 N = N_or_D; cos_theta_i = has_transmission ? fabsf(dot(point_to_centroid, N)) : dot(point_to_centroid, N); -sin_theta_i = safe_sqrtf(1.0f - sqr(cos_theta_i)); +sin_theta_i = sin_from_cos(cos_theta_i); /* cos_min_incidence_angle = cos(max{theta_i - theta_u, 0}) = cos(theta_i') in the paper */ cos_min_incidence_angle = cos_theta_i >= cos_theta_u ? @@ -118,7 +118,7 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D, * cos(theta') in the paper */ float cos_min_outgoing_angle; /* cos(theta - theta_u) */ - const float sin_theta = safe_sqrtf(1.0f - sqr(cos_theta)); + const float sin_theta = sin_from_cos(cos_theta); const float cos_theta_minus_theta_u = cos_theta * cos_theta_u + sin_theta * sin_theta_u; float cos_theta_o, sin_theta_o; @@ -134,7 +134,7 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D, /* theta' = theta - theta_o - theta_u < theta_e */ kernel_assert( (fast_acosf(cos_theta) - bcone.theta_o - fast_acosf(cos_theta_u) - bcone.theta_e) < 5e-4f); -const float sin_theta_minus_theta_u = safe_sqrtf(1.0f - sqr(cos_theta_minus_theta_u)); +const float sin_theta_minus_theta_u = sin_from_cos(cos_theta_minus_theta_u); cos_min_outgoing_angle = cos_theta_minus_theta_u * cos_theta_o + sin_theta_minus_theta_u * sin_theta_o; } @@ -163,7 +163,7 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D, min_importance = 0.0f; } else { -const float sin_theta_plus_theta_u = safe_sqrtf(1.0f - sqr(cos_theta_plus_theta_u)); +const float sin_theta_plus_theta_u = sin_from_cos(cos_theta_plus_theta_u); cos_max_outgoing_angle = cos_theta_plus_theta_u * cos_theta_o - sin_theta_plus_theta_u * sin_theta_o; min_importance = fabsf(f_a * cos_max_incidence_angle * energy * cos_max_outgoing_angle / @@ -580,26 +580,17 @@ ccl_device bool light_tree_sample(KernelGlobals kg, const int left_index = node_index + 1; const int right_index = knode->child_index; -float left_probability; +float left_prob; if (!get_left_probability( -kg, P, N_or_D, t, has_transmission, left_index, right_index, left_probability)) { +kg, P, N_or_D, t, has_transmission, left_index, right_index, left_prob)) { return false; /* both child nodes have zero importance */ } -if (randu < left_probability) { /* go left */ - kernel_assert(left_probability > 0.0f); - - node_index = left_index; - randu /= left_probability; - pdf_leaf *= left_probability; -} -else { - kernel_assert((1.0f - left_probability) > 0.0f); - - node_index = right_index; - randu = (randu - left_probability) / (1.0f - left_probability); - pdf_leaf *= (1.0f - left_probability); -} +float discard; +float total_prob = left_prob; +node_index = left_index; +sample_resevoir(right_index, 1.0f - left_prob, node_index, discard, total_prob, randu); +pdf_leaf *= (node_index == left_index) ? left_prob : (1.0f - left_prob); } /* TODO: check `spot_light_tree_weight()` and `area_light_tree_weight()` */ @@ -675,15 +666,15 @@ ccl_device float light_tree_pdf( const int left_index = node_index + 1; const int right_index = knode->child_index; -float left_probability; +float left_prob; if (!get_left_probability( -kg, P, N, 0, has_transmission, left_index, right_index,
[Bf-blender-cvs] [c387b5240aa] soc-2022-many-lights-sampling: Cleanup: reduce variable scope
Commit: c387b5240aad1f8a4f044543493a55f1f61322f7 Author: Weizhen Huang Date: Wed Nov 30 13:05:50 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBc387b5240aad1f8a4f044543493a55f1f61322f7 Cleanup: reduce variable scope === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index e02fd033726..88729da8d48 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -83,7 +83,6 @@ ccl_device void light_tree_importance(const float3 N_or_D, min_importance = 0.0f; const float sin_theta_u = sin_from_cos(cos_theta_u); - float cos_theta, cos_theta_i, sin_theta_i; /* cos(theta_i') in the paper, omitted for volume */ float cos_min_incidence_angle = 1.0f; float cos_max_incidence_angle = 1.0f; @@ -91,11 +90,12 @@ ccl_device void light_tree_importance(const float3 N_or_D, * `sample.h` */ const bool in_volume = is_zero(N_or_D); - cos_theta = dot(bcone.axis, -point_to_centroid); + const float cos_theta = dot(bcone.axis, -point_to_centroid); if (!in_volume_segment && !in_volume) { const float3 N = N_or_D; -cos_theta_i = has_transmission ? fabsf(dot(point_to_centroid, N)) : dot(point_to_centroid, N); -sin_theta_i = sin_from_cos(cos_theta_i); +const float cos_theta_i = has_transmission ? fabsf(dot(point_to_centroid, N)) : + dot(point_to_centroid, N); +const float sin_theta_i = sin_from_cos(cos_theta_i); /* cos_min_incidence_angle = cos(max{theta_i - theta_u, 0}) = cos(theta_i') in the paper */ cos_min_incidence_angle = cos_theta_i >= cos_theta_u ? ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1e277d8a554] soc-2022-many-lights-sampling: Cleanup: rearranging the order of some variables
Commit: 1e277d8a5545d126b90211eb27f5568cd1942f3c Author: Weizhen Huang Date: Wed Nov 30 13:23:34 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB1e277d8a5545d126b90211eb27f5568cd1942f3c Cleanup: rearranging the order of some variables === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index 88729da8d48..b35f76286b9 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -83,14 +83,14 @@ ccl_device void light_tree_importance(const float3 N_or_D, min_importance = 0.0f; const float sin_theta_u = sin_from_cos(cos_theta_u); + /* cos(theta_i') in the paper, omitted for volume */ float cos_min_incidence_angle = 1.0f; float cos_max_incidence_angle = 1.0f; + /* when sampling the light tree for the second time in `shade_volume.h` and when query the pdf in * `sample.h` */ const bool in_volume = is_zero(N_or_D); - - const float cos_theta = dot(bcone.axis, -point_to_centroid); if (!in_volume_segment && !in_volume) { const float3 N = N_or_D; const float cos_theta_i = has_transmission ? fabsf(dot(point_to_centroid, N)) : @@ -102,9 +102,6 @@ ccl_device void light_tree_importance(const float3 N_or_D, 1.0f : cos_theta_i * cos_theta_u + sin_theta_i * sin_theta_u; -/* cos_max_incidence_angle = cos(min{theta_i + theta_u, pi}) */ -cos_max_incidence_angle = fmaxf(cos_theta_i * cos_theta_u - sin_theta_i * sin_theta_u, 0.0f); - /* If the node is guaranteed to be behind the surface we're sampling, and the surface is * opaque, then we can give the node an importance of 0 as it contributes nothing to the * surface. This is more accurate than the bbox test if we are calculating the importance of @@ -112,18 +109,22 @@ ccl_device void light_tree_importance(const float3 N_or_D, if (!has_transmission && cos_min_incidence_angle < 0) { return; } + +/* cos_max_incidence_angle = cos(min{theta_i + theta_u, pi}) */ +cos_max_incidence_angle = fmaxf(cos_theta_i * cos_theta_u - sin_theta_i * sin_theta_u, 0.0f); } - /* minimum angle an emitter’s axis would form with the direction to the shading point, - * cos(theta') in the paper */ - float cos_min_outgoing_angle; /* cos(theta - theta_u) */ + const float cos_theta = dot(bcone.axis, -point_to_centroid); const float sin_theta = sin_from_cos(cos_theta); const float cos_theta_minus_theta_u = cos_theta * cos_theta_u + sin_theta * sin_theta_u; float cos_theta_o, sin_theta_o; fast_sincosf(bcone.theta_o, &sin_theta_o, &cos_theta_o); + /* minimum angle an emitter’s axis would form with the direction to the shading point, + * cos(theta') in the paper */ + float cos_min_outgoing_angle; if ((cos_theta > cos_theta_u) || (cos_theta_minus_theta_u > cos_theta_o)) { /* theta - theta_o - theta_u < 0 */ kernel_assert((fast_acosf(cos_theta) - bcone.theta_o - fast_acosf(cos_theta_u)) < 5e-4f); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [af00a73971e] soc-2022-many-lights-sampling: Cleanup: suppress some warnings
Commit: af00a73971ef6329b4b679f15915beb04f11b36c Author: Weizhen Huang Date: Wed Nov 30 13:35:29 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBaf00a73971ef6329b4b679f15915beb04f11b36c Cleanup: suppress some warnings === M intern/cycles/kernel/light/tree.h M intern/cycles/scene/light_tree.cpp === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index b35f76286b9..b68b7f2a32a 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -446,7 +446,7 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg, kernel_assert(knode->num_prims <= sizeof(uint) * 8); uint has_importance = 0; - bool sample_max = (rand > 0.5f); /* sampling using the maximum importance */ + const bool sample_max = (rand > 0.5f); /* sampling using the maximum importance */ rand = rand * 2.0f - float(sample_max); for (int i = 0; i < knode->num_prims; i++) { diff --git a/intern/cycles/scene/light_tree.cpp b/intern/cycles/scene/light_tree.cpp index 6db2b29c4fd..121b5593bde 100644 --- a/intern/cycles/scene/light_tree.cpp +++ b/intern/cycles/scene/light_tree.cpp @@ -131,8 +131,8 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id) /* For an area light, sizeu and sizev determine the 2 dimensions of the area light, * while axisu and axisv determine the orientation of the 2 dimensions. * We want to add all 4 corners to our bounding box. */ - const float3 half_extentu = 0.5 * lamp->get_sizeu() * lamp->get_axisu() * size; - const float3 half_extentv = 0.5 * lamp->get_sizev() * lamp->get_axisv() * size; + const float3 half_extentu = 0.5f * lamp->get_sizeu() * lamp->get_axisu() * size; + const float3 half_extentv = 0.5f * lamp->get_sizev() * lamp->get_axisv() * size; bbox.grow(centroid + half_extentu + half_extentv); bbox.grow(centroid + half_extentu - half_extentv); bbox.grow(centroid - half_extentu + half_extentv); @@ -272,7 +272,7 @@ int LightTree::recursive_build( middle = (start + end) / 2; } -int left_index = recursive_build(start, middle, prims, bit_trail, depth + 1); +[[maybe_unused]] int left_index = recursive_build(start, middle, prims, bit_trail, depth + 1); int right_index = recursive_build(middle, end, prims, bit_trail | (1u << depth), depth + 1); assert(left_index == current_index + 1); nodes_[current_index].make_interior(right_index); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f4ab719f569] soc-2022-many-lights-sampling: Cleanup: unify variable names in function declaration and definition
Commit: f4ab719f569472aa48391488ddd4f90634569205 Author: Weizhen Huang Date: Wed Nov 30 14:21:42 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBf4ab719f569472aa48391488ddd4f90634569205 Cleanup: unify variable names in function declaration and definition === M intern/cycles/scene/light_tree.h === diff --git a/intern/cycles/scene/light_tree.h b/intern/cycles/scene/light_tree.h index 2f12ad4f3f3..18f552924a9 100644 --- a/intern/cycles/scene/light_tree.h +++ b/intern/cycles/scene/light_tree.h @@ -144,13 +144,13 @@ class LightTree { private: int recursive_build( int start, int end, vector &prims, uint bit_trail, int depth); - float min_split_saoh(const BoundBox ¢roid_bounds, + float min_split_saoh(const BoundBox ¢roid_bbox, int start, int end, const BoundBox &bbox, const OrientationBounds &bcone, - int &min_dim, - int &min_bucket, + int &split_dim, + int &split_bucket, int &num_left_prims, const vector &prims); }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f3fedfe2659] soc-2022-many-lights-sampling: Cleanup: delete a few outdated comments
Commit: f3fedfe26590835de443f23935293fc741e2f74e Author: Weizhen Huang Date: Wed Nov 30 14:21:02 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBf3fedfe26590835de443f23935293fc741e2f74e Cleanup: delete a few outdated comments === M intern/cycles/kernel/light/tree.h M intern/cycles/scene/light_tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index b68b7f2a32a..02897dfe2e2 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -515,7 +515,6 @@ ccl_device_inline bool get_left_probability(KernelGlobals kg, const int right_index, ccl_private float &left_probability) { - /* If we don't split, then we need to choose sampling between the left or right child. */ const ccl_global KernelLightTreeNode *left = &kernel_data_fetch(light_tree_nodes, left_index); const ccl_global KernelLightTreeNode *right = &kernel_data_fetch(light_tree_nodes, right_index); @@ -594,7 +593,6 @@ ccl_device bool light_tree_sample(KernelGlobals kg, pdf_leaf *= (node_index == left_index) ? left_prob : (1.0f - left_prob); } - /* TODO: check `spot_light_tree_weight()` and `area_light_tree_weight()` */ if (selected_light < 0) { return false; } diff --git a/intern/cycles/scene/light_tree.h b/intern/cycles/scene/light_tree.h index 4123a103116..2f12ad4f3f3 100644 --- a/intern/cycles/scene/light_tree.h +++ b/intern/cycles/scene/light_tree.h @@ -49,15 +49,14 @@ OrientationBounds merge(const OrientationBounds &cone_a, const OrientationBounds /* * Light Tree Construction * - * The light tree construction is based off PBRT's BVH construction, - * which first uses build nodes before converting to a more compact structure. + * The light tree construction is based on PBRT's BVH construction. */ /* Light Tree Primitive * Struct that indexes into the scene's triangle and light arrays. */ struct LightTreePrimitive { - /* prim_id >= 0 is an index into an object's local triangle index, - * otherwise -prim_id-1 is an index into device lights array. */ + /* `prim_id >= 0` is an index into an object's local triangle index, + * otherwise `-prim_id-1`(`~prim`) is an index into device lights array. */ int prim_id; int object_id; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [313c2e91050] master: Fix a test after recent changes to lib (in)directly linked ID handling.
Commit: 313c2e910506d4fdccf27c7593eb8518f7dff8b5 Author: Bastien Montagne Date: Wed Nov 30 15:04:36 2022 +0100 Branches: master https://developer.blender.org/rB313c2e910506d4fdccf27c7593eb8518f7dff8b5 Fix a test after recent changes to lib (in)directly linked ID handling. rB133dde41bb5b changed handling of (in)directly linked status handling for IDs, now IDs that are not directly linked get proper status and handling on file save. this broke parts of the `pyapi_idprop_datablock` tests. === M tests/python/bl_pyapi_idprop_datablock.py === diff --git a/tests/python/bl_pyapi_idprop_datablock.py b/tests/python/bl_pyapi_idprop_datablock.py index 42c9ec1b16f..ba545aee151 100644 --- a/tests/python/bl_pyapi_idprop_datablock.py +++ b/tests/python/bl_pyapi_idprop_datablock.py @@ -146,6 +146,8 @@ def check_lib_linking(): with bpy.data.libraries.load(lib_path, link=True) as (data_from, data_to): data_to.scenes = ["Scene_lib"] +bpy.context.window.scene = bpy.data.scenes["Scene_lib"] + o = bpy.data.scenes["Scene_lib"].objects['Unique_Cube'] expect_false_or_abort(o.prop_array[0].test_prop == bpy.data.scenes["Scene_lib"].objects['Light']) @@ -158,9 +160,10 @@ def check_lib_linking(): def check_linked_scene_copying(): # full copy of the scene with datablock props bpy.ops.wm.open_mainfile(filepath=test_path) -bpy.context.window.scene = bpy.data.scenes["Scene_lib"] bpy.ops.scene.new(type='FULL_COPY') +bpy.context.window.scene = get_scene("lib.blend", "Scene_lib") + # check save/open bpy.ops.wm.save_as_mainfile(filepath=test_path) bpy.ops.wm.open_mainfile(filepath=test_path) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [94248012532] refactor-mesh-corners-generic: Merge branch 'refactor-mesh-position-generic' into refactor-mesh-corners-generic
Commit: 94248012532e96ab99187b9715a6f3d4b716f892 Author: Hans Goudey Date: Tue Nov 29 22:02:02 2022 -0600 Branches: refactor-mesh-corners-generic https://developer.blender.org/rB94248012532e96ab99187b9715a6f3d4b716f892 Merge branch 'refactor-mesh-position-generic' into refactor-mesh-corners-generic === === diff --cc source/blender/blenkernel/BKE_mesh_mapping.h index f1eb455ff6d,b5db649bb9a..34194f901e9 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@@ -351,9 -349,10 +351,12 @@@ namespace blender::bke::mesh_topology Array build_loop_to_poly_map(Span polys, int loops_num); Array> build_vert_to_edge_map(Span edges, int verts_num); -Array> build_vert_to_poly_map(Span polys, Span loops, int verts_num); -Array> build_vert_to_loop_map(Span loops, int verts_num); -Array> build_edge_to_loop_map(Span loops, int edges_num); -Vector> build_edge_to_loop_map_resizable(Span loops, int edges_num); ++Array> build_vert_to_poly_map(Span polys, ++ Span corner_verts, ++ int verts_num); +Array> build_vert_to_loop_map(Span corner_verts, int verts_num); +Array> build_edge_to_loop_map(Span corner_edges, int edges_num); +Vector> build_edge_to_loop_map_resizable(Span corner_edges, int edges_num); inline int previous_poly_loop(const MPoly &poly, int loop_i) { diff --cc source/blender/blenkernel/intern/mesh.cc index 6048e60d1b7,9f40cc381b8..1a7a4f028dc --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@@ -1468,24 -1485,18 +1468,21 @@@ int BKE_mesh_edge_other_vert(const MEdg return -1; } - void BKE_mesh_looptri_get_real_edges(const Mesh *mesh, const MLoopTri *looptri, int r_edges[3]) + void BKE_mesh_looptri_get_real_edges(const MEdge *edges, + const MLoop *loops, + const MLoopTri *tri, + int r_edges[3]) { + const Span edges = mesh->edges(); - const Span corner_edges = mesh->corner_edges(); - const Span corner_verts = mesh->corner_edges(); ++ const Span loops = mesh->loops(); + for (int i = 2, i_next = 0; i_next < 3; i = i_next++) { - const int corner_1 = looptri->tri[i]; - const int corner_2 = looptri->tri[i_next]; - const int vert_1 = corner_verts[corner_1]; - const int vert_2 = corner_verts[corner_1]; - const int edge_1 = corner_edges[corner_1]; - const int edge_2 = corner_edges[corner_1]; - const MEdge *e = &edges[edge_1]; -const MLoop *l1 = &loops[tri->tri[i]], *l2 = &loops[tri->tri[i_next]]; ++const MLoop *l1 = &loops[looptri->tri[i]], *l2 = &loops[looptri->tri[i_next]]; + const MEdge *e = &edges[l1->e]; -bool is_real = (l1->v == e->v1 && l2->v == e->v2) || (l1->v == e->v2 && l2->v == e->v1); +bool is_real = (vert_1 == e->v1 && vert_2 == e->v2) || (vert_1 == e->v2 && vert_2 == e->v1); -r_edges[i] = is_real ? l1->e : -1; +r_edges[i] = is_real ? edge_1 : -1; } } diff --cc source/blender/blenkernel/intern/mesh_mapping.cc index a1317ccb59a,f564634d77b..85cc9f60535 --- a/source/blender/blenkernel/intern/mesh_mapping.cc +++ b/source/blender/blenkernel/intern/mesh_mapping.cc @@@ -569,11 -576,25 +569,25 @@@ Array> build_vert_to_edge_m return map; } + Array> build_vert_to_poly_map(const Span polys, - const Span loops, ++ const Span corner_verts, + int verts_num) + { + Array> map(verts_num); + for (const int64_t i : polys.index_range()) { + const MPoly &poly = polys[i]; -for (const MLoop &loop : loops.slice(poly.loopstart, poly.totloop)) { - map[loop.v].append(int(i)); ++for (const int64_t vert_i : corner_verts.slice(poly.loopstart, poly.totloop)) { ++ map[int(vert_i)].append(int(i)); + } + } + return map; + } + -Array> build_vert_to_loop_map(const Span loops, const int verts_num) +Array> build_vert_to_loop_map(const Span corner_verts, const int verts_num) { Array> map(verts_num); - for (const int64_t i : loops.index_range()) { -map[loops[i].v].append(int(i)); + for (const int64_t i : corner_verts.index_range()) { +map[corner_verts[i]].append(int(i)); } return map; } diff --cc source/blender/blenkernel/intern/mesh_normals.cc index 20a637cc325,23a026b56db..570195f529c --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@@ -211,46 -209,35 +211,45 @@@ void BKE_mesh_calc_poly_normal(const MP } } -static void calculate_normals_poly(const Span positions, - const Span polys, -
[Bf-blender-cvs] [f5e39d9190a] refactor-mesh-corners-generic: 298 remaining uses of MLoop
Commit: f5e39d9190a6d3ce7ad46fffaddfd4035fa1ebad Author: Hans Goudey Date: Wed Nov 30 09:14:51 2022 -0600 Branches: refactor-mesh-corners-generic https://developer.blender.org/rBf5e39d9190a6d3ce7ad46fffaddfd4035fa1ebad 298 remaining uses of MLoop === M source/blender/blenkernel/BKE_mesh.h M source/blender/blenkernel/BKE_mesh_remap.h M source/blender/blenkernel/BKE_uv_islands.hh M source/blender/blenkernel/intern/cdderivedmesh.c M source/blender/blenkernel/intern/data_transfer.c M source/blender/blenkernel/intern/mesh.cc M source/blender/blenkernel/intern/mesh_convert.cc M source/blender/blenkernel/intern/mesh_iterators.cc M source/blender/blenkernel/intern/mesh_mirror.c M source/blender/blenkernel/intern/mesh_normals.cc M source/blender/blenkernel/intern/mesh_remap.cc M source/blender/blenkernel/intern/mesh_remesh_voxel.cc M source/blender/blenkernel/intern/mesh_runtime.cc M source/blender/blenkernel/intern/mesh_validate.cc M source/blender/blenkernel/intern/mesh_wrapper.cc M source/blender/blenkernel/intern/multires_unsubdivide.c M source/blender/blenkernel/intern/pbvh_pixels.cc M source/blender/blenkernel/intern/pbvh_uv_islands.cc M source/blender/blenkernel/intern/pbvh_uv_islands.hh M source/blender/blenkernel/intern/subdiv_foreach.c M source/blender/draw/intern/mesh_extractors/extract_mesh.hh M source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_fdots.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc M source/blender/modifiers/intern/MOD_laplaciandeform.c M source/blender/modifiers/intern/MOD_normal_edit.cc M source/blender/modifiers/intern/MOD_ocean.c M source/blender/modifiers/intern/MOD_particleinstance.c M source/blender/modifiers/intern/MOD_remesh.c M source/blender/modifiers/intern/MOD_surfacedeform.c M source/blender/modifiers/intern/MOD_uvwarp.cc M source/blender/modifiers/intern/MOD_weighted_normal.cc M source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc M source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc M source/blender/render/intern/multires_bake.c === diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 623c1a6806d..89b02e2ffc2 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -111,7 +111,7 @@ void BKE_mesh_ensure_default_orig_index_customdata_no_check(struct Mesh *mesh); * Find the index of the loop in 'poly' which references vertex, * returns -1 if not found */ -int poly_find_loop_from_vert(const struct MPoly *poly, const int *poly_corner_verts, int vert); +int poly_find_loop_from_vert(const struct MPoly *poly, const int *poly_verts, int vert); /** * Fill \a r_adj with the loop indices in \a poly adjacent to the * vertex. Returns the index of the loop matching vertex, or -1 if the @@ -131,8 +131,9 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v); * Sets each output array element to the edge index if it is a real edge, or -1. */ void BKE_mesh_looptri_get_real_edges(const struct MEdge *edges, - const struct MLoop *loops, - const struct MLoopTri *looptri, + const int *corner_verts, + const int *corner_edges, + const struct MLoopTri *tri, int r_edges[3]); /** @@ -439,7 +440,7 @@ bool BKE_mesh_vertex_normals_are_dirty(const struct Mesh *mesh); bool BKE_mesh_poly_normals_are_dirty(const struct Mesh *mesh); void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly, - const int *poly_corner_verts, + const int *poly_verts, const float (*positions)[3], float r_no[3]); @@ -919,7 +920,8 @@ bool BKE_mesh_validate_arrays(struct Mesh *me, unsigned int totedge, struct MFace *mfaces, unsigned int totface, - struct MLoop *mloops, + int *corner_verts, + int *corner_edges, unsigned int totloop, struct MPoly *mpolys, unsigned int totpoly, @@ -1045,22
[Bf-blender-cvs] [2efae990c73] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal
Commit: 2efae990c73d3b1fbc886db52b0c9a9ec8655eed Author: Antonio Vazquez Date: Wed Nov 30 16:33:58 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB2efae990c73d3b1fbc886db52b0c9a9ec8655eed Merge branch 'master' into gpencil-new-data-proposal === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [18de7122573] master: Fix T100879: Bake Action fails with "Nothing to Bake"
Commit: 18de7122573fa5aa5224a3cd1a93f996b77faa0a Author: Christoph Lendenfeld Date: Wed Nov 30 16:57:21 2022 +0100 Branches: master https://developer.blender.org/rB18de7122573fa5aa5224a3cd1a93f996b77faa0a Fix T100879: Bake Action fails with "Nothing to Bake" When applying the "Bake Action" operator in pose mode it could throw an error saying "Nothing to Bake" even though bones are selected That is because the code was looking for a selected armature But in Pose Mode, clicking into empty space to de-select would also deselect the armature. Then box selecting would not make the armature selected again Reviewed by: Sybren A. Stüvel Differential Revision: https://developer.blender.org/D16593 === M release/datafiles/locale M release/scripts/addons M release/scripts/addons_contrib M release/scripts/startup/bl_operators/anim.py === diff --git a/release/datafiles/locale b/release/datafiles/locale index ef57e2c2c65..4a581c54af9 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit ef57e2c2c65933a68811d58b40ed62b775e9b4b0 +Subproject commit 4a581c54af9b92cb670d750951b9382160f10f3e diff --git a/release/scripts/addons b/release/scripts/addons index bde68da02fd..0b0052bd53a 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit bde68da02fde93968dc11b52d42060ac3b81ed37 +Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index e6179b3b112..96143b1a8b0 16 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit e6179b3b112298e131bbd0faf648bf0d392b6cdd +Subproject commit 96143b1a8b037ea3c81f065f557025db9fe1ace3 diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index 1c92ee81345..e9a0b62cd60 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -252,9 +252,14 @@ class NLA_OT_bake(Operator): do_pose = 'POSE' in self.bake_types do_object = 'OBJECT' in self.bake_types -objects = context.selected_editable_objects -if do_pose and not do_object: -objects = [obj for obj in objects if obj.pose is not None] +if do_pose and self.only_selected: +pose_bones = context.selected_pose_bones or [] +armatures = {pose_bone.id_data for pose_bone in pose_bones} +objects = list(armatures) +else: +objects = context.selected_editable_objects +if do_pose and not do_object: +objects = [obj for obj in objects if obj.pose is not None] object_action_pairs = ( [(obj, getattr(obj.animation_data, "action", None)) for obj in objects] ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [429771fed55] master: Add 'work around' to accessing data from volatile iterators in py API.
Commit: 429771fed55119df4dfebcf1c8c3666f017fc0eb Author: Bastien Montagne Date: Wed Nov 30 16:52:10 2022 +0100 Branches: master https://developer.blender.org/rB429771fed55119df4dfebcf1c8c3666f017fc0eb Add 'work around' to accessing data from volatile iterators in py API. Re T102550. === M doc/python_api/rst/info_gotcha.rst === diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst index 2dd6c3c92b1..e2a49898a4b 100644 --- a/doc/python_api/rst/info_gotcha.rst +++ b/doc/python_api/rst/info_gotcha.rst @@ -870,6 +870,26 @@ an issue but, due to internal implementation details, currently are: thus breaking any current iteration over ``Collection.all_objects``. +.. rubric:: Do not: + +.. code-block:: python + + # `all_objects` is an iterator. Using it directly while performing operations on its members that will update + # the memory accessed by the `all_objects` iterator will lead to invalid memory accesses and crashes. + for object in bpy.data.collections["Collection"].all_objects: +object.hide_viewport = True + + +.. rubric:: Do: + +.. code-block:: python + + # `all_objects[:]` is an independent list generated from the iterator. As long as no objects are deleted, + # its content will remain valid even if the data accessed by the `all_objects` iterator is modified. + for object in bpy.data.collections["Collection"].all_objects[:]: +object.hide_viewport = True + + sys.exit ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5c1cc79cf4e] blender-v3.4-release: Fix T100879: Bake Action fails with "Nothing to Bake"
Commit: 5c1cc79cf4ea9b557d3ee843f275074441b90894 Author: Christoph Lendenfeld Date: Wed Nov 30 16:57:21 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB5c1cc79cf4ea9b557d3ee843f275074441b90894 Fix T100879: Bake Action fails with "Nothing to Bake" When applying the "Bake Action" operator in pose mode it could throw an error saying "Nothing to Bake" even though bones are selected That is because the code was looking for a selected armature But in Pose Mode, clicking into empty space to de-select would also deselect the armature. Then box selecting would not make the armature selected again Reviewed by: Sybren A. Stüvel Differential Revision: https://developer.blender.org/D16593 === M release/datafiles/locale M release/scripts/addons M release/scripts/addons_contrib M release/scripts/startup/bl_operators/anim.py === diff --git a/release/datafiles/locale b/release/datafiles/locale index ef57e2c2c65..4a581c54af9 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit ef57e2c2c65933a68811d58b40ed62b775e9b4b0 +Subproject commit 4a581c54af9b92cb670d750951b9382160f10f3e diff --git a/release/scripts/addons b/release/scripts/addons index bde68da02fd..0b0052bd53a 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit bde68da02fde93968dc11b52d42060ac3b81ed37 +Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index e6179b3b112..96143b1a8b0 16 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit e6179b3b112298e131bbd0faf648bf0d392b6cdd +Subproject commit 96143b1a8b037ea3c81f065f557025db9fe1ace3 diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index 0f4c6c4b9c3..33e87d0abdb 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -252,9 +252,14 @@ class NLA_OT_bake(Operator): do_pose = 'POSE' in self.bake_types do_object = 'OBJECT' in self.bake_types -objects = context.selected_editable_objects -if do_pose and not do_object: -objects = [obj for obj in objects if obj.pose is not None] +if do_pose and self.only_selected: +pose_bones = context.selected_pose_bones or [] +armatures = {pose_bone.id_data for pose_bone in pose_bones} +objects = list(armatures) +else: +objects = context.selected_editable_objects +if do_pose and not do_object: +objects = [obj for obj in objects if obj.pose is not None] object_action_pairs = ( [(obj, getattr(obj.animation_data, "action", None)) for obj in objects] ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c17d7ddabed] master: Merge branch 'blender-v3.4-release'
Commit: c17d7ddabed89d7bce0d7d6488193d10ceaa5cb5 Author: Christoph Lendenfeld Date: Wed Nov 30 17:26:01 2022 +0100 Branches: master https://developer.blender.org/rBc17d7ddabed89d7bce0d7d6488193d10ceaa5cb5 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0b13e7ce0fd] master: Cleanup: Remove unnecessary use of deprecated DNA define
Commit: 0b13e7ce0fd4b69ded3afe25a48f9ecb0c01333c Author: Hans Goudey Date: Wed Nov 30 10:27:10 2022 -0600 Branches: master https://developer.blender.org/rB0b13e7ce0fd4b69ded3afe25a48f9ecb0c01333c Cleanup: Remove unnecessary use of deprecated DNA define This was solved by `dna::shallow_copy` === M source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc === diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index 5c3216b085b..5d37b058ed0 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -3,8 +3,6 @@ /** \file * \ingroup obj */ -/* Silence warnings from copying deprecated fields. Needed for an Object copy constructor use. */ -#define DNA_DEPRECATED_ALLOW #include "BKE_attribute.hh" #include "BKE_customdata.h" ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d20b672e01c] tmp-workbench-rewrite2: wbench next: render to image
Commit: d20b672e01c2f7b64db3a5b43d3dda1b432bd816 Author: Miguel Pozo Date: Tue Nov 29 20:18:25 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBd20b672e01c2f7b64db3a5b43d3dda1b432bd816 wbench next: render to image === M release/scripts/startup/bl_ui/properties_view_layer.py M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_state.cc === diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py index b18734ea98a..c45cafa07fa 100644 --- a/release/scripts/startup/bl_ui/properties_view_layer.py +++ b/release/scripts/startup/bl_ui/properties_view_layer.py @@ -44,7 +44,7 @@ class VIEWLAYER_PT_layer(ViewLayerButtonsPanel, Panel): class VIEWLAYER_PT_layer_passes(ViewLayerButtonsPanel, Panel): bl_label = "Passes" -COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT'} +COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', 'BLENDER_WORKBENCH_NEXT'} def draw(self, context): pass @@ -94,6 +94,23 @@ class VIEWLAYER_PT_eevee_next_layer_passes_data(ViewLayerButtonsPanel, Panel): sub.active = not scene.eevee.use_motion_blur sub.prop(view_layer, "use_pass_vector") +class VIEWLAYER_PT_eevee_next_layer_passes_data(ViewLayerButtonsPanel, Panel): +bl_label = "Data" +bl_parent_id = "VIEWLAYER_PT_layer_passes" + +COMPAT_ENGINES = {'BLENDER_WORKBENCH_NEXT'} + +def draw(self, context): +layout = self.layout +layout.use_property_split = True +layout.use_property_decorate = False + +view_layer = context.view_layer + +col = layout.column() +col.prop(view_layer, "use_pass_combined") +col.prop(view_layer, "use_pass_z") + class VIEWLAYER_PT_eevee_layer_passes_light(ViewLayerButtonsPanel, Panel): bl_label = "Light" diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 0a3d89f37f0..483664b3f66 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -6,6 +6,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pbvh.h" +#include "BKE_report.h" #include "DEG_depsgraph_query.h" #include "DNA_fluid_types.h" #include "ED_paint.h" @@ -34,9 +35,9 @@ class Instance { DofPass dof_ps; AntiAliasingPass anti_aliasing_ps; - void init() + void init(Object *camera_ob = nullptr) { -scene_state.init(); +scene_state.init(camera_ob); resources.init(scene_state); outline_ps.init(scene_state); @@ -462,19 +463,201 @@ static void workbench_id_update(void *vedata, struct ID *id) UNUSED_VARS(vedata, id); } +/* RENDER */ + +static bool workbench_render_framebuffers_init(void) +{ + /* For image render, allocate own buffers because we don't have a viewport. */ + const float2 viewport_size = DRW_viewport_size_get(); + const int2 size = {int(viewport_size.x), int(viewport_size.y)}; + + DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + + /* When doing a multi view rendering the first view will allocate the buffers + * the other views will reuse these buffers */ + if (dtxl->color == nullptr) { +BLI_assert(dtxl->depth == nullptr); +dtxl->color = GPU_texture_create_2d("txl.color", size.x, size.y, 1, GPU_RGBA16F, nullptr); +dtxl->depth = GPU_texture_create_2d( +"txl.depth", size.x, size.y, 1, GPU_DEPTH24_STENCIL8, nullptr); + } + + if (!(dtxl->depth && dtxl->color)) { +return false; + } + + DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); + + GPU_framebuffer_ensure_config( + &dfbl->default_fb, + {GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_TEXTURE(dtxl->color)}); + + GPU_framebuffer_ensure_config(&dfbl->depth_only_fb, +{GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_NONE}); + + GPU_framebuffer_ensure_config(&dfbl->color_only_fb, +{GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(dtxl->color)}); + + return GPU_framebuffer_check_valid(dfbl->default_fb, nullptr) && + GPU_framebuffer_check_valid(dfbl->color_only_fb, nullptr) && + GPU_framebuffer_check_valid(dfbl->depth_only_fb, nullptr); +} + +#ifdef DEBUG +/* This is just to ease GPU debugging when the frame delimiter is set to Finish */ +# define GPU_FINISH_DELIMITER() GPU_finish() +#else +# define GPU_FINISH_DELIMITER() +#endif + static void workbench_render_to_image(void *vedata, struct RenderEngine *engine, struct RenderLayer *layer, -
[Bf-blender-cvs] [507b724056d] master: Cleanup: Remove unnecessary BMesh unique pointer in OBJ code
Commit: 507b724056ddc92388b4814ba721c59081931d3b Author: Hans Goudey Date: Wed Nov 30 10:45:18 2022 -0600 Branches: master https://developer.blender.org/rB507b724056ddc92388b4814ba721c59081931d3b Cleanup: Remove unnecessary BMesh unique pointer in OBJ code This is only used once, it's simpler to just free it in that case and wait for further RAII improvements from elsewhere in the codebase. === M source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc M source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh === diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index 5d37b058ed0..8519fb97217 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -99,9 +99,8 @@ std::pair OBJMesh::triangulate_mesh_eval() * triangulated here. */ const int triangulate_min_verts = 4; - unique_bmesh_ptr bmesh( - BKE_mesh_to_bmesh_ex(export_mesh_eval_, &bm_create_params, &bm_convert_params)); - BM_mesh_triangulate(bmesh.get(), + BMesh *bmesh = BKE_mesh_to_bmesh_ex(export_mesh_eval_, &bm_create_params, &bm_convert_params); + BM_mesh_triangulate(bmesh, MOD_TRIANGULATE_NGON_BEAUTY, MOD_TRIANGULATE_QUAD_SHORTEDGE, triangulate_min_verts, @@ -110,8 +109,8 @@ std::pair OBJMesh::triangulate_mesh_eval() nullptr, nullptr); - Mesh *triangulated = BKE_mesh_from_bmesh_for_eval_nomain( - bmesh.get(), nullptr, export_mesh_eval_); + Mesh *triangulated = BKE_mesh_from_bmesh_for_eval_nomain(bmesh, nullptr, export_mesh_eval_); + BM_mesh_free(bmesh); free_mesh_if_needed(); return {triangulated, true}; } diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh index e1c0e67c174..f45dda338ee 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh @@ -28,20 +28,6 @@ const int NOT_FOUND = -1; /** Any negative number other than `NOT_FOUND` to initialize usually non-negative numbers. */ const int NEGATIVE_INIT = -10; -/** - * #std::unique_ptr than handles freeing #BMesh. - */ -struct CustomBMeshDeleter { - void operator()(BMesh *bmesh) - { -if (bmesh) { - BM_mesh_free(bmesh); -} - } -}; - -using unique_bmesh_ptr = std::unique_ptr; - class OBJMesh : NonCopyable { private: /** ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7cdcb76815b] master: Cleanup: Remove node tree runtime fields
Commit: 7cdcb76815bb3f96b98f6443eecae35b22a236e7 Author: Hans Goudey Date: Wed Nov 30 11:41:01 2022 -0600 Branches: master https://developer.blender.org/rB7cdcb76815bb3f96b98f6443eecae35b22a236e7 Cleanup: Remove node tree runtime fields `done` was only used in one place, and `is_updating` was never read. Generally we should avoid adding this sort of temporary data to longer lived structs. === M source/blender/blenkernel/BKE_node_runtime.hh M source/blender/editors/space_node/node_edit.cc M source/blender/editors/space_node/node_relationships.cc === diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh index 69e3b8915cc..ef32dcd8351 100644 --- a/source/blender/blenkernel/BKE_node_runtime.hh +++ b/source/blender/blenkernel/BKE_node_runtime.hh @@ -46,11 +46,6 @@ class bNodeTreeRuntime : NonCopyable, NonMovable { */ uint8_t runtime_flag = 0; - /** Flag to prevent re-entrant update calls. */ - short is_updating = 0; - /** Generic temporary flag for recursion check (DFS/BFS). */ - short done = 0; - /** Execution data. * * XXX It would be preferable to completely move this data out of the underlying node tree, diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index c6d1cc94c98..73d95f7af4b 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -2793,18 +2793,19 @@ static bool node_shader_script_update_poll(bContext *C) static bool node_shader_script_update_text_recursive(RenderEngine *engine, RenderEngineType *type, bNodeTree *ntree, - Text *text) + Text *text, + Set &done_trees) { bool found = false; - ntree->runtime->done = true; + done_trees.add_new(ntree); /* update each script that is using this text datablock */ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == NODE_GROUP) { bNodeTree *ngroup = (bNodeTree *)node->id; - if (ngroup && !ngroup->runtime->done) { -found |= node_shader_script_update_text_recursive(engine, type, ngroup, text); + if (ngroup && !done_trees.contains(ngroup)) { +found |= node_shader_script_update_text_recursive(engine, type, ngroup, text, done_trees); } } else if (node->type == SH_NODE_SCRIPT && node->id == &text->id) { @@ -2852,18 +2853,14 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op) Text *text = (Text *)CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data; if (text) { - /* clear flags for recursion check */ - FOREACH_NODETREE_BEGIN (bmain, ntree, id) { -if (ntree->type == NTREE_SHADER) { - ntree->runtime->done = false; -} - } - FOREACH_NODETREE_END; + + Set done_trees; FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { - if (!ntree->runtime->done) { -found |= node_shader_script_update_text_recursive(engine, type, ntree, text); + if (!done_trees.contains(ntree)) { +found |= node_shader_script_update_text_recursive( +engine, type, ntree, text, done_trees); } } } diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index a18b5c83857..f37061e5efb 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -902,8 +902,6 @@ static void node_link_exit(bContext &C, wmOperator &op, const bool apply_links) bNodeTree &ntree = *snode.edittree; bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op.customdata; - /* avoid updates while applying links */ - ntree.runtime->is_updating = true; for (bNodeLink *link : nldrag->links) { link->flag &= ~NODE_LINK_DRAGGED; @@ -929,7 +927,6 @@ static void node_link_exit(bContext &C, wmOperator &op, const bool apply_links) nodeRemLink(&ntree, link); } } - ntree.runtime->is_updating = false; ED_node_tree_propagate_change(&C, bmain, &ntree); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b78b6e3cd71] master: Cleanup: Correct comment in hash description
Commit: b78b6e3cd71b15ca2c8ab32717d91102c5915352 Author: Hans Goudey Date: Wed Nov 30 11:49:32 2022 -0600 Branches: master https://developer.blender.org/rBb78b6e3cd71b15ca2c8ab32717d91102c5915352 Cleanup: Correct comment in hash description We use the blender namespace now rather than BLI. === M source/blender/blenlib/BLI_hash.hh === diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh index c29dc74599a..1c9dd3914cf 100644 --- a/source/blender/blenlib/BLI_hash.hh +++ b/source/blender/blenlib/BLI_hash.hh @@ -33,14 +33,14 @@ * * There are three main ways to provide a hash table implementation with a custom hash function. * - * - When you want to provide a default hash function for your own custom type: Add a `hash` + * - When you want to provide a default hash function for your own custom type: Add a `hash()` * member function to it. The function should return `uint64_t` and take no arguments. This * method will be called by the default implementation of #DefaultHash. It will automatically be * used by hash table implementations. * * - When you want to provide a default hash function for a type that you cannot modify: Add a new * specialization to the #DefaultHash struct. This can be done by writing code like below in - * either global or BLI namespace. + * either global or `blender` namespace. * * template<> struct blender::DefaultHash { * uint64_t operator()(const TheType &value) const { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cfaca0d9ab2] master: Asset System: Store root path in asset library data
Commit: cfaca0d9ab2fa102379c09b6db693e41ceddb2e8 Author: Julian Eisel Date: Wed Nov 30 17:15:31 2022 +0100 Branches: master https://developer.blender.org/rBcfaca0d9ab2fa102379c09b6db693e41ceddb2e8 Asset System: Store root path in asset library data No user visible changes expected. If an asset library is located on disk, store the path to it in the asset library data. This is called the "root path" now. With this we can construct an asset identifier, which is introduced in the following commit. === M source/blender/asset_system/AS_asset_library.hh M source/blender/asset_system/CMakeLists.txt M source/blender/asset_system/intern/asset_library.cc M source/blender/asset_system/intern/asset_library_service.cc M source/blender/asset_system/intern/asset_library_service.hh A source/blender/asset_system/intern/utils.cc A source/blender/asset_system/intern/utils.hh === diff --git a/source/blender/asset_system/AS_asset_library.hh b/source/blender/asset_system/AS_asset_library.hh index 1a558c4e322..7df6e6d9f51 100644 --- a/source/blender/asset_system/AS_asset_library.hh +++ b/source/blender/asset_system/AS_asset_library.hh @@ -34,7 +34,9 @@ class AssetStorage; * to also include asset indexes and more. */ class AssetLibrary { - bCallbackFuncStore on_save_callback_store_{}; + /** If this is an asset library on disk, the top-level directory path. Normalized using + * #normalize_directory_path().*/ + std::string root_path_; /** Storage for assets (better said their representations) that are considered to be part of this * library. Assets are not automatically loaded into this when loading an asset library. Assets @@ -51,6 +53,8 @@ class AssetLibrary { */ std::unique_ptr asset_storage_; + bCallbackFuncStore on_save_callback_store_{}; + public: /* Controlled by #ED_asset_catalogs_set_save_catalogs_when_file_is_saved, * for managing the "Save Catalog Changes" in the quit-confirmation dialog box. */ @@ -59,10 +63,13 @@ class AssetLibrary { std::unique_ptr catalog_service; public: - AssetLibrary(); + /** + * \param root_path: If this is an asset library on disk, the top-level directory path. + */ + AssetLibrary(StringRef root_path = ""); ~AssetLibrary(); - void load_catalogs(StringRefNull library_root_directory); + void load_catalogs(); /** Load catalogs that have changed on disk. */ void refresh(); @@ -105,6 +112,8 @@ class AssetLibrary { void on_blend_save_post(Main *bmain, PointerRNA **pointers, int num_pointers); + StringRefNull root_path() const; + private: std::optional find_asset_index(const AssetRepresentation &asset); }; diff --git a/source/blender/asset_system/CMakeLists.txt b/source/blender/asset_system/CMakeLists.txt index d00c3c72e3b..c9ef11d33f4 100644 --- a/source/blender/asset_system/CMakeLists.txt +++ b/source/blender/asset_system/CMakeLists.txt @@ -21,6 +21,7 @@ set(SRC intern/asset_library_service.cc intern/asset_representation.cc intern/asset_storage.cc + intern/utils.cc AS_asset_catalog.hh AS_asset_catalog_path.hh @@ -29,6 +30,7 @@ set(SRC AS_asset_representation.hh intern/asset_library_service.hh intern/asset_storage.hh + intern/utils.hh AS_asset_library.h AS_asset_representation.h diff --git a/source/blender/asset_system/intern/asset_library.cc b/source/blender/asset_system/intern/asset_library.cc index 45196a218aa..7bdffe9abad 100644 --- a/source/blender/asset_system/intern/asset_library.cc +++ b/source/blender/asset_system/intern/asset_library.cc @@ -22,6 +22,7 @@ #include "asset_library_service.hh" #include "asset_storage.hh" +#include "utils.hh" using namespace blender; using namespace blender::asset_system; @@ -120,8 +121,9 @@ void AS_asset_library_remap_ids(const IDRemapper *mappings) namespace blender::asset_system { -AssetLibrary::AssetLibrary() -: asset_storage_(std::make_unique()), +AssetLibrary::AssetLibrary(StringRef root_path) +: root_path_(utils::normalize_directory_path(root_path)), + asset_storage_(std::make_unique()), catalog_service(std::make_unique()) { } @@ -133,9 +135,9 @@ AssetLibrary::~AssetLibrary() } } -void AssetLibrary::load_catalogs(StringRefNull library_root_directory) +void AssetLibrary::load_catalogs() { - auto catalog_service = std::make_unique(library_root_directory); + auto catalog_service = std::make_unique(root_path()); catalog_service->load_from_disk(); this->catalog_service = std::move(catalog_service); } @@ -224,6 +226,11 @@ void AssetLibrary::refresh_catalog_simplename(struct AssetMetaData *asset_data) STRNCPY(asset_data->catalog_simple_name, catalog->simple_name.c_str()); } +StringRefNull AssetLibrary::root_path() const +{ + return root_path_; +} + Vector all_valid_asset_library_refs() { Vector resul
[Bf-blender-cvs] [2165136740f] master: File/Asset Browser: Refactor how recursive paths are set
Commit: 2165136740f88fe92ebe4e548ef587adb6a3dfdd Author: Julian Eisel Date: Wed Nov 30 18:54:42 2022 +0100 Branches: master https://developer.blender.org/rB2165136740f88fe92ebe4e548ef587adb6a3dfdd File/Asset Browser: Refactor how recursive paths are set When reading directories recursively, the code would first only set the file name as the relative path and then later iterate over the read files and prepend the recursed into path, to get the complete path relative to the recursed into directory. This isn't clear and confused me quite a bit. And it is not compatible with what we need for creating asset identifiers, which are introduced in the 2nd following commit. Instead properly determine the complete relative path when initially adding the file, and don't change it after. The asset identifier can the be constructed properly at the time needed. === M source/blender/editors/space_file/filelist.cc === diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index dc59bb1286d..4a27893e985 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -2888,7 +2888,65 @@ struct TodoDir { char *dir; }; -static int filelist_readjob_list_dir(const char *root, +struct FileListReadJob { + ThreadMutex lock; + char main_name[FILE_MAX]; + Main *current_main; + FileList *filelist; + + /** The path currently being read, relative to the filelist root directory. Needed for recursive + * reading. The full file path is then composed like: `//. + * (whereby the file name may also be a library path within a .blend, e.g. + * `Materials/Material.001`). */ + char cur_relbase[FILE_MAX_LIBEXTRA]; + + /** Set to request a partial read that only adds files representing #Main data (IDs). Used when + * #Main may have received changes of interest (e.g. asset removed or renamed). */ + bool only_main_data; + + /** Shallow copy of #filelist for thread-safe access. + * + * The job system calls #filelist_readjob_update which moves any read file from #tmp_filelist + * into #filelist in a thread-safe way. + * + * #tmp_filelist also keeps an `AssetLibrary *` so that it can be loaded in the same thread, + * and moved to #filelist once all categories are loaded. + * + * NOTE: #tmp_filelist is freed in #filelist_readjob_free, so any copied pointers need to be + * set to nullptr to avoid double-freeing them. */ + FileList *tmp_filelist; +}; + +/** + * Append \a filename (or even a path inside of a .blend, like `Material/Material.001`), to the + * current relative path being read within the filelist root. The returned string needs freeing + * with #MEM_freeN(). + */ +static char *current_relpath_append(const FileListReadJob *job_params, const char *filename) +{ + const char *relbase = job_params->cur_relbase; + + /* Early exit, nothing to join. */ + if (!relbase[0]) { +return BLI_strdup(filename); + } + + BLI_assert(relbase[strlen(relbase) - 1] == SEP); + BLI_assert(BLI_path_is_rel(relbase)); + + char relpath[FILE_MAX_LIBEXTRA]; + /* Using #BLI_path_join works but isn't needed as `rel_subdir` has a trailing slash. */ + BLI_string_join(relpath, + sizeof(relpath), + /* + 2 to remove "//" relative path prefix. */ + relbase + 2, + filename); + + return BLI_strdup(relpath); +} + +static int filelist_readjob_list_dir(FileListReadJob *job_params, + const char *root, ListBase *entries, const char *filter_glob, const bool do_lib, @@ -2911,7 +2969,7 @@ static int filelist_readjob_list_dir(const char *root, } entry = MEM_cnew(__func__); - entry->relpath = static_cast(MEM_dupallocN(files[i].relname)); + entry->relpath = current_relpath_append(job_params, files[i].relname); entry->st = files[i].s; BLI_path_join(full_path, FILE_MAX, root, entry->relpath); @@ -2998,11 +3056,11 @@ enum ListLibOptions { }; ENUM_OPERATORS(ListLibOptions, LIST_LIB_ADD_PARENT); -static FileListInternEntry *filelist_readjob_list_lib_group_create(const int idcode, - const char *group_name) +static FileListInternEntry *filelist_readjob_list_lib_group_create( +const FileListReadJob *job_params, const int idcode, const char *group_name) { FileListInternEntry *entry = MEM_cnew(__func__); - entry->relpath = BLI_strdup(group_name); + entry->relpath = current_relpath_append(job_params, group_name); entry->typeflag |= FILE_TYPE_BLENDERLIB | FILE_TYPE_DIR; entry->blentype = idcode; return entry; @@ -3012,19 +3070,21 @@ static FileListInternEnt
[Bf-blender-cvs] [ccc9eef1b92] master: Assets: Get asset path via new identifier (not via file browser hacks)
Commit: ccc9eef1b9278ec2e8b57feddbf44cdfcda9d0a9 Author: Julian Eisel Date: Wed Nov 30 19:24:24 2022 +0100 Branches: master https://developer.blender.org/rBccc9eef1b9278ec2e8b57feddbf44cdfcda9d0a9 Assets: Get asset path via new identifier (not via file browser hacks) With the asset identifier introduced in the previous commit, we can now locate an asset just from its `AssetRepresentation`, without requiring information from the asset library and the file browser storage. With this we can remove some hacks and function parameters. A RNA/BPY function is also affected, but I didn't remove the paramter to keep compatibility. It's simply ignored and not required anymore, noted this in the parameter description (noted for T102877). === M release/scripts/startup/bl_operators/assets.py M release/scripts/startup/bl_ui/space_filebrowser.py M source/blender/editors/armature/pose_lib_2.c M source/blender/editors/asset/ED_asset_handle.h M source/blender/editors/asset/ED_asset_list.h M source/blender/editors/asset/ED_asset_list.hh M source/blender/editors/asset/ED_asset_temp_id_consumer.h M source/blender/editors/asset/intern/asset_handle.cc M source/blender/editors/asset/intern/asset_list.cc M source/blender/editors/asset/intern/asset_temp_id_consumer.cc M source/blender/editors/interface/interface_template_asset_view.cc M source/blender/editors/space_node/add_node_search.cc M source/blender/editors/space_node/link_drag_search.cc M source/blender/editors/space_node/node_add.cc M source/blender/makesrna/intern/rna_asset.c M source/blender/windowmanager/WM_api.h M source/blender/windowmanager/intern/wm_dragdrop.cc === diff --git a/release/scripts/startup/bl_operators/assets.py b/release/scripts/startup/bl_operators/assets.py index 1911a98f930..b794ede10a2 100644 --- a/release/scripts/startup/bl_operators/assets.py +++ b/release/scripts/startup/bl_operators/assets.py @@ -97,13 +97,12 @@ class ASSET_OT_open_containing_blend_file(Operator): def execute(self, context): asset_file_handle = context.asset_file_handle -asset_library_ref = context.asset_library_ref if asset_file_handle.local_id: self.report({'WARNING'}, "This asset is stored in the current blend file") return {'CANCELLED'} -asset_lib_path = bpy.types.AssetHandle.get_full_library_path(asset_file_handle, asset_library_ref) +asset_lib_path = bpy.types.AssetHandle.get_full_library_path(asset_file_handle) self.open_in_new_blender(asset_lib_path) wm = context.window_manager diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py index 1e7faf68b3f..614f350533b 100644 --- a/release/scripts/startup/bl_ui/space_filebrowser.py +++ b/release/scripts/startup/bl_ui/space_filebrowser.py @@ -862,8 +862,7 @@ def asset_path_str_get(_self): if asset_file_handle.local_id: return "Current File" -asset_library_ref = bpy.context.asset_library_ref -return bpy.types.AssetHandle.get_full_library_path(asset_file_handle, asset_library_ref) +return bpy.types.AssetHandle.get_full_library_path(asset_file_handle) def register_props(): diff --git a/source/blender/editors/armature/pose_lib_2.c b/source/blender/editors/armature/pose_lib_2.c index e3189eacdd5..1e69d9d0fc2 100644 --- a/source/blender/editors/armature/pose_lib_2.c +++ b/source/blender/editors/armature/pose_lib_2.c @@ -249,16 +249,15 @@ static void poselib_tempload_exit(PoseBlendData *pbd) static bAction *poselib_blend_init_get_action(bContext *C, wmOperator *op) { bool asset_handle_valid; - const AssetLibraryReference *asset_library_ref = CTX_wm_asset_library_ref(C); const AssetHandle asset_handle = CTX_wm_asset_handle(C, &asset_handle_valid); /* Poll callback should check. */ - BLI_assert((asset_library_ref != NULL) && asset_handle_valid); + BLI_assert(asset_handle_valid); PoseBlendData *pbd = op->customdata; pbd->temp_id_consumer = ED_asset_temp_id_consumer_create(&asset_handle); return (bAction *)ED_asset_temp_id_consumer_ensure_local_id( - pbd->temp_id_consumer, C, asset_library_ref, ID_AC, CTX_data_main(C), op->reports); + pbd->temp_id_consumer, ID_AC, CTX_data_main(C), op->reports); } static bAction *flip_pose(bContext *C, Object *ob, bAction *action) @@ -508,11 +507,9 @@ static bool poselib_asset_in_context(bContext *C) { bool asset_handle_valid; /* Check whether the context provides the asset data needed to add a pose. */ - const AssetLibraryReference *asset_library_ref = CTX_wm_asset_library_ref(C); - AssetHandle asset_handle = CTX_wm_asset_handle(C, &asset_handle_valid); + const AssetHandle asset_handle = CTX_wm_asset_handle(C, &asset_handle_
[Bf-blender-cvs] [f68da703a5d] master: Asset system: Initial asset identifier type
Commit: f68da703a5d2731231e0faa5d33eef87d65eedf1 Author: Julian Eisel Date: Wed Nov 30 18:12:42 2022 +0100 Branches: master https://developer.blender.org/rBf68da703a5d2731231e0faa5d33eef87d65eedf1 Asset system: Initial asset identifier type No user visible changes expected. `AssetIdentifier` holds information to uniquely identify and locate an asset. More information: https://wiki.blender.org/wiki/Source/Architecture/Asset_System/Back_End#Asset_Identifier For the start this is tied quite a bit to file paths, so that external assets are assumed to be in the file system. This is needed to support an "All" asset library (see T102879), which would contain assets from different locations. Currently the location of an asset is queried via the file browser backend, which however requires a common root location. It also moves us further away from the file browser towards the asset system (see T87235) and allows us to remove some hacks (see following commit). === A source/blender/asset_system/AS_asset_identifier.hh M source/blender/asset_system/AS_asset_library.hh M source/blender/asset_system/AS_asset_representation.hh M source/blender/asset_system/CMakeLists.txt A source/blender/asset_system/intern/asset_identifier.cc M source/blender/asset_system/intern/asset_library.cc M source/blender/asset_system/intern/asset_representation.cc M source/blender/asset_system/intern/asset_storage.cc M source/blender/asset_system/intern/asset_storage.hh M source/blender/editors/space_file/filelist.cc === diff --git a/source/blender/asset_system/AS_asset_identifier.hh b/source/blender/asset_system/AS_asset_identifier.hh new file mode 100644 index 000..33b7f71becc --- /dev/null +++ b/source/blender/asset_system/AS_asset_identifier.hh @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup asset_system + * + * \brief Information to uniquely identify and locate an asset. + * + * https://wiki.blender.org/wiki/Source/Architecture/Asset_System/Back_End#Asset_Identifier + */ + +#pragma once + +#include +#include + +namespace blender::asset_system { + +class AssetIdentifier { + std::shared_ptr library_root_path_; + std::string relative_asset_path_; + + public: + AssetIdentifier(std::shared_ptr library_root_path, std::string relative_asset_path); + AssetIdentifier(AssetIdentifier &&) = default; + AssetIdentifier(const AssetIdentifier &) = default; + + std::string full_path() const; +}; + +} // namespace blender::asset_system diff --git a/source/blender/asset_system/AS_asset_library.hh b/source/blender/asset_system/AS_asset_library.hh index 7df6e6d9f51..9f9b1b80343 100644 --- a/source/blender/asset_system/AS_asset_library.hh +++ b/source/blender/asset_system/AS_asset_library.hh @@ -24,6 +24,7 @@ struct Main; namespace blender::asset_system { +class AssetIdentifier; class AssetRepresentation; class AssetStorage; @@ -35,8 +36,10 @@ class AssetStorage; */ class AssetLibrary { /** If this is an asset library on disk, the top-level directory path. Normalized using - * #normalize_directory_path().*/ - std::string root_path_; + * #normalize_directory_path(). Shared pointer so assets can safely point to it, and don't have + * to hold a copy (which is the size of `std::string` + the allocated buffer, if no short string + * optimization is used). With thousands of assets this might make a reasonable difference. */ + std::shared_ptr root_path_; /** Storage for assets (better said their representations) that are considered to be part of this * library. Assets are not automatically loaded into this when loading an asset library. Assets @@ -79,10 +82,16 @@ class AssetLibrary { * representation is not needed anymore, it must be freed using #remove_asset(), or there will be * leaking that's only cleared when the library storage is destructed (typically on exit or * loading a different file). + * + * \param relative_asset_path: The path of the asset relative to the asset library root. With + * this the asset must be uniquely identifiable within the asset + * library. */ - AssetRepresentation &add_external_asset(StringRef name, std::unique_ptr metadata); + AssetRepresentation &add_external_asset(StringRef relative_asset_path, + StringRef name, + std::unique_ptr metadata); /** See #AssetLibrary::add_external_asset(). */ - AssetRepresentation &add_local_id_asset(ID &id); + AssetRepresentation &add_local_id_asset(StringRef relative_asset_path, ID &id); /** Remove an asset from the library that was added using #add_external_asset() or * #add_local_id_asset(). Can usually be expected to be co
[Bf-blender-cvs] [39c9164ea18] master: File/Asset Browser: Get full asset path from asset representation
Commit: 39c9164ea1839decfa4f6b8930237864e5be6509 Author: Julian Eisel Date: Wed Nov 30 19:34:11 2022 +0100 Branches: master https://developer.blender.org/rB39c9164ea1839decfa4f6b8930237864e5be6509 File/Asset Browser: Get full asset path from asset representation No user visible changes expected. Add a function to query the full path for a file, so that asset files can get the path via the asset representation and its new asset identifier. This is designed to be a reliable way to locate an asset, and using it is yet another step to rely less on the problematic file browser code. Also, previous code would build the full path manually in a few places, which is good to deduplicate anyway. === M source/blender/editors/space_file/file_ops.c M source/blender/editors/space_file/filelist.cc M source/blender/editors/space_file/filelist.h === diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 6d7365fa136..e9a7080ff35 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2859,12 +2859,12 @@ static bool file_delete_poll(bContext *C) return false; } -static bool file_delete_single(const FileSelectParams *params, +static bool file_delete_single(const struct FileList *files, FileDirEntry *file, const char **r_error_message) { - char str[FILE_MAX]; - BLI_path_join(str, sizeof(str), params->dir, file->relpath); + char str[FILE_MAX_LIBEXTRA]; + filelist_file_get_full_path(files, file, str); if (BLI_delete_soft(str, r_error_message) != 0 || BLI_exists(str)) { return false; } @@ -2876,7 +2876,6 @@ static int file_delete_exec(bContext *C, wmOperator *op) { wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); - FileSelectParams *params = ED_fileselect_get_active_params(sfile); int numfiles = filelist_files_ensure(sfile->files); const char *error_message = NULL; @@ -2885,7 +2884,7 @@ static int file_delete_exec(bContext *C, wmOperator *op) for (int i = 0; i < numfiles; i++) { if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL)) { FileDirEntry *file = filelist_file(sfile->files, i); - if (!file_delete_single(params, file, &error_message)) { + if (!file_delete_single(sfile->files, file, &error_message)) { report_error = true; } } diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index b97f1e27a1a..beb1387b26e 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -1132,6 +1132,18 @@ void filelist_free_icons(void) } } +void filelist_file_get_full_path(const FileList *filelist, const FileDirEntry *file, char *r_path) +{ + if (file->asset) { +const std::string asset_path = AS_asset_representation_full_path_get(file->asset); +BLI_strncpy(r_path, asset_path.c_str(), FILE_MAX_LIBEXTRA); +return; + } + + const char *root = filelist_dir(filelist); + BLI_path_join(r_path, FILE_MAX_LIBEXTRA, root, file->relpath); +} + static FileDirEntry *filelist_geticon_get_file(struct FileList *filelist, const int index) { BLI_assert(G.background == false); @@ -1176,8 +1188,8 @@ ImBuf *filelist_geticon_image(struct FileList *filelist, const int index) return filelist_geticon_image_ex(file); } -static int filelist_geticon_ex(const FileDirEntry *file, - const char *root, +static int filelist_geticon_ex(const FileList *filelist, + const FileDirEntry *file, const bool is_main, const bool ignore_libdir) { @@ -1215,8 +1227,8 @@ static int filelist_geticon_ex(const FileDirEntry *file, if (file->redirection_path) { target = file->redirection_path; } - else if (root) { -BLI_path_join(fullpath, sizeof(fullpath), root, file->relpath); + else if (filelist) { +filelist_file_get_full_path(filelist, file, fullpath); BLI_path_slash_ensure(fullpath, sizeof(fullpath)); } for (; tfsm; tfsm = tfsm->next) { @@ -1296,13 +1308,13 @@ int filelist_geticon(struct FileList *filelist, const int index, const bool is_m { FileDirEntry *file = filelist_geticon_get_file(filelist, index); - return filelist_geticon_ex(file, filelist->filelist.root, is_main, false); + return filelist_geticon_ex(filelist, file, is_main, false); } int ED_file_icon(const FileDirEntry *file) { return file->preview_icon_id ? file->preview_icon_id : - filelist_geticon_ex(file, nullptr, false, false); + filelist_geticon_ex(nullptr, fi
[Bf-blender-cvs] [b582028b127] master: Correct previously missed case of manual path building in file browser
Commit: b582028b127aab86028f422c8f30a5e697714c60 Author: Julian Eisel Date: Wed Nov 30 19:59:26 2022 +0100 Branches: master https://developer.blender.org/rBb582028b127aab86028f422c8f30a5e697714c60 Correct previously missed case of manual path building in file browser Missed in 39c9164ea183. Also adds a comments to point at the function that should be used instead. === M source/blender/editors/space_file/file_draw.c M source/blender/editors/space_file/filelist.h M source/blender/makesdna/DNA_space_types.h === diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index ed0132c6990..e85a6cbc0d4 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -907,7 +907,6 @@ void file_draw_list(const bContext *C, ARegion *region) View2D *v2d = ®ion->v2d; struct FileList *files = sfile->files; struct FileDirEntry *file; - const char *root = filelist_dir(files); ImBuf *imb; uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS); int numfiles; @@ -988,7 +987,6 @@ void file_draw_list(const bContext *C, ARegion *region) for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { uint file_selflag; -char path[FILE_MAX_LIBEXTRA]; const int padx = 0.1f * UI_UNIT_X; int icon_ofs = 0; @@ -997,7 +995,8 @@ void file_draw_list(const bContext *C, ARegion *region) file = filelist_file(files, i); file_selflag = filelist_entry_select_get(sfile->files, file, CHECK_ALL); -BLI_path_join(path, sizeof(path), root, file->relpath); +char path[FILE_MAX_LIBEXTRA]; +filelist_file_get_full_path(files, file, path); if (!(file_selflag & FILE_SEL_EDITING)) { if ((params->highlight_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) || diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index e81a8926eaf..e96ced3fa63 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -94,6 +94,10 @@ void filelist_clear_ex(struct FileList *filelist, void filelist_clear_from_reset_tag(struct FileList *filelist); void filelist_free(struct FileList *filelist); +/** + * Get the root path of the file list. To get the full path for a file, use + * #filelist_file_get_full_path(). + */ const char *filelist_dir(const struct FileList *filelist); bool filelist_is_dir(struct FileList *filelist, const char *path); /** diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 36c15b6e106..72e39647093 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1123,7 +1123,8 @@ typedef struct FileDirEntry { /** ID type, in case typeflag has FILE_TYPE_BLENDERLIB set. */ int blentype; - /* Path to item that is relative to current folder root. */ + /* Path to item that is relative to current folder root. To get the full path, use + * #filelist_file_get_full_path() */ char *relpath; /** Optional argument for shortcuts, aliases etc. */ char *redirection_path; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [692474ccf92] blender-v3.4-release: Release cycle: Bump BLENDER_VERSION_CYCLE to rc for 3.4.
Commit: 692474ccf921716862d65c3c708bead7fdefa057 Author: Thomas Dinges Date: Wed Nov 30 20:04:37 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB692474ccf921716862d65c3c708bead7fdefa057 Release cycle: Bump BLENDER_VERSION_CYCLE to rc for 3.4. === M source/blender/blenkernel/BKE_blender_version.h === diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index a7150913290..c6acc1d9f2c 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -21,7 +21,7 @@ extern "C" { /* Blender patch version for bugfix releases. */ #define BLENDER_VERSION_PATCH 0 /** Blender release cycle stage: alpha/beta/rc/release. */ -#define BLENDER_VERSION_CYCLE beta +#define BLENDER_VERSION_CYCLE rc /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f37e8c2e96d] master: Merge branch 'blender-v3.4-release'
Commit: f37e8c2e96df97980de8fe14a11bc7cbb41bd10c Author: Thomas Dinges Date: Wed Nov 30 20:08:31 2022 +0100 Branches: master https://developer.blender.org/rBf37e8c2e96df97980de8fe14a11bc7cbb41bd10c Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [31b3b07ad77] master: Cleanup: Remove useless comments in node.cc
Commit: 31b3b07ad77aabef13dcfff4b2a5c1038547c3fd Author: Hans Goudey Date: Wed Nov 30 13:06:54 2022 -0600 Branches: master https://developer.blender.org/rB31b3b07ad77aabef13dcfff4b2a5c1038547c3fd Cleanup: Remove useless comments in node.cc Also remove unnecessary `struct` keywords. === M source/blender/blenkernel/intern/node.cc === diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 827dbd2b6f9..8e160607e04 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -876,7 +876,7 @@ static void lib_link_node_sockets(BlendLibReader *reader, Library *lib, ListBase } } -void ntreeBlendReadLib(struct BlendLibReader *reader, struct bNodeTree *ntree) +void ntreeBlendReadLib(BlendLibReader *reader, bNodeTree *ntree) { Library *lib = ntree->id.lib; @@ -1002,7 +1002,7 @@ static void ntree_blend_read_expand(BlendExpander *expander, ID *id) namespace blender::bke { -static void node_tree_asset_pre_save(void *asset_ptr, struct AssetMetaData *asset_data) +static void node_tree_asset_pre_save(void *asset_ptr, AssetMetaData *asset_data) { bNodeTree &node_tree = *static_cast(asset_ptr); @@ -1085,7 +1085,7 @@ static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType * The #bNodeType may not be registered at creation time of the node, * so this can be delayed until the node type gets registered. */ -static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node) +static void node_init(const bContext *C, bNodeTree *ntree, bNode *node) { bNodeType *ntype = node->typeinfo; if (ntype == &NodeTypeUndefined) { @@ -1126,7 +1126,6 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node) id_us_plus(node->id); } - /* extra init callback */ if (ntype->initfunc_api) { PointerRNA ptr; RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr); @@ -1154,7 +1153,7 @@ static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo) BKE_ntree_update_tag_all(ntree); } -static void node_set_typeinfo(const struct bContext *C, +static void node_set_typeinfo(const bContext *C, bNodeTree *ntree, bNode *node, bNodeType *typeinfo) @@ -1206,7 +1205,7 @@ static void node_socket_set_typeinfo(bNodeTree *ntree, /* Set specific typeinfo pointers in all node trees on register/unregister */ static void update_typeinfo(Main *bmain, -const struct bContext *C, +const bContext *C, bNodeTreeType *treetype, bNodeType *nodetype, bNodeSocketType *socktype, @@ -1255,7 +1254,7 @@ static void update_typeinfo(Main *bmain, FOREACH_NODETREE_END; } -void ntreeSetTypes(const struct bContext *C, bNodeTree *ntree) +void ntreeSetTypes(const bContext *C, bNodeTree *ntree) { ntree_set_typeinfo(ntree, ntreeTypeFind(ntree->idname)); @@ -1303,7 +1302,6 @@ void ntreeTypeAdd(bNodeTreeType *nt) update_typeinfo(G_MAIN, nullptr, nt, nullptr, nullptr, false); } -/* callback for hash value free function */ static void ntree_free_type(void *treetype_v) { bNodeTreeType *treetype = (bNodeTreeType *)treetype_v; @@ -1341,7 +1339,6 @@ bNodeType *nodeTypeFind(const char *idname) return nullptr; } -/* callback for hash value free function */ static void node_free_type(void *nodetype_v) { bNodeType *nodetype = (bNodeType *)nodetype_v; @@ -1409,7 +1406,6 @@ bNodeSocketType *nodeSocketTypeFind(const char *idname) return nullptr; } -/* callback for hash value free function */ static void node_free_socket_type(void *socktype_v) { bNodeSocketType *socktype = (bNodeSocketType *)socktype_v; @@ -1451,9 +1447,7 @@ const char *nodeSocketTypeLabel(const bNodeSocketType *stype) return stype->label[0] != '\0' ? stype->label : RNA_struct_ui_name(stype->ext_socket.srna); } -struct bNodeSocket *nodeFindSocket(const bNode *node, - eNodeSocketInOut in_out, - const char *identifier) +bNodeSocket *nodeFindSocket(const bNode *node, eNodeSocketInOut in_out, const char *identifier) { const ListBase *sockets = (in_out == SOCK_IN) ? &node->inputs : &node->outputs; LISTBASE_FOREACH (bNodeSocket *, sock, sockets) { @@ -1491,7 +1485,6 @@ bNodeSocket *node_find_enabled_output_socket(bNode &node, StringRef name) } // namespace blender::bke -/* find unique socket identifier */ static bool unique_identifier_check(void *arg, const char *identifier) { const ListBase *lb = (const ListBase *)arg; @@ -1703,7 +1696,7 @@ bNodeSocket *nodeAddSocket(bNodeTree *ntree, return sock; } -b
[Bf-blender-cvs] [2c2515d4657] temp-asset-library-all: Merge branch 'master' into temp-asset-library-all
Commit: 2c2515d46573c0c407e134253782d917883edb08 Author: Julian Eisel Date: Tue Nov 29 11:14:41 2022 +0100 Branches: temp-asset-library-all https://developer.blender.org/rB2c2515d46573c0c407e134253782d917883edb08 Merge branch 'master' into temp-asset-library-all === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [03bd4371702] temp-asset-library-all: Merge branch 'master' into temp-asset-library-all
Commit: 03bd43717027ef4318c30edf611e4f32d94f1a95 Author: Julian Eisel Date: Wed Nov 30 19:49:29 2022 +0100 Branches: temp-asset-library-all https://developer.blender.org/rB03bd43717027ef4318c30edf611e4f32d94f1a95 Merge branch 'master' into temp-asset-library-all === === diff --cc source/blender/asset_system/intern/asset_library.cc index 79c3c55029c,2f3b56d226a..043d1a45ef2 --- a/source/blender/asset_system/intern/asset_library.cc +++ b/source/blender/asset_system/intern/asset_library.cc @@@ -249,7 -235,11 +253,12 @@@ void AssetLibrary::refresh_catalog_simp STRNCPY(asset_data->catalog_simple_name, catalog->simple_name.c_str()); } + StringRefNull AssetLibrary::root_path() const + { + return *root_path_; + } + +/* TODO get rid of this. */ Vector all_valid_asset_library_refs() { Vector result; diff --cc source/blender/asset_system/intern/asset_storage.hh index 0814c258442,2b4614abca5..b4866fa9382 --- a/source/blender/asset_system/intern/asset_storage.hh +++ b/source/blender/asset_system/intern/asset_storage.hh @@@ -30,13 -31,13 +31,15 @@@ class AssetStorage * faster lookups. Not possible until each asset is only represented once in the storage. */ StorageT local_id_assets_; + friend class AssetLibrary; + public: /** See #AssetLibrary::add_external_asset(). */ - AssetRepresentation &add_external_asset(StringRef name, std::unique_ptr metadata); + AssetRepresentation &add_external_asset(AssetIdentifier &&identifier, + StringRef name, + std::unique_ptr metadata); /** See #AssetLibrary::add_external_asset(). */ - AssetRepresentation &add_local_id_asset(ID &id); + AssetRepresentation &add_local_id_asset(AssetIdentifier &&identifier, ID &id); /** See #AssetLibrary::remove_asset(). */ bool remove_asset(AssetRepresentation &asset); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3f1e4f6f56d] temp-asset-library-all: Merge branch 'master' into temp-asset-library-all
Commit: 3f1e4f6f56d3c4bba24a0d70ea7779918d9565a4 Author: Julian Eisel Date: Wed Nov 30 20:02:29 2022 +0100 Branches: temp-asset-library-all https://developer.blender.org/rB3f1e4f6f56d3c4bba24a0d70ea7779918d9565a4 Merge branch 'master' into temp-asset-library-all === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [126136baaba] temp-asset-library-all: Fix missing asset previews and broken drag & drop in "All" library
Commit: 126136baabac679e95d578267d2b4f042dc5f9bd Author: Julian Eisel Date: Wed Nov 30 20:15:04 2022 +0100 Branches: temp-asset-library-all https://developer.blender.org/rB126136baabac679e95d578267d2b4f042dc5f9bd Fix missing asset previews and broken drag & drop in "All" library Together with the changes made in master, all this does is making sure the assets are loaded and removed using the correct asset library nested within the "All" library. Now full paths for the assets can be built correctly from the asset identifier, which fixes preview loading and drag & drop. === M source/blender/asset_system/AS_asset_library.hh M source/blender/asset_system/intern/asset_library.cc M source/blender/editors/space_file/filelist.cc === diff --git a/source/blender/asset_system/AS_asset_library.hh b/source/blender/asset_system/AS_asset_library.hh index cb75a2540ff..561452d3ac8 100644 --- a/source/blender/asset_system/AS_asset_library.hh +++ b/source/blender/asset_system/AS_asset_library.hh @@ -101,6 +101,9 @@ class AssetLibrary { /** Remove an asset from the library that was added using #add_external_asset() or * #add_local_id_asset(). Can usually be expected to be constant time complexity (worst case may * differ). + * Can also be called when this asset library is just a merged library containing multiple nested + * ones ("All" library). Will then check if it exists in a nested library and remove it. + * * \note This is save to call if \a asset is freed (dangling reference), will not perform any * change then. * \return True on success, false if the asset couldn't be found inside the library (also the diff --git a/source/blender/asset_system/intern/asset_library.cc b/source/blender/asset_system/intern/asset_library.cc index 043d1a45ef2..944e91bcf4d 100644 --- a/source/blender/asset_system/intern/asset_library.cc +++ b/source/blender/asset_system/intern/asset_library.cc @@ -170,7 +170,24 @@ AssetRepresentation &AssetLibrary::add_local_id_asset(StringRef relative_asset_p bool AssetLibrary::remove_asset(AssetRepresentation &asset) { - return asset_storage_->remove_asset(asset); + /* Usual case, only the "All" library differs and uses nested libraries (see below). */ + if (asset_storage_->remove_asset(asset)) { +return true; + } + + /* If asset is not stored in this library, check nested ones (for "All" library). */ + for (AssetLibrary *library : nested_libs_) { +if (!library) { + BLI_assert_unreachable(); + continue; +} + +if (asset_storage_->remove_asset(asset)) { + return true; +} + } + + return false; } void AssetLibrary::foreach_nested(FunctionRef fn) diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 5039fcdce5a..9d1191ad80e 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -2928,6 +2928,11 @@ struct FileListReadJob { * `Materials/Material.001`). */ char cur_relbase[FILE_MAX_LIBEXTRA]; + /** The current asset library to load. Usually the same as #FileList.asset_library, however + * sometimes the #FileList one is a combination of multiple other ones ("All" asset library), + * which need to be loaded individually. Then this can be set to override the #FileList library. + * Use this in all loading code. */ + asset_system::AssetLibrary *load_asset_library; /** Set to request a partial read that only adds files representing #Main data (IDs). Used when * #Main may have received changes of interest (e.g. asset removed or renamed). */ bool only_main_data; @@ -3105,7 +3110,6 @@ static void filelist_readjob_list_lib_add_datablock(FileListReadJob *job_params, const int idcode, const char *group_name) { - FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ FileListInternEntry *entry = MEM_cnew(__func__); if (prefix_relpath_with_group_name) { std::string datablock_path = StringRef(group_name) + "/" + datablock_info->name; @@ -3121,13 +3125,13 @@ static void filelist_readjob_list_lib_add_datablock(FileListReadJob *job_params, if (datablock_info->asset_data) { entry->typeflag |= FILE_TYPE_ASSET; - if (filelist->asset_library) { + if (job_params->load_asset_library) { /** XXX Moving out the asset metadata like this isn't great. */ std::unique_ptr metadata = BKE_asset_metadata_move_to_unique_ptr( datablock_info->asset_data); BKE_asset_metadata_free(&datablock_info->asset_data); -entry->asset = &filelist->asset_library->add_external_asset( +entry->asset = &job_params->load_asset_library->add_ex
[Bf-blender-cvs] [db1728096ab] master: Cleanup: Remove unused node socket cache handling
Commit: db1728096ab6bcd05f7b4f087c060a6349b5b2ce Author: Hans Goudey Date: Wed Nov 30 13:25:06 2022 -0600 Branches: master https://developer.blender.org/rBdb1728096ab6bcd05f7b4f087c060a6349b5b2ce Cleanup: Remove unused node socket cache handling This cache was never written to, only "copied" between sockets in one case, it dates back at least a decade. It doesn't make sense to store caches on node trees directly anyway, since they can be used in multiple places. === M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/BKE_node_runtime.hh M source/blender/blenkernel/intern/node.cc M source/blender/editors/space_node/node_group.cc M source/blender/nodes/composite/node_composite_tree.cc M source/blender/nodes/composite/node_composite_util.cc M source/blender/render/intern/pipeline.cc === diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index a8e28ba492a..2cd2fa9ac62 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -405,8 +405,6 @@ typedef struct bNodeTreeType { int ui_icon; /* callbacks */ - void (*free_cache)(struct bNodeTree *ntree); - void (*free_node_cache)(struct bNodeTree *ntree, struct bNode *node); /* Iteration over all node classes. */ void (*foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func); /* Check visibility in the node editor */ @@ -521,8 +519,6 @@ void ntreeUpdateAllUsers(struct Main *main, struct ID *id); */ void ntreeSetOutput(struct bNodeTree *ntree); -void ntreeFreeCache(struct bNodeTree *ntree); - void ntreeNodeFlagSet(const bNodeTree *ntree, int flag, bool enable); /** * Returns localized tree for execution in threads. diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh index ef32dcd8351..56d51169934 100644 --- a/source/blender/blenkernel/BKE_node_runtime.hh +++ b/source/blender/blenkernel/BKE_node_runtime.hh @@ -133,9 +133,6 @@ class bNodeSocketRuntime : NonCopyable, NonMovable { /* Runtime-only cache of the number of input links, for multi-input sockets. */ short total_inputs = 0; - /** Cached data from execution. */ - void *cache = nullptr; - /** Only valid when #topology_cache_is_dirty is false. */ Vector directly_linked_links; Vector directly_linked_sockets; diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 8e160607e04..7c437f8fa9f 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2234,9 +2234,6 @@ static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src, MEM_dupallocN(sock_src->default_attribute_name)); sock_dst->stack_index = 0; - /* XXX some compositor nodes (e.g. image, render layers) still store - * some persistent buffer data here, need to clear this to avoid dangling pointers. */ - sock_dst->runtime->cache = nullptr; } namespace blender::bke { @@ -2923,10 +2920,6 @@ static void node_free_node(bNodeTree *ntree, bNode *node) if (ntree) { BLI_remlink(&ntree->nodes, node); -if (ntree->typeinfo->free_node_cache) { - ntree->typeinfo->free_node_cache(ntree, node); -} - /* texture node has bad habit of keeping exec data around */ if (ntree->type == NTREE_TEXTURE && ntree->runtime->execdata) { ntreeTexEndExecTree(ntree->runtime->execdata); @@ -3107,17 +3100,6 @@ void ntreeFreeLocalTree(bNodeTree *ntree) } } -void ntreeFreeCache(bNodeTree *ntree) -{ - if (ntree == nullptr) { -return; - } - - if (ntree->typeinfo->free_cache) { -ntree->typeinfo->free_cache(ntree); - } -} - void ntreeSetOutput(bNodeTree *ntree) { /* find the active outputs, might become tree type dependent handler */ diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc index b6c062a2a83..f95561035a3 100644 --- a/source/blender/editors/space_node/node_group.cc +++ b/source/blender/editors/space_node/node_group.cc @@ -889,9 +889,6 @@ static void node_group_make_insert_selected(const bContext &C, bNodeTree &ntree, } } - /* node groups don't use internal cached data */ - ntreeFreeCache(ngroup); - /* create input node */ bNode *input_node = nodeAddStaticNode(&C, ngroup, NODE_GROUP_INPUT); input_node->locx = real_min[0] - center[0] - offsetx; diff --git a/source/blender/nodes/composite/node_composite_tree.cc b/source/blender/nodes/composite/node_composite_tree.cc index d821733244f..a2a3d7d1b64 100644 --- a/source/blender/nodes/composite/node_composite_tree.cc +++ b/source/blender/nodes/composite/node_composite_tree.cc @@ -62,22 +62,6 @@ static void foreach_nodeclass(Scene * /*scene*/, void *calldata, bNodeClassCallb func(ca
[Bf-blender-cvs] [b25c301c15d] master: Build: make CUDA kernel compilation output not verbose
Commit: b25c301c15dc078fa4f0c12aed1e2ffa256dc9a2 Author: Brecht Van Lommel Date: Wed Nov 30 21:11:41 2022 +0100 Branches: master https://developer.blender.org/rBb25c301c15dc078fa4f0c12aed1e2ffa256dc9a2 Build: make CUDA kernel compilation output not verbose Unless using WITH_CYCLES_DEBUG. This is convenient for investigating kernel performance, but too verbose to always have in the buildbot logs especially now that we are also compiling HIP and OneAPI kernels. === M intern/cycles/kernel/CMakeLists.txt === diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index dd96cfd5058..cb1f720af26 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -472,6 +472,7 @@ if(WITH_CYCLES_CUDA_BINARIES) if(WITH_CYCLES_DEBUG) set(cuda_flags ${cuda_flags} -D WITH_CYCLES_DEBUG) + set(cuda_flags ${cuda_flags} --ptxas-options="-v") endif() set(_cuda_nvcc_args @@ -479,7 +480,6 @@ if(WITH_CYCLES_CUDA_BINARIES) ${CUDA_NVCC_FLAGS} --${format} ${CMAKE_CURRENT_SOURCE_DIR}${cuda_kernel_src} - --ptxas-options="-v" ${cuda_flags}) if(WITH_COMPILER_CCACHE AND CCACHE_PROGRAM) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ac51d331dfb] master: Refactor: Cycles light sampling code reorganization
Commit: ac51d331dfbdccb3ec6d4b7cb60909fe01d1a333 Author: Brecht Van Lommel Date: Wed Nov 30 20:17:45 2022 +0100 Branches: master https://developer.blender.org/rBac51d331dfbdccb3ec6d4b7cb60909fe01d1a333 Refactor: Cycles light sampling code reorganization * Split light types into own files, move light type specific code from light tree and MNEE. * Move flat light distribution code into own kernel file and host side building function, in preparation of light tree addition. Add light/sample.h as main entry point to kernel light sampling. * Better separate calculation of pdf for selecting a light, and pdf for sampling a point on the light. The selection pdf is now also stored in LightSampling for MNEE to correctly recalculate the full pdf when the shading position changes but the point on the light remains fixed. * Improvement to kernel light storage, using packed_float3, better variable names, etc. Includes contributions by Brecht Van Lommel and Weizhen Huang. Ref T77889 === M intern/cycles/kernel/CMakeLists.txt M intern/cycles/kernel/data_template.h M intern/cycles/kernel/integrator/intersect_closest.h M intern/cycles/kernel/integrator/mnee.h M intern/cycles/kernel/integrator/shade_background.h M intern/cycles/kernel/integrator/shade_light.h M intern/cycles/kernel/integrator/shade_surface.h M intern/cycles/kernel/integrator/shade_volume.h A intern/cycles/kernel/light/area.h M intern/cycles/kernel/light/background.h M intern/cycles/kernel/light/common.h A intern/cycles/kernel/light/distant.h A intern/cycles/kernel/light/distribution.h M intern/cycles/kernel/light/light.h A intern/cycles/kernel/light/point.h M intern/cycles/kernel/light/sample.h A intern/cycles/kernel/light/spot.h A intern/cycles/kernel/light/triangle.h M intern/cycles/kernel/types.h M intern/cycles/scene/background.cpp M intern/cycles/scene/light.cpp M intern/cycles/scene/light.h === diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 3f03118b105..dd96cfd5058 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -285,10 +285,16 @@ set(SRC_KERNEL_INTEGRATOR_HEADERS ) set(SRC_KERNEL_LIGHT_HEADERS - light/light.h + light/area.h light/background.h light/common.h + light/distant.h + light/distribution.h + light/light.h + light/point.h light/sample.h + light/spot.h + light/triangle.h ) set(SRC_KERNEL_SAMPLE_HEADERS diff --git a/intern/cycles/kernel/data_template.h b/intern/cycles/kernel/data_template.h index c7b50b20c70..9a44b21543c 100644 --- a/intern/cycles/kernel/data_template.h +++ b/intern/cycles/kernel/data_template.h @@ -23,24 +23,19 @@ KERNEL_STRUCT_MEMBER(background, int, volume_shader) KERNEL_STRUCT_MEMBER(background, float, volume_step_size) KERNEL_STRUCT_MEMBER(background, int, transparent) KERNEL_STRUCT_MEMBER(background, float, transparent_roughness_squared_threshold) -/* Portal sampling. */ -KERNEL_STRUCT_MEMBER(background, float, portal_weight) -KERNEL_STRUCT_MEMBER(background, int, num_portals) -KERNEL_STRUCT_MEMBER(background, int, portal_offset) /* Sun sampling. */ KERNEL_STRUCT_MEMBER(background, float, sun_weight) /* Importance map sampling. */ KERNEL_STRUCT_MEMBER(background, float, map_weight) +KERNEL_STRUCT_MEMBER(background, float, portal_weight) KERNEL_STRUCT_MEMBER(background, int, map_res_x) KERNEL_STRUCT_MEMBER(background, int, map_res_y) /* Multiple importance sampling. */ KERNEL_STRUCT_MEMBER(background, int, use_mis) /* Lightgroup. */ KERNEL_STRUCT_MEMBER(background, int, lightgroup) -/* Padding. */ -KERNEL_STRUCT_MEMBER(background, int, pad1) -KERNEL_STRUCT_MEMBER(background, int, pad2) -KERNEL_STRUCT_MEMBER(background, int, pad3) +/* Light Index. */ +KERNEL_STRUCT_MEMBER(background, int, light_index) KERNEL_STRUCT_END(KernelBackground) /* BVH: own BVH2 if no native device acceleration struct used. */ @@ -147,10 +142,17 @@ KERNEL_STRUCT_END(KernelFilm) KERNEL_STRUCT_BEGIN(KernelIntegrator, integrator) /* Emission. */ KERNEL_STRUCT_MEMBER(integrator, int, use_direct_light) +KERNEL_STRUCT_MEMBER(integrator, int, use_light_mis) +KERNEL_STRUCT_MEMBER(integrator, int, num_lights) +KERNEL_STRUCT_MEMBER(integrator, int, num_distant_lights) +KERNEL_STRUCT_MEMBER(integrator, int, num_background_lights) +/* Portal sampling. */ +KERNEL_STRUCT_MEMBER(integrator, int, num_portals) +KERNEL_STRUCT_MEMBER(integrator, int, portal_offset) +/* Flat light distribution. */ KERNEL_STRUCT_MEMBER(integrator, int, num_distribution) -KERNEL_STRUCT_MEMBER(integrator, int, num_all_lights) -KERNEL_STRUCT_MEMBER(integrator, float, pdf_triangles) -KERNEL_STRUCT_MEMBER(integrator, float, pdf_lights) +KERNEL_STRUCT_MEMBER(integrator, float, di
[Bf-blender-cvs] [396b407c7d1] master: Cycles: new setting and heuristics for mesh light importance sampling
Commit: 396b407c7d14d2ad4fb43da196b7ea0cc5891fe6 Author: Brecht Van Lommel Date: Wed Nov 30 20:50:11 2022 +0100 Branches: master https://developer.blender.org/rB396b407c7d14d2ad4fb43da196b7ea0cc5891fe6 Cycles: new setting and heuristics for mesh light importance sampling Materials now have an enum to set the emission sampling method, to be either None, Auto, Front, Back or Front & Back. This replace the previous "Multiple Importance Sample" option. Auto is the new default, and uses a heuristic to estimate the emitted light intensity to determine of the mesh should be considered as a light for sampling. Shaders sometimes have a bit of emission but treating them as a light source is not worth the memory/performance overhead. The Front/Back settings are not important yet, but will help when a light tree is added. In that case setting emission to Front only on closed meshes can help ignore emission from inside the mesh interior that does not contribute anything. Includes contributions by Brecht Van Lommel and Alaska. Ref T77889 === M intern/cycles/blender/addon/properties.py M intern/cycles/blender/addon/ui.py M intern/cycles/blender/addon/version_update.py M intern/cycles/blender/shader.cpp M intern/cycles/kernel/closure/bsdf_diffuse.h M intern/cycles/kernel/closure/bsdf_hair.h M intern/cycles/kernel/closure/bsdf_hair_principled.h M intern/cycles/kernel/closure/bsdf_microfacet.h M intern/cycles/kernel/closure/bsdf_microfacet_multi.h M intern/cycles/kernel/integrator/path_state.h M intern/cycles/kernel/integrator/shade_surface.h M intern/cycles/kernel/integrator/shade_volume.h M intern/cycles/kernel/types.h M intern/cycles/scene/geometry.cpp M intern/cycles/scene/light.cpp M intern/cycles/scene/object.cpp M intern/cycles/scene/osl.cpp M intern/cycles/scene/shader.cpp M intern/cycles/scene/shader.h M intern/cycles/scene/shader_graph.h M intern/cycles/scene/shader_nodes.cpp M intern/cycles/scene/shader_nodes.h M intern/cycles/scene/svm.cpp M source/blender/blenkernel/BKE_blender_version.h === diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 9d7c71417f2..b8fb67deb52 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -86,6 +86,14 @@ enum_sampling_pattern = ( ('PROGRESSIVE_MULTI_JITTER', "Progressive Multi-Jitter", "Use Progressive Multi-Jitter random sampling pattern", 1), ) +enum_emission_sampling = ( +('NONE', 'None', "Do not use this surface as a light for sampling", 0), +('AUTO', 'Auto', "Automatically determine if the surface should be treated as a light for sampling, based on estimated emission intensity", 1), +('FRONT', 'Front', "Treat only front side of the surface as a light, usually for closed meshes whose interior is not visible", 2), +('BACK', 'Back', "Treat only back side of the surface as a light for sampling", 3), +('FRONT_BACK', 'Front and Back', "Treat surface as a light for sampling, emitting from both the front and back side", 4), +) + enum_volume_sampling = ( ('DISTANCE', "Distance", @@ -1043,13 +1051,13 @@ class CyclesCameraSettings(bpy.types.PropertyGroup): class CyclesMaterialSettings(bpy.types.PropertyGroup): -sample_as_light: BoolProperty( -name="Multiple Importance Sample", -description="Use multiple importance sampling for this material, " -"disabling may reduce overall noise for large " -"objects that emit little light compared to other light sources", -default=True, +emission_sampling: EnumProperty( +name="Emission Sampling", +description="Sampling strategy for emissive surfaces", +items=enum_emission_sampling, +default="AUTO", ) + use_transparent_shadow: BoolProperty( name="Transparent Shadows", description="Use transparent shadows for this material if it contains a Transparent BSDF, " diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 60a7ee9708d..959b945461e 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1832,9 +1832,9 @@ class CYCLES_MATERIAL_PT_settings_surface(CyclesButtonsPanel, Panel): cmat = mat.cycles col = layout.column() -col.prop(cmat, "sample_as_light", text="Multiple Importance") -col.prop(cmat, "use_transparent_shadow") col.prop(cmat, "displacement_method", text="Displacement") +col.prop(cmat, "emission_sampling") +col.prop(cmat, "use_transparent_shadow") def draw(self, context): self.draw_shared(self, context.material) diff --git a/intern/cycles/blender/addon/version
[Bf-blender-cvs] [894df862d8b] soc-2022-many-lights-sampling: Merge branch 'master' into soc-2022-many-lights-sampling
Commit: 894df862d8b222ccbac00db639fc80cc191411a3 Author: Brecht Van Lommel Date: Wed Nov 30 21:27:16 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB894df862d8b222ccbac00db639fc80cc191411a3 Merge branch 'master' into soc-2022-many-lights-sampling === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [222b64fcdc8] master: Fix Cycles CUDA crash when building kernels without optimizations (for debug)
Commit: 222b64fcdc8166266eca10bb16c1cebb2bda8923 Author: Brecht Van Lommel Date: Wed Nov 30 21:38:57 2022 +0100 Branches: master https://developer.blender.org/rB222b64fcdc8166266eca10bb16c1cebb2bda8923 Fix Cycles CUDA crash when building kernels without optimizations (for debug) In this case the blocksize may not the one we requested, which was assumed to be the case. Instead get the effective block size from the compiler as was already done for Metal and OneAPI. === M intern/cycles/kernel/device/gpu/kernel.h M intern/cycles/kernel/device/gpu/parallel_active_index.h === diff --git a/intern/cycles/kernel/device/gpu/kernel.h b/intern/cycles/kernel/device/gpu/kernel.h index d7d2000775f..a44bd1dece7 100644 --- a/intern/cycles/kernel/device/gpu/kernel.h +++ b/intern/cycles/kernel/device/gpu/kernel.h @@ -314,11 +314,7 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) int kernel_index); ccl_gpu_kernel_lambda_pass.kernel_index = kernel_index; - gpu_parallel_active_index_array(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE, - num_states, - indices, - num_indices, - ccl_gpu_kernel_lambda_pass); + gpu_parallel_active_index_array(num_states, indices, num_indices, ccl_gpu_kernel_lambda_pass); } ccl_gpu_kernel_postfix @@ -333,11 +329,7 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) int kernel_index); ccl_gpu_kernel_lambda_pass.kernel_index = kernel_index; - gpu_parallel_active_index_array(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE, - num_states, - indices, - num_indices, - ccl_gpu_kernel_lambda_pass); + gpu_parallel_active_index_array(num_states, indices, num_indices, ccl_gpu_kernel_lambda_pass); } ccl_gpu_kernel_postfix @@ -349,11 +341,7 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) { ccl_gpu_kernel_lambda(INTEGRATOR_STATE(state, path, queued_kernel) != 0); - gpu_parallel_active_index_array(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE, - num_states, - indices, - num_indices, - ccl_gpu_kernel_lambda_pass); + gpu_parallel_active_index_array(num_states, indices, num_indices, ccl_gpu_kernel_lambda_pass); } ccl_gpu_kernel_postfix @@ -366,11 +354,8 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) { ccl_gpu_kernel_lambda(INTEGRATOR_STATE(state, path, queued_kernel) == 0); - gpu_parallel_active_index_array(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE, - num_states, - indices + indices_offset, - num_indices, - ccl_gpu_kernel_lambda_pass); + gpu_parallel_active_index_array( + num_states, indices + indices_offset, num_indices, ccl_gpu_kernel_lambda_pass); } ccl_gpu_kernel_postfix @@ -383,11 +368,8 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) { ccl_gpu_kernel_lambda(INTEGRATOR_STATE(state, shadow_path, queued_kernel) == 0); - gpu_parallel_active_index_array(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE, - num_states, - indices + indices_offset, - num_indices, - ccl_gpu_kernel_lambda_pass); + gpu_parallel_active_index_array( + num_states, indices + indices_offset, num_indices, ccl_gpu_kernel_lambda_pass); } ccl_gpu_kernel_postfix @@ -431,11 +413,7 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) int num_active_paths); ccl_gpu_kernel_lambda_pass.num_active_paths = num_active_paths; - gpu_parallel_active_index_array(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE, - num_states, - indices, - num_indices, - ccl_gpu_kernel_lambda_pass); + gpu_parallel_active_index_array(num_states, indices, num_indices, ccl_gpu_kernel_lambda_pass); } ccl_gpu_kernel_postfix @@ -469,11 +447,7 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) int num_active_paths); ccl_gpu_kernel_lambda_pass.num_active_paths = num_active_paths; - gpu_parallel_active_index_array(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE, - num_states, -
[Bf-blender-cvs] [7151c2dc3e1] master: Cleanup: Unused variable, RNA description warning
Commit: 7151c2dc3e1bf91b5cc2c9931cff510a73be1542 Author: Hans Goudey Date: Wed Nov 30 15:34:08 2022 -0600 Branches: master https://developer.blender.org/rB7151c2dc3e1bf91b5cc2c9931cff510a73be1542 Cleanup: Unused variable, RNA description warning === M source/blender/makesrna/intern/rna_asset.c M source/blender/nodes/composite/node_composite_tree.cc === diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c index e7eb6a022ba..76751f1d9f1 100644 --- a/source/blender/makesrna/intern/rna_asset.c +++ b/source/blender/makesrna/intern/rna_asset.c @@ -434,7 +434,7 @@ static void rna_def_asset_handle_api(StructRNA *srna) "AssetLibraryReference", "", "The asset library containing the given asset. Deprecated and optional argument, will be " - "ignored. Kept for API compatibility only."); + "ignored. Kept for API compatibility only"); parm = RNA_def_string(func, "result", NULL, FILE_MAX_LIBEXTRA, "result", ""); RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); RNA_def_function_output(func, parm); diff --git a/source/blender/nodes/composite/node_composite_tree.cc b/source/blender/nodes/composite/node_composite_tree.cc index a2a3d7d1b64..60557b5d893 100644 --- a/source/blender/nodes/composite/node_composite_tree.cc +++ b/source/blender/nodes/composite/node_composite_tree.cc @@ -95,13 +95,10 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) static void local_merge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) { - bNode *lnode; - bNodeSocket *lsock; - /* move over the compbufs and previews */ BKE_node_preview_merge_tree(ntree, localtree, true); - for (lnode = (bNode *)localtree->nodes.first; lnode; lnode = lnode->next) { + for (bNode *lnode = (bNode *)localtree->nodes.first; lnode; lnode = lnode->next) { if (bNode *orig_node = nodeFindNodebyName(ntree, lnode->name)) { if (ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { if (lnode->id && (lnode->flag & NODE_DO_OUTPUT)) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fde628ddb32] blender-v3.4-release: Sculpt: Fix broken pivots when entering paint modes
Commit: fde628ddb324660c715c0b8fd345f002eb993beb Author: Joseph Eagar Date: Wed Nov 30 12:36:29 2022 -0800 Branches: blender-v3.4-release https://developer.blender.org/rBfde628ddb324660c715c0b8fd345f002eb993beb Sculpt: Fix broken pivots when entering paint modes When entering paint modes the paint pivot was cleared, which broken rotate around pivot. Fixed for all paint modes. PBVH modes set the pivot to the PBVH bounding box while texture paint uses the evaluated mesh bounding box. === M source/blender/editors/include/ED_object.h M source/blender/editors/sculpt_paint/paint_cursor.c M source/blender/editors/sculpt_paint/paint_image.cc M source/blender/editors/sculpt_paint/paint_vertex.cc M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/editors/sculpt_paint/sculpt_ops.c === diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index acb0e53aa55..9e8d9636a29 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -293,7 +293,10 @@ void ED_object_vpaintmode_exit(struct bContext *C); void ED_object_wpaintmode_exit_ex(struct Object *ob); void ED_object_wpaintmode_exit(struct bContext *C); -void ED_object_texture_paint_mode_enter_ex(struct Main *bmain, struct Scene *scene, Object *ob); +void ED_object_texture_paint_mode_enter_ex(struct Main *bmain, + struct Scene *scene, + struct Depsgraph *depsgraph, + Object *ob); void ED_object_texture_paint_mode_enter(struct bContext *C); void ED_object_texture_paint_mode_exit_ex(struct Main *bmain, struct Scene *scene, Object *ob); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index b6e83187c86..c2fde7c2117 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -15,6 +15,7 @@ #include "DNA_brush_types.h" #include "DNA_color_types.h" #include "DNA_customdata_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -27,6 +28,7 @@ #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_image.h" +#include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_paint.h" diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index 8c6358520ca..eebc1bdb4b9 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -34,11 +34,14 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mesh.h" +#include "BKE_object.h" #include "BKE_paint.h" +#include "BKE_scene.h" #include "NOD_texture.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "UI_interface.h" #include "UI_view2d.h" @@ -755,7 +758,34 @@ void PAINT_OT_sample_color(wmOperatorType *ot) / texture paint toggle operator / -void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object *ob) +static void paint_init_pivot(Object *ob, Scene *scene) +{ + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; + + const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); + if (!me_eval) { +me_eval = (const Mesh *)ob->data; + } + + float location[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX}; + + if (!BKE_mesh_minmax(me_eval, location, max)) { +zero_v3(location); +zero_v3(max); + } + + interp_v3_v3v3(location, location, max, 0.5f); + mul_m4_v3(ob->object_to_world, location); + + ups->last_stroke_valid = true; + ups->average_stroke_counter = 1; + copy_v3_v3(ups->average_stroke_accum, location); +} + +void ED_object_texture_paint_mode_enter_ex(Main *bmain, + Scene *scene, + Depsgraph *depsgraph, + Object *ob) { Image *ima = nullptr; ImagePaintSettings *imapaint = &scene->toolsettings->imapaint; @@ -812,6 +842,14 @@ void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object *ob Mesh *me = BKE_mesh_from_object(ob); BLI_assert(me != nullptr); DEG_id_tag_update(&me->id, ID_RECALC_COPY_ON_WRITE); + + /* Ensure we have evaluated data for bounding box. */ + BKE_scene_graph_evaluated_ensure(depsgraph, bmain); + + /* Set pivot to bounding box center. */ + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); + paint_init_pivot(ob_eval ? ob_eval : ob, scene); + WM_main_add_notifier(NC_SCENE | ND_MODE, scene); } @@ -820,7 +858,9 @@ vo
[Bf-blender-cvs] [8fa5206ab04] blender-v3.4-release: Sculpt: fix crash when no brush
Commit: 8fa5206ab04d901320484351657bbcea8dc037f0 Author: Joseph Eagar Date: Tue Nov 29 14:29:45 2022 -0800 Branches: blender-v3.4-release https://developer.blender.org/rB8fa5206ab04d901320484351657bbcea8dc037f0 Sculpt: fix crash when no brush If no brush exists the stroke operator falls through to the grab transform op in the global view3d keymap. This now works. It would be nice if we could get rid of that keymap entry though and add it manually to the edit/paint modes that need it. === M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c === diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index aad86ffc2b1..212d39464b7 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4861,6 +4861,10 @@ static bool sculpt_needs_connectivity_info(const Sculpt *sd, SculptSession *ss, int stroke_mode) { + if (!brush) { +return true; + } + if (ss && ss->pbvh && SCULPT_is_automasking_enabled(sd, ss, brush)) { return true; } diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index c158cf33f6d..e677b565a10 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -191,7 +191,8 @@ void SCULPT_filter_cache_init(bContext *C, BKE_pbvh_search_gather(pbvh, SCULPT_search_sphere_cb, &search_data2, &nodes, &totnode); -if (SCULPT_pbvh_calc_area_normal( +if (BKE_paint_brush(&sd->paint) && +SCULPT_pbvh_calc_area_normal( brush, ob, nodes, totnode, true, ss->filter_cache->initial_normal)) { copy_v3_v3(ss->last_normal, ss->filter_cache->initial_normal); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1017b493edb] blender-v3.4-release: Sculpt: Fix T102824: broken face primitive partitioning in pbvh nodes
Commit: 1017b493edb9bc0a14bdfe642dbdc09eebf10d77 Author: Joseph Eagar Date: Wed Nov 30 13:16:17 2022 -0800 Branches: blender-v3.4-release https://developer.blender.org/rB1017b493edb9bc0a14bdfe642dbdc09eebf10d77 Sculpt: Fix T102824: broken face primitive partitioning in pbvh nodes The code I wrote to group triangles or multires quads that belonging to single faces into single PBVH nodes had edge cases that failed. The code is now much simpler and simply assigns groups of primitives to nodes. === M source/blender/blenkernel/intern/pbvh.c M source/blender/editors/sculpt_paint/sculpt_ops.c === diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 7d7641a7a54..4b24f851fca 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -39,6 +39,11 @@ #define LEAF_LIMIT 1 +/* Uncomment to test if triangles of the same face are + * properly clustered into single nodes. + */ +//#define TEST_PBVH_FACE_SPLIT + /* Uncomment to test that faces are only assigned to one PBVHNode */ //#define VALIDATE_UNIQUE_NODE_FACES @@ -164,24 +169,65 @@ static bool grid_materials_match(const DMFlagMat *f1, const DMFlagMat *f2) /* Adapted from BLI_kdopbvh.c */ /* Returns the index of the first element on the right of the partition */ -static int partition_indices(int *prim_indices, int lo, int hi, int axis, float mid, BBC *prim_bbc) +static int partition_indices_faces(int *prim_indices, + int *prim_scratch, + int lo, + int hi, + int axis, + float mid, + BBC *prim_bbc, + const MLoopTri *looptri, + const MPoly *mpoly) { - int i = lo, j = hi; - for (;;) { -for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) { - /* pass */ -} -for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) { - /* pass */ -} + for (int i = lo; i < hi; i++) { +prim_scratch[i - lo] = prim_indices[i]; + } -if (!(i < j)) { - return i; + int lo2 = lo, hi2 = hi - 1; + int i1 = lo, i2 = 0; + + while (i1 < hi) { +int poly = looptri[prim_scratch[i2]].poly; +bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid; + +while (i1 < hi && looptri[prim_scratch[i2]].poly == poly) { + prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2]; + i1++; + i2++; } + } -SWAP(int, prim_indices[i], prim_indices[j]); -i++; + return lo2; +} + +static int partition_indices_grids(int *prim_indices, + int *prim_scratch, + int lo, + int hi, + int axis, + float mid, + BBC *prim_bbc, + SubdivCCG *subdiv_ccg) +{ + for (int i = lo; i < hi; i++) { +prim_scratch[i - lo] = prim_indices[i]; + } + + int lo2 = lo, hi2 = hi - 1; + int i1 = lo, i2 = 0; + + while (i1 < hi) { +int poly = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]); +bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid; + +while (i1 < hi && BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]) == poly) { + prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2]; + i1++; + i2++; +} } + + return lo2; } /* Returns the index of the first element on the right of the partition */ @@ -424,55 +470,53 @@ static bool leaf_needs_material_split(PBVH *pbvh, int offset, int count) return false; } -static int adjust_partition_faces(PBVH *pbvh, int offset, int mid, int count) +#ifdef TEST_PBVH_FACE_SPLIT +static void test_face_boundaries(PBVH *pbvh) { - int poly = pbvh->looptri[pbvh->prim_indices[mid]].poly; - - /* Scan backwards. */ - while (mid > offset + 2) { /* First node should have at least 1 primitive */ -if (pbvh->looptri[pbvh->prim_indices[mid - 1]].poly != poly) { - return mid; -} - -mid--; + int faces_num = BKE_pbvh_num_faces(pbvh); + int *node_map = MEM_calloc_arrayN(faces_num, sizeof(int), __func__); + for (int i = 0; i < faces_num; i++) { +node_map[i] = -1; } - /* If that didn't work try scanning forward. */ - while (mid < pbvh->totprim + count) { -if (pbvh->looptri[pbvh->prim_indices[mid]].poly != poly) { - break; -} - -mid++; - } - - return mid; -} - -static int adjust_partition_grids(PBVH *pbvh, int offset, int mid, int count) -{ - int poly = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, pbvh->prim_indices[mid]); + for (int i = 0;
[Bf-blender-cvs] [918282d391a] master: Sculpt: fix crash when no brush
Commit: 918282d391a4068102bbc4e25ab9c829bd1b41f3 Author: Joseph Eagar Date: Tue Nov 29 14:29:45 2022 -0800 Branches: master https://developer.blender.org/rB918282d391a4068102bbc4e25ab9c829bd1b41f3 Sculpt: fix crash when no brush If no brush exists the stroke operator falls through to the grab transform op in the global view3d keymap. This now works. It would be nice if we could get rid of that keymap entry though and add it manually to the edit/paint modes that need it. === M source/blender/editors/sculpt_paint/sculpt.cc M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c === diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index e1dac167a32..9d30aa512c8 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -4839,6 +4839,10 @@ static bool sculpt_needs_connectivity_info(const Sculpt *sd, SculptSession *ss, int stroke_mode) { + if (!brush) { +return true; + } + if (ss && ss->pbvh && SCULPT_is_automasking_enabled(sd, ss, brush)) { return true; } diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index c158cf33f6d..e677b565a10 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -191,7 +191,8 @@ void SCULPT_filter_cache_init(bContext *C, BKE_pbvh_search_gather(pbvh, SCULPT_search_sphere_cb, &search_data2, &nodes, &totnode); -if (SCULPT_pbvh_calc_area_normal( +if (BKE_paint_brush(&sd->paint) && +SCULPT_pbvh_calc_area_normal( brush, ob, nodes, totnode, true, ss->filter_cache->initial_normal)) { copy_v3_v3(ss->last_normal, ss->filter_cache->initial_normal); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [65393add526] master: Sculpt: Fix broken pivots when entering paint modes
Commit: 65393add5269f9b803691b2df67fcdf0152d0b40 Author: Joseph Eagar Date: Wed Nov 30 13:54:56 2022 -0800 Branches: master https://developer.blender.org/rB65393add5269f9b803691b2df67fcdf0152d0b40 Sculpt: Fix broken pivots when entering paint modes When entering paint modes the paint pivot was cleared, which broken rotate around pivot. Fixed for all paint modes. PBVH modes set the pivot to the PBVH bounding box while texture paint uses the evaluated mesh bounding box. === M source/blender/editors/include/ED_object.h M source/blender/editors/sculpt_paint/paint_cursor.cc M source/blender/editors/sculpt_paint/paint_image.cc M source/blender/editors/sculpt_paint/paint_vertex.cc M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/editors/sculpt_paint/sculpt_ops.c === diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index acb0e53aa55..9e8d9636a29 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -293,7 +293,10 @@ void ED_object_vpaintmode_exit(struct bContext *C); void ED_object_wpaintmode_exit_ex(struct Object *ob); void ED_object_wpaintmode_exit(struct bContext *C); -void ED_object_texture_paint_mode_enter_ex(struct Main *bmain, struct Scene *scene, Object *ob); +void ED_object_texture_paint_mode_enter_ex(struct Main *bmain, + struct Scene *scene, + struct Depsgraph *depsgraph, + Object *ob); void ED_object_texture_paint_mode_enter(struct bContext *C); void ED_object_texture_paint_mode_exit_ex(struct Main *bmain, struct Scene *scene, Object *ob); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.cc b/source/blender/editors/sculpt_paint/paint_cursor.cc index 29d86e22814..c27cd8eb2ef 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.cc +++ b/source/blender/editors/sculpt_paint/paint_cursor.cc @@ -15,6 +15,7 @@ #include "DNA_brush_types.h" #include "DNA_color_types.h" #include "DNA_customdata_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index 2fff4fe9dc5..1ab364c4877 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -35,11 +35,14 @@ #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_node_runtime.hh" +#include "BKE_object.h" #include "BKE_paint.h" +#include "BKE_scene.h" #include "NOD_texture.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "UI_interface.h" #include "UI_view2d.h" @@ -756,7 +759,34 @@ void PAINT_OT_sample_color(wmOperatorType *ot) / texture paint toggle operator / -void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object *ob) +static void paint_init_pivot(Object *ob, Scene *scene) +{ + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; + + const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); + if (!me_eval) { +me_eval = (const Mesh *)ob->data; + } + + float location[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX}; + + if (!BKE_mesh_minmax(me_eval, location, max)) { +zero_v3(location); +zero_v3(max); + } + + interp_v3_v3v3(location, location, max, 0.5f); + mul_m4_v3(ob->object_to_world, location); + + ups->last_stroke_valid = true; + ups->average_stroke_counter = 1; + copy_v3_v3(ups->average_stroke_accum, location); +} + +void ED_object_texture_paint_mode_enter_ex(Main *bmain, + Scene *scene, + Depsgraph *depsgraph, + Object *ob) { Image *ima = nullptr; ImagePaintSettings *imapaint = &scene->toolsettings->imapaint; @@ -800,6 +830,14 @@ void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object *ob Mesh *me = BKE_mesh_from_object(ob); BLI_assert(me != nullptr); DEG_id_tag_update(&me->id, ID_RECALC_COPY_ON_WRITE); + + /* Ensure we have evaluated data for bounding box. */ + BKE_scene_graph_evaluated_ensure(depsgraph, bmain); + + /* Set pivot to bounding box center. */ + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); + paint_init_pivot(ob_eval ? ob_eval : ob, scene); + WM_main_add_notifier(NC_SCENE | ND_MODE, scene); } @@ -808,7 +846,9 @@ void ED_object_texture_paint_mode_enter(bContext *C) Main *bmain = CTX_data_main(C); Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C);
[Bf-blender-cvs] [4aac5b92c1b] master: Sculpt: Fix T102824: broken face primitive partitioning in pbvh nodes
Commit: 4aac5b92c1bbef77edaa50f460cba8350c56eaea Author: Joseph Eagar Date: Wed Nov 30 13:16:17 2022 -0800 Branches: master https://developer.blender.org/rB4aac5b92c1bbef77edaa50f460cba8350c56eaea Sculpt: Fix T102824: broken face primitive partitioning in pbvh nodes The code I wrote to group triangles or multires quads that belonging to single faces into single PBVH nodes had edge cases that failed. The code is now much simpler and simply assigns groups of primitives to nodes. === M source/blender/blenkernel/intern/pbvh.c M source/blender/editors/sculpt_paint/sculpt_ops.c === diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 145ceb143ea..0322b7135cb 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -39,6 +39,11 @@ #define LEAF_LIMIT 1 +/* Uncomment to test if triangles of the same face are + * properly clustered into single nodes. + */ +//#define TEST_PBVH_FACE_SPLIT + /* Uncomment to test that faces are only assigned to one PBVHNode */ //#define VALIDATE_UNIQUE_NODE_FACES @@ -164,24 +169,65 @@ static bool grid_materials_match(const DMFlagMat *f1, const DMFlagMat *f2) /* Adapted from BLI_kdopbvh.c */ /* Returns the index of the first element on the right of the partition */ -static int partition_indices(int *prim_indices, int lo, int hi, int axis, float mid, BBC *prim_bbc) +static int partition_indices_faces(int *prim_indices, + int *prim_scratch, + int lo, + int hi, + int axis, + float mid, + BBC *prim_bbc, + const MLoopTri *looptri, + const MPoly *mpoly) { - int i = lo, j = hi; - for (;;) { -for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) { - /* pass */ -} -for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) { - /* pass */ -} + for (int i = lo; i < hi; i++) { +prim_scratch[i - lo] = prim_indices[i]; + } -if (!(i < j)) { - return i; + int lo2 = lo, hi2 = hi - 1; + int i1 = lo, i2 = 0; + + while (i1 < hi) { +int poly = looptri[prim_scratch[i2]].poly; +bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid; + +while (i1 < hi && looptri[prim_scratch[i2]].poly == poly) { + prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2]; + i1++; + i2++; } + } -SWAP(int, prim_indices[i], prim_indices[j]); -i++; + return lo2; +} + +static int partition_indices_grids(int *prim_indices, + int *prim_scratch, + int lo, + int hi, + int axis, + float mid, + BBC *prim_bbc, + SubdivCCG *subdiv_ccg) +{ + for (int i = lo; i < hi; i++) { +prim_scratch[i - lo] = prim_indices[i]; + } + + int lo2 = lo, hi2 = hi - 1; + int i1 = lo, i2 = 0; + + while (i1 < hi) { +int poly = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]); +bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid; + +while (i1 < hi && BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]) == poly) { + prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2]; + i1++; + i2++; +} } + + return lo2; } /* Returns the index of the first element on the right of the partition */ @@ -424,55 +470,53 @@ static bool leaf_needs_material_split(PBVH *pbvh, int offset, int count) return false; } -static int adjust_partition_faces(PBVH *pbvh, int offset, int mid, int count) +#ifdef TEST_PBVH_FACE_SPLIT +static void test_face_boundaries(PBVH *pbvh) { - int poly = pbvh->looptri[pbvh->prim_indices[mid]].poly; - - /* Scan backwards. */ - while (mid > offset + 2) { /* First node should have at least 1 primitive */ -if (pbvh->looptri[pbvh->prim_indices[mid - 1]].poly != poly) { - return mid; -} - -mid--; + int faces_num = BKE_pbvh_num_faces(pbvh); + int *node_map = MEM_calloc_arrayN(faces_num, sizeof(int), __func__); + for (int i = 0; i < faces_num; i++) { +node_map[i] = -1; } - /* If that didn't work try scanning forward. */ - while (mid < pbvh->totprim + count) { -if (pbvh->looptri[pbvh->prim_indices[mid]].poly != poly) { - break; -} - -mid++; - } - - return mid; -} - -static int adjust_partition_grids(PBVH *pbvh, int offset, int mid, int count) -{ - int poly = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, pbvh->prim_indices[mid]); + for (int i = 0; i < pbvh->totn
[Bf-blender-cvs] [4726803e85a] geometry-nodes-simulation: Fixed typo in Simulation Input node
Commit: 4726803e85aefbf4fe3c4341a2561e60ed4d76a5 Author: Erik Abrahamsson Date: Wed Nov 30 23:35:48 2022 +0100 Branches: geometry-nodes-simulation https://developer.blender.org/rB4726803e85aefbf4fe3c4341a2561e60ed4d76a5 Fixed typo in Simulation Input node "Delta Time" was set instead of "Elapsed Time" output. === M source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc index 2d6a13de980..2cd240570a7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc @@ -54,7 +54,7 @@ static void node_geo_exec(GeoNodeExecParams params) params.set_output("Delta Time", scene_ctime - data->time); } if (params.lazy_output_is_required("Elapsed Time")) { - params.set_output("Delta Time", scene_ctime - cache->geometry_per_frame.first().time); + params.set_output("Elapsed Time", scene_ctime - cache->geometry_per_frame.first().time); } return; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3cebc58936b] master: Fix: Assert in subdivide curves node after span slicing change
Commit: 3cebc58936bc9d7391d24be334f5cb145948bb4b Author: Hans Goudey Date: Wed Nov 30 21:21:44 2022 -0600 Branches: master https://developer.blender.org/rB3cebc58936bc9d7391d24be334f5cb145948bb4b Fix: Assert in subdivide curves node after span slicing change a5e7657ceeb6cc5b6 missed this call where clamped slicing is necessary. The subdivision of a segment purposefully modifies the handle types of the other side of the following control point, but that didn't work for the final cyclic segment. === M release/scripts/addons M source/blender/geometry/intern/subdivide_curves.cc === diff --git a/release/scripts/addons b/release/scripts/addons index 0b0052bd53a..fdfd24de034 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde +Subproject commit fdfd24de034d4bba4fb67731d0aae81dc4940239 diff --git a/source/blender/geometry/intern/subdivide_curves.cc b/source/blender/geometry/intern/subdivide_curves.cc index f2c54d4fa59..021fa091364 100644 --- a/source/blender/geometry/intern/subdivide_curves.cc +++ b/source/blender/geometry/intern/subdivide_curves.cc @@ -172,7 +172,7 @@ static void subdivide_bezier_segment(const float3 &position_prev, auto fill_segment_handle_types = [&](const HandleType type) { /* Also change the left handle of the control point following the segment's points. And don't * change the left handle of the first point, since that is part of the previous segment. */ -dst_types_l.slice(segment_points.shift(1)).fill(type); +dst_types_l.slice_safe(segment_points.shift(1)).fill(type); dst_types_r.slice(segment_points).fill(type); }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs