WIP commit, completely untested (should introduce: 1. copy of modifier settings work...
authorDaniel Genrich <daniel.genrich@gmx.net>
Mon, 28 Jul 2008 16:55:48 +0000 (16:55 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Mon, 28 Jul 2008 16:55:48 +0000 (16:55 +0000)
intern/elbeem/intern/controlparticles.cpp
intern/elbeem/intern/elbeem.cpp
source/blender/blenkernel/intern/fluidsim.c
source/blender/blenkernel/intern/modifier.c
source/blender/makesdna/DNA_object_fluidsim.h
source/blender/src/buttons_object.c
source/blender/src/fluidsim.c

index 90bc99cada73dbe9ab6268bf1710a1870bacb732..c08501d5847ed099cd4cfbf46735649688aa7714 100644 (file)
@@ -184,6 +184,12 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) {
        delete genscene;
        delete glob;
        
+       // do reverse here
+       if(model->getGeoPartSlipValue())
+       {
+               mirrorTime();
+       }
+       
        return 1;
 }
 
index c9e6bc7989b9c7585611987304cbb64679af3e6b..f7923322d5b4e3e008197cfb14056ea7e3abc99f 100644 (file)
@@ -217,7 +217,13 @@ int elbeemAddMesh(elbeemMesh *mesh) {
        obj->setGeoInitId( mesh->parentDomainId+1 );
        obj->setGeoInitIntersect(true);
        obj->setGeoInitType(initType);
-       obj->setGeoPartSlipValue(mesh->obstaclePartslip);
+       
+       // abuse partslip value for control fluid: reverse control keys or not
+       if(initType == FGI_CONTROL)
+               obj->setGeoPartSlipValue(mesh->obstacleType);
+       else
+               obj->setGeoPartSlipValue(mesh->obstaclePartslip);
+       
        obj->setGeoImpactFactor(mesh->obstacleImpactFactor);
        
        /* fluid control features */
index fb0f3975529dc7a3d0e97afdf4da88479f782879..29c7fff24f9d32755da894d0464f976a6751cccb 100644 (file)
@@ -178,6 +178,13 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Object *ob, Deri
        // timescale not supported yet
        // clmd->sim_parms->timescale= timescale;
        
+       // support reversing of baked fluid frames here
+       if((fss->show_advancedoptions & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0))
+       {
+               framenr = fss->lastgoodframe - framenr + 1;
+               CLAMP(framenr, 1, fss->lastgoodframe);
+       }
+       
        /* try to read from cache */
        if(((fss->lastgoodframe >= framenr) || (fss->lastgoodframe < 0)) && (result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
        {
index d970b064a449772c0e7d4f2ea867fd60ac44c0d1..e8dfab7988d5e0b03bb75755b33771aef06819eb 100644 (file)
@@ -6906,6 +6906,17 @@ static void fluidsimModifier_freeData(ModifierData *md)
        fluidsim_free(fluidmd);
 }
 
+static void fluidsimModifier_copyData(ModifierData *md, ModifierData *target)
+{
+       FluidsimModifierData *fluidmd= (FluidsimModifierData*) md;
+       FluidsimModifierData *tfluidmd= (FluidsimModifierData*) target;
+       
+       if(tfluidmd->fss)
+               MEM_freeN(tfluidmd->fss);
+       
+       tfluidmd->fss = MEM_dupallocN(fluidmd->fss);
+}
+
 static DerivedMesh * fluidsimModifier_applyModifier(
                ModifierData *md, Object *ob, DerivedMesh *derivedData,
   int useRenderParams, int isFinalCalc)
@@ -7605,6 +7616,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
                mti->flags = eModifierTypeFlag_AcceptsMesh;
                mti->initData = fluidsimModifier_initData;
                mti->freeData = fluidsimModifier_freeData;
+               mti->copyData = fluidsimModifier_copyData;
                mti->dependsOnTime = fluidsimModifier_dependsOnTime;
                mti->applyModifier = fluidsimModifier_applyModifier;
                mti->updateDepgraph = fluidsimModifier_updateDepgraph;
index 30257bb9b177af24c44d6087be42a3045fc33426..19e65855c54e16ea71a29543be45e5741c4a72f9 100644 (file)
@@ -158,6 +158,9 @@ typedef struct FluidsimSettings {
 #define OB_FSPART_NEWPART (1<<3)
 #define OB_FSPART_FLOAT   (1<<4)
 
+// new fluid bit flags for show_advancedoptions (min 8 - 1,2,4 reserved) - dg
+#define OB_FLUIDSIM_REVERSE 8
+
 #ifdef __cplusplus
 }
 #endif
index 4fc665c96432ea35422787bbb498ee90bc4e05de..18bc483f03e12409abf4194775020da5b0edbde1 100644 (file)
@@ -2406,6 +2406,7 @@ void do_object_panels(unsigned short event)
        case B_FLUIDSIM_CHANGETYPE:
        {
                FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
+               fluidmd->fss->show_advancedoptions &= ~OB_FLUIDSIM_REVERSE; // clear flag
                if(ob && ob->particlesystem.first && fluidmd->fss->type!=OB_FLUIDSIM_PARTICLE){
                        ParticleSystem *psys;
                        for(psys=ob->particlesystem.first; psys; psys=psys->next) {
@@ -5050,53 +5051,17 @@ static void object_panel_fluidsim(Object *ob)
                                               fss->bbSize[0],fss->bbSize[1],fss->bbSize[2], fss->maxRefine, memString );
                
                        uiBlockBeginAlign ( block );
-                       uiDefButS ( block, ROW, REDRAWBUTSOBJECT, "Std",         0,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 0, 20.0, 0, "Show standard domain options." );
-                       uiDefButS ( block, ROW, REDRAWBUTSOBJECT, "Adv",        25,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 1, 20.0, 1, "Show advanced domain options." );
-                       uiDefButS ( block, ROW, REDRAWBUTSOBJECT, "Bnd",        50,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 2, 20.0, 2, "Show domain boundary options." );
+                       uiDefButBitS ( block, TOG, 4, REDRAWBUTSOBJECT, "Std",     0, yline,25,objHeight, &fss->show_advancedoptions, 0, 0, 0, 0, "Show standard domain options." );
+                       uiDefButBitS ( block, TOG, 1, REDRAWBUTSOBJECT, "Adv",     25, yline,25,objHeight, &fss->show_advancedoptions, 0, 0, 0, 0, "Show advanced domain options." );
+                       uiDefButBitS ( block, TOG, 2, REDRAWBUTSOBJECT, "Bnd",     50, yline,25,objHeight, &fss->show_advancedoptions, 0, 0, 0, 0, "Show domain boundary options." );
                        uiBlockEndAlign ( block );
                
                        uiDefBut ( block, BUT, B_FLUIDSIM_BAKE, "BAKE",90, yline,210,objHeight, NULL, 0.0, 0.0, 10, 0, "Perform simulation and output and surface&preview meshes for each frame." );
+                       
                        yline -= lineHeight;
                        yline -= 2*separateHeight;
                
-                       if ( fss->show_advancedoptions == 0 )
-                       {
-                               uiDefBut ( block, LABEL,   0, "Req. BAKE Memory:",  0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "" );
-                               uiDefBut ( block, LABEL,   0, memString,  200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, "" );
-                               yline -= lineHeight;
-               
-                               uiBlockBeginAlign ( block );
-                               uiDefButS ( block, NUM, REDRAWBUTSOBJECT, "Resolution:", 0, yline,150,objHeight, &fss->resolutionxyz, 1, maxRes, 10, 0, "Domain resolution in X, Y and Z direction" );
-                               uiDefButS ( block, NUM, B_DIFF,           "Preview-Res.:", 150, yline,150,objHeight, &fss->previewresxyz, 1, 100, 10, 0, "Resolution of the preview meshes to generate, also in X, Y and Z direction" );
-                               uiBlockEndAlign ( block );
-                               yline -= lineHeight;
-                               yline -= 1*separateHeight;
-               
-                               uiBlockBeginAlign ( block );
-                               uiDefButF ( block, NUM, B_DIFF, "Start time:",   0, yline,150,objHeight, &fss->animStart, 0.0, 100.0, 10, 0, "Simulation time of the first blender frame." );
-                               uiDefButF ( block, NUM, B_DIFF, "End time:",   150, yline,150,objHeight, &fss->animEnd  , 0.0, 100.0, 10, 0, "Simulation time of the last blender frame." );
-                               uiBlockEndAlign ( block );
-                               yline -= lineHeight;
-                               yline -= 2*separateHeight;
-               
-                               if ( ( fss->guiDisplayMode<1 ) || ( fss->guiDisplayMode>3 ) ) { fss->guiDisplayMode=2; } // can be changed by particle setting
-                               uiDefBut ( block, LABEL,   0, "Disp.-Qual.:",            0,yline, 90,objHeight, NULL, 0.0, 0, 0, 0, "" );
-                               uiBlockBeginAlign ( block );
-                               uiDefButS ( block, MENU, B_BAKE_CACHE_CHANGE, "GuiDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",
-                                               90,yline,105,objHeight, &fss->guiDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh in the Blender GUI." );
-                               uiDefButS ( block, MENU, B_DIFF, "RenderDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",
-                                               195,yline,105,objHeight, &fss->renderDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh for rendering." );
-                               uiBlockEndAlign ( block );
-                               yline -= lineHeight;
-                               yline -= 1*separateHeight;
-               
-                               uiBlockBeginAlign ( block );
-                               uiDefIconBut ( block, BUT, B_FLUIDSIM_SELDIR, ICON_FILESEL,  0, yline,  20, objHeight,                   0, 0, 0, 0, 0,  "Select Directory (and/or filename prefix) to store baked fluid simulation files in" );
-                               uiDefBut ( block, TEX,     B_BAKE_CACHE_CHANGE,"",            20, yline, 280, objHeight, fss->surfdataPath, 0.0,79.0, 0, 0,  "Enter Directory (and/or filename prefix) to store baked fluid simulation files in" );
-                               uiBlockEndAlign ( block );
-                               // FIXME what is the 79.0 above?
-                       }
-                       else if ( fss->show_advancedoptions == 1 )
+                       if ( fss->show_advancedoptions & 1 )
                        {
                                // advanced options
                                uiDefBut ( block, LABEL, 0, "Gravity:",         0, yline,  90,objHeight, NULL, 0.0, 0, 0, 0, "" );
@@ -5141,7 +5106,7 @@ static void object_panel_fluidsim(Object *ob)
                                yline -= lineHeight;
                
                        }
-                       else if ( fss->show_advancedoptions == 2 )
+                       else if ( fss->show_advancedoptions & 2 )
                        {
                                // copied from obstacle...
                                //yline -= lineHeight + 5;
@@ -5185,7 +5150,47 @@ static void object_panel_fluidsim(Object *ob)
                                uiDefBut ( block, LABEL, 0, "Generate&Use SpeedVecs:",          0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "" );
                                uiDefButBitC ( block, TOG, 1, REDRAWBUTSOBJECT, "Disable",     200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Default is to generate and use fluidsim vertex speed vectors, this option switches calculation off during bake, and disables loading." );
                                yline -= lineHeight;
-                       } // domain 3
+                       }
+                       else
+                       {
+                               uiDefBut ( block, LABEL,   0, "Req. BAKE Memory:",  0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "" );
+                               uiDefBut ( block, LABEL,   0, memString,  200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, "" );
+                               yline -= lineHeight;
+               
+                               uiBlockBeginAlign ( block );
+                               uiDefButS ( block, NUM, REDRAWBUTSOBJECT, "Resolution:", 0, yline,150,objHeight, &fss->resolutionxyz, 1, maxRes, 10, 0, "Domain resolution in X, Y and Z direction" );
+                               uiDefButS ( block, NUM, B_DIFF,           "Preview-Res.:", 150, yline,150,objHeight, &fss->previewresxyz, 1, 100, 10, 0, "Resolution of the preview meshes to generate, also in X, Y and Z direction" );
+                               uiBlockEndAlign ( block );
+                               yline -= lineHeight;
+                               yline -= 1*separateHeight;
+               
+                               uiBlockBeginAlign ( block );
+                               uiDefButF ( block, NUM, B_DIFF, "Start time:",   0, yline,150,objHeight, &fss->animStart, 0.0, 100.0, 10, 0, "Simulation time of the first blender frame." );
+                               uiDefButF ( block, NUM, B_DIFF, "End time:",   150, yline,150,objHeight, &fss->animEnd  , 0.0, 100.0, 10, 0, "Simulation time of the last blender frame." );
+                               uiBlockEndAlign ( block );
+                               yline -= lineHeight;
+                               yline -= 2*separateHeight;
+               
+                               if ( ( fss->guiDisplayMode<1 ) || ( fss->guiDisplayMode>3 ) ) { fss->guiDisplayMode=2; } // can be changed by particle setting
+                               uiDefBut ( block, LABEL,   0, "Disp.-Qual.:",            0,yline, 90,objHeight, NULL, 0.0, 0, 0, 0, "" );
+                               uiBlockBeginAlign ( block );
+                               uiDefButS ( block, MENU, B_BAKE_CACHE_CHANGE, "GuiDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",
+                                           90,yline,105,objHeight, &fss->guiDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh in the Blender GUI." );
+                               uiDefButS ( block, MENU, B_DIFF, "RenderDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",
+                                           195,yline,105,objHeight, &fss->renderDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh for rendering." );
+                               uiBlockEndAlign ( block );
+                               yline -= lineHeight;
+                               yline -= 1*separateHeight;
+               
+                               uiDefButBitS ( block, TOG, OB_FLUIDSIM_REVERSE, REDRAWBUTSOBJECT, "Reverse",     0, yline,50,objHeight, &fss->show_advancedoptions, 0, 0, 0, 0, "Reverse fluidsim frames" );
+                               uiDefBut ( block, LABEL,   0, "",  50,yline,25,objHeight, NULL, 0.0, 0, 0, 0, "" );
+                               uiBlockBeginAlign ( block );
+                               uiDefIconBut ( block, BUT, B_FLUIDSIM_SELDIR, ICON_FILESEL,  75, yline,  20, objHeight,                   0, 0, 0, 0, 0,  "Select Directory (and/or filename prefix) to store baked fluid simulation files in" );
+                               uiDefBut ( block, TEX,     B_BAKE_CACHE_CHANGE,"",            95, yline, 205, objHeight, fss->surfdataPath, 0.0,79.0, 0, 0,  "Enter Directory (and/or filename prefix) to store baked fluid simulation files in" );
+                               
+                               uiBlockEndAlign ( block );
+                               // FIXME what is the 79.0 above?
+                       }
                }
                else if (
                        ( fss->type == OB_FLUIDSIM_FLUID )
@@ -5335,6 +5340,7 @@ static void object_panel_fluidsim(Object *ob)
                
                        yline -= lineHeight;
                        uiDefButF ( block, NUM, B_DIFF, "Quality:", 0, yline,150,20, &fss->cpsQuality, 5.0, 100.0,   10,0, "Specifies the quality which is used for object sampling (higher = better but slower)." );
+                       uiDefButBitS ( block, TOG, OB_FLUIDSIM_REVERSE, REDRAWBUTSOBJECT, "Reverse",     150, yline,150,20, &fss->show_advancedoptions, 0, 0, 0, 0, "Reverse control object movement." );
                }
                else
                {
index d2ad4bed62554bc7c7c428371b4d47a76b1013e3..7d5939ce94b56a8a64d30563a9811427f75b1261 100644 (file)
@@ -911,7 +911,7 @@ void fluidsimBake(struct Object *ob)
                                int o = channelObjCount;
                                int     deform = (fluidmdtmp->fss->domainNovecgen); // misused value
                                // todo - use blenderInitElbeemMesh
-                               int modifierIndex = modifiers_indexInObject(obit, fluidmdtmp);
+                               int modifierIndex = modifiers_indexInObject(obit, (ModifierData *)fluidmdtmp);
                                
                                elbeemMesh fsmesh;
                                elbeemResetMesh( &fsmesh );
@@ -956,6 +956,7 @@ void fluidsimBake(struct Object *ob)
                                        fsmesh.cpsTimeStart = fluidmdtmp->fss->cpsTimeStart;
                                        fsmesh.cpsTimeEnd = fluidmdtmp->fss->cpsTimeEnd;
                                        fsmesh.cpsQuality = fluidmdtmp->fss->cpsQuality;
+                                       fsmesh.obstacleType = (fluidmdtmp->fss->show_advancedoptions & OB_FLUIDSIM_REVERSE);
                                        
                                        fsmesh.channelSizeAttractforceRadius = 
                                        fsmesh.channelSizeVelocityforceStrength =