Commit: a9992eaaabec8441cbf2a73fc64b03c3427460ce
Author: Sebastián Barschkis
Date:   Fri Jun 30 23:17:45 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBa9992eaaabec8441cbf2a73fc64b03c3427460ce

first support for ptcache files for liquids

===================================================================

M       intern/mantaflow/extern/manta_fluid_API.h
M       intern/mantaflow/intern/FLUID.cpp
M       intern/mantaflow/intern/FLUID.h
M       intern/mantaflow/intern/manta_fluid_API.cpp
M       source/blender/blenkernel/intern/pointcache.c
M       source/blender/blenkernel/intern/smoke.c
M       source/blender/makesrna/intern/rna_smoke.c

===================================================================

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index ed76fbee91a..96ef02c9b0d 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -44,7 +44,7 @@ void smoke_manta_export(struct FLUID* smoke, struct 
SmokeModifierData *smd);
 void smoke_step(struct FLUID *smoke, int framenr);
 void smoke_dissolve(struct FLUID *smoke, int speed, int log);
 void smoke_dissolve_wavelet(struct FLUID *smoke, int speed, int log);
-void smoke_export(struct FLUID *smoke, float *dt, float *dx, float **dens, 
float **react, float **flame, float **fuel, float **heat, float **vx, float 
**vy, float **vz, float **r, float **g, float **b, int **obstacles);
+void smoke_export(struct FLUID *smoke, float *dt, float *dx, float **dens, 
float **react, float **flame, float **fuel, float **heat, float **vx, float 
**vy, float **vz, float **r, float **g, float **b, int **obstacles, float 
**phi, float **pp, float **pvel, int *numParts);
 void smoke_turbulence_export(struct FLUID *smoke, float **dens, float **react, 
float **flame, float **fuel, float **r, float **g, float **b , float **tcu, 
float **tcv, float **tcw, float **tcu2, float **tcv2, float **tcw2);
 float *smoke_get_density(struct FLUID *smoke);
 float *smoke_get_fuel(struct FLUID *smoke);
@@ -116,12 +116,15 @@ float liquid_get_particle_position_z_at(struct FLUID 
*liquid, int i);
 float liquid_get_particle_velocity_x_at(struct FLUID *liquid, int i);
 float liquid_get_particle_velocity_y_at(struct FLUID *liquid, int i);
 float liquid_get_particle_velocity_z_at(struct FLUID *liquid, int i);
+float *liquid_get_particle_data(struct FLUID *liquid);
+float *liquid_get_particle_velocity(struct FLUID *liquid);
 void liquid_update_mesh_data(struct FLUID *liquid, char *filename);
-void liquid_update_particle_data(struct FLUID *liquid, char* filename);
 void liquid_save_mesh_high(struct FLUID *liquid, char *filename);
 void liquid_save_data_high(struct FLUID *liquid, char *pathname);
 void liquid_load_data_high(struct FLUID *liquid, char *pathname);
 void liquid_manta_export(struct FLUID* smoke, struct SmokeModifierData *smd);
+void liquid_set_particle_data(struct FLUID* liquid, float* buffer, int 
numParts);
+void liquid_set_particle_velocity(struct FLUID* liquid, float* buffer, int 
numParts);
 
 int *fluid_get_num_obstacle(struct FLUID *fluid);
 float *fluid_get_inflow(struct FLUID *fluid);
diff --git a/intern/mantaflow/intern/FLUID.cpp 
b/intern/mantaflow/intern/FLUID.cpp
index 5a2b4838e57..8a9c5503f7c 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -117,16 +117,15 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : 
mCurrentID(++solverID)
        mPhiIn          = NULL;
        mPhiObs         = NULL;
        mPhiOut         = NULL;
+       mPhi            = NULL;
 
        mNumVertices  = 0;
        mNumNormals   = 0;
        mNumTriangles = 0;
 
        // Particles
-       mNumParticles = 0;
-       mParticleDimX = 0;
-       mParticleDimY = 0;
-       mParticleDimZ = 0;
+       mParticleData      = NULL;
+       mParticleVelocity  = NULL;
 
        // Only start Mantaflow once. No need to start whenever new FLUID 
objected is allocated
        if (!mantaInitialized)
@@ -475,6 +474,10 @@ FLUID::~FLUID()
        mPhiIn  = NULL;
        mPhiObs = NULL;
        mPhiOut = NULL;
+       mPhi    = NULL;
+
+       mParticleData      = NULL;
+       mParticleVelocity  = NULL;
 
        // Reset flags
        mUsingHeat    = false;
