doxygen: add newline after \file
[blender.git] / intern / elbeem / intern / elbeem.cpp
index 23a447a..01e4801 100644 (file)
@@ -1,3 +1,6 @@
+/** \file
+ * \ingroup elbeem
+ */
 /******************************************************************************
  *
  * El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
@@ -96,6 +99,13 @@ int elbeemInit() {
        return 0;
 }
 
+// fluidsim end
+extern "C" 
+int elbeemFree() {
+       
+       return 0;
+}
+
 // start fluidsim init
 extern "C" 
 int elbeemAddDomain(elbeemSimulationSettings *settings) {
@@ -159,13 +169,27 @@ void elbeemResetMesh(elbeemMesh *mesh) {
 
        /* name of the mesh, mostly for debugging */
        mesh->name = "[unnamed]";
+       
+       /* fluid control settings */
+       mesh->cpsTimeStart = 0;
+       mesh->cpsTimeEnd = 0;
+       mesh->cpsQuality = 0;
+       
+       mesh->channelSizeAttractforceStrength = 0;
+       mesh->channelAttractforceStrength = NULL;
+       mesh->channelSizeAttractforceRadius = 0;
+       mesh->channelAttractforceRadius = NULL;
+       mesh->channelSizeVelocityforceStrength = 0;
+       mesh->channelVelocityforceStrength = NULL;
+       mesh->channelSizeVelocityforceRadius = 0;
+       mesh->channelVelocityforceRadius = NULL;
 }
 
 int globalMeshCounter = 1;
 // add mesh as fluidsim object
 extern "C" 
 int elbeemAddMesh(elbeemMesh *mesh) {
-       int initType = -1;
+       int initType;
        if(getElbeemState() != SIMWORLD_INITIALIZING) { errFatal("elbeemAddMesh","World and domain not initialized, call elbeemInit and elbeemAddDomain before...", SIMWORLD_INITERROR); }
 
        switch(mesh->type) {
@@ -177,12 +201,13 @@ int elbeemAddMesh(elbeemMesh *mesh) {
                case OB_FLUIDSIM_FLUID: initType = FGI_FLUID; break;
                case OB_FLUIDSIM_INFLOW: initType = FGI_MBNDINFLOW; break;
                case OB_FLUIDSIM_OUTFLOW: initType = FGI_MBNDOUTFLOW; break;
+               case OB_FLUIDSIM_CONTROL: initType = FGI_CONTROL; break;
+               default: return 1; // invalid type
        }
-       // invalid type?
-       if(initType<0) return 1;
        
        ntlGeometryObjModel *obj = new ntlGeometryObjModel( );
        gpWorld->getRenderGlobals()->getSimScene()->addGeoClass( obj );
+       gpWorld->getRenderGlobals()->getRenderScene()->addGeoClass(obj);
        obj->initModel(
                        mesh->numVertices, mesh->vertices, mesh->numTriangles, mesh->triangles,
                        mesh->channelSizeVertices, mesh->channelVertices );
@@ -196,17 +221,34 @@ 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 */
+       obj->setCpsTimeStart(mesh->cpsTimeStart);
+       obj->setCpsTimeEnd(mesh->cpsTimeEnd);
+       obj->setCpsQuality(mesh->cpsQuality);
+       
        if((mesh->volumeInitType<VOLUMEINIT_VOLUME)||(mesh->volumeInitType>VOLUMEINIT_BOTH)) mesh->volumeInitType = VOLUMEINIT_VOLUME;
        obj->setVolumeInit(mesh->volumeInitType);
        // use channel instead, obj->setInitialVelocity( ntlVec3Gfx(mesh->iniVelocity[0], mesh->iniVelocity[1], mesh->iniVelocity[2]) );
+       
        obj->initChannels(
                        mesh->channelSizeTranslation, mesh->channelTranslation, 
                        mesh->channelSizeRotation,    mesh->channelRotation, 
                        mesh->channelSizeScale,       mesh->channelScale,
                        mesh->channelSizeActive,      mesh->channelActive,
-                       mesh->channelSizeInitialVel,  mesh->channelInitialVel
+                       mesh->channelSizeInitialVel,  mesh->channelInitialVel,
+                       mesh->channelSizeAttractforceStrength,  mesh->channelAttractforceStrength,
+                       mesh->channelSizeAttractforceRadius,  mesh->channelAttractforceRadius,
+                       mesh->channelSizeVelocityforceStrength,  mesh->channelVelocityforceStrength,
+                       mesh->channelSizeVelocityforceRadius,  mesh->channelVelocityforceRadius
                );
        obj->setLocalCoordInivel( mesh->localInivelCoords );
 
@@ -228,6 +270,7 @@ int elbeemSimulate(void) {
                if(getElbeemState() != SIMWORLD_STOP) {
                        // ok, we're done...
                        delete gpWorld;
+                       
                        gpWorld = NULL;
                        debMsgStd("elbeemSimulate",DM_NOTIFY, "El'Beem simulation done, time: "<<getTimeString(timeend-timestart)<<".\n", 2 ); 
                } else {