Merge branch 'master' into blender2.8
Conflicts: source/blender/editors/object/object_add.c source/blender/editors/object/object_select.c source/blender/editors/space_outliner/outliner_edit.c
This commit is contained in:
@@ -95,8 +95,7 @@ void *BKE_libblock_copy_nolib(const struct ID *id, const bool do_action) ATTR_NO
|
|||||||
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
|
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
|
||||||
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
|
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
|
||||||
|
|
||||||
struct ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
struct ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||||
struct ID *BKE_libblock_find_name(const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
|
||||||
|
|
||||||
/* library_remap.c (keep here since they're general functions) */
|
/* library_remap.c (keep here since they're general functions) */
|
||||||
/**
|
/**
|
||||||
@@ -140,7 +139,7 @@ void BKE_libblock_free_data(struct ID *id, const bool do_id_user) ATTR_NONNULL(
|
|||||||
|
|
||||||
void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
|
void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
|
||||||
void id_lib_extern(struct ID *id);
|
void id_lib_extern(struct ID *id);
|
||||||
void BKE_library_filepath_set(struct Library *lib, const char *filepath);
|
void BKE_library_filepath_set(struct Main *bmain, struct Library *lib, const char *filepath);
|
||||||
void id_us_ensure_real(struct ID *id);
|
void id_us_ensure_real(struct ID *id);
|
||||||
void id_us_clear_real(struct ID *id);
|
void id_us_clear_real(struct ID *id);
|
||||||
void id_us_plus_no_lib(struct ID *id);
|
void id_us_plus_no_lib(struct ID *id);
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
|
|||||||
/* keep packedfile paths always relative to the blend */
|
/* keep packedfile paths always relative to the blend */
|
||||||
if (lib->packedfile == NULL) {
|
if (lib->packedfile == NULL) {
|
||||||
if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
|
if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
|
||||||
BKE_library_filepath_set(lib, lib->name);
|
BKE_library_filepath_set(bmain, lib, lib->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1738,17 +1738,12 @@ void BKE_main_thumbnail_create(struct Main *bmain)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ***************** ID ************************ */
|
/* ***************** ID ************************ */
|
||||||
ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const char *name)
|
ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *name)
|
||||||
{
|
{
|
||||||
ListBase *lb = which_libbase(bmain, type);
|
ListBase *lb = which_libbase(bmain, type);
|
||||||
BLI_assert(lb != NULL);
|
BLI_assert(lb != NULL);
|
||||||
return BLI_findstring(lb, name, offsetof(ID, name) + 2);
|
return BLI_findstring(lb, name, offsetof(ID, name) + 2);
|
||||||
}
|
}
|
||||||
ID *BKE_libblock_find_name(const short type, const char *name)
|
|
||||||
{
|
|
||||||
return BKE_libblock_find_name_ex(G.main, type, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void id_sort_by_name(ListBase *lb, ID *id)
|
void id_sort_by_name(ListBase *lb, ID *id)
|
||||||
{
|
{
|
||||||
@@ -2078,7 +2073,7 @@ static void library_make_local_copying_check(ID *id, GSet *loop_tags, MainIDRela
|
|||||||
|
|
||||||
/** Make linked datablocks local.
|
/** Make linked datablocks local.
|
||||||
*
|
*
|
||||||
* \param bmain Almost certainly G.main.
|
* \param bmain Almost certainly global main.
|
||||||
* \param lib If not NULL, only make local datablocks from this library.
|
* \param lib If not NULL, only make local datablocks from this library.
|
||||||
* \param untagged_only If true, only make local datablocks not tagged with LIB_TAG_PRE_EXISTING.
|
* \param untagged_only If true, only make local datablocks not tagged with LIB_TAG_PRE_EXISTING.
|
||||||
* \param set_fake If true, set fake user on all localized datablocks (except group and objects ones).
|
* \param set_fake If true, set fake user on all localized datablocks (except group and objects ones).
|
||||||
@@ -2510,7 +2505,7 @@ void BKE_id_ui_prefix(char name[MAX_ID_NAME + 1], const ID *id)
|
|||||||
strcpy(name + 3, id->name + 2);
|
strcpy(name + 3, id->name + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_library_filepath_set(Library *lib, const char *filepath)
|
void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
|
||||||
{
|
{
|
||||||
/* in some cases this is used to update the absolute path from the
|
/* in some cases this is used to update the absolute path from the
|
||||||
* relative */
|
* relative */
|
||||||
@@ -2529,8 +2524,8 @@ void BKE_library_filepath_set(Library *lib, const char *filepath)
|
|||||||
* since making local could cause this to be directly linked - campbell
|
* since making local could cause this to be directly linked - campbell
|
||||||
*/
|
*/
|
||||||
/* Never make paths relative to parent lib - reading code (blenloader) always set *all* lib->name relative to
|
/* Never make paths relative to parent lib - reading code (blenloader) always set *all* lib->name relative to
|
||||||
* current G.main, not to their parent for indirectly linked ones. */
|
* current main, not to their parent for indirectly linked ones. */
|
||||||
const char *basepath = G.main->name;
|
const char *basepath = bmain->name;
|
||||||
BLI_path_abs(lib->filepath, basepath);
|
BLI_path_abs(lib->filepath, basepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -942,7 +942,7 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
|
|||||||
/* called from creator_args.c */
|
/* called from creator_args.c */
|
||||||
Scene *BKE_scene_set_name(Main *bmain, const char *name)
|
Scene *BKE_scene_set_name(Main *bmain, const char *name)
|
||||||
{
|
{
|
||||||
Scene *sce = (Scene *)BKE_libblock_find_name_ex(bmain, ID_SCE, name);
|
Scene *sce = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, name);
|
||||||
if (sce) {
|
if (sce) {
|
||||||
BKE_scene_set_background(bmain, sce);
|
BKE_scene_set_background(bmain, sce);
|
||||||
printf("Scene switch for render: '%s' in file: '%s'\n", name, bmain->name);
|
printf("Scene switch for render: '%s' in file: '%s'\n", name, bmain->name);
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BKE_library_filepath_set(curlib, curlib->name);
|
BKE_library_filepath_set(bmain, curlib, curlib->name);
|
||||||
BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports);
|
BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports);
|
||||||
|
|
||||||
if (bh == NULL) {
|
if (bh == NULL) {
|
||||||
|
|||||||
@@ -8268,7 +8268,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG_PRINTF("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>");
|
DEBUG_PRINTF("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>");
|
||||||
if ((id = BKE_libblock_find_name_ex(main, GS(idname), idname + 2))) {
|
if ((id = BKE_libblock_find_name(main, GS(idname), idname + 2))) {
|
||||||
DEBUG_PRINTF("FOUND!\n");
|
DEBUG_PRINTF("FOUND!\n");
|
||||||
/* Even though we found our linked ID, there is no guarantee its address is still the same... */
|
/* Even though we found our linked ID, there is no guarantee its address is still the same... */
|
||||||
if (id != bhead->old) {
|
if (id != bhead->old) {
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
|
|||||||
{
|
{
|
||||||
Object *ob;
|
Object *ob;
|
||||||
|
|
||||||
ob = (Object *)BKE_libblock_find_name_ex(bmain, ID_OB, "Camera");
|
ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, "Camera");
|
||||||
if (ob) {
|
if (ob) {
|
||||||
ob->rot[1] = 0.0f;
|
ob->rot[1] = 0.0f;
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
|
|||||||
{
|
{
|
||||||
Brush *br;
|
Brush *br;
|
||||||
|
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Fill");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Fill");
|
||||||
if (!br) {
|
if (!br) {
|
||||||
br = BKE_brush_add(bmain, "Fill", OB_MODE_TEXTURE_PAINT);
|
br = BKE_brush_add(bmain, "Fill", OB_MODE_TEXTURE_PAINT);
|
||||||
id_us_min(&br->id); /* fake user only */
|
id_us_min(&br->id); /* fake user only */
|
||||||
@@ -288,14 +288,14 @@ void BLO_update_defaults_startup_blend(Main *bmain)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Vertex/Weight Paint */
|
/* Vertex/Weight Paint */
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Average");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Average");
|
||||||
if (!br) {
|
if (!br) {
|
||||||
br = BKE_brush_add(bmain, "Average", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
|
br = BKE_brush_add(bmain, "Average", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
|
||||||
id_us_min(&br->id); /* fake user only */
|
id_us_min(&br->id); /* fake user only */
|
||||||
br->vertexpaint_tool = PAINT_BLEND_AVERAGE;
|
br->vertexpaint_tool = PAINT_BLEND_AVERAGE;
|
||||||
br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
|
br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
|
||||||
}
|
}
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Smear");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Smear");
|
||||||
if (!br) {
|
if (!br) {
|
||||||
br = BKE_brush_add(bmain, "Smear", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
|
br = BKE_brush_add(bmain, "Smear", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
|
||||||
id_us_min(&br->id); /* fake user only */
|
id_us_min(&br->id); /* fake user only */
|
||||||
@@ -303,49 +303,49 @@ void BLO_update_defaults_startup_blend(Main *bmain)
|
|||||||
br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
|
br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Mask");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Mask");
|
||||||
if (br) {
|
if (br) {
|
||||||
br->imagepaint_tool = PAINT_TOOL_MASK;
|
br->imagepaint_tool = PAINT_TOOL_MASK;
|
||||||
br->ob_mode |= OB_MODE_TEXTURE_PAINT;
|
br->ob_mode |= OB_MODE_TEXTURE_PAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove polish brush (flatten/contrast does the same) */
|
/* remove polish brush (flatten/contrast does the same) */
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Polish");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Polish");
|
||||||
if (br) {
|
if (br) {
|
||||||
BKE_libblock_delete(bmain, br);
|
BKE_libblock_delete(bmain, br);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove brush brush (huh?) from some modes (draw brushes do the same) */
|
/* remove brush brush (huh?) from some modes (draw brushes do the same) */
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Brush");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Brush");
|
||||||
if (br) {
|
if (br) {
|
||||||
BKE_libblock_delete(bmain, br);
|
BKE_libblock_delete(bmain, br);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove draw brush from texpaint (draw brushes do the same) */
|
/* remove draw brush from texpaint (draw brushes do the same) */
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Draw");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Draw");
|
||||||
if (br) {
|
if (br) {
|
||||||
br->ob_mode &= ~OB_MODE_TEXTURE_PAINT;
|
br->ob_mode &= ~OB_MODE_TEXTURE_PAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rename twist brush to rotate brush to match rotate tool */
|
/* rename twist brush to rotate brush to match rotate tool */
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Twist");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Twist");
|
||||||
if (br) {
|
if (br) {
|
||||||
BKE_libblock_rename(bmain, &br->id, "Rotate");
|
BKE_libblock_rename(bmain, &br->id, "Rotate");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use original normal for grab brush (otherwise flickers with normal weighting). */
|
/* use original normal for grab brush (otherwise flickers with normal weighting). */
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Grab");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Grab");
|
||||||
if (br) {
|
if (br) {
|
||||||
br->flag |= BRUSH_ORIGINAL_NORMAL;
|
br->flag |= BRUSH_ORIGINAL_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* increase strength, better for smoothing method */
|
/* increase strength, better for smoothing method */
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Blur");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Blur");
|
||||||
if (br) {
|
if (br) {
|
||||||
br->alpha = 1.0f;
|
br->alpha = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Flatten/Contrast");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Flatten/Contrast");
|
||||||
if (br) {
|
if (br) {
|
||||||
br->flag |= BRUSH_ACCUMULATE;
|
br->flag |= BRUSH_ACCUMULATE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1051,6 +1051,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot)
|
|||||||
|
|
||||||
static int collection_instance_add_exec(bContext *C, wmOperator *op)
|
static int collection_instance_add_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
Collection *collection;
|
Collection *collection;
|
||||||
unsigned int layer;
|
unsigned int layer;
|
||||||
float loc[3], rot[3];
|
float loc[3], rot[3];
|
||||||
@@ -1059,7 +1060,7 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
|
|||||||
char name[MAX_ID_NAME - 2];
|
char name[MAX_ID_NAME - 2];
|
||||||
|
|
||||||
RNA_string_get(op->ptr, "name", name);
|
RNA_string_get(op->ptr, "name", name);
|
||||||
collection = (Collection *)BKE_libblock_find_name(ID_GR, name);
|
collection = (Collection *)BKE_libblock_find_name(bmain, ID_GR, name);
|
||||||
|
|
||||||
if (0 == RNA_struct_property_is_set(op->ptr, "location")) {
|
if (0 == RNA_struct_property_is_set(op->ptr, "location")) {
|
||||||
const wmEvent *event = CTX_wm_window(C)->eventstate;
|
const wmEvent *event = CTX_wm_window(C)->eventstate;
|
||||||
@@ -1078,7 +1079,6 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
|
|
||||||
if (collection) {
|
if (collection) {
|
||||||
Main *bmain = CTX_data_main(C);
|
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||||
|
|
||||||
@@ -2399,7 +2399,7 @@ static int add_named_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
/* find object, create fake base */
|
/* find object, create fake base */
|
||||||
RNA_string_get(op->ptr, "name", name);
|
RNA_string_get(op->ptr, "name", name);
|
||||||
ob = (Object *)BKE_libblock_find_name(ID_OB, name);
|
ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name);
|
||||||
|
|
||||||
if (ob == NULL) {
|
if (ob == NULL) {
|
||||||
BKE_report(op->reports, RPT_ERROR, "Object not found");
|
BKE_report(op->reports, RPT_ERROR, "Object not found");
|
||||||
|
|||||||
@@ -2504,12 +2504,13 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
|
|||||||
|
|
||||||
static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
Base *base = ED_view3d_give_base_under_cursor(C, event->mval);
|
Base *base = ED_view3d_give_base_under_cursor(C, event->mval);
|
||||||
Material *ma;
|
Material *ma;
|
||||||
char name[MAX_ID_NAME - 2];
|
char name[MAX_ID_NAME - 2];
|
||||||
|
|
||||||
RNA_string_get(op->ptr, "name", name);
|
RNA_string_get(op->ptr, "name", name);
|
||||||
ma = (Material *)BKE_libblock_find_name(ID_MA, name);
|
ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, name);
|
||||||
if (base == NULL || ma == NULL)
|
if (base == NULL || ma == NULL)
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
|
|
||||||
|
|||||||
@@ -905,6 +905,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot)
|
|||||||
|
|
||||||
static int object_select_same_collection_exec(bContext *C, wmOperator *op)
|
static int object_select_same_collection_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
Collection *collection;
|
Collection *collection;
|
||||||
char collection_name[MAX_ID_NAME];
|
char collection_name[MAX_ID_NAME];
|
||||||
|
|
||||||
@@ -913,7 +914,7 @@ static int object_select_same_collection_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
RNA_string_get(op->ptr, "collection", collection_name);
|
RNA_string_get(op->ptr, "collection", collection_name);
|
||||||
|
|
||||||
collection = (Collection *)BKE_libblock_find_name(ID_GR, collection_name);
|
collection = (Collection *)BKE_libblock_find_name(bmain, ID_GR, collection_name);
|
||||||
|
|
||||||
if (!collection) {
|
if (!collection) {
|
||||||
return OPERATOR_PASS_THROUGH;
|
return OPERATOR_PASS_THROUGH;
|
||||||
@@ -955,6 +956,7 @@ void OBJECT_OT_select_same_collection(wmOperatorType *ot)
|
|||||||
/**************************** Select Mirror ****************************/
|
/**************************** Select Mirror ****************************/
|
||||||
static int object_select_mirror_exec(bContext *C, wmOperator *op)
|
static int object_select_mirror_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||||
bool extend;
|
bool extend;
|
||||||
@@ -968,7 +970,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
|
|||||||
BLI_string_flip_side_name(name_flip, primbase->object->id.name + 2, true, sizeof(name_flip));
|
BLI_string_flip_side_name(name_flip, primbase->object->id.name + 2, true, sizeof(name_flip));
|
||||||
|
|
||||||
if (!STREQ(name_flip, primbase->object->id.name + 2)) {
|
if (!STREQ(name_flip, primbase->object->id.name + 2)) {
|
||||||
Object *ob = (Object *)BKE_libblock_find_name(ID_OB, name_flip);
|
Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip);
|
||||||
if (ob) {
|
if (ob) {
|
||||||
Base *secbase = BKE_view_layer_base_find(view_layer, ob);
|
Base *secbase = BKE_view_layer_base_find(view_layer, ob);
|
||||||
|
|
||||||
|
|||||||
@@ -4203,6 +4203,7 @@ static void sculpt_update_cache_invariants(
|
|||||||
wmOperator *op, const float mouse[2])
|
wmOperator *op, const float mouse[2])
|
||||||
{
|
{
|
||||||
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
|
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
|
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
|
||||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||||
@@ -4274,7 +4275,7 @@ static void sculpt_update_cache_invariants(
|
|||||||
BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2,
|
BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2,
|
||||||
sizeof(cache->saved_active_brush_name));
|
sizeof(cache->saved_active_brush_name));
|
||||||
|
|
||||||
br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth");
|
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Smooth");
|
||||||
if (br) {
|
if (br) {
|
||||||
BKE_paint_brush_set(p, br);
|
BKE_paint_brush_set(p, br);
|
||||||
brush = br;
|
brush = br;
|
||||||
@@ -5012,6 +5013,7 @@ static void sculpt_brush_exit_tex(Sculpt *sd)
|
|||||||
|
|
||||||
static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke))
|
static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke))
|
||||||
{
|
{
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
Object *ob = CTX_data_active_object(C);
|
Object *ob = CTX_data_active_object(C);
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
SculptSession *ss = ob->sculpt;
|
SculptSession *ss = ob->sculpt;
|
||||||
@@ -5033,7 +5035,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BKE_brush_size_set(scene, brush, ss->cache->saved_smooth_size);
|
BKE_brush_size_set(scene, brush, ss->cache->saved_smooth_size);
|
||||||
brush = (Brush *)BKE_libblock_find_name(ID_BR, ss->cache->saved_active_brush_name);
|
brush = (Brush *)BKE_libblock_find_name(bmain, ID_BR, ss->cache->saved_active_brush_name);
|
||||||
if (brush) {
|
if (brush) {
|
||||||
BKE_paint_brush_set(&sd->paint, brush);
|
BKE_paint_brush_set(&sd->paint, brush);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ static int unpack_item_exec(bContext *C, wmOperator *op)
|
|||||||
int method = RNA_enum_get(op->ptr, "method");
|
int method = RNA_enum_get(op->ptr, "method");
|
||||||
|
|
||||||
RNA_string_get(op->ptr, "id_name", idname);
|
RNA_string_get(op->ptr, "id_name", idname);
|
||||||
id = BKE_libblock_find_name(type, idname);
|
id = BKE_libblock_find_name(bmain, type, idname);
|
||||||
|
|
||||||
if (id == NULL) {
|
if (id == NULL) {
|
||||||
BKE_report(op->reports, RPT_WARNING, "No packed file");
|
BKE_report(op->reports, RPT_WARNING, "No packed file");
|
||||||
|
|||||||
@@ -400,6 +400,7 @@ static int node_add_mask_poll(bContext *C)
|
|||||||
|
|
||||||
static int node_add_mask_exec(bContext *C, wmOperator *op)
|
static int node_add_mask_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
SpaceNode *snode = CTX_wm_space_node(C);
|
SpaceNode *snode = CTX_wm_space_node(C);
|
||||||
bNode *node;
|
bNode *node;
|
||||||
ID *mask = NULL;
|
ID *mask = NULL;
|
||||||
@@ -407,7 +408,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
|
|||||||
/* check input variables */
|
/* check input variables */
|
||||||
char name[MAX_ID_NAME - 2];
|
char name[MAX_ID_NAME - 2];
|
||||||
RNA_string_get(op->ptr, "name", name);
|
RNA_string_get(op->ptr, "name", name);
|
||||||
mask = BKE_libblock_find_name(ID_MSK, name);
|
mask = BKE_libblock_find_name(bmain, ID_MSK, name);
|
||||||
if (!mask) {
|
if (!mask) {
|
||||||
BKE_reportf(op->reports, RPT_ERROR, "Mask '%s' not found", name);
|
BKE_reportf(op->reports, RPT_ERROR, "Mask '%s' not found", name);
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
|
|||||||
Library *lib = (Library *)tselem->id;
|
Library *lib = (Library *)tselem->id;
|
||||||
char expanded[FILE_MAX];
|
char expanded[FILE_MAX];
|
||||||
|
|
||||||
BKE_library_filepath_set(lib, lib->name);
|
BKE_library_filepath_set(bmain, lib, lib->name);
|
||||||
|
|
||||||
BLI_strncpy(expanded, lib->name, sizeof(expanded));
|
BLI_strncpy(expanded, lib->name, sizeof(expanded));
|
||||||
BLI_path_abs(expanded, bmain->name);
|
BLI_path_abs(expanded, bmain->name);
|
||||||
|
|||||||
@@ -1887,9 +1887,9 @@ static int parent_drop_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
partype = RNA_enum_get(op->ptr, "type");
|
partype = RNA_enum_get(op->ptr, "type");
|
||||||
RNA_string_get(op->ptr, "parent", parname);
|
RNA_string_get(op->ptr, "parent", parname);
|
||||||
par = (Object *)BKE_libblock_find_name(ID_OB, parname);
|
par = (Object *)BKE_libblock_find_name(bmain, ID_OB, parname);
|
||||||
RNA_string_get(op->ptr, "child", childname);
|
RNA_string_get(op->ptr, "child", childname);
|
||||||
ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
|
ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname);
|
||||||
|
|
||||||
if (ID_IS_LINKED(ob)) {
|
if (ID_IS_LINKED(ob)) {
|
||||||
BKE_report(op->reports, RPT_INFO, "Can't edit library linked object");
|
BKE_report(op->reports, RPT_INFO, "Can't edit library linked object");
|
||||||
@@ -1928,9 +1928,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
RNA_string_set(op->ptr, "parent", te->name);
|
RNA_string_set(op->ptr, "parent", te->name);
|
||||||
/* Identify parent and child */
|
/* Identify parent and child */
|
||||||
RNA_string_get(op->ptr, "child", childname);
|
RNA_string_get(op->ptr, "child", childname);
|
||||||
ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
|
ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname);
|
||||||
RNA_string_get(op->ptr, "parent", parname);
|
RNA_string_get(op->ptr, "parent", parname);
|
||||||
par = (Object *)BKE_libblock_find_name(ID_OB, parname);
|
par = (Object *)BKE_libblock_find_name(bmain, ID_OB, parname);
|
||||||
|
|
||||||
if (ELEM(NULL, ob, par)) {
|
if (ELEM(NULL, ob, par)) {
|
||||||
if (par == NULL) printf("par==NULL\n");
|
if (par == NULL) printf("par==NULL\n");
|
||||||
@@ -2085,7 +2085,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
|
|||||||
char obname[MAX_ID_NAME];
|
char obname[MAX_ID_NAME];
|
||||||
|
|
||||||
RNA_string_get(op->ptr, "dragged_obj", obname);
|
RNA_string_get(op->ptr, "dragged_obj", obname);
|
||||||
ob = (Object *)BKE_libblock_find_name(ID_OB, obname);
|
ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, obname);
|
||||||
|
|
||||||
/* search forwards to find the object */
|
/* search forwards to find the object */
|
||||||
outliner_find_id(soops, &soops->tree, (ID *)ob);
|
outliner_find_id(soops, &soops->tree, (ID *)ob);
|
||||||
@@ -2136,10 +2136,10 @@ static int scene_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
|
|
||||||
if (te) {
|
if (te) {
|
||||||
RNA_string_set(op->ptr, "scene", te->name);
|
RNA_string_set(op->ptr, "scene", te->name);
|
||||||
scene = (Scene *)BKE_libblock_find_name(ID_SCE, te->name);
|
scene = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, te->name);
|
||||||
|
|
||||||
RNA_string_get(op->ptr, "object", obname);
|
RNA_string_get(op->ptr, "object", obname);
|
||||||
ob = (Object *)BKE_libblock_find_name(ID_OB, obname);
|
ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, obname);
|
||||||
|
|
||||||
if (ELEM(NULL, ob, scene) || ID_IS_LINKED(scene)) {
|
if (ELEM(NULL, ob, scene) || ID_IS_LINKED(scene)) {
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
@@ -2215,10 +2215,10 @@ static int material_drop_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||||||
|
|
||||||
if (te) {
|
if (te) {
|
||||||
RNA_string_set(op->ptr, "object", te->name);
|
RNA_string_set(op->ptr, "object", te->name);
|
||||||
ob = (Object *)BKE_libblock_find_name(ID_OB, te->name);
|
ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, te->name);
|
||||||
|
|
||||||
RNA_string_get(op->ptr, "material", mat_name);
|
RNA_string_get(op->ptr, "material", mat_name);
|
||||||
ma = (Material *)BKE_libblock_find_name(ID_MA, mat_name);
|
ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, mat_name);
|
||||||
|
|
||||||
if (ELEM(NULL, ob, ma)) {
|
if (ELEM(NULL, ob, ma)) {
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
@@ -2311,7 +2311,7 @@ static int collection_drop_invoke(bContext *C, wmOperator *op, const wmEvent *ev
|
|||||||
Scene *scene = BKE_scene_find_from_collection(bmain, collection);
|
Scene *scene = BKE_scene_find_from_collection(bmain, collection);
|
||||||
BLI_assert(scene);
|
BLI_assert(scene);
|
||||||
RNA_string_get(op->ptr, "child", childname);
|
RNA_string_get(op->ptr, "child", childname);
|
||||||
Object *ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
|
Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname);
|
||||||
BKE_collection_object_add(bmain, collection, ob);
|
BKE_collection_object_add(bmain, collection, ob);
|
||||||
|
|
||||||
DEG_relations_tag_update(bmain);
|
DEG_relations_tag_update(bmain);
|
||||||
|
|||||||
@@ -512,7 +512,7 @@ static void rna_IDMaterials_clear_id(ID *id, Main *bmain, int remove_material_sl
|
|||||||
static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
|
static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
|
||||||
{
|
{
|
||||||
Library *lib = (Library *)ptr->data;
|
Library *lib = (Library *)ptr->data;
|
||||||
BKE_library_filepath_set(lib, value);
|
BKE_library_filepath_set(G.main, lib, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ***** ImagePreview ***** */
|
/* ***** ImagePreview ***** */
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *UN
|
|||||||
char lib_name[MAX_NAME];
|
char lib_name[MAX_NAME];
|
||||||
|
|
||||||
RNA_string_get(op->ptr, "library", lib_name);
|
RNA_string_get(op->ptr, "library", lib_name);
|
||||||
lib = (Library *)BKE_libblock_find_name_ex(CTX_data_main(C), ID_LI, lib_name);
|
lib = (Library *)BKE_libblock_find_name(CTX_data_main(C), ID_LI, lib_name);
|
||||||
|
|
||||||
if (lib) {
|
if (lib) {
|
||||||
if (lib->parent) {
|
if (lib->parent) {
|
||||||
@@ -822,7 +822,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
|
|||||||
char lib_name[MAX_NAME];
|
char lib_name[MAX_NAME];
|
||||||
|
|
||||||
RNA_string_get(op->ptr, "library", lib_name);
|
RNA_string_get(op->ptr, "library", lib_name);
|
||||||
lib = (Library *)BKE_libblock_find_name_ex(CTX_data_main(C), ID_LI, lib_name);
|
lib = (Library *)BKE_libblock_find_name(CTX_data_main(C), ID_LI, lib_name);
|
||||||
|
|
||||||
if (lib) {
|
if (lib) {
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
|
|||||||
@@ -1408,6 +1408,7 @@ void WM_operator_last_properties_ensure(wmOperatorType *ot, PointerRNA *ptr)
|
|||||||
*/
|
*/
|
||||||
ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short idcode)
|
ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short idcode)
|
||||||
{
|
{
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
ID *id = NULL;
|
ID *id = NULL;
|
||||||
/* check input variables */
|
/* check input variables */
|
||||||
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||||
@@ -1435,8 +1436,6 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
|
|||||||
|
|
||||||
if (is_relative_path ) {
|
if (is_relative_path ) {
|
||||||
if (exists == false) {
|
if (exists == false) {
|
||||||
Main *bmain = CTX_data_main(C);
|
|
||||||
|
|
||||||
if (idcode == ID_IM) {
|
if (idcode == ID_IM) {
|
||||||
BLI_path_rel(((Image *)id)->name, bmain->name);
|
BLI_path_rel(((Image *)id)->name, bmain->name);
|
||||||
}
|
}
|
||||||
@@ -1449,7 +1448,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
|
|||||||
else if (RNA_struct_property_is_set(op->ptr, "name")) {
|
else if (RNA_struct_property_is_set(op->ptr, "name")) {
|
||||||
char name[MAX_ID_NAME - 2];
|
char name[MAX_ID_NAME - 2];
|
||||||
RNA_string_get(op->ptr, "name", name);
|
RNA_string_get(op->ptr, "name", name);
|
||||||
id = BKE_libblock_find_name(idcode, name);
|
id = BKE_libblock_find_name(bmain, idcode, name);
|
||||||
if (!id) {
|
if (!id) {
|
||||||
BKE_reportf(op->reports, RPT_ERROR, "%s '%s' not found",
|
BKE_reportf(op->reports, RPT_ERROR, "%s '%s' not found",
|
||||||
BKE_idcode_to_name(idcode), name);
|
BKE_idcode_to_name(idcode), name);
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
|||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
|
|
||||||
/* Currently only brush data-blocks supported. */
|
/* Currently only brush data-blocks supported. */
|
||||||
struct Brush *brush = (struct Brush *)BKE_libblock_find_name(ID_BR, tref_rt->data_block);
|
struct Brush *brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, tref_rt->data_block);
|
||||||
|
|
||||||
if (brush) {
|
if (brush) {
|
||||||
wmWindowManager *wm = bmain->wm.first;
|
wmWindowManager *wm = bmain->wm.first;
|
||||||
|
|||||||
@@ -1593,8 +1593,9 @@ static int arg_handle_python_text_run(int argc, const char **argv, void *data)
|
|||||||
|
|
||||||
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
|
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
/* Make the path absolute because its needed for relative linked blends to be found */
|
/* Make the path absolute because its needed for relative linked blends to be found */
|
||||||
struct Text *text = (struct Text *)BKE_libblock_find_name(ID_TXT, argv[1]);
|
struct Text *text = (struct Text *)BKE_libblock_find_name(bmain, ID_TXT, argv[1]);
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
|
|||||||
Reference in New Issue
Block a user