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.
This commit is contained in:
parent
4e5ee5b75e
commit
1270ab91be
Notes:
blender-bot
2023-02-14 07:44:27 +01:00
Referenced by issue #48898, shaders are remove from metaballs on cycles render
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue