diff options
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index be688cf0c6c..6f6af2d84a5 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -32,20 +32,18 @@ #include "MEM_guardedalloc.h" -#include "DNA_customdata_types.h" #include "DNA_material_types.h" -#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_view3d_types.h" -#include "DNA_windowmanager_types.h" #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_library.h" #include "BKE_material.h" #include "BKE_mesh.h" @@ -321,17 +319,33 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) { Scene *scene= CTX_data_scene(C); Base *base= ED_view3d_give_base_under_cursor(C, event->mval); - Image *ima; + Image *ima= NULL; Mesh *me; Object *obedit; int exitmode= 0; char name[32]; + /* Check context */ + if(base==NULL || base->object->type!=OB_MESH) { + BKE_report(op->reports, RPT_ERROR, "Not an Object or Mesh"); + return OPERATOR_CANCELLED; + } + /* check input variables */ - RNA_string_get(op->ptr, "name", name); - ima= (Image *)find_id("IM", name); - if(base==NULL || base->object->type!=OB_MESH || ima==NULL) { - BKE_report(op->reports, RPT_ERROR, "Not a Mesh or no Image."); + if(RNA_property_is_set(op->ptr, "filepath")) { + char path[FILE_MAX]; + + RNA_string_get(op->ptr, "filepath", path); + ima= BKE_add_image_file(path, + scene ? scene->r.cfra : 1); + } + else { + RNA_string_get(op->ptr, "name", name); + ima= (Image *)find_id("IM", name); + } + + if(!ima) { + BKE_report(op->reports, RPT_ERROR, "Not an Image."); return OPERATOR_CANCELLED; } @@ -377,6 +391,7 @@ void MESH_OT_drop_named_image(wmOperatorType *ot) /* properties */ RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Image name to assign."); + RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); } static int uv_texture_remove_exec(bContext *C, wmOperator *op) @@ -703,7 +718,7 @@ static void mesh_add_faces(Mesh *mesh, int len) /* set default flags */ mface= &mesh->mface[mesh->totface]; for(i=0; i<len; i++, mface++) - mface->flag= SELECT; + mface->flag= ME_FACE_SEL; mesh->totface= totface; } |