Duplicator bugfix: particle duplicators were not restoring the matrix for
[blender-staging.git] / source / blender / blenkernel / intern / anim.c
1 /** anim.c
2  *
3  *
4  * $Id$
5  *
6  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version. The Blender
12  * Foundation also sells licenses for use in proprietary software under
13  * the Blender License.  See http://www.blender.org/BL/ for information
14  * about this.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  *
25  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
26  * All rights reserved.
27  *
28  * The Original Code is: all of this file.
29  *
30  * Contributor(s): none yet.
31  *
32  * ***** END GPL/BL DUAL LICENSE BLOCK *****
33  */
34
35 #include <math.h>
36 #include <string.h>
37
38 #include "MEM_guardedalloc.h"
39 #include "BLI_blenlib.h"
40 #include "BLI_arithb.h"
41 #include "DNA_listBase.h"
42
43 #include "DNA_curve_types.h"
44 #include "DNA_effect_types.h"
45 #include "DNA_group_types.h"
46 #include "DNA_key_types.h"
47 #include "DNA_mesh_types.h"
48 #include "DNA_meshdata_types.h"
49 #include "DNA_object_types.h"
50 #include "DNA_scene_types.h"
51 #include "DNA_view3d_types.h"
52 #include "DNA_vfont_types.h"
53
54 #include "BKE_anim.h"
55 #include "BKE_DerivedMesh.h"
56 #include "BKE_displist.h"
57 #include "BKE_effect.h"
58 #include "BKE_font.h"
59 #include "BKE_group.h"
60 #include "BKE_global.h"
61 #include "BKE_ipo.h"
62 #include "BKE_key.h"
63 #include "BKE_main.h"
64 #include "BKE_object.h"
65 #include "BKE_utildefines.h"
66
67 #include "BKE_bad_level_calls.h"
68
69 #ifdef HAVE_CONFIG_H
70 #include <config.h>
71 #endif
72
73 ListBase duplilist= {0, 0}; 
74
75 void free_path(Path *path)
76 {
77         if(path->data) MEM_freeN(path->data);
78         MEM_freeN(path);
79 }
80
81
82 void calc_curvepath(Object *ob)
83 {
84         BevList *bl;
85         BevPoint *bevp, *bevpn, *bevpfirst, *bevplast, *tempbevp;
86         Curve *cu;
87         Nurb *nu;
88         Path *path;
89         float *fp, *dist, *maxdist, x, y, z;
90         float fac, d=0, fac1, fac2;
91         int a, tot, cycl=0;
92         float *ft;
93         
94         /* in a path vertices are with equal differences: path->len = number of verts */
95         /* NOW WITH BEVELCURVE!!! */
96         
97         if(ob==NULL || ob->type != OB_CURVE) return;
98         cu= ob->data;
99         if(ob==G.obedit) nu= editNurb.first;
100         else nu= cu->nurb.first;
101         
102         if(cu->path) free_path(cu->path);
103         cu->path= NULL;
104         
105         bl= cu->bev.first;
106         if(bl==NULL) return;
107
108         cu->path=path= MEM_callocN(sizeof(Path), "path");
109         
110         /* if POLY: last vertice != first vertice */
111         cycl= (bl->poly!= -1);
112         
113         if(cycl) tot= bl->nr;
114         else tot= bl->nr-1;
115         
116         path->len= tot+1;
117         /* exception: vector handle paths and polygon paths should be subdivided at least a factor 6 (or more?) */
118         if(path->len<6*nu->pntsu) path->len= 6*nu->pntsu;
119         
120         dist= (float *)MEM_mallocN((tot+1)*4, "calcpathdist");
121
122                 /* all lengths in *dist */
123         bevp= bevpfirst= (BevPoint *)(bl+1);
124         fp= dist;
125         *fp= 0;
126         for(a=0; a<tot; a++) {
127                 fp++;
128                 if(cycl && a==tot-1) {
129                         x= bevpfirst->x - bevp->x;
130                         y= bevpfirst->y - bevp->y;
131                         z= bevpfirst->z - bevp->z;
132                 }
133                 else {
134                         tempbevp = bevp+1;
135                         x= (tempbevp)->x - bevp->x;
136                         y= (tempbevp)->y - bevp->y;
137                         z= (tempbevp)->z - bevp->z;
138                 }
139                 *fp= *(fp-1)+ (float)sqrt(x*x+y*y+z*z);
140                 
141                 bevp++;
142         }
143         
144         path->totdist= *fp;
145
146                 /* the path verts  in path->data */
147                 /* now also with TILT value */
148         ft= path->data = (float *)MEM_callocN(16*path->len, "pathdata");
149         
150         bevp= bevpfirst;
151         bevpn= bevp+1;
152         bevplast= bevpfirst + (bl->nr-1);
153         fp= dist+1;
154         maxdist= dist+tot;
155         fac= 1.0f/((float)path->len-1.0f);
156         fac = fac * path->totdist;
157
158         for(a=0; a<path->len; a++) {
159                 
160                 d= ((float)a)*fac;
161                 
162                 /* we're looking for location (distance) 'd' in the array */
163                 while((d>= *fp) && fp<maxdist) {
164                         fp++;
165                         if(bevp<bevplast) bevp++;
166                         bevpn= bevp+1;
167                         if(bevpn>bevplast) {
168                                 if(cycl) bevpn= bevpfirst;
169                                 else bevpn= bevplast;
170                         }
171                 }
172                 
173                 fac1= *(fp)- *(fp-1);
174                 fac2= *(fp)-d;
175                 fac1= fac2/fac1;
176                 fac2= 1.0f-fac1;
177
178                 ft[0]= fac1*bevp->x+ fac2*(bevpn)->x;
179                 ft[1]= fac1*bevp->y+ fac2*(bevpn)->y;
180                 ft[2]= fac1*bevp->z+ fac2*(bevpn)->z;
181                 ft[3]= fac1*bevp->alfa+ fac2*(bevpn)->alfa;
182                 
183                 ft+= 4;
184
185         }
186         
187         MEM_freeN(dist);
188 }
189
190 int interval_test(int min, int max, int p1, int cycl)
191 {
192         
193         if(cycl) {
194                 if( p1 < min) 
195                         p1=  ((p1 -min) % (max-min+1)) + max+1;
196                 else if(p1 > max)
197                         p1=  ((p1 -min) % (max-min+1)) + min;
198         }
199         else {
200                 if(p1 < min) p1= min;
201                 else if(p1 > max) p1= max;
202         }
203         return p1;
204 }
205
206 /* warning, *vec needs FOUR items! */
207 /* ctime is normalized range <0-1> */
208 int where_on_path(Object *ob, float ctime, float *vec, float *dir)      /* returns OK */
209 {
210         Curve *cu;
211         Nurb *nu;
212         BevList *bl;
213         Path *path;
214         float *fp, *p0, *p1, *p2, *p3, fac;
215         float data[4];
216         int cycl=0, s0, s1, s2, s3;
217
218         if(ob==NULL || ob->type != OB_CURVE) return 0;
219         cu= ob->data;
220         if(cu->path==NULL || cu->path->data==NULL) {
221                 printf("no path!\n");
222         }
223         path= cu->path;
224         fp= path->data;
225         
226         /* test for cyclic */
227         bl= cu->bev.first;
228         if(bl && bl->poly> -1) cycl= 1;
229
230         ctime *= (path->len-1);
231         
232         s1= (int)floor(ctime);
233         fac= (float)(s1+1)-ctime;
234
235         /* path->len is corected for cyclic */
236         s0= interval_test(0, path->len-1-cycl, s1-1, cycl);
237         s1= interval_test(0, path->len-1-cycl, s1, cycl);
238         s2= interval_test(0, path->len-1-cycl, s1+1, cycl);
239         s3= interval_test(0, path->len-1-cycl, s1+2, cycl);
240
241         p0= fp + 4*s0;
242         p1= fp + 4*s1;
243         p2= fp + 4*s2;
244         p3= fp + 4*s3;
245
246         /* note, commented out for follow constraint */
247         //if(cu->flag & CU_FOLLOW) {
248                 
249                 set_afgeleide_four_ipo(1.0f-fac, data, KEY_BSPLINE);
250                 
251                 dir[0]= data[0]*p0[0] + data[1]*p1[0] + data[2]*p2[0] + data[3]*p3[0] ;
252                 dir[1]= data[0]*p0[1] + data[1]*p1[1] + data[2]*p2[1] + data[3]*p3[1] ;
253                 dir[2]= data[0]*p0[2] + data[1]*p1[2] + data[2]*p2[2] + data[3]*p3[2] ;
254                 
255                 /* make compatible with vectoquat */
256                 dir[0]= -dir[0];
257                 dir[1]= -dir[1];
258                 dir[2]= -dir[2];
259         //}
260         
261         nu= cu->nurb.first;
262
263         /* make sure that first and last frame are included in the vectors here  */
264         if((nu->type & 7)==CU_POLY) set_four_ipo(1.0f-fac, data, KEY_LINEAR);
265         else if((nu->type & 7)==CU_BEZIER) set_four_ipo(1.0f-fac, data, KEY_LINEAR);
266         else if(s0==s1 || p2==p3) set_four_ipo(1.0f-fac, data, KEY_CARDINAL);
267         else set_four_ipo(1.0f-fac, data, KEY_BSPLINE);
268
269         vec[0]= data[0]*p0[0] + data[1]*p1[0] + data[2]*p2[0] + data[3]*p3[0] ;
270         vec[1]= data[0]*p0[1] + data[1]*p1[1] + data[2]*p2[1] + data[3]*p3[1] ;
271         vec[2]= data[0]*p0[2] + data[1]*p1[2] + data[2]*p2[2] + data[3]*p3[2] ;
272
273         vec[3]= data[0]*p0[3] + data[1]*p1[3] + data[2]*p2[3] + data[3]*p3[3] ;
274
275         return 1;
276 }
277
278 /* ****************** DUPLICATOR ************** */
279
280 static void new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay)
281 {
282         DupliObject *dob= MEM_mallocN(sizeof(DupliObject), "dupliobject");
283         BLI_addtail(lb, dob);
284         dob->ob= ob;
285         Mat4CpyMat4(dob->mat, mat);
286         Mat4CpyMat4(dob->omat, ob->obmat);
287         dob->origlay= ob->lay;
288         ob->lay= lay;
289 }
290
291 static void group_duplilist(ListBase *lb, Object *ob)
292 {
293         GroupObject *go;
294         float mat[4][4];
295         
296         if(ob->dup_group==NULL) return;
297         
298         /* handles animated groups, and */
299         /* we need to check update for objects that are not in scene... */
300         group_handle_recalc_and_update(ob, ob->dup_group);
301         
302         for(go= ob->dup_group->gobject.first; go; go= go->next) {
303                 if(go->ob!=ob) {
304                         Mat4MulMat4(mat, go->ob->obmat, ob->obmat);
305                         new_dupli_object(lb, go->ob, mat, ob->lay);
306                 }
307         }
308 }
309
310 static void frames_duplilist(ListBase *lb, Object *ob)
311 {
312         extern int enable_cu_speed;     /* object.c */
313         Object copyob;
314         int cfrao, ok;
315         
316         cfrao= G.scene->r.cfra;
317         if(ob->parent==NULL && ob->track==NULL && ob->ipo==NULL && ob->constraints.first==NULL) return;
318
319         if(ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0;
320         copyob= *ob;    /* store transform info */
321
322         for(G.scene->r.cfra= ob->dupsta; G.scene->r.cfra<=ob->dupend; G.scene->r.cfra++) {
323
324                 ok= 1;
325                 if(ob->dupoff) {
326                         ok= G.scene->r.cfra - ob->dupsta;
327                         ok= ok % (ob->dupon+ob->dupoff);
328                         if(ok < ob->dupon) ok= 1;
329                         else ok= 0;
330                 }
331                 if(ok) {
332                         do_ob_ipo(ob);
333                         where_is_object_time(ob, (float)G.scene->r.cfra);
334                         new_dupli_object(lb, ob, ob->obmat, ob->lay);
335                 }
336         }
337
338         *ob= copyob;    /* restore transform info */
339         G.scene->r.cfra= cfrao;
340         enable_cu_speed= 1;
341 }
342
343 struct vertexDupliData {
344         ListBase *lb;
345         float pmat[4][4];
346         Object *ob, *par;
347 };
348
349 static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
350 {
351         struct vertexDupliData *vdd= userData;
352         float vec[3], *q2, mat[3][3], tmat[4][4], obmat[4][4];
353         
354         VECCOPY(vec, co);
355         Mat4MulVecfl(vdd->pmat, vec);
356         VecSubf(vec, vec, vdd->pmat[3]);
357         VecAddf(vec, vec, vdd->ob->obmat[3]);
358         
359         Mat4CpyMat4(obmat, vdd->ob->obmat);
360         VECCOPY(obmat[3], vec);
361         
362         if(vdd->par->transflag & OB_DUPLIROT) {
363                 
364                 vec[0]= -no_f[0]; vec[1]= -no_f[1]; vec[2]= -no_f[2];
365                 
366                 q2= vectoquat(vec, vdd->ob->trackflag, vdd->ob->upflag);
367                 
368                 QuatToMat3(q2, mat);
369                 Mat4CpyMat4(tmat, obmat);
370                 Mat4MulMat43(obmat, tmat, mat);
371         }
372         new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay);
373 }
374
375 static void vertex_duplilist(ListBase *lb, Scene *sce, Object *par)
376 {
377         Object *ob;
378         Base *base;
379         float vec[3], no[3], pmat[4][4];
380         int lay, totvert, a;
381         int dmNeedsFree;
382         DerivedMesh *dm;
383         
384         Mat4CpyMat4(pmat, par->obmat);
385         
386         lay= G.scene->lay;
387         
388         if(par==G.obedit)
389                 dm= editmesh_get_derived_cage(&dmNeedsFree);
390         else
391                 dm = mesh_get_derived_deform(par, &dmNeedsFree);
392         
393         totvert = dm->getNumVerts(dm);
394
395         base= sce->base.first;
396         while(base) {
397
398                 if(base->object->type>0 && (lay & base->lay) && G.obedit!=base->object) {
399                         ob= base->object->parent;
400                         while(ob) {
401                                 if(ob==par) {
402                                         struct vertexDupliData vdd;
403                                         
404                                         ob= base->object;
405                                         vdd.lb= lb;
406                                         vdd.ob= ob;
407                                         vdd.par= par;
408                                         Mat4CpyMat4(vdd.pmat, pmat);
409                                         
410                                         /* mballs have a different dupli handling */
411                                         if(ob->type!=OB_MBALL) ob->flag |= OB_DONE;     /* doesnt render */
412
413                                         if(par==G.obedit) {
414                                                 dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd);
415                                         }
416                                         else {
417                                                 for(a=0; a<totvert; a++) {
418                                                         dm->getVertCo(dm, a, vec);
419                                                         dm->getVertNo(dm, a, no);
420                                                         
421                                                         vertex_dupli__mapFunc(&vdd, a, vec, no, NULL);
422                                                 }
423                                         }
424                                         
425                                         break;
426                                 }
427                                 ob= ob->parent;
428                         }
429                 }
430                 base= base->next;
431         }
432
433         if (dmNeedsFree)
434                 dm->release(dm);
435 }
436
437 static void particle_duplilist(ListBase *lb, Scene *sce, Object *par, PartEff *paf)
438 {
439         Object *ob, copyob;
440         Base *base;
441         Particle *pa;
442         float ctime, vec1[3];
443         float vec[3], tmat[4][4], mat[3][3];
444         float *q2;
445         int lay, a;
446         
447         pa= paf->keys;
448         if(pa==0) {
449                 build_particle_system(par);
450                 pa= paf->keys;
451                 if(pa==0) return;
452         }
453         
454         ctime= bsystem_time(par, 0, (float)G.scene->r.cfra, 0.0);
455         
456         lay= G.scene->lay;
457
458         for(base= sce->base.first; base; base= base->next) {
459                 if(base->object->type>0 && (base->lay & lay) && G.obedit!=base->object) {
460                         ob= base->object->parent;
461                         while(ob) {
462                                 if(ob==par) {
463                                 
464                                         ob= base->object;
465                                         /* temp copy, to have ipos etc to work OK */
466                                         copyob= *ob;
467                                         
468                                         for(a=0, pa= paf->keys; a<paf->totpart; a++, pa+=paf->totkey) {
469                                                 
470                                                 if(paf->flag & PAF_STATIC) {
471                                                         float mtime;
472                                                         
473                                                         where_is_particle(paf, pa, pa->time, vec1);
474                                                         mtime= pa->time+pa->lifetime;
475                                                         
476                                                         for(ctime= pa->time; ctime<mtime; ctime+=paf->staticstep) {
477                                                                 
478                                                                 /* make sure hair grows until the end.. */ 
479                                                                 if(ctime>pa->time+pa->lifetime) ctime= pa->time+pa->lifetime;
480                                                                 
481                                                                 /* to give ipos in object correct offset */
482                                                                 where_is_object_time(ob, ctime-pa->time);
483
484                                                                 where_is_particle(paf, pa, ctime, vec); // makes sure there's always a vec
485                                                                 Mat4MulVecfl(par->obmat, vec);
486                                                                 
487                                                                 if(paf->stype==PAF_VECT) {
488                                                                         where_is_particle(paf, pa, ctime+1.0, vec1); // makes sure there's always a vec
489                                                                         Mat4MulVecfl(par->obmat, vec1);
490
491                                                                         VecSubf(vec1, vec1, vec);
492                                                                         q2= vectoquat(vec1, ob->trackflag, ob->upflag);
493                                                                         
494                                                                         QuatToMat3(q2, mat);
495                                                                         Mat4CpyMat4(tmat, ob->obmat);
496                                                                         Mat4MulMat43(ob->obmat, tmat, mat);
497                                                                 }
498                                                                 
499                                                                 VECCOPY(ob->obmat[3], vec);
500                                                                 /* put object back in original state, so it cam be restored OK */
501                                                                 Mat4CpyMat4(tmat, ob->obmat);
502                                                                 Mat4CpyMat4(ob->obmat, copyob.obmat);
503                                                                 new_dupli_object(lb, ob, tmat, par->lay);
504                                                         }
505                                                 }
506                                                 else { // non static particles
507                                                            
508                                                         if((paf->flag & PAF_UNBORN)==0 && ctime < pa->time) continue;
509                                                         if((paf->flag & PAF_DIED)==0 && ctime > pa->time+pa->lifetime) continue;
510
511                                                         //if(ctime < pa->time+pa->lifetime) {
512
513                                                         /* to give ipos in object correct offset */
514                                                         where_is_object_time(ob, ctime-pa->time);
515                                                         
516                                                         where_is_particle(paf, pa, ctime, vec);
517                                                         if(paf->stype==PAF_VECT) {
518                                                                 where_is_particle(paf, pa, ctime+1.0f, vec1);
519                                                                 
520                                                                 VecSubf(vec1, vec1, vec);
521                                                                 q2= vectoquat(vec1, ob->trackflag, ob->upflag);
522                                         
523                                                                 QuatToMat3(q2, mat);
524                                                                 Mat4CpyMat4(tmat, ob->obmat);
525                                                                 Mat4MulMat43(ob->obmat, tmat, mat);
526                                                         }
527
528                                                         VECCOPY(ob->obmat[3], vec);
529                                                         
530                                                         /* put object back in original state, so it cam be restored OK */
531                                                         Mat4CpyMat4(tmat, ob->obmat);
532                                                         Mat4CpyMat4(ob->obmat, copyob.obmat);
533                                                         new_dupli_object(lb, ob, tmat, par->lay);
534                                                 }                                       
535                                         }
536                                         /* temp copy, to have ipos etc to work OK */
537                                         *ob= copyob;
538                                         
539                                         break;
540                                 }
541                                 ob= ob->parent;
542                         }
543                 }
544         }
545 }
546
547 static Object *find_family_object(Object **obar, char *family, char ch)
548 {
549         Object *ob;
550         int flen;
551         
552         if( obar[ch] ) return obar[ch];
553         
554         flen= strlen(family);
555         
556         ob= G.main->object.first;
557         while(ob) {
558                 if( ob->id.name[flen+2]==ch ) {
559                         if( strncmp(ob->id.name+2, family, flen)==0 ) break;
560                 }
561                 ob= ob->id.next;
562         }
563         
564         obar[ch]= ob;
565         
566         return ob;
567 }
568
569
570 static void font_duplilist(ListBase *lb, Object *par)
571 {
572         Object *ob, *obar[256];
573         Curve *cu;
574         struct chartrans *ct, *chartransdata;
575         float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof;
576         int slen, a;
577         
578         Mat4CpyMat4(pmat, par->obmat);
579         
580         /* in par the family name is stored, use this to find the other objects */
581         
582         chartransdata= text_to_curve(par, FO_DUPLI);
583         if(chartransdata==0) return;
584         
585         memset(obar, 0, 256*sizeof(void *));
586         
587         cu= par->data;
588         slen= strlen(cu->str);
589         fsize= cu->fsize;
590         xof= cu->xof;
591         yof= cu->yof;
592         
593         ct= chartransdata;
594         
595         for(a=0; a<slen; a++, ct++) {
596                 
597                 ob= find_family_object(obar, cu->family, cu->str[a]);
598                 if(ob) {
599                         vec[0]= fsize*(ct->xof - xof);
600                         vec[1]= fsize*(ct->yof - yof);
601                         vec[2]= 0.0;
602                         
603                         Mat4MulVecfl(pmat, vec);
604                         
605                         Mat4CpyMat4(obmat, par->obmat);
606                         VECCOPY(obmat[3], vec);
607                         
608                         new_dupli_object(lb, ob, obmat, par->lay);
609                 }
610                 
611         }
612         
613         MEM_freeN(chartransdata);
614 }
615
616 /* ***************************** */
617
618 ListBase *object_duplilist(Scene *sce, Object *ob)
619 {
620         static ListBase duplilist={NULL, NULL};
621         
622         if(duplilist.first) {
623                 printf("wrong call to object_duplilist\n");
624                 return &duplilist;
625         }
626         duplilist.first= duplilist.last= NULL;
627         
628         if(ob->transflag & OB_DUPLI) {
629                 if(ob->transflag & OB_DUPLIVERTS) {
630                         if(ob->type==OB_MESH) {
631                                 if(ob->transflag & OB_DUPLIVERTS) {
632                                         PartEff *paf;
633                                         if( (paf=give_parteff(ob)) ) particle_duplilist(&duplilist, sce, ob, paf);
634                                         else vertex_duplilist(&duplilist, sce, ob);
635                                 }
636                         }
637                         else if(ob->type==OB_FONT) {
638                                 font_duplilist(&duplilist, ob);
639                         }
640                 }
641                 else if(ob->transflag & OB_DUPLIFRAMES) 
642                         frames_duplilist(&duplilist, ob);
643                 else if(ob->transflag & OB_DUPLIGROUP)
644                         group_duplilist(&duplilist, ob);
645         }
646         
647         return &duplilist;
648 }
649
650 void free_object_duplilist(ListBase *lb)
651 {
652         DupliObject *dob;
653         
654         for(dob= lb->first; dob; dob= dob->next)
655                 dob->ob->lay= dob->origlay;
656         BLI_freelistN(lb);
657 }
658
659 int count_duplilist(Object *ob)
660 {
661         if(ob->transflag & OB_DUPLI) {
662                 if(ob->transflag & OB_DUPLIVERTS) {
663                         if(ob->type==OB_MESH) {
664                                 if(ob->transflag & OB_DUPLIVERTS) {
665                                         PartEff *paf;
666                                         if( (paf=give_parteff(ob)) ) {
667                                                 return paf->totpart;
668                                         }
669                                         else {
670                                                 Mesh *me= ob->data;
671                                                 return me->totvert;
672                                         }
673                                 }
674                         }
675                 }
676                 else if(ob->transflag & OB_DUPLIFRAMES) {
677                         int tot= ob->dupend - ob->dupsta; 
678                         tot/= (ob->dupon+ob->dupoff);
679                         return tot*ob->dupon;
680                 }
681         }
682         return 1;
683 }