Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_ops.c
| Context not available. | |||||
| Object *obedit; | Object *obedit; | ||||
| Image *ima; | Image *ima; | ||||
| Main *bmain; | Main *bmain; | ||||
| Tex *tex; | |||||
| PointerRNA ptr, idptr; | PointerRNA ptr, idptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| char _name[MAX_ID_NAME - 2]; | char _name[MAX_ID_NAME - 2]; | ||||
| Context not available. | |||||
| obedit = CTX_data_edit_object(C); | obedit = CTX_data_edit_object(C); | ||||
| bmain = CTX_data_main(C); | bmain = CTX_data_main(C); | ||||
| tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; | |||||
| prop = RNA_struct_find_property(op->ptr, "name"); | prop = RNA_struct_find_property(op->ptr, "name"); | ||||
| RNA_property_string_get(op->ptr, prop, name); | RNA_property_string_get(op->ptr, prop, name); | ||||
| if (!RNA_property_is_set(op->ptr, prop)) { | if (!RNA_property_is_set(op->ptr, prop)) { | ||||
| Context not available. | |||||
| if (!alpha) | if (!alpha) | ||||
| color[3] = 1.0f; | color[3] = 1.0f; | ||||
| if (tex && tex->type == TEX_ENVMAP) { | |||||
| /* Here we control that envmap width = 3 / 2 * envmap height and that | |||||
| * envmap height is a power of 2 to be sure to have a supported envmap resolution. | |||||
| */ | |||||
| if (!(width == ceil(height * 3 / 2) && ((height & (height - 1)) == 0))) { | |||||
| int previous = pow(2, ceil(log(height) / log(2))) / 2; | |||||
| height = previous; | |||||
| width = previous * 3 / 2; | |||||
| BKE_report(op->reports, RPT_ERROR, "Invalid image size for cube map texture user, down to a valid size"); | |||||
| } | |||||
| } | |||||
| ima = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d); | ima = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d); | ||||
| if (!ima) | if (!ima) | ||||
| Context not available. | |||||
| WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); | WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; | if (tex && (tex->type == TEX_IMAGE || tex->type == TEX_ENVMAP)) { | ||||
| if (tex && tex->type == TEX_IMAGE) { | |||||
| if (tex->ima) | if (tex->ima) | ||||
| id_us_min(&tex->ima->id); | id_us_min(&tex->ima->id); | ||||
| tex->ima = ima; | tex->ima = ima; | ||||
| ED_area_tag_redraw(CTX_wm_area(C)); | ED_area_tag_redraw(CTX_wm_area(C)); | ||||
| DAG_id_tag_update(&tex->id, 0); | |||||
| WM_main_add_notifier(NC_TEXTURE, tex); | |||||
| WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, NULL); | |||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||