[Bf-blender-cvs] [e5c0d4613a8] master: Cleanup: remove smoke code from pointcache

Jacques Lucke noreply at git.blender.org
Wed Sep 23 11:39:40 CEST 2020


Commit: e5c0d4613a8943c712b57fb336997ecd78e6508e
Author: Jacques Lucke
Date:   Wed Sep 23 11:36:45 2020 +0200
Branches: master
https://developer.blender.org/rBe5c0d4613a8943c712b57fb336997ecd78e6508e

Cleanup: remove smoke code from pointcache

This code is not used by the new fluid simulation system.
Therefore, it does not make sense to keep it around.
We do want to integrate the fluid system with the generic cache
system eventually, but refactoring the system is easier when there
is less dead code that has to be refactored.

Note, I could not remove BKE_ptcache_id_from_smoke entirely yet,
because the depsgraph seems to expect that object that
uses DEG_add_collision_relations also has a pointcache.
That is because it wants to reset the point cache when any of the
other objects changed (this does not work with fluids currently).

Reviewers: sebbas

Differential Revision: https://developer.blender.org/D8987

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

M	source/blender/blenkernel/intern/pointcache.c

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

diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 75b88ae7845..31f5edf3d27 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -672,748 +672,6 @@ static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
   }
 }
 
-static void ptcache_smoke_error(void *smoke_v, const char *message)
-{
-  FluidModifierData *fmd = (FluidModifierData *)smoke_v;
-  BKE_modifier_set_error(&fmd->modifier, "%s", message);
-}
-
-#  define SMOKE_CACHE_VERSION "1.04"
-
-static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
-{
-  FluidModifierData *fmd = (FluidModifierData *)smoke_v;
-  FluidDomainSettings *fds = fmd->domain;
-  int ret = 0;
-  int fluid_fields = BKE_fluid_get_data_flags(fds);
-
-  /* version header */
-  ptcache_file_write(pf, SMOKE_CACHE_VERSION, 4, sizeof(char));
-  ptcache_file_write(pf, &fluid_fields, 1, sizeof(int));
-  ptcache_file_write(pf, &fds->active_fields, 1, sizeof(int));
-  ptcache_file_write(pf, &fds->res, 3, sizeof(int));
-  ptcache_file_write(pf, &fds->dx, 1, sizeof(float));
-
-  if (fds->fluid) {
-    size_t res = fds->res[0] * fds->res[1] * fds->res[2];
-    float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
-    unsigned char *obstacles;
-    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;
-    int mode = 1;  // light
-    if (fds->cache_comp == SM_CACHE_HEAVY) {
-      mode = 2;  // heavy
-    }
-
-    smoke_export(fds->fluid,
-                 &dt,
-                 &dx,
-                 &dens,
-                 &react,
-                 &flame,
-                 &fuel,
-                 &heat,
-                 &heatold,
-                 &vx,
-                 &vy,
-                 &vz,
-                 &r,
-                 &g,
-                 &b,
-                 &obstacles,
-                 NULL);
-
-    ptcache_file_compressed_write(pf, (unsigned char *)fds->shadow, in_len, out, mode);
-    ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len, out, mode);
-    if (fluid_fields & FLUID_DOMAIN_ACTIVE_HEAT) {
-      ptcache_file_compressed_write(pf, (unsigned char *)heat, in_len, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode);
-    }
-    if (fluid_fields & FLUID_DOMAIN_ACTIVE_FIRE) {
-      ptcache_file_compressed_write(pf, (unsigned char *)flame, in_len, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)fuel, in_len, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)react, in_len, out, mode);
-    }
-    if (fluid_fields & FLUID_DOMAIN_ACTIVE_COLORS) {
-      ptcache_file_compressed_write(pf, (unsigned char *)r, in_len, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)g, in_len, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)b, in_len, out, mode);
-    }
-    ptcache_file_compressed_write(pf, (unsigned char *)vx, in_len, out, mode);
-    ptcache_file_compressed_write(pf, (unsigned char *)vy, in_len, out, mode);
-    ptcache_file_compressed_write(pf, (unsigned char *)vz, in_len, out, mode);
-    ptcache_file_compressed_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode);
-    ptcache_file_write(pf, &dt, 1, sizeof(float));
-    ptcache_file_write(pf, &dx, 1, sizeof(float));
-    ptcache_file_write(pf, &fds->p0, 3, sizeof(float));
-    ptcache_file_write(pf, &fds->p1, 3, sizeof(float));
-    ptcache_file_write(pf, &fds->dp0, 3, sizeof(float));
-    ptcache_file_write(pf, &fds->shift, 3, sizeof(int));
-    ptcache_file_write(pf, &fds->obj_shift_f, 3, sizeof(float));
-    ptcache_file_write(pf, &fds->obmat, 16, sizeof(float));
-    ptcache_file_write(pf, &fds->base_res, 3, sizeof(int));
-    ptcache_file_write(pf, &fds->res_min, 3, sizeof(int));
-    ptcache_file_write(pf, &fds->res_max, 3, sizeof(int));
-    ptcache_file_write(pf, &fds->active_color, 3, sizeof(float));
-
-    MEM_freeN(out);
-
-    ret = 1;
-  }
-
-  if (fds->wt) {
-    int res_big_array[3];
-    int res_big;
-    int res = fds->res[0] * fds->res[1] * fds->res[2];
-    float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
-    unsigned int in_len = sizeof(float) * (unsigned int)res;
-    unsigned int in_len_big;
-    unsigned char *out;
-    int mode;
-
-    smoke_turbulence_get_res(fds->wt, res_big_array);
-    res_big = res_big_array[0] * res_big_array[1] * res_big_array[2];
-    // mode =  res_big >= 1000000 ? 2 : 1;
-    mode = 1;  // light
-    if (fds->cache_high_comp == SM_CACHE_HEAVY) {
-      mode = 2;  // heavy
-    }
-
-    in_len_big = sizeof(float) * (unsigned int)res_big;
-
-    smoke_turbulence_export(fds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
-
-    out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer");
-    ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len_big, out, mode);
-    if (fluid_fields & FLUID_DOMAIN_ACTIVE_FIRE) {
-      ptcache_file_compressed_write(pf, (unsigned char *)flame, in_len_big, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)fuel, in_len_big, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)react, in_len_big, out, mode);
-    }
-    if (fluid_fields & FLUID_DOMAIN_ACTIVE_COLORS) {
-      ptcache_file_compressed_write(pf, (unsigned char *)r, in_len_big, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)g, in_len_big, out, mode);
-      ptcache_file_compressed_write(pf, (unsigned char *)b, in_len_big, out, mode);
-    }
-    MEM_freeN(out);
-
-    out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
-    ptcache_file_compressed_write(pf, (unsigned char *)tcu, in_len, out, mode);
-    ptcache_file_compressed_write(pf, (unsigned char *)tcv, in_len, out, mode);
-    ptcache_file_compressed_write(pf, (unsigned char *)tcw, in_len, out, mode);
-    MEM_freeN(out);
-
-    ret = 1;
-  }
-
-  return ret;
-}
-
-/* read old smoke cache from 2.64 */
-static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v)
-{
-  FluidModifierData *fmd = (FluidModifierData *)smoke_v;
-  FluidDomainSettings *fds = fmd->domain;
-
-  if (fds->fluid) {
-    const size_t res = fds->res[0] * fds->res[1] * fds->res[2];
-    const unsigned int out_len = (unsigned int)res * sizeof(float);
-    float dt, dx, *dens, *heat, *heatold, *vx, *vy, *vz;
-    unsigned char *obstacles;
-    float *tmp_array = MEM_callocN(out_len, "Smoke old cache tmp");
-
-    int fluid_fields = BKE_fluid_get_data_flags(fds);
-
-    /* Part part of the new cache header */
-    fds->active_color[0] = 0.7f;
-    fds->active_color[1] = 0.7f;
-    fds->active_color[2] = 0.7f;
-
-    smoke_export(fds->fluid,
-                 &dt,
-                 &dx,
-                 &dens,
-                 NULL,
-                 NULL,
-                 NULL,
-                 &heat,
-                 &heatold,
-                 &vx,
-                 &vy,
-                 &vz,
-                 NULL,
-                 NULL,
-                 NULL,
-                 &obstacles,
-                 NULL);
-
-    ptcache_file_compressed_read(pf, (unsigned char *)fds->shadow, out_len);
-    ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len);
-    ptcache_file_compressed_read(pf, (unsigned char *)tmp_array, out_len);
-
-    if (fluid_fields & FLUID_DOMAIN_ACTIVE_HEAT) {
-      ptcache_file_compressed_read(pf, (unsigned char *)heat, out_len);
-      ptcache_file_compressed_read(pf, (unsigned char *)heatold, out_len);
-    }
-    else {
-      ptcache_file_compressed_read(pf, (unsigned char *)tmp_array, out_len);
-      ptcache_file_compressed_read(pf, (unsigned char *)tmp_array, out_len);
-    }
-    ptcache_file_compressed_read(pf, (unsigned char *)vx, out_len);
-    ptcache_file_compressed_read(pf, (unsigned char *)vy, out_len);
-    ptcache_file_compressed_read(pf, (unsigned char *)vz, out_len);
-    ptcache_file_compressed_read(pf, (unsigned char *)tmp_array, out_len);
-    ptcache_file_compressed_read(pf, (unsigned char *)tmp_array, out_len);
-    ptcache_file_compressed_read(pf, (unsigned char *)tmp_array, out_len);
-    ptcache_file_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res);
-    ptcache_file_read(pf, &dt, 1, sizeof(float));
-    ptcache_file_read(pf, &dx, 1, sizeof(float));
-
-    MEM_freeN(tmp_array);
-
-    if (pf->data_types & (1 << BPHYS_DATA_SMOKE_HIGH) && fds->wt) {
-      int res_big, res_big_array[3];
-      float *tcu, *tcv, *tcw;
-      unsigned int out_len_big;
-      unsigned char *tmp_array_big;
-      smoke_turbulence_get_res(fds->wt, res_big_array);
-      res_big = res_big_array[0] * res_big_array[1] * res_big_array[2];
-      out_len_big = sizeof(float) * (unsigned int)res_big;
-
-      tmp_array_big = MEM_callocN(out_len_big, "Smoke old cache tmp");
-
-      smoke_turbulence_export(
-          fds->wt, &dens, NULL, NULL, NULL, NULL, NULL, NULL, &tcu, &tcv, &tcw);
-
-      ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len_big);
-      ptcache_file_compressed_read(pf, (unsigned char *)tmp_array_big, out_len_big);
-
-      ptcache_file_compressed_read(pf, (unsigned char *)tcu, out_len);
-      ptcache_file_compressed_read(pf, (unsigned char *)tcv, out_len);
-      ptcache_file_compressed_read(pf, (unsigned char *)tcw, out_len);
-
-      MEM_freeN(tmp_array_big);
-    }
-  }
-
-  return 1;
-}
-
-static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
-{
-  FluidModifierData *fmd = (FluidModifierData *)smoke_v;
-  FluidDomainSettings *fds = fmd->domain;
-  char version[4];
-  int ch_res[3];
-  float ch_dx;
-  int fluid_fields = BKE_fluid_get_data_flags(fds);
-  int cache_fields = 0;
-  int active_fields = 0;
-  int reallocate = 0;
-
-  /* version header */
-  ptcache_file_read(pf, version, 4, sizeof(char));
-  if (!STREQLEN(version, SMOKE_CACHE_VERSION, 4)) {
-    /* reset file pointer */
-    fseek(pf->

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list