[Bf-blender-cvs] [afc9c2ddcbd] fluid-mantaflow: added surface thickness option for effector objects (i.e. obstacle or guide objects)
Sebastián Barschkis
noreply at git.blender.org
Thu Aug 31 17:07:59 CEST 2017
Commit: afc9c2ddcbd305edb4264bc2a3e7fd445121675f
Author: Sebastián Barschkis
Date: Thu Aug 31 17:07:41 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBafc9c2ddcbd305edb4264bc2a3e7fd445121675f
added surface thickness option for effector objects (i.e. obstacle or guide objects)
===================================================================
M release/scripts/startup/bl_ui/properties_physics_smoke.py
M source/blender/blenkernel/intern/smoke.c
M source/blender/makesdna/DNA_smoke_types.h
M source/blender/makesrna/intern/rna_smoke.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 5a9df8e9e49..6bb8ccc48e1 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -181,10 +181,15 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
elif md.smoke_type == 'EFFECTOR':
effec = md.effec_settings
+ layout.prop(effec, "effec_type")
+
split = layout.split()
+ col = split.column()
+ col.label(text="Surface thickness:")
col = split.column()
- col.prop(effec, "effec_type")
+
+ col.prop(effec, "surface_distance")
class PHYSICS_PT_smoke_flow_advanced(PhysicButtonsPanel, Panel):
bl_label = "Fluid Source"
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 609889f887c..c7269cb4b4c 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -622,6 +622,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->effec->numverts = 0;
smd->effec->type = 0; // static obstacle
smd->effec->dm = NULL;
+ smd->effec->surface_distance = 0.5f;
#ifdef USE_SMOKE_COLLISION_DM
smd->effec->dm = NULL;
@@ -744,6 +745,7 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
}
else if (tsmd->effec) {
/* leave it as initialized, collision settings is mostly caches */
+ tsmd->effec->surface_distance = smd->effec->surface_distance;
}
}
@@ -752,7 +754,7 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
// forward decleration
static void smoke_calc_transparency(SmokeDomainSettings *sds, Scene *scene);
static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
-static void update_mesh_distances(int index, float *mesh_distances, BVHTreeFromMesh *treeData, const float ray_start[3]);
+static void update_mesh_distances(int index, float *mesh_distances, BVHTreeFromMesh *treeData, const float ray_start[3], float surface_thickness);
static int get_lamp(Scene *scene, float *light)
{
@@ -794,6 +796,7 @@ typedef struct ObstaclesFromDMData {
float *velocityX, *velocityY, *velocityZ;
int *num_objects;
float *distances_map;
+ float surface_thickness;
} ObstaclesFromDMData;
static void obstacles_from_derivedmesh_task_cb(void *userdata, const int z)
@@ -843,7 +846,7 @@ static void obstacles_from_derivedmesh_task_cb(void *userdata, const int z)
/* Get distance to mesh surface from both within and outside grid (mantaflow phi grid) */
if (data->distances_map) {
- update_mesh_distances(index, data->distances_map, data->tree, ray_start);
+ update_mesh_distances(index, data->distances_map, data->tree, ray_start, data->surface_thickness);
}
}
}
@@ -922,7 +925,7 @@ static void obstacles_from_derivedmesh(
.sds = sds, .mvert = mvert, .mloop = mloop, .looptri = looptri,
.tree = &treeData, .has_velocity = has_velocity, .vert_vel = vert_vel,
.velocityX = velocityX, .velocityY = velocityY, .velocityZ = velocityZ,
- .num_objects = num_objects, .distances_map = distances_map
+ .num_objects = num_objects, .distances_map = distances_map, .surface_thickness = scs->surface_distance
};
BLI_task_parallel_range(
sds->res_min[2], sds->res_max[2], &data, obstacles_from_derivedmesh_task_cb, true);
@@ -1683,7 +1686,7 @@ static void emit_from_particles(
//}
/* Calculate map of (minimum) distances to flow/obstacle surface. Distances outside mesh are positive, inside negative */
-static void update_mesh_distances(int index, float *mesh_distances, BVHTreeFromMesh *treeData, const float ray_start[3]) {
+static void update_mesh_distances(int index, float *mesh_distances, BVHTreeFromMesh *treeData, const float ray_start[3], float surface_thickness) {
float min_dist = 9999;
@@ -1720,9 +1723,8 @@ static void update_mesh_distances(int index, float *mesh_distances, BVHTreeFromM
/* If point is on surface it is also considered to be "inside" the mesh (negative levelset) */
BVHTreeNearest nearest = {0};
- const float surface_distance = 1.5f;
nearest.index = -1;
- nearest.dist_sq = surface_distance * surface_distance;
+ nearest.dist_sq = surface_thickness * surface_thickness;
inside |= (BLI_bvhtree_find_nearest(treeData->tree, ray_start, &nearest, treeData->nearest_callback, treeData) != -1);
/* Levelset is negative inside mesh */
@@ -1915,7 +1917,7 @@ static void emit_from_derivedmesh_task_cb(void *userdata, const int z)
}
/* Calculate levelset from meshes. Result in em->distances */
- update_mesh_distances(index, em->distances, data->tree, ray_start);
+ update_mesh_distances(index, em->distances, data->tree, ray_start, data->sfs->surface_distance);
}
/* take high res samples if required */
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 5b91b3bbca1..f5e56c9c183 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -370,6 +370,8 @@ typedef struct SmokeCollSettings {
int numverts;
short type;
short pad;
+ float surface_distance; /* thickness of mesh surface, used in obstacle sdf */
+ char pad2[4]; /* unused */
} SmokeCollSettings;
#endif
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index 307ed229246..6a1c713f15e 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -1654,6 +1654,12 @@ static void rna_def_smoke_effec_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, smoke_effec_type_items);
RNA_def_property_ui_text(prop, "Effector type", "Effector type");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "surface_distance", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, 10.0);
+ RNA_def_property_ui_range(prop, 0.5, 5.0, 0.05, 5);
+ RNA_def_property_ui_text(prop, "Distance", "Distance around mesh surface to consider as effector");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
}
void RNA_def_smoke(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list