~ubuntu-branches/ubuntu/lucid/blender/lucid

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/fluidsim.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-08-06 22:32:19 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090806223219-8z4eej1u8levu4pz
Tags: 2.49a+dfsg-0ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control: Build-depend on python-2.6 rather than python-2.5.
  - debian/misc/*.desktop: Add Spanish translation to .desktop 
    files.
  - debian/pyversions: 2.6.
  - debian/rules: Clean *.o of source/blender/python/api2_2x/
* New upstream release (LP: #382153).
* Refreshed patches:
  - 01_sanitize_sys.patch
  - 02_tmp_in_HOME
  - 10_use_systemwide_ftgl
  - 70_portability_platform_detection
* Removed patches merged upstream:
  - 30_fix_python_syntax_warning
  - 90_ubuntu_ffmpeg_52_changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
139
139
                fluid_get_bb(mesh->mvert, mesh->totvert, ob->obmat, fss->bbStart, fss->bbSize); 
140
140
                */
141
141
                
 
142
                // (ab)used to store velocities
 
143
                fss->meshSurfNormals = NULL;
 
144
                
142
145
                fss->lastgoodframe = -1;
143
146
                
144
147
                fss->flag = 0;
153
156
#ifndef DISABLE_ELBEEM
154
157
        if(fluidmd)
155
158
        {
 
159
                if(fluidmd->fss->meshSurfNormals)
 
160
                {
 
161
                        MEM_freeN(fluidmd->fss->meshSurfNormals);
 
162
                        fluidmd->fss->meshSurfNormals = NULL;
 
163
                }
156
164
                MEM_freeN(fluidmd->fss);
157
165
        }
158
166
#endif
462
470
        // load vertex velocities, if they exist...
463
471
        // TODO? use generate flag as loading flag as well?
464
472
        // warning, needs original .bobj.gz mesh loading filename
465
 
        /*
466
473
        if(displaymode==3) 
467
474
        {
468
 
                readVelgz(targetFile, srcob);
 
475
                fluidsim_read_vel_cache(fluidmd, dm, targetFile);
469
476
        } 
470
477
        else 
471
478
        {
472
 
                // no data for preview, only clear...
473
 
                int i,j;
474
 
                for(i=0; i<mesh->totvert;i++) { for(j=0; j<3; j++) { srcob->fluidsimSettings->meshSurfNormals[i].co[j] = 0.; }} 
475
 
        }*/
 
479
                if(fss->meshSurfNormals)
 
480
                        MEM_freeN(fss->meshSurfNormals); 
 
481
                        
 
482
                fss->meshSurfNormals = NULL;
 
483
        }
476
484
        
477
485
        return dm;
478
486
}
479
487
 
 
488
 
 
489
/* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */
 
490
void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename)
 
491
{
 
492
        int wri, i, j;
 
493
        float wrf;
 
494
        gzFile gzf;
 
495
        FluidsimSettings *fss = fluidmd->fss;
 
496
        int len = strlen(filename);
 
497
        int totvert = dm->getNumVerts(dm);
 
498
        float *velarray = NULL;
 
499
        
 
500
        // mesh and vverts have to be valid from loading...
 
501
        
 
502
        if(fss->meshSurfNormals)
 
503
                MEM_freeN(fss->meshSurfNormals);
 
504
                
 
505
        if(len<7) 
 
506
        { 
 
507
                return; 
 
508
        }
 
509
        
 
510
        if(fss->domainNovecgen>0) return;
 
511
        
 
512
        // abusing pointer to hold an array of 3d-velocities
 
513
        fss->meshSurfNormals = MEM_callocN(sizeof(float)*3*dm->getNumVerts(dm), "Fluidsim_velocities");
 
514
        // abusing pointer to hold an INT
 
515
        fss->meshSurface = SET_INT_IN_POINTER(totvert);
 
516
        
 
517
        velarray = (float *)fss->meshSurfNormals;
 
518
        
 
519
        // .bobj.gz , correct filename
 
520
        // 87654321
 
521
        filename[len-6] = 'v';
 
522
        filename[len-5] = 'e';
 
523
        filename[len-4] = 'l';
 
524
 
 
525
        gzf = gzopen(filename, "rb");
 
526
        if (!gzf)
 
527
        {
 
528
                MEM_freeN(fss->meshSurfNormals);
 
529
                fss->meshSurfNormals = NULL;    
 
530
                return;
 
531
        }
 
532
 
 
533
        gzread(gzf, &wri, sizeof( wri ));
 
534
        if(wri != totvert) 
 
535
        {
 
536
                MEM_freeN(fss->meshSurfNormals);
 
537
                fss->meshSurfNormals = NULL;
 
538
                return; 
 
539
        }
 
540
 
 
541
        for(i=0; i<totvert;i++) 
 
542
        {
 
543
                for(j=0; j<3; j++) 
 
544
                {
 
545
                        gzread(gzf, &wrf, sizeof( wrf )); 
 
546
                        velarray[3*i + j] = wrf;
 
547
                }
 
548
        }
 
549
 
 
550
        gzclose(gzf);
 
551
}
 
552
 
480
553
void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4],
481
554
                 /*RET*/ float start[3], /*RET*/ float size[3] )
482
555
{
583
656
        dm->release(dm);
584
657
}
585
658
 
586
 
/* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */
587
 
void readVelgz(char *filename, Object *srcob)
588
 
{
589
 
        int wri, i, j;
590
 
        float wrf;
591
 
        gzFile gzf;
592
 
        MVert *vverts = srcob->fluidsimSettings->meshSurfNormals;
593
 
        int len = strlen(filename);
594
 
        Mesh *mesh = srcob->data;
595
 
        // mesh and vverts have to be valid from loading...
596
 
 
597
 
        // clean up in any case
598
 
        for(i=0; i<mesh->totvert;i++) 
599
 
        { 
600
 
                for(j=0; j<3; j++) 
601
 
                {
602
 
                        vverts[i].co[j] = 0.; 
603
 
                } 
604
 
        } 
605
 
        if(srcob->fluidsimSettings->domainNovecgen>0) return;
606
 
 
607
 
        if(len<7) 
608
 
        { 
609
 
                return; 
610
 
        }
611
 
 
612
 
        // .bobj.gz , correct filename
613
 
        // 87654321
614
 
        filename[len-6] = 'v';
615
 
        filename[len-5] = 'e';
616
 
        filename[len-4] = 'l';
617
 
 
618
 
        gzf = gzopen(filename, "rb");
619
 
        if (!gzf)
620
 
                return;
621
 
 
622
 
        gzread(gzf, &wri, sizeof( wri ));
623
 
        if(wri != mesh->totvert) 
624
 
        {
625
 
                return; 
626
 
        }
627
 
 
628
 
        for(i=0; i<mesh->totvert;i++) 
629
 
        {
630
 
                for(j=0; j<3; j++) 
631
 
                {
632
 
                        gzread(gzf, &wrf, sizeof( wrf )); 
633
 
                        vverts[i].co[j] = wrf;
634
 
                }
635
 
        }
636
 
 
637
 
        gzclose(gzf);
638
 
}
639
 
 
640
 
 
641
659
#endif // DISABLE_ELBEEM
642
660