diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-20 17:29:54 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-20 17:42:09 +0300 |
commit | 1270ab91be53fd90e404e6366c73cc99ba470b14 (patch) | |
tree | 3ed3599fbc4788d0fa430485ba0a622787f288d3 /source/blender/blenkernel | |
parent | 4e5ee5b75e19b24eeceee489f2958e9000d0f2fb (diff) |
Fix T48898: shaders are removed from metaballs on cycles render.
Note that issue has several levels here actually, first one was metaball's materials
not being properly copied into new mesh (code was commented out because of some crash it
seems, made it a bit closer to mesh one and got no crash at all...).
Then, we were calling test_object_materials when ob->data is actually *not* new tmpmesh!
Will remove this call completely in next commit (to make it easier to bisect), I cannot see
any case where object would be assigned with newly generated tmpmesh in this func.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index b2f57328df3..0ad3847988e 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -31,6 +31,7 @@ #include "DNA_scene_types.h" #include "DNA_material_types.h" +#include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" @@ -2394,23 +2395,25 @@ Mesh *BKE_mesh_new_from_object( } break; -#if 0 - /* Crashes when assigning the new material, not sure why */ case OB_MBALL: - tmpmb = (MetaBall *)ob->data; + { + MetaBall *tmpmb = (MetaBall *)ob->data; + tmpmesh->mat = MEM_dupallocN(tmpmb->mat); tmpmesh->totcol = tmpmb->totcol; /* free old material list (if it exists) and adjust user counts */ if (tmpmb->mat) { for (i = tmpmb->totcol; i-- > 0; ) { - tmpmesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */ + /* are we an object material or data based? */ + tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpmb->mat[i]; + if (tmpmesh->mat[i]) { - id_us_plus(&tmpmb->mat[i]->id); + id_us_plus(&tmpmesh->mat[i]->id); } } } break; -#endif + } case OB_MESH: if (!cage) { @@ -2439,7 +2442,9 @@ Mesh *BKE_mesh_new_from_object( } /* make sure materials get updated in object */ - test_object_materials(ob, &tmpmesh->id); + if (ob->data == tmpmesh) { /* XXX To be removed, there is no reason that ob->data would be new tmpmesh... */ + test_object_materials(ob, &tmpmesh->id); + } return tmpmesh; } |