[Bf-blender-cvs] [3ed9864aa40] fluid-mantaflow: changed particle lifetime from int to float

Sebastián Barschkis noreply at git.blender.org
Wed Nov 29 19:12:33 CET 2017


Commit: 3ed9864aa40dc8223820ec555af9782075d44ceb
Author: Sebastián Barschkis
Date:   Wed Nov 29 15:01:34 2017 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB3ed9864aa40dc8223820ec555af9782075d44ceb

changed particle lifetime from int to float

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

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

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

diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index e17f533907f..9b688bf6306 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -45,7 +45,7 @@ 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 liquid_export(struct FLUID *liquid, float **phi, float **pp, float **pvel, float **ppSnd, float **pvelSnd, int **plifeSnd);
+void liquid_export(struct FLUID *liquid, float **phi, float **pp, float **pvel, float **ppSnd, float **pvelSnd, float **plifeSnd);
 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);
@@ -152,7 +152,7 @@ void liquid_set_snd_particle_data(struct FLUID* liquid, float* buffer, int numPa
 
 void liquid_set_flip_particle_velocity(struct FLUID* liquid, float* buffer, int numParts);
 void liquid_set_snd_particle_velocity(struct FLUID* liquid, float* buffer, int numParts);
-void liquid_set_snd_particle_life(struct FLUID* liquid, int* buffer, int numParts);
+void liquid_set_snd_particle_life(struct FLUID* liquid, float* buffer, int numParts);
 
 // Fluids in general
 int *fluid_get_num_obstacle(struct FLUID *fluid);
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 1706107bc22..74e3b75c5c7 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -1367,7 +1367,7 @@ void FLUID::updatePointers()
 		if (mUsingDrops || mUsingBubbles || mUsingFloats || mUsingTracers) {
 			mSndParticleData     = (std::vector<pData>*) getDataPointer("ppSnd" + solver_ext, solver);
 			mSndParticleVelocity = (std::vector<pVel>*)  getDataPointer("pVelSnd" + parts_ext, parts);
-			mSndParticleLife     = (std::vector<int>*)   getDataPointer("pLifeSnd" + parts_ext, parts);
+			mSndParticleLife     = (std::vector<float>*) getDataPointer("pLifeSnd" + parts_ext, parts);
 		}
 	}
 	
@@ -1482,11 +1482,11 @@ void FLUID::setSndParticleVelocity(float* buffer, int numParts)
 	}
 }
 
