Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/source/voxeldata.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "BKE_cloth.h" | #include "BKE_cloth.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "smoke_API.h" | #ifdef WITH_MANTA | ||||
| # include "manta_fluid_API.h" | |||||
| #endif | |||||
| #include "BPH_mass_spring.h" | #include "BPH_mass_spring.h" | ||||
| #include "DNA_texture_types.h" | #include "DNA_texture_types.h" | ||||
| #include "DNA_object_force_types.h" | #include "DNA_object_force_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_particle_types.h" | #include "DNA_particle_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_smoke_types.h" | #include "DNA_smoke_types.h" | ||||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | static int read_voxeldata_header(FILE *fp, struct VoxelData *vd) | ||||
| vd->resol[2] = h->resolZ; | vd->resol[2] = h->resolZ; | ||||
| MEM_freeN(h); | MEM_freeN(h); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static void init_frame_smoke(VoxelData *vd, int cfra) | static void init_frame_smoke(VoxelData *vd, int cfra) | ||||
| { | { | ||||
| #ifdef WITH_SMOKE | #ifdef WITH_MANTA | ||||
| Object *ob; | Object *ob; | ||||
| ModifierData *md; | ModifierData *md; | ||||
| vd->dataset = NULL; | vd->dataset = NULL; | ||||
| if (vd->object == NULL) return; | if (vd->object == NULL) return; | ||||
| ob = vd->object; | ob = vd->object; | ||||
| /* draw code for smoke */ | /* draw code for smoke */ | ||||
| Show All 36 Lines | if (sds && sds->fluid) { | ||||
| size_t totRes; | size_t totRes; | ||||
| size_t i; | size_t i; | ||||
| float *xvel, *yvel, *zvel; | float *xvel, *yvel, *zvel; | ||||
| copy_v3_v3_int(vd->resol, sds->res); | copy_v3_v3_int(vd->resol, sds->res); | ||||
| totRes = vd_resol_size(vd); | totRes = vd_resol_size(vd); | ||||
| vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); | vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); | ||||
| /* get velocity data */ | /* get velocity data */ | ||||
| xvel = smoke_get_velocity_x(sds->fluid); | xvel = fluid_get_velocity_x(sds->fluid); | ||||
| yvel = smoke_get_velocity_y(sds->fluid); | yvel = fluid_get_velocity_y(sds->fluid); | ||||
| zvel = smoke_get_velocity_z(sds->fluid); | zvel = fluid_get_velocity_z(sds->fluid); | ||||
| /* map velocities between 0 and 0.3f */ | /* map velocities between 0 and 0.3f */ | ||||
| for (i = 0; i < totRes; i++) { | for (i = 0; i < totRes; i++) { | ||||
| vd->dataset[i] = sqrtf(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f; | vd->dataset[i] = sqrtf(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f; | ||||
| } | } | ||||
| } | } | ||||
| else if (vd->smoked_type == TEX_VD_SMOKEFLAME) { | else if (vd->smoked_type == TEX_VD_SMOKEFLAME) { | ||||
| size_t totRes; | size_t totRes; | ||||
| float *flame; | float *flame; | ||||
| if (sds->flags & MOD_SMOKE_HIGHRES) { | if (sds->flags & FLUID_DOMAIN_USE_NOISE) { | ||||
| if (!smoke_turbulence_has_fuel(sds->wt)) { | if (!smoke_turbulence_has_fuel(sds->fluid)) { | ||||
| BLI_rw_mutex_unlock(sds->fluid_mutex); | BLI_rw_mutex_unlock(sds->fluid_mutex); | ||||
| return; | return; | ||||
| } | } | ||||
| smoke_turbulence_get_res(sds->wt, vd->resol); | smoke_turbulence_get_res(sds->fluid, vd->resol); | ||||
| flame = smoke_turbulence_get_flame(sds->wt); | flame = smoke_turbulence_get_flame(sds->fluid); | ||||
| } | } | ||||
| else { | else { | ||||
| if (!smoke_has_fuel(sds->fluid)) { | if (!smoke_has_fuel(sds->fluid)) { | ||||
| BLI_rw_mutex_unlock(sds->fluid_mutex); | BLI_rw_mutex_unlock(sds->fluid_mutex); | ||||
| return; | return; | ||||
| } | } | ||||
| copy_v3_v3_int(vd->resol, sds->res); | copy_v3_v3_int(vd->resol, sds->res); | ||||
| flame = smoke_get_flame(sds->fluid); | flame = smoke_get_flame(sds->fluid); | ||||
| } | } | ||||
| /* always store copy, as smoke internal data can change */ | /* always store copy, as smoke internal data can change */ | ||||
| totRes = vd_resol_size(vd); | totRes = vd_resol_size(vd); | ||||
| vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); | vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); | ||||
| memcpy(vd->dataset, flame, sizeof(float)*totRes); | memcpy(vd->dataset, flame, sizeof(float)*totRes); | ||||
| } | } | ||||
| else { | else { | ||||
| size_t totCells; | size_t totCells; | ||||
| int depth = 4; | int depth = 4; | ||||
| vd->data_type = TEX_VD_RGBA_PREMUL; | vd->data_type = TEX_VD_RGBA_PREMUL; | ||||
| /* data resolution */ | /* data resolution */ | ||||
| if (sds->flags & MOD_SMOKE_HIGHRES) { | if (sds->flags & FLUID_DOMAIN_USE_NOISE) { | ||||
| smoke_turbulence_get_res(sds->wt, vd->resol); | smoke_turbulence_get_res(sds->fluid, vd->resol); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3_int(vd->resol, sds->res); | copy_v3_v3_int(vd->resol, sds->res); | ||||
| } | } | ||||
| /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */ | /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */ | ||||
| totCells = vd_resol_size(vd) * depth; | totCells = vd_resol_size(vd) * depth; | ||||
| /* always store copy, as smoke internal data can change */ | /* always store copy, as smoke internal data can change */ | ||||
| vd->dataset = MEM_mapallocN(sizeof(float) * totCells, "smoke data"); | vd->dataset = MEM_mapallocN(sizeof(float) * totCells, "smoke data"); | ||||
| if (sds->flags & MOD_SMOKE_HIGHRES) { | if (sds->flags & FLUID_DOMAIN_USE_NOISE) { | ||||
| if (smoke_turbulence_has_colors(sds->wt)) { | if (smoke_turbulence_has_colors(sds->fluid)) { | ||||
| smoke_turbulence_get_rgba(sds->wt, vd->dataset, 1); | smoke_turbulence_get_rgba(sds->fluid, vd->dataset, 1); | ||||
| } | } | ||||
| else { | else { | ||||
| smoke_turbulence_get_rgba_from_density(sds->wt, sds->active_color, vd->dataset, 1); | smoke_turbulence_get_rgba_from_density(sds->fluid, sds->active_color, vd->dataset, 1); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (smoke_has_colors(sds->fluid)) { | if (smoke_has_colors(sds->fluid)) { | ||||
| smoke_get_rgba(sds->fluid, vd->dataset, 1); | smoke_get_rgba(sds->fluid, vd->dataset, 1); | ||||
| } | } | ||||
| else { | else { | ||||
| smoke_get_rgba_from_density(sds->fluid, sds->active_color, vd->dataset, 1); | smoke_get_rgba_from_density(sds->fluid, sds->active_color, vd->dataset, 1); | ||||
| } | } | ||||
| } | } | ||||
| } /* end of fluid condition */ | } /* end of fluid condition */ | ||||
| BLI_rw_mutex_unlock(sds->fluid_mutex); | BLI_rw_mutex_unlock(sds->fluid_mutex); | ||||
| } | } | ||||
| } | } | ||||
| vd->ok = 1; | vd->ok = 1; | ||||
| #else // WITH_SMOKE | #else // WITH_MANTA | ||||
| (void)vd; | (void)vd; | ||||
| (void)cfra; | (void)cfra; | ||||
| vd->dataset = NULL; | vd->dataset = NULL; | ||||
| #endif | #endif | ||||
| } | } | ||||
| static void init_frame_hair(VoxelData *vd, int UNUSED(cfra)) | static void init_frame_hair(VoxelData *vd, int UNUSED(cfra)) | ||||
| ▲ Show 20 Lines • Show All 201 Lines • Show Last 20 Lines | |||||