Merge remote-tracking branch 'origin/blender-v4.5-release'

This commit is contained in:
Sybren A. Stüvel
2025-06-26 10:49:57 +02:00
3 changed files with 49 additions and 1 deletions

View File

@@ -2208,6 +2208,14 @@ void BKE_pose_blend_read_after_liblink(BlendLibReader *reader, Object *ob, bPose
pchan->bone->flag &= ~BONE_SELECTED;
pchan->bone->flag |= pchan->selectflag;
}
/* At some point in history, bones could have an armature object as custom shape, which caused
* all kinds of wonderful issues. This is now avoided in RNA, but through the magic of linking
* and editing the library file, the situation can still occur. Better to just reset the
* pointer in those cases. */
if (pchan->custom && pchan->custom->type == OB_ARMATURE) {
pchan->custom = nullptr;
}
}
if (rebuild) {

View File

@@ -3148,7 +3148,19 @@ void BKE_pchan_minmax(const Object *ob,
{
using namespace blender;
const bArmature *arm = static_cast<const bArmature *>(ob->data);
Object *ob_custom = (arm->flag & ARM_NO_CUSTOM) ? nullptr : pchan->custom;
Object *ob_custom = nullptr;
if (!(arm->flag & ARM_NO_CUSTOM) && pchan->custom) {
/* This should not be possible, protected against in RNA code and
* BKE_pose_blend_read_after_liblink(). Just for safety do another check
* here, as otherwise this code can end in an infinite loop. */
BLI_assert(pchan->custom->type != OB_ARMATURE);
if (pchan->custom->type != OB_ARMATURE) {
ob_custom = pchan->custom;
}
}
const bPoseChannel *pchan_tx = (ob_custom && pchan->custom_tx) ? pchan->custom_tx : pchan;
std::optional<Bounds<float3>> bb_custom;

View File

@@ -644,6 +644,32 @@ static void rna_PoseChannel_custom_shape_transform_set(PointerRNA *ptr,
ob, (Object *)value.owner_id, static_cast<bPoseChannel *>(value.data));
}
void rna_Pose_custom_shape_set(PointerRNA *ptr, PointerRNA value, struct ReportList *reports)
{
bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
Object *custom_shape = static_cast<Object *>(value.data);
if (!custom_shape) {
pchan->custom = nullptr;
return;
}
/* This should be ensured by the RNA property type. */
BLI_assert(GS(custom_shape->id.name) == ID_OB);
if (custom_shape->type == OB_ARMATURE) {
BKE_report(reports, RPT_ERROR, "Cannot use armature object as custom bone shape");
return;
}
pchan->custom = custom_shape;
}
bool rna_Pose_custom_shape_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
{
return (reinterpret_cast<Object *>(value.owner_id))->type != OB_ARMATURE;
}
#else
void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const char *update_cb)
@@ -1106,6 +1132,8 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Custom Object", "Object that defines custom display shape for this bone");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_pointer_funcs(
prop, nullptr, "rna_Pose_custom_shape_set", nullptr, "rna_Pose_custom_shape_object_poll");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update");
prop = RNA_def_property(srna, "custom_shape_scale_xyz", PROP_FLOAT, PROP_XYZ);