- added modifier_dependsOnTime to check if modifier needs updating
authorDaniel Dunbar <daniel@zuster.org>
Wed, 20 Jul 2005 04:14:21 +0000 (04:14 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 20 Jul 2005 04:14:21 +0000 (04:14 +0000)
   based on time change. would be nice if dep graph could handle this.
 - made dep check if modifiers need update on time change
 - fix render crash (access null)
 - added new Build Effect modifier type. compared to old one works as
   a full member of modifier system, means can apply subsurf, etc on
   it, reorder, what have you. and it is all nice and self contained.
 - removed old Build effect, old files convert to new style on load
 - couldn't help myself, added a randomize feature to build effect
 - removed Python BuildEffect support

17 files changed:
source/blender/blenkernel/BKE_effect.h
source/blender/blenkernel/BKE_modifier.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/include/particle_effect.h
source/blender/makesdna/DNA_modifier_types.h
source/blender/python/SConscript
source/blender/python/api2_2x/Effect.c
source/blender/python/api2_2x/Types.c
source/blender/python/api2_2x/Types.h
source/blender/renderconverter/intern/convertBlenderScene.c
source/blender/src/buttons_object.c
source/blender/src/drawmesh.c

index 4ed2febc0d7a1fb4009a1874f20e95b4ee069bb9..df413fe5c9dccb9945c22b99da2621fccebc599e 100644 (file)
@@ -50,7 +50,6 @@ struct Effect *copy_effect(struct Effect *eff);
 void copy_act_effect(struct Object *ob);
 void copy_effects(struct ListBase *lbn, struct ListBase *lb);
 void deselectall_eff(struct Object *ob);
-void set_buildvars(struct Object *ob, int *start, int *end);
 struct Particle *new_particle(struct PartEff *paf);
 struct PartEff *give_parteff(struct Object *ob);
 void where_is_particle(struct PartEff *paf, struct Particle *pa, float ctime, float *vec);
index fab705a3a8cc56fda059722fae46f820b7a64d2e..94c847d50d8857b161a69493b6839864e71834e5 100644 (file)
@@ -1,6 +1,6 @@
 /**
  *     
- * $$ 
+ * $Id
  *
  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
  *
@@ -88,6 +88,12 @@ typedef struct ModifierTypeInfo {
                 */
        void (*updateDepgraph)(struct ModifierData *md, struct DagForest *forest, struct Object *ob, struct DagNode *obNode);
 
+               /* Should return true if the modifier needs to be recalculated on time changes.
+                *
+                * This function is optional (assumes false if not present).
+                */
+       int (*dependsOnTime)(struct ModifierData *md);
+
                /* Only for deform types, should apply the deformation
                 * to the given vertex array. Object is guaranteed to be
                 * non-NULL.
@@ -121,5 +127,7 @@ typedef struct ModifierTypeInfo {
 
 ModifierTypeInfo *modifierType_get_info(ModifierType type);
 
+int modifier_dependsOnTime(struct ModifierData *md);
+
 #endif
 
index 4f89e8e5634f79d83b9e503aa67fac40716e93d3..8dfe4d0c2ef99b9be16fbeb70964491216899c78 100644 (file)
@@ -148,12 +148,10 @@ static void meshDM_drawVerts(DerivedMesh *dm)
 {
        MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
        Mesh *me = mdm->me;
-       int a, start=0, end=me->totvert;
-
-       if (mdm->ob) set_buildvars(mdm->ob, &start, &end);
+       int a;
 
        glBegin(GL_POINTS);
-       for(a= start; a<end; a++) {
+       for(a=0; a<me->totvert; a++) {
                glVertex3fv(mdm->verts[ a].co);
        }
        glEnd();
@@ -162,15 +160,10 @@ static void meshDM_drawEdges(DerivedMesh *dm)
 {
        MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
        Mesh *me= mdm->me;
-       int a, start= 0, end= me->totface;
+       int a;
        MFace *mface = me->mface;
 
-       if (mdm->ob) set_buildvars(mdm->ob, &start, &end);
-       mface+= start;
-       
-               // edges can't cope with buildvars, draw with
-               // faces if build is in use.
-       if(me->medge && start==0 && end==me->totface) {
+       if(me->medge) {
                MEdge *medge= me->medge;
                
                glBegin(GL_LINES);
@@ -184,7 +177,7 @@ static void meshDM_drawEdges(DerivedMesh *dm)
        }
        else {
                glBegin(GL_LINES);
-               for(a=start; a<end; a++, mface++) {
+               for(a=0; a<me->totface; a++, mface++) {
                        int test= mface->edcode;
                        
                        if(test) {
@@ -225,13 +218,10 @@ static void meshDM_drawLooseEdges(DerivedMesh *dm)
        MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
        Mesh *me = mdm->me;
        MFace *mface= me->mface;
-       int a, start=0, end=me->totface;
+       int a;
 
-       if (mdm->ob) set_buildvars(mdm->ob, &start, &end);
-       mface+= start;
-               
        glBegin(GL_LINES);
-       for(a=start; a<end; a++, mface++) {
+       for(a=0; a<me->totface; a++, mface++) {
                if(!mface->v3) {
                        glVertex3fv(mdm->verts[mface->v3].co);
                        glVertex3fv(mdm->verts[mface->v4].co);
@@ -246,12 +236,9 @@ static void meshDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
        MVert *mvert= mdm->verts;
        MFace *mface= me->mface;
        float *nors = mdm->nors;
-       int a, start=0, end=me->totface;
+       int a;
        int glmode=-1, shademodel=-1, matnr=-1, drawCurrentMat=1;
 
-       if (mdm->ob) set_buildvars(mdm->ob, &start, &end);
-       mface+= start;
-       
 #define PASSVERT(index, punoBit) {                             \
        if (shademodel==GL_SMOOTH) {                            \
                short *no = mvert[index].no;                    \
@@ -265,7 +252,7 @@ static void meshDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
 }
 
        glBegin(glmode=GL_QUADS);
-       for(a=start; a<end; a++, mface++, nors+=3) {
+       for(a=0; a<me->totface; a++, mface++, nors+=3) {
                if(mface->v3) {
                        int new_glmode, new_matnr, new_shademodel;
                                
@@ -306,14 +293,9 @@ static void meshDM_drawFacesColored(DerivedMesh *dm, int useTwoSide, unsigned ch
        MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
        Mesh *me= mdm->me;
        MFace *mface= me->mface;
-       int a, glmode, start=0, end=me->totface;
+       int a, glmode;
        unsigned char *cp1, *cp2;
 
-       if (mdm->ob) set_buildvars(mdm->ob, &start, &end);
-       mface+= start;
-       col1+= 4*start;
-       if(col2) col2+= 4*start;
-       
        cp1= col1;
        if(col2) {
                cp2= col2;
@@ -330,7 +312,7 @@ static void meshDM_drawFacesColored(DerivedMesh *dm, int useTwoSide, unsigned ch
        
        glShadeModel(GL_SMOOTH);
        glBegin(glmode=GL_QUADS);
-       for(a=start; a<end; a++, mface++, cp1+= 16) {
+       for(a=0; a<me->totface; a++, mface++, cp1+= 16) {
                if(mface->v3) {
                        int new_glmode= mface->v4?GL_QUADS:GL_TRIANGLES;
 
@@ -379,11 +361,9 @@ static void meshDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf,
        MFace *mface= me->mface;
        TFace *tface = me->tface;
        float *nors = mdm->nors;
-       int a, start=0, end=me->totface;
+       int a;
 
-       if (mdm->ob) set_buildvars(mdm->ob, &start, &end);
-       
-       for (a=start; a<end; a++) {
+       for (a=0; a<me->totface; a++) {
                MFace *mf= &mface[a];
                TFace *tf = tface?&tface[a]:NULL;
                unsigned char *cp= NULL;
@@ -1016,7 +996,7 @@ DerivedMesh *derivedmesh_from_displistmesh(DispListMesh *dlm)
 
 static void mesh_calc_modifiers(Mesh *me, Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform)
 {
-       ModifierData *md=ob->modifiers.first;
+       ModifierData *md= ob?ob->modifiers.first:NULL;
        float (*deformedVerts)[3];
        DerivedMesh *dm;
        int a, numVerts = me->totvert;
index 018ceac2bc4f649b551324e9dd39e23a76e1bf7a..a50eb21ecb70f031567b10a7217eb8219e944e3d 100644 (file)
@@ -1403,6 +1403,17 @@ void DAG_scene_flush_update(Scene *sce)
        }
 }
 
+static int object_modifiers_use_time(Object *ob)
+{
+       ModifierData *md;
+
+       for (md=ob->modifiers.first; md; md=md->next)
+               if (modifier_dependsOnTime(md))
+                       return 1;
+
+       return 0;
+}
+
 /* flag all objects that need recalc, for changes in time for example */
 void DAG_scene_update_flags(Scene *sce, unsigned int lay)
 {
@@ -1426,6 +1437,7 @@ void DAG_scene_update_flags(Scene *sce, unsigned int lay)
                if(ob->action) ob->recalc |= OB_RECALC_DATA;
                else if(ob->nlastrips.first) ob->recalc |= OB_RECALC_DATA;
                else if(ob->softflag & OB_SB_ENABLE) ob->recalc |= OB_RECALC_DATA;
+               else if(object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA;
                else {
                        Mesh *me;
                        Curve *cu;
index 98810ede1ce78d0b153ccfb4e12b740f09de83bd..5dd63fddd442bac0ab02b98730ad64f91e2bc161 100644 (file)
 Effect *add_effect(int type)
 {
        Effect *eff=0;
-       BuildEff *bld;
        PartEff *paf;
        WaveEff *wav;
        int a;
        
        switch(type) {
-       case EFF_BUILD:
-               bld= MEM_callocN(sizeof(BuildEff), "neweff");
-               eff= (Effect *)bld;
-               
-               bld->sfra= 1.0;
-               bld->len= 100.0;
-               break;
-               
        case EFF_PARTICLE:
                paf= MEM_callocN(sizeof(PartEff), "neweff");
                eff= (Effect *)paf;
@@ -194,7 +185,7 @@ void copy_act_effect(Object *ob)
        }
        
        /* when it comes here: add new effect */
-       eff= add_effect(EFF_BUILD);
+       eff= add_effect(EFF_PARTICLE);
        BLI_addtail(&ob->effect, eff);
                        
 }
@@ -225,28 +216,6 @@ void deselectall_eff(Object *ob)
        }
 }
 
-void set_buildvars(Object *ob, int *start, int *end)
-{
-       BuildEff *bld;
-       float ctime;
-       
-       bld= ob->effect.first;
-       while(bld) {
-               if(bld->type==EFF_BUILD) {
-                       ctime= bsystem_time(ob, 0, (float)G.scene->r.cfra, bld->sfra-1.0f);
-                       if(ctime < 0.0) {
-                               *end= *start;
-                       }
-                       else if(ctime < bld->len) {
-                               *end= *start+ (int)((*end - *start)*ctime/bld->len);
-                       }
-                       
-                       return;
-               }
-               bld= bld->next;
-       }
-}
-
 /* ***************** PARTICLES ***************** */
 
 Particle *new_particle(PartEff *paf)
index 9bba515fbbf98482229cab57218911c5f027bc1f..d3d48a6f5f38ceda33ba01f5350778fd34cff912 100644 (file)
@@ -1,18 +1,24 @@
 #include "string.h"
 
+#include "BLI_rand.h"
+
 #include "MEM_guardedalloc.h"
 
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
+#include "DNA_scene_types.h"
 
+#include "BKE_global.h"
 #include "BKE_utildefines.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_displist.h"
 #include "BKE_modifier.h"
 #include "BKE_lattice.h"
 #include "BKE_subsurf.h"
+#include "BKE_object.h"
+#include "BKE_mesh.h"
 #include "depsgraph_private.h"
 
 /***/
@@ -145,6 +151,227 @@ static void *subsurfModifier_applyModifier(ModifierData *md, void *data, Object
        }
 }
 
+/* Build */
+
+static ModifierData *buildModifier_allocData(void)
+{
+       BuildModifierData *bmd = allocModifierData(eModifierType_Build, sizeof(BuildModifierData));
+
+       bmd->start = 1.0;
+       bmd->length = 100.0;
+
+       return (ModifierData*) bmd;
+}
+
+static int buildModifier_isDisabled(ModifierData *md)
+{
+       return 0;
+}
+
+static int buildModifier_dependsOnTime(ModifierData *md)
+{
+       return 1;
+}
+
+static void *buildModifier_applyModifier(ModifierData *md, void *data, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int useRenderParams)
+{
+       BuildModifierData *bmd = (BuildModifierData*) md;
+       DispListMesh *dlm=NULL, *ndlm = MEM_callocN(sizeof(*ndlm), "build_dlm");
+       MVert *mvert;
+       MEdge *medge;
+       MFace *mface;
+       MCol *mcol;
+       TFace *tface;
+       int totvert, totedge, totface;
+       int i,j;
+       float frac;
+
+       if (dm) {
+               dlm = dm->convertToDispListMesh(dm);
+               mvert = dlm->mvert;
+               medge = dlm->medge;
+               mface = dlm->mface;
+               mcol = dlm->mcol;
+               tface = dlm->tface;
+               totvert = dlm->totvert;
+               totedge = dlm->totedge;
+               totface = dlm->totface;
+       } else {
+               Mesh *me = data;
+               mvert = me->mvert;
+               medge = me->medge;
+               mface = me->mface;
+               mcol = me->mcol;
+               tface = me->tface;
+               totvert = me->totvert;
+               totedge = me->totedge;
+               totface = me->totface;
+       }
+
+       if (ob) {
+               frac = bsystem_time(ob, 0, (float)G.scene->r.cfra, bmd->start-1.0f)/bmd->length;
+       } else {
+               frac = G.scene->r.cfra - bmd->start/bmd->length;
+       }
+       CLAMP(frac, 0.0, 1.0);
+
+       ndlm->totface = totface*frac;
+       ndlm->totedge = totedge*frac;
+       if (ndlm->totface) {
+               ndlm->mvert = MEM_mallocN(sizeof(*ndlm->mvert)*totvert, "build_mvert");
+               memcpy(ndlm->mvert, mvert, sizeof(*mvert)*totvert);
+               for (i=0; i<totvert; i++) {
+                       ndlm->mvert[i].flag = 0;
+               }
+
+               if (bmd->randomize) {
+                       ndlm->mface = MEM_dupallocN(mface);
+                       BLI_array_randomize(ndlm->mface, sizeof(*mface), totface, bmd->seed);
+
+                       if (tface) {
+                               ndlm->tface = MEM_dupallocN(tface);
+                               BLI_array_randomize(ndlm->tface, sizeof(*tface), totface, bmd->seed);
+                       } else if (mcol) {
+                               ndlm->mcol = MEM_dupallocN(mcol);
+                               BLI_array_randomize(ndlm->mcol, sizeof(*mcol)*4, totface, bmd->seed);
+                       }
+               } else {
+                       ndlm->mface = MEM_mallocN(sizeof(*ndlm->mface)*ndlm->totface, "build_mf");
+                       memcpy(ndlm->mface, mface, sizeof(*mface)*ndlm->totface);
+
+                       if (tface) {
+                               ndlm->tface = MEM_mallocN(sizeof(*ndlm->tface)*ndlm->totface, "build_tf");
+                               memcpy(ndlm->tface, tface, sizeof(*tface)*ndlm->totface);
+                       } else if (mcol) {
+                               ndlm->mcol = MEM_mallocN(sizeof(*ndlm->mcol)*4*ndlm->totface, "build_mcol");
+                               memcpy(ndlm->mcol, mcol, sizeof(*mcol)*4*ndlm->totface);
+                       }
+               }
+
+               for (i=0; i<ndlm->totface; i++) {
+                       MFace *mf = &ndlm->mface[i];
+
+                       ndlm->mvert[mf->v1].flag = 1;
+                       ndlm->mvert[mf->v2].flag = 1;
+                       if (mf->v3) {
+                               ndlm->mvert[mf->v3].flag = 1;
+                               if (mf->v4) ndlm->mvert[mf->v4].flag = 1;
+                       }
+               }
+
+                       /* Store remapped indices in *((int*) mv->no) */
+               ndlm->totvert = 0;
+               for (i=0; i<totvert; i++) {
+                       MVert *mv = &ndlm->mvert[i];
+
+                       if (mv->flag) 
+                               *((int*) mv->no) = ndlm->totvert++;
+               }
+
+                       /* Remap face vertex indices */
+               for (i=0; i<ndlm->totface; i++) {
+                       MFace *mf = &ndlm->mface[i];
+
+                       mf->v1 = *((int*) ndlm->mvert[mf->v1].no);
+                       mf->v2 = *((int*) ndlm->mvert[mf->v2].no);
+                       if (mf->v3) {
+                               mf->v3 = *((int*) ndlm->mvert[mf->v3].no);
+                               if (mf->v4) mf->v4 = *((int*) ndlm->mvert[mf->v4].no);
+                       }
+               }
+                       /* Copy in all edges that have both vertices (remap in process) */
+               if (totedge) {
+                       ndlm->totedge = 0;
+                       ndlm->medge = MEM_mallocN(sizeof(*ndlm->medge)*totedge, "build_med");
+
+                       for (i=0; i<totedge; i++) {
+                               MEdge *med = &medge[i];
+
+                               if (ndlm->mvert[med->v1].flag && ndlm->mvert[med->v2].flag) {
+                                       MEdge *nmed = &ndlm->medge[ndlm->totedge++];
+
+                                       memcpy(nmed, med, sizeof(*med));
+
+                                       nmed->v1 = *((int*) ndlm->mvert[nmed->v1].no);
+                                       nmed->v2 = *((int*) ndlm->mvert[nmed->v2].no);
+                               }
+                       }
+               }
+
+                       /* Collapse vertex array to remove unused verts */
+               for(i=j=0; i<totvert; i++) {
+                       MVert *mv = &ndlm->mvert[i];
+
+                       if (mv->flag) {
+                               if (j!=i) 
+                                       memcpy(&ndlm->mvert[j], mv, sizeof(*mv));
+                               j++;
+                       }
+               }
+       } else if (ndlm->totedge) {
+               ndlm->mvert = MEM_mallocN(sizeof(*ndlm->mvert)*totvert, "build_mvert");
+               memcpy(ndlm->mvert, mvert, sizeof(*mvert)*totvert);
+               for (i=0; i<totvert; i++) {
+                       ndlm->mvert[i].flag = 0;
+               }
+
+               if (bmd->randomize) {
+                       ndlm->medge = MEM_dupallocN(medge);
+                       BLI_array_randomize(ndlm->medge, sizeof(*medge), totedge, bmd->seed);
+               } else {
+                       ndlm->medge = MEM_mallocN(sizeof(*ndlm->medge)*ndlm->totedge, "build_mf");
+                       memcpy(ndlm->medge, medge, sizeof(*medge)*ndlm->totedge);
+               }
+
+               for (i=0; i<ndlm->totedge; i++) {
+                       MEdge *med = &ndlm->medge[i];
+
+                       ndlm->mvert[med->v1].flag = 1;
+                       ndlm->mvert[med->v2].flag = 1;
+               }
+
+                       /* Store remapped indices in *((int*) mv->no) */
+               ndlm->totvert = 0;
+               for (i=0; i<totvert; i++) {
+                       MVert *mv = &ndlm->mvert[i];
+
+                       if (mv->flag) 
+                               *((int*) mv->no) = ndlm->totvert++;
+               }
+
+                       /* Remap edge vertex indices */
+               for (i=0; i<ndlm->totedge; i++) {
+                       MEdge *med = &ndlm->medge[i];
+
+                       med->v1 = *((int*) ndlm->mvert[med->v1].no);
+                       med->v2 = *((int*) ndlm->mvert[med->v2].no);
+               }
+
+                       /* Collapse vertex array to remove unused verts */
+               for(i=j=0; i<totvert; i++) {
+                       MVert *mv = &ndlm->mvert[i];
+
+                       if (mv->flag) {
+                               if (j!=i) 
+                                       memcpy(&ndlm->mvert[j], mv, sizeof(*mv));
+                               j++;
+                       }
+               }
+       } else {
+               ndlm->totvert = totvert*frac;
+
+               ndlm->mvert = MEM_mallocN(sizeof(*ndlm->mvert)*ndlm->totvert, "build_mvert");
+               memcpy(ndlm->mvert, mvert, sizeof(*mvert)*ndlm->totvert);
+       }
+
+       if (dm) dm->release(dm);
+       if (dlm) displistmesh_free(dlm);
+
+       mesh_calc_normals(ndlm->mvert, ndlm->totvert, ndlm->mface, ndlm->totface, &ndlm->nors);
+       
+       return derivedmesh_from_displistmesh(ndlm);
+}
+
 /***/
 
 static ModifierTypeInfo typeArr[NUM_MODIFIER_TYPES];
@@ -194,6 +421,16 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
                mti->isDisabled = subsurfModifier_isDisabled;
                mti->applyModifier = subsurfModifier_applyModifier;
 
+               mti = &typeArr[eModifierType_Build];
+               strcpy(mti->name, "Build");
+               strcpy(mti->structName, "BuildModifierData");
+               mti->type = eModifierTypeType_Nonconstructive;
+               mti->flags = eModifierTypeFlag_AcceptsMesh;
+               mti->allocData = buildModifier_allocData;
+               mti->isDisabled = buildModifier_isDisabled;
+               mti->dependsOnTime = buildModifier_dependsOnTime;
+               mti->applyModifier = buildModifier_applyModifier;
+
                typeArrInit = 0;
        }
 
