Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Reynish <william@reynish.com>2010-05-09 22:07:17 +0400
committerWilliam Reynish <william@reynish.com>2010-05-09 22:07:17 +0400
commit95bb364bda806a3d28ae45e2fddfc87842e9234c (patch)
tree03fc0981c65ad9423748f29784a04ae4982049ff /source/blender/editors/mesh/mesh_data.c
parent6d8cb93f71b5fb3b0d1638378e0cd56696337cbe (diff)
***Drag and drop fun!***
Added ability to drag images and movies directly onto objects to assign them as textures. You can drag them from the file browser, directly from the OS or even from other apps. Here's a video to demonstrate: http://www.youtube.com/watch?v=fGe2U8F_JvE Ton wanted to show me how to add it, but he ended up doing almost all of the coding himself ;) Ton/Matt: Dropping a text file in the Text Editor fails for some reason. It aught to work - probably a keymap conflict of some sorts?
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r--source/blender/editors/mesh/mesh_data.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 70352e9399f..4eae2540fcc 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -43,6 +43,7 @@
#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"
@@ -319,11 +320,25 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
char name[32];
/* 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.");
- return OPERATOR_CANCELLED;
+ if(RNA_property_is_set(op->ptr, "path")) {
+ char path[FILE_MAX];
+
+ RNA_string_get(op->ptr, "path", path);
+ ima= BKE_add_image_file(path,
+ scene ? scene->r.cfra : 1);
+
+ if(!ima) {
+ BKE_report(op->reports, RPT_ERROR, "Not an Image.");
+ return OPERATOR_CANCELLED;
+ }
+ }
+ else {
+ 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.");
+ return OPERATOR_CANCELLED;
+ }
}
/* turn mesh in editmode */
@@ -368,6 +383,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, "path", "Path", FILE_MAX, "Filepath", "Path to image file");
}
static int uv_texture_remove_exec(bContext *C, wmOperator *op)