diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-04-19 15:23:50 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-04-19 15:23:50 +0400 |
commit | 8a888dbdc794668d3043b075ae6d7a5d7d0a2c0e (patch) | |
tree | 68e634ce587585c7129f9d1e09278cf7675a2202 /source/blender/blenkernel/intern/object.c | |
parent | d00a0e56f69c00748c635bb06860041a8726d9fd (diff) |
bugfix for [#8256] Creating proxy from linked mesh object removes materials
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5029ac458ab..7a5385def17 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -113,6 +113,8 @@ #include "BPY_extern.h" +#include "blendef.h" + /* Local function protos */ static void solve_parenting (Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul); @@ -1351,11 +1353,29 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) /* skip constraints, constraintchannels, nla? */ - + /* set object type and link to data */ ob->type= target->type; ob->data= target->data; id_us_plus((ID *)ob->data); /* ensures lib data becomes LIB_EXTERN */ + /* copy material and index information */ + ob->actcol= ob->totcol= 0; + if(ob->mat) MEM_freeN(ob->mat); + ob->mat = NULL; + if ((target->totcol) && (target->mat) && OB_SUPPORT_MATERIAL(ob)) { + int i; + ob->colbits = target->colbits; + + ob->actcol= target->actcol; + ob->totcol= target->totcol; + + ob->mat = MEM_dupallocN(target->mat); + for(i=0; i<target->totcol; i++) { + /* dont need to run test_object_materials since we know this object is new and not used elsewhere */ + id_us_plus(ob->mat[i]); + } + } + /* type conversions */ if(target->type == OB_ARMATURE) { copy_object_pose(ob, target); /* data copy, object pointers in constraints */ |