From bacb560634f8e1dbe6100f723bf303fa037d598a Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 20 Jul 2005 18:04:50 +0000 Subject: [PATCH] - readfile incorrectly increased user count for Lattice & Curve modifier objects - make unlink_object clear Lattice & Curve Modifier object references - add expand_modifiers for liblinking There really needs to be a more consistent and unified way of dealing with datablock references between objects. It should be possible to make this generic so that lib_link, expand_, DEP graph, unlink, oops and maybe outliner can use a single API. The code to deal with this is too bulky and error prone at the moment. --- source/blender/blenkernel/intern/object.c | 19 +++++++++++++++++ source/blender/blenloader/intern/readfile.c | 23 +++++++++++++++++++-- source/blender/src/editobject.c | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 00134a9c03a..9b70f2923f7 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -253,6 +253,7 @@ void unlink_object(Object *ob) ObHook *hook; Group *group; bConstraint *con; + ModifierData *md; int a; char *str; @@ -280,6 +281,24 @@ void unlink_object(Object *ob) obt->recalc |= OB_RECALC; } } + + for (md=obt->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Curve) { + CurveModifierData *cmd = (CurveModifierData*) md; + + if (cmd->object==ob) { + cmd->object = NULL; + obt->recalc |= OB_RECALC; + } + } else if (md->type==eModifierType_Lattice) { + LatticeModifierData *lmd = (LatticeModifierData*) md; + + if (lmd->object==ob) { + lmd->object = NULL; + obt->recalc |= OB_RECALC; + } + } + } if ELEM(obt->type, OB_CURVE, OB_FONT) { cu= obt->data; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 7972dd92046..8385535ed8b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2117,12 +2117,12 @@ static void lib_link_modifier_data(FileData *fd, Object *ob, ModifierData *md) if (md->type==eModifierType_Lattice) { LatticeModifierData *lmd = (LatticeModifierData*) md; - lmd->object = newlibadr_us(fd, ob->id.lib, lmd->object); + lmd->object = newlibadr(fd, ob->id.lib, lmd->object); } else if (md->type==eModifierType_Curve) { CurveModifierData *cmd = (CurveModifierData*) md; - cmd->object = newlibadr_us(fd, ob->id.lib, cmd->object); + cmd->object = newlibadr(fd, ob->id.lib, cmd->object); } } @@ -5194,8 +5194,23 @@ static void expand_action(FileData *fd, Main *mainvar, bAction *act) } } +static void expand_modifier(FileData *fd, Main *mainvar, ModifierData *md) +{ + if (md->type==eModifierType_Lattice) { + LatticeModifierData *lmd = (LatticeModifierData*) md; + + expand_doit(fd, mainvar, lmd->object); + } + else if (md->type==eModifierType_Curve) { + CurveModifierData *cmd = (CurveModifierData*) md; + + expand_doit(fd, mainvar, cmd->object); + } +} + static void expand_object(FileData *fd, Main *mainvar, Object *ob) { + ModifierData *md; bSensor *sens; bController *cont; bActuator *act; @@ -5207,6 +5222,10 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) expand_doit(fd, mainvar, ob->ipo); expand_doit(fd, mainvar, ob->action); + for (md=ob->modifiers.first; md; md=md->next) { + expand_modifier(fd, mainvar, md); + } + expand_pose(fd, mainvar, ob->pose); expand_constraints(fd, mainvar, &ob->constraints); expand_constraint_channels(fd, mainvar, &ob->constraintChannels); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index b866d522561..8d1e4377beb 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -3950,7 +3950,7 @@ void adduplicate(int noTrans) ob= base->object; obn= copy_object(ob); - obn->recalc |= OB_RECALC_OB; + obn->recalc |= OB_RECALC; basen= MEM_mallocN(sizeof(Base), "duplibase"); *basen= *base;