[Bf-blender-cvs] [dd075f267c0] fluid-mantaflow: added guiding object velocity factor (UI option)
Sebastián Barschkis
noreply at git.blender.org
Wed Jul 11 16:49:31 CEST 2018
Commit: dd075f267c07e56773cd36b26776c7e544522b32
Author: Sebastián Barschkis
Date: Wed Jul 11 16:49:20 2018 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBdd075f267c07e56773cd36b26776c7e544522b32
added guiding object velocity factor (UI option)
===================================================================
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 60efbffab8f..090525b30c7 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -218,9 +218,11 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
col = split.column()
col.label(text="Surface thickness:")
+ col.label(text="Velocity factor:")
col = split.column()
col.prop(effec, "surface_distance")
+ col.prop(effec, "velocity_factor")
class PHYSICS_PT_smoke_flow_source(PhysicButtonsPanel, Panel):
bl_label = "Fluid Source"
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index b68b7738dee..888c929b198 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -643,6 +643,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->effec->type = 0; // static obstacle
smd->effec->dm = NULL;
smd->effec->surface_distance = 0.5f;
+ smd->effec->vel_multi = 1.0f;
}
}
}
@@ -795,6 +796,7 @@ void smokeModifier_copy(const struct SmokeModifierData *smd, struct SmokeModifie
else if (tsmd->effec) {
tsmd->effec->type = smd->effec->type;
tsmd->effec->surface_distance = smd->effec->surface_distance;
+ tsmd->effec->vel_multi = smd->effec->vel_multi;
}
}
@@ -835,6 +837,7 @@ static int get_lamp(Scene *scene, float *light)
typedef struct ObstaclesFromDMData {
SmokeDomainSettings *sds;
+ SmokeCollSettings *scs;
const MVert *mvert;
const MLoop *mloop;
const MLoopTri *looptri;
@@ -845,7 +848,6 @@ typedef struct ObstaclesFromDMData {
float *velocityX, *velocityY, *velocityZ;
int *num_objects;
float *distances_map;
- float surface_thickness;
} ObstaclesFromDMData;
static void obstacles_from_derivedmesh_task_cb(
@@ -888,9 +890,9 @@ static void obstacles_from_derivedmesh_task_cb(
/* apply object velocity */
float hit_vel[3];
interp_v3_v3v3v3(hit_vel, &data->vert_vel[v1 * 3], &data->vert_vel[v2 * 3], &data->vert_vel[v3 * 3], weights);
- data->velocityX[index] += hit_vel[0];
- data->velocityY[index] += hit_vel[1];
- data->velocityZ[index] += hit_vel[2];
+ data->velocityX[index] += hit_vel[0] * data->scs->vel_multi;
+ data->velocityY[index] += hit_vel[1] * data->scs->vel_multi;
+ data->velocityZ[index] += hit_vel[2] * data->scs->vel_multi;
// printf("adding obvel: [%f, %f, %f], dx is: %f\n", hit_vel[0], hit_vel[1], hit_vel[2], sds->dx);
/* increase object count */
@@ -901,7 +903,7 @@ static void obstacles_from_derivedmesh_task_cb(
/* 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, data->surface_thickness);
+ update_mesh_distances(index, data->distances_map, data->tree, ray_start, data->scs->surface_distance);
/* Ensure that num objects are also counted inside object. But dont count twice (see object inc for nearest point) */
if (data->distances_map[index] < 0 && !hasIncObj) {
@@ -980,10 +982,10 @@ static void obstacles_from_derivedmesh(
if (bvhtree_from_mesh_get(&treeData, dm, BVHTREE_FROM_LOOPTRI, 4)) {
ObstaclesFromDMData data = {
- .sds = sds, .mvert = mvert, .mloop = mloop, .looptri = looptri,
+ .sds = sds, .scs = scs, .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, .surface_thickness = scs->surface_distance
+ .num_objects = num_objects, .distances_map = distances_map
};
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index d5843a31001..475ca9c625a 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -460,7 +460,7 @@ typedef struct SmokeCollSettings {
short type;
short pad;
float surface_distance; /* thickness of mesh surface, used in obstacle sdf */
- char pad2[4]; /* unused */
+ float vel_multi; // Multiplier for obstacle velocity
} SmokeCollSettings;
#endif
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index a6960ea54a3..c2100c945c6 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -2049,6 +2049,13 @@ static void rna_def_smoke_effec_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 10.0);
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");
+
+ prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "vel_multi");
+ RNA_def_property_range(prop, -100.0, 100.0);
+ RNA_def_property_ui_text(prop, "Source", "Multiplier of obstacle velocity");
+ 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