@@ -204,3 +441,9 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
        }
 }
 
+int modifier_dependsOnTime(ModifierData *md) 
+{
+       ModifierTypeInfo *mti = modifierType_get_info(md->type);
+
+       return mti->dependsOnTime && mti->dependsOnTime(md);
+}
index 436537ca39f50d71f2456ceb224741c8822e8521..7972dd9204658898aac3710ecf2297148236e60e 100644 (file)
 #include "BKE_library.h" // for wich_libbase
 #include "BKE_main.h" // for Main
 #include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_modifier.h"
 #include "BKE_object.h"
 #include "BKE_sca.h" // for init_actuator
 #include "BKE_scene.h"
@@ -2322,6 +2323,25 @@ static void direct_link_object(FileData *fd, Object *ob)
                }
                if(paf->type==EFF_WAVE) {
 
+               }
+               if(paf->type==EFF_BUILD) {
+                       BuildEff *baf = (BuildEff*) paf;
+                       PartEff *next = paf->next;
+                       ModifierTypeInfo *mti = modifierType_get_info(eModifierType_Build);
+                       BuildModifierData *bmd = (BuildModifierData*) mti->allocData();
+
+                       bmd->start = baf->sfra;
+                       bmd->length = baf->len;
+                       bmd->randomize = 0;
+                       bmd->seed = 1;
+
+                       BLI_addtail(&ob->modifiers, bmd);
+
+                       BLI_remlink(&ob->effect, paf);
+                       MEM_freeN(paf);
+
+                       paf = next;
+                       continue;
                }
                paf= paf->next;
        }
