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 | |
parent | 4633bb9939cd11a2429aeb2c0e5e3ede311a3126 (diff) | |
parent | 57801426792c3ca9c126c3c720ca6f337815294c (diff) |
Merge branch 'blender-v2.82-release'
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 53 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 35 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fluid.c | 16 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 48 |
4 files changed, 90 insertions, 62 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))) { diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index 3c29f8ec8c0..01f240e715b 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -246,7 +246,7 @@ static void rna_Fluid_tracer_parts_update(Main *bmain, Scene *UNUSED(scene), Poi rna_Fluid_parts_create(bmain, ptr, "TracerParticleSettings", - "Tracer Particles", + "Tracers", "Tracer Particle System", PART_FLUID_TRACER); mmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_TRACER; @@ -290,7 +290,7 @@ static void rna_Fluid_combined_export_update(Main *bmain, Scene *scene, PointerR rna_Fluid_parts_create(bmain, ptr, "SprayFoamParticleSettings", - "Spray + Foam Particles", + "Spray + Foam", "Spray + Foam Particle System", PART_FLUID_SPRAYFOAM); @@ -316,7 +316,7 @@ static void rna_Fluid_combined_export_update(Main *bmain, Scene *scene, PointerR rna_Fluid_parts_create(bmain, ptr, "SprayBubbleParticleSettings", - "Spray + Bubble Particles", + "Spray + Bubbles", "Spray + Bubble Particle System", PART_FLUID_SPRAYBUBBLE); @@ -369,7 +369,7 @@ static void rna_Fluid_combined_export_update(Main *bmain, Scene *scene, PointerR rna_Fluid_parts_create(bmain, ptr, "SprayFoamBubbleParticleSettings", - "Spray + Foam + Bubble Particles", + "Spray + Foam + Bubbles", "Spray + Foam + Bubble Particle System", PART_FLUID_SPRAYFOAMBUBBLE); @@ -1522,10 +1522,10 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "particle_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 10.0); - RNA_def_property_ui_text( - prop, - "Radius", - "Particle radius factor. Adjust this parameter when the simulation appears to leak volume"); + RNA_def_property_ui_text(prop, + "Radius", + "Particle radius factor. Increase this value if the simulation appears " + "to leak volume, decrease it if the simulation seems to gain volume"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_resetCache"); prop = RNA_def_property(srna, "particle_band_width", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index d914dc3b8dd..4155c453440 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -120,6 +120,29 @@ static const EnumPropertyItem part_hair_ren_as_items[] = { }; #endif +static const EnumPropertyItem part_type_items[] = { + {PART_EMITTER, "EMITTER", 0, "Emitter", ""}, + /*{PART_REACTOR, "REACTOR", 0, "Reactor", ""}, */ + {PART_HAIR, "HAIR", 0, "Hair", ""}, + {0, NULL, 0, NULL, NULL}, +}; + +#ifdef RNA_RUNTIME +static const EnumPropertyItem part_fluid_type_items[] = { + {PART_FLUID, "FLUID", 0, "Fluid", ""}, + {PART_FLUID_FLIP, "FLIP", 0, "Liquid", ""}, + {PART_FLUID_SPRAY, "SPRAY", 0, "Spray", ""}, + {PART_FLUID_BUBBLE, "BUBBLE", 0, "Bubble", ""}, + {PART_FLUID_FOAM, "FOAM", 0, "Foam", ""}, + {PART_FLUID_TRACER, "TRACER", 0, "Tracer", ""}, + {PART_FLUID_SPRAYFOAM, "SPRAYFOAM", 0, "Spray-Foam", ""}, + {PART_FLUID_SPRAYBUBBLE, "SPRAYBUBBLE", 0, "Spray-Bubble", ""}, + {PART_FLUID_FOAMBUBBLE, "FOAMBUBBLE", 0, "Foam-Bubble", ""}, + {PART_FLUID_SPRAYFOAMBUBBLE, "SPRAYFOAMBUBBLE", 0, "Spray-Foam-Bubble", ""}, + {0, NULL, 0, NULL, NULL}, +}; +#endif + #ifdef RNA_RUNTIME # include "BLI_math.h" @@ -1239,6 +1262,21 @@ static int rna_ParticleDupliWeight_name_length(PointerRNA *ptr) return strlen(tstr); } +static const EnumPropertyItem *rna_Particle_type_itemf(bContext *UNUSED(C), + PointerRNA *ptr, + PropertyRNA *UNUSED(prop), + bool *UNUSED(r_free)) +{ + ParticleSettings *part = (ParticleSettings *)ptr->owner_id; + + if (part->type == PART_HAIR || part->type == PART_EMITTER) { + return part_type_items; + } + else { + return part_fluid_type_items; + } +} + static const EnumPropertyItem *rna_Particle_from_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), @@ -2260,13 +2298,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem type_items[] = { - {PART_EMITTER, "EMITTER", 0, "Emitter", ""}, - /*{PART_REACTOR, "REACTOR", 0, "Reactor", ""}, */ - {PART_HAIR, "HAIR", 0, "Hair", ""}, - {0, NULL, 0, NULL, NULL}, - }; - static const EnumPropertyItem phys_type_items[] = { {PART_PHYS_NO, "NO", 0, "None", ""}, {PART_PHYS_NEWTON, "NEWTON", 0, "Newtonian", ""}, @@ -2493,8 +2524,9 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, type_items); + RNA_def_property_enum_items(prop, part_type_items); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_type_itemf"); RNA_def_property_ui_text(prop, "Type", "Particle Type"); RNA_def_property_update(prop, 0, "rna_Particle_change_type"); |