@@ -952,99 +955,99 @@ void FLUID::updateMeshData(const char* filename)
        gzclose(gzf);
 }
 
-void FLUID::updateParticleData(const char* filename)
-{
-       gzFile gzf;
-       float fbuffer[3];
-       int ibuffer[4];
-
-       gzf = (gzFile) BLI_gzopen(filename, "rb1"); // do some compression
-       if (!gzf)
-               std::cout << "updateParticleData: unable to open file" << 
std::endl;
-
-       char ID[5] = {0,0,0,0,0};
-       gzread(gzf, ID, 4);
-
-       if (!strcmp(ID, "PB01")) {
-               std::cout << "particle uni file format v01 not supported 
anymore" << std::endl;
-               return;
-       }
-
-       // pdata uni header
-       const int STR_LEN_PDATA = 256;
-       int elementType, bytesPerElement; // type id and byte size
-       char info[STR_LEN_PDATA]; // mantaflow build information
-       unsigned long long timestamp; // creation time
-
-       // read particle header
-       gzread(gzf, &ibuffer, sizeof(int) * 4); // num particles, dimX, dimY, 
dimZ
-       gzread(gzf, &elementType, sizeof(int));
-       gzread(gzf, &bytesPerElement, sizeof(int));
-       gzread(gzf, &info, sizeof(info));
-       gzread(gzf, &timestamp, sizeof(unsigned long long));
-
-       if (with_debug)
-               std::cout << "read particles , num particles " << mNumParticles 
<< " , in file: "<< filename << std::endl;
-
-       // Sanity checks
-       const int partSysSize = sizeof(float) * 3 + sizeof(int);
-       if (! (bytesPerElement == partSysSize) && (elementType == 0)){
-               std::cout << "particle type doesn't match" << std::endl;
-       }
-       if (!ibuffer[0]) { // Any particles present?
-               if (with_debug) std::cout << "no particles present yet" << 
std::endl;
-               return;
-       }
-
-       // Reading base particle system file v2
-       if (!strcmp(ID, "PB02"))
-       {
-               // Only set head fields when read from particle system and not 
from pdata files (possibly incomplete)
-               mNumParticles = ibuffer[0];
-               mParticleDimX = ibuffer[1];
-               mParticleDimY = ibuffer[2];
-               mParticleDimZ = ibuffer[3];
-
-               mParticlePositionsX.resize(mNumParticles);
-               mParticlePositionsY.resize(mNumParticles);
-               mParticlePositionsZ.resize(mNumParticles);
-               mParticleFlags.resize(mNumParticles);
-
-               for (int i = 0; i < mNumParticles; ++i) {
-                       gzread(gzf, fbuffer, sizeof(float) * 3);
-
-                       mParticlePositionsX[i] = fbuffer[0];
-                       mParticlePositionsY[i] = fbuffer[1];
-                       mParticlePositionsZ[i] = fbuffer[2];
-
-//                     std::cout << "Positions are: [" << 
mParticlePositionsX[i] << ", " << mParticlePositionsY[i] << "," << 
mParticlePositionsZ[i] << "]" << std::endl;
-
-                       gzread(gzf, &ibuffer, sizeof(int));
-                       mParticleFlags[i] = ibuffer[0];
-               }
-       }
-       // Reading particle data file v1 with velocities
-       else if (!strcmp(ID, "PD01"))
-       {
-               mNumParticles = ibuffer[0];
-
-               mParticleVelocitiesX.resize(mNumParticles);
-               mParticleVelocitiesY.resize(mNumParticles);
-               mParticleVelocitiesZ.resize(mNumParticles);
-
-               for (int i = 0; i < mNumParticles; ++i) {
-                       gzread(gzf, fbuffer, sizeof(float) * 3);
-
-                       mParticleVelocitiesX[i] = fbuffer[0];
-                       mParticleVelocitiesY[i] = fbuffer[1];
-                       mParticleVelocitiesZ[i] = fbuffer[2];
-
-//                     std::cout << "Velocities are: [" << 
mParticleVelocitiesX[i] << ", " << mParticleVelocitiesY[i] << "," << 
mParticleVelocitiesZ[i] << "]" << std::endl;
-               }
-       }
-
-       gzclose(gzf);
-}
+//void FLUID::updateParticleData(const char* filename)
+//{
+//     gzFile gzf;
+//     float fbuffer[3];
+//     int ibuffer[4];
+//
+//     gzf = (gzFile) BLI_gzopen(filename, "rb1"); // do some compression
+//     if (!gzf)
+//             std::cout << "updateParticleData: unable to open file" << 
std::endl;
+//
+//     char ID[5] = {0,0,0,0,0};
+//     gzread(gzf, ID, 4);
+//
+//     if (!strcmp(ID, "PB01")) {
+//             std::cout << "particle uni file format v01 not supported 
anymore" << std::endl;
+//             return;
+//     }
+//
+//     // pdata uni header
+//     const int STR_LEN_PDATA = 256;
+//     int elementType, bytesPerElement; // type id and byte size
+//     char info[STR_LEN_PDATA]; // mantaflow build information
+//     unsigned long long timestamp; // creation time
+//
+//     // read particle header
+//     gzread(gzf, &ibuffer, sizeof(int) * 4); // num particles, dimX, dimY, 
dimZ
+//     gzread(gzf, &elementType, sizeof(int));
+//     gzread(gzf, &bytesPerElement, sizeof(int));
+//     gzread(gzf, &info, sizeof(info));
+//     gzread(gzf, &timestamp, sizeof(unsigned long long));
+//
+//     if (with_debug)
+//             std::cout << "read particles , num particles " << mNumParticles 
<< " , in file: "<< filename << std::endl;
+//
+//     // Sanity checks
+//     const int partSysSize = sizeof(float) * 3 + sizeof(int);
+//     if (! (bytesPerElement == partSysSize) && (elementType == 0)){
+//             std::cout << "particle type doesn't match" << std::endl;
+//     }
+//     if (!ibuffer[0]) { // Any particles present?
+//             if (with_debug) std::cout << "no particles present yet" << 
std::endl;
+//             return;
+//     }
+//
+//     // Reading base particle system file v2
+//     if (!strcmp(ID, "PB02"))
+//     {
+//             // Only set head fields when read from particle system and not 
from pdata files (possibly incomplete)
+//             mNumParticles = ibuffer[0];
+//             mParticleDimX = ibuffer[1];
+//             mParticleDimY = ibuffer[2];
+//             mParticleDimZ = ibuffer[3];
+//
+//             mParticlePositionsX.resize(mNumParticles);
+//             mParticlePositionsY.resize(mNumParticles);
+//             mParticlePositionsZ.resize(mNumParticles);
+//             mParticleFlags.resize(mNumParticles);
+//
+//             for (int i = 0; i < mNumParticles; ++i) {
+//                     gzread(gzf, fbuffer, sizeof(float) * 3);
+//
+//                     mParticlePositionsX[i] = fbuffer[0];
+//                     mParticlePositionsY[i] = fbuffer[1];
+//                     mParticlePositionsZ[i] = fbuffer[2];
+//
+////                   std::cout << "Positions are: [" << 
mParticlePositionsX[i] << ", " << mParticlePositionsY[i] << "," << 
mParticlePositionsZ[i] << "]" << std::endl;
+//
+//                     gzread(gzf, &ibuffer, sizeof(int));
+//                     mParticleFlags[i] = ibuffer[0];
+//             }
+//     }
+//     // Reading particle data file v1 with velocities
+//     else if (!strcmp(ID, "PD01"))
+//     {
+//             mNumParticles = ibuffer[0];
+//
+//             mParticleVelocitiesX.resize(mNumParticles);
+//             mParticleVelocitiesY.resize(mNumParticles);
+//             mParticleVelocitiesZ.resize(mNumParticles);
+//
+//             for (int i = 0; i < mNumParticles; ++i) {
+//                     gzread(gzf, fbuffer, sizeof(float) * 3);
+//
+//                     mParticleVelocitiesX[i] = fbuffer[0];
+//                     mParticleVelocitiesY[i] = fbuffer[1];
+//                     mParticleVelocitiesZ[i] = fbuffer[2];
+//
+////                   std::cout << "Velocities are: [" << 
mParticleVelocitiesX[i] << ", " << mParticleVelocitiesY[i] << "," << 
mParticleVelocitiesZ[i] << "]" << std::endl;
+//             }
+//     }
+//
+//     gzclose(gzf);
+//}
 
 void FLUID::updatePointers()
 {
@@ -1053,7 +1056,9 @@ void FLUID::updatePointers()
 
        std::string id = std::to_string(mCurrentID);
        std::string solver = "s" + id;
+       std::string parts  = "pp" + id;
        std::string solver_ext = "_" + solver;
+       std::string parts_ext = "_" + parts;
        
        mObstacle    = (int*) getDataPointer("flags" + solver_ext,  solver);
        mNumObstacle = (int*) getDataPointer("numObs" + solver_ext, solver);
@@ -1076,6 +1081,10 @@ void FLUID::updatePointers()
        if (m

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to