index 3ee4e1be1827b88ef61f9afc6ff5d72384ed966d..3b14f11a8cd5ca0da659508c221a90a5fe2f2513 100644 (file)
@@ -403,9 +403,6 @@ static void write_effects(WriteData *wd, ListBase *lb)
        while(eff) {
 
                switch(eff->type) {
-               case EFF_BUILD:
-                       writestruct(wd, DATA, "BuildEff", 1, eff);
-                       break;
                case EFF_PARTICLE:
                        writestruct(wd, DATA, "PartEff", 1, eff);
                        break;
index 86a0417b807f80dd1f074f3366df9eabcbefe956..883331ac7402e6689a6b066c9fd96ce716f1c386 100644 (file)
@@ -42,8 +42,6 @@ extern void free_effect(Effect *eff);
 extern void free_effects(ListBase *lb);
 extern void copy_effects(ListBase *lbn, ListBase *lb);
 extern void build_particle_system(Object *ob);
-/* used externally */
-void set_buildvars(Object *ob, int *start, int *end);
 
 #endif
 
index 486fc68785cb9198bb11a175e3bded15d9dda54f..baa2a77bf10a826ceef42f9644bc8f929ae2ee52 100644 (file)
@@ -10,6 +10,7 @@ typedef enum ModifierType {
        eModifierType_Subsurf,
        eModifierType_Lattice,
        eModifierType_Curve,
+       eModifierType_Build,
 
        NUM_MODIFIER_TYPES
 } ModifierType;
@@ -49,4 +50,11 @@ typedef struct CurveModifierData {
        struct Object *object;
 } CurveModifierData;
 
+typedef struct BuildModifierData {
+       ModifierData modifier;
+
+       float start, length;
+       int randomize, seed;
+} BuildModifierData;
+
 #endif
index d9989ec46c2c71493005ff2d93fdd804f733dd5a..81388df01edc26d7af10fa49746ee261e9533d18 100644 (file)
@@ -12,7 +12,6 @@ source_files = ['BPY_interface.c',
                 'api2_2x/BGL.c',
                 'api2_2x/Blender.c',
                 'api2_2x/Bone.c',
-                'api2_2x/Build.c',
                 'api2_2x/Camera.c',
                 'api2_2x/CurNurb.c',
                 'api2_2x/Curve.c',
index ee81281ec39f2e200de2ca615fbdaa7258363522..c49dd53257c0468278237670f54228f2bfa834a4 100644 (file)
@@ -34,7 +34,6 @@
 #include "DNA_object_types.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
-#include "Build.h"
 #include "Particle.h"
 #include "Wave.h"
 #include "gen_utils.h"
@@ -104,8 +103,6 @@ PyObject *M_Effect_New( PyObject * self, PyObject * args )
                                                "expected type argument(wave,build or particle)" ) );
        if( !strcmp( btype, "wave" ) )
                type = EFF_WAVE;
-       if( !strcmp( btype, "build" ) )
-               type = EFF_BUILD;
        if( !strcmp( btype, "particle" ) )
                type = EFF_PARTICLE;
        if( type == -1 )
@@ -235,7 +232,6 @@ PyObject *M_Effect_Get( PyObject * self, PyObject * args )
 /*****************************************************************************/
 
 
-PyObject *Build_Init( void );
 PyObject *Wave_Init( void );
 PyObject *Particle_Init( void );
 
@@ -248,7 +244,6 @@ PyObject *Effect_Init( void )
        submodule = Py_InitModule3( "Blender.Effect", M_Effect_methods, 0 );
        dict = PyModule_GetDict( submodule );
        PyDict_SetItemString( dict, "Wave", Wave_Init(  ) );
-       PyDict_SetItemString( dict, "Build", Build_Init(  ) );
        PyDict_SetItemString( dict, "Particle", Particle_Init(  ) );
        return ( submodule );
 }
