Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pointcache.c
| Show All 34 Lines | |||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_dynamicpaint_types.h" | #include "DNA_dynamicpaint_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_object_force_types.h" | #include "DNA_object_force_types.h" | ||||
| #include "DNA_particle_types.h" | #include "DNA_particle_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_smoke_types.h" | #include "DNA_manta_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "PIL_time.h" | #include "PIL_time.h" | ||||
| #include "BKE_appdir.h" | #include "BKE_appdir.h" | ||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_cloth.h" | #include "BKE_cloth.h" | ||||
| #include "BKE_collection.h" | #include "BKE_collection.h" | ||||
| #include "BKE_dynamicpaint.h" | #include "BKE_dynamicpaint.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_smoke.h" | #include "BKE_manta.h" | ||||
| #include "BKE_softbody.h" | #include "BKE_softbody.h" | ||||
| #include "BIK_api.h" | #include "BIK_api.h" | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| # include "RBI_api.h" | # include "RBI_api.h" | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 510 Lines • ▼ Show 20 Lines | static void ptcache_cloth_error(void *cloth_v, const char *message) | ||||
| ClothModifierData *clmd = cloth_v; | ClothModifierData *clmd = cloth_v; | ||||
| modifier_setError(&clmd->modifier, "%s", message); | modifier_setError(&clmd->modifier, "%s", message); | ||||
| } | } | ||||
| #ifdef WITH_SMOKE | #ifdef WITH_SMOKE | ||||
| /* Smoke functions */ | /* Smoke functions */ | ||||
| static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra)) | static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra)) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)smoke_v; | FluidModifierData *mmd = (FluidModifierData *)smoke_v; | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| if (sds->fluid) { | if (mds->fluid) { | ||||
| return sds->base_res[0] * sds->base_res[1] * sds->base_res[2]; | return mds->base_res[0] * mds->base_res[1] * mds->base_res[2]; | ||||
| } | } | ||||
| else { | else { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| static void ptcache_smoke_error(void *smoke_v, const char *message) | static void ptcache_smoke_error(void *smoke_v, const char *message) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)smoke_v; | FluidModifierData *mmd = (FluidModifierData *)smoke_v; | ||||
| modifier_setError(&smd->modifier, "%s", message); | modifier_setError(&mmd->modifier, "%s", message); | ||||
| } | } | ||||
| # define SMOKE_CACHE_VERSION "1.04" | # define SMOKE_CACHE_VERSION "1.04" | ||||
| static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) | static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)smoke_v; | FluidModifierData *mmd = (FluidModifierData *)smoke_v; | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| int ret = 0; | int ret = 0; | ||||
| int fluid_fields = BKE_smoke_get_data_flags(sds); | int fluid_fields = BKE_manta_get_data_flags(mds); | ||||
| /* version header */ | /* version header */ | ||||
| ptcache_file_write(pf, SMOKE_CACHE_VERSION, 4, sizeof(char)); | ptcache_file_write(pf, SMOKE_CACHE_VERSION, 4, sizeof(char)); | ||||
| ptcache_file_write(pf, &fluid_fields, 1, sizeof(int)); | ptcache_file_write(pf, &fluid_fields, 1, sizeof(int)); | ||||
| ptcache_file_write(pf, &sds->active_fields, 1, sizeof(int)); | ptcache_file_write(pf, &mds->active_fields, 1, sizeof(int)); | ||||
| ptcache_file_write(pf, &sds->res, 3, sizeof(int)); | ptcache_file_write(pf, &mds->res, 3, sizeof(int)); | ||||
| ptcache_file_write(pf, &sds->dx, 1, sizeof(float)); | ptcache_file_write(pf, &mds->dx, 1, sizeof(float)); | ||||
| if (sds->fluid) { | if (mds->fluid) { | ||||
| size_t res = sds->res[0] * sds->res[1] * sds->res[2]; | size_t res = mds->res[0] * mds->res[1] * mds->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 in_len = sizeof(float) * (unsigned int)res; | unsigned int in_len = sizeof(float) * (unsigned int)res; | ||||
| unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, | unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, | ||||
| "pointcache_lzo_buffer"); | "pointcache_lzo_buffer"); | ||||
| // 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) { | if (mds->cache_comp == SM_CACHE_HEAVY) { | ||||
| mode = 2; // heavy | mode = 2; // heavy | ||||
| } | } | ||||
| smoke_export(sds->fluid, | smoke_export(mds->fluid, | ||||
| &dt, | &dt, | ||||
| &dx, | &dx, | ||||
| &dens, | &dens, | ||||
| &react, | &react, | ||||
| &flame, | &flame, | ||||
| &fuel, | &fuel, | ||||
| &heat, | &heat, | ||||
| &heatold, | &heatold, | ||||
| &vx, | &vx, | ||||
| &vy, | &vy, | ||||
| &vz, | &vz, | ||||
| &r, | &r, | ||||
| &g, | &g, | ||||
| &b, | &b, | ||||
| &obstacles); | &obstacles, | ||||
| NULL); | |||||
| ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, in_len, out, mode); | ptcache_file_compressed_write(pf, (unsigned char *)mds->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); | ||||
| ptcache_file_write(pf, &dt, 1, sizeof(float)); | ptcache_file_write(pf, &dt, 1, sizeof(float)); | ||||
| ptcache_file_write(pf, &dx, 1, sizeof(float)); | ptcache_file_write(pf, &dx, 1, sizeof(float)); | ||||
| ptcache_file_write(pf, &sds->p0, 3, sizeof(float)); | ptcache_file_write(pf, &mds->p0, 3, sizeof(float)); | ||||
| ptcache_file_write(pf, &sds->p1, 3, sizeof(float)); | ptcache_file_write(pf, &mds->p1, 3, sizeof(float)); | ||||
| ptcache_file_write(pf, &sds->dp0, 3, sizeof(float)); | ptcache_file_write(pf, &mds->dp0, 3, sizeof(float)); | ||||
| ptcache_file_write(pf, &sds->shift, 3, sizeof(int)); | ptcache_file_write(pf, &mds->shift, 3, sizeof(int)); | ||||
| ptcache_file_write(pf, &sds->obj_shift_f, 3, sizeof(float)); | ptcache_file_write(pf, &mds->obj_shift_f, 3, sizeof(float)); | ||||
| ptcache_file_write(pf, &sds->obmat, 16, sizeof(float)); | ptcache_file_write(pf, &mds->obmat, 16, sizeof(float)); | ||||
| ptcache_file_write(pf, &sds->base_res, 3, sizeof(int)); | ptcache_file_write(pf, &mds->base_res, 3, sizeof(int)); | ||||
| ptcache_file_write(pf, &sds->res_min, 3, sizeof(int)); | ptcache_file_write(pf, &mds->res_min, 3, sizeof(int)); | ||||
| ptcache_file_write(pf, &sds->res_max, 3, sizeof(int)); | ptcache_file_write(pf, &mds->res_max, 3, sizeof(int)); | ||||
| ptcache_file_write(pf, &sds->active_color, 3, sizeof(float)); | ptcache_file_write(pf, &mds->active_color, 3, sizeof(float)); | ||||
| MEM_freeN(out); | MEM_freeN(out); | ||||
| ret = 1; | ret = 1; | ||||
| } | } | ||||
| if (sds->wt) { | if (mds->wt) { | ||||
| int res_big_array[3]; | int res_big_array[3]; | ||||
| int res_big; | int res_big; | ||||
| int res = sds->res[0] * sds->res[1] * sds->res[2]; | int res = mds->res[0] * mds->res[1] * mds->res[2]; | ||||
| float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b; | float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b; | ||||
| unsigned int in_len = sizeof(float) * (unsigned int)res; | unsigned int in_len = sizeof(float) * (unsigned int)res; | ||||
| unsigned int in_len_big; | unsigned int in_len_big; | ||||
| unsigned char *out; | unsigned char *out; | ||||
| int mode; | int mode; | ||||
| smoke_turbulence_get_res(sds->wt, res_big_array); | smoke_turbulence_get_res(mds->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]; | ||||
| // mode = res_big >= 1000000 ? 2 : 1; | // mode = res_big >= 1000000 ? 2 : 1; | ||||
| mode = 1; // light | mode = 1; // light | ||||
| if (sds->cache_high_comp == SM_CACHE_HEAVY) { | if (mds->cache_high_comp == SM_CACHE_HEAVY) { | ||||
| mode = 2; // 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(mds->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); | ||||
| ptcache_file_compressed_write(pf, (unsigned char *)tcv, 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); | ptcache_file_compressed_write(pf, (unsigned char *)tcw, in_len, out, mode); | ||||
| MEM_freeN(out); | MEM_freeN(out); | ||||
| ret = 1; | ret = 1; | ||||
| } | } | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| /* read old smoke cache from 2.64 */ | /* read old smoke cache from 2.64 */ | ||||
| static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v) | static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)smoke_v; | FluidModifierData *mmd = (FluidModifierData *)smoke_v; | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| if (sds->fluid) { | if (mds->fluid) { | ||||
| const size_t res = sds->res[0] * sds->res[1] * sds->res[2]; | const size_t res = mds->res[0] * mds->res[1] * mds->res[2]; | ||||
| const unsigned int out_len = (unsigned int)res * sizeof(float); | const unsigned int out_len = (unsigned int)res * sizeof(float); | ||||
| float dt, dx, *dens, *heat, *heatold, *vx, *vy, *vz; | float dt, dx, *dens, *heat, *heatold, *vx, *vy, *vz; | ||||
| unsigned char *obstacles; | unsigned char *obstacles; | ||||
| float *tmp_array = MEM_callocN(out_len, "Smoke old cache tmp"); | float *tmp_array = MEM_callocN(out_len, "Smoke old cache tmp"); | ||||
| int fluid_fields = BKE_smoke_get_data_flags(sds); | int fluid_fields = BKE_manta_get_data_flags(mds); | ||||
| /* Part part of the new cache header */ | /* Part part of the new cache header */ | ||||
| sds->active_color[0] = 0.7f; | mds->active_color[0] = 0.7f; | ||||
| sds->active_color[1] = 0.7f; | mds->active_color[1] = 0.7f; | ||||
| sds->active_color[2] = 0.7f; | mds->active_color[2] = 0.7f; | ||||
| smoke_export(sds->fluid, | smoke_export(mds->fluid, | ||||
| &dt, | &dt, | ||||
| &dx, | &dx, | ||||
| &dens, | &dens, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| &heat, | &heat, | ||||
| &heatold, | &heatold, | ||||
| &vx, | &vx, | ||||
| &vy, | &vy, | ||||
| &vz, | &vz, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| &obstacles); | &obstacles, | ||||
| NULL); | |||||
| ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)mds->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); | ||||
| } | } | ||||
| 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 *)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); | ||||
| 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_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res); | ||||
| ptcache_file_read(pf, &dt, 1, sizeof(float)); | ptcache_file_read(pf, &dt, 1, sizeof(float)); | ||||
| ptcache_file_read(pf, &dx, 1, sizeof(float)); | ptcache_file_read(pf, &dx, 1, sizeof(float)); | ||||
| MEM_freeN(tmp_array); | MEM_freeN(tmp_array); | ||||
| if (pf->data_types & (1 << BPHYS_DATA_SMOKE_HIGH) && sds->wt) { | if (pf->data_types & (1 << BPHYS_DATA_SMOKE_HIGH) && mds->wt) { | ||||
| int res_big, res_big_array[3]; | int res_big, res_big_array[3]; | ||||
| float *tcu, *tcv, *tcw; | float *tcu, *tcv, *tcw; | ||||
| unsigned int out_len_big; | unsigned int out_len_big; | ||||
| unsigned char *tmp_array_big; | unsigned char *tmp_array_big; | ||||
| smoke_turbulence_get_res(sds->wt, res_big_array); | smoke_turbulence_get_res(mds->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; | ||||
| tmp_array_big = MEM_callocN(out_len_big, "Smoke old cache tmp"); | tmp_array_big = MEM_callocN(out_len_big, "Smoke old cache tmp"); | ||||
| smoke_turbulence_export( | smoke_turbulence_export( | ||||
| sds->wt, &dens, NULL, NULL, NULL, NULL, NULL, NULL, &tcu, &tcv, &tcw); | mds->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 *)dens, out_len_big); | ||||
| ptcache_file_compressed_read(pf, (unsigned char *)tmp_array_big, 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 *)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); | ||||
| MEM_freeN(tmp_array_big); | MEM_freeN(tmp_array_big); | ||||
| } | } | ||||
| } | } | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) | static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)smoke_v; | FluidModifierData *mmd = (FluidModifierData *)smoke_v; | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| char version[4]; | char version[4]; | ||||
| int ch_res[3]; | int ch_res[3]; | ||||
| float ch_dx; | float ch_dx; | ||||
| int fluid_fields = BKE_smoke_get_data_flags(sds); | int fluid_fields = BKE_manta_get_data_flags(mds); | ||||
| int cache_fields = 0; | int cache_fields = 0; | ||||
| int active_fields = 0; | int active_fields = 0; | ||||
| int reallocate = 0; | int reallocate = 0; | ||||
| /* version header */ | /* version header */ | ||||
| ptcache_file_read(pf, version, 4, sizeof(char)); | ptcache_file_read(pf, version, 4, sizeof(char)); | ||||
| if (!STREQLEN(version, SMOKE_CACHE_VERSION, 4)) { | if (!STREQLEN(version, SMOKE_CACHE_VERSION, 4)) { | ||||
| /* reset file pointer */ | /* reset file pointer */ | ||||
| fseek(pf->fp, -4, SEEK_CUR); | fseek(pf->fp, -4, SEEK_CUR); | ||||
| return ptcache_smoke_read_old(pf, smoke_v); | return ptcache_smoke_read_old(pf, smoke_v); | ||||
| } | } | ||||
| /* fluid info */ | /* fluid info */ | ||||
| ptcache_file_read(pf, &cache_fields, 1, sizeof(int)); | ptcache_file_read(pf, &cache_fields, 1, sizeof(int)); | ||||
| ptcache_file_read(pf, &active_fields, 1, sizeof(int)); | ptcache_file_read(pf, &active_fields, 1, sizeof(int)); | ||||
| 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] || sds->res[1] != ch_res[1] || sds->res[2] != ch_res[2]) { | if (mds->res[0] != ch_res[0] || mds->res[1] != ch_res[1] || mds->res[2] != ch_res[2]) { | ||||
| if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) { | if (mds->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 || active_fields != sds->active_fields) { | if (fluid_fields != cache_fields || active_fields != mds->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; | mds->active_fields = active_fields | cache_fields; | ||||
| BKE_smoke_reallocate_fluid(sds, ch_dx, ch_res, 1); | BKE_manta_reallocate_fluid(mds, ch_res, 1); | ||||
| sds->dx = ch_dx; | mds->dx = ch_dx; | ||||
| copy_v3_v3_int(sds->res, ch_res); | copy_v3_v3_int(mds->res, ch_res); | ||||
| sds->total_cells = ch_res[0] * ch_res[1] * ch_res[2]; | mds->total_cells = ch_res[0] * ch_res[1] * ch_res[2]; | ||||
| if (sds->flags & MOD_SMOKE_HIGHRES) { | |||||
| BKE_smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1); | |||||
| } | |||||
| } | } | ||||
| if (sds->fluid) { | if (mds->fluid) { | ||||
| size_t res = sds->res[0] * sds->res[1] * sds->res[2]; | size_t res = mds->res[0] * mds->res[1] * mds->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, | smoke_export(mds->fluid, | ||||
| &dt, | &dt, | ||||
| &dx, | &dx, | ||||
| &dens, | &dens, | ||||
| &react, | &react, | ||||
| &flame, | &flame, | ||||
| &fuel, | &fuel, | ||||
| &heat, | &heat, | ||||
| &heatold, | &heatold, | ||||
| &vx, | &vx, | ||||
| &vy, | &vy, | ||||
| &vz, | &vz, | ||||
| &r, | &r, | ||||
| &g, | &g, | ||||
| &b, | &b, | ||||
| &obstacles); | &obstacles, | ||||
| NULL); | |||||
| ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); | ptcache_file_compressed_read(pf, (unsigned char *)mds->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); | ||||
| ptcache_file_read(pf, &dt, 1, sizeof(float)); | ptcache_file_read(pf, &dt, 1, sizeof(float)); | ||||
| ptcache_file_read(pf, &dx, 1, sizeof(float)); | ptcache_file_read(pf, &dx, 1, sizeof(float)); | ||||
| ptcache_file_read(pf, &sds->p0, 3, sizeof(float)); | ptcache_file_read(pf, &mds->p0, 3, sizeof(float)); | ||||
| ptcache_file_read(pf, &sds->p1, 3, sizeof(float)); | ptcache_file_read(pf, &mds->p1, 3, sizeof(float)); | ||||
| ptcache_file_read(pf, &sds->dp0, 3, sizeof(float)); | ptcache_file_read(pf, &mds->dp0, 3, sizeof(float)); | ||||
| ptcache_file_read(pf, &sds->shift, 3, sizeof(int)); | ptcache_file_read(pf, &mds->shift, 3, sizeof(int)); | ||||
| ptcache_file_read(pf, &sds->obj_shift_f, 3, sizeof(float)); | ptcache_file_read(pf, &mds->obj_shift_f, 3, sizeof(float)); | ||||
| ptcache_file_read(pf, &sds->obmat, 16, sizeof(float)); | ptcache_file_read(pf, &mds->obmat, 16, sizeof(float)); | ||||
| ptcache_file_read(pf, &sds->base_res, 3, sizeof(int)); | ptcache_file_read(pf, &mds->base_res, 3, sizeof(int)); | ||||
| ptcache_file_read(pf, &sds->res_min, 3, sizeof(int)); | ptcache_file_read(pf, &mds->res_min, 3, sizeof(int)); | ||||
| ptcache_file_read(pf, &sds->res_max, 3, sizeof(int)); | ptcache_file_read(pf, &mds->res_max, 3, sizeof(int)); | ||||
| ptcache_file_read(pf, &sds->active_color, 3, sizeof(float)); | ptcache_file_read(pf, &mds->active_color, 3, sizeof(float)); | ||||
| } | } | ||||
| if (pf->data_types & (1 << BPHYS_DATA_SMOKE_HIGH) && sds->wt) { | if (pf->data_types & (1 << BPHYS_DATA_SMOKE_HIGH) && mds->wt) { | ||||
| int res = sds->res[0] * sds->res[1] * sds->res[2]; | int res = mds->res[0] * mds->res[1] * mds->res[2]; | ||||
| int res_big, res_big_array[3]; | int res_big, res_big_array[3]; | ||||
| float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b; | float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b; | ||||
| unsigned int out_len = sizeof(float) * (unsigned int)res; | unsigned int out_len = sizeof(float) * (unsigned int)res; | ||||
| unsigned int out_len_big; | unsigned int out_len_big; | ||||
| smoke_turbulence_get_res(sds->wt, res_big_array); | smoke_turbulence_get_res(mds->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(mds->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 10 Lines | |||||
| * 0 vs 0 0 | * 0 vs 0 0 | ||||
| * 0 0 vs 0 | * 0 0 vs 0 | ||||
| * px py pz 1 | * px py pz 1 | ||||
| * </pre> | * </pre> | ||||
| * | * | ||||
| * with `vs` = voxel size, and `px, py, pz`, | * with `vs` = voxel size, and `px, py, pz`, | ||||
| * 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(FluidDomainSettings *mds) | ||||
| { | { | ||||
| float bbox_min[3]; | float bbox_min[3]; | ||||
| copy_v3_v3(bbox_min, sds->p0); | copy_v3_v3(bbox_min, mds->p0); | ||||
| if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) { | if (mds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) { | ||||
| bbox_min[0] += (sds->cell_size[0] * (float)sds->res_min[0]); | bbox_min[0] += (mds->cell_size[0] * (float)mds->res_min[0]); | ||||
| bbox_min[1] += (sds->cell_size[1] * (float)sds->res_min[1]); | bbox_min[1] += (mds->cell_size[1] * (float)mds->res_min[1]); | ||||
| bbox_min[2] += (sds->cell_size[2] * (float)sds->res_min[2]); | bbox_min[2] += (mds->cell_size[2] * (float)mds->res_min[2]); | ||||
| add_v3_v3(bbox_min, sds->obj_shift_f); | add_v3_v3(bbox_min, mds->obj_shift_f); | ||||
| } | } | ||||
| /* construct low res matrix */ | /* construct low res matrix */ | ||||
| size_to_mat4(sds->fluidmat, sds->cell_size); | size_to_mat4(mds->fluidmat, mds->cell_size); | ||||
| copy_v3_v3(sds->fluidmat[3], bbox_min); | copy_v3_v3(mds->fluidmat[3], bbox_min); | ||||
| /* The smoke simulator stores voxels cell-centered, whilst VDB is node | /* The smoke simulator stores voxels cell-centered, whilst VDB is node | ||||
| * centered, so we offset the matrix by half a voxel to compensate. */ | * centered, so we offset the matrix by half a voxel to compensate. */ | ||||
| madd_v3_v3fl(sds->fluidmat[3], sds->cell_size, 0.5f); | madd_v3_v3fl(mds->fluidmat[3], mds->cell_size, 0.5f); | ||||
| mul_m4_m4m4(sds->fluidmat, sds->obmat, sds->fluidmat); | mul_m4_m4m4(mds->fluidmat, mds->obmat, mds->fluidmat); | ||||
| if (sds->wt) { | if (mds->wt) { | ||||
| float voxel_size_high[3]; | float voxel_size_high[3]; | ||||
| /* construct high res matrix */ | /* construct high res matrix */ | ||||
| mul_v3_v3fl(voxel_size_high, sds->cell_size, 1.0f / (float)(sds->amplify + 1)); | mul_v3_v3fl(voxel_size_high, mds->cell_size, 1.0f / (float)(mds->amplify + 1)); | ||||
| size_to_mat4(sds->fluidmat_wt, voxel_size_high); | size_to_mat4(mds->fluidmat_wt, voxel_size_high); | ||||
| copy_v3_v3(sds->fluidmat_wt[3], bbox_min); | copy_v3_v3(mds->fluidmat_wt[3], bbox_min); | ||||
| /* Same here, add half a voxel to adjust the position of the fluid. */ | /* Same here, add half a voxel to adjust the position of the fluid. */ | ||||
| madd_v3_v3fl(sds->fluidmat_wt[3], voxel_size_high, 0.5f); | madd_v3_v3fl(mds->fluidmat_wt[3], voxel_size_high, 0.5f); | ||||
| mul_m4_m4m4(sds->fluidmat_wt, sds->obmat, sds->fluidmat_wt); | mul_m4_m4m4(mds->fluidmat_wt, mds->obmat, mds->fluidmat_wt); | ||||
| } | } | ||||
| } | } | ||||
| static int ptcache_smoke_openvdb_write(struct OpenVDBWriter *writer, void *smoke_v) | static int ptcache_smoke_openvdb_write(struct OpenVDBWriter *writer, void *smoke_v) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)smoke_v; | FluidModifierData *mmd = (FluidModifierData *)smoke_v; | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| OpenVDBWriter_set_flags(writer, sds->openvdb_comp, (sds->data_depth == 16)); | OpenVDBWriter_set_flags(writer, mds->openvdb_comp, (mds->data_depth == 16)); | ||||
| OpenVDBWriter_add_meta_int(writer, "blender/smoke/active_fields", sds->active_fields); | OpenVDBWriter_add_meta_int(writer, "blender/smoke/active_fields", mds->active_fields); | ||||
| OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/resolution", sds->res); | OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/resolution", mds->res); | ||||
| OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/min_resolution", sds->res_min); | OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/min_resolution", mds->res_min); | ||||
| OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/max_resolution", sds->res_max); | OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/max_resolution", mds->res_max); | ||||
| OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/base_resolution", sds->base_res); | OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/base_resolution", mds->base_res); | ||||
| OpenVDBWriter_add_meta_v3(writer, "blender/smoke/min_bbox", sds->p0); | OpenVDBWriter_add_meta_v3(writer, "blender/smoke/min_bbox", mds->p0); | ||||
| OpenVDBWriter_add_meta_v3(writer, "blender/smoke/max_bbox", sds->p1); | OpenVDBWriter_add_meta_v3(writer, "blender/smoke/max_bbox", mds->p1); | ||||
| OpenVDBWriter_add_meta_v3(writer, "blender/smoke/dp0", sds->dp0); | OpenVDBWriter_add_meta_v3(writer, "blender/smoke/dp0", mds->dp0); | ||||
| OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/shift", sds->shift); | OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/shift", mds->shift); | ||||
| OpenVDBWriter_add_meta_v3(writer, "blender/smoke/obj_shift_f", sds->obj_shift_f); | OpenVDBWriter_add_meta_v3(writer, "blender/smoke/obj_shift_f", mds->obj_shift_f); | ||||
| OpenVDBWriter_add_meta_v3(writer, "blender/smoke/active_color", sds->active_color); | OpenVDBWriter_add_meta_v3(writer, "blender/smoke/active_color", mds->active_color); | ||||
| OpenVDBWriter_add_meta_mat4(writer, "blender/smoke/obmat", sds->obmat); | OpenVDBWriter_add_meta_mat4(writer, "blender/smoke/obmat", mds->obmat); | ||||
| int fluid_fields = BKE_smoke_get_data_flags(sds); | int fluid_fields = BKE_manta_get_data_flags(mds); | ||||
| struct OpenVDBFloatGrid *clip_grid = NULL; | struct OpenVDBFloatGrid *clip_grid = NULL; | ||||
| compute_fluid_matrices(sds); | compute_fluid_matrices(mds); | ||||
| OpenVDBWriter_add_meta_int(writer, "blender/smoke/fluid_fields", fluid_fields); | OpenVDBWriter_add_meta_int(writer, "blender/smoke/fluid_fields", fluid_fields); | ||||
| if (sds->wt) { | if (mds->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(mds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); | ||||
| wt_density_grid = OpenVDB_export_grid_fl( | wt_density_grid = OpenVDB_export_grid_fl( | ||||
| writer, "density", dens, sds->res_wt, sds->fluidmat_wt, sds->clipping, NULL); | writer, "density", dens, mds->res_wt, mds->fluidmat_wt, mds->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( | OpenVDB_export_grid_fl( | ||||
| writer, "flame", flame, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | writer, "flame", flame, mds->res_wt, mds->fluidmat_wt, mds->clipping, wt_density_grid); | ||||
| OpenVDB_export_grid_fl( | OpenVDB_export_grid_fl( | ||||
| writer, "fuel", fuel, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | writer, "fuel", fuel, mds->res_wt, mds->fluidmat_wt, mds->clipping, wt_density_grid); | ||||
| OpenVDB_export_grid_fl( | OpenVDB_export_grid_fl( | ||||
| writer, "react", react, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid); | writer, "react", react, mds->res_wt, mds->fluidmat_wt, mds->clipping, wt_density_grid); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_COLORS) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| OpenVDB_export_grid_vec(writer, | OpenVDB_export_grid_vec(writer, | ||||
| "color", | "color", | ||||
| r, | r, | ||||
| g, | g, | ||||
| b, | b, | ||||
| sds->res_wt, | mds->res_wt, | ||||
| sds->fluidmat_wt, | mds->fluidmat_wt, | ||||
| VEC_INVARIANT, | VEC_INVARIANT, | ||||
| true, | true, | ||||
| sds->clipping, | mds->clipping, | ||||
| wt_density_grid); | wt_density_grid); | ||||
| } | } | ||||
| OpenVDB_export_grid_vec(writer, | OpenVDB_export_grid_vec(writer, | ||||
| "texture coordinates", | "texture coordinates", | ||||
| tcu, | tcu, | ||||
| tcv, | tcv, | ||||
| tcw, | tcw, | ||||
| sds->res, | mds->res, | ||||
| sds->fluidmat, | mds->fluidmat, | ||||
| VEC_INVARIANT, | VEC_INVARIANT, | ||||
| false, | false, | ||||
| sds->clipping, | mds->clipping, | ||||
| wt_density_grid); | wt_density_grid); | ||||
| } | } | ||||
| if (sds->fluid) { | if (mds->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, | smoke_export(mds->fluid, | ||||
| &dt, | &dt, | ||||
| &dx, | &dx, | ||||
| &dens, | &dens, | ||||
| &react, | &react, | ||||
| &flame, | &flame, | ||||
| &fuel, | &fuel, | ||||
| &heat, | &heat, | ||||
| &heatold, | &heatold, | ||||
| &vx, | &vx, | ||||
| &vy, | &vy, | ||||
| &vz, | &vz, | ||||
| &r, | &r, | ||||
| &g, | &g, | ||||
| &b, | &b, | ||||
| &obstacles); | &obstacles, | ||||
| NULL); | |||||
| 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 = (!mds->wt) ? "density" : "density_low"; | ||||
| density_grid = OpenVDB_export_grid_fl( | density_grid = OpenVDB_export_grid_fl( | ||||
| writer, name, dens, sds->res, sds->fluidmat, sds->clipping, NULL); | writer, name, dens, mds->res, mds->fluidmat, mds->clipping, NULL); | ||||
| clip_grid = sds->wt ? clip_grid : density_grid; | clip_grid = mds->wt ? clip_grid : density_grid; | ||||
| OpenVDB_export_grid_fl( | OpenVDB_export_grid_fl( | ||||
| writer, "shadow", sds->shadow, sds->res, sds->fluidmat, sds->clipping, NULL); | writer, "shadow", mds->shadow, mds->res, mds->fluidmat, mds->clipping, NULL); | ||||
| if (fluid_fields & SM_ACTIVE_HEAT) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_HEAT) { | ||||
| OpenVDB_export_grid_fl( | OpenVDB_export_grid_fl( | ||||
| writer, "heat", heat, sds->res, sds->fluidmat, sds->clipping, clip_grid); | writer, "heat", heat, mds->res, mds->fluidmat, mds->clipping, clip_grid); | ||||
| OpenVDB_export_grid_fl( | OpenVDB_export_grid_fl( | ||||
| writer, "heat_old", heatold, sds->res, sds->fluidmat, sds->clipping, clip_grid); | writer, "heat_old", heatold, mds->res, mds->fluidmat, mds->clipping, clip_grid); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_FIRE) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_FIRE) { | ||||
| name = (!sds->wt) ? "flame" : "flame_low"; | name = (!mds->wt) ? "flame" : "flame_low"; | ||||
| OpenVDB_export_grid_fl( | OpenVDB_export_grid_fl( | ||||
| writer, name, flame, sds->res, sds->fluidmat, sds->clipping, density_grid); | writer, name, flame, mds->res, mds->fluidmat, mds->clipping, density_grid); | ||||
| name = (!sds->wt) ? "fuel" : "fuel_low"; | name = (!mds->wt) ? "fuel" : "fuel_low"; | ||||
| OpenVDB_export_grid_fl( | OpenVDB_export_grid_fl( | ||||
| writer, name, fuel, sds->res, sds->fluidmat, sds->clipping, density_grid); | writer, name, fuel, mds->res, mds->fluidmat, mds->clipping, density_grid); | ||||
| name = (!sds->wt) ? "react" : "react_low"; | name = (!mds->wt) ? "react" : "react_low"; | ||||
| OpenVDB_export_grid_fl( | OpenVDB_export_grid_fl( | ||||
| writer, name, react, sds->res, sds->fluidmat, sds->clipping, density_grid); | writer, name, react, mds->res, mds->fluidmat, mds->clipping, density_grid); | ||||
| } | } | ||||
| if (fluid_fields & SM_ACTIVE_COLORS) { | if (fluid_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| name = (!sds->wt) ? "color" : "color_low"; | name = (!mds->wt) ? "color" : "color_low"; | ||||
| OpenVDB_export_grid_vec(writer, | OpenVDB_export_grid_vec(writer, | ||||
| name, | name, | ||||
| r, | r, | ||||
| g, | g, | ||||
| b, | b, | ||||
| sds->res, | mds->res, | ||||
| sds->fluidmat, | mds->fluidmat, | ||||
| VEC_INVARIANT, | VEC_INVARIANT, | ||||
| true, | true, | ||||
| sds->clipping, | mds->clipping, | ||||
| density_grid); | density_grid); | ||||
| } | } | ||||
| OpenVDB_export_grid_vec(writer, | OpenVDB_export_grid_vec(writer, | ||||
| "velocity", | "velocity", | ||||
| vx, | vx, | ||||
| vy, | vy, | ||||
| vz, | vz, | ||||
| sds->res, | mds->res, | ||||
| sds->fluidmat, | mds->fluidmat, | ||||
| VEC_CONTRAVARIANT_RELATIVE, | VEC_CONTRAVARIANT_RELATIVE, | ||||
| false, | false, | ||||
| sds->clipping, | mds->clipping, | ||||
| clip_grid); | clip_grid); | ||||
| OpenVDB_export_grid_ch( | OpenVDB_export_grid_ch( | ||||
| writer, "obstacles", obstacles, sds->res, sds->fluidmat, sds->clipping, NULL); | writer, "obstacles", obstacles, mds->res, mds->fluidmat, mds->clipping, NULL); | ||||
| } | } | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static int ptcache_smoke_openvdb_read(struct OpenVDBReader *reader, void *smoke_v) | static int ptcache_smoke_openvdb_read(struct OpenVDBReader *reader, void *smoke_v) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)smoke_v; | FluidModifierData *mmd = (FluidModifierData *)smoke_v; | ||||
| if (!smd) { | if (!mmd) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| int fluid_fields = BKE_smoke_get_data_flags(sds); | int fluid_fields = BKE_manta_get_data_flags(mds); | ||||
| int active_fields, cache_fields = 0; | int active_fields, cache_fields = 0; | ||||
| int cache_res[3]; | int cache_res[3]; | ||||
| float cache_dx; | float cache_dx; | ||||
| bool reallocate = false; | bool reallocate = false; | ||||
| OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/min_resolution", sds->res_min); | OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/min_resolution", mds->res_min); | ||||
| OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/max_resolution", sds->res_max); | OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/max_resolution", mds->res_max); | ||||
| OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/base_resolution", sds->base_res); | OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/base_resolution", mds->base_res); | ||||
| OpenVDBReader_get_meta_v3(reader, "blender/smoke/min_bbox", sds->p0); | OpenVDBReader_get_meta_v3(reader, "blender/smoke/min_bbox", mds->p0); | ||||
| OpenVDBReader_get_meta_v3(reader, "blender/smoke/max_bbox", sds->p1); | OpenVDBReader_get_meta_v3(reader, "blender/smoke/max_bbox", mds->p1); | ||||
| OpenVDBReader_get_meta_v3(reader, "blender/smoke/dp0", sds->dp0); | OpenVDBReader_get_meta_v3(reader, "blender/smoke/dp0", mds->dp0); | ||||
| OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/shift", sds->shift); | OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/shift", mds->shift); | ||||
| OpenVDBReader_get_meta_v3(reader, "blender/smoke/obj_shift_f", sds->obj_shift_f); | OpenVDBReader_get_meta_v3(reader, "blender/smoke/obj_shift_f", mds->obj_shift_f); | ||||
| OpenVDBReader_get_meta_v3(reader, "blender/smoke/active_color", sds->active_color); | OpenVDBReader_get_meta_v3(reader, "blender/smoke/active_color", mds->active_color); | ||||
| OpenVDBReader_get_meta_mat4(reader, "blender/smoke/obmat", sds->obmat); | OpenVDBReader_get_meta_mat4(reader, "blender/smoke/obmat", mds->obmat); | ||||
| OpenVDBReader_get_meta_int(reader, "blender/smoke/fluid_fields", &cache_fields); | OpenVDBReader_get_meta_int(reader, "blender/smoke/fluid_fields", &cache_fields); | ||||
| OpenVDBReader_get_meta_int(reader, "blender/smoke/active_fields", &active_fields); | OpenVDBReader_get_meta_int(reader, "blender/smoke/active_fields", &active_fields); | ||||
| 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] || sds->res[1] != cache_res[1] || sds->res[2] != cache_res[2]) { | if (mds->res[0] != cache_res[0] || mds->res[1] != cache_res[1] || mds->res[2] != cache_res[2]) { | ||||
| if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) { | if (mds->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 != mds->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; | mds->active_fields = active_fields | cache_fields; | ||||
| BKE_smoke_reallocate_fluid(sds, cache_dx, cache_res, 1); | BKE_manta_reallocate_fluid(mds, cache_dx, cache_res, 1); | ||||
| sds->dx = cache_dx; | mds->dx = cache_dx; | ||||
| copy_v3_v3_int(sds->res, cache_res); | copy_v3_v3_int(mds->res, cache_res); | ||||
| sds->total_cells = cache_res[0] * cache_res[1] * cache_res[2]; | mds->total_cells = cache_res[0] * cache_res[1] * cache_res[2]; | ||||
| if (sds->flags & MOD_SMOKE_HIGHRES) { | |||||
| BKE_smoke_reallocate_highres_fluid(sds, cache_dx, cache_res, 1); | |||||
| } | |||||
| } | } | ||||
| if (sds->fluid) { | if (mds->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, | smoke_export(mds->fluid, | ||||
| &dt, | &dt, | ||||
| &dx, | &dx, | ||||
| &dens, | &dens, | ||||
| &react, | &react, | ||||
| &flame, | &flame, | ||||
| &fuel, | &fuel, | ||||
| &heat, | &heat, | ||||
| &heatold, | &heatold, | ||||
| &vx, | &vx, | ||||
| &vy, | &vy, | ||||
| &vz, | &vz, | ||||
| &r, | &r, | ||||
| &g, | &g, | ||||
| &b, | &b, | ||||
| &obstacles); | &obstacles, | ||||
| NULL); | |||||
| 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", &mds->shadow, mds->res); | ||||
| const char *name = (!sds->wt) ? "density" : "density_low"; | const char *name = (!mds->wt) ? "density" : "density_low"; | ||||
| OpenVDB_import_grid_fl(reader, name, &dens, sds->res); | OpenVDB_import_grid_fl(reader, name, &dens, mds->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, mds->res); | ||||
| OpenVDB_import_grid_fl(reader, "heat_old", &heatold, sds->res); | OpenVDB_import_grid_fl(reader, "heat_old", &heatold, mds->res); | ||||
| } | } | ||||
| if (cache_fields & SM_ACTIVE_FIRE) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_FIRE) { | ||||
| name = (!sds->wt) ? "flame" : "flame_low"; | name = (!mds->wt) ? "flame" : "flame_low"; | ||||
| OpenVDB_import_grid_fl(reader, name, &flame, sds->res); | OpenVDB_import_grid_fl(reader, name, &flame, mds->res); | ||||
| name = (!sds->wt) ? "fuel" : "fuel_low"; | name = (!mds->wt) ? "fuel" : "fuel_low"; | ||||
| OpenVDB_import_grid_fl(reader, name, &fuel, sds->res); | OpenVDB_import_grid_fl(reader, name, &fuel, mds->res); | ||||
| name = (!sds->wt) ? "react" : "react_low"; | name = (!mds->wt) ? "react" : "react_low"; | ||||
| OpenVDB_import_grid_fl(reader, name, &react, sds->res); | OpenVDB_import_grid_fl(reader, name, &react, mds->res); | ||||
| } | } | ||||
| if (cache_fields & SM_ACTIVE_COLORS) { | if (cache_fields & FLUID_DOMAIN_ACTIVE_COLORS) { | ||||
| name = (!sds->wt) ? "color" : "color_low"; | name = (!mds->wt) ? "color" : "color_low"; | ||||
| OpenVDB_import_grid_vec(reader, name, &r, &g, &b, sds->res); | OpenVDB_import_grid_vec(reader, name, &r, &g, &b, mds->res); | ||||
| } | } | ||||
| OpenVDB_import_grid_vec(reader, "velocity", &vx, &vy, &vz, sds->res); | OpenVDB_import_grid_vec(reader, "velocity", &vx, &vy, &vz, mds->res); | ||||
| OpenVDB_import_grid_ch(reader, "obstacles", &obstacles, sds->res); | OpenVDB_import_grid_ch(reader, "obstacles", &obstacles, mds->res); | ||||
| } | } | ||||
| if (sds->wt) { | if (mds->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(mds->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, mds->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, mds->res_wt); | ||||
| OpenVDB_import_grid_fl(reader, "fuel", &fuel, sds->res_wt); | OpenVDB_import_grid_fl(reader, "fuel", &fuel, mds->res_wt); | ||||
| OpenVDB_import_grid_fl(reader, "react", &react, sds->res_wt); | OpenVDB_import_grid_fl(reader, "react", &react, mds->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, mds->res_wt); | ||||
| } | } | ||||
| OpenVDB_import_grid_vec(reader, "texture coordinates", &tcu, &tcv, &tcw, sds->res); | OpenVDB_import_grid_vec(reader, "texture coordinates", &tcu, &tcv, &tcw, mds->res); | ||||
| } | } | ||||
| OpenVDBReader_free(reader); | OpenVDBReader_free(reader); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| # endif | # endif | ||||
| ▲ Show 20 Lines • Show All 374 Lines • ▼ Show 20 Lines | void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd) | ||||
| pid->data_types = (1 << BPHYS_DATA_LOCATION) | (1 << BPHYS_DATA_VELOCITY) | | pid->data_types = (1 << BPHYS_DATA_LOCATION) | (1 << BPHYS_DATA_VELOCITY) | | ||||
| (1 << BPHYS_DATA_XCONST); | (1 << BPHYS_DATA_XCONST); | ||||
| pid->info_types = 0; | pid->info_types = 0; | ||||
| pid->default_step = 1; | pid->default_step = 1; | ||||
| pid->max_step = 1; | pid->max_step = 1; | ||||
| pid->file_type = PTCACHE_FILE_PTCACHE; | pid->file_type = PTCACHE_FILE_PTCACHE; | ||||
| } | } | ||||
| void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) | void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct FluidModifierData *mmd) | ||||
| { | { | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| memset(pid, 0, sizeof(PTCacheID)); | memset(pid, 0, sizeof(PTCacheID)); | ||||
| pid->ob = ob; | pid->ob = ob; | ||||
| pid->calldata = smd; | pid->calldata = mmd; | ||||
| pid->type = PTCACHE_TYPE_SMOKE_DOMAIN; | pid->type = PTCACHE_TYPE_SMOKE_DOMAIN; | ||||
| pid->stack_index = sds->point_cache[0]->index; | pid->stack_index = mds->point_cache[0]->index; | ||||
| pid->cache = sds->point_cache[0]; | pid->cache = mds->point_cache[0]; | ||||
| pid->cache_ptr = &(sds->point_cache[0]); | pid->cache_ptr = &(mds->point_cache[0]); | ||||
| pid->ptcaches = &(sds->ptcaches[0]); | pid->ptcaches = &(mds->ptcaches[0]); | ||||
| pid->totpoint = pid->totwrite = ptcache_smoke_totpoint; | pid->totpoint = pid->totwrite = ptcache_smoke_totpoint; | ||||
| pid->error = ptcache_smoke_error; | pid->error = ptcache_smoke_error; | ||||
| pid->write_point = NULL; | pid->write_point = NULL; | ||||
| pid->read_point = NULL; | pid->read_point = NULL; | ||||
| pid->interpolate_point = NULL; | pid->interpolate_point = NULL; | ||||
| pid->read_stream = ptcache_smoke_read; | pid->read_stream = ptcache_smoke_read; | ||||
| pid->write_stream = ptcache_smoke_write; | pid->write_stream = ptcache_smoke_write; | ||||
| pid->write_openvdb_stream = ptcache_smoke_openvdb_write; | pid->write_openvdb_stream = ptcache_smoke_openvdb_write; | ||||
| pid->read_openvdb_stream = ptcache_smoke_openvdb_read; | pid->read_openvdb_stream = ptcache_smoke_openvdb_read; | ||||
| pid->write_extra_data = NULL; | pid->write_extra_data = NULL; | ||||
| pid->read_extra_data = NULL; | pid->read_extra_data = NULL; | ||||
| pid->interpolate_extra_data = NULL; | pid->interpolate_extra_data = NULL; | ||||
| 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 (mds->fluid) { | ||||
| pid->data_types |= (1 << BPHYS_DATA_SMOKE_LOW); | pid->data_types |= (1 << BPHYS_DATA_SMOKE_LOW); | ||||
| } | if (mds->flags & FLUID_DOMAIN_USE_NOISE) { | ||||
| if (sds->wt) { | |||||
| pid->data_types |= (1 << BPHYS_DATA_SMOKE_HIGH); | 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; | pid->file_type = mmd->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 145 Lines • ▼ Show 20 Lines | static bool foreach_object_modifier_ptcache(Object *object, | ||||
| PTCacheID pid; | PTCacheID pid; | ||||
| for (ModifierData *md = object->modifiers.first; md != NULL; md = md->next) { | for (ModifierData *md = object->modifiers.first; md != NULL; md = md->next) { | ||||
| if (md->type == eModifierType_Cloth) { | if (md->type == eModifierType_Cloth) { | ||||
| BKE_ptcache_id_from_cloth(&pid, object, (ClothModifierData *)md); | BKE_ptcache_id_from_cloth(&pid, object, (ClothModifierData *)md); | ||||
| if (!callback(&pid, callback_user_data)) { | if (!callback(&pid, callback_user_data)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| else if (md->type == eModifierType_Smoke) { | else if (md->type == eModifierType_Manta) { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)md; | FluidModifierData *mmd = (FluidModifierData *)md; | ||||
| if (smd->type & MOD_SMOKE_TYPE_DOMAIN) { | if (mmd->type & MOD_MANTA_TYPE_DOMAIN) { | ||||
| BKE_ptcache_id_from_smoke(&pid, object, (SmokeModifierData *)md); | BKE_ptcache_id_from_smoke(&pid, object, (FluidModifierData *)md); | ||||
| if (!callback(&pid, callback_user_data)) { | if (!callback(&pid, callback_user_data)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (md->type == eModifierType_DynamicPaint) { | else if (md->type == eModifierType_DynamicPaint) { | ||||
| DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; | DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; | ||||
| if (pmd->canvas) { | if (pmd->canvas) { | ||||
| ▲ Show 20 Lines • Show All 1,813 Lines • ▼ Show 20 Lines | for (psys = ob->particlesystem.first; psys; psys = psys->next) { | ||||
| } | } | ||||
| } | } | ||||
| for (md = ob->modifiers.first; md; md = md->next) { | for (md = ob->modifiers.first; md; md = md->next) { | ||||
| if (md->type == eModifierType_Cloth) { | if (md->type == eModifierType_Cloth) { | ||||
| BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData *)md); | BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData *)md); | ||||
| reset |= BKE_ptcache_id_reset(scene, &pid, mode); | reset |= BKE_ptcache_id_reset(scene, &pid, mode); | ||||
| } | } | ||||
| if (md->type == eModifierType_Smoke) { | if (md->type == eModifierType_Manta) { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)md; | FluidModifierData *mmd = (FluidModifierData *)md; | ||||
| if (smd->type & MOD_SMOKE_TYPE_DOMAIN) { | if (mmd->type & MOD_MANTA_TYPE_DOMAIN) { | ||||
| BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData *)md); | BKE_ptcache_id_from_smoke(&pid, ob, (FluidModifierData *)md); | ||||
| reset |= BKE_ptcache_id_reset(scene, &pid, mode); | reset |= BKE_ptcache_id_reset(scene, &pid, mode); | ||||
| } | } | ||||
| } | } | ||||
| if (md->type == eModifierType_DynamicPaint) { | if (md->type == eModifierType_DynamicPaint) { | ||||
| DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; | DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; | ||||
| if (pmd->canvas) { | if (pmd->canvas) { | ||||
| DynamicPaintSurface *surface = pmd->canvas->surfaces.first; | DynamicPaintSurface *surface = pmd->canvas->surfaces.first; | ||||
| ▲ Show 20 Lines • Show All 832 Lines • Show Last 20 Lines | |||||
Juts remove it then (also same below).