diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-31 21:26:20 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-31 21:26:20 +0300 |
commit | f9d09a120910a21d383933c15fd72546772b5e81 (patch) | |
tree | aba43105de416afdf376bbf563002f9fd360188f /source/blender/blenkernel/intern | |
parent | 4633bb9939cd11a2429aeb2c0e5e3ede311a3126 (diff) | |
parent | 57801426792c3ca9c126c3c720ca6f337815294c (diff) |
Merge branch 'blender-v2.82-release'
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 53 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 35 |
2 files changed, 42 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 12c65027e25..f19137bf796 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -1452,7 +1452,7 @@ static void update_mesh_distances(int index, return; } - /* b) Volumetric initialization: 1) Ray-casts around mesh object. */ + /* b) Volumetric initialization: Ray-casts around mesh object. */ /* Ray-casts in 26 directions. * (6 main axis + 12 quadrant diagonals (2D) + 8 octant diagonals (3D)). */ @@ -1508,45 +1508,8 @@ static void update_mesh_distances(int index, min_dist = (-1.0f) * fabsf(min_dist); } - /* Update global distance array with distance value. */ - mesh_distances[index] = min_dist; - - /* b) Volumetric initialization: 2) Use nearest neighbor search on mesh surface. */ - - /* Distance between two opposing vertices in a unit cube. - * I.e. the unit cube diagonal or sqrt(3). - * This value is our nearest neighbour search distance. */ - const float surface_distance = 1.732; - BVHTreeNearest nearest = {0}; - nearest.index = -1; - nearest.dist_sq = surface_distance * surface_distance; /* find_nearest uses squared distance. */ - - if (BLI_bvhtree_find_nearest( - tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) { - float ray[3] = {0}; - sub_v3_v3v3(ray, nearest.co, ray_start); - min_dist = len_v3(ray); - - BVHTreeRayHit hit_tree = {0}; - hit_tree.index = -1; - hit_tree.dist = PHI_MAX; - - normalize_v3(ray); - BLI_bvhtree_ray_cast( - tree_data->tree, ray_start, ray, 0.0f, &hit_tree, tree_data->raycast_callback, tree_data); - - /* Only proceed if casted ray hit the mesh surface. */ - if (hit_tree.index != -1) { - - /* Ray and normal are pointing in the same direction: Point must lie inside mesh. */ - if (dot_v3v3(ray, hit_tree.no) > 0) { - min_dist = (-1.0f) * fabsf(min_dist); - } - - /* Update distance map with more accurate distance from this nearest neighbor search. */ - mesh_distances[index] = min_dist; - } - } + /* Update global distance array but ensure that older entries are not overridden. */ + mesh_distances[index] = MIN2(mesh_distances[index], min_dist); /* Subtract optional surface thickness value and virtually increase the object size. */ if (surface_thickness) { @@ -4012,7 +3975,7 @@ void BKE_fluid_particle_system_create(struct Main *bmain, part->type = psys_type; part->totpart = 0; - part->draw_size = 0.01f; // make fluid particles more subtle in viewport + part->draw_size = 0.01f; /* Make fluid particles more subtle in viewport. */ part->draw_col = PART_DRAW_COL_VEL; psys->part = part; psys->pointcache = BKE_ptcache_add(&psys->ptcaches); @@ -4386,7 +4349,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *mmd) mmd->domain->particle_number = 2; mmd->domain->particle_minimum = 8; mmd->domain->particle_maximum = 16; - mmd->domain->particle_radius = 1.5f; + mmd->domain->particle_radius = 1.0f; mmd->domain->particle_band_width = 3.0f; mmd->domain->fractions_threshold = 0.05f; @@ -4445,9 +4408,9 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *mmd) mmd->domain->cache_flag = 0; mmd->domain->cache_type = FLUID_DOMAIN_CACHE_MODULAR; mmd->domain->cache_mesh_format = FLUID_DOMAIN_FILE_BIN_OBJECT; - mmd->domain->cache_data_format = FLUID_DOMAIN_FILE_UNI; - mmd->domain->cache_particle_format = FLUID_DOMAIN_FILE_UNI; - mmd->domain->cache_noise_format = FLUID_DOMAIN_FILE_UNI; + mmd->domain->cache_data_format = FLUID_DOMAIN_FILE_OPENVDB; + mmd->domain->cache_particle_format = FLUID_DOMAIN_FILE_OPENVDB; + mmd->domain->cache_noise_format = FLUID_DOMAIN_FILE_OPENVDB; modifier_path_init(mmd->domain->cache_directory, sizeof(mmd->domain->cache_directory), FLUID_DOMAIN_DIR_DEFAULT); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 6b87cf2df81..97fcef4fd27 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3586,14 +3586,47 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob return; } - /* clear all other appearances of this pointer (like on manta flow modifier) */ + /* Clear particle system in fluid modifier. */ if ((md = modifiers_findByType(ob, eModifierType_Fluid))) { FluidModifierData *mmd = (FluidModifierData *)md; + + /* Clear particle system pointer in flow settings. */ if ((mmd->type == MOD_FLUID_TYPE_FLOW) && mmd->flow && mmd->flow->psys) { if (mmd->flow->psys == psys) { mmd->flow->psys = NULL; } } + /* Clear particle flag in domain settings when removing particle system manually. */ + if (mmd->type == MOD_FLUID_TYPE_DOMAIN) { + if (psys->part->type == PART_FLUID_FLIP) { + mmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FLIP; + } + if (psys->part->type == PART_FLUID_SPRAY || psys->part->type == PART_FLUID_SPRAYFOAM || + psys->part->type == PART_FLUID_SPRAYBUBBLE || + psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) { + mmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_SPRAY; + } + if (psys->part->type == PART_FLUID_FOAM || psys->part->type == PART_FLUID_SPRAYFOAM || + psys->part->type == PART_FLUID_FOAMBUBBLE || + psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) { + mmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FOAM; + } + if (psys->part->type == PART_FLUID_BUBBLE || psys->part->type == PART_FLUID_FOAMBUBBLE || + psys->part->type == PART_FLUID_SPRAYBUBBLE || + psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) { + mmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_BUBBLE; + } + if (psys->part->type == PART_FLUID_TRACER) { + mmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_TRACER; + } + + /* Disable combined export if combined particle system was deleted. */ + if (psys->part->type == PART_FLUID_SPRAYFOAM || psys->part->type == PART_FLUID_SPRAYBUBBLE || + psys->part->type == PART_FLUID_FOAMBUBBLE || + psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) { + mmd->domain->sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF; + } + } } if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint))) { |