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:
authorCampbell Barton <ideasman42@gmail.com>2010-03-09 12:17:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-03-09 12:17:45 +0300
commitb7a73f9e5b74062d4498a5061281c0d0af9fb026 (patch)
tree1175ff8ca1cff5bd90d5449d7014b4f32c454780 /source/blender/blenkernel
parent6a4b39ed2ce9e44139e91a4daab9ccf6caff0375 (diff)
mtex buffer copy & paste back for materials.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_material.h4
-rw-r--r--source/blender/blenkernel/intern/material.c70
2 files changed, 74 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index 7ec5d172130..07ca5a1c0ee 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -83,6 +83,10 @@ void free_matcopybuf(void);
void copy_matcopybuf(struct Material *ma);
void paste_matcopybuf(struct Material *ma);
+void clear_mat_mtex_copybuf(void);
+void copy_mat_mtex_copybuf(struct ID *id);
+void paste_mat_mtex_copybuf(struct ID *id);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 27b46c40d28..05f0f20feff 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1247,6 +1247,7 @@ static short matcopied=0;
void clear_matcopybuf(void)
{
memset(&matcopybuf, 0, sizeof(Material));
+ matcopied= 0;
}
void free_matcopybuf(void)
@@ -1273,6 +1274,8 @@ void free_matcopybuf(void)
matcopybuf.nodetree= NULL;
}
// default_mtex(&mtexcopybuf);
+
+ matcopied= 0;
}
void copy_matcopybuf(Material *ma)
@@ -1346,3 +1349,70 @@ 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);
+ }
+}