diff options
author | Hans Goudey <h.goudey@me.com> | 2022-02-15 19:28:57 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-02-15 19:28:57 +0300 |
commit | ff89665ad1252d17b9ab06715d5f9e670d51d7b3 (patch) | |
tree | ef67ba4069c0b0b44904d1a4caa5f934d27a8fbc /source/blender | |
parent | f3fd69067a94b285f6ec1a36448011956b2cc932 (diff) | |
parent | a9f023e226389461b1140f80e62f650d009a06a5 (diff) |
Merge branch 'master' into bli-math-basic-types
Diffstat (limited to 'source/blender')
37 files changed, 347 insertions, 105 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index aca3f99d55f..dee163a9797 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -74,6 +74,7 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_text_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_texture_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_tracking_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_userdef_enums.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_userdef_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_uuid_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_vec_types.h diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 80a500fe3c0..52de39f3ed9 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -118,8 +118,9 @@ typedef enum eContextObjectMode { CTX_MODE_SCULPT_GPENCIL, CTX_MODE_WEIGHT_GPENCIL, CTX_MODE_VERTEX_GPENCIL, + CTX_MODE_SCULPT_CURVES, } eContextObjectMode; -#define CTX_MODE_NUM (CTX_MODE_VERTEX_GPENCIL + 1) +#define CTX_MODE_NUM (CTX_MODE_SCULPT_CURVES + 1) /* Context */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 2de18382b7f..bf720fa1341 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -183,6 +183,7 @@ set(SRC intern/mball_tessellate.c intern/mesh.cc intern/mesh_boolean_convert.cc + intern/mesh_calc_edges.cc intern/mesh_convert.cc intern/mesh_debug.cc intern/mesh_evaluate.cc @@ -199,7 +200,6 @@ set(SRC intern/mesh_tangent.c intern/mesh_tessellate.c intern/mesh_validate.c - intern/mesh_validate.cc intern/mesh_wrapper.c intern/modifier.c intern/movieclip.c diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 3f524eaf230..d1374958763 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -1198,6 +1198,9 @@ enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, if (object_mode & OB_MODE_VERTEX_GPENCIL) { return CTX_MODE_VERTEX_GPENCIL; } + if (object_mode & OB_MODE_SCULPT_CURVES) { + return CTX_MODE_SCULPT_CURVES; + } } } @@ -1217,11 +1220,27 @@ enum eContextObjectMode CTX_data_mode_enum(const bContext *C) * \note Must be aligned with above enum. */ static const char *data_mode_strings[] = { - "mesh_edit", "curve_edit", "surface_edit", "text_edit", - "armature_edit", "mball_edit", "lattice_edit", "posemode", - "sculpt_mode", "weightpaint", "vertexpaint", "imagepaint", - "particlemode", "objectmode", "greasepencil_paint", "greasepencil_edit", - "greasepencil_sculpt", "greasepencil_weight", "greasepencil_vertex", NULL, + "mesh_edit", + "curve_edit", + "surface_edit", + "text_edit", + "armature_edit", + "mball_edit", + "lattice_edit", + "posemode", + "sculpt_mode", + "weightpaint", + "vertexpaint", + "imagepaint", + "particlemode", + "objectmode", + "greasepencil_paint", + "greasepencil_edit", + "greasepencil_sculpt", + "greasepencil_weight", + "greasepencil_vertex", + "curves_sculpt", + NULL, }; BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings) == CTX_MODE_NUM + 1, "Must have a string for each context mode") diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_calc_edges.cc index 5c941c16137..0524412e302 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_calc_edges.cc @@ -7,10 +7,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" - -#include "BLI_edgehash.h" #include "BLI_map.hh" -#include "BLI_math_base.h" #include "BLI_task.hh" #include "BLI_threads.h" #include "BLI_timeit.hh" diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh index 81e59b157ee..b8a208f0a0d 100644 --- a/source/blender/blenlib/BLI_math_vec_types.hh +++ b/source/blender/blenlib/BLI_math_vec_types.hh @@ -60,6 +60,16 @@ template<typename T> uint64_t vector_hash(const T &vec) return result; } +template<typename T> inline bool is_any_zero(const T &a) +{ + for (int i = 0; i < T::type_length; i++) { + if (a[i] == T::base_type(0)) { + return true; + } + } + return false; +} + } // namespace math template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> { @@ -349,7 +359,7 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> friend vec_base operator/(const vec_base &a, const vec_base &b) { - BLI_assert(!b.is_any_zero()); + BLI_assert(!math::is_any_zero()); BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] / b[i]); } @@ -361,7 +371,7 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> friend vec_base operator/(T a, const vec_base &b) { - BLI_assert(!b.is_any_zero()); + BLI_assert(!math::is_any_zero()); BLI_VEC_OP_IMPL(ret, i, ret[i] = a / b[i]); } @@ -505,7 +515,7 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> BLI_INT_OP(T) friend vec_base operator%(const vec_base &a, const vec_base &b) { - BLI_assert(!b.is_any_zero()); + BLI_assert(!math::is_any_zero()); BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] % b[i]); } diff --git a/source/blender/blenlib/BLI_math_vector.hh b/source/blender/blenlib/BLI_math_vector.hh index 7c39565cedc..32cc15e44a4 100644 --- a/source/blender/blenlib/BLI_math_vector.hh +++ b/source/blender/blenlib/BLI_math_vector.hh @@ -63,16 +63,6 @@ template<typename T, BLI_ENABLE_IF_VEC(T)> inline bool is_zero(const T &a) return true; } -template<typename T, BLI_ENABLE_IF_VEC(T)> inline bool is_any_zero(const T &a) -{ - for (int i = 0; i < T::type_length; i++) { - if (a[i] == bT(0)) { - return true; - } - } - return false; -} - template<typename T, BLI_ENABLE_IF_VEC(T)> inline T abs(const T &a) { T result; diff --git a/source/blender/draw/engines/image/image_instance_data.hh b/source/blender/draw/engines/image/image_instance_data.hh index ec6290ae8de..dcc3b7d15cb 100644 --- a/source/blender/draw/engines/image/image_instance_data.hh +++ b/source/blender/draw/engines/image/image_instance_data.hh @@ -102,7 +102,7 @@ struct IMAGE_InstanceData { short requested_view = image_user ? image_user->multi_index : 0; /* There is room for 2 multiview textures. When a higher number is requested we should always * target the first view slot. This is fine as multi view images aren't used together. */ - if (requested_view < 2) { + if (requested_view > 1) { requested_view = 0; } diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 3c1c8ffd4fc..7efd0de7a44 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -1762,9 +1762,9 @@ static bool draw_subdiv_create_requested_buffers(const Scene *scene, const float obmat[4][4], const bool do_final, const bool do_uvedit, - const bool use_subsurf_fdots, + const bool UNUSED(use_subsurf_fdots), const ToolSettings *ts, - const bool use_hide, + const bool UNUSED(use_hide), OpenSubdiv_EvaluatorCache *evaluator_cache) { SubsurfModifierData *smd = BKE_object_get_last_subsurf_modifier(ob); diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 2203c08dc50..9fff8bf861c 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -9,6 +9,7 @@ if(WITH_BLENDER) add_subdirectory(armature) add_subdirectory(asset) add_subdirectory(curve) + add_subdirectory(curves) add_subdirectory(geometry) add_subdirectory(gizmo_library) add_subdirectory(gpencil) diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 19e4daf1db7..0d6db8743af 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -574,6 +574,14 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke) cdd->vc.scene = CTX_data_scene(C); cdd->vc.view_layer = CTX_data_view_layer(C); cdd->vc.obedit = CTX_data_edit_object(C); + + /* Using an empty stroke complicates logic later, + * it's simplest to disallow early on (see: T94085). */ + if (RNA_collection_is_empty(op->ptr, "stroke")) { + MEM_freeN(cdd); + BKE_report(op->reports, RPT_ERROR, "The \"stroke\" cannot be empty"); + return false; + } } op->customdata = cdd; diff --git a/source/blender/editors/curves/CMakeLists.txt b/source/blender/editors/curves/CMakeLists.txt new file mode 100644 index 00000000000..d2b7dacbc20 --- /dev/null +++ b/source/blender/editors/curves/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +set(INC + ../include + ../../blenkernel + ../../blenlib + ../../blentranslation + ../../depsgraph + ../../makesdna + ../../makesrna + ../../windowmanager + ../../../../intern/guardedalloc +) + +set(SRC + intern/curves_ops.cc +) + +set(LIB + bf_blenkernel + bf_blenlib +) + +blender_add_lib(bf_editor_curves "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc new file mode 100644 index 00000000000..fdda8e636f7 --- /dev/null +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup edcurves + */ + +#include "BLI_utildefines.h" + +#include "ED_curves.h" +#include "ED_object.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BKE_context.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_types.h" + +static bool curves_sculptmode_toggle_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + if (ob == nullptr) { + return false; + } + if (ob->type != OB_CURVES) { + return false; + } + return true; +} + +static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + const bool is_mode_set = ob->mode == OB_MODE_SCULPT_CURVES; + + if (is_mode_set) { + if (!ED_object_mode_compat_set(C, ob, OB_MODE_SCULPT_CURVES, op->reports)) { + return OPERATOR_CANCELLED; + } + } + + if (is_mode_set) { + ob->mode = OB_MODE_OBJECT; + } + else { + ob->mode = OB_MODE_SCULPT_CURVES; + } + + WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr); + return OPERATOR_CANCELLED; +} + +static void CURVES_OT_sculptmode_toggle(wmOperatorType *ot) +{ + ot->name = "Curve Sculpt Mode Toggle"; + ot->idname = "CURVES_OT_sculptmode_toggle"; + ot->description = "Enter/Exit sculpt mode for curves"; + + ot->exec = curves_sculptmode_toggle_exec; + ot->poll = curves_sculptmode_toggle_poll; + + ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER; +} + +void ED_operatortypes_curves() +{ + WM_operatortype_append(CURVES_OT_sculptmode_toggle); +} diff --git a/source/blender/editors/include/ED_curves.h b/source/blender/editors/include/ED_curves.h new file mode 100644 index 00000000000..7316b045646 --- /dev/null +++ b/source/blender/editors/include/ED_curves.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup editors + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +void ED_operatortypes_curves(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 53d6d88f5b9..abadbe5a5c6 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -9,6 +9,7 @@ #include "BLI_compiler_attrs.h" #include "DNA_object_enums.h" +#include "DNA_userdef_enums.h" #ifdef __cplusplus extern "C" { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index e7e2706d5f9..e277aa2e629 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -2354,6 +2354,7 @@ int UI_icon_from_object_mode(const int mode) return ICON_EDITMODE_HLT; case OB_MODE_SCULPT: case OB_MODE_SCULPT_GPENCIL: + case OB_MODE_SCULPT_CURVES: return ICON_SCULPTMODE_HLT; case OB_MODE_VERTEX_PAINT: case OB_MODE_VERTEX_GPENCIL: diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c index c586527973d..509e496c39a 100644 --- a/source/blender/editors/object/object_modes.c +++ b/source/blender/editors/object/object_modes.c @@ -94,6 +94,9 @@ static const char *object_mode_op_string(eObjectMode mode) if (mode == OB_MODE_VERTEX_GPENCIL) { return "GPENCIL_OT_vertexmode_toggle"; } + if (mode == OB_MODE_SCULPT_CURVES) { + return "CURVES_OT_sculptmode_toggle"; + } return NULL; } @@ -139,6 +142,11 @@ bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode) return true; } break; + case OB_CURVES: + if (mode & (OB_MODE_SCULPT_CURVES)) { + return true; + } + break; } return false; diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index d27782877ce..897091731a4 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -28,6 +28,7 @@ #include "ED_asset.h" #include "ED_clip.h" #include "ED_curve.h" +#include "ED_curves.h" #include "ED_fileselect.h" #include "ED_geometry.h" #include "ED_gizmo_library.h" @@ -99,6 +100,7 @@ void ED_spacetypes_init(void) ED_operatortypes_paint(); ED_operatortypes_physics(); ED_operatortypes_curve(); + ED_operatortypes_curves(); ED_operatortypes_armature(); ED_operatortypes_marker(); ED_operatortypes_metaball(); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 64ac20123d9..311f3719864 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -186,7 +186,7 @@ static int open_exec(bContext *C, wmOperator *op) MovieClip *clip = NULL; char str[FILE_MAX]; - if (RNA_collection_length(op->ptr, "files")) { + if (!RNA_collection_is_empty(op->ptr, "files")) { PointerRNA fileptr; PropertyRNA *prop; char dir_only[FILE_MAX], file_only[FILE_MAX]; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index f371c663416..e5f267bb9fa 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -747,7 +747,8 @@ static int sequencer_add_movie_strip_invoke(bContext *C, RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(scene)); /* This is for drag and drop. */ - if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || + if ((RNA_struct_property_is_set(op->ptr, "files") && + !RNA_collection_is_empty(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE); return sequencer_add_movie_strip_exec(C, op); @@ -901,7 +902,8 @@ static int sequencer_add_sound_strip_invoke(bContext *C, const wmEvent *UNUSED(event)) { /* This is for drag and drop. */ - if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || + if ((RNA_struct_property_is_set(op->ptr, "files") && + !RNA_collection_is_empty(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM); return sequencer_add_sound_strip_exec(C, op); @@ -1094,7 +1096,7 @@ static int sequencer_add_image_strip_invoke(bContext *C, RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(scene)); /* Name set already by drag and drop. */ - if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) { + if (RNA_struct_property_is_set(op->ptr, "files") && !RNA_collection_is_empty(op->ptr, "files")) { sequencer_generic_invoke_xy__internal( C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE); return sequencer_add_image_strip_exec(C, op); diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc index ad8778b5cb0..33fd7329e6d 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc @@ -255,6 +255,23 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { } } } + else if (data.type().is<std::string>()) { + uiDefIconTextBut(params.block, + UI_BTYPE_LABEL, + 0, + ICON_NONE, + data.get<std::string>(real_index).c_str(), + params.xmin, + params.ymin, + params.width, + params.height, + nullptr, + 0, + 0, + 0, + 0, + nullptr); + } } void draw_float_vector(const CellDrawParams ¶ms, const Span<float> values) const diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index b01a696edc5..2300e664dfa 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -39,6 +39,7 @@ set(SRC ../include/ED_buttons.h ../include/ED_clip.h ../include/ED_curve.h + ../include/ED_curves.h ../include/ED_datafiles.h ../include/ED_file_indexer.h ../include/ED_fileselect.h diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh index 0fc3a1f354b..2c57c467bcf 100644 --- a/source/blender/gpu/intern/gpu_texture_private.hh +++ b/source/blender/gpu/intern/gpu_texture_private.hh @@ -355,10 +355,15 @@ inline int to_component_len(eGPUTextureFormat format) { switch (format) { case GPU_RGBA8: + case GPU_RGBA8I: case GPU_RGBA8UI: - case GPU_RGBA16F: case GPU_RGBA16: + case GPU_RGBA16F: + case GPU_RGBA16I: + case GPU_RGBA16UI: case GPU_RGBA32F: + case GPU_RGBA32I: + case GPU_RGBA32UI: case GPU_SRGB8_A8: case GPU_RGB10_A2: return 4; @@ -366,11 +371,15 @@ inline int to_component_len(eGPUTextureFormat format) case GPU_R11F_G11F_B10F: return 3; case GPU_RG8: + case GPU_RG8I: + case GPU_RG8UI: case GPU_RG16: case GPU_RG16F: case GPU_RG16I: case GPU_RG16UI: case GPU_RG32F: + case GPU_RG32I: + case GPU_RG32UI: return 2; default: return 1; diff --git a/source/blender/gpu/opengl/gl_compute.cc b/source/blender/gpu/opengl/gl_compute.cc index 4e178f74d8b..1913174eaef 100644 --- a/source/blender/gpu/opengl/gl_compute.cc +++ b/source/blender/gpu/opengl/gl_compute.cc @@ -15,6 +15,9 @@ namespace blender::gpu { void GLCompute::dispatch(int group_x_len, int group_y_len, int group_z_len) { GL_CHECK_RESOURCES("Compute"); + + GLContext::get()->state_manager->apply_state(); + glDispatchCompute(group_x_len, group_y_len, group_z_len); } diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc index ea373afac7d..a3288ff4cff 100644 --- a/source/blender/gpu/opengl/gl_debug.cc +++ b/source/blender/gpu/opengl/gl_debug.cc @@ -112,7 +112,7 @@ static void APIENTRY debug_callback(GLenum UNUSED(source), break; } - if (((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level >= clog_severity))) { + if (((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level <= clog_severity))) { CLG_logf(LOG.type, clog_severity, debug_groups, "", "%s", message); if (severity == GL_DEBUG_SEVERITY_HIGH) { /* Focus on error message. */ diff --git a/source/blender/gpu/opengl/gl_shader_interface.cc b/source/blender/gpu/opengl/gl_shader_interface.cc index 65235cfa88b..f6a7eee80c3 100644 --- a/source/blender/gpu/opengl/gl_shader_interface.cc +++ b/source/blender/gpu/opengl/gl_shader_interface.cc @@ -397,7 +397,9 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI else { input->location = input->binding = attr.index; } - enabled_attr_mask_ |= (1 << input->location); + if (input->location != -1) { + enabled_attr_mask_ |= (1 << input->location); + } input++; } diff --git a/source/blender/makesdna/DNA_object_enums.h b/source/blender/makesdna/DNA_object_enums.h index ce9b97284bc..3a3e4a01d7c 100644 --- a/source/blender/makesdna/DNA_object_enums.h +++ b/source/blender/makesdna/DNA_object_enums.h @@ -27,6 +27,7 @@ typedef enum eObjectMode { OB_MODE_SCULPT_GPENCIL = 1 << 9, OB_MODE_WEIGHT_GPENCIL = 1 << 10, OB_MODE_VERTEX_GPENCIL = 1 << 11, + OB_MODE_SCULPT_CURVES = 1 << 12, } eObjectMode; /** #Object.dt, #View3DShading.type */ @@ -60,7 +61,7 @@ typedef enum eDrawType { #define OB_MODE_ALL_MODE_DATA \ (OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT | OB_MODE_POSE | \ OB_MODE_PAINT_GPENCIL | OB_MODE_EDIT_GPENCIL | OB_MODE_SCULPT_GPENCIL | \ - OB_MODE_WEIGHT_GPENCIL | OB_MODE_VERTEX_GPENCIL) + OB_MODE_WEIGHT_GPENCIL | OB_MODE_VERTEX_GPENCIL | OB_MODE_SCULPT_CURVES) #ifdef __cplusplus } diff --git a/source/blender/makesdna/DNA_userdef_enums.h b/source/blender/makesdna/DNA_userdef_enums.h new file mode 100644 index 00000000000..bb061e73c9c --- /dev/null +++ b/source/blender/makesdna/DNA_userdef_enums.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** #UserDef.dupflag */ +typedef enum eDupli_ID_Flags { + USER_DUP_MESH = (1 << 0), + USER_DUP_CURVE = (1 << 1), + USER_DUP_SURF = (1 << 2), + USER_DUP_FONT = (1 << 3), + USER_DUP_MBALL = (1 << 4), + USER_DUP_LAMP = (1 << 5), + /* USER_DUP_FCURVE = (1 << 6), */ /* UNUSED, keep because we may implement. */ + USER_DUP_MAT = (1 << 7), + /* USER_DUP_TEX = (1 << 8), */ /* UNUSED, keep because we may implement. */ + USER_DUP_ARM = (1 << 9), + USER_DUP_ACT = (1 << 10), + USER_DUP_PSYS = (1 << 11), + USER_DUP_LIGHTPROBE = (1 << 12), + USER_DUP_GPENCIL = (1 << 13), + USER_DUP_CURVES = (1 << 14), + USER_DUP_POINTCLOUD = (1 << 15), + USER_DUP_VOLUME = (1 << 16), + USER_DUP_LATTICE = (1 << 17), + USER_DUP_CAMERA = (1 << 18), + USER_DUP_SPEAKER = (1 << 19), + + USER_DUP_OBDATA = (~0) & ((1 << 24) - 1), + + /* Those are not exposed as user preferences, only used internally. */ + USER_DUP_OBJECT = (1 << 24), + /* USER_DUP_COLLECTION = (1 << 25), */ /* UNUSED, keep because we may implement. */ + + /* Duplicate (and hence make local) linked data. */ + USER_DUP_LINKED_ID = (1 << 30), +} eDupli_ID_Flags; + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 59b17c5c7c4..e081be73a1c 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -9,6 +9,7 @@ #include "DNA_listBase.h" #include "DNA_texture_types.h" /* ColorBand */ +#include "DNA_userdef_enums.h" #ifdef __cplusplus extern "C" { @@ -1220,39 +1221,6 @@ typedef enum eUserpref_Translation_Flags { USER_TR_NEWDATANAME = (1 << 8), } eUserpref_Translation_Flags; -/** #UserDef.dupflag */ -typedef enum eDupli_ID_Flags { - USER_DUP_MESH = (1 << 0), - USER_DUP_CURVE = (1 << 1), - USER_DUP_SURF = (1 << 2), - USER_DUP_FONT = (1 << 3), - USER_DUP_MBALL = (1 << 4), - USER_DUP_LAMP = (1 << 5), - /* USER_DUP_FCURVE = (1 << 6), */ /* UNUSED, keep because we may implement. */ - USER_DUP_MAT = (1 << 7), - /* USER_DUP_TEX = (1 << 8), */ /* UNUSED, keep because we may implement. */ - USER_DUP_ARM = (1 << 9), - USER_DUP_ACT = (1 << 10), - USER_DUP_PSYS = (1 << 11), - USER_DUP_LIGHTPROBE = (1 << 12), - USER_DUP_GPENCIL = (1 << 13), - USER_DUP_CURVES = (1 << 14), - USER_DUP_POINTCLOUD = (1 << 15), - USER_DUP_VOLUME = (1 << 16), - USER_DUP_LATTICE = (1 << 17), - USER_DUP_CAMERA = (1 << 18), - USER_DUP_SPEAKER = (1 << 19), - - USER_DUP_OBDATA = (~0) & ((1 << 24) - 1), - - /* Those are not exposed as user preferences, only used internally. */ - USER_DUP_OBJECT = (1 << 24), - /* USER_DUP_COLLECTION = (1 << 25), */ /* UNUSED, keep because we may implement. */ - - /* Duplicate (and hence make local) linked data. */ - USER_DUP_LINKED_ID = (1 << 30), -} eDupli_ID_Flags; - /** * Text Editor options * #UserDef.text_flag diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 5441cf44ac9..eb25733a88a 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -1117,6 +1117,11 @@ void RNA_property_collection_next(CollectionPropertyIterator *iter); void RNA_property_collection_skip(CollectionPropertyIterator *iter, int num); void RNA_property_collection_end(CollectionPropertyIterator *iter); int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop); +/** + * Return true when `RNA_property_collection_length(ptr, prop) == 0`, + * without having to iterate over items in the collection (needed for some kinds of collections). + */ +bool RNA_property_collection_is_empty(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *t_ptr); int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, @@ -1445,6 +1450,7 @@ void RNA_pointer_add(PointerRNA *ptr, const char *name); void RNA_collection_begin(PointerRNA *ptr, const char *name, CollectionPropertyIterator *iter); int RNA_collection_length(PointerRNA *ptr, const char *name); +bool RNA_collection_is_empty(PointerRNA *ptr, const char *name); void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value); void RNA_collection_clear(PointerRNA *ptr, const char *name); diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 953c959dcd0..a0e5fc282d2 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -427,6 +427,7 @@ set(LIB bf_editor_armature bf_editor_asset bf_editor_curve + bf_editor_curves bf_editor_gizmo_library bf_editor_gpencil bf_editor_io diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 8189dc6b16f..6c3b46c4408 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3753,6 +3753,16 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop) return length; } +bool RNA_property_collection_is_empty(PointerRNA *ptr, PropertyRNA *prop) +{ + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + CollectionPropertyIterator iter; + RNA_property_collection_begin(ptr, prop, &iter); + bool test = iter.valid; + RNA_property_collection_end(&iter); + return !test; +} + /* This helper checks whether given collection property itself is editable (we only currently * support a limited set of operations, insertion of new items, and re-ordering of those new items * exclusively). */ @@ -6417,6 +6427,17 @@ int RNA_collection_length(PointerRNA *ptr, const char *name) return 0; } +bool RNA_collection_is_empty(PointerRNA *ptr, const char *name) +{ + PropertyRNA *prop = RNA_struct_find_property(ptr, name); + + if (prop) { + return RNA_property_collection_is_empty(ptr, prop); + } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return false; +} + bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost) { prop = rna_ensure_property(prop); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 772562d9575..bc4bd9ad3d6 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -39,6 +39,7 @@ const EnumPropertyItem rna_enum_context_mode_items[] = { {CTX_MODE_SCULPT_GPENCIL, "SCULPT_GPENCIL", 0, "Grease Pencil Sculpt", ""}, {CTX_MODE_WEIGHT_GPENCIL, "WEIGHT_GPENCIL", 0, "Grease Pencil Weight Paint", ""}, {CTX_MODE_VERTEX_GPENCIL, "VERTEX_GPENCIL", 0, "Grease Pencil Vertex Paint", ""}, + {CTX_MODE_SCULPT_CURVES, "SCULPT_CURVES", 0, "Curves Sculpt", ""}, {0, NULL, 0, NULL, NULL}, }; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index fd39ff893f1..9c4ebf79a08 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -84,6 +84,7 @@ const EnumPropertyItem rna_enum_object_mode_items[] = { ICON_VPAINT_HLT, "Vertex Paint", "Grease Pencil Vertex Paint Strokes"}, + {OB_MODE_SCULPT_CURVES, "SCULPT_CURVES", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""}, {0, NULL, 0, NULL, NULL}, }; diff --git a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc index 39c32edfe90..95e6e42cdff 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc @@ -23,7 +23,7 @@ static void node_shader_buts_vertex_color(uiLayout *layout, bContext *C, Pointer PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); if (U.experimental.use_sculpt_vertex_colors && - RNA_collection_length(&dataptr, "sculpt_vertex_colors")) { + !RNA_collection_is_empty(&dataptr, "sculpt_vertex_colors")) { uiItemPointerR( layout, ptr, "layer_name", &dataptr, "sculpt_vertex_colors", "", ICON_GROUP_VCOL); } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 3654dbbcf29..316cfe4d8b1 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2192,16 +2192,9 @@ static int pyrna_prop_array_bool(BPy_PropertyRNA *self) static int pyrna_prop_collection_bool(BPy_PropertyRNA *self) { - /* No callback defined, just iterate and find the nth item. */ - CollectionPropertyIterator iter; - int test; - PYRNA_PROP_CHECK_INT(self); - RNA_property_collection_begin(&self->ptr, self->prop, &iter); - test = iter.valid; - RNA_property_collection_end(&iter); - return test; + return !RNA_property_collection_is_empty(&self->ptr, self->prop); } /* notice getting the length of the collection is avoided unless negative @@ -6017,6 +6010,36 @@ static PyObject *small_dict_get_item_string(PyObject *dict, const char *key_look return NULL; } +/** + * \param parm_index: The argument index or -1 for keyword arguments. + */ +static void pyrna_func_error_prefix(BPy_FunctionRNA *self, + PropertyRNA *parm, + const int parm_index, + char *error, + const size_t error_size) +{ + PointerRNA *self_ptr = &self->ptr; + FunctionRNA *self_func = self->func; + if (parm_index == -1) { + BLI_snprintf(error, + error_size, + "%.200s.%.200s(): error with keyword argument \"%.200s\" - ", + RNA_struct_identifier(self_ptr->type), + RNA_function_identifier(self_func), + RNA_property_identifier(parm)); + } + else { + BLI_snprintf(error, + error_size, + "%.200s.%.200s(): error with argument %d, \"%.200s\" - ", + RNA_struct_identifier(self_ptr->type), + RNA_function_identifier(self_func), + parm_index + 1, + RNA_property_identifier(parm)); + } +} + static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject *kw) { /* NOTE: both BPy_StructRNA and BPy_PropertyRNA can be used here. */ @@ -6143,8 +6166,6 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject kw_arg = true; } - i++; /* Current argument. */ - if (item == NULL) { if (flag_parameter & PARM_REQUIRED) { PyErr_Format(PyExc_TypeError, @@ -6156,46 +6177,33 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject break; } /* PyDict_GetItemString won't raise an error. */ - continue; } + else { #ifdef DEBUG_STRING_FREE - if (item) { - if (PyUnicode_Check(item)) { - PyList_APPEND(string_free_ls, PyUnicode_FromString(PyUnicode_AsUTF8(item))); + if (item) { + if (PyUnicode_Check(item)) { + PyList_APPEND(string_free_ls, PyUnicode_FromString(PyUnicode_AsUTF8(item))); + } } - } #endif - err = pyrna_py_to_prop(&funcptr, parm, iter.data, item, ""); - if (err != 0) { /* the error generated isn't that useful, so generate it again with a useful prefix * could also write a function to prepend to error messages */ char error_prefix[512]; - PyErr_Clear(); /* Re-raise. */ - if (kw_arg == true) { - BLI_snprintf(error_prefix, - sizeof(error_prefix), - "%.200s.%.200s(): error with keyword argument \"%.200s\" - ", - RNA_struct_identifier(self_ptr->type), - RNA_function_identifier(self_func), - RNA_property_identifier(parm)); - } - else { - BLI_snprintf(error_prefix, - sizeof(error_prefix), - "%.200s.%.200s(): error with argument %d, \"%.200s\" - ", - RNA_struct_identifier(self_ptr->type), - RNA_function_identifier(self_func), - i, - RNA_property_identifier(parm)); - } + err = pyrna_py_to_prop(&funcptr, parm, iter.data, item, ""); - pyrna_py_to_prop(&funcptr, parm, iter.data, item, error_prefix); + if (err != 0) { + PyErr_Clear(); /* Re-raise. */ + pyrna_func_error_prefix(self, parm, kw_arg ? -1 : i, error_prefix, sizeof(error_prefix)); + pyrna_py_to_prop(&funcptr, parm, iter.data, item, error_prefix); - break; + break; + } } + + i++; /* Current argument. */ } RNA_parameter_list_end(&iter); diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 06ee093372e..162246798de 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -157,6 +157,9 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C) case CTX_MODE_VERTEX_GPENCIL: km_id = "Grease Pencil Stroke Vertex Mode"; break; + case CTX_MODE_SCULPT_CURVES: + km_id = "Curves Sculpt Mode"; + break; } } else if (sl->spacetype == SPACE_IMAGE) { |