@@ -324,8 +319,6 @@ void EffectDeAlloc( BPy_Effect * self )
 PyObject *EffectGetAttr( BPy_Effect * self, char *name )
 {
        switch ( self->effect->type ) {
-       case EFF_BUILD:
-               return BuildGetAttr( ( BPy_Build * ) self, name );
        case EFF_WAVE:
                return WaveGetAttr( ( BPy_Wave * ) self, name );
        case EFF_PARTICLE:
@@ -345,8 +338,6 @@ PyObject *EffectGetAttr( BPy_Effect * self, char *name )
 int EffectSetAttr( BPy_Effect * self, char *name, PyObject * value )
 {
        switch ( self->effect->type ) {
-       case EFF_BUILD:
-               return BuildSetAttr( ( BPy_Build * ) self, name, value );
        case EFF_WAVE:
                return WaveSetAttr( ( BPy_Wave * ) self, name, value );
        case EFF_PARTICLE:
@@ -363,7 +354,6 @@ int EffectSetAttr( BPy_Effect * self, char *name, PyObject * value )
 /*
 int EffectPrint(BPy_Effect *self, FILE *fp, int flags) 
 { 
-if (self->effect->type == EFF_BUILD)puts("Effect Build");
 if (self->effect->type == EFF_PARTICLE)puts("Effect Particle");
 if (self->effect->type == EFF_WAVE)puts("Effect Wave");
  
@@ -379,8 +369,6 @@ if (self->effect->type == EFF_WAVE)puts("Effect Wave");
 PyObject *EffectRepr( BPy_Effect * self )
 {
        char *str = "";
-       if( self->effect->type == EFF_BUILD )
-               str = "Effect Build";
        if( self->effect->type == EFF_PARTICLE )
                str = "Effect Particle";
        if( self->effect->type == EFF_WAVE )
index 44414e604fb16b4d86919d14feffae30139d092a..9e4584a647ba89a2a7b454e4ec51b192945e2eea 100644 (file)
@@ -51,7 +51,6 @@ void types_InitAll( void )
        Armature_Type.ob_type = &PyType_Type;
        BezTriple_Type.ob_type = &PyType_Type;
        Bone_Type.ob_type = &PyType_Type;
-       Build_Type.ob_type = &PyType_Type;
        Button_Type.ob_type = &PyType_Type;
        Camera_Type.ob_type = &PyType_Type;
        CurNurb_Type.ob_type = &PyType_Type;
index f29ba04a976fdee09eba091b05cba98a26ac2e1c..a687a109dd2cf1fe13b05a70def1c810d83f5ca5 100644 (file)
@@ -36,7 +36,7 @@
 #include <Python.h>
 
 extern PyTypeObject Action_Type, Armature_Type;
-extern PyTypeObject BezTriple_Type, Bone_Type, Build_Type, Button_Type;
+extern PyTypeObject BezTriple_Type, Bone_Type, Button_Type;
 extern PyTypeObject Camera_Type;
 extern PyTypeObject CurNurb_Type;
 extern PyTypeObject Curve_Type;
index 8b09d8a4742b75476ffa27ea85b07531b4c8683c..fe20a8725185411464aa97d473313d60732e7b6a 100644 (file)
@@ -795,19 +795,14 @@ static void make_render_halos(Object *ob, Mesh *me, int totvert, MVert *mvert, M
        HaloRen *har;
        float xn, yn, zn, nor[3], view[3];
        float vec[3], hasize, mat[4][4], imat[3][3];
-       int start, end, a, ok, seed= ma->seed1;
+       int a, ok, seed= ma->seed1;
 
        MTC_Mat4MulMat4(mat, ob->obmat, R.viewmat);
        MTC_Mat3CpyMat4(imat, ob->imat);
 
        R.flag |= R_HALO;
 
-       start= 0;
-       end= totvert;
-       set_buildvars(ob, &start, &end);
-       mvert+= start;
-
-       for(a=start; a<end; a++, mvert++) {
+       for(a=0; a<totvert; a++, mvert++) {
                ok= 1;
 
                if(ok) {
@@ -1318,7 +1313,7 @@ static void init_render_mesh(Object *ob)
        float xn, yn, zn,  imat[3][3], mat[4][4];  //nor[3],
        float *orco=0;
        int a, a1, ok, do_puno=0, need_orco=0, totvlako, totverto, vertofs;
-       int start, end, do_autosmooth=0, totvert = 0;
+       int end, do_autosmooth=0, totvert = 0;
        DispListMesh *dlm = NULL;
        DerivedMesh *dm;
        
@@ -1435,13 +1430,11 @@ static void init_render_mesh(Object *ob)
                                        if(ma->mode & MA_RADIO) 
                                                do_autosmooth= 1;
                                
-                               start= 0;
                                end= dlm?dlm->totface:me->totface;
-                               set_buildvars(ob, &start, &end);
                                if (dlm) {
-                                       mface= dlm->mface + start;
+                                       mface= dlm->mface;
                                        if (dlm->tface) {
-                                               tface= dlm->tface + start;
+                                               tface= dlm->tface;
                                                vertcol= NULL;
                                        } else if (dlm->mcol) {
                                                vertcol= (unsigned int *)dlm->mcol;
@@ -1449,9 +1442,9 @@ static void init_render_mesh(Object *ob)
                                                vertcol= NULL;
                                        }
                                } else {
-                                       mface= ((MFace*) me->mface) + start;
+                                       mface= me->mface;
                                        if (me->tface) {
-                                               tface= ((TFace*) me->tface) + start;
+                                               tface= me->tface;
                                                vertcol= NULL;
                                        } else if (me->mcol) {
                                                vertcol= (unsigned int *)me->mcol;
@@ -1460,7 +1453,7 @@ static void init_render_mesh(Object *ob)
                                        }
                                }
 
-                               for(a=start; a<end; a++) {
+                               for(a=0; a<end; a++) {
                                        int v1, v2, v3, v4, edcode, flag;
                                        
                                        if( mface->mat_nr==a1 ) {
index 89e2d6fa9253f6ec1466627b1c17148d8e131fc2..4f3e6ec9fcb1b89d1e7f9b3d0885b65eac613c4b 100644 (file)
@@ -1665,7 +1665,6 @@ static void modifiers_add(void *ob_v, int type)
        
                BLI_addtail(&ob->modifiers, md);
 
-               md->type = type;
                actModifier = BLI_countlist(&ob->modifiers);
 
                allqueue(REDRAWBUTSOBJECT, 0);
@@ -1826,8 +1825,15 @@ static void object_panel_modifiers(Object *ob)
                                uiDefIDPoinBut(block, modifier_testLatticeObj, B_CHANGEDEP, "Ob:",              550, 320, 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:",                550, 320, 120,19, &cmd->object, "Lattice object to deform with");
+                               uiDefIDPoinBut(block, modifier_testCurveObj, B_CHANGEDEP, "Ob:",                550, 320, 120,19, &cmd->object, "Curve object to deform with");
+                       } else if (md->type==eModifierType_Build) {
+                               BuildModifierData *bmd = (BuildModifierData*) md;
+                               uiDefButF(block, NUM, B_MAKEDISP, "Start:", 550, 320, 150,19, &bmd->start, 1.0, 9000.0, 100, 0, "Specify the start frame of the effect");
+                               uiDefButF(block, NUM, B_MAKEDISP, "Length:", 550, 300, 150,19, &bmd->length, 1.0, 9000.0, 100, 0, "Specify the total time the build effect requires");
+                               uiDefButI(block, TOG, B_MAKEDISP, "Randomize", 550, 280, 150,19, &bmd->randomize, 0, 0, 1, 0, "Randomize the faces or edges during build.");
+                               uiDefButI(block, NUM, B_MAKEDISP, "Seed:", 700, 280, 150,19, &bmd->seed, 1.0, 9000.0, 100, 0, "Specify the seed for random if used.");
                        }
+
                        uiBlockEndAlign(block);
                }
        }
@@ -1876,17 +1882,9 @@ static void object_panel_effects(Object *ob)
        }
        
        if(eff) {
-               uiDefButS(block, MENU, B_CHANGEEFFECT, "Build %x0|Particles %x1|Wave %x2", 895,187,107,27, &eff->buttype, 0, 0, 0, 0, "Set effect type");
+               uiDefButS(block, MENU, B_CHANGEEFFECT, "Particles %x1|Wave %x2", 895,187,107,27, &eff->buttype, 0, 0, 0, 0, "Set effect type");
                
-               if(eff->type==EFF_BUILD) {
-                       BuildEff *bld;
-                       
-                       bld= (BuildEff *)eff;
-                       
-                       uiDefButF(block, NUM, 0, "Len:",                        649,138,95,21, &bld->len, 1.0, 9000.0, 100, 0, "Specify the total time the build effect requires");
-                       uiDefButF(block, NUM, 0, "Sfra:",                       746,138,94,22, &bld->sfra, 1.0, 9000.0, 100, 0, "Specify the startframe of the effect");
-               }
-               else if(eff->type==EFF_WAVE) {
+               if(eff->type==EFF_WAVE) {
                        WaveEff *wav;
                        
                        wav= (WaveEff *)eff;
index 6681e30111b0d8035c67260096acb976b1f7534e..b66c7b1a5f64cf5a77e0d4ead61ef5312575b2ee 100644 (file)
@@ -893,7 +893,6 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt)
 
                start = 0;
                totface = me->totface;
-               set_buildvars(ob, &start, &totface);
 
                if (!editing && prop && tface) {
                        dm = mesh_get_derived_deform(ob, &dmNeedsFree);