Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2005-07-28 00:16:41 +0400
committerDaniel Dunbar <daniel@zuster.org>2005-07-28 00:16:41 +0400
commit4b1588e277d6a6e6bc7dc9553652d2ca4aad2d73 (patch)
tree39310f93a57a9d3cbac4be639723a5aed2eb6291 /source/blender/blenkernel
parent410512e2656007587cc1671c71c37cbc0b5bda4f (diff)
- update storage.c to use standard time codes (should fix issue
with MSVS 8) - broke mesh_create_shadedColors out of shadeDispList, used to build vertex colors for mesh in vpaint as well (also fixed bug where they were not initialized correctly for subsurfs) - added modifier_copyData and modifier_findByType functions - change editmode modifiers to only calculate if Realtime and Editmode bits are both set, makes more sense for copying modifiers - update object_copy to correctly copy modifiers - removed duplicate redefinition of ME_ attributes in python, this is a horrible idea, why was it done in the first place? - update armature auto vertex group code to check for subsurf in modifier stack - fixed flip_subdivision to work with move to modifier stack - added copymenu_modifiers, can copy all modifiers or just data from first modifier of a certain type (not sure how to deal with multiple modifiers of same type... not a big issue though I think)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_displist.h2
-rw-r--r--source/blender/blenkernel/BKE_modifier.h9
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c1
-rw-r--r--source/blender/blenkernel/intern/displist.c273
-rw-r--r--source/blender/blenkernel/intern/mesh.c2
-rw-r--r--source/blender/blenkernel/intern/modifier.c91
-rw-r--r--source/blender/blenkernel/intern/object.c9
7 files changed, 266 insertions, 121 deletions
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index eb66397fb37..463b7b22e1d 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -147,5 +147,7 @@ void imagestodisplist(void);
void reshadeall_displist(void);
void filldisplist(struct ListBase *dispbase, struct ListBase *to);
+void mesh_create_shadedColors(struct Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r);
+
#endif
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index e407c04159c..94e174f0e0e 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -38,6 +38,7 @@ struct ModifierData;
struct DagForest;
struct DagNode;
struct Object;
+struct ListBase;
typedef enum {
/* Should not be used, only for None modifier type */
@@ -91,6 +92,11 @@ typedef struct ModifierTypeInfo {
*/
void (*initData)(struct ModifierData *md);
+ /* Copy instance data for this modifier type. Should copy all user
+ * level settings to the target modifier.
+ */
+ void (*copyData)(struct ModifierData *md, struct ModifierData *target);
+
/* Free internal modifier data variables, this function should
* not free the _md_ variable itself.
*
@@ -171,7 +177,10 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type);
struct ModifierData* modifier_new (int type);
void modifier_free (struct ModifierData *md);
+void modifier_copyData (struct ModifierData *md, struct ModifierData *target);
int modifier_dependsOnTime (struct ModifierData *md);
+struct ModifierData* modifiers_findByType (struct ListBase *lb, ModifierType type);
+
#endif
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 3b00fb034a0..615429bee9f 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1393,6 +1393,7 @@ static void editmesh_calc_modifiers(DerivedMesh **cage_r, DerivedMesh **final_r)
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_get_info(md->type);
+ if (!(md->mode&eModifierMode_Realtime)) continue;
if (!(md->mode&eModifierMode_Editmode)) continue;
if (mti->isDisabled && mti->isDisabled(md)) continue;
if (!(mti->flags&eModifierTypeFlag_SupportsEditmode)) continue;
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 15c16db3142..bebd7bf4d93 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -603,7 +603,7 @@ void addnormalsDispList(Object *ob, ListBase *lb)
float *n1, *n2, *n3, *n4;
int a, b, p1, p2, p3, p4;
-
+
dl= lb->first;
while(dl) {
@@ -661,18 +661,11 @@ void addnormalsDispList(Object *ob, ListBase *lb)
}
}
-
-void shadeDispList(Object *ob)
+static void init_fastshade_for_ob(Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3])
{
- DispList *dl, *dlob;
- Material *ma = NULL;
- Curve *cu;
- float *orco=NULL, imat[3][3], tmat[4][4], mat[4][4], vec[3], xn, yn, zn;
- float *fp, *nor, n1[3];
- unsigned int *col1;
- int a, need_orco = 0;
+ float tmat[4][4];
+ int a;
- if(ob->flag & OB_FROMDUPLI) return;
initfastshade();
Mat4MulMat4(mat, ob->obmat, fviewmat);
@@ -680,129 +673,176 @@ void shadeDispList(Object *ob)
Mat4Invert(tmat, mat);
Mat3CpyMat4(imat, tmat);
if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0);
-
- dl = find_displist(&ob->disp, DL_VERTCOL);
- if (dl) {
- BLI_remlink(&ob->disp, dl);
- free_disp_elem(dl);
- }
- need_orco= 0;
+ if (need_orco_r) *need_orco_r= 0;
for(a=0; a<ob->totcol; a++) {
- ma= give_current_material(ob, a+1);
+ Material *ma= give_current_material(ob, a+1);
if(ma) {
init_render_material(ma);
- if(ma->texco & TEXCO_ORCO) need_orco= 1;
+ if(ma->texco & TEXCO_ORCO) {
+ if (need_orco_r) *need_orco_r= 1;
+ }
}
}
+}
+static void end_fastshade_for_ob(Object *ob)
+{
+ int a;
- if(ob->type==OB_MESH) {
- Mesh *me= ob->data;
- int dmNeedsFree;
- DerivedMesh *dm= mesh_get_derived_final(ob, &dmNeedsFree);
- DispListMesh *dlm;
- MVert *mvert;
- float *vnors, *vn;
- int i;
-
- if (need_orco) {
- orco = mesh_create_orco(ob);
- }
+ for(a=0; a<ob->totcol; a++) {
+ Material *ma= give_current_material(ob, a+1);
+ if(ma) end_render_material(ma);
+ }
+}
- dlm= dm->convertToDispListMesh(dm);
+void mesh_create_shadedColors(Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r)
+{
+ Mesh *me= ob->data;
+ int dmNeedsFree;
+ DerivedMesh *dm;
+ DispListMesh *dlm;
+ unsigned int *col1, *col2;
+ float *orco, *vnors, imat[3][3], mat[4][4], vec[3];
+ int a, i, need_orco;
+
+ init_fastshade_for_ob(ob, &need_orco, mat, imat);
+
+ if (need_orco) {
+ orco = mesh_create_orco(ob);
+ } else {
+ orco = NULL;
+ }
+
+ if (onlyForMesh) {
+ dm = mesh_get_derived_deform(ob, &dmNeedsFree);
+ } else {
+ dm = mesh_get_derived_final(ob, &dmNeedsFree);
+ }
+ dlm= dm->convertToDispListMesh(dm);
- dlob= MEM_callocN(sizeof(DispList), "displistshade");
- BLI_addtail(&ob->disp, dlob);
- dlob->type= DL_VERTCOL;
+ col1 = MEM_mallocN(sizeof(*col1)*dlm->totface*4, "col1");
+ if (col2_r && (me->flag & ME_TWOSIDED)) {
+ col2 = MEM_mallocN(sizeof(*col2)*dlm->totface*4, "col1");
+ } else {
+ col2 = NULL;
+ }
- dlob->col1= MEM_mallocN(sizeof(*dlob->col1)*dlm->totface*4, "col1");
- if (me->flag & ME_TWOSIDED)
- dlob->col2= MEM_mallocN(sizeof(*dlob->col2)*dlm->totface*4, "col1");
-
+ *col1_r = col1;
+ if (col2_r) *col2_r = col2;
+
/* vertexnormals */
- vn=vnors= MEM_mallocN(dlm->totvert*3*sizeof(float), "vnors disp");
- mvert= dlm->mvert;
- a= dlm->totvert;
- while(a--) {
-
- xn= mvert->no[0];
- yn= mvert->no[1];
- zn= mvert->no[2];
-
+ vnors= MEM_mallocN(dlm->totvert*3*sizeof(float), "vnors disp");
+ for (a=0; a<dlm->totvert; a++) {
+ MVert *mv = &dlm->mvert[a];
+ float *vn= &vnors[a*3];
+ float xn= mv->no[0];
+ float yn= mv->no[1];
+ float zn= mv->no[2];
+
/* transpose ! */
- vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
- vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
- vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
- Normalise(vn);
+ vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
+ vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
+ vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
+ Normalise(vn);
+ }
+
+ for (i=0; i<dlm->totface; i++) {
+ MFace *mf= &dlm->mface[i];
+
+ if (mf->v3) {
+ int j, vidx[4], nverts= mf->v4?4:3;
+ unsigned char *col1base= (unsigned char*) &col1[i*4];
+ unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL);
+ unsigned char *mcolbase;
+ Material *ma= give_current_material(ob, mf->mat_nr+1);
+ float nor[3], n1[3];
- mvert++; vn+=3;
- }
-
- for (i=0; i<dlm->totface; i++) {
- MFace *mf= &dlm->mface[i];
-
- if (mf->v3) {
- int j, vidx[4], nverts= mf->v4?4:3;
- unsigned char *col1base= (unsigned char*) &dlob->col1[i*4];
- unsigned char *col2base= (unsigned char*) (dlob->col2?&dlob->col2[i*4]:NULL);
- unsigned char *mcolbase;
- float nor[3];
-
- if (dlm->tface) {
- mcolbase = (unsigned char*) dlm->tface[i].col;
- } else if (dlm->mcol) {
- mcolbase = (unsigned char*) &dlm->mcol[i*4];
- } else {
- mcolbase = NULL;
- }
+ if(ma==0) ma= &defmaterial;
+
+ if (dlm->tface) {
+ mcolbase = (unsigned char*) dlm->tface[i].col;
+ } else if (dlm->mcol) {
+ mcolbase = (unsigned char*) &dlm->mcol[i*4];
+ } else {
+ mcolbase = NULL;
+ }
- ma= give_current_material(ob, mf->mat_nr+1);
- if(ma==0) ma= &defmaterial;
-
- vidx[0]= mf->v1;
- vidx[1]= mf->v2;
- vidx[2]= mf->v3;
- vidx[3]= mf->v4;
-
- // XXX, should all DLM's have normals?
- if (dlm->nors) {
- VECCOPY(nor, &dlm->nors[i*3]);
- } else {
- if (mf->v4)
- CalcNormFloat4(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, dlm->mvert[mf->v4].co, nor);
- else
- CalcNormFloat(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, nor);
- }
+ vidx[0]= mf->v1;
+ vidx[1]= mf->v2;
+ vidx[2]= mf->v3;
+ vidx[3]= mf->v4;
+
+ // XXX, should all DLM's have normals?
+ if (dlm->nors) {
+ VECCOPY(nor, &dlm->nors[i*3]);
+ } else {
+ if (mf->v4)
+ CalcNormFloat4(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, dlm->mvert[mf->v4].co, nor);
+ else
+ CalcNormFloat(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, nor);
+ }
- n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
- n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
- n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
- Normalise(n1);
-
- vn = n1;
- for (j=0; j<nverts; j++) {
- MVert *mv= &dlm->mvert[vidx[j]];
- unsigned char *col1= &col1base[j*4];
- unsigned char *col2= col2base?&col2base[j*4]:NULL;
- unsigned char *mcol= mcolbase?&mcolbase[j*4]:NULL;
-
- VECCOPY(vec, mv->co);
- Mat4MulVecfl(mat, vec);
- if(mf->flag & ME_SMOOTH) vn= vnors+3*vidx[j];
- fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2, mcol);
- }
+ n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
+ n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
+ n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
+ Normalise(n1);
+
+ for (j=0; j<nverts; j++) {
+ MVert *mv= &dlm->mvert[vidx[j]];
+ unsigned char *col1= &col1base[j*4];
+ unsigned char *col2= col2base?&col2base[j*4]:NULL;
+ unsigned char *mcol= mcolbase?&mcolbase[j*4]:NULL;
+ float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
+
+ VECCOPY(vec, mv->co);
+ Mat4MulVecfl(mat, vec);
+ fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2, mcol);
}
}
- MEM_freeN(vnors);
- displistmesh_free(dlm);
+ }
+ MEM_freeN(vnors);
+ displistmesh_free(dlm);
- if (orco) {
- MEM_freeN(orco);
- }
+ if (orco) {
+ MEM_freeN(orco);
+ }
+
+ if (dmNeedsFree) dm->release(dm);
+
+ end_fastshade_for_ob(ob);
+}
- if (dmNeedsFree) dm->release(dm);
+void shadeDispList(Object *ob)
+{
+ DispList *dl, *dlob;
+ Material *ma = NULL;
+ Curve *cu;
+ float imat[3][3], mat[4][4], vec[3];
+ float *fp, *nor, n1[3];
+ unsigned int *col1;
+ int a;
+
+ if(ob->flag & OB_FROMDUPLI) return;
+
+ dl = find_displist(&ob->disp, DL_VERTCOL);
+ if (dl) {
+ BLI_remlink(&ob->disp, dl);
+ free_disp_elem(dl);
+ }
+
+ if(ob->type==OB_MESH) {
+ dl= MEM_callocN(sizeof(DispList), "displistshade");
+ BLI_addtail(&ob->disp, dl);
+ dl->type= DL_VERTCOL;
+
+ mesh_create_shadedColors(ob, 0, &dl->col1, &dl->col2);
+
+ return;
}
- else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
+
+ init_fastshade_for_ob(ob, NULL, mat, imat);
+
+ if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
/* now we need the normals */
cu= ob->data;
@@ -910,10 +950,7 @@ void shadeDispList(Object *ob)
}
}
- for(a=0; a<ob->totcol; a++) {
- ma= give_current_material(ob, a+1);
- if(ma) end_render_material(ma);
- }
+ end_fastshade_for_ob(ob);
}
void reshadeall_displist(void)
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 41e9d0b4c70..c61797f2396 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -197,8 +197,6 @@ Mesh *add_mesh()
me->smoothresh= 30;
me->texflag= AUTOSPACE;
me->flag= ME_TWOSIDED;
- me->subdiv= 1;
- me->subdivr = 1;
me->bb= unit_boundbox();
return me;
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 7f60fdda187..0c43b128141 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -39,6 +39,14 @@ static int noneModifier_isDisabled(ModifierData *md)
/* Curve */
+static void curveModifier_copyData(ModifierData *md, ModifierData *target)
+{
+ CurveModifierData *cmd = (CurveModifierData*) md;
+ CurveModifierData *tcmd = (CurveModifierData*) target;
+
+ tcmd->object = cmd->object;
+}
+
static int curveModifier_isDisabled(ModifierData *md)
{
CurveModifierData *cmd = (CurveModifierData*) md;
@@ -73,6 +81,14 @@ static void curveModifier_deformVertsEM(ModifierData *md, Object *ob, void *edit
/* Lattice */
+static void latticeModifier_copyData(ModifierData *md, ModifierData *target)
+{
+ LatticeModifierData *lmd = (LatticeModifierData*) md;
+ LatticeModifierData *tlmd = (LatticeModifierData*) target;
+
+ tlmd->object = lmd->object;
+}
+
static int latticeModifier_isDisabled(ModifierData *md)
{
LatticeModifierData *lmd = (LatticeModifierData*) md;
@@ -115,6 +131,17 @@ static void subsurfModifier_initData(ModifierData *md)
smd->renderLevels = 2;
}
+static void subsurfModifier_copyData(ModifierData *md, ModifierData *target)
+{
+ SubsurfModifierData *smd = (SubsurfModifierData*) md;
+ SubsurfModifierData *tsmd = (SubsurfModifierData*) target;
+
+ tsmd->flags = smd->flags;
+ tsmd->levels = smd->levels;
+ tsmd->renderLevels = smd->renderLevels;
+ tsmd->subdivType = smd->subdivType;
+}
+
static void subsurfModifier_freeData(ModifierData *md)
{
SubsurfModifierData *smd = (SubsurfModifierData*) md;
@@ -192,6 +219,17 @@ static void buildModifier_initData(ModifierData *md)
bmd->length = 100.0;
}
+static void buildModifier_copyData(ModifierData *md, ModifierData *target)
+{
+ BuildModifierData *bmd = (BuildModifierData*) md;
+ BuildModifierData *tbmd = (BuildModifierData*) target;
+
+ tbmd->start = bmd->start;
+ tbmd->length = bmd->length;
+ tbmd->randomize = bmd->randomize;
+ tbmd->seed = bmd->seed;
+}
+
static int buildModifier_dependsOnTime(ModifierData *md)
{
return 1;
@@ -421,6 +459,15 @@ static void mirrorModifier_initData(ModifierData *md)
mmd->tolerance = 0.001;
}
+static void mirrorModifier_copyData(ModifierData *md, ModifierData *target)
+{
+ MirrorModifierData *mmd = (MirrorModifierData*) md;
+ MirrorModifierData *tmmd = (MirrorModifierData*) target;
+
+ tmmd->axis = mmd->axis;
+ tmmd->tolerance = mmd->tolerance;
+}
+
static void mirrorModifier__doMirror(MirrorModifierData *mmd, DispListMesh *ndlm, float (*vertexCos)[3])
{
int totvert=ndlm->totvert, totedge=ndlm->totedge, totface=ndlm->totface;
@@ -874,6 +921,23 @@ static void waveModifier_initData(ModifierData *md)
wmd->damp= 10.0f;
}
+static void waveModifier_copyData(ModifierData *md, ModifierData *target)
+{
+ WaveModifierData *wmd = (WaveModifierData*) md;
+ WaveModifierData *twmd = (WaveModifierData*) target;
+
+ twmd->damp = wmd->damp;
+ twmd->flag = wmd->flag;
+ twmd->height = wmd->height;
+ twmd->lifetime = wmd->lifetime;
+ twmd->narrow = wmd->narrow;
+ twmd->speed = wmd->speed;
+ twmd->startx = wmd->startx;
+ twmd->starty = wmd->starty;
+ twmd->timeoffs = wmd->timeoffs;
+ twmd->width = wmd->width;
+}
+
static int waveModifier_dependsOnTime(ModifierData *md)
{
return 1;
@@ -972,6 +1036,7 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
mti = INIT_TYPE(Curve);
mti->type = eModifierTypeType_OnlyDeform;
mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode;
+ mti->copyData = curveModifier_copyData;
mti->isDisabled = curveModifier_isDisabled;
mti->updateDepgraph = curveModifier_updateDepgraph;
mti->deformVerts = curveModifier_deformVerts;
@@ -980,6 +1045,7 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
mti = INIT_TYPE(Lattice);
mti->type = eModifierTypeType_OnlyDeform;
mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode;
+ mti->copyData = latticeModifier_copyData;
mti->isDisabled = latticeModifier_isDisabled;
mti->updateDepgraph = latticeModifier_updateDepgraph;
mti->deformVerts = latticeModifier_deformVerts;
@@ -989,6 +1055,7 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
mti->type = eModifierTypeType_Constructive;
mti->flags = eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsMapping | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode;
mti->initData = subsurfModifier_initData;
+ mti->copyData = subsurfModifier_copyData;
mti->freeData = subsurfModifier_freeData;
mti->applyModifier = subsurfModifier_applyModifier;
mti->applyModifierEM = subsurfModifier_applyModifierEM;
@@ -997,6 +1064,7 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
mti->type = eModifierTypeType_Nonconstructive;
mti->flags = eModifierTypeFlag_AcceptsMesh;
mti->initData = buildModifier_initData;
+ mti->copyData = buildModifier_copyData;
mti->dependsOnTime = buildModifier_dependsOnTime;
mti->applyModifier = buildModifier_applyModifier;
@@ -1004,6 +1072,7 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
mti->type = eModifierTypeType_Constructive;
mti->flags = eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode;
mti->initData = mirrorModifier_initData;
+ mti->copyData = mirrorModifier_copyData;
mti->applyModifier = mirrorModifier_applyModifier;
mti->applyModifierEM = mirrorModifier_applyModifierEM;
@@ -1017,6 +1086,7 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
mti->type = eModifierTypeType_OnlyDeform;
mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode;
mti->initData = waveModifier_initData;
+ mti->copyData = waveModifier_copyData;
mti->dependsOnTime = waveModifier_dependsOnTime;
mti->deformVerts = waveModifier_deformVerts;
mti->deformVertsEM = waveModifier_deformVertsEM;
@@ -1063,3 +1133,24 @@ int modifier_dependsOnTime(ModifierData *md)
return mti->dependsOnTime && mti->dependsOnTime(md);
}
+
+ModifierData *modifiers_findByType(struct ListBase *lb, ModifierType type)
+{
+ ModifierData *md = lb->first;
+
+ for (; md; md=md->next)
+ if (md->type==type)
+ break;
+
+ return md;
+}
+
+void modifier_copyData(ModifierData *md, ModifierData *target)
+{
+ ModifierTypeInfo *mti = modifierType_get_info(md->type);
+
+ target->mode = md->mode;
+
+ if (mti->copyData)
+ mti->copyData(md, target);
+}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 7b601bfbe43..2b8b14429ef 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -823,6 +823,7 @@ SoftBody *copy_softbody(SoftBody *sb)
Object *copy_object(Object *ob)
{
Object *obn;
+ ModifierData *md;
int a;
bConstraintChannel *actcon;
@@ -837,7 +838,13 @@ Object *copy_object(Object *ob)
obn->flag &= ~OB_FROMGROUP;
copy_effects(&obn->effect, &ob->effect);
- obn->modifiers.first = obn->modifiers.last= NULL; // XXX fixme
+ obn->modifiers.first = obn->modifiers.last= NULL;
+
+ for (md=ob->modifiers.first; md; md=md->next) {
+ ModifierData *nmd = modifier_new(md->type);
+ modifier_copyData(md, nmd);
+ BLI_addtail(&obn->modifiers, nmd);
+ }
obn->network.first= obn->network.last= 0;