Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pointcache.c
| Show First 20 Lines • Show All 602 Lines • ▼ Show 20 Lines | if (sds->fluid) { | ||||
| //int mode = res >= 1000000 ? 2 : 1; | //int mode = res >= 1000000 ? 2 : 1; | ||||
| int mode=1; // light | int mode=1; // light | ||||
| if (sds->cache_comp == SM_CACHE_HEAVY) mode=2; // heavy | if (sds->cache_comp == SM_CACHE_HEAVY) mode=2; // heavy | ||||
| smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); | smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, in_len, out, mode); | ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, in_len, out, mode); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len, out, mode); | ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len, out, mode); | ||||
| if (fluid_fields & SM_ACTIVE_HEAT) { | 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 *)heat, in_len, out, mode); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode); | ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_FIRE) { | 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 *)flame, in_len, out, mode); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)fuel, 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); | ptcache_file_compressed_write(pf, (unsigned char *)react, in_len, out, mode); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_COLORS) { | 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 *)r, in_len, out, mode); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)g, 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 *)b, in_len, out, mode); | ||||
| } | } | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)vx, 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 *)vy, in_len, out, mode); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)vz, 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_compressed_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode); | ||||
| Show All 32 Lines | if (sds->wt) { | ||||
| if (sds->cache_high_comp == SM_CACHE_HEAVY) mode=2; // heavy | if (sds->cache_high_comp == SM_CACHE_HEAVY) mode=2; // heavy | ||||
| in_len_big = sizeof(float) * (unsigned int)res_big; | in_len_big = sizeof(float) * (unsigned int)res_big; | ||||
| smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); | smoke_turbulence_export(sds->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"); | 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); | ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len_big, out, mode); | ||||
| if (fluid_fields & SM_ACTIVE_FIRE) { | 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 *)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 *)fuel, in_len_big, out, mode); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)react, in_len_big, out, mode); | ptcache_file_compressed_write(pf, (unsigned char *)react, in_len_big, out, mode); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_COLORS) { | 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 *)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 *)g, in_len_big, out, mode); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)b, in_len_big, out, mode); | ptcache_file_compressed_write(pf, (unsigned char *)b, in_len_big, out, mode); | ||||
| } | } | ||||
| MEM_freeN(out); | MEM_freeN(out); | ||||
| out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer"); | 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 *)tcu, in_len, out, mode); | ||||
| Show All 28 Lines | if (sds->fluid) { | ||||
| sds->active_color[2] = 0.7f; | sds->active_color[2] = 0.7f; | ||||
| smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, NULL, &heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles); | smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, NULL, &heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len); | ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len); | ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len); | ||||
| if (fluid_fields & SM_ACTIVE_HEAT) | if (fluid_fields & FLUID_DOMAIN_ACTIVE_HEAT) | ||||
| { | { | ||||
| ptcache_file_compressed_read(pf, (unsigned char*)heat, out_len); | ptcache_file_compressed_read(pf, (unsigned char*)heat, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char*)heatold, out_len); | ptcache_file_compressed_read(pf, (unsigned char*)heatold, out_len); | ||||
| } | } | ||||
| else | 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*)tmp_array, out_len); | ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len); | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) | ||||
| ptcache_file_read(pf, &ch_res, 3, sizeof(int)); | ptcache_file_read(pf, &ch_res, 3, sizeof(int)); | ||||
| ptcache_file_read(pf, &ch_dx, 1, sizeof(float)); | ptcache_file_read(pf, &ch_dx, 1, sizeof(float)); | ||||
| /* check if resolution has changed */ | /* check if resolution has changed */ | ||||
| if (sds->res[0] != ch_res[0] || | if (sds->res[0] != ch_res[0] || | ||||
| sds->res[1] != ch_res[1] || | sds->res[1] != ch_res[1] || | ||||
| sds->res[2] != ch_res[2]) | sds->res[2] != ch_res[2]) | ||||
| { | { | ||||
| if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) | if (sds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) | ||||
| reallocate = 1; | reallocate = 1; | ||||
| else | else | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* check if active fields have changed */ | /* check if active fields have changed */ | ||||
| if (fluid_fields != cache_fields || | if (fluid_fields != cache_fields || | ||||
| active_fields != sds->active_fields) | active_fields != sds->active_fields) | ||||
| reallocate = 1; | reallocate = 1; | ||||
| /* reallocate fluid if needed*/ | /* reallocate fluid if needed*/ | ||||
| if (reallocate) { | if (reallocate) { | ||||
| sds->active_fields = active_fields | cache_fields; | sds->active_fields = active_fields | cache_fields; | ||||
| smoke_reallocate_fluid(sds, ch_dx, ch_res, 1); | smoke_reallocate_fluid(sds, ch_res, 1); | ||||
| sds->dx = ch_dx; | sds->dx = ch_dx; | ||||
| VECCOPY(sds->res, ch_res); | VECCOPY(sds->res, ch_res); | ||||
| sds->total_cells = ch_res[0]*ch_res[1]*ch_res[2]; | sds->total_cells = ch_res[0]*ch_res[1]*ch_res[2]; | ||||
| if (sds->flags & MOD_SMOKE_HIGHRES) { | if (sds->flags & FLUID_DOMAIN_USE_NOISE) { | ||||
| smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1); | smoke_reallocate_highres_fluid(sds, ch_res); | ||||
| } | } | ||||
| } | } | ||||
| if (sds->fluid) { | if (sds->fluid) { | ||||
| size_t res = sds->res[0]*sds->res[1]*sds->res[2]; | size_t res = sds->res[0]*sds->res[1]*sds->res[2]; | ||||
| float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b; | float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b; | ||||
| unsigned char *obstacles; | unsigned char *obstacles; | ||||
| unsigned int out_len = (unsigned int)res * sizeof(float); | unsigned int out_len = (unsigned int)res * sizeof(float); | ||||
| smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); | smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len); | ||||
| if (cache_fields & SM_ACTIVE_HEAT) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_HEAT) { | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)heat, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)heat, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)heatold, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)heatold, out_len); | ||||
| } | } | ||||
| if (cache_fields & SM_ACTIVE_FIRE) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_FIRE) { | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)react, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)react, out_len); | ||||
| } | } | ||||
| if (cache_fields & SM_ACTIVE_COLORS) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)r, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)r, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)g, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)g, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)b, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)b, out_len); | ||||
| } | } | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)vx, 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 *)vy, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)vz, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)vz, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res); | ptcache_file_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res); | ||||
| Show All 20 Lines | if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) { | ||||
| smoke_turbulence_get_res(sds->wt, res_big_array); | smoke_turbulence_get_res(sds->wt, res_big_array); | ||||
| res_big = res_big_array[0]*res_big_array[1]*res_big_array[2]; | res_big = res_big_array[0]*res_big_array[1]*res_big_array[2]; | ||||
| out_len_big = sizeof(float) * (unsigned int)res_big; | out_len_big = sizeof(float) * (unsigned int)res_big; | ||||
| smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); | smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len_big); | ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len_big); | ||||
| if (cache_fields & SM_ACTIVE_FIRE) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_FIRE) { | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len_big); | ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len_big); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len_big); | ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len_big); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)react, out_len_big); | ptcache_file_compressed_read(pf, (unsigned char *)react, out_len_big); | ||||
| } | } | ||||
| if (cache_fields & SM_ACTIVE_COLORS) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)r, out_len_big); | ptcache_file_compressed_read(pf, (unsigned char *)r, out_len_big); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)g, out_len_big); | ptcache_file_compressed_read(pf, (unsigned char *)g, out_len_big); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)b, out_len_big); | ptcache_file_compressed_read(pf, (unsigned char *)b, out_len_big); | ||||
| } | } | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)tcu, out_len); | 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 *)tcv, out_len); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)tcw, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)tcw, out_len); | ||||
| Show All 16 Lines | |||||
| * the min position of the domain's bounding box. | * the min position of the domain's bounding box. | ||||
| */ | */ | ||||
| static void compute_fluid_matrices(SmokeDomainSettings *sds) | static void compute_fluid_matrices(SmokeDomainSettings *sds) | ||||
| { | { | ||||
| float bbox_min[3]; | float bbox_min[3]; | ||||
| copy_v3_v3(bbox_min, sds->p0); | copy_v3_v3(bbox_min, sds->p0); | ||||
| if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) { | if (sds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) { | ||||
| bbox_min[0] += (sds->cell_size[0] * (float)sds->res_min[0]); | bbox_min[0] += (sds->cell_size[0] * (float)sds->res_min[0]); | ||||
| bbox_min[1] += (sds->cell_size[1] * (float)sds->res_min[1]); | bbox_min[1] += (sds->cell_size[1] * (float)sds->res_min[1]); | ||||
| bbox_min[2] += (sds->cell_size[2] * (float)sds->res_min[2]); | bbox_min[2] += (sds->cell_size[2] * (float)sds->res_min[2]); | ||||
| add_v3_v3(bbox_min, sds->obj_shift_f); | add_v3_v3(bbox_min, sds->obj_shift_f); | ||||
| } | } | ||||
| /* construct low res matrix */ | /* construct low res matrix */ | ||||
| size_to_mat4(sds->fluidmat, sds->cell_size); | size_to_mat4(sds->fluidmat, sds->cell_size); | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if (sds->wt) { | ||||
| struct OpenVDBFloatGrid *wt_density_grid; | struct OpenVDBFloatGrid *wt_density_grid; | ||||
| float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b; | float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b; | ||||
| smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); | smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); | ||||
| wt_density_grid = OpenVDB_export_grid_fl(writer, "density", dens, sds->res_wt, sds->fluidmat_wt, sds->clipping, NULL); | wt_density_grid = OpenVDB_export_grid_fl(writer, "density", dens, sds->res_wt, sds->fluidmat_wt, sds->clipping, NULL); | ||||
| clip_grid = wt_density_grid; | clip_grid = wt_density_grid; | ||||
| if (fluid_fields & SM_ACTIVE_FIRE) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_FIRE) { | ||||
| OpenVDB_export_grid_fl(writer, "flame", flame, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | OpenVDB_export_grid_fl(writer, "flame", flame, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | ||||
| OpenVDB_export_grid_fl(writer, "fuel", fuel, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | OpenVDB_export_grid_fl(writer, "fuel", fuel, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | ||||
| OpenVDB_export_grid_fl(writer, "react", react, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | OpenVDB_export_grid_fl(writer, "react", react, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_COLORS) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| OpenVDB_export_grid_vec(writer, "color", r, g, b, sds->res_wt, sds->fluidmat_wt, VEC_INVARIANT, true, sds->clipping, wt_density_grid); | OpenVDB_export_grid_vec(writer, "color", r, g, b, sds->res_wt, sds->fluidmat_wt, VEC_INVARIANT, true, sds->clipping, wt_density_grid); | ||||
| } | } | ||||
| OpenVDB_export_grid_vec(writer, "texture coordinates", tcu, tcv, tcw, sds->res, sds->fluidmat, VEC_INVARIANT, false, sds->clipping, wt_density_grid); | OpenVDB_export_grid_vec(writer, "texture coordinates", tcu, tcv, tcw, sds->res, sds->fluidmat, VEC_INVARIANT, false, sds->clipping, wt_density_grid); | ||||
| } | } | ||||
| if (sds->fluid) { | if (sds->fluid) { | ||||
| struct OpenVDBFloatGrid *density_grid; | struct OpenVDBFloatGrid *density_grid; | ||||
| float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b; | float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b; | ||||
| unsigned char *obstacles; | unsigned char *obstacles; | ||||
| smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, | smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, | ||||
| &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); | &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); | ||||
| OpenVDBWriter_add_meta_fl(writer, "blender/smoke/dx", dx); | OpenVDBWriter_add_meta_fl(writer, "blender/smoke/dx", dx); | ||||
| OpenVDBWriter_add_meta_fl(writer, "blender/smoke/dt", dt); | OpenVDBWriter_add_meta_fl(writer, "blender/smoke/dt", dt); | ||||
| const char *name = (!sds->wt) ? "density" : "density_low"; | const char *name = (!sds->wt) ? "density" : "density_low"; | ||||
| density_grid = OpenVDB_export_grid_fl(writer, name, dens, sds->res, sds->fluidmat, sds->clipping, NULL); | density_grid = OpenVDB_export_grid_fl(writer, name, dens, sds->res, sds->fluidmat, sds->clipping, NULL); | ||||
| clip_grid = sds->wt ? clip_grid : density_grid; | clip_grid = sds->wt ? clip_grid : density_grid; | ||||
| OpenVDB_export_grid_fl(writer, "shadow", sds->shadow, sds->res, sds->fluidmat, sds->clipping, NULL); | OpenVDB_export_grid_fl(writer, "shadow", sds->shadow, sds->res, sds->fluidmat, sds->clipping, NULL); | ||||
| if (fluid_fields & SM_ACTIVE_HEAT) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_HEAT) { | ||||
| OpenVDB_export_grid_fl(writer, "heat", heat, sds->res, sds->fluidmat, sds->clipping, clip_grid); | OpenVDB_export_grid_fl(writer, "heat", heat, sds->res, sds->fluidmat, sds->clipping, clip_grid); | ||||
| OpenVDB_export_grid_fl(writer, "heat_old", heatold, sds->res, sds->fluidmat, sds->clipping, clip_grid); | OpenVDB_export_grid_fl(writer, "heat_old", heatold, sds->res, sds->fluidmat, sds->clipping, clip_grid); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_FIRE) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_FIRE) { | ||||
| name = (!sds->wt) ? "flame" : "flame_low"; | name = (!sds->wt) ? "flame" : "flame_low"; | ||||
| OpenVDB_export_grid_fl(writer, name, flame, sds->res, sds->fluidmat, sds->clipping, density_grid); | OpenVDB_export_grid_fl(writer, name, flame, sds->res, sds->fluidmat, sds->clipping, density_grid); | ||||
| name = (!sds->wt) ? "fuel" : "fuel_low"; | name = (!sds->wt) ? "fuel" : "fuel_low"; | ||||
| OpenVDB_export_grid_fl(writer, name, fuel, sds->res, sds->fluidmat, sds->clipping, density_grid); | OpenVDB_export_grid_fl(writer, name, fuel, sds->res, sds->fluidmat, sds->clipping, density_grid); | ||||
| name = (!sds->wt) ? "react" : "react_low"; | name = (!sds->wt) ? "react" : "react_low"; | ||||
| OpenVDB_export_grid_fl(writer, name, react, sds->res, sds->fluidmat, sds->clipping, density_grid); | OpenVDB_export_grid_fl(writer, name, react, sds->res, sds->fluidmat, sds->clipping, density_grid); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_COLORS) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| name = (!sds->wt) ? "color" : "color_low"; | name = (!sds->wt) ? "color" : "color_low"; | ||||
| OpenVDB_export_grid_vec(writer, name, r, g, b, sds->res, sds->fluidmat, VEC_INVARIANT, true, sds->clipping, density_grid); | OpenVDB_export_grid_vec(writer, name, r, g, b, sds->res, sds->fluidmat, VEC_INVARIANT, true, sds->clipping, density_grid); | ||||
| } | } | ||||
| OpenVDB_export_grid_vec(writer, "velocity", vx, vy, vz, sds->res, sds->fluidmat, VEC_CONTRAVARIANT_RELATIVE, false, sds->clipping, clip_grid); | OpenVDB_export_grid_vec(writer, "velocity", vx, vy, vz, sds->res, sds->fluidmat, VEC_CONTRAVARIANT_RELATIVE, false, sds->clipping, clip_grid); | ||||
| OpenVDB_export_grid_ch(writer, "obstacles", obstacles, sds->res, sds->fluidmat, sds->clipping, NULL); | OpenVDB_export_grid_ch(writer, "obstacles", obstacles, sds->res, sds->fluidmat, sds->clipping, NULL); | ||||
| } | } | ||||
| Show All 31 Lines | static int ptcache_smoke_openvdb_read(struct OpenVDBReader *reader, void *smoke_v) | ||||
| OpenVDBReader_get_meta_fl(reader, "blender/smoke/dx", &cache_dx); | OpenVDBReader_get_meta_fl(reader, "blender/smoke/dx", &cache_dx); | ||||
| OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/resolution", cache_res); | OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/resolution", cache_res); | ||||
| /* check if resolution has changed */ | /* check if resolution has changed */ | ||||
| if (sds->res[0] != cache_res[0] || | if (sds->res[0] != cache_res[0] || | ||||
| sds->res[1] != cache_res[1] || | sds->res[1] != cache_res[1] || | ||||
| sds->res[2] != cache_res[2]) | sds->res[2] != cache_res[2]) | ||||
| { | { | ||||
| if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) { | if (sds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) { | ||||
| reallocate = true; | reallocate = true; | ||||
| } | } | ||||
| else { | else { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| /* check if active fields have changed */ | /* check if active fields have changed */ | ||||
| if ((fluid_fields != cache_fields) || (active_fields != sds->active_fields)) { | if ((fluid_fields != cache_fields) || (active_fields != sds->active_fields)) { | ||||
| reallocate = true; | reallocate = true; | ||||
| } | } | ||||
| /* reallocate fluid if needed*/ | /* reallocate fluid if needed*/ | ||||
| if (reallocate) { | if (reallocate) { | ||||
| sds->active_fields = active_fields | cache_fields; | sds->active_fields = active_fields | cache_fields; | ||||
| smoke_reallocate_fluid(sds, cache_dx, cache_res, 1); | smoke_reallocate_fluid(sds, cache_dx, cache_res, 1); | ||||
| sds->dx = cache_dx; | sds->dx = cache_dx; | ||||
| copy_v3_v3_int(sds->res, cache_res); | copy_v3_v3_int(sds->res, cache_res); | ||||
| sds->total_cells = cache_res[0] * cache_res[1] * cache_res[2]; | sds->total_cells = cache_res[0] * cache_res[1] * cache_res[2]; | ||||
| if (sds->flags & MOD_SMOKE_HIGHRES) { | if (sds->flags & FLUID_DOMAIN_USE_NOISE) { | ||||
| smoke_reallocate_highres_fluid(sds, cache_dx, cache_res, 1); | smoke_reallocate_highres_fluid(sds, cache_res, 1); | ||||
| } | } | ||||
| } | } | ||||
| if (sds->fluid) { | if (sds->fluid) { | ||||
| float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b; | float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b; | ||||
| unsigned char *obstacles; | unsigned char *obstacles; | ||||
| smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, | smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, | ||||
| &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); | &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); | ||||
| OpenVDBReader_get_meta_fl(reader, "blender/smoke/dt", &dt); | OpenVDBReader_get_meta_fl(reader, "blender/smoke/dt", &dt); | ||||
| OpenVDB_import_grid_fl(reader, "shadow", &sds->shadow, sds->res); | OpenVDB_import_grid_fl(reader, "shadow", &sds->shadow, sds->res); | ||||
| const char *name = (!sds->wt) ? "density" : "density_low"; | const char *name = (!sds->wt) ? "density" : "density_low"; | ||||
| OpenVDB_import_grid_fl(reader, name, &dens, sds->res); | OpenVDB_import_grid_fl(reader, name, &dens, sds->res); | ||||
| if (cache_fields & SM_ACTIVE_HEAT) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_HEAT) { | ||||
| OpenVDB_import_grid_fl(reader, "heat", &heat, sds->res); | OpenVDB_import_grid_fl(reader, "heat", &heat, sds->res); | ||||
| OpenVDB_import_grid_fl(reader, "heat_old", &heatold, sds->res); | OpenVDB_import_grid_fl(reader, "heat_old", &heatold, sds->res); | ||||
| } | } | ||||
| if (cache_fields & SM_ACTIVE_FIRE) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_FIRE) { | ||||
| name = (!sds->wt) ? "flame" : "flame_low"; | name = (!sds->wt) ? "flame" : "flame_low"; | ||||
| OpenVDB_import_grid_fl(reader, name, &flame, sds->res); | OpenVDB_import_grid_fl(reader, name, &flame, sds->res); | ||||
| name = (!sds->wt) ? "fuel" : "fuel_low"; | name = (!sds->wt) ? "fuel" : "fuel_low"; | ||||
| OpenVDB_import_grid_fl(reader, name, &fuel, sds->res); | OpenVDB_import_grid_fl(reader, name, &fuel, sds->res); | ||||
| name = (!sds->wt) ? "react" : "react_low"; | name = (!sds->wt) ? "react" : "react_low"; | ||||
| OpenVDB_import_grid_fl(reader, name, &react, sds->res); | OpenVDB_import_grid_fl(reader, name, &react, sds->res); | ||||
| } | } | ||||
| if (cache_fields & SM_ACTIVE_COLORS) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| name = (!sds->wt) ? "color" : "color_low"; | name = (!sds->wt) ? "color" : "color_low"; | ||||
| OpenVDB_import_grid_vec(reader, name, &r, &g, &b, sds->res); | OpenVDB_import_grid_vec(reader, name, &r, &g, &b, sds->res); | ||||
| } | } | ||||
| OpenVDB_import_grid_vec(reader, "velocity", &vx, &vy, &vz, sds->res); | OpenVDB_import_grid_vec(reader, "velocity", &vx, &vy, &vz, sds->res); | ||||
| OpenVDB_import_grid_ch(reader, "obstacles", &obstacles, sds->res); | OpenVDB_import_grid_ch(reader, "obstacles", &obstacles, sds->res); | ||||
| } | } | ||||
| if (sds->wt) { | if (sds->wt) { | ||||
| float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b; | float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b; | ||||
| smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); | smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); | ||||
| OpenVDB_import_grid_fl(reader, "density", &dens, sds->res_wt); | OpenVDB_import_grid_fl(reader, "density", &dens, sds->res_wt); | ||||
| if (cache_fields & SM_ACTIVE_FIRE) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_FIRE) { | ||||
| OpenVDB_import_grid_fl(reader, "flame", &flame, sds->res_wt); | OpenVDB_import_grid_fl(reader, "flame", &flame, sds->res_wt); | ||||
| OpenVDB_import_grid_fl(reader, "fuel", &fuel, sds->res_wt); | OpenVDB_import_grid_fl(reader, "fuel", &fuel, sds->res_wt); | ||||
| OpenVDB_import_grid_fl(reader, "react", &react, sds->res_wt); | OpenVDB_import_grid_fl(reader, "react", &react, sds->res_wt); | ||||
| } | } | ||||
| if (cache_fields & SM_ACTIVE_COLORS) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| OpenVDB_import_grid_vec(reader, "color", &r, &g, &b, sds->res_wt); | OpenVDB_import_grid_vec(reader, "color", &r, &g, &b, sds->res_wt); | ||||
| } | } | ||||
| OpenVDB_import_grid_vec(reader, "texture coordinates", &tcu, &tcv, &tcw, sds->res); | OpenVDB_import_grid_vec(reader, "texture coordinates", &tcu, &tcv, &tcw, sds->res); | ||||
| } | } | ||||
| OpenVDBReader_free(reader); | OpenVDBReader_free(reader); | ||||
| ▲ Show 20 Lines • Show All 396 Lines • ▼ Show 20 Lines | void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) | ||||
| pid->write_header = ptcache_basic_header_write; | pid->write_header = ptcache_basic_header_write; | ||||
| pid->read_header = ptcache_basic_header_read; | pid->read_header = ptcache_basic_header_read; | ||||
| pid->data_types= 0; | pid->data_types= 0; | ||||
| pid->info_types= 0; | pid->info_types= 0; | ||||
| if (sds->fluid) | if (sds->fluid) | ||||
| pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW); | pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW); | ||||
| if (sds->wt) | // (sebbas): Option deprecated in manta cache | ||||
| pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH); | // if (sds->wt) | ||||
| // pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH); | |||||
mont29: Juts remove it then (also same below). | |||||
| pid->default_step = 1; | pid->default_step = 1; | ||||
| pid->max_step = 1; | pid->max_step = 1; | ||||
| pid->file_type = smd->domain->cache_file_format; | |||||
| // (sebbas): Option deprecated in manta cache | |||||
| // pid->file_type = smd->domain->cache_file_format; | |||||
| } | } | ||||
| void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSurface *surface) | void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSurface *surface) | ||||
| { | { | ||||
| memset(pid, 0, sizeof(PTCacheID)); | memset(pid, 0, sizeof(PTCacheID)); | ||||
| pid->ob= ob; | pid->ob= ob; | ||||
| ▲ Show 20 Lines • Show All 2,527 Lines • Show Last 20 Lines | |||||
Juts remove it then (also same below).