128
119
"INVALID" /* end */
134
// similar to MeshDerivedMesh
135
struct Object *ob; // pointer to parent object
136
float *extverts, *nors; // face normals, colors?
137
Mesh *fsmesh; // mesh struct to display (either surface, or original one)
138
char meshFree; // free the mesh afterwards? (boolean)
139
} fluidsimDerivedMesh;
143
122
/* enable/disable overall compilation */
144
123
#ifndef DISABLE_ELBEEM
147
126
/* ********************** fluid sim settings struct functions ********************** */
149
/* allocates and initializes general main data */
151
FluidsimSettings *fluidsimSettingsNew(struct Object *srcob)
153
//char blendDir[FILE_MAXDIR], blendFile[FILE_MAXFILE];
154
FluidsimSettings *fss;
156
/* this call uses derivedMesh methods... */
157
if(srcob->type!=OB_MESH) return NULL;
159
fss= MEM_callocN( sizeof(FluidsimSettings), "fluidsimsettings memory");
162
fss->show_advancedoptions = 0;
164
fss->resolutionxyz = 50;
165
fss->previewresxyz = 25;
166
fss->realsize = 0.03;
167
fss->guiDisplayMode = 2; // preview
168
fss->renderDisplayMode = 3; // render
170
fss->viscosityMode = 2; // default to water
171
fss->viscosityValue = 1.0;
172
fss->viscosityExponent = 6;
176
fss->animStart = 0.0;
178
fss->gstar = 0.005; // used as normgstar
180
// maxRefine is set according to resolutionxyz during bake
182
// fluid/inflow settings
187
/* elubie: changed this to default to the same dir as the render output
188
to prevent saving to C:\ on Windows */
189
BLI_strncpy(fss->surfdataPath, btempdir, FILE_MAX);
190
fss->orgMesh = (Mesh *)srcob->data;
191
fss->meshSurface = NULL;
193
fss->meshSurfNormals = NULL;
195
// first init of bounding box
196
fss->bbStart[0] = 0.0;
197
fss->bbStart[1] = 0.0;
198
fss->bbStart[2] = 0.0;
199
fss->bbSize[0] = 1.0;
200
fss->bbSize[1] = 1.0;
201
fss->bbSize[2] = 1.0;
202
fluidsimGetAxisAlignedBB(srcob->data, srcob->obmat, fss->bbStart, fss->bbSize, &fss->meshBB);
204
// todo - reuse default init from elbeem!
206
fss->domainNovecgen = 0;
207
fss->volumeInitType = 1; // volume
208
fss->partSlipValue = 0.0;
210
fss->generateTracers = 0;
211
fss->generateParticles = 0.0;
212
fss->surfaceSmoothing = 1.0;
213
fss->surfaceSubdivs = 1.0;
214
fss->particleInfSize = 0.0;
215
fss->particleInfAlpha = 0.0;
220
/* duplicate struct, analogous to free */
221
static Mesh *fluidsimCopyMesh(Mesh *me)
223
Mesh *dup = MEM_dupallocN(me);
225
CustomData_copy(&me->vdata, &dup->vdata, CD_MASK_MESH, CD_DUPLICATE, me->totvert);
226
CustomData_copy(&me->edata, &dup->edata, CD_MASK_MESH, CD_DUPLICATE, me->totedge);
227
CustomData_copy(&me->fdata, &dup->fdata, CD_MASK_MESH, CD_DUPLICATE, me->totface);
232
FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *fss)
234
FluidsimSettings *dupfss;
236
if(!fss) return NULL;
237
dupfss = MEM_dupallocN(fss);
240
dupfss->meshSurface = fluidsimCopyMesh(fss->meshSurface);
242
dupfss->meshBB = fluidsimCopyMesh(fss->meshBB);
244
if(fss->meshSurfNormals) dupfss->meshSurfNormals = MEM_dupallocN(fss->meshSurfNormals);
250
static void fluidsimFreeMesh(Mesh *me)
252
CustomData_free(&me->vdata, me->totvert);
253
CustomData_free(&me->edata, me->totedge);
254
CustomData_free(&me->fdata, me->totface);
259
void fluidsimSettingsFree(FluidsimSettings *fss)
261
if(fss->meshSurface) {
262
fluidsimFreeMesh(fss->meshSurface);
263
fss->meshSurface = NULL;
266
fluidsimFreeMesh(fss->meshBB);
270
if(fss->meshSurfNormals){ MEM_freeN(fss->meshSurfNormals); fss->meshSurfNormals=NULL; }
276
128
/* helper function */
277
129
void fluidsimGetGeometryObjFilename(struct Object *ob, char *dst) { //, char *srcname) {
278
130
//snprintf(dst,FILE_MAXFILE, "%s_cfgdata_%s.bobj.gz", srcname, ob->id.name);
306
158
FS_FREE_ONECHANNEL(channelObjMove[i][2],"channelObjMove2"); \
307
159
FS_FREE_ONECHANNEL(channelObjInivel[i],"channelObjInivel"); \
308
160
FS_FREE_ONECHANNEL(channelObjActive[i],"channelObjActive"); \
161
FS_FREE_ONECHANNEL(channelAttractforceStrength[i],"channelAttractforceStrength"); \
162
FS_FREE_ONECHANNEL(channelAttractforceRadius[i],"channelAttractforceRadius"); \
163
FS_FREE_ONECHANNEL(channelVelocityforceStrength[i],"channelVelocityforceStrength"); \
164
FS_FREE_ONECHANNEL(channelVelocityforceRadius[i],"channelVelocityforceRadius"); \
310
166
} // end FS FREE CHANNELS
403
259
G.scene->r.cfra = frame;
404
260
scene_update_for_newframe(G.scene, G.scene->lay);
406
initElbeemMesh(obm, &numVerts, &verts, &numTris, &tris, 1);
262
initElbeemMesh(obm, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
407
263
//fprintf(stderr,"\nfluidsimInitMeshChannel frame%d verts%d/%d \n\n",frame,vertices,numVerts);
408
264
for(i=0; i<3*vertices;i++) {
409
265
channel[(frame-1)*setsize + i] = verts[i];
423
279
/* ********************** simulation thread ************************* */
424
280
/* ******************************************************************************** */
426
SDL_mutex *globalBakeLock=NULL;
427
int globalBakeState = 0; // 0 everything ok, -1 abort simulation, -2 sim error, 1 sim done
428
int globalBakeFrame = 0;
282
static volatile int globalBakeState = 0; // 0 everything ok, -1 abort simulation, -2 sim error, 1 sim done
283
static volatile int globalBakeFrame = 0;
284
static volatile int g_break= 0;
430
286
// run simulation in seperate thread
431
static int fluidsimSimulateThread(void *unused) { // *ptr) {
287
static void *fluidsimSimulateThread(void *unused) { // *ptr) {
432
288
//char* fnameCfgPath = (char*)(ptr);
435
291
ret = elbeemSimulate();
436
SDL_mutexP(globalBakeLock);
292
BLI_lock_thread(LOCK_CUSTOM1);
437
293
if(globalBakeState==0) {
439
295
// if no error, set to normal exit
443
299
globalBakeState = -2;
446
SDL_mutexV(globalBakeLock);
302
BLI_unlock_thread(LOCK_CUSTOM1);
451
307
int runSimulationCallback(void *data, int status, int frame) {
452
308
//elbeemSimulationSettings *settings = (elbeemSimulationSettings*)data;
453
309
//printf("elbeem blender cb s%d, f%d, domainid:%d \n", status,frame, settings->domainId ); // DEBUG
455
if(!globalBakeLock) return FLUIDSIM_CBRET_ABORT;
456
311
if(status==FLUIDSIM_CBSTATUS_NEWFRAME) {
457
SDL_mutexP(globalBakeLock);
312
BLI_lock_thread(LOCK_CUSTOM1);
458
313
globalBakeFrame = frame-1;
459
SDL_mutexV(globalBakeLock);
314
BLI_unlock_thread(LOCK_CUSTOM1);
462
317
//if((frameCounter==3) && (!frameStop)) { frameStop=1; return 1; }
464
SDL_mutexP(globalBakeLock);
465
if(globalBakeState!=0) {
319
BLI_lock_thread(LOCK_CUSTOM1);
320
state = globalBakeState;
321
BLI_unlock_thread(LOCK_CUSTOM1);
466
324
return FLUIDSIM_CBRET_ABORT;
468
SDL_mutexV(globalBakeLock);
469
327
return FLUIDSIM_CBRET_CONTINUE;
522
381
float *channelObjMove[256][3]; // object movments , 0=trans, 1=rot, 2=scale
523
382
float *channelObjInivel[256]; // initial velocities
524
383
float *channelObjActive[256]; // obj active channel
385
/* fluid control channels */
386
float *channelAttractforceStrength[256];
387
float *channelAttractforceRadius[256];
388
float *channelVelocityforceStrength[256];
389
float *channelVelocityforceRadius[256];
390
FluidsimModifierData *fluidmd = NULL;
526
393
if(getenv(strEnvName)) {
527
394
int dlevel = atoi(getenv(strEnvName));
528
395
elbeemSetDebugLevel(dlevel);
546
413
/* no object pointer, find in selected ones.. */
549
415
for(base=G.scene->base.first; base; base= base->next) {
550
if ( ((base)->flag & SELECT)
551
// ignore layer setting for now? && ((base)->lay & G.vd->lay)
553
if((!ob)&&(base->object->fluidsimFlag & OB_FLUIDSIM_ENABLE)&&(base->object->type==OB_MESH)) {
554
if(base->object->fluidsimSettings->type == OB_FLUIDSIM_DOMAIN) {
416
if ((base)->flag & SELECT)
418
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(base->object, eModifierType_Fluidsim);
420
if(fluidmdtmp && (base->object->type==OB_MESH))
422
if(fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN)
555
424
ob = base->object;
560
430
// no domains found?
435
for(base=G.scene->base.first; base; base= base->next)
437
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(base->object, eModifierType_Fluidsim);
440
(obit->type==OB_MESH) &&
441
(fluidmdtmp->fss->type != OB_FLUIDSIM_DOMAIN) && // if has to match 3 places! // CHECKMATCH
442
(fluidmdtmp->fss->type != OB_FLUIDSIM_PARTICLE) )
448
if (channelObjCount>=255) {
449
pupmenu("Fluidsim Bake Error%t|Cannot bake with more then 256 objects");
564
453
/* check if there's another domain... */
565
for(obit= G.main->object.first; obit; obit= obit->id.next) {
566
if((obit->fluidsimFlag & OB_FLUIDSIM_ENABLE)&&(obit->type==OB_MESH)) {
567
if(obit->fluidsimSettings->type == OB_FLUIDSIM_DOMAIN) {
569
//snprintf(debugStrBuffer,256,"fluidsimBake::warning - More than one domain!\n"); elbeemDebugOut(debugStrBuffer);
454
for(base=G.scene->base.first; base; base= base->next)
456
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(base->object, eModifierType_Fluidsim);
458
if( fluidmdtmp &&(obit->type==OB_MESH))
460
if(fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN)
570
464
pupmenu("Fluidsim Bake Error%t|There should be only one domain object! Aborted%x0");
471
// check if theres any fluid
472
// abort baking if not...
473
for(base=G.scene->base.first; base; base= base->next)
475
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(base->object, eModifierType_Fluidsim);
478
(obit->type==OB_MESH) &&
479
((fluidmdtmp->fss->type == OB_FLUIDSIM_FLUID) ||
480
(fluidmdtmp->fss->type == OB_FLUIDSIM_INFLOW) ))
487
pupmenu("Fluidsim Bake Error%t|No fluid objects in scene... Aborted%x0");
576
491
/* these both have to be valid, otherwise we wouldnt be here */
577
492
/* dont use ob here after...*/
579
domainSettings = ob->fluidsimSettings;
494
fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
495
domainSettings = fluidmd->fss;
497
mesh = fsDomain->data;
499
// calculate bounding box
500
fluid_get_bb(mesh->mvert, mesh->totvert, fsDomain->obmat, domainSettings->bbStart, domainSettings->bbSize);
502
// reset last valid frame
503
domainSettings->lastgoodframe = -1;
581
505
/* rough check of settings... */
582
506
if(domainSettings->previewresxyz > domainSettings->resolutionxyz) {
583
507
snprintf(debugStrBuffer,256,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz , domainSettings->resolutionxyz);
603
527
snprintf(debugStrBuffer,256,"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels );
604
528
elbeemDebugOut(debugStrBuffer);
606
// check if theres any fluid
607
// abort baking if not...
608
for(obit= G.main->object.first; obit; obit= obit->id.next) {
609
if( (obit->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
610
(obit->type==OB_MESH) && (
611
(obit->fluidsimSettings->type == OB_FLUIDSIM_FLUID) ||
612
(obit->fluidsimSettings->type == OB_FLUIDSIM_INFLOW) )
618
pupmenu("Fluidsim Bake Error%t|No fluid objects in scene... Aborted%x0");
622
530
// prepare names...
623
531
strncpy(targetDir, domainSettings->surfdataPath, FILE_MAXDIR);
681
589
// dump data for start frame
682
590
// CHECK more reasonable to number frames according to blender?
683
591
// dump data for frame 0
684
G.scene->r.cfra = startFrame;
685
scene_update_for_newframe(G.scene, G.scene->lay);
592
G.scene->r.cfra = startFrame;
593
scene_update_for_newframe(G.scene, G.scene->lay);
687
595
// init common export vars for both file export and run
688
596
for(i=0; i<256; i++) {
689
597
channelObjMove[i][0] = channelObjMove[i][1] = channelObjMove[i][2] = NULL;
690
598
channelObjInivel[i] = NULL;
691
599
channelObjActive[i] = NULL;
600
channelAttractforceStrength[i] = NULL;
601
channelAttractforceRadius[i] = NULL;
602
channelVelocityforceStrength[i] = NULL;
603
channelVelocityforceRadius[i] = NULL;
693
605
allchannelSize = G.scene->r.efra; // always use till last frame
694
606
aniFrameTime = (domainSettings->animEnd - domainSettings->animStart)/(double)noFrames;
750
661
// init obj movement channels
751
662
channelObjCount=0;
752
for(obit= G.main->object.first; obit; obit= obit->id.next) {
753
//{ snprintf(debugStrBuffer,256,"DEBUG object name=%s, type=%d ...\n", obit->id.name, obit->type); elbeemDebugOut(debugStrBuffer); } // DEBUG
754
if( (obit->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
755
(obit->type==OB_MESH) &&
756
(obit->fluidsimSettings->type != OB_FLUIDSIM_DOMAIN) && // if has to match 3 places! // CHECKMATCH
757
(obit->fluidsimSettings->type != OB_FLUIDSIM_PARTICLE) ) {
663
for(base=G.scene->base.first; base; base= base->next)
665
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(base->object, eModifierType_Fluidsim);
669
(obit->type==OB_MESH) &&
670
(fluidmdtmp->fss->type != OB_FLUIDSIM_DOMAIN) && // if has to match 3 places! // CHECKMATCH
671
(fluidmdtmp->fss->type != OB_FLUIDSIM_PARTICLE) ) {
759
673
// cant use fluidsimInitChannel for obj channels right now, due
760
674
// to the special DXXX channels, and the rotation specialities
852
766
channelObjMove[o][j][(i-1)*4 + 3] = timeAtFrame[i];
771
int attrFSIcu[1] = { FLUIDSIM_ATTR_FORCE_STR };
772
int attrFRIcu[1] = { FLUIDSIM_ATTR_FORCE_RADIUS };
773
int velFSIcu[1] = { FLUIDSIM_VEL_FORCE_STR };
774
int velFRIcu[1] = { FLUIDSIM_VEL_FORCE_RADIUS };
856
fluidsimInitChannel( &channelObjInivel[o], allchannelSize, timeAtFrame, inivelIcu,inivelDefs, obit->fluidsimSettings->ipo, CHANNEL_VEC );
857
fluidsimInitChannel( &channelObjActive[o], allchannelSize, timeAtFrame, activeIcu,activeDefs, obit->fluidsimSettings->ipo, CHANNEL_FLOAT );
781
attrFSDefs[0] = fluidmdtmp->fss->attractforceStrength;
782
attrFRDefs[0] = fluidmdtmp->fss->attractforceRadius;
783
velFSDefs[0] = fluidmdtmp->fss->velocityforceStrength;
784
velFRDefs[0] = fluidmdtmp->fss->velocityforceRadius;
786
fluidsimInitChannel( &channelAttractforceStrength[o], allchannelSize, timeAtFrame, attrFSIcu,attrFSDefs, fluidmdtmp->fss->ipo, CHANNEL_FLOAT );
787
fluidsimInitChannel( &channelAttractforceRadius[o], allchannelSize, timeAtFrame, attrFRIcu,attrFRDefs, fluidmdtmp->fss->ipo, CHANNEL_FLOAT );
788
fluidsimInitChannel( &channelVelocityforceStrength[o], allchannelSize, timeAtFrame, velFSIcu,velFSDefs, fluidmdtmp->fss->ipo, CHANNEL_FLOAT );
789
fluidsimInitChannel( &channelVelocityforceRadius[o], allchannelSize, timeAtFrame, velFRIcu,velFRDefs, fluidmdtmp->fss->ipo, CHANNEL_FLOAT );
792
fluidsimInitChannel( &channelObjInivel[o], allchannelSize, timeAtFrame, inivelIcu,inivelDefs, fluidmdtmp->fss->ipo, CHANNEL_VEC );
793
fluidsimInitChannel( &channelObjActive[o], allchannelSize, timeAtFrame, activeIcu,activeDefs, fluidmdtmp->fss->ipo, CHANNEL_FLOAT );
859
796
channelObjCount++;
954
892
channelObjCount = 0;
955
for(obit= G.main->object.first; obit; obit= obit->id.next) {
893
for(base=G.scene->base.first; base; base= base->next) {
894
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(base->object, eModifierType_Fluidsim);
956
896
//{ snprintf(debugStrBuffer,256,"DEBUG object name=%s, type=%d ...\n", obit->id.name, obit->type); elbeemDebugOut(debugStrBuffer); } // DEBUG
957
if( (obit->fluidsimFlag & OB_FLUIDSIM_ENABLE) && // if has to match 3 places! // CHECKMATCH
958
(obit->type==OB_MESH) &&
959
(obit->fluidsimSettings->type != OB_FLUIDSIM_DOMAIN) &&
960
(obit->fluidsimSettings->type != OB_FLUIDSIM_PARTICLE)
897
if( fluidmdtmp && // if has to match 3 places! // CHECKMATCH
898
(obit->type==OB_MESH) &&
899
(fluidmdtmp->fss->type != OB_FLUIDSIM_DOMAIN) &&
900
(fluidmdtmp->fss->type != OB_FLUIDSIM_PARTICLE))
962
902
float *verts=NULL;
964
904
int numVerts=0, numTris=0;
965
905
int o = channelObjCount;
966
int deform = (obit->fluidsimSettings->domainNovecgen); // misused value
906
int deform = (fluidmdtmp->fss->domainNovecgen); // misused value
967
907
// todo - use blenderInitElbeemMesh
908
int modifierIndex = modifiers_indexInObject(obit, (ModifierData *)fluidmdtmp);
968
910
elbeemMesh fsmesh;
969
911
elbeemResetMesh( &fsmesh );
970
fsmesh.type = obit->fluidsimSettings->type;;
912
fsmesh.type = fluidmdtmp->fss->type;
971
913
// get name of object for debugging solver
972
914
fsmesh.name = obit->id.name;
974
initElbeemMesh(obit, &numVerts, &verts, &numTris, &tris, 0);
916
initElbeemMesh(obit, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
975
917
fsmesh.numVertices = numVerts;
976
918
fsmesh.numTriangles = numTris;
977
919
fsmesh.vertices = verts;
988
930
fsmesh.channelScale = channelObjMove[o][2];
989
931
fsmesh.channelActive = channelObjActive[o];
990
932
if( (fsmesh.type == OB_FLUIDSIM_FLUID) ||
991
(fsmesh.type == OB_FLUIDSIM_INFLOW) ) {
933
(fsmesh.type == OB_FLUIDSIM_INFLOW)) {
992
934
fsmesh.channelInitialVel = channelObjInivel[o];
993
fsmesh.localInivelCoords = ((obit->fluidsimSettings->typeFlags&OB_FSINFLOW_LOCALCOORD)?1:0);
935
fsmesh.localInivelCoords = ((fluidmdtmp->fss->typeFlags&OB_FSINFLOW_LOCALCOORD)?1:0);
996
if( (obit->fluidsimSettings->typeFlags&OB_FSBND_NOSLIP)) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
997
else if((obit->fluidsimSettings->typeFlags&OB_FSBND_PARTSLIP)) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP;
998
else if((obit->fluidsimSettings->typeFlags&OB_FSBND_FREESLIP)) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
999
fsmesh.obstaclePartslip = obit->fluidsimSettings->partSlipValue;
1000
fsmesh.volumeInitType = obit->fluidsimSettings->volumeInitType;
1001
fsmesh.obstacleImpactFactor = obit->fluidsimSettings->surfaceSmoothing; // misused value
938
if( (fluidmdtmp->fss->typeFlags&OB_FSBND_NOSLIP)) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
939
else if((fluidmdtmp->fss->typeFlags&OB_FSBND_PARTSLIP)) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP;
940
else if((fluidmdtmp->fss->typeFlags&OB_FSBND_FREESLIP)) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
941
fsmesh.obstaclePartslip = fluidmdtmp->fss->partSlipValue;
942
fsmesh.volumeInitType = fluidmdtmp->fss->volumeInitType;
943
fsmesh.obstacleImpactFactor = fluidmdtmp->fss->surfaceSmoothing; // misused value
945
if(fsmesh.type == OB_FLUIDSIM_CONTROL)
947
// control fluids will get exported as whole
950
fsmesh.cpsTimeStart = fluidmdtmp->fss->cpsTimeStart;
951
fsmesh.cpsTimeEnd = fluidmdtmp->fss->cpsTimeEnd;
952
fsmesh.cpsQuality = fluidmdtmp->fss->cpsQuality;
953
fsmesh.obstacleType = (fluidmdtmp->fss->flag & OB_FLUIDSIM_REVERSE);
955
fsmesh.channelSizeAttractforceRadius =
956
fsmesh.channelSizeVelocityforceStrength =
957
fsmesh.channelSizeVelocityforceRadius =
958
fsmesh.channelSizeAttractforceStrength = allchannelSize;
960
fsmesh.channelAttractforceStrength = channelAttractforceStrength[o];
961
fsmesh.channelAttractforceRadius = channelAttractforceRadius[o];
962
fsmesh.channelVelocityforceStrength = channelVelocityforceStrength[o];
963
fsmesh.channelVelocityforceRadius = channelVelocityforceRadius[o];
968
fsmesh.channelAttractforceStrength =
969
fsmesh.channelAttractforceRadius =
970
fsmesh.channelVelocityforceStrength =
971
fsmesh.channelVelocityforceRadius = NULL;
1003
974
// animated meshes
1005
976
fsmesh.channelSizeVertices = allchannelSize;
1006
fluidsimInitMeshChannel( &fsmesh.channelVertices, allchannelSize, obit, numVerts, timeAtFrame);
977
fluidsimInitMeshChannel( &fsmesh.channelVertices, allchannelSize, obit, numVerts, timeAtFrame, modifierIndex);
1007
978
G.scene->r.cfra = startFrame;
1008
979
scene_update_for_newframe(G.scene, G.scene->lay);
1009
980
// remove channels
1023
994
//domainSettings->type = OB_FLUIDSIM_DOMAIN; // enable for bake display again
1024
995
//fsDomain->fluidsimFlag = OB_FLUIDSIM_ENABLE; // disable during bake
1026
globalBakeLock = SDL_CreateMutex();
1027
997
// set to neutral, -1 means user abort, -2 means init error
1028
998
globalBakeState = 0;
1029
999
globalBakeFrame = 0;
1030
simthr = SDL_CreateThread(fluidsimSimulateThread, targetFile);
1033
snprintf(debugStrBuffer,256,"fluidsimBake::error: Unable to create thread... running without one.\n");
1034
elbeemDebugOut(debugStrBuffer);
1000
BLI_init_threads(&threads, fluidsimSimulateThread, 1);
1001
BLI_insert_thread(&threads, targetFile);
1039
1005
unsigned short event=0;
1054
1023
sprintf(busy_mess, "baking fluids %d / %d |||", globalBakeFrame, (int) noFramesf);
1055
1024
progress_bar(percentdone, busy_mess );
1057
SDL_Delay(2000); // longer delay to prevent frequent redrawing
1058
SDL_mutexP(globalBakeLock);
1026
// longer delay to prevent frequent redrawing
1029
BLI_lock_thread(LOCK_CUSTOM1);
1059
1030
if(globalBakeState != 0) done = 1; // 1=ok, <0=error/abort
1060
SDL_mutexV(globalBakeLock);
1031
BLI_unlock_thread(LOCK_CUSTOM1);
1063
event = extern_qread(&val);
1064
if(event == ESCKEY) {
1033
if (!G.background) {
1034
g_break= blender_test_break();
1066
SDL_mutexP(globalBakeLock);
1039
BLI_lock_thread(LOCK_CUSTOM1);
1042
domainSettings->lastgoodframe = startFrame+globalBakeFrame;
1068
1045
globalBakeFrame = 0;
1069
1046
globalBakeState = -1;
1070
1047
simAborted = 1;
1071
SDL_mutexV(globalBakeLock);
1048
BLI_unlock_thread(LOCK_CUSTOM1);