diff options
21 files changed, 554 insertions, 482 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index d3baa8e7bf3..a06940e883c 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -47,8 +47,6 @@ struct bDeformGroup* copy_defgroup (struct bDeformGroup *ingroup); struct bDeformGroup *get_named_vertexgroup (Object *ob, char *name); int get_defgroup_num (struct Object *ob, struct bDeformGroup *dg); -void hook_object_deform(struct Object *ob, int index, float *vec); - int curve_modifier(struct Object *ob, char mode); void mesh_modifier(struct Object *ob, float (**vertexCos_r)[3]); int lattice_modifier(struct Object *ob, char mode); diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 19fc11424ce..e2838622494 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -38,7 +38,6 @@ struct ModifierData; struct DagForest; struct DagNode; struct Object; -struct ListBase; typedef enum { /* Should not be used, only for None modifier type */ @@ -60,14 +59,19 @@ typedef enum { eModifierTypeFlag_AcceptsCVs = (1<<1), eModifierTypeFlag_SupportsMapping = (1<<2), eModifierTypeFlag_SupportsEditmode = (1<<3), - + /* For modifiers that support editmode this determines if the * modifier should be enabled by default in editmode. This should * only be used by modifiers that are relatively speedy and * also generally used in editmode, otherwise let the user enable - * it. + * it by hand. */ eModifierTypeFlag_EnableInEditmode = (1<<4), + + /* For modifiers that require original data and so cannot + * be placed after any non-deformative modifier. + */ + eModifierTypeFlag_RequiresOriginalData = (1<<5), } ModifierTypeFlag; typedef struct ModifierTypeInfo { @@ -126,6 +130,14 @@ typedef struct ModifierTypeInfo { */ int (*dependsOnTime)(struct ModifierData *md); + /* Should call the given _walk_ function on with a pointer to each Object pointer + * that the modifier data stores. This is used for linking on file load and for + * unlinking objects or forwarding object references. + * + * This function is optional. + */ + void (*foreachObjectLink)(struct ModifierData *md, struct Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData); + /* Only for deform types, should apply the deformation * to the given vertex array. If the deformer requires information from * the object it can obtain it from the _derivedData_ argument if non-NULL, @@ -183,9 +195,10 @@ int modifier_supportsMapping(struct ModifierData *md); int modifier_couldBeCage (struct ModifierData *md); void modifier_setError (struct ModifierData *md, char *format, ...); -struct ModifierData* modifiers_findByType (struct ListBase *lb, ModifierType type); -void modifiers_clearErrors (struct ListBase *lb); -int modifiers_getCageIndex (struct ListBase *lb, int *lastPossibleCageIndex_r); +void modifiers_foreachObjectLink (struct Object *ob, void (*walk)(void *userData, struct Object *ob, struct Object **obpoin), void *userData); +struct ModifierData* modifiers_findByType (struct Object *ob, ModifierType type); +void modifiers_clearErrors (struct Object *ob); +int modifiers_getCageIndex (struct Object *ob, int *lastPossibleCageIndex_r); #endif diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 4c5fe962c72..574ff1fd31a 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1393,7 +1393,7 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedM DerivedMesh *dm; int numVerts = me->totvert; - modifiers_clearErrors(&ob->modifiers); + modifiers_clearErrors(ob); if (deform_r) *deform_r = NULL; *final_r = NULL; @@ -1434,6 +1434,10 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedM if (!(md->mode&(1<<useRenderParams))) continue; if (mti->type==eModifierTypeType_OnlyDeform && !useDeform) continue; + if ((mti->flags&eModifierTypeFlag_RequiresOriginalData) && dm) { + modifier_setError(md, "Internal error, modifier requires original data (bad stack position)."); + continue; + } if (mti->isDisabled && mti->isDisabled(md)) continue; /* How to apply modifier depends on (a) what we already have as @@ -1521,9 +1525,9 @@ static void editmesh_calc_modifiers(DerivedMesh **cage_r, DerivedMesh **final_r) ModifierData *md; float (*deformedVerts)[3] = NULL; DerivedMesh *dm; - int i, numVerts, cageIndex = modifiers_getCageIndex(&ob->modifiers, NULL); + int i, numVerts, cageIndex = modifiers_getCageIndex(ob, NULL); - modifiers_clearErrors(&ob->modifiers); + modifiers_clearErrors(ob); if (cage_r && cageIndex==-1) { *cage_r = getEditMeshDerivedMesh(em, NULL); @@ -1535,6 +1539,10 @@ static void editmesh_calc_modifiers(DerivedMesh **cage_r, DerivedMesh **final_r) if (!(md->mode&eModifierMode_Realtime)) continue; if (!(md->mode&eModifierMode_Editmode)) continue; + if ((mti->flags&eModifierTypeFlag_RequiresOriginalData) && dm) { + modifier_setError(md, "Internal error, modifier requires original data (bad stack position)."); + continue; + } if (mti->isDisabled && mti->isDisabled(md)) continue; if (!(mti->flags&eModifierTypeFlag_SupportsEditmode)) continue; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 8e33303d137..a1f04eaa048 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -156,98 +156,13 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) /* *************** HOOK ****************** */ -/* vec==NULL: init - vec is supposed to be local coord, deform happens in local space -*/ - -void hook_object_deform(Object *ob, int index, float *vec) -{ - float totforce; - ObHook *hook; - float vect[3], vectot[3]; - - if(ob->hooks.first==NULL) return; - - /* reinitialize if... */ - if(vec==NULL) { - totforce= 0.0; - for(hook= ob->hooks.first; hook; hook= hook->next) { - if(hook->parent) { - hook->curindex= 0; - Mat4Invert(ob->imat, ob->obmat); - /* apparently this call goes from right to left... */ - Mat4MulSerie(hook->mat, ob->imat, hook->parent->obmat, hook->parentinv, NULL, - NULL, NULL, NULL, NULL); - } - } - return; - } - - totforce= 0.0; - vectot[0]= vectot[1]= vectot[2]= 0.0; - - for(hook= ob->hooks.first; hook; hook= hook->next) { - if(hook->parent) { - - /* is 'index' in hook array? */ - while(hook->curindex < hook->totindex-1) { - if( hook->indexar[hook->curindex] < index ) hook->curindex++; - else break; - } - - if( hook->indexar[hook->curindex]==index ) { - float fac= hook->force, len; - - VecMat4MulVecfl(vect, hook->mat, vec); - - if(hook->falloff!=0.0) { - /* hook->cent is in local coords */ - len= VecLenf(vec, hook->cent); - if(len > hook->falloff) fac= 0.0; - else if(len>0.0) fac*= sqrt(1.0 - len/hook->falloff); - } - if(fac!=0.0) { - totforce+= fac; - vectot[0]+= fac*vect[0]; - vectot[1]+= fac*vect[1]; - vectot[2]+= fac*vect[2]; - } - } - } - } - - /* if totforce < 1.0, we take old position also into account */ - if(totforce<1.0) { - vectot[0]+= (1.0-totforce)*vec[0]; - vectot[1]+= (1.0-totforce)*vec[1]; - vectot[2]+= (1.0-totforce)*vec[2]; - } - else VecMulf(vectot, 1.0/totforce); - - VECCOPY(vec, vectot); -} - - void mesh_modifier(Object *ob, float (**vertexCos_r)[3]) { Mesh *me= ob->data; float (*vertexCos)[3] = NULL; - int a; do_mesh_key(me); - /* hooks */ - if(ob->hooks.first) { - if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); - - /* NULL signals initialize */ - hook_object_deform(ob, 0, NULL); - - for(a=0; a<me->totvert; a++) { - hook_object_deform(ob, a, vertexCos[a]); - } - } - if((ob->softflag & OB_SB_ENABLE) && !(ob->softflag & OB_SB_POSTDEF)) { if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); sbObjectStep(ob, (float)G.scene->r.cfra, vertexCos); @@ -281,15 +196,12 @@ int curve_modifier(Object *ob, char mode) static ListBase nurb={NULL, NULL}; Curve *cu= ob->data; Nurb *nu, *newnu; - BezTriple *bezt; - BPoint *bp; - int a, index, done= 0; + int done= 0; do_curve_key(cu); /* conditions if it's needed */ - if(ob->hooks.first); - else if(ob->parent && ob->partype==PARSKEL); + if(ob->parent && ob->partype==PARSKEL); else if(ob->parent && ob->parent->type==OB_LATTICE); else return 0; @@ -302,39 +214,6 @@ int curve_modifier(Object *ob, char mode) BLI_addtail(&nurb, newnu); nu= nu->next; } - - /* hooks */ - if(ob->hooks.first) { - done= 1; - - /* NULL signals initialize */ - hook_object_deform(ob, 0, NULL); - index= 0; - - nu= cu->nurb.first; - while(nu) { - if((nu->type & 7)==CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; - while(a--) { - hook_object_deform(ob, index++, bezt->vec[0]); - hook_object_deform(ob, index++, bezt->vec[1]); - hook_object_deform(ob, index++, bezt->vec[2]); - bezt++; - } - } - else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; - while(a--) { - hook_object_deform(ob, index++, bp->vec); - bp++; - } - } - - nu= nu->next; - } - } } else if(mode=='e') { /* paste */ @@ -352,14 +231,12 @@ int lattice_modifier(Object *ob, char mode) { static BPoint *bpoint; Lattice *lt= ob->data; - BPoint *bp; - int a, index, done= 0; + int done= 0; do_latt_key(lt); /* conditions if it's needed */ - if(ob->hooks.first); - else if(ob->parent && ob->partype==PARSKEL); + if(ob->parent && ob->partype==PARSKEL); else if((ob->softflag & OB_SB_ENABLE)); else return 0; @@ -367,25 +244,9 @@ int lattice_modifier(Object *ob, char mode) /* copy */ bpoint= MEM_dupallocN(lt->def); - /* hooks */ - if(ob->hooks.first) { - done= 1; - - /* NULL signals initialize */ - hook_object_deform(ob, 0, NULL); - index= 0; - bp= lt->def; - a= lt->pntsu*lt->pntsv*lt->pntsw; - while(a--) { - hook_object_deform(ob, index++, bp->vec); - bp++; - } - } - if((ob->softflag & OB_SB_ENABLE)) { sbObjectStep(ob, (float)G.scene->r.cfra, NULL); } - } else { // end MEM_freeN(lt->def); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index c3428d865fe..323c6793c7d 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -352,16 +352,6 @@ struct DagForest *build_dag(struct Scene *sce, short mask) } } } - if (ob->hooks.first) { - ObHook *hook; - - for(hook= ob->hooks.first; hook; hook= hook->next) { - if(hook->parent) { - node3 = dag_get_node(dag,hook->parent); - dag_add_relation(dag,node3,node,DAG_RL_OB_DATA); - } - } - } if (ob->modifiers.first) { ModifierData *md; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 6f9e2f861b2..d6c4a6838ae 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -4,6 +4,7 @@ #include "BLI_blenlib.h" #include "BLI_rand.h" +#include "BLI_arithb.h" #include "MEM_guardedalloc.h" @@ -56,6 +57,13 @@ static int curveModifier_isDisabled(ModifierData *md) return !cmd->object; } +static void curveModifier_foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) +{ + CurveModifierData *cmd = (CurveModifierData*) md; + + walk(userData, ob, &cmd->object); +} + static void curveModifier_updateDepgraph(ModifierData *md, DagForest *forest, Object *ob, DagNode *obNode) { CurveModifierData *cmd = (CurveModifierData*) md; @@ -98,6 +106,13 @@ static int latticeModifier_isDisabled(ModifierData *md) return !lmd->object; } +static void latticeModifier_foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) +{ + LatticeModifierData *lmd = (LatticeModifierData*) md; + + walk(userData, ob, &lmd->object); +} + static void latticeModifier_updateDepgraph(ModifierData *md, DagForest *forest, Object *ob, DagNode *obNode) { LatticeModifierData *lmd = (LatticeModifierData*) md; @@ -1007,6 +1022,158 @@ static void waveModifier_deformVertsEM(ModifierData *md, Object *ob, void *editD waveModifier_deformVerts(md, ob, NULL, vertexCos, numVerts); } +/* Armature */ + +static void armatureModifier_copyData(ModifierData *md, ModifierData *target) +{ + ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *tamd = (ArmatureModifierData*) target; + + tamd->object = amd->object; +} + +static int armatureModifier_isDisabled(ModifierData *md) +{ + ArmatureModifierData *amd = (ArmatureModifierData*) md; + + return !amd->object; +} + +static void armatureModifier_foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) +{ + ArmatureModifierData *amd = (ArmatureModifierData*) md; + + walk(userData, ob, &amd->object); +} + +static void armatureModifier_updateDepgraph(ModifierData *md, DagForest *forest, Object *ob, DagNode *obNode) +{ + ArmatureModifierData *amd = (ArmatureModifierData*) md; + + if (amd->object) { + DagNode *curNode = dag_get_node(forest, amd->object); + + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA); + } +} + +static void armatureModifier_deformVerts(ModifierData *md, Object *ob, void *derivedData, float (*vertexCos)[3], int numVerts) +{ + ArmatureModifierData *amd = (ArmatureModifierData*) md; + + armature_deform_verts(amd->object, ob, vertexCos, numVerts); +} + +static void armatureModifier_deformVertsEM(ModifierData *md, Object *ob, void *editData, void *derivedData, float (*vertexCos)[3], int numVerts) +{ + ArmatureModifierData *amd = (ArmatureModifierData*) md; + + armature_deform_verts(amd->object, ob, vertexCos, numVerts); +} + +/* Hook */ + +static void hookModifier_initData(ModifierData *md) +{ + HookModifierData *hmd = (HookModifierData*) md; + + hmd->force= 1.0; +} + +static void hookModifier_copyData(ModifierData *md, ModifierData *target) +{ + HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *thmd = (HookModifierData*) target; + + VECCOPY(thmd->cent, hmd->cent); + thmd->falloff = hmd->falloff; + thmd->force = hmd->force; + thmd->object = hmd->object; + thmd->totindex = hmd->totindex; + thmd->indexar = MEM_dupallocN(hmd->indexar); + memcpy(thmd->parentinv, hmd->parentinv, sizeof(hmd->parentinv)); +} + +static void hookModifier_freeData(ModifierData *md) +{ + HookModifierData *hmd = (HookModifierData*) md; + + if (hmd->indexar) MEM_freeN(hmd->indexar); +} + +static int hookModifier_isDisabled(ModifierData *md) +{ + HookModifierData *hmd = (HookModifierData*) md; + + return !hmd->object; +} + +static void hookModifier_foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) +{ + HookModifierData *hmd = (HookModifierData*) md; + + walk(userData, ob, &hmd->object); +} + +static void hookModifier_updateDepgraph(ModifierData *md, DagForest *forest, Object *ob, DagNode *obNode) +{ + HookModifierData *hmd = (HookModifierData*) md; + + if (hmd->object) { + DagNode *curNode = dag_get_node(forest, hmd->object); + + dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA); + } +} + +static void hookModifier_deformVerts(ModifierData *md, Object *ob, void *derivedData, float (*vertexCos)[3], int numVerts) +{ + HookModifierData *hmd = (HookModifierData*) md; + float vec[3], mat[4][4]; + int i; + + Mat4Invert(ob->imat, ob->obmat); + Mat4MulSerie(mat, ob->imat, hmd->object->obmat, hmd->parentinv, NULL, NULL, NULL, NULL, NULL); + + for (i=0; i<hmd->totindex; i++) { + float *co = vertexCos[hmd->indexar[i]]; + float fac = hmd->force; + + if(hmd->falloff!=0.0) { + float len= VecLenf(co, hmd->cent); + if(len > hmd->falloff) fac = 0.0; + else if(len>0.0) fac *= sqrt(1.0 - len/hmd->falloff); + } + + if(fac!=0.0) { + VecMat4MulVecfl(vec, mat, co); + VecLerpf(co, co, vec, fac); + } + } +} + +static void hookModifier_deformVertsEM(ModifierData *md, Object *ob, void *editData, void *derivedData, float (*vertexCos)[3], int numVerts) +{ + HookModifierData *hmd = (HookModifierData*) md; + + hookModifier_deformVerts(md, ob, derivedData, vertexCos, numVerts); +} + +/* Softbody */ + +static void softbodyModifier_deformVerts(ModifierData *md, Object *ob, void *derivedData, float (*vertexCos)[3], int numVerts) +{ + SoftbodyModifierData *hmd = (SoftbodyModifierData*) md; + +// sbObjectStep(ob, (float)G.scene->r.cfra, vertexCos); +} + +static void softbodyModifier_deformVertsEM(ModifierData *md, Object *ob, void *editData, void *derivedData, float (*vertexCos)[3], int numVerts) +{ + SoftbodyModifierData *hmd = (SoftbodyModifierData*) md; + +// sbObjectStep(ob, (float)G.scene->r.cfra, vertexCos); +} /***/ @@ -1044,6 +1211,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode; mti->copyData = curveModifier_copyData; mti->isDisabled = curveModifier_isDisabled; + mti->foreachObjectLink = curveModifier_foreachObjectLink; mti->updateDepgraph = curveModifier_updateDepgraph; mti->deformVerts = curveModifier_deformVerts; mti->deformVertsEM = curveModifier_deformVertsEM; @@ -1053,6 +1221,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode; mti->copyData = latticeModifier_copyData; mti->isDisabled = latticeModifier_isDisabled; + mti->foreachObjectLink = latticeModifier_foreachObjectLink; mti->updateDepgraph = latticeModifier_updateDepgraph; mti->deformVerts = latticeModifier_deformVerts; mti->deformVertsEM = latticeModifier_deformVertsEM; @@ -1097,6 +1266,34 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->deformVerts = waveModifier_deformVerts; mti->deformVertsEM = waveModifier_deformVertsEM; + mti = INIT_TYPE(Armature); + mti->type = eModifierTypeType_OnlyDeform; + mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode; + mti->copyData = armatureModifier_copyData; + mti->isDisabled = armatureModifier_isDisabled; + mti->foreachObjectLink = armatureModifier_foreachObjectLink; + mti->updateDepgraph = armatureModifier_updateDepgraph; + mti->deformVerts = armatureModifier_deformVerts; + mti->deformVertsEM = armatureModifier_deformVertsEM; + + mti = INIT_TYPE(Hook); + mti->type = eModifierTypeType_OnlyDeform; + mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_RequiresOriginalData; + mti->initData = hookModifier_initData; + mti->copyData = hookModifier_copyData; + mti->freeData = hookModifier_freeData; + mti->isDisabled = hookModifier_isDisabled; + mti->foreachObjectLink = hookModifier_foreachObjectLink; + mti->updateDepgraph = hookModifier_updateDepgraph; + mti->deformVerts = hookModifier_deformVerts; + mti->deformVertsEM = hookModifier_deformVertsEM; + + mti = INIT_TYPE(Softbody); + mti->type = eModifierTypeType_OnlyDeform; + mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode; + mti->deformVerts = softbodyModifier_deformVerts; + mti->deformVertsEM = softbodyModifier_deformVertsEM; + typeArrInit = 0; #undef INIT_TYPE } @@ -1108,11 +1305,15 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) } } +/***/ + ModifierData *modifier_new(int type) { ModifierTypeInfo *mti = modifierType_getInfo(type); ModifierData *md = MEM_callocN(mti->structSize, mti->structName); + strcpy(md->name, mti->name); + md->type = type; md->mode = eModifierMode_Realtime|eModifierMode_Render|eModifierMode_Expanded; @@ -1150,9 +1351,9 @@ int modifier_supportsMapping(ModifierData *md) (mti->flags&eModifierTypeFlag_SupportsMapping))) ); } -ModifierData *modifiers_findByType(struct ListBase *lb, ModifierType type) +ModifierData *modifiers_findByType(Object *ob, ModifierType type) { - ModifierData *md = lb->first; + ModifierData *md = ob->modifiers.first; for (; md; md=md->next) if (md->type==type) @@ -1161,18 +1362,32 @@ ModifierData *modifiers_findByType(struct ListBase *lb, ModifierType type) return md; } -void modifiers_clearErrors(struct ListBase *lb) +void modifiers_clearErrors(Object *ob) { - ModifierData *md = lb->first; + ModifierData *md = ob->modifiers.first; + int qRedraw = 0; for (; md; md=md->next) { if (md->error) { MEM_freeN(md->error); md->error = NULL; - allqueue(REDRAWBUTSEDIT, 0); + qRedraw = 1; } } + + if (qRedraw) allqueue(REDRAWBUTSEDIT, 0); +} + +void modifiers_foreachObjectLink(Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) +{ + ModifierData *md = ob->modifiers.first; + + for (; md; md=md->next) { + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + + if (mti->foreachObjectLink) mti->foreachObjectLink(md, ob, walk, userData); + } } void modifier_copyData(ModifierData *md, ModifierData *target) @@ -1212,9 +1427,9 @@ void modifier_setError(ModifierData *md, char *format, ...) allqueue(REDRAWBUTSEDIT, 0); } -int modifiers_getCageIndex(ListBase *lb, int *lastPossibleCageIndex_r) +int modifiers_getCageIndex(Object *ob, int *lastPossibleCageIndex_r) { - ModifierData *md = lb->first; + ModifierData *md = ob->modifiers.first; int i, cageIndex = -1; /* Find the last modifier acting on the cage. */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c8feb7f89ce..ab0ee151209 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -149,29 +149,6 @@ void update_base_layer(Object *ob) } } -static void free_hooks(ListBase *lb) -{ - while(lb->first) { - ObHook *hook= lb->first; - if(hook->indexar) MEM_freeN(hook->indexar); - BLI_remlink(lb, hook); - MEM_freeN(hook); - } -} - -static void copy_hooks(ListBase *new, ListBase *old) -{ - ObHook *hook, *hookn; - new->first= new->last= NULL; - - for(hook= old->first; hook; hook= hook->next) { - hookn= MEM_dupallocN(hook); - hookn->indexar= MEM_dupallocN(hookn->indexar); - BLI_addtail(new, hookn); - } - -} - void object_free_modifiers(Object *ob) { while (ob->modifiers.first) { @@ -233,8 +210,6 @@ void free_object(Object *ob) free_constraint_channels(&ob->constraintChannels); free_nlastrips(&ob->nlastrips); - free_hooks(&ob->hooks); - freedisplist(&ob->disp); BPY_free_scriptlink(&ob->scriptlink); @@ -243,6 +218,15 @@ void free_object(Object *ob) if(ob->soft) sbFree(ob->soft); } +static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin) +{ + Object *unlinkOb = userData; + + if (*obpoin==unlinkOb) { + *obpoin = NULL; + ob->recalc |= OB_RECALC; + } +} void unlink_object(Object *ob) { Object *obt; @@ -252,10 +236,8 @@ void unlink_object(Object *ob) Scene *sce; Curve *cu; Tex *tex; - ObHook *hook; Group *group; bConstraint *con; - ModifierData *md; int a; char *str; @@ -277,30 +259,7 @@ void unlink_object(Object *ob) obt->recalc |= OB_RECALC_OB; } - for(hook=obt->hooks.first; hook; hook= hook->next) { - if(hook->parent==ob) { - hook->parent= NULL; - 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; - } - } - } + modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob); if ELEM(obt->type, OB_CURVE, OB_FONT) { cu= obt->data; @@ -860,8 +819,6 @@ Object *copy_object(Object *ob) copy_nlastrips(&obn->nlastrips, &ob->nlastrips); copy_constraints (&obn->constraints, &ob->constraints); - copy_hooks( &obn->hooks, &ob->hooks); - actcon = clone_constraint_channels (&obn->constraintChannels, &ob->constraintChannels, ob->activecon); /* If the active constraint channel was in this list, update it */ if (actcon) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index d010d16c786..b4da0f1097c 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -745,7 +745,6 @@ static int object_has_edges(Object *ob) /* helper call */ static void set_body_point(Object *ob, BodyPoint *bp, float *vec) { - VECCOPY(bp->pos, vec); Mat4MulVecfl(ob->obmat, bp->pos); // yep, sofbody is global coords VECCOPY(bp->origS, bp->pos); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index cb6ed51a714..a166b070d67 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2119,22 +2119,15 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) /* ************ READ OBJECT ***************** */ -static void lib_link_modifiers(FileData *fd, Object *ob) +static void lib_link_modifiers__linkModifiers(void *userData, Object *ob, Object **obpoin) { - ModifierData *md; + FileData *fd = userData; - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Lattice) { - LatticeModifierData *lmd = (LatticeModifierData*) md; - - lmd->object = newlibadr(fd, ob->id.lib, lmd->object); - } - else if (md->type==eModifierType_Curve) { - CurveModifierData *cmd = (CurveModifierData*) md; - - cmd->object = newlibadr(fd, ob->id.lib, cmd->object); - } - } + *obpoin = newlibadr(fd, ob->id.lib, *obpoin); +} +static void lib_link_modifiers(FileData *fd, Object *ob) +{ + modifiers_foreachObjectLink(ob, lib_link_modifiers__linkModifiers, fd); } static void lib_link_object(FileData *fd, Main *main) @@ -2143,7 +2136,6 @@ static void lib_link_object(FileData *fd, Main *main) bSensor *sens; bController *cont; bActuator *act; - ObHook *hook; void *poin; int warn=0, a; @@ -2265,11 +2257,6 @@ static void lib_link_object(FileData *fd, Main *main) } lib_link_scriptlink(fd, &ob->id, &ob->scriptlink); - - for(hook= ob->hooks.first; hook; hook= hook->next) { - hook->parent= newlibadr(fd, ob->id.lib, hook->parent); - } - lib_link_modifiers(fd, ob); } ob= ob->id.next; @@ -2310,6 +2297,16 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) SubsurfModifierData *smd = (SubsurfModifierData*) md; smd->emCache = smd->mCache = 0; + } else if (md->type==eModifierType_Hook) { + HookModifierData *hmd = (HookModifierData*) md; + + hmd->indexar= newdataadr(fd, hmd->indexar); + if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) { + int a; + for(a=0; a<hmd->totindex; a++) { + SWITCH_INT(hmd->indexar[a]); + } + } } } } @@ -4785,6 +4782,24 @@ static void do_versions(FileData *fd, Library *lib, Main *main) where_is_armature(arm); } for(ob= main->object.first; ob; ob= ob->id.next) { + while (ob->hooks.first) { + ObHook *hook = ob->hooks.first; + HookModifierData *hmd = (HookModifierData*) modifier_new(eModifierType_Hook); + + VECCOPY(hmd->cent, hook->cent); + hmd->falloff = hook->falloff; + hmd->force = hook->force; + hmd->indexar = hook->indexar; + hmd->object = hook->parent; + memcpy(hmd->parentinv, hook->parentinv, sizeof(hmd->parentinv)); + hmd->totindex = hook->totindex; + + BLI_addtail(&ob->modifiers, hmd); + BLI_remlink(&ob->hooks, hook); + + MEM_freeN(hook); + } + // btw. armature_rebuild_pose is further only called on leave editmode if(ob->type==OB_ARMATURE) { if(ob->pose) { diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index fe6b0c56629..920d4ed634a 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -664,13 +664,18 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) ModifierTypeInfo *mti = modifierType_getInfo(md->type); writestruct(wd, DATA, mti->structName, 1, md); + + if (md->type==eModifierType_Hook) { + HookModifierData *hmd = (HookModifierData*) md; + + writedata(wd, DATA, sizeof(int)*hmd->totindex, hmd->indexar); + } } } static void write_objects(WriteData *wd, ListBase *idbase) { Object *ob; - ObHook *hook; int a; ob= idbase->first; @@ -705,11 +710,6 @@ static void write_objects(WriteData *wd, ListBase *idbase) } } - for(hook= ob->hooks.first; hook; hook= hook->next) { - writestruct(wd, DATA, "ObHook", 1, hook); - writedata(wd, DATA, sizeof(int)*hook->totindex, hook->indexar); - } - write_modifiers(wd, &ob->modifiers); } ob= ob->id.next; diff --git a/source/blender/include/BIF_outliner.h b/source/blender/include/BIF_outliner.h index 448a6be5884..1a33b3d0810 100644 --- a/source/blender/include/BIF_outliner.h +++ b/source/blender/include/BIF_outliner.h @@ -60,11 +60,12 @@ typedef struct TreeElement { #define TSE_EBONE 6 #define TSE_CONSTRAINT_BASE 7 #define TSE_CONSTRAINT 8 -#define TSE_HOOKS_BASE 9 -#define TSE_HOOK 10 -#define TSE_SCRIPT_BASE 11 -#define TSE_POSE_BASE 12 -#define TSE_POSE_CHANNEL 13 +#define TSE_MODIFIER_BASE 9 +#define TSE_MODIFIER 10 +#define TSE_MODIFIER_OB 11 +#define TSE_SCRIPT_BASE 12 +#define TSE_POSE_BASE 13 +#define TSE_POSE_CHANNEL 14 /* button events */ #define OL_NAMEBUTTON 1 diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index cddf8809c14..e849cdbf114 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -215,10 +215,8 @@ void test_idbutton_cb(void *namev, void *arg2_unused); /* *********************** */ #define B_ANIMBUTS 1500 -#define B_RECALCPATH 1401 +#define B_RECALCPATH 1401 #define B_TRACKBUTS 1402 -#define B_DEL_HOOK 1403 -#define B_CLR_HOOK 1404 #define B_PRINTSPEED 1413 #define B_PRINTLEN 1414 diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index ee43dd543cd..5847e2cd01a 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -14,6 +14,9 @@ typedef enum ModifierType { eModifierType_Mirror, eModifierType_Decimate, eModifierType_Wave, + eModifierType_Armature, + eModifierType_Hook, + eModifierType_Softbody, NUM_MODIFIER_TYPES } ModifierType; @@ -23,7 +26,6 @@ typedef enum ModifierType { * for render calc. */ typedef enum ModifierMode { - eModifierMode_Disabled = 0, eModifierMode_Realtime = (1<<0), eModifierMode_Render = (1<<1), eModifierMode_Editmode = (1<<2), @@ -35,6 +37,7 @@ typedef struct ModifierData { struct ModifierData *next, *prev; int type, mode; + char name[32]; char *error; } ModifierData; @@ -95,4 +98,27 @@ typedef struct WaveModifierData { float timeoffs, lifetime; } WaveModifierData; +typedef struct ArmatureModifierData { + ModifierData modifier; + + struct Object *object; +} ArmatureModifierData; + +typedef struct HookModifierData { + ModifierData modifier; + + struct Object *object; + float parentinv[4][4]; /* matrix making current transform unmodified */ + float cent[3]; /* visualization of hook */ + float falloff; /* if not zero, falloff is distance where influence zero */ + + int *indexar; + int totindex; + float force; +} HookModifierData; + +typedef struct SoftbodyModifierData { + ModifierData modifier; +} SoftbodyModifierData; + #endif diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 0f6c2fcf909..354f204087f 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -511,11 +511,13 @@ void do_modifier_panels(unsigned short event) switch(event) { case B_MODIFIER_REDRAW: allqueue(REDRAWBUTSEDIT, 0); + allqueue(REDRAWOOPS, 0); break; case B_MODIFIER_RECALC: allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWOOPS, 0); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); break; } @@ -590,6 +592,17 @@ static void modifiers_moveDown(void *ob_v, void *md_v) ModifierData *md = md_v; if (md->next) { + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + + if (mti->flags&eModifierTypeFlag_RequiresOriginalData) { + ModifierTypeInfo *nmti = modifierType_getInfo(md->next->type); + + if (nmti->type!=eModifierTypeType_OnlyDeform) { + error("Cannot move beyond a non-deforming modifier."); + return; + } + } + BLI_remlink(&ob->modifiers, md); BLI_insertlink(&ob->modifiers, md->next, md); } @@ -629,6 +642,23 @@ static void modifier_testCurveObj(char *name, ID **idpp) *idpp= 0; } +static void modifier_testArmatureObj(char *name, ID **idpp) +{ + ID *id; + + for (id= G.main->object.first; id; id= id->next) { + if( strcmp(name, id->name+2)==0 ) { + if (((Object *)id)->type != OB_ARMATURE) { + error ("Armature deform object must be an armature"); + break; + } + *idpp= id; + return; + } + } + *idpp= 0; +} + static void modifiers_applyModifier(void *obv, void *mdv) { Object *ob = obv; @@ -718,6 +748,19 @@ static void modifiers_setSubsurfIncremental(void *ob_v, void *md_v) } } +static void modifiers_clearHookOffset(void *ob_v, void *md_v) +{ + Object *ob = ob_v; + ModifierData *md = md_v; + HookModifierData *hmd = (HookModifierData*) md; + + if (hmd->object) { + Mat4Invert(hmd->object->imat, hmd->object->obmat); + Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + BIF_undo_push("Clear hook"); + } +} + static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco, int *yco, int index, int cageIndex, int lastCageIndex) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -737,7 +780,14 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiRoundBox(x+4+10, y-18, x+width+10, y+6, 5.0); BIF_ThemeColor(color); - uiDefBut(block, LABEL, B_NOP, mti->name, x+5, y-1, 100, 19, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiBlockBeginAlign(block); + uiDefBut(block, TEX, B_MODIFIER_REDRAW, "", x+10, y-1, width-120-60-10, 19, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); + uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+width-120-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering"); + uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, VICON_VIEW3D, x+width-120-60+20, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display"); + if (mti->flags&eModifierTypeFlag_SupportsEditmode) { + uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, VICON_EDIT, x+width-120-60+40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)"); + } + uiBlockEndAlign(block); uiBlockSetEmboss(block, UI_EMBOSSR); @@ -756,7 +806,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco icon = ICON_BLANK1; } uiBlockSetCol(block, color); - but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, icon, x+width-120, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode"); + but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, icon, x+width-105, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode"); uiButSetFunc(but, modifiers_setOnCage, ob, md); uiBlockSetCol(block, TH_AUTO); } @@ -778,14 +828,6 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco BIF_ThemeColor(color); uiBlockSetEmboss(block, UI_EMBOSS); - uiBlockBeginAlign(block); - uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+width-120-90, y, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering"); - uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, VICON_VIEW3D, x+width-120-90+20, y, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display"); - if (mti->flags&eModifierTypeFlag_SupportsEditmode) { - uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, VICON_EDIT, x+width-120-90+40, y, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)"); - } - uiBlockEndAlign(block); - if (!(md->mode&eModifierMode_Expanded)) { y -= 18; } else { @@ -798,17 +840,23 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco if (md->type==eModifierType_Subsurf) { height = 86; } else if (md->type==eModifierType_Lattice) { - height = 86; + height = 46; } else if (md->type==eModifierType_Curve) { - height = 86; + height = 46; } else if (md->type==eModifierType_Build) { height = 86; } else if (md->type==eModifierType_Mirror) { - height = 86; + height = 46; } else if (md->type==eModifierType_Decimate) { - height = 66; + height = 46; } else if (md->type==eModifierType_Wave) { height = 200; + } else if (md->type==eModifierType_Armature) { + height = 46; + } else if (md->type==eModifierType_Hook) { + height = 86; + } else if (md->type==eModifierType_Softbody) { + height = 46; } BIF_ThemeColor(color); @@ -845,10 +893,10 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiDefButBitS(block, TOG, eSubsurfModifierFlag_DebugIncr, B_MODIFIER_RECALC, "Debug", lx+90, cy,70,19,&smd->flags, 0, 0, 0, 0, "Visualize the subsurf incremental calculation, for debugging effect of other modifiers"); } else if (md->type==eModifierType_Lattice) { LatticeModifierData *lmd = (LatticeModifierData*) md; - uiDefIDPoinBut(block, modifier_testLatticeObj, B_CHANGEDEP, "Ob:", lx, (cy-=19), 120,19, &lmd->object, "Lattice object to deform with"); + uiDefIDPoinBut(block, modifier_testLatticeObj, B_CHANGEDEP, "Ob: ", lx, (cy-=19), 120,19, &lmd->object, "Lattice object to deform with"); } else if (md->type==eModifierType_Curve) { CurveModifierData *cmd = (CurveModifierData*) md; - uiDefIDPoinBut(block, modifier_testCurveObj, B_CHANGEDEP, "Ob:", lx, (cy-=19), 120,19, &cmd->object, "Curve object to deform with"); + uiDefIDPoinBut(block, modifier_testCurveObj, B_CHANGEDEP, "Ob: ", lx, (cy-=19), 120,19, &cmd->object, "Curve object to deform with"); } else if (md->type==eModifierType_Build) { BuildModifierData *bmd = (BuildModifierData*) md; uiDefButF(block, NUM, B_MODIFIER_RECALC, "Start:", lx, (cy-=19), 160,19, &bmd->start, 1.0, 9000.0, 100, 0, "Specify the start frame of the effect"); @@ -883,6 +931,18 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiDefButF(block, NUMSLI, B_MODIFIER_RECALC, "Heigth:", lx,(cy-=19),220,19, &wmd->height, -2.0, 2.0, 0, 0, "Specify the amplitude of the wave"); uiDefButF(block, NUMSLI, B_MODIFIER_RECALC, "Width:", lx,(cy-=19),220,19, &wmd->width, 0.0, 5.0, 0, 0, "Specify the width of the wave"); uiDefButF(block, NUMSLI, B_MODIFIER_RECALC, "Narrow:", lx,(cy-=19),220,19, &wmd->narrow, 0.0, 10.0, 0, 0, "Specify how narrow the wave follows"); + } else if (md->type==eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData*) md; + uiDefIDPoinBut(block, modifier_testArmatureObj, B_CHANGEDEP, "Ob: ", lx, (cy-=19), 120,19, &amd->object, "Armature object to deform with"); + } else if (md->type==eModifierType_Hook) { + HookModifierData *hmd = (HookModifierData*) md; + uiDefButF(block, NUM, B_MODIFIER_RECALC, "Falloff: ", lx, (cy-=19), 160,19, &hmd->falloff, 0.0, 100.0, 100, 0, "If not zero, the distance from hook where influence ends"); + uiDefButF(block, NUMSLI, B_MODIFIER_RECALC, "Force: ", lx, (cy-=19), 160,19, &hmd->force, 0.0, 1.0, 100, 0, "Set relative force of hook"); + uiDefIDPoinBut(block, test_obpoin_but, B_CHANGEDEP, "Ob: ", lx, (cy-=19), 160,19, &hmd->object, "Parent Object for hook, also recalculates and clears offset"); + but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Clear offset", lx, (cy-=19), 160,19, NULL, 0.0, 0.0, 0, 0, "Recalculate and clear offset (transform) of hook"); + uiButSetFunc(but, modifiers_clearHookOffset, ob, md); + } else if (md->type==eModifierType_Softbody) { + uiDefBut(block, LABEL, 1, "See Softbody panel.", lx, (cy-=19), 160,19, NULL, 0.0, 0.0, 0, 0, ""); } uiBlockEndAlign(block); @@ -913,9 +973,8 @@ static void editing_panel_modifiers(Object *ob) ModifierData *md; uiBlock *block; char str[64]; - int xco, yco, i, lastCageIndex, cageIndex = modifiers_getCageIndex(&ob->modifiers, &lastCageIndex); + int xco, yco, i, lastCageIndex, cageIndex = modifiers_getCageIndex(ob, &lastCageIndex); - // XXX ofsx should probably be changed in other panels here block= uiNewBlock(&curarea->uiblocks, "editing_panel_modifiers", UI_EMBOSS, UI_HELV, curarea->win); if( uiNewPanel(curarea, block, "Modifiers", "Editing", 640, 0, 318, 204)==0) return; diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 7e5405f3e3f..9ce1ecb099f 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1032,60 +1032,6 @@ static void object_panel_draw(Object *ob) } -static void object_panel_hooks(Object *ob) -{ - uiBlock *block; - ObHook *hook; - int tothook=0, nr, active; - char *cp; - - block= uiNewBlock(&curarea->uiblocks, "object_panel_hooks", UI_EMBOSS, UI_HELV, curarea->win); - uiNewPanelTabbed("Draw", "Object"); - if(uiNewPanel(curarea, block, "Hooks", "Object", 320, 0, 318, 204)==0) return; - - if(ob->hooks.first==NULL) { - uiDefBut(block, LABEL, 0, "Add hooks in Editmode", 10,180,300,19, NULL, 0, 0, 0, 0, ""); - return; - } - - /* build menu */ - for(hook= ob->hooks.first; hook; hook= hook->next) tothook++; - - cp= MEM_callocN(32*tothook+32, "temp string"); - strcpy(cp, "Active Hook %t|"); - - for(hook= ob->hooks.first; hook; hook= hook->next) { - strcat(cp, hook->name); - strcat(cp, " |"); - } - /* active is stored in first hook */ - hook= ob->hooks.first; - if(hook->active<1 || hook->active > tothook) hook->active= 1; - active= hook->active; - - uiBlockBeginAlign(block); - uiDefButS(block, MENU, B_REDR, cp, 10,180,150,19, &hook->active, 0, 0, 0, 0, "Set active hook"); - MEM_freeN(cp); - - for(nr=1, hook= ob->hooks.first; hook; hook= hook->next, nr++) { - if(nr==active) break; - } - if(hook==NULL) printf("error in object_panel_hooks\n"); - - uiDefBut(block, TEX, B_REDR, "Name: ", 160,180,150,19, hook->name, 0, 31, 0, 0, "Set name of hook"); - - uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_MAKEDISP, "Falloff: ", 160,140,150,19, &hook->falloff, 0.0, 100.0, 100, 0, "If not zero, the distance from hook where influence ends"); - uiDefButF(block, NUMSLI, B_MAKEDISP, "Force: ", 160,120,150,19, &hook->force, 0.0, 1.0, 100, 0, "Set relative force of hook"); - uiBlockEndAlign(block); - - uiDefIDPoinBut(block, test_obpoin_but, B_CLR_HOOK, "Parent:", 10, 120, 150, 19, &hook->parent, "Parent Object for hook, also recalculates and clears offset"); - - uiBlockBeginAlign(block); - uiDefBut(block, BUT, B_DEL_HOOK, "Delete", 10,80,150,19, NULL, 0.0, 0.0, 0, 0, "Delete hook"); - uiDefBut(block, BUT, B_CLR_HOOK, "Clear offset", 160,80,150,19, NULL, 0.0, 0.0, 0, 0, "Recalculate and clear offset (transform) of hook"); -} - static void softbody_bake(Object *ob) { SoftBody *sb= ob->soft; @@ -1139,7 +1085,6 @@ static void softbody_bake(Object *ob) void do_object_panels(unsigned short event) { Object *ob; - ObHook *hook; Effect *eff; ob= OBACT; @@ -1150,42 +1095,6 @@ void do_object_panels(unsigned short event) DAG_object_flush_update(G.scene, ob, OB_RECALC_OB); allqueue(REDRAWVIEW3D, 0); break; - case B_DEL_HOOK: - hook= ob->hooks.first; - if(hook) { - int active= hook->active, nr; - for(nr=1, hook=ob->hooks.first; hook; hook=hook->next, nr++) { - if(active==nr) break; - } - if(hook) { - BLI_remlink(&ob->hooks, hook); - if(hook->indexar) MEM_freeN(hook->indexar); - MEM_freeN(hook); - } - freedisplist(&ob->disp); - BIF_undo_push("Delete hook"); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWBUTSOBJECT, 0); - } - break; - case B_CLR_HOOK: - hook= ob->hooks.first; - if(hook) { - int active= hook->active, nr; - for(nr=1, hook=ob->hooks.first; hook; hook=hook->next, nr++) { - if(active==nr) break; - } - if(hook && hook->parent) { - Mat4Invert(hook->parent->imat, hook->parent->obmat); - /* apparently this call goes from right to left... */ - Mat4MulSerie(hook->parentinv, hook->parent->imat, ob->obmat, NULL, - NULL, NULL, NULL, NULL, NULL); - DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - BIF_undo_push("Clear hook"); - allqueue(REDRAWVIEW3D, 0); - } - } - break; case B_RECALCPATH: DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA); allqueue(REDRAWVIEW3D, 0); @@ -1782,7 +1691,6 @@ void object_panels() object_panel_anim(ob); object_panel_draw(ob); - object_panel_hooks(ob); object_panel_constraint(); if(ob->type==OB_MESH) { object_panel_effects(ob); diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 02b90877b6c..9ad5fe1f566 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -58,6 +58,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_meta_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_object_force.h" #include "DNA_space_types.h" @@ -3387,27 +3388,30 @@ static void drawWireExtra(Object *ob) /* should be called in view space */ static void draw_hooks(Object *ob) { - ObHook *hook; + ModifierData *md; float vec[3]; - for(hook= ob->hooks.first; hook; hook= hook->next) { - - VecMat4MulVecfl(vec, ob->obmat, hook->cent); - if(hook->parent) { - setlinestyle(3); - glBegin(GL_LINES); - glVertex3fv(hook->parent->obmat[3]); - glVertex3fv(vec); - glEnd(); - setlinestyle(0); - } + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Hook) { + HookModifierData *hmd = (HookModifierData*) md; - glPointSize(3.0); - bglBegin(GL_POINTS); - bglVertex3fv(vec); - bglEnd(); - glPointSize(1.0); + VecMat4MulVecfl(vec, ob->obmat, hmd->cent); + if(hmd->object) { + setlinestyle(3); + glBegin(GL_LINES); + glVertex3fv(hmd->object->obmat[3]); + glVertex3fv(vec); + glEnd(); + setlinestyle(0); + } + + glPointSize(3.0); + bglBegin(GL_POINTS); + bglVertex3fv(vec); + bglEnd(); + glPointSize(1.0); + } } } @@ -3782,7 +3786,7 @@ void draw_object(Base *base) ListBase *list; /* draw hook center and offset line */ - if(ob->hooks.first && ob!=G.obedit) draw_hooks(ob); + if(ob!=G.obedit) draw_hooks(ob); /* help lines and so */ if(ob!=G.obedit && ob->parent && (ob->parent->lay & G.vd->lay)) { diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 8beb90d2062..35f3b44091c 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -1995,7 +1995,7 @@ static void add_verts_to_closest_dgroup(Object *ob, Object *par) mesh = (Mesh*)ob->data; /* Is subsurf on? Lets use the verts on the limit surface then */ - if (modifiers_findByType(&ob->modifiers, eModifierType_Subsurf)) { + if (modifiers_findByType(ob, eModifierType_Subsurf)) { subverts = MEM_mallocN(3*mesh->totvert*sizeof(float), "subverts"); subsurf_calculate_limit_positions(mesh, (void *)subverts); /* (ton) made void*, dunno how to cast */ } diff --git a/source/blender/src/editmesh_loop.c b/source/blender/src/editmesh_loop.c index c10f7ac4c0d..813498b1043 100644 --- a/source/blender/src/editmesh_loop.c +++ b/source/blender/src/editmesh_loop.c @@ -695,7 +695,7 @@ short seg_intersect(EditEdge *e, CutCurve *c, int len) int i; short isect=0; - /* Get screen coords of verts (v->xs and v->ys clip if off screen */ + /* Get screen coords of verts */ VECCOPY(co, e->v1->co); co[3]= 1.0; Mat4MulVec4fl(G.obedit->obmat, co); diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index 5ed2470c33e..09bb08255bd 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -1077,8 +1077,6 @@ void fill_mesh(void) ok= BLI_edgefill(0); - /* printf("time: %d\n",(clock()-tijd)/1000); */ - if(ok) { efa= fillfacebase.first; while(efa) { @@ -1087,7 +1085,6 @@ void fill_mesh(void) efa= efa->next; } } - /* else printf("fill error\n"); */ BLI_end_edgefill(); @@ -4436,8 +4433,6 @@ int EdgeSlide(short immediate, float imperc) tempsv->origvert.no[0] = ev->no[0]; tempsv->origvert.no[1] = ev->no[1]; tempsv->origvert.no[2] = ev->no[2]; - tempsv->origvert.xs = ev->xs; - tempsv->origvert.ys = ev->ys; // i is total edges that vert is on // j is total selected edges that vert is on diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 65839cd84e5..82851ee82d2 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -307,16 +307,16 @@ static int return_editmesh_indexar(int **indexar, float *cent) return totvert; } -static void select_editmesh_hook(ObHook *hook) +static void select_editmesh_hook(HookModifierData *hmd) { EditMesh *em = G.editMesh; EditVert *eve; int index=0, nr=0; for(eve= em->verts.first; eve; eve= eve->next, nr++) { - if(nr==hook->indexar[index]) { + if(nr==hmd->indexar[index]) { eve->f |= SELECT; - if(index < hook->totindex-1) index++; + if(index < hmd->totindex-1) index++; } } EM_select_flush(); @@ -361,7 +361,7 @@ static int return_editlattice_indexar(int **indexar, float *cent) return totvert; } -static void select_editlattice_hook(ObHook *hook) +static void select_editlattice_hook(HookModifierData *hmd) { BPoint *bp; int index=0, nr=0, a; @@ -370,9 +370,9 @@ static void select_editlattice_hook(ObHook *hook) a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw; bp= editLatt->def; while(a--) { - if(hook->indexar[index]==nr) { + if(hmd->indexar[index]==nr) { bp->f1 |= SELECT; - if(index < hook->totindex-1) index++; + if(index < hmd->totindex-1) index++; } nr++; bp++; @@ -455,7 +455,7 @@ static int return_editcurve_indexar(int **indexar, float *cent) return totvert; } -static void select_editcurve_hook(ObHook *hook) +static void select_editcurve_hook(HookModifierData *hmd) { extern ListBase editNurb; Nurb *nu; @@ -468,19 +468,19 @@ static void select_editcurve_hook(ObHook *hook) bezt= nu->bezt; a= nu->pntsu; while(a--) { - if(nr == hook->indexar[index]) { + if(nr == hmd->indexar[index]) { bezt->f1 |= SELECT; - if(index<hook->totindex-1) index++; + if(index<hmd->totindex-1) index++; } nr++; - if(nr == hook->indexar[index]) { + if(nr == hmd->indexar[index]) { bezt->f2 |= SELECT; - if(index<hook->totindex-1) index++; + if(index<hmd->totindex-1) index++; } nr++; - if(nr == hook->indexar[index]) { + if(nr == hmd->indexar[index]) { bezt->f3 |= SELECT; - if(index<hook->totindex-1) index++; + if(index<hmd->totindex-1) index++; } nr++; @@ -491,9 +491,9 @@ static void select_editcurve_hook(ObHook *hook) bp= nu->bp; a= nu->pntsu*nu->pntsv; while(a--) { - if(nr == hook->indexar[index]) { + if(nr == hmd->indexar[index]) { bp->f1 |= SELECT; - if(index<hook->totindex-1) index++; + if(index<hmd->totindex-1) index++; } nr++; bp++; @@ -504,14 +504,15 @@ static void select_editcurve_hook(ObHook *hook) void add_hook(void) { + ModifierData *md = NULL; + HookModifierData *hmd = NULL; Object *ob=NULL; - ObHook *hook=NULL; float cent[3]; int tot=0, *indexar, mode; if(G.obedit==NULL) return; - if(G.obedit->hooks.first) + if(modifiers_findByType(G.obedit, eModifierType_Hook)) mode= pupmenu("Hooks %t|Add Hook, To New Empty %x1|Add Hook, To Selected Object %x2|Remove... %x3|Reassign... %x4|Select... %x5|Clear Offset...%x6"); else mode= pupmenu("Hooks %t|Add, New Empty %x1|Add, To Selected Object %x2"); @@ -541,7 +542,10 @@ void add_hook(void) char *cp; // make pupmenu with hooks - for(hook= G.obedit->hooks.first; hook; hook= hook->next) maxlen+=32; + for(md=G.obedit->modifiers.first; md; md= md->next) { + if (md->type==eModifierType_Hook) + maxlen+=32; + } if(maxlen==0) { error("Object has no hooks yet"); @@ -554,9 +558,11 @@ void add_hook(void) else if(mode==5) strcpy(cp, "Select %t|"); else if(mode==6) strcpy(cp, "Clear Offset %t|"); - for(hook= G.obedit->hooks.first; hook; hook= hook->next) { - strcat(cp, hook->name); - strcat(cp, " |"); + for(md=G.obedit->modifiers.first; md; md= md->next) { + if (md->type==eModifierType_Hook) { + strcat(cp, md->name); + strcat(cp, " |"); + } } nr= pupmenu(cp); @@ -565,10 +571,15 @@ void add_hook(void) if(nr<1) return; a= 1; - for(hook= G.obedit->hooks.first; hook; hook= hook->next, a++) { - if(a==nr) break; + for(md=G.obedit->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Hook) { + if(a==nr) break; + a++; + } } - ob= hook->parent; + + hmd = (HookModifierData*) md; + ob= hmd->object; } /* do it, new hooks or reassign */ @@ -611,17 +622,16 @@ void add_hook(void) /* new hook */ if(mode==1 || mode==2) { - hook= MEM_callocN(sizeof(ObHook), "new hook"); - BLI_addtail(&G.obedit->hooks, hook); - strncpy(hook->name, ob->id.name+2, 30); - hook->force= 1.0; + hmd = (HookModifierData*) modifier_new(eModifierType_Hook); + BLI_addtail(&G.obedit->modifiers, &hmd); // XXX, ordering + sprintf("Hook-%s", hmd->modifier.name, ob->id.name+2); } - else MEM_freeN(hook->indexar); // reassign, hook was set + else if (hmd->indexar) MEM_freeN(hmd->indexar); // reassign, hook was set - hook->parent= ob; - hook->indexar= indexar; - VECCOPY(hook->cent, cent); - hook->totindex= tot; + hmd->object= ob; + hmd->indexar= indexar; + VECCOPY(hmd->cent, cent); + hmd->totindex= tot; if(mode==1 || mode==2) { /* matrix calculus */ @@ -632,28 +642,27 @@ void add_hook(void) Mat4Invert(ob->imat, ob->obmat); /* apparently this call goes from right to left... */ - Mat4MulSerie(hook->parentinv, ob->imat, G.obedit->obmat, NULL, + Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL, NULL, NULL, NULL, NULL, NULL); } } } else if(mode==3) { // remove - BLI_remlink(&G.obedit->hooks, hook); - MEM_freeN(hook->indexar); - MEM_freeN(hook); + BLI_remlink(&G.obedit->modifiers, md); + modifier_free(md); } else if(mode==5) { // select - if(G.obedit->type==OB_MESH) select_editmesh_hook(hook); - else if(G.obedit->type==OB_LATTICE) select_editlattice_hook(hook); - else if(G.obedit->type==OB_CURVE) select_editcurve_hook(hook); - else if(G.obedit->type==OB_SURF) select_editcurve_hook(hook); + if(G.obedit->type==OB_MESH) select_editmesh_hook(hmd); + else if(G.obedit->type==OB_LATTICE) select_editlattice_hook(hmd); + else if(G.obedit->type==OB_CURVE) select_editcurve_hook(hmd); + else if(G.obedit->type==OB_SURF) select_editcurve_hook(hmd); } else if(mode==6) { // clear offset where_is_object(ob); // ob is hook->parent Mat4Invert(ob->imat, ob->obmat); /* this call goes from right to left... */ - Mat4MulSerie(hook->parentinv, ob->imat, G.obedit->obmat, NULL, + Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL, NULL, NULL, NULL, NULL, NULL); } @@ -2318,7 +2327,7 @@ void convertmenu(void) */ void flip_subdivison(Object *ob, int level) { - ModifierData *md = modifiers_findByType(&ob->modifiers, eModifierType_Subsurf); + ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf); if (md) { SubsurfModifierData *smd = (SubsurfModifierData*) md; @@ -2464,6 +2473,8 @@ static void copymenu_modifiers(Object *ob) for (i=eModifierType_None+1; i<NUM_MODIFIER_TYPES; i++) { ModifierTypeInfo *mti = modifierType_getInfo(i); + if (i==eModifierType_Hook) continue; + if ( (mti->flags&eModifierTypeFlag_AcceptsCVs) || (ob->type==OB_MESH && (mti->flags&eModifierTypeFlag_AcceptsMesh))) { sprintf(str+strlen(str), "|%s%%x%d", mti->name, i); @@ -2485,15 +2496,17 @@ static void copymenu_modifiers(Object *ob) object_free_modifiers(base->object); for (md=ob->modifiers.first; md; md=md->next) { - ModifierData *nmd = modifier_new(md->type); - modifier_copyData(md, nmd); - BLI_addtail(&base->object->modifiers, nmd); + if (md->type!=eModifierType_Hook) { + ModifierData *nmd = modifier_new(md->type); + modifier_copyData(md, nmd); + BLI_addtail(&base->object->modifiers, nmd); + } } } else { - ModifierData *md = modifiers_findByType(&ob->modifiers, event); + ModifierData *md = modifiers_findByType(ob, event); if (md) { - ModifierData *tmd = modifiers_findByType(&base->object->modifiers, event); + ModifierData *tmd = modifiers_findByType(base->object, event); if (!tmd) { tmd = modifier_new(event); @@ -2727,10 +2740,10 @@ void copy_attr(short event) } else if(event==21){ if (base->object->type==OB_MESH) { - ModifierData *md = modifiers_findByType(&ob->modifiers, eModifierType_Subsurf); + ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf); if (md) { - ModifierData *tmd = modifiers_findByType(&base->object->modifiers, eModifierType_Subsurf); + ModifierData *tmd = modifiers_findByType(base->object, eModifierType_Subsurf); if (!tmd) { tmd = modifier_new(eModifierType_Subsurf); @@ -3444,6 +3457,10 @@ void rightmouse_transform(void) /* ************************************** */ +static void single_object_users__forwardModifierLinks(void *userData, Object *ob, Object **obpoin) +{ + ID_NEW(*obpoin); +} void single_object_users(int flag) { Base *base; @@ -3485,17 +3502,10 @@ void single_object_users(int flag) relink_constraints(&chan->constraints); } } - if(base->object->hooks.first) { - ObHook *hook= base->object->hooks.first; - while(hook) { - ID_NEW(hook->parent); - hook= hook->next; - } - } + modifiers_foreachObjectLink(base->object, single_object_users__forwardModifierLinks, NULL); ID_NEW(ob->parent); ID_NEW(ob->track); - } } base= base->next; @@ -4012,7 +4022,10 @@ void make_local(void) BIF_undo_push("Make local"); } - +static void adduplicate__forwardModifierLinks(void *userData, Object *ob, Object **obpoin) +{ + ID_NEW(*obpoin); +} void adduplicate(int noTrans) /* dtrans is 3 x 3xfloat dloc, drot en dsize */ { @@ -4206,7 +4219,6 @@ void adduplicate(int noTrans) base= FIRSTBASE; while(base) { if TESTBASELIB(base) { - relink_constraints(&base->object->constraints); if (base->object->pose){ bPoseChannel *chan; @@ -4214,13 +4226,7 @@ void adduplicate(int noTrans) relink_constraints(&chan->constraints); } } - if(base->object->hooks.first) { - ObHook *hook= base->object->hooks.first; - while(hook) { - ID_NEW(hook->parent); - hook= hook->next; - } - } + modifiers_foreachObjectLink(base->object, adduplicate__forwardModifierLinks, NULL); ID_NEW(base->object->parent); ID_NEW(base->object->track); diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c index ceae2838650..16745342fae 100644 --- a/source/blender/src/outliner.c +++ b/source/blender/src/outliner.c @@ -47,6 +47,7 @@ #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" +#include "DNA_modifier_types.h" #include "DNA_nla_types.h" #include "DNA_object_types.h" #include "DNA_oops_types.h" @@ -65,6 +66,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_material.h" +#include "BKE_modifier.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -367,7 +369,6 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone, TreeElement *parent, int *a); - static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index) { @@ -502,16 +503,25 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } } - if(ob->hooks.first) { - ObHook *hook; - TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_HOOKS_BASE, 0); - int a= 0; - - tenla->name= "Hooks"; - for(hook=ob->hooks.first; hook; hook= hook->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, hook->parent, tenla, TSE_HOOK, a); - if(ten) ten->name= hook->name; + if(ob->modifiers.first) { + ModifierData *md; + TreeElement *temod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0); + int index; + + for (index=0,md=ob->modifiers.first; md; index++,md=md->next) { + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + TreeElement *te = outliner_add_element(soops, &temod->subtree, ob, temod, TSE_MODIFIER, index); + if(te) te->name= md->name; + + if (md->type==eModifierType_Lattice) { + outliner_add_element(soops, &te->subtree, ((LatticeModifierData*) md)->object, te, TSE_MODIFIER_OB, 0); + } else if (md->type==eModifierType_Curve) { + outliner_add_element(soops, &te->subtree, ((CurveModifierData*) md)->object, te, TSE_MODIFIER_OB, 0); + } else if (md->type==eModifierType_Armature) { + outliner_add_element(soops, &te->subtree, ((ArmatureModifierData*) md)->object, te, TSE_MODIFIER_OB, 0); + } else if (md->type==eModifierType_Hook) { + outliner_add_element(soops, &te->subtree, ((HookModifierData*) md)->object, te, TSE_MODIFIER_OB, 0); + } } } if(ob->defbase.first) { @@ -1298,6 +1308,14 @@ static int tree_element_active_ebone(TreeElement *te, TreeStoreElem *tselem, int return 0; } +static int tree_element_active_modifier(TreeElement *te, TreeStoreElem *tselem, int set) +{ + if(set) { + extern_set_butspace(F9KEY); + } + + return 0; +} static int tree_element_active_text(SpaceOops *soops, TreeElement *te, int set) { @@ -1369,7 +1387,9 @@ static int tree_element_type_active(SpaceOops *soops, TreeElement *te, TreeStore return tree_element_active_bone(te, tselem, set); case TSE_EBONE: return tree_element_active_ebone(te, tselem, set); - case TSE_HOOK: // actually object + case TSE_MODIFIER: + return tree_element_active_modifier(te, tselem, set); + case TSE_MODIFIER_OB: if(set) tree_element_active_object(soops, te); else if(tselem->id==(ID *)OBACT) return 1; break; @@ -1417,7 +1437,7 @@ static int do_outliner_mouse_event(SpaceOops *soops, TreeElement *te, short even /* activate a name button? */ if(G.qual & LR_CTRLKEY) { - if(ELEM5(tselem->type, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_HOOKS_BASE, TSE_SCRIPT_BASE)) + if(ELEM5(tselem->type, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE)) error("Cannot edit builtin name"); else { tselem->flag |= TSE_TEXTBUT; @@ -1903,9 +1923,9 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem) BIF_draw_icon(x, y, ICON_WPAINT_DEHLT); break; case TSE_CONSTRAINT_BASE: BIF_draw_icon(x, y, ICON_CONSTRAINT); break; - case TSE_HOOKS_BASE: + case TSE_MODIFIER_BASE: BIF_draw_icon(x, y, ICON_HOOK); break; - case TSE_HOOK: + case TSE_MODIFIER_OB: BIF_draw_icon(x, y, ICON_OBJECT); break; case TSE_SCRIPT_BASE: BIF_draw_icon(x, y, ICON_TEXT); break; @@ -2326,15 +2346,14 @@ static void outliner_buttons(uiBlock *block, SpaceOops *soops, ListBase *lb) tselem= TREESTORE(te); if(tselem->flag & TSE_TEXTBUT) { - if(tselem->type==TSE_EBONE) { - len= 32; - } - else len= 19; + if(tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name); + else if (tselem->type==TSE_MODIFIER) len = sizeof(((ModifierData*) 0)->name); + else len= sizeof(((ID*) 0)->name)-2; dx= BIF_GetStringWidth(G.font, te->name, 0); if(dx<50) dx= 50; - bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", te->xs+2*OL_X-4, te->ys, dx+10, OL_H-1, te->name, 1.0, (float)len, 0, 0, ""); + bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", te->xs+2*OL_X-4, te->ys, dx+10, OL_H-1, te->name, 1.0, (float)len-1, 0, 0, ""); uiButSetFunc(bt, namebutton_cb, soops, NULL); // signal for button to open |