From 430ced76d559d828b6f47c5fbb22530dcc70c257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Tue, 15 Feb 2022 17:48:49 +0100 Subject: GPU subdiv: fix custom data interpolation for N-gons Not all coarse vertices were used to compute the center value (off by one), and the interpolation for the current would always start at the base corner for the base face instead of the base corner for the current patch. --- .../draw/intern/shaders/common_subdiv_custom_data_interp_comp.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/draw/intern/shaders/common_subdiv_custom_data_interp_comp.glsl b/source/blender/draw/intern/shaders/common_subdiv_custom_data_interp_comp.glsl index 36c3970d9a0..df0016761e2 100644 --- a/source/blender/draw/intern/shaders/common_subdiv_custom_data_interp_comp.glsl +++ b/source/blender/draw/intern/shaders/common_subdiv_custom_data_interp_comp.glsl @@ -185,7 +185,7 @@ void main() } else { /* Interpolate the src data for the center. */ - uint loop_end = loop_start + number_of_vertices - 1; + uint loop_end = loop_start + number_of_vertices; Vertex center_value; clear(center_value); @@ -202,7 +202,7 @@ void main() uint prev_coarse_corner = (current_coarse_corner + number_of_vertices - 1) % number_of_vertices; - v0 = read_vertex(loop_start); + v0 = read_vertex(loop_start + current_coarse_corner); v1 = average(v0, read_vertex(loop_start + next_coarse_corner)); v3 = average(v0, read_vertex(loop_start + prev_coarse_corner)); -- cgit v1.2.3 From 48b26d9c2e0f4f4b6b5b7279c5bfc40c3ec77a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Tue, 15 Feb 2022 17:51:19 +0100 Subject: Fix T95697: GPU subdivision ignores custom normals Similarly to the CPU subdivision, we interpolate custom loop normals from the coarse mesh, and this for the final normals. --- .../draw/intern/draw_cache_impl_subdivision.cc | 32 ++++++++++++++++-- source/blender/draw/intern/draw_subdivision.h | 5 +++ .../mesh_extractors/extract_mesh_vbo_pos_nor.cc | 39 ++++++++++++++++++++-- .../common_subdiv_normals_finalize_comp.glsl | 21 ++++++++++++ 4 files changed, 93 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index ea05ae799b0..e4c53604370 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -1355,8 +1355,9 @@ void draw_subdiv_interp_custom_data(const DRWSubdivCache *cache, drw_subdiv_compute_dispatch(cache, shader, 0, dst_offset, cache->num_subdiv_quads); - /* This generates a vertex buffer, so we need to put a barrier on the vertex attribute array. */ - GPU_memory_barrier(GPU_BARRIER_VERTEX_ATTRIB_ARRAY); + /* This generates a vertex buffer, so we need to put a barrier on the vertex attribute array. Put + * a barrier on the shader storage as we may use the result in another compute shader. */ + GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE | GPU_BARRIER_VERTEX_ATTRIB_ARRAY); /* Cleanup. */ GPU_shader_unbind(); @@ -1437,6 +1438,28 @@ void draw_subdiv_finalize_normals(const DRWSubdivCache *cache, GPU_shader_unbind(); } +void draw_subdiv_finalize_custom_normals(const DRWSubdivCache *cache, + GPUVertBuf *src_custom_normals, + GPUVertBuf *pos_nor) +{ + GPUShader *shader = get_subdiv_shader(SHADER_BUFFER_NORMALS_FINALIZE, "#define CUSTOM_NORMALS"); + GPU_shader_bind(shader); + + GPU_vertbuf_bind_as_ssbo(src_custom_normals, 0); + /* outputPosNor is bound at index 2 in the base shader. */ + GPU_vertbuf_bind_as_ssbo(pos_nor, 2); + + drw_subdiv_compute_dispatch(cache, shader, 0, 0, cache->num_subdiv_quads); + + /* This generates a vertex buffer, so we need to put a barrier on the vertex attribute array. + * We also need it for subsequent compute shaders, so a barrier on the shader storage is also + * needed. */ + GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE | GPU_BARRIER_VERTEX_ATTRIB_ARRAY); + + /* Cleanup. */ + GPU_shader_unbind(); +} + void draw_subdiv_build_tris_buffer(const DRWSubdivCache *cache, GPUIndexBuf *subdiv_tris, const int material_count) @@ -1828,6 +1851,11 @@ static bool draw_subdiv_create_requested_buffers(const Scene *scene, /* We can only evaluate limit normals if the patches are adaptive. */ draw_cache->do_limit_normals = settings.is_adaptive; + draw_cache->use_custom_loop_normals = (smd->flags & eSubsurfModifierFlag_UseCustomNormals) && + (mesh_eval->flag & ME_AUTOSMOOTH) && + CustomData_has_layer(&mesh_eval->ldata, + CD_CUSTOMLOOPNORMAL); + if (DRW_ibo_requested(mbc->buff.ibo.tris)) { draw_subdiv_cache_ensure_mat_offsets(draw_cache, mesh_eval, batch_cache->mat_len); } diff --git a/source/blender/draw/intern/draw_subdivision.h b/source/blender/draw/intern/draw_subdivision.h index 65e845c21a4..78313441a70 100644 --- a/source/blender/draw/intern/draw_subdivision.h +++ b/source/blender/draw/intern/draw_subdivision.h @@ -67,6 +67,7 @@ typedef struct DRWSubdivCache { struct Subdiv *subdiv; bool optimal_display; bool do_limit_normals; + bool use_custom_loop_normals; /* Coordinates used to evaluate patches for UVs, positions, and normals. */ struct GPUVertBuf *patch_coords; @@ -186,6 +187,10 @@ void draw_subdiv_finalize_normals(const DRWSubdivCache *cache, struct GPUVertBuf *subdiv_loop_subdiv_vert_index, struct GPUVertBuf *pos_nor); +void draw_subdiv_finalize_custom_normals(const DRWSubdivCache *cache, + GPUVertBuf *src_custom_normals, + GPUVertBuf *pos_nor); + void draw_subdiv_extract_pos_nor(const DRWSubdivCache *cache, struct GPUVertBuf *pos_nor, bool do_limit_normals); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc index c92cf554fda..ef88a34021e 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc @@ -216,6 +216,16 @@ static GPUVertFormat *get_normals_format() return &format; } +static GPUVertFormat *get_custom_normals_format() +{ + static GPUVertFormat format = {0}; + if (format.attr_len == 0) { + GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + GPU_vertformat_alias_add(&format, "lnor"); + } + return &format; +} + static void extract_pos_nor_init_subdiv(const DRWSubdivCache *subdiv_cache, const MeshRenderData *mr, struct MeshBatchCache *UNUSED(cache), @@ -223,7 +233,8 @@ static void extract_pos_nor_init_subdiv(const DRWSubdivCache *subdiv_cache, void *UNUSED(data)) { GPUVertBuf *vbo = static_cast(buffer); - const bool do_limit_normals = subdiv_cache->do_limit_normals; + const bool do_limit_normals = subdiv_cache->do_limit_normals && + !subdiv_cache->use_custom_loop_normals; /* Initialize the vertex buffer, it was already allocated. */ GPU_vertbuf_init_build_on_device( @@ -231,7 +242,31 @@ static void extract_pos_nor_init_subdiv(const DRWSubdivCache *subdiv_cache, draw_subdiv_extract_pos_nor(subdiv_cache, vbo, do_limit_normals); - if (!do_limit_normals) { + if (subdiv_cache->use_custom_loop_normals) { + Mesh *coarse_mesh = subdiv_cache->mesh; + float(*lnors)[3] = static_cast( + CustomData_get_layer(&coarse_mesh->ldata, CD_NORMAL)); + BLI_assert(lnors != NULL); + + GPUVertBuf *src_custom_normals = GPU_vertbuf_calloc(); + GPU_vertbuf_init_with_format(src_custom_normals, get_custom_normals_format()); + GPU_vertbuf_data_alloc(src_custom_normals, coarse_mesh->totloop); + + memcpy( + GPU_vertbuf_get_data(src_custom_normals), lnors, sizeof(float[3]) * coarse_mesh->totloop); + + GPUVertBuf *dst_custom_normals = GPU_vertbuf_calloc(); + GPU_vertbuf_init_build_on_device( + dst_custom_normals, get_custom_normals_format(), subdiv_cache->num_subdiv_loops); + + draw_subdiv_interp_custom_data(subdiv_cache, src_custom_normals, dst_custom_normals, 3, 0); + + draw_subdiv_finalize_custom_normals(subdiv_cache, dst_custom_normals, vbo); + + GPU_vertbuf_discard(src_custom_normals); + GPU_vertbuf_discard(dst_custom_normals); + } + else if (!do_limit_normals) { /* We cannot evaluate vertex normals using the limit surface, so compute them manually. */ GPUVertBuf *subdiv_loop_subdiv_vert_index = draw_subdiv_build_origindex_buffer( subdiv_cache->subdiv_loop_subdiv_vert_index, subdiv_cache->num_subdiv_loops); diff --git a/source/blender/draw/intern/shaders/common_subdiv_normals_finalize_comp.glsl b/source/blender/draw/intern/shaders/common_subdiv_normals_finalize_comp.glsl index 84cd65d4161..c2e0e752783 100644 --- a/source/blender/draw/intern/shaders/common_subdiv_normals_finalize_comp.glsl +++ b/source/blender/draw/intern/shaders/common_subdiv_normals_finalize_comp.glsl @@ -1,6 +1,18 @@ /* To be compile with common_subdiv_lib.glsl */ +#ifdef CUSTOM_NORMALS +struct CustomNormal { + float x; + float y; + float z; +}; + +layout(std430, binding = 0) readonly buffer inputNormals +{ + CustomNormal custom_normals[]; +}; +#else layout(std430, binding = 0) readonly buffer inputNormals { vec3 vertex_normals[]; @@ -10,6 +22,7 @@ layout(std430, binding = 1) readonly buffer inputSubdivVertLoopMap { uint vert_loop_map[]; }; +#endif layout(std430, binding = 2) buffer outputPosNor { @@ -26,9 +39,17 @@ void main() uint start_loop_index = quad_index * 4; +#ifdef CUSTOM_NORMALS + for (int i = 0; i < 4; i++) { + CustomNormal custom_normal = custom_normals[start_loop_index + i]; + vec3 nor = vec3(custom_normal.x, custom_normal.y, custom_normal.z); + set_vertex_nor(pos_nor[start_loop_index + i], normalize(nor)); + } +#else for (int i = 0; i < 4; i++) { uint subdiv_vert_index = vert_loop_map[start_loop_index + i]; vec3 nor = vertex_normals[subdiv_vert_index]; set_vertex_nor(pos_nor[start_loop_index + i], nor); } +#endif } -- cgit v1.2.3 From 53fe4f62feae69856a8113d9e957cd305efee44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Tue, 15 Feb 2022 20:40:58 +0100 Subject: Fix T95806: subdivision missing in Cycles when using autosmooth Although rB56407432a6a did fix missing subdivision in some cases, in other cases it did not return the mesh wrapper (like when using autosmooth, which requires a copy of the mesh), so the non-subdivided mesh was still returned. --- source/blender/blenkernel/intern/mesh_convert.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index f8deb4e6807..87631348188 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -1055,7 +1055,7 @@ static Mesh *mesh_new_from_mesh(Object *object, Mesh *mesh) BKE_mesh_wrapper_ensure_mdata(mesh); } else { - BKE_mesh_wrapper_ensure_subdivision(object, mesh); + mesh = BKE_mesh_wrapper_ensure_subdivision(object, mesh); } Mesh *mesh_result = (Mesh *)BKE_id_copy_ex( @@ -1093,8 +1093,7 @@ static Mesh *mesh_new_from_mesh_object_with_layers(Depsgraph *depsgraph, mask.pmask |= CD_MASK_ORIGINDEX; } Mesh *result = mesh_create_eval_final(depsgraph, scene, &object_for_eval, &mask); - BKE_mesh_wrapper_ensure_subdivision(object, result); - return result; + return BKE_mesh_wrapper_ensure_subdivision(object, result); } static Mesh *mesh_new_from_mesh_object(Depsgraph *depsgraph, -- cgit v1.2.3 From cbdd57864049f6f300494d56b623934a4134fa2b Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 15 Feb 2022 13:57:17 -0600 Subject: Fix: Build error in debug build Error in a9f023e226389461b1140 --- source/blender/blenlib/BLI_math_vec_types.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh index ad885bde27d..8e897870098 100644 --- a/source/blender/blenlib/BLI_math_vec_types.hh +++ b/source/blender/blenlib/BLI_math_vec_types.hh @@ -349,7 +349,7 @@ template struct vec_base : public vec_struct_base friend vec_base operator/(const vec_base &a, const vec_base &b) { - BLI_assert(!math::is_any_zero()); + BLI_assert(!math::is_any_zero(b)); BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] / b[i]); } @@ -361,7 +361,7 @@ template struct vec_base : public vec_struct_base friend vec_base operator/(T a, const vec_base &b) { - BLI_assert(!math::is_any_zero()); + BLI_assert(!math::is_any_zero(b)); BLI_VEC_OP_IMPL(ret, i, ret[i] = a / b[i]); } @@ -373,7 +373,7 @@ template struct vec_base : public vec_struct_base vec_base &operator/=(const vec_base &b) { - BLI_assert(!b != T(0)); + BLI_assert(b != T(0)); BLI_VEC_OP_IMPL_SELF(i, (*this)[i] /= b[i]); } @@ -505,7 +505,7 @@ template struct vec_base : public vec_struct_base BLI_INT_OP(T) friend vec_base operator%(const vec_base &a, const vec_base &b) { - BLI_assert(!math::is_any_zero()); + BLI_assert(!math::is_any_zero(b)); BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] % b[i]); } -- cgit v1.2.3 From d3b1cce4000b4b530d3ac8e2aa6b86b79b94cca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 15 Feb 2022 22:20:25 +0100 Subject: GPUTexture: Add dimensions getter Pretty straight forward. Returns the texture dimensions count. This is different from the size. --- source/blender/gpu/GPU_texture.h | 6 ++++++ source/blender/gpu/intern/gpu_texture.cc | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'source/blender') diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 9472aed79a5..d689fbe14b5 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -287,6 +287,12 @@ void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter); void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat, bool use_clamp); void GPU_texture_swizzle_set(GPUTexture *tex, const char swizzle[4]); +/** + * Return the number of dimensions of the texture ignoring dimension of layers (1, 2 or 3). + * Cube textures are considered 2D. + */ +int GPU_texture_dimensions(const GPUTexture *tex); + int GPU_texture_width(const GPUTexture *tex); int GPU_texture_height(const GPUTexture *tex); int GPU_texture_orig_width(const GPUTexture *tex); diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 19c7c5d78ff..da5f08f003e 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -507,6 +507,25 @@ void GPU_texture_ref(GPUTexture *tex) reinterpret_cast(tex)->refcount++; } +int GPU_texture_dimensions(const GPUTexture *tex_) +{ + eGPUTextureType type = reinterpret_cast(tex_)->type_get(); + if (type & GPU_TEXTURE_1D) { + return 1; + } + else if (type & GPU_TEXTURE_2D) { + return 2; + } + else if (type & GPU_TEXTURE_3D) { + return 3; + } + else if (type & GPU_TEXTURE_CUBE) { + return 2; + } + /* GPU_TEXTURE_BUFFER */ + return 1; +} + int GPU_texture_width(const GPUTexture *tex) { return reinterpret_cast(tex)->width_get(); -- cgit v1.2.3 From 37821143dda42acb5e37e3e62a17b0da805d9abd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Feb 2022 13:02:52 +1100 Subject: Cleanup: clang-format, use static sets, sort struct declarations --- source/blender/blenkernel/BKE_animsys.h | 3 ++- source/blender/blenkernel/BKE_curves.h | 2 +- source/blender/blenkernel/BKE_gpencil.h | 2 +- source/blender/blenkernel/BKE_gpencil_update_cache.h | 6 +++--- source/blender/blenkernel/BKE_image_partial_update.hh | 2 +- source/blender/blenkernel/BKE_node_tree_update.h | 2 +- source/blender/blenkernel/intern/image_partial_update.cc | 2 +- source/blender/blenkernel/intern/mesh_calc_edges.cc | 1 + source/blender/editors/include/ED_util.h | 2 +- source/blender/editors/space_view3d/view3d_navigate.h | 4 ++-- source/blender/io/usd/intern/usd_writer_material.h | 4 ++-- source/blender/makesdna/DNA_gpencil_types.h | 2 +- source/blender/render/RE_pipeline.h | 2 +- 13 files changed, 18 insertions(+), 16 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index b448214ce28..ded64b68f79 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -88,7 +88,8 @@ struct KS_Path *BKE_keyingset_find_path(struct KeyingSet *ks, void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list); /** Process the ID pointers inside a scene's keyingsets, in see `BKE_lib_query.h` for details. */ -void BKE_keyingsets_foreach_id(struct LibraryForeachIDData *data, const struct ListBase *keyingsets); +void BKE_keyingsets_foreach_id(struct LibraryForeachIDData *data, + const struct ListBase *keyingsets); /* Free the given Keying Set path */ void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp); diff --git a/source/blender/blenkernel/BKE_curves.h b/source/blender/blenkernel/BKE_curves.h index 7ad915b50d7..2cce15fbfd6 100644 --- a/source/blender/blenkernel/BKE_curves.h +++ b/source/blender/blenkernel/BKE_curves.h @@ -12,9 +12,9 @@ extern "C" { #endif struct BoundBox; +struct Curves; struct CustomDataLayer; struct Depsgraph; -struct Curves; struct Main; struct Object; struct Scene; diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index a40a354eef7..e586bc4247d 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -16,6 +16,7 @@ struct Brush; struct CurveMapping; struct Depsgraph; struct GHash; +struct GPencilUpdateCache; struct ListBase; struct MDeformVert; struct Main; @@ -32,7 +33,6 @@ struct bGPDlayer; struct bGPDlayer_Mask; struct bGPDstroke; struct bGPdata; -struct GPencilUpdateCache; #define GPENCIL_SIMPLIFY(scene) (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_ENABLE) #define GPENCIL_SIMPLIFY_ONPLAY(playing) \ diff --git a/source/blender/blenkernel/BKE_gpencil_update_cache.h b/source/blender/blenkernel/BKE_gpencil_update_cache.h index a4fd70eb883..52b8716bab5 100644 --- a/source/blender/blenkernel/BKE_gpencil_update_cache.h +++ b/source/blender/blenkernel/BKE_gpencil_update_cache.h @@ -14,11 +14,11 @@ extern "C" { #include "BLI_sys_types.h" /* for bool */ struct DLRBT_Tree; -struct bGPdata; -struct bGPDlayer; +struct GPencilUpdateCache; struct bGPDframe; +struct bGPDlayer; struct bGPDstroke; -struct GPencilUpdateCache; +struct bGPdata; /* GPencilUpdateCache.flag */ typedef enum eGPUpdateCacheNodeFlag { diff --git a/source/blender/blenkernel/BKE_image_partial_update.hh b/source/blender/blenkernel/BKE_image_partial_update.hh index 3804936d00f..45b08e17920 100644 --- a/source/blender/blenkernel/BKE_image_partial_update.hh +++ b/source/blender/blenkernel/BKE_image_partial_update.hh @@ -21,8 +21,8 @@ #include "DNA_image_types.h" extern "C" { -struct PartialUpdateUser; struct PartialUpdateRegister; +struct PartialUpdateUser; } namespace blender::bke::image { diff --git a/source/blender/blenkernel/BKE_node_tree_update.h b/source/blender/blenkernel/BKE_node_tree_update.h index 7998a5ec017..5e377728bb7 100644 --- a/source/blender/blenkernel/BKE_node_tree_update.h +++ b/source/blender/blenkernel/BKE_node_tree_update.h @@ -7,12 +7,12 @@ */ struct ID; +struct ImageUser; struct Main; struct bNode; struct bNodeLink; struct bNodeSocket; struct bNodeTree; -struct ImageUser; #ifdef __cplusplus extern "C" { diff --git a/source/blender/blenkernel/intern/image_partial_update.cc b/source/blender/blenkernel/intern/image_partial_update.cc index e1e4a12533a..9d5635f49ab 100644 --- a/source/blender/blenkernel/intern/image_partial_update.cc +++ b/source/blender/blenkernel/intern/image_partial_update.cc @@ -90,8 +90,8 @@ static int chunk_number_for_pixel(int pixel_offset) return chunk_offset; } -struct PartialUpdateUserImpl; struct PartialUpdateRegisterImpl; +struct PartialUpdateUserImpl; /** * Wrap PartialUpdateUserImpl to its C-struct (PartialUpdateUser). diff --git a/source/blender/blenkernel/intern/mesh_calc_edges.cc b/source/blender/blenkernel/intern/mesh_calc_edges.cc index 0524412e302..5895eb7fd71 100644 --- a/source/blender/blenkernel/intern/mesh_calc_edges.cc +++ b/source/blender/blenkernel/intern/mesh_calc_edges.cc @@ -7,6 +7,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" + #include "BLI_map.hh" #include "BLI_task.hh" #include "BLI_threads.h" diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 87d5adda213..bd3a6bce8e8 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -15,9 +15,9 @@ extern "C" { #endif struct GPUBatch; +struct IDRemapper; struct Main; struct bContext; -struct IDRemapper; /* ed_util.c */ diff --git a/source/blender/editors/space_view3d/view3d_navigate.h b/source/blender/editors/space_view3d/view3d_navigate.h index 5fbfb3e9bd8..127d08580dc 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.h +++ b/source/blender/editors/space_view3d/view3d_navigate.h @@ -14,15 +14,15 @@ #define V3D_OP_TRACKBALLSIZE (1.1f) struct ARegion; -struct bContext; struct Depsgraph; struct Dial; struct Main; -struct rcti; struct RegionView3D; struct Scene; struct ScrArea; struct View3D; +struct bContext; +struct rcti; struct wmEvent; struct wmOperator; diff --git a/source/blender/io/usd/intern/usd_writer_material.h b/source/blender/io/usd/intern/usd_writer_material.h index 80b5626e3bd..3e9b84477d5 100644 --- a/source/blender/io/usd/intern/usd_writer_material.h +++ b/source/blender/io/usd/intern/usd_writer_material.h @@ -8,10 +8,10 @@ #include -struct bNode; -struct bNodeTree; struct Material; struct USDExportParams; +struct bNode; +struct bNodeTree; namespace blender::io::usd { diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index c0a9cc1ec41..fe3613548a6 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -18,8 +18,8 @@ extern "C" { struct AnimData; struct Curve; struct Curve; -struct MDeformVert; struct GPencilUpdateCache; +struct MDeformVert; #define GP_DEFAULT_PIX_FACTOR 1.0f #define GP_DEFAULT_GRID_LINES 4 diff --git a/source/blender/render/RE_pipeline.h b/source/blender/render/RE_pipeline.h index 6250f61b11c..2d43aa7b27f 100644 --- a/source/blender/render/RE_pipeline.h +++ b/source/blender/render/RE_pipeline.h @@ -11,11 +11,11 @@ #include "DNA_listBase.h" #include "DNA_vec_types.h" +struct ImBuf; struct Image; struct ImageFormatData; struct Main; struct Object; -struct ImBuf; struct RenderData; struct RenderResult; struct ReportList; -- cgit v1.2.3 From 81223ae164cf8b72743ffec2471f621509e913dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Feb 2022 13:02:53 +1100 Subject: Cleanup: spelling in comments --- source/blender/blenkernel/intern/gpencil.c | 2 +- source/blender/blenkernel/intern/gpencil_update_cache.c | 8 ++++---- source/blender/blenlib/intern/winstuff.c | 2 +- source/blender/blenloader/BLO_undofile.h | 2 +- source/blender/editors/gpencil/gpencil_sculpt_paint.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index fe3b1d0c306..16d43d40c50 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -2823,7 +2823,7 @@ void BKE_gpencil_frame_selected_hash(bGPdata *gpd, struct GHash *r_list) bool BKE_gpencil_can_avoid_full_copy_on_write(const Depsgraph *depsgraph, bGPdata *gpd) { - /* For now, we only use the update cache in the active depsgraph. Othwerwise we might access the + /* For now, we only use the update cache in the active depsgraph. Otherwise we might access the * cache while another depsgraph frees it. */ if (!DEG_is_active(depsgraph)) { return false; diff --git a/source/blender/blenkernel/intern/gpencil_update_cache.c b/source/blender/blenkernel/intern/gpencil_update_cache.c index 2258f8c353f..bbe576eb847 100644 --- a/source/blender/blenkernel/intern/gpencil_update_cache.c +++ b/source/blender/blenkernel/intern/gpencil_update_cache.c @@ -99,7 +99,7 @@ static void update_cache_node_create_ex(GPencilUpdateCache *root_cache, bool full_copy) { if (root_cache->flag == GP_UPDATE_NODE_FULL_COPY) { - /* Entire data-block has to be recaculated, e.g. nothing else needs to be added to the cache. + /* Entire data-block has to be recalculated, e.g. nothing else needs to be added to the cache. */ return; } @@ -110,14 +110,14 @@ static void update_cache_node_create_ex(GPencilUpdateCache *root_cache, root_cache->data = (bGPdata *)data; root_cache->flag = node_flag; if (full_copy) { - /* Entire data-block has to be recaculated, remove all caches of "lower" elements. */ + /* Entire data-block has to be recalculated, remove all caches of "lower" elements. */ BLI_dlrbTree_free(root_cache->children, cache_node_free); } return; } const bool is_layer_update_node = (gpf_index == -1); - /* If the data pointer in GPencilUpdateCache is NULL, this element is not actually cached + /* If the data pointer in #GPencilUpdateCache is NULL, this element is not actually cached * and does not need to be updated, but we do need the index to find elements that are in * levels below. E.g. if a stroke needs to be updated, the frame it is in would not hold a * pointer to it's data. */ @@ -174,7 +174,7 @@ static void update_cache_node_create( } if (root_cache->flag == GP_UPDATE_NODE_FULL_COPY) { - /* Entire data-block has to be recaculated, e.g. nothing else needs to be added to the cache. + /* Entire data-block has to be recalculated, e.g. nothing else needs to be added to the cache. */ return; } diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 485836eca72..e90a0ee02db 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -3,7 +3,7 @@ /** \file * \ingroup bli - * Windows-posix compatibility layer, windows-specific functions. + * WIN32-POSIX compatibility layer, MS-Windows-specific functions. */ #ifdef WIN32 diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h index 49f7f62cb9b..48334444c4c 100644 --- a/source/blender/blenloader/BLO_undofile.h +++ b/source/blender/blenloader/BLO_undofile.h @@ -5,7 +5,7 @@ /** \file * \ingroup blenloader - * External writefile function prototypes. + * External write-file function prototypes. */ #include "BLI_filereader.h" diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c index 976c5988aa6..e8f097d0018 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c @@ -1811,7 +1811,7 @@ static void gpencil_sculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA * gso->mval[1] = mouse[1] = (int)(mousef[1]); /* If the mouse/pen has not moved, no reason to continue. This also avoid a small - * drift due precision acumulation errors. */ + * drift due precision accumulation errors. */ if ((gso->mval[0] == gso->mval_prev[0]) && (gso->mval[1] == gso->mval_prev[1])) { return; } -- cgit v1.2.3 From a0ad8c57ef7da7ee21b3c2352057cf78b60000ae Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Feb 2022 13:02:54 +1100 Subject: License headers: use SPDX identifiers --- .../shaders/workbench_effect_dof_frag.glsl | 27 ++------------- source/blender/python/mathutils/mathutils_noise.c | 40 ++++------------------ 2 files changed, 8 insertions(+), 59 deletions(-) (limited to 'source/blender') diff --git a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl index e9525ce9de0..d8f8a1cc03f 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl @@ -254,31 +254,8 @@ void main() * Morgan McGuire and Kyle Whitson * http://graphics.cs.williams.edu * - * - * Copyright (c) Morgan McGuire and Williams College, 2006 - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-2-Clause + * Copyright 2006 Morgan McGuire and Williams College, All rights reserved. */ #ifdef BLUR2 diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c index 1c0b5fc782c..0853c5dd3ea 100644 --- a/source/blender/python/mathutils/mathutils_noise.c +++ b/source/blender/python/mathutils/mathutils_noise.c @@ -27,48 +27,20 @@ /*-----------------------------------------*/ /* 'mersenne twister' random number generator */ -/* - * A C-program for MT19937, with initialization improved 2002/2/10. +/* A C-program for MT19937, with initialization improved 2002/2/10. * Coded by Takuji Nishimura and Makoto Matsumoto. * This is a faster version by taking Shawn Cokus's optimization, * Matthe Bellew's simplification, Isaku Wada's real version. * - * Before using, initialize the state by using init_genrand(seed) - * or init_by_array(init_key, key_length). + * Before using, initialize the state by using + * `init_genrand(seed)` or `init_by_array(init_key, key_length)`. * - * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, - * All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * Copyright 1997-2002 Makoto Matsumoto and Takuji Nishimura, All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. The names of its contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Any feedback is very welcome. * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html - * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) - */ + * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space). */ /* Period parameters */ #define N 624 -- cgit v1.2.3 From 18d18b5a986724d43f45bac63a98400741e8e12a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Feb 2022 13:46:00 +1100 Subject: UV: move sticky selection from image space into tool settings Having this setting stored in the image space caused low level selection logic to have to pass around the image space (which could be NULL in some cases). Use the tool-settings instead since there doesn't seem to be much/any advantage in having this setting per-space. --- source/blender/editors/include/ED_uvedit.h | 9 +-- source/blender/editors/uvedit/uvedit_ops.c | 2 +- source/blender/editors/uvedit/uvedit_path.c | 48 +++--------- source/blender/editors/uvedit/uvedit_select.c | 109 ++++++++++---------------- source/blender/makesdna/DNA_scene_types.h | 10 ++- source/blender/makesdna/DNA_space_types.h | 12 +-- source/blender/makesrna/intern/rna_scene.c | 26 ++++++ source/blender/makesrna/intern/rna_space.c | 27 ------- 8 files changed, 91 insertions(+), 152 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 0c9ddc97508..26af378b1b7 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -97,8 +97,7 @@ bool uvedit_face_select_test(const struct Scene *scene, struct BMFace *efa, int bool uvedit_edge_select_test(const struct Scene *scene, struct BMLoop *l, int cd_loop_uv_offset); bool uvedit_uv_select_test(const struct Scene *scene, struct BMLoop *l, int cd_loop_uv_offset); /* uv face */ -void uvedit_face_select_set_with_sticky(const struct SpaceImage *sima, - const struct Scene *scene, +void uvedit_face_select_set_with_sticky(const struct Scene *scene, struct BMEditMesh *em, struct BMFace *efa, bool select, @@ -120,8 +119,7 @@ void uvedit_face_select_disable(const struct Scene *scene, struct BMFace *efa, int cd_loop_uv_offset); /* uv edge */ -void uvedit_edge_select_set_with_sticky(const struct SpaceImage *sima, - const struct Scene *scene, +void uvedit_edge_select_set_with_sticky(const struct Scene *scene, struct BMEditMesh *em, struct BMLoop *l, bool select, @@ -143,8 +141,7 @@ void uvedit_edge_select_disable(const struct Scene *scene, struct BMLoop *l, int cd_loop_uv_offset); /* uv vert */ -void uvedit_uv_select_set_with_sticky(const struct SpaceImage *sima, - const struct Scene *scene, +void uvedit_uv_select_set_with_sticky(const struct Scene *scene, struct BMEditMesh *em, struct BMLoop *l, bool select, diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 3d5b9207ad1..ccaabe18620 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1572,7 +1572,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op) const ToolSettings *ts = scene->toolsettings; const bool use_face_center = (ts->uv_selectmode == UV_SELECT_FACE); - const bool stickymode = sima ? (sima->sticky != SI_STICKY_DISABLE) : 1; + const bool stickymode = sima ? (ts->uv_sticky != SI_STICKY_DISABLE) : 1; const bool select = RNA_boolean_get(op->ptr, "select"); uint objects_len = 0; diff --git a/source/blender/editors/uvedit/uvedit_path.c b/source/blender/editors/uvedit/uvedit_path.c index 225b595852f..33621c1f0b6 100644 --- a/source/blender/editors/uvedit/uvedit_path.c +++ b/source/blender/editors/uvedit/uvedit_path.c @@ -138,7 +138,6 @@ struct PathSelectParams { }; struct UserData_UV { - const SpaceImage *sima; Scene *scene; BMEditMesh *em; uint cd_loop_uv_offset; @@ -226,8 +225,7 @@ static void looptag_set_cb(BMLoop *l, bool val, void *user_data_v) } } -static int mouse_mesh_uv_shortest_path_vert(const SpaceImage *sima, - Scene *scene, +static int mouse_mesh_uv_shortest_path_vert(Scene *scene, Object *obedit, const struct PathSelectParams *op_params, BMLoop *l_src, @@ -269,7 +267,6 @@ static int mouse_mesh_uv_shortest_path_vert(const SpaceImage *sima, } struct UserData_UV user_data = { - .sima = sima, .scene = scene, .em = em, .cd_loop_uv_offset = cd_loop_uv_offset, @@ -389,15 +386,13 @@ static bool facetag_test_cb(BMFace *f, void *user_data_v) static void facetag_set_cb(BMFace *f, bool val, void *user_data_v) { struct UserData_UV *user_data = user_data_v; - const SpaceImage *sima = user_data->sima; const Scene *scene = user_data->scene; BMEditMesh *em = user_data->em; const uint cd_loop_uv_offset = user_data->cd_loop_uv_offset; - uvedit_face_select_set_with_sticky(sima, scene, em, f, val, false, cd_loop_uv_offset); + uvedit_face_select_set_with_sticky(scene, em, f, val, false, cd_loop_uv_offset); } -static int mouse_mesh_uv_shortest_path_face(const SpaceImage *sima, - Scene *scene, +static int mouse_mesh_uv_shortest_path_face(Scene *scene, Object *obedit, const struct PathSelectParams *op_params, BMFace *f_src, @@ -410,7 +405,6 @@ static int mouse_mesh_uv_shortest_path_face(const SpaceImage *sima, int flush = 0; struct UserData_UV user_data = { - .sima = sima, .scene = scene, .em = em, .cd_loop_uv_offset = cd_loop_uv_offset, @@ -489,8 +483,7 @@ static int mouse_mesh_uv_shortest_path_face(const SpaceImage *sima, static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op); -static bool uv_shortest_path_pick_ex(const SpaceImage *sima, - Scene *scene, +static bool uv_shortest_path_pick_ex(Scene *scene, Depsgraph *depsgraph, Object *obedit, const struct PathSelectParams *op_params, @@ -508,8 +501,7 @@ static bool uv_shortest_path_pick_ex(const SpaceImage *sima, /* pass */ } else if (ele_src->head.htype == BM_FACE) { - flush = mouse_mesh_uv_shortest_path_face(sima, - scene, + flush = mouse_mesh_uv_shortest_path_face(scene, obedit, op_params, (BMFace *)ele_src, @@ -519,8 +511,7 @@ static bool uv_shortest_path_pick_ex(const SpaceImage *sima, ok = true; } else if (ele_src->head.htype == BM_LOOP) { - flush = mouse_mesh_uv_shortest_path_vert(sima, - scene, + flush = mouse_mesh_uv_shortest_path_vert(scene, obedit, op_params, (BMLoop *)ele_src, @@ -560,7 +551,6 @@ static bool uv_shortest_path_pick_ex(const SpaceImage *sima, static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); const ToolSettings *ts = scene->toolsettings; const char uv_selectmode = ED_uvedit_select_mode_get(scene); @@ -667,7 +657,7 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve } uv_shortest_path_pick_ex( - sima, scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, cd_loop_uv_offset); + scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, cd_loop_uv_offset); /* To support redo. */ int index; @@ -691,7 +681,6 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - const SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); const char uv_selectmode = ED_uvedit_select_mode_get(scene); Object *obedit = CTX_data_edit_object(C); @@ -742,15 +731,8 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op) path_select_params_from_op(op, &op_params); op_params.track_active = true; - if (!uv_shortest_path_pick_ex(sima, - scene, - depsgraph, - obedit, - &op_params, - ele_src, - ele_dst, - aspect_y, - cd_loop_uv_offset)) { + if (!uv_shortest_path_pick_ex( + scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, cd_loop_uv_offset)) { return OPERATOR_CANCELLED; } @@ -791,7 +773,6 @@ void UV_OT_shortest_path_pick(wmOperatorType *ot) static int uv_shortest_path_select_exec(bContext *C, wmOperator *op) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - const SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); const char uv_selectmode = ED_uvedit_select_mode_get(scene); bool found_valid_elements = false; @@ -840,15 +821,8 @@ static int uv_shortest_path_select_exec(bContext *C, wmOperator *op) struct PathSelectParams op_params; path_select_params_from_op(op, &op_params); - uv_shortest_path_pick_ex(sima, - scene, - depsgraph, - obedit, - &op_params, - ele_src, - ele_dst, - aspect_y, - cd_loop_uv_offset); + uv_shortest_path_pick_ex( + scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, cd_loop_uv_offset); found_valid_elements = true; } diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index 75bcf7c546e..4454a8414b5 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -63,14 +63,8 @@ static void uv_select_all_perform_multi(Scene *scene, const uint objects_len, int action); -static void uv_select_flush_from_tag_face(SpaceImage *sima, - Scene *scene, - Object *obedit, - const bool select); -static void uv_select_flush_from_tag_loop(SpaceImage *sima, - Scene *scene, - Object *obedit, - const bool select); +static void uv_select_flush_from_tag_face(Scene *scene, Object *obedit, const bool select); +static void uv_select_flush_from_tag_loop(Scene *scene, Object *obedit, const bool select); static void uv_select_tag_update_for_object(Depsgraph *depsgraph, const ToolSettings *ts, Object *obedit); @@ -234,8 +228,7 @@ bool uvedit_face_select_test(const Scene *scene, BMFace *efa, const int cd_loop_ return uvedit_face_select_test_ex(scene->toolsettings, efa, cd_loop_uv_offset); } -void uvedit_face_select_set_with_sticky(const SpaceImage *sima, - const Scene *scene, +void uvedit_face_select_set_with_sticky(const Scene *scene, BMEditMesh *em, BMFace *efa, const bool select, @@ -251,8 +244,7 @@ void uvedit_face_select_set_with_sticky(const SpaceImage *sima, BMLoop *l_iter, *l_first; l_iter = l_first = BM_FACE_FIRST_LOOP(efa); do { - uvedit_uv_select_set_with_sticky( - sima, scene, em, l_iter, select, do_history, cd_loop_uv_offset); + uvedit_uv_select_set_with_sticky(scene, em, l_iter, select, do_history, cd_loop_uv_offset); } while ((l_iter = l_iter->next) != l_first); } @@ -344,8 +336,7 @@ bool uvedit_edge_select_test(const Scene *scene, BMLoop *l, const int cd_loop_uv return uvedit_edge_select_test_ex(scene->toolsettings, l, cd_loop_uv_offset); } -void uvedit_edge_select_set_with_sticky(const struct SpaceImage *sima, - const Scene *scene, +void uvedit_edge_select_set_with_sticky(const Scene *scene, BMEditMesh *em, BMLoop *l, const bool select, @@ -358,9 +349,8 @@ void uvedit_edge_select_set_with_sticky(const struct SpaceImage *sima, return; } - uvedit_uv_select_set_with_sticky(sima, scene, em, l, select, do_history, cd_loop_uv_offset); - uvedit_uv_select_set_with_sticky( - sima, scene, em, l->next, select, do_history, cd_loop_uv_offset); + uvedit_uv_select_set_with_sticky(scene, em, l, select, do_history, cd_loop_uv_offset); + uvedit_uv_select_set_with_sticky(scene, em, l->next, select, do_history, cd_loop_uv_offset); } void uvedit_edge_select_set(const Scene *scene, @@ -463,8 +453,7 @@ bool uvedit_uv_select_test(const Scene *scene, BMLoop *l, const int cd_loop_uv_o return uvedit_uv_select_test_ex(scene->toolsettings, l, cd_loop_uv_offset); } -void uvedit_uv_select_set_with_sticky(const struct SpaceImage *sima, - const Scene *scene, +void uvedit_uv_select_set_with_sticky(const Scene *scene, BMEditMesh *em, BMLoop *l, const bool select, @@ -477,7 +466,7 @@ void uvedit_uv_select_set_with_sticky(const struct SpaceImage *sima, return; } - const int sticky = sima->sticky; + const int sticky = ts->uv_sticky; switch (sticky) { case SI_STICKY_DISABLE: { uvedit_uv_select_set(scene, em, l, select, do_history, cd_loop_uv_offset); @@ -1133,8 +1122,7 @@ static void uv_select_edgeloop_single_side_tag(const Scene *scene, } } -static int uv_select_edgeloop( - SpaceImage *sima, Scene *scene, Object *obedit, UvNearestHit *hit, const bool extend) +static int uv_select_edgeloop(Scene *scene, Object *obedit, UvNearestHit *hit, const bool extend) { BMEditMesh *em = BKE_editmesh_from_object(obedit); bool select; @@ -1197,8 +1185,7 @@ static int uv_select_edgeloop( BMLoop *l_iter; BM_ITER_ELEM (l_iter, &liter, f, BM_LOOPS_OF_FACE) { if (BM_elem_flag_test(l_iter, BM_ELEM_TAG)) { - uvedit_edge_select_set_with_sticky( - sima, scene, em, l_iter, select, false, cd_loop_uv_offset); + uvedit_edge_select_set_with_sticky(scene, em, l_iter, select, false, cd_loop_uv_offset); } } } @@ -1213,8 +1200,7 @@ static int uv_select_edgeloop( /** \name Edge Ring Select * \{ */ -static int uv_select_edgering( - const SpaceImage *sima, Scene *scene, Object *obedit, UvNearestHit *hit, const bool extend) +static int uv_select_edgering(Scene *scene, Object *obedit, UvNearestHit *hit, const bool extend) { const ToolSettings *ts = scene->toolsettings; BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -1253,12 +1239,10 @@ static int uv_select_edgering( } if (use_face_select) { - uvedit_face_select_set_with_sticky( - sima, scene, em, l_step->f, select, false, cd_loop_uv_offset); + uvedit_face_select_set_with_sticky(scene, em, l_step->f, select, false, cd_loop_uv_offset); } else { - uvedit_edge_select_set_with_sticky( - sima, scene, em, l_step, select, false, cd_loop_uv_offset); + uvedit_edge_select_set_with_sticky(scene, em, l_step, select, false, cd_loop_uv_offset); } BM_elem_flag_enable(l_step->e, BM_ELEM_TAG); @@ -1544,7 +1528,6 @@ static int uv_select_more_less(bContext *C, const bool select) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - SpaceImage *sima = CTX_wm_space_image(C); BMFace *efa; BMLoop *l; @@ -1643,11 +1626,11 @@ static int uv_select_more_less(bContext *C, const bool select) if (changed) { if (is_uv_face_selectmode) { /* Select tagged faces. */ - uv_select_flush_from_tag_face(sima, scene, obedit, select); + uv_select_flush_from_tag_face(scene, obedit, select); } else { /* Select tagged loops. */ - uv_select_flush_from_tag_loop(sima, scene, obedit, select); + uv_select_flush_from_tag_loop(scene, obedit, select); } DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); @@ -1877,7 +1860,6 @@ static int uv_mouse_select_multi(bContext *C, const bool deselect_all) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - SpaceImage *sima = CTX_wm_space_image(C); const ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); const ToolSettings *ts = scene->toolsettings; @@ -1907,7 +1889,7 @@ static int uv_mouse_select_multi(bContext *C, } else { selectmode = ts->uv_selectmode; - sticky = (sima) ? sima->sticky : SI_STICKY_DISABLE; + sticky = ts->uv_sticky; } /* find nearest element */ @@ -1991,20 +1973,19 @@ static int uv_mouse_select_multi(bContext *C, if (selectmode == UV_SELECT_VERTEX) { /* (de)select uv vertex */ select = !uvedit_uv_select_test(scene, hit.l, cd_loop_uv_offset); - uvedit_uv_select_set_with_sticky(sima, scene, em, hit.l, select, true, cd_loop_uv_offset); + uvedit_uv_select_set_with_sticky(scene, em, hit.l, select, true, cd_loop_uv_offset); flush = 1; } else if (selectmode == UV_SELECT_EDGE) { /* (de)select edge */ select = !(uvedit_edge_select_test(scene, hit.l, cd_loop_uv_offset)); - uvedit_edge_select_set_with_sticky(sima, scene, em, hit.l, select, true, cd_loop_uv_offset); + uvedit_edge_select_set_with_sticky(scene, em, hit.l, select, true, cd_loop_uv_offset); flush = 1; } else if (selectmode == UV_SELECT_FACE) { /* (de)select face */ select = !(uvedit_face_select_test(scene, hit.efa, cd_loop_uv_offset)); - uvedit_face_select_set_with_sticky( - sima, scene, em, hit.efa, select, true, cd_loop_uv_offset); + uvedit_face_select_set_with_sticky(scene, em, hit.efa, select, true, cd_loop_uv_offset); flush = -1; } @@ -2027,18 +2008,17 @@ static int uv_mouse_select_multi(bContext *C, if (selectmode == UV_SELECT_VERTEX) { /* select vertex */ - uvedit_uv_select_set_with_sticky(sima, scene, em, hit.l, select, true, cd_loop_uv_offset); + uvedit_uv_select_set_with_sticky(scene, em, hit.l, select, true, cd_loop_uv_offset); flush = 1; } else if (selectmode == UV_SELECT_EDGE) { /* select edge */ - uvedit_edge_select_set_with_sticky(sima, scene, em, hit.l, select, true, cd_loop_uv_offset); + uvedit_edge_select_set_with_sticky(scene, em, hit.l, select, true, cd_loop_uv_offset); flush = 1; } else if (selectmode == UV_SELECT_FACE) { /* select face */ - uvedit_face_select_set_with_sticky( - sima, scene, em, hit.efa, select, true, cd_loop_uv_offset); + uvedit_face_select_set_with_sticky(scene, em, hit.efa, select, true, cd_loop_uv_offset); flush = 1; } } @@ -2154,7 +2134,6 @@ static int uv_mouse_select_loop_generic_multi(bContext *C, const bool extend, enum eUVLoopGenericType loop_type) { - SpaceImage *sima = CTX_wm_space_image(C); const ARegion *region = CTX_wm_region(C); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); @@ -2179,10 +2158,10 @@ static int uv_mouse_select_loop_generic_multi(bContext *C, } if (loop_type == UV_LOOP_SELECT) { - flush = uv_select_edgeloop(sima, scene, obedit, &hit, extend); + flush = uv_select_edgeloop(scene, obedit, &hit, extend); } else if (loop_type == UV_RING_SELECT) { - flush = uv_select_edgering(sima, scene, obedit, &hit, extend); + flush = uv_select_edgering(scene, obedit, &hit, extend); } else { BLI_assert_unreachable(); @@ -2686,10 +2665,7 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene, * \note This function is very similar to #uv_select_flush_from_tag_loop, * be sure to update both upon changing. */ -static void uv_select_flush_from_tag_face(SpaceImage *sima, - Scene *scene, - Object *obedit, - const bool select) +static void uv_select_flush_from_tag_face(Scene *scene, Object *obedit, const bool select) { /* Selecting UV Faces with some modes requires us to change * the selection in other faces (depending on the sticky mode). @@ -2704,7 +2680,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, BMIter iter, liter; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_VERTEX) { + if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && ts->uv_sticky == SI_STICKY_VERTEX) { /* Tag all verts as untouched, then touch the ones that have a face center * in the loop and select all MLoopUV's that use a touched vert. */ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false); @@ -2728,7 +2704,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, } } } - else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_LOC) { + else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && ts->uv_sticky == SI_STICKY_LOC) { struct UvVertMap *vmap; uint efa_index; @@ -2769,10 +2745,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, * \note This function is very similar to #uv_select_flush_from_tag_loop, * be sure to update both upon changing. */ -static void uv_select_flush_from_tag_loop(SpaceImage *sima, - Scene *scene, - Object *obedit, - const bool select) +static void uv_select_flush_from_tag_loop(Scene *scene, Object *obedit, const bool select) { /* Selecting UV Loops with some modes requires us to change * the selection in other faces (depending on the sticky mode). @@ -2788,7 +2761,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_VERTEX) { + if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && ts->uv_sticky == SI_STICKY_VERTEX) { /* Tag all verts as untouched, then touch the ones that have a face center * in the loop and select all MLoopUV's that use a touched vert. */ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false); @@ -2812,7 +2785,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, } } } - else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_LOC) { + else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && ts->uv_sticky == SI_STICKY_LOC) { struct UvVertMap *vmap; uint efa_index; @@ -2854,7 +2827,6 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, static int uv_box_select_exec(bContext *C, wmOperator *op) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); const ToolSettings *ts = scene->toolsettings; ViewLayer *view_layer = CTX_data_view_layer(C); @@ -2923,7 +2895,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op) /* (de)selects all tagged faces and deals with sticky modes */ if (changed) { - uv_select_flush_from_tag_face(sima, scene, obedit, select); + uv_select_flush_from_tag_face(scene, obedit, select); } } else if (use_edge && !pinned) { @@ -2939,7 +2911,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op) luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); if (BLI_rctf_isect_pt_v(&rectf, luv->uv) && BLI_rctf_isect_pt_v(&rectf, luv_prev->uv)) { uvedit_edge_select_set_with_sticky( - sima, scene, em, l_prev, select, false, cd_loop_uv_offset); + scene, em, l_prev, select, false, cd_loop_uv_offset); changed = true; } l_prev = l; @@ -2985,7 +2957,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op) } } - if (sima->sticky == SI_STICKY_VERTEX) { + if (ts->uv_sticky == SI_STICKY_VERTEX) { uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset); } } @@ -3142,7 +3114,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op) /* (de)selects all tagged faces and deals with sticky modes */ if (changed) { - uv_select_flush_from_tag_face(sima, scene, obedit, select); + uv_select_flush_from_tag_face(scene, obedit, select); } } else if (use_edge) { @@ -3158,7 +3130,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op) luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); if (uv_circle_select_is_edge_inside(luv->uv, luv_prev->uv, offset, ellipse)) { uvedit_edge_select_set_with_sticky( - sima, scene, em, l_prev, select, false, cd_loop_uv_offset); + scene, em, l_prev, select, false, cd_loop_uv_offset); changed = true; } l_prev = l; @@ -3194,7 +3166,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op) } } - if (sima->sticky == SI_STICKY_VERTEX) { + if (ts->uv_sticky == SI_STICKY_VERTEX) { uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset); } } @@ -3262,7 +3234,6 @@ static bool do_lasso_select_mesh_uv(bContext *C, const eSelectOp sel_op) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - SpaceImage *sima = CTX_wm_space_image(C); const ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); const ToolSettings *ts = scene->toolsettings; @@ -3321,7 +3292,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, /* (de)selects all tagged faces and deals with sticky modes */ if (changed) { - uv_select_flush_from_tag_face(sima, scene, obedit, select); + uv_select_flush_from_tag_face(scene, obedit, select); } } else if (use_edge) { @@ -3340,7 +3311,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, do_lasso_select_mesh_uv_is_point_inside( region, &rect, mcoords, mcoords_len, luv_prev->uv)) { uvedit_edge_select_set_with_sticky( - sima, scene, em, l_prev, select, false, cd_loop_uv_offset); + scene, em, l_prev, select, false, cd_loop_uv_offset); changed = true; } l_prev = l; @@ -3377,7 +3348,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, } } - if (sima->sticky == SI_STICKY_VERTEX) { + if (ts->uv_sticky == SI_STICKY_VERTEX) { uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset); } } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index a3e4551a865..0d42abdb363 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1391,13 +1391,14 @@ typedef struct ToolSettings { char object_flag; /* Selection Mode for Mesh */ - short selectmode; + char selectmode; /* UV Calculation */ char unwrapper; char uvcalc_flag; char uv_flag; char uv_selectmode; + char uv_sticky; float uvcalc_margin; @@ -2300,6 +2301,13 @@ enum { #define UV_SELECT_FACE 4 #define UV_SELECT_ISLAND 8 +/** #ToolSettings.uv_sticky */ +enum { + SI_STICKY_LOC = 0, + SI_STICKY_DISABLE = 1, + SI_STICKY_VERTEX = 2, +}; + /** #ToolSettings.gpencil_flags */ typedef enum eGPencil_Flags { /* When creating new frames, the last frame gets used as the basis for the new one */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index ad7f8cc1e40..b1212965992 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1214,11 +1214,10 @@ typedef struct SpaceImage { /** UV draw type. */ char dt_uv; /** Sticky selection type. */ - char sticky; char dt_uvstretch; char around; - char _pad1[3]; + char _pad1[4]; int flag; @@ -1265,15 +1264,6 @@ typedef enum eSpaceImage_Mode { SI_MODE_UV = 3, } eSpaceImage_Mode; -/* SpaceImage.sticky - * Note DISABLE should be 0, however would also need to re-arrange icon order, - * also, sticky loc is the default mode so this means we don't need to 'do_versions' */ -typedef enum eSpaceImage_Sticky { - SI_STICKY_LOC = 0, - SI_STICKY_DISABLE = 1, - SI_STICKY_VERTEX = 2, -} eSpaceImage_Sticky; - /** #SpaceImage.flag */ typedef enum eSpaceImage_Flag { SI_FLAG_UNUSED_0 = (1 << 0), /* cleared */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index c8f65e5e153..178029ef340 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2883,6 +2883,25 @@ static void rna_def_tool_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem uv_sticky_mode_items[] = { + {SI_STICKY_DISABLE, + "DISABLED", + ICON_STICKY_UVS_DISABLE, + "Disabled", + "Sticky vertex selection disabled"}, + {SI_STICKY_LOC, + "SHARED_LOCATION", + ICON_STICKY_UVS_LOC, + "Shared Location", + "Select UVs that are at the same location and share a mesh vertex"}, + {SI_STICKY_VERTEX, + "SHARED_VERTEX", + ICON_STICKY_UVS_VERT, + "Shared Vertex", + "Select UVs that share a mesh vertex, whether or not they are at the same location"}, + {0, NULL, 0, NULL, NULL}, + }; + srna = RNA_def_struct(brna, "ToolSettings", NULL); RNA_def_struct_path_func(srna, "rna_ToolSettings_path"); RNA_def_struct_ui_text(srna, "Tool Settings", ""); @@ -3454,6 +3473,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "UV Selection Mode", "UV selection and display mode"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); + prop = RNA_def_property(srna, "uv_sticky_select_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "uv_sticky"); + RNA_def_property_enum_items(prop, uv_sticky_mode_items); + RNA_def_property_ui_text( + prop, "Sticky Selection Mode", "Method for extending UV vertex selection"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); + prop = RNA_def_property(srna, "use_uv_select_sync", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uv_flag", UV_SYNC_SELECTION); RNA_def_property_ui_text( diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 20fa8b87cd2..c51f0c00498 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3428,25 +3428,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem sticky_mode_items[] = { - {SI_STICKY_DISABLE, - "DISABLED", - ICON_STICKY_UVS_DISABLE, - "Disabled", - "Sticky vertex selection disabled"}, - {SI_STICKY_LOC, - "SHARED_LOCATION", - ICON_STICKY_UVS_LOC, - "Shared Location", - "Select UVs that are at the same location and share a mesh vertex"}, - {SI_STICKY_VERTEX, - "SHARED_VERTEX", - ICON_STICKY_UVS_VERT, - "Shared Vertex", - "Select UVs that share a mesh vertex, whether or not they are at the same location"}, - {0, NULL, 0, NULL, NULL}, - }; - static const EnumPropertyItem dt_uvstretch_items[] = { {SI_UVDT_STRETCH_ANGLE, "ANGLE", 0, "Angle", "Angular distortion between UV and 3D angles"}, {SI_UVDT_STRETCH_AREA, "AREA", 0, "Area", "Area distortion between UV and 3D faces"}, @@ -3466,14 +3447,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_SpaceUVEditor_path"); RNA_def_struct_ui_text(srna, "Space UV Editor", "UV editor data for the image editor space"); - /* selection */ - prop = RNA_def_property(srna, "sticky_select_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "sticky"); - RNA_def_property_enum_items(prop, sticky_mode_items); - RNA_def_property_ui_text( - prop, "Sticky Selection Mode", "Method for extending UV vertex selection"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - /* drawing */ prop = RNA_def_property(srna, "edge_display_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt_uv"); -- cgit v1.2.3 From 232d5d3f13479b5bddd44e3e73c94a2b419ea0fa Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 15 Feb 2022 15:42:17 +0100 Subject: Fix T95787: Texture paint: Apply Camera Image crash for certain images This does not happen with **any** image, but with images that have ID properties. ID properties are used to store view projection matrices (e.g. for reprojection with `Image from View` or `Quick Edit` -- these are the ones we are interested in), but of course they can be used for anything else, too. The images in the file from the report have ID properties from an Addon for example. So the crash can reliably be reproduced with **any** image doing the following: ``` bpy.data.images['myImage']['myIDprop'] = "foo" ``` This would lead code in `texture_paint_camera_project_exec` to think the needed `view_data` is on the image (but in reality it was just some other IDprop). Solution is simple: just check `view_data` is really valid after getting it from the IDprops. Maniphest Tasks: T95787 Differential Revision: https://developer.blender.org/D14116 --- source/blender/editors/sculpt_paint/paint_image_proj.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index ca012f20f01..6f650c82435 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -6081,7 +6081,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) view_data = IDP_GetPropertyTypeFromGroup(idgroup, PROJ_VIEW_DATA_ID, IDP_ARRAY); /* type check to make sure its ok */ - if (view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT) { + if (view_data != NULL && + (view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT)) { BKE_report(op->reports, RPT_ERROR, "Image project data invalid"); return OPERATOR_CANCELLED; } -- cgit v1.2.3 From 54972123f73ac2d4674efc5fa07fbf372c5bb4f6 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 16 Feb 2022 10:45:46 +0100 Subject: Fix Image GPU texture. Due to recent changes there have been reports of incorrect loading of GPU textures. This fix reverts a part of {D13238} that might be the source of the issue. --- source/blender/blenkernel/intern/image_gpu.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index c43df7e157e..42dcfcd7aa9 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -447,7 +447,8 @@ static GPUTexture *image_get_gpu_texture(Image *ima, if (ibuf_intern == nullptr) { ibuf_intern = BKE_image_acquire_ibuf(ima, iuser, nullptr); if (ibuf_intern == nullptr) { - return image_gpu_texture_error_create(textarget); + *tex = image_gpu_texture_error_create(textarget); + return *tex; } } -- cgit v1.2.3 From a6267f11678f7f5d05c50542945faad62a4e5c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 16 Feb 2022 14:40:01 +0100 Subject: BLI: Fix compilation error caused by rBa9f023e22638 Explicitly referencing the typename fixes the issue. --- source/blender/blenlib/BLI_math_vec_types.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh index 8e897870098..8d6f04ab15f 100644 --- a/source/blender/blenlib/BLI_math_vec_types.hh +++ b/source/blender/blenlib/BLI_math_vec_types.hh @@ -63,7 +63,7 @@ template uint64_t vector_hash(const T &vec) template inline bool is_any_zero(const T &a) { for (int i = 0; i < T::type_length; i++) { - if (a[i] == T::base_type(0)) { + if (a[i] == typename T::base_type(0)) { return true; } } -- cgit v1.2.3 From 7e312f89d970744eb90351de01101358613b89ec Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 16 Feb 2022 11:52:48 +0100 Subject: Cleanup: Use const qualifier in modifier data copy --- source/blender/blenkernel/BKE_modifier.h | 6 ++++-- source/blender/blenkernel/intern/modifier.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 9a212cb1275..6df503153b9 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -415,8 +415,10 @@ bool BKE_modifier_unique_name(struct ListBase *modifiers, struct ModifierData *m void BKE_modifier_copydata_generic(const struct ModifierData *md, struct ModifierData *md_dst, int flag); -void BKE_modifier_copydata(struct ModifierData *md, struct ModifierData *target); -void BKE_modifier_copydata_ex(struct ModifierData *md, struct ModifierData *target, int flag); +void BKE_modifier_copydata(const struct ModifierData *md, struct ModifierData *target); +void BKE_modifier_copydata_ex(const struct ModifierData *md, + struct ModifierData *target, + int flag); bool BKE_modifier_depends_ontime(struct Scene *scene, struct ModifierData *md, int dag_eval_mode); bool BKE_modifier_supports_mapping(struct ModifierData *md); bool BKE_modifier_supports_cage(struct Scene *scene, struct ModifierData *md); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 46fea5ae115..0e8838d16ce 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -348,7 +348,7 @@ static void modifier_copy_data_id_us_cb(void *UNUSED(userData), } } -void BKE_modifier_copydata_ex(ModifierData *md, ModifierData *target, const int flag) +void BKE_modifier_copydata_ex(const ModifierData *md, ModifierData *target, const int flag) { const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); @@ -378,7 +378,7 @@ void BKE_modifier_copydata_ex(ModifierData *md, ModifierData *target, const int } } -void BKE_modifier_copydata(ModifierData *md, ModifierData *target) +void BKE_modifier_copydata(const ModifierData *md, ModifierData *target) { BKE_modifier_copydata_ex(md, target, 0); } -- cgit v1.2.3 From 03ff58b67d50a714c5609e584a6942996cfdee1b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 16 Feb 2022 11:56:04 +0100 Subject: Cleanup: Use const qualifier in modifier data copy Fix possible overflow of Modifier UUID The code prior this change was re-generating modifier's session UUID prior to copying this id from the source. This approach has a higher risk of modifiers session UUID to overflow and start colliding with existing modifiers. This change makes it so that modifier copy does not re-generated the session UUID unless it is needed. Differential Revision: https://developer.blender.org/D14125 --- source/blender/blenkernel/BKE_modifier.h | 2 ++ source/blender/blenkernel/intern/modifier.c | 19 ++++++++++++++++++- source/blender/blenkernel/intern/object.cc | 4 +--- 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 6df503153b9..acdca23b21c 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -409,6 +409,8 @@ void BKE_modifier_session_uuid_generate(struct ModifierData *md); bool BKE_modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md); +struct ModifierData *BKE_modifier_copy_ex(const struct ModifierData *md, int flag); + /** * Callback's can use this to avoid copying every member. */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 0e8838d16ce..837c1fe179f 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -131,7 +131,7 @@ void BKE_modifier_panel_expand(ModifierData *md) /***/ -ModifierData *BKE_modifier_new(int type) +static ModifierData *modifier_allocate_and_init(int type) { const ModifierTypeInfo *mti = BKE_modifier_get_info(type); ModifierData *md = MEM_callocN(mti->structSize, mti->structName); @@ -152,6 +152,13 @@ ModifierData *BKE_modifier_new(int type) mti->initData(md); } + return md; +} + +ModifierData *BKE_modifier_new(int type) +{ + ModifierData *md = modifier_allocate_and_init(type); + BKE_modifier_session_uuid_generate(md); return md; @@ -315,6 +322,16 @@ void BKE_modifiers_foreach_tex_link(Object *ob, TexWalkFunc walk, void *userData } } +ModifierData *BKE_modifier_copy_ex(const ModifierData *md, int flag) +{ + ModifierData *md_dst = modifier_allocate_and_init(md->type); + + BLI_strncpy(md_dst->name, md->name, sizeof(md_dst->name)); + BKE_modifier_copydata_ex(md, md_dst, flag); + + return md_dst; +} + void BKE_modifier_copydata_generic(const ModifierData *md_src, ModifierData *md_dst, const int UNUSED(flag)) diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 579e61750f0..3a8d7d6bc8a 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -1599,9 +1599,7 @@ bool BKE_object_modifier_stack_copy(Object *ob_dst, continue; } - ModifierData *md_dst = BKE_modifier_new(md_src->type); - BLI_strncpy(md_dst->name, md_src->name, sizeof(md_dst->name)); - BKE_modifier_copydata_ex(md_src, md_dst, flag_subdata); + ModifierData *md_dst = BKE_modifier_copy_ex(md_src, flag_subdata); BLI_addtail(&ob_dst->modifiers, md_dst); } -- cgit v1.2.3 From 257ba175fa7e324792ce5f32d5369bcd685b8f55 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 16 Feb 2022 15:58:27 +0100 Subject: Fix: removing anonymous attributes before adding mesh to bmain This was an issue when e.g. `bpy.data.meshes.new_from_object` was used on an object that uses geometry nodes. --- source/blender/blenkernel/intern/mesh_convert.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 87631348188..22e4c3bf13c 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -1236,6 +1236,9 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain, BKE_mesh_nomain_to_mesh(mesh, mesh_in_bmain, nullptr, &CD_MASK_MESH, true); + /* Anonymous attributes shouldn't exist on original data. */ + BKE_mesh_anonymous_attributes_remove(mesh_in_bmain); + /* User-count is required because so far mesh was in a limbo, where library management does * not perform any user management (i.e. copy of a mesh will not increase users of materials). */ BKE_library_foreach_ID_link( -- cgit v1.2.3