Merge branch 'blender-v4.3-release'

This commit is contained in:
Campbell Barton
2024-10-16 21:08:12 +11:00
5 changed files with 32 additions and 2 deletions

View File

@@ -92,6 +92,7 @@ int *BKE_object_defgroup_flip_map_single(const Object *ob,
int BKE_object_defgroup_flip_index(const Object *ob, int index, bool use_default);
int BKE_object_defgroup_name_index(const Object *ob, blender::StringRef name);
void BKE_object_defgroup_unique_name(bDeformGroup *dg, Object *ob);
void BKE_object_defgroup_set_name(bDeformGroup *dg, Object *ob, const char *new_name);
MDeformWeight *BKE_defvert_find_index(const MDeformVert *dv, int defgroup);
/**

View File

@@ -1047,6 +1047,8 @@ void BKE_grease_pencil_copy_layer_group_parameters(
void BKE_grease_pencil_nomain_to_grease_pencil(GreasePencil *grease_pencil_src,
GreasePencil *grease_pencil_dst);
void BKE_grease_pencil_vgroup_name_update(Object *ob, const char *old_name, const char *new_name);
void BKE_grease_pencil_data_update(Depsgraph *depsgraph, Scene *scene, Object *object);
void BKE_grease_pencil_duplicate_drawing_array(const GreasePencil *grease_pencil_src,
GreasePencil *grease_pencil_dst);

View File

@@ -25,6 +25,7 @@
#include "BLI_listbase.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_string_utils.hh"
#include "BLI_utildefines.h"
@@ -754,6 +755,18 @@ void BKE_object_defgroup_unique_name(bDeformGroup *dg, Object *ob)
BLI_uniquename_cb(defgroup_unique_check, &data, DATA_("Group"), '.', dg->name, sizeof(dg->name));
}
void BKE_object_defgroup_set_name(bDeformGroup *dg, Object *ob, const char *new_name)
{
std::string old_name = dg->name;
STRNCPY_UTF8(dg->name, new_name);
BKE_object_defgroup_unique_name(dg, ob);
if (ob->type == OB_GREASE_PENCIL) {
/* Update vgroup names stored in CurvesGeometry */
BKE_grease_pencil_vgroup_name_update(ob, old_name.c_str(), dg->name);
}
}
float BKE_defvert_find_weight(const MDeformVert *dvert, const int defgroup)
{
MDeformWeight *dw = BKE_defvert_find_index(dvert, defgroup);

View File

@@ -1890,6 +1890,21 @@ void BKE_grease_pencil_nomain_to_grease_pencil(GreasePencil *grease_pencil_src,
BKE_id_free(nullptr, grease_pencil_src);
}
void BKE_grease_pencil_vgroup_name_update(Object *ob, const char *old_name, const char *new_name)
{
using namespace blender::bke::greasepencil;
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
for (GreasePencilDrawingBase *base : grease_pencil.drawings()) {
Drawing &drawing = reinterpret_cast<GreasePencilDrawing *>(base)->wrap();
CurvesGeometry &curves = drawing.strokes_for_write();
LISTBASE_FOREACH (bDeformGroup *, vgroup, &curves.vertex_group_names) {
if (strcmp(vgroup->name, old_name) == 0) {
STRNCPY(vgroup->name, new_name);
}
}
}
}
static void grease_pencil_evaluate_modifiers(Depsgraph *depsgraph,
Scene *scene,
Object *object,

View File

@@ -902,8 +902,7 @@ static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
}
bDeformGroup *dg = static_cast<bDeformGroup *>(ptr->data);
STRNCPY_UTF8(dg->name, value);
BKE_object_defgroup_unique_name(dg, ob);
BKE_object_defgroup_set_name(dg, ob, value);
}
static int rna_VertexGroup_index_get(PointerRNA *ptr)