Merge branch 'blender-v3.2-release'
This commit is contained in:
commit
961db61fb8
|
@ -234,7 +234,7 @@ struct Base *ED_object_add_duplicate(struct Main *bmain,
|
|||
|
||||
void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr);
|
||||
char *ED_object_ot_drop_named_material_tooltip(struct bContext *C,
|
||||
struct PointerRNA *properties,
|
||||
const char *name,
|
||||
const int mval[2]);
|
||||
|
||||
/* bitflags for enter/exit editmode */
|
||||
|
|
|
@ -1653,7 +1653,7 @@ static std::optional<CollectionAddInfo> collection_add_info_get_from_op(bContext
|
|||
PropertyRNA *prop_location = RNA_struct_find_property(op->ptr, "location");
|
||||
|
||||
add_info.collection = reinterpret_cast<Collection *>(
|
||||
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op, ID_GR));
|
||||
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_GR));
|
||||
|
||||
bool update_location_if_necessary = false;
|
||||
if (add_info.collection) {
|
||||
|
@ -3801,7 +3801,7 @@ static int object_add_named_exec(bContext *C, wmOperator *op)
|
|||
/* Find object, create fake base. */
|
||||
|
||||
Object *ob = reinterpret_cast<Object *>(
|
||||
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op, ID_OB));
|
||||
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_OB));
|
||||
|
||||
if (ob == nullptr) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Object not found");
|
||||
|
@ -3913,7 +3913,7 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op)
|
|||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
|
||||
Object *ob = reinterpret_cast<Object *>(
|
||||
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op, ID_OB));
|
||||
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_OB));
|
||||
|
||||
if (!ob) {
|
||||
ob = OBACT(view_layer);
|
||||
|
|
|
@ -2605,9 +2605,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
|
|||
/** \name Drop Named Material on Object Operator
|
||||
* \{ */
|
||||
|
||||
char *ED_object_ot_drop_named_material_tooltip(bContext *C,
|
||||
PointerRNA *properties,
|
||||
const int mval[2])
|
||||
char *ED_object_ot_drop_named_material_tooltip(bContext *C, const char *name, const int mval[2])
|
||||
{
|
||||
int mat_slot = 0;
|
||||
Object *ob = ED_view3d_give_material_slot_under_cursor(C, mval, &mat_slot);
|
||||
|
@ -2616,9 +2614,6 @@ char *ED_object_ot_drop_named_material_tooltip(bContext *C,
|
|||
}
|
||||
mat_slot = max_ii(mat_slot, 1);
|
||||
|
||||
char name[MAX_ID_NAME - 2];
|
||||
RNA_string_get(properties, "name", name);
|
||||
|
||||
Material *prev_mat = BKE_object_material_get(ob, mat_slot);
|
||||
|
||||
char *result;
|
||||
|
@ -2641,7 +2636,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
mat_slot = max_ii(mat_slot, 1);
|
||||
|
||||
Material *ma = (Material *)WM_operator_properties_id_lookup_from_name_or_session_uuid(
|
||||
bmain, op, ID_MA);
|
||||
bmain, op->ptr, ID_MA);
|
||||
|
||||
if (ob == NULL || ma == NULL) {
|
||||
return OPERATOR_CANCELLED;
|
||||
|
|
|
@ -590,16 +590,15 @@ static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event
|
|||
static char *view3d_mat_drop_tooltip(bContext *C,
|
||||
wmDrag *drag,
|
||||
const int xy[2],
|
||||
struct wmDropBox *drop)
|
||||
wmDropBox *UNUSED(drop))
|
||||
{
|
||||
const char *name = WM_drag_get_item_name(drag);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
RNA_string_set(drop->ptr, "name", name);
|
||||
int mval[2] = {
|
||||
xy[0] - region->winrct.xmin,
|
||||
xy[1] - region->winrct.ymin,
|
||||
};
|
||||
return ED_object_ot_drop_named_material_tooltip(C, drop->ptr, mval);
|
||||
return ED_object_ot_drop_named_material_tooltip(C, name, mval);
|
||||
}
|
||||
|
||||
static bool view3d_world_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
|
||||
|
|
|
@ -786,7 +786,7 @@ void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id)
|
|||
* helper to add the properties.
|
||||
*/
|
||||
struct ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(struct Main *bmain,
|
||||
const struct wmOperator *op,
|
||||
PointerRNA *ptr,
|
||||
enum ID_Type type);
|
||||
/**
|
||||
* Adds "name" and "session_uuid" properties so the caller can tell the operator which ID to act
|
||||
|
|
|
@ -683,15 +683,10 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain, wmDrag *drag, wmDropBox *
|
|||
return;
|
||||
}
|
||||
|
||||
/* Get name from property, not asset data - it may have changed after importing to ensure
|
||||
* uniqueness (name is assumed to be set from the imported ID name). */
|
||||
char name[MAX_ID_NAME - 2];
|
||||
RNA_string_get(drop->ptr, "name", name);
|
||||
if (!name[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ID *id = BKE_libblock_find_name(bmain, asset_drag->id_type, name);
|
||||
/* Try to find the imported ID. For this to work either a "session_uuid" or "name" property must
|
||||
* have been defined (see #WM_operator_properties_id_lookup()). */
|
||||
ID *id = WM_operator_properties_id_lookup_from_name_or_session_uuid(
|
||||
bmain, drop->ptr, asset_drag->id_type);
|
||||
if (id != NULL) {
|
||||
/* Do not delete the dragged ID if it has any user, otherwise if it is a 're-used' ID it will
|
||||
* cause T95636. Note that we need first to add the user that we want to remove in
|
||||
|
|
|
@ -243,20 +243,20 @@ void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id)
|
|||
}
|
||||
|
||||
ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain,
|
||||
const wmOperator *op,
|
||||
PointerRNA *ptr,
|
||||
const ID_Type type)
|
||||
{
|
||||
PropertyRNA *prop_name = RNA_struct_find_property(op->ptr, "name");
|
||||
PropertyRNA *prop_session_uuid = RNA_struct_find_property(op->ptr, "session_uuid");
|
||||
PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name");
|
||||
PropertyRNA *prop_session_uuid = RNA_struct_find_property(ptr, "session_uuid");
|
||||
|
||||
if (prop_name && RNA_property_is_set(op->ptr, prop_name)) {
|
||||
if (prop_name && RNA_property_is_set(ptr, prop_name)) {
|
||||
char name[MAX_ID_NAME - 2];
|
||||
RNA_property_string_get(op->ptr, prop_name, name);
|
||||
RNA_property_string_get(ptr, prop_name, name);
|
||||
return BKE_libblock_find_name(bmain, type, name);
|
||||
}
|
||||
|
||||
if (prop_session_uuid && RNA_property_is_set(op->ptr, prop_session_uuid)) {
|
||||
const uint32_t session_uuid = (uint32_t)RNA_property_int_get(op->ptr, prop_session_uuid);
|
||||
if (prop_session_uuid && RNA_property_is_set(ptr, prop_session_uuid)) {
|
||||
const uint32_t session_uuid = (uint32_t)RNA_property_int_get(ptr, prop_session_uuid);
|
||||
return BKE_libblock_find_session_uuid(bmain, type, session_uuid);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue