From fe96b2a613106ed16fc540829c5ee6ed6bb66c83 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Mon, 28 Jul 2025 14:15:07 +0200 Subject: [PATCH] Fix #107679: Smoke simulation adaptive domain shrinks too much * Take into account heat grid in addition to density and fuel, as this is used for displaying smoke in Blender. * Lower adaptive domain threshold from 0.02 to 0.002, to fix visual issues with small smoke density that can still be visible. Pull Request: https://projects.blender.org/blender/blender/pulls/139940 --- source/blender/blenkernel/intern/fluid.cc | 2 ++ source/blender/blenloader/intern/versioning_260.cc | 2 +- source/blender/makesdna/DNA_fluid_defaults.h | 2 +- source/blender/makesrna/intern/rna_fluid.cc | 10 +++++----- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/fluid.cc b/source/blender/blenkernel/intern/fluid.cc index cb943fa607f..da71bae5a07 100644 --- a/source/blender/blenkernel/intern/fluid.cc +++ b/source/blender/blenkernel/intern/fluid.cc @@ -2222,6 +2222,7 @@ static void adaptive_domain_adjust( int x, y, z; float *density = manta_smoke_get_density(fds->fluid); float *fuel = manta_smoke_get_fuel(fds->fluid); + float *heat = manta_smoke_get_heat(fds->fluid); float *bigdensity = manta_noise_get_density(fds->fluid); float *bigfuel = manta_noise_get_fuel(fds->fluid); float *vx = manta_get_velocity_x(fds->fluid); @@ -2258,6 +2259,7 @@ static void adaptive_domain_adjust( fds->res[1], z - fds->res_min[2]); max_den = (fuel) ? std::max(density[index], fuel[index]) : density[index]; + max_den = (heat) ? std::max(max_den, heat[index]) : max_den; /* Check high resolution bounds if max density isn't already high enough. */ if (max_den < fds->adapt_threshold && fds->flags & FLUID_DOMAIN_USE_NOISE && fds->fluid) { diff --git a/source/blender/blenloader/intern/versioning_260.cc b/source/blender/blenloader/intern/versioning_260.cc index ac7231ce56b..9085454999f 100644 --- a/source/blender/blenloader/intern/versioning_260.cc +++ b/source/blender/blenloader/intern/versioning_260.cc @@ -1988,7 +1988,7 @@ void blo_do_versions_260(FileData *fd, Library * /*lib*/, Main *bmain) fmd->domain->flame_vorticity = 0.5f; fmd->domain->flame_ignition = 1.25f; fmd->domain->flame_max_temp = 1.75f; - fmd->domain->adapt_threshold = 0.02f; + fmd->domain->adapt_threshold = 0.002f; fmd->domain->adapt_margin = 4; fmd->domain->flame_smoke_color[0] = 0.7f; fmd->domain->flame_smoke_color[1] = 0.7f; diff --git a/source/blender/makesdna/DNA_fluid_defaults.h b/source/blender/makesdna/DNA_fluid_defaults.h index fcdb81fd5e3..f7e73093eaf 100644 --- a/source/blender/makesdna/DNA_fluid_defaults.h +++ b/source/blender/makesdna/DNA_fluid_defaults.h @@ -62,7 +62,7 @@ .gravity_final = {0.0f, 0.0f, 0.0f}, \ .adapt_margin = 4, \ .adapt_res = 0, \ - .adapt_threshold = 0.02f, \ + .adapt_threshold = 0.002f, \ .maxres = 32, \ .solver_res = 3, \ .border_collisions = 0, \ diff --git a/source/blender/makesrna/intern/rna_fluid.cc b/source/blender/makesrna/intern/rna_fluid.cc index 8e3f05c38d3..23f3bd141c0 100644 --- a/source/blender/makesrna/intern/rna_fluid.cc +++ b/source/blender/makesrna/intern/rna_fluid.cc @@ -1573,11 +1573,11 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "adapt_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_range(prop, 0.0, 1.0, 0.02, 6); - RNA_def_property_ui_text( - prop, - "Threshold", - "Minimum amount of fluid a cell can contain before it is considered empty"); + RNA_def_property_ui_range(prop, 0.0, 1.0, 0.002, 6); + RNA_def_property_ui_text(prop, + "Threshold", + "Minimum amount of fluid grid values (smoke density, fuel and heat) a " + "cell can contain, before it is considered empty"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset"); prop = RNA_def_property(srna, "use_adaptive_domain", PROP_BOOLEAN, PROP_NONE);