-void FLUID::setSndParticleLife(int* buffer, int numParts)
+void FLUID::setSndParticleLife(float* buffer, int numParts)
 {
 	mSndParticleLife->resize(numParts);
-	int* bufferPType = buffer;
-	for (std::vector<int>::iterator it = mSndParticleLife->begin(); it != mSndParticleLife->end(); ++it) {
+	float* bufferPType = buffer;
+	for (std::vector<float>::iterator it = mSndParticleLife->begin(); it != mSndParticleLife->end(); ++it) {
 		*it = *bufferPType;
 		bufferPType++;
 	}
diff --git a/intern/mantaflow/intern/FLUID.h b/intern/mantaflow/intern/FLUID.h
index f4f22524d62..0362a7f6aa6 100644
--- a/intern/mantaflow/intern/FLUID.h
+++ b/intern/mantaflow/intern/FLUID.h
@@ -195,7 +195,7 @@ public:
 
 	inline float* getFlipParticleVelocity() { return (mFlipParticleVelocity) ? (float*) &mFlipParticleVelocity->front() : NULL; }
 	inline float* getSndParticleVelocity()  { return (mSndParticleVelocity) ? (float*) &mSndParticleVelocity->front() : NULL; }
-	inline int*   getSndParticleLife()      { return (mSndParticleLife) ? (int*) &mSndParticleLife->front() : NULL; }
+	inline float* getSndParticleLife()      { return (mSndParticleLife) ? (float*) &mSndParticleLife->front() : NULL; }
 
 	inline int getNumFlipParticles() { return (mFlipParticleData) ? mFlipParticleData->size() : 0; }
 	inline int getNumSndParticles() { return (mSndParticleData) ? mSndParticleData->size() : 0; }
@@ -208,8 +208,7 @@ public:
 
 	void setFlipParticleVelocity(float* buffer, int numParts);
 	void setSndParticleVelocity(float* buffer, int numParts);
-	void setSndParticleType(int* buffer, int numParts);
-	void setSndParticleLife(int* buffer, int numParts);
+	void setSndParticleLife(float* buffer, int numParts);
 
 private:
 	// simulation constants
@@ -314,7 +313,7 @@ private:
 
 	std::vector<pData>* mSndParticleData;
 	std::vector<pVel>* mSndParticleVelocity;
-	std::vector<int>* mSndParticleLife;
+	std::vector<float>* mSndParticleLife;
 
 	void initDomain(struct SmokeModifierData *smd);
 	void initDomainHigh(struct SmokeModifierData *smd);
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index 4ec010e7cc4..51cb37a9e94 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -160,7 +160,7 @@ extern "C" void smoke_export(FLUID *smoke, float *dt, float *dx, float **dens, f
 	*dx = 1; //dummy value, not needed for smoke
 }
 
-extern "C" void liquid_export(FLUID *liquid, float **phi, float **pp, float **pvel, float **ppSnd, float **pvelSnd, int **plifeSnd)
+extern "C" void liquid_export(FLUID *liquid, float **phi, float **pp, float **pvel, float **ppSnd, float **pvelSnd, float **plifeSnd)
 {
 	if (phi)
 		*phi = liquid->getPhi();
@@ -810,7 +810,7 @@ extern "C" void liquid_set_snd_particle_velocity(FLUID* liquid, float* buffer, i
 	liquid->setSndParticleVelocity(buffer, numParts);
 }
 
-extern "C" void liquid_set_snd_particle_life(FLUID* liquid, int* buffer, int numParts)
+extern "C" void liquid_set_snd_particle_life(FLUID* liquid, float* buffer, int numParts)
 {
 	liquid->setSndParticleLife(buffer, numParts);
 }
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 72aef45fe09..10e3bff8110 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -598,8 +598,8 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
 	
 	if (sds->fluid) {
 		size_t res = sds->res[0]*sds->res[1]*sds->res[2];
-		float dt, dx, *dens, *react, *fuel, *flame, *heat, *vx, *vy, *vz, *r, *g, *b, *phi, *pp, *pvel, *ppSnd, *pvelSnd;
-		int *obstacles, *plifeSnd, numParts = 0, numPartsSnd = 0;
+		float dt, dx, *dens, *react, *fuel, *flame, *heat, *vx, *vy, *vz, *r, *g, *b, *phi, *pp, *pvel, *ppSnd, *pvelSnd, *plifeSnd;
+		int *obstacles, numParts = 0, numPartsSnd = 0;
 		unsigned int in_len = sizeof(float)*(unsigned int)res;
 		unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
 		//int mode = res >= 1000000 ? 2 : 1;
@@ -661,7 +661,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
 			out = (unsigned char *)MEM_callocN(numPartsSnd*sizeof(float)*3 + numPartsSnd*sizeof(int), "pointcache_lzo_buffer");
 			ptcache_file_compressed_write(pf, (unsigned char *) ppSnd, numPartsSnd*sizeof(float)*3 + numPartsSnd*sizeof(int), out, mode);
 			ptcache_file_compressed_write(pf, (unsigned char *) pvelSnd, numPartsSnd*sizeof(float)*3, out, mode);
-			ptcache_file_compressed_write(pf, (unsigned char *) plifeSnd, numPartsSnd*sizeof(int), out, mode);
+			ptcache_file_compressed_write(pf, (unsigned char *) plifeSnd, numPartsSnd*sizeof(float), out, mode);
 		}
 
 		MEM_freeN(out);
@@ -870,10 +870,12 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
 	
 	if (sds->fluid) {
 		size_t res = sds->res[0]*sds->res[1]*sds->res[2];
-		float dt, dx, *dens, *react, *fuel, *flame, *heat, *vx, *vy, *vz, *r, *g, *b, *phi, *pp, *pvel, *ppSnd, *pvelSnd;
-		int *obstacles, *plifeSnd, numParts = 0, numPartsSnd = 0;
+		float dt, dx, *dens, *react, *fuel, *flame, *heat, *vx, *vy, *vz, *r, *g, *b, *phi, *pp, *pvel, *ppSnd, *pvelSnd, *plifeSnd;
+		int *obstacles, numParts = 0, numPartsSnd = 0;
 		unsigned int out_len = (unsigned int)res * sizeof(float);
-		
+		unsigned char *buffer;
+		int readPP = 0, readPPSnd = 0; // Set if successfully read pp / ppSnd size
+
 		smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &vx, &vy, &vz, &r, &g, &b, &obstacles);
 		liquid_export(sds->fluid, &phi, &pp, &pvel, &ppSnd, &pvelSnd, &plifeSnd);
 
@@ -900,8 +902,8 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
 		ptcache_file_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res);
 		if (phi) {
 			ptcache_file_compressed_read(pf, (unsigned char *)phi, out_len);
-			ptcache_file_read(pf, &numParts, 1, sizeof(int));
-			ptcache_file_read(pf, &numPartsSnd, 1, sizeof(int));
+			readPP = ptcache_file_read(pf, &numParts, 1, sizeof(int));
+			readPPSnd = ptcache_file_read(pf, &numPartsSnd, 1, sizeof(int));
 		}
 		ptcache_file_read(pf, &dt, 1, sizeof(float));
 		ptcache_file_read(pf, &dx, 1, sizeof(float));
@@ -915,19 +917,19 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
 		ptcache_file_read(pf, &sds->res_min, 3, sizeof(int));
 		ptcache_file_read(pf, &sds->res_max, 3, sizeof(int));
 		ptcache_file_read(pf, &sds->active_color, 3, sizeof(float));
-		if (numParts) {
-			unsigned char *buffer = (unsigned char *)MEM_callocN(numParts*sizeof(float)*3 + numParts*sizeof(int), "pointcache_lzo_buffer");
+		if (readPP) { // cannot use pp in this if since pp vector is still empty
+			buffer = (unsigned char *)MEM_callocN(numParts*sizeof(float)*3 + numParts*sizeof(int), "pointcache_lzo_buffer");
 
 			ptcache_file_compressed_read(pf, (unsigned char *)buffer, numParts*sizeof(float)*3 + numParts*sizeof(int));
 			liquid_set_flip_particle_data(sds->fluid, (float*) buffer, numParts);
 
 			ptcache_file_compressed_read(pf, (unsigned char *)buffer, numParts*sizeof(float)*3);
 			liquid_set_flip_particle_velocity(sds->fluid, (float *) buffer, numParts);
-
 			MEM_freeN(buffer);
 		}
-		if (numPartsSnd) {
-			unsigned char *buffer = (unsigned char *)MEM_callocN(numPartsSnd*sizeof(float)*3 + numPartsSnd*sizeof(int), "pointcache_lzo_buffer");
+
+		if (readPPSnd) { // cannot use ppSnd in this if since pp vector is still empty
+			buffer = (unsigned char *)MEM_callocN(numPartsSnd*sizeof(float)*3 + numPartsSnd*sizeof(int), "pointcache_lo_buffer");
 
 			ptcache_file_compressed_read(pf, (unsigned 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list