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:
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index baaa5becd44..95534deae66 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -58,7 +58,11 @@
#include "BKE_node.h"
#include "BKE_utildefines.h"
+#ifndef DISABLE_PYTHON
#include "BPY_extern.h"
+#endif
+
+#include "GPU_material.h"
/* used in UI and render */
Material defmaterial;
@@ -75,7 +79,9 @@ void free_material(Material *ma)
MTex *mtex;
int a;
+#ifndef DISABLE_PYTHON
BPY_free_scriptlink(&ma->scriptlink);
+#endif
for(a=0; a<MAX_MTEX; a++) {
mtex= ma->mtex[a];
@@ -95,6 +101,9 @@ void free_material(Material *ma)
ntreeFreeTree(ma->nodetree);
MEM_freeN(ma->nodetree);
}
+
+ if(ma->gpumaterial.first)
+ GPU_material_free(ma);
}
void init_material(Material *ma)
@@ -195,8 +204,10 @@ Material *copy_material(Material *ma)
id_us_plus((ID *)man->mtex[a]->tex);
}
}
-
+
+#ifndef DISABLE_PYTHON
BPY_copy_scriptlink(&ma->scriptlink);
+#endif
if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
@@ -206,6 +217,8 @@ Material *copy_material(Material *ma)
if(ma->nodetree) {
man->nodetree= ntreeCopyTree(ma->nodetree, 0); /* 0 == full new tree */
}
+
+ man->gpumaterial.first= man->gpumaterial.last= NULL;
return man;
}
@@ -629,9 +642,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
if(ma->flarec==0) ma->flarec= 1;
- /* add all texcoflags from mtex */
- ma->texco= 0;
- ma->mapto= 0;
+ /* add all texcoflags from mtex, texco and mapto were cleared in advance */
for(a=0; a<MAX_MTEX; a++) {
/* separate tex switching */
@@ -726,6 +737,16 @@ void init_render_materials(int r_mode, float *amb)
{
Material *ma;
+ /* clear these flags before going over materials, to make sure they
+ * are cleared only once, otherwise node materials contained in other
+ * node materials can go wrong */
+ for(ma= G.main->mat.first; ma; ma= ma->id.next) {
+ if(ma->id.us) {
+ ma->texco= 0;
+ ma->mapto= 0;
+ }
+ }
+
/* two steps, first initialize, then or the flags for layers */
for(ma= G.main->mat.first; ma; ma= ma->id.next) {
/* is_used flag comes back in convertblender.c */