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:
authorMatt Ebb <matt@mke3.net>2010-03-29 09:37:34 +0400
committerMatt Ebb <matt@mke3.net>2010-03-29 09:37:34 +0400
commitbd7ed4f077d3ff86c1043642b5d228a95d9334a6 (patch)
tree1ffd8bdd0e22d24b88d64825bfc1d65158e0a1a2 /source/blender
parenta59d24fd94d3a5426c13439dc912551e7d81d8fd (diff)
Fix [#21708] Copy/Paste Texture channels for Lamps/World not working
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/material.c67
-rw-r--r--source/blender/editors/include/ED_render.h2
-rw-r--r--source/blender/editors/render/render_intern.h6
-rw-r--r--source/blender/editors/render/render_ops.c5
-rw-r--r--source/blender/editors/render/render_shading.c138
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c2
6 files changed, 125 insertions, 95 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index e877abea7cf..3b17ac1db1a 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1345,70 +1345,3 @@ void paste_matcopybuf(Material *ma)
scrarea_queue_winredraw(curarea);
*/
}
-
-
-static short mtexcopied=0; /* must be reset on file load */
-static MTex mtexcopybuf;
-
-void clear_mat_mtex_copybuf(void)
-{ /* use for file reload */
- mtexcopied= 0;
-}
-
-void copy_mat_mtex_copybuf(ID *id)
-{
- MTex **mtex= NULL;
-
- switch(GS(id->name)) {
- case ID_MA:
- mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
- break;
- case ID_LA:
- // la->mtex[(int)la->texact] // TODO
- break;
- case ID_WO:
- // mtex= wrld->mtex[(int)wrld->texact]; // TODO
- break;
- }
-
- if(mtex && *mtex) {
- memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
- mtexcopied= 1;
- }
- else {
- mtexcopied= 0;
- }
-}
-
-void paste_mat_mtex_copybuf(ID *id)
-{
- MTex **mtex= NULL;
-
- if(mtexcopied == 0 || mtexcopybuf.tex==NULL)
- return;
-
- switch(GS(id->name)) {
- case ID_MA:
- mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
- break;
- case ID_LA:
- // la->mtex[(int)la->texact] // TODO
- break;
- case ID_WO:
- // mtex= wrld->mtex[(int)wrld->texact]; // TODO
- break;
- }
-
- if(mtex) {
- if(*mtex==NULL) {
- *mtex= MEM_mallocN(sizeof(MTex), "mtex copy");
- }
- else if((*mtex)->tex) {
- (*mtex)->tex->id.us--;
- }
-
- memcpy(*mtex, &mtexcopybuf, sizeof(MTex));
-
- id_us_plus((ID *)mtexcopybuf.tex);
- }
-}
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h
index a81c562bccb..6100ecd436f 100644
--- a/source/blender/editors/include/ED_render.h
+++ b/source/blender/editors/include/ED_render.h
@@ -81,4 +81,6 @@ void ED_preview_icon_job(const struct bContext *C, void *owner, struct ID *id, u
void ED_preview_draw(const struct bContext *C, void *idp, void *parentp, void *slot, rcti *rect);
+void ED_render_clear_mtex_copybuf(void);
+
#endif
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h
index 110435c14bd..a0441155629 100644
--- a/source/blender/editors/render/render_intern.h
+++ b/source/blender/editors/render/render_intern.h
@@ -48,12 +48,12 @@ void WORLD_OT_new(struct wmOperatorType *ot);
void MATERIAL_OT_copy(struct wmOperatorType *ot);
void MATERIAL_OT_paste(struct wmOperatorType *ot);
-void MATERIAL_OT_mtex_copy(struct wmOperatorType *ot);
-void MATERIAL_OT_mtex_paste(struct wmOperatorType *ot);
-
void SCENE_OT_render_layer_add(struct wmOperatorType *ot);
void SCENE_OT_render_layer_remove(struct wmOperatorType *ot);
+
+void TEXTURE_OT_slot_copy(struct wmOperatorType *ot);
+void TEXTURE_OT_slot_paste(struct wmOperatorType *ot);
void TEXTURE_OT_slot_move(struct wmOperatorType *ot);
void TEXTURE_OT_envmap_save(struct wmOperatorType *ot);
void TEXTURE_OT_envmap_clear(struct wmOperatorType *ot);
diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c
index d483f8e4af7..b1cb1d9c2f1 100644
--- a/source/blender/editors/render/render_ops.c
+++ b/source/blender/editors/render/render_ops.c
@@ -53,9 +53,6 @@ void ED_operatortypes_render(void)
WM_operatortype_append(MATERIAL_OT_copy);
WM_operatortype_append(MATERIAL_OT_paste);
-
- WM_operatortype_append(MATERIAL_OT_mtex_copy);
- WM_operatortype_append(MATERIAL_OT_mtex_paste);
WM_operatortype_append(SCENE_OT_render_layer_add);
WM_operatortype_append(SCENE_OT_render_layer_remove);
@@ -64,6 +61,8 @@ void ED_operatortypes_render(void)
WM_operatortype_append(SCENE_OT_render_data_set_quicktime_codec);
#endif
+ WM_operatortype_append(TEXTURE_OT_slot_copy);
+ WM_operatortype_append(TEXTURE_OT_slot_paste);
WM_operatortype_append(TEXTURE_OT_slot_move);
WM_operatortype_append(TEXTURE_OT_envmap_save);
WM_operatortype_append(TEXTURE_OT_envmap_clear);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 1876aa5b44a..870eea74464 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -1030,57 +1030,153 @@ void MATERIAL_OT_paste(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int copy_material_mtex_exec(bContext *C, wmOperator *op)
+
+static short mtexcopied=0; /* must be reset on file load */
+static MTex mtexcopybuf;
+
+void ED_render_clear_mtex_copybuf(void)
+{ /* use for file reload */
+ mtexcopied= 0;
+}
+
+void copy_mtex_copybuf(ID *id)
{
- Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+ MTex **mtex= NULL;
+
+ switch(GS(id->name)) {
+ case ID_MA:
+ mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
+ break;
+ case ID_LA:
+ mtex= &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
+ // la->mtex[(int)la->texact] // TODO
+ break;
+ case ID_WO:
+ mtex= &(((World *)id)->mtex[(int)((World *)id)->texact]);
+ // mtex= wrld->mtex[(int)wrld->texact]; // TODO
+ break;
+ }
+
+ if(mtex && *mtex) {
+ memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
+ mtexcopied= 1;
+ }
+ else {
+ mtexcopied= 0;
+ }
+}
- if(ma==NULL)
+void paste_mtex_copybuf(ID *id)
+{
+ MTex **mtex= NULL;
+
+ if(mtexcopied == 0 || mtexcopybuf.tex==NULL)
+ return;
+
+ switch(GS(id->name)) {
+ case ID_MA:
+ mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
+ break;
+ case ID_LA:
+ mtex= &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
+ // la->mtex[(int)la->texact] // TODO
+ break;
+ case ID_WO:
+ mtex= &(((World *)id)->mtex[(int)((World *)id)->texact]);
+ // mtex= wrld->mtex[(int)wrld->texact]; // TODO
+ break;
+ }
+
+ if(mtex) {
+ if(*mtex==NULL) {
+ *mtex= MEM_mallocN(sizeof(MTex), "mtex copy");
+ }
+ else if((*mtex)->tex) {
+ (*mtex)->tex->id.us--;
+ }
+
+ memcpy(*mtex, &mtexcopybuf, sizeof(MTex));
+
+ id_us_plus((ID *)mtexcopybuf.tex);
+ }
+}
+
+
+static int copy_mtex_exec(bContext *C, wmOperator *op)
+{
+ ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+
+ if(id==NULL) {
+ /* copying empty slot */
+ ED_render_clear_mtex_copybuf();
return OPERATOR_CANCELLED;
+ }
- copy_mat_mtex_copybuf(&ma->id);
+ copy_mtex_copybuf(id);
- WM_event_add_notifier(C, NC_MATERIAL, ma);
+ WM_event_add_notifier(C, NC_TEXTURE, NULL);
return OPERATOR_FINISHED;
}
-void MATERIAL_OT_mtex_copy(wmOperatorType *ot)
+static int copy_mtex_poll(bContext *C)
+{
+ ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+
+ return (id != NULL);
+}
+
+void TEXTURE_OT_slot_copy(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Copy Material Texture Settings";
- ot->idname= "MATERIAL_OT_mtex_copy";
+ ot->name= "Copy Texture Slot Settings";
+ ot->idname= "TEXTURE_OT_slot_copy";
ot->description="Copy the material texture settings and nodes";
/* api callbacks */
- ot->exec= copy_material_mtex_exec;
-
+ ot->exec= copy_mtex_exec;
+ ot->poll= copy_mtex_poll;
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int paste_material_mtex_exec(bContext *C, wmOperator *op)
+static int paste_mtex_exec(bContext *C, wmOperator *op)
{
- Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+ ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
- if(ma==NULL)
- return OPERATOR_CANCELLED;
+ if(id==NULL) {
+ Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+ Lamp *la= CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
+ World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data;
+
+ if (ma)
+ id = &ma->id;
+ else if (la)
+ id = &la->id;
+ else if (wo)
+ id = &wo->id;
+
+ if (id==NULL)
+ return OPERATOR_CANCELLED;
+ }
- paste_mat_mtex_copybuf(&ma->id);
+ paste_mtex_copybuf(id);
- WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, ma);
+ WM_event_add_notifier(C, NC_TEXTURE|ND_SHADING_DRAW, NULL);
return OPERATOR_FINISHED;
}
-void MATERIAL_OT_mtex_paste(wmOperatorType *ot)
+void TEXTURE_OT_slot_paste(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Paste Material Texture Settings";
- ot->idname= "MATERIAL_OT_mtex_paste";
- ot->description="Copy the material texture settings and nodes";
+ ot->name= "Paste Texture Slot Settings";
+ ot->idname= "TEXTURE_OT_slot_paste";
+ ot->description="Copy the texture settings and nodes";
/* api callbacks */
- ot->exec= paste_material_mtex_exec;
+ ot->exec= paste_mtex_exec;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index af001aa9627..862255d7cd5 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -155,7 +155,7 @@ void WM_init(bContext *C, int argc, char **argv)
}
clear_matcopybuf();
- clear_mat_mtex_copybuf();
+ ED_render_clear_mtex_copybuf();
// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);