[Bf-blender-cvs] [3bd4739d5c1] soc-2020-fluid-tools: Fluid: Added display support for guide velocity vectors
Sriharsha Kotcharlakot
noreply at git.blender.org
Wed May 27 20:31:52 CEST 2020
Commit: 3bd4739d5c19b8d6b7ccea9ff93147e8126d8a45
Author: Sriharsha Kotcharlakot
Date: Thu May 28 00:01:27 2020 +0530
Branches: soc-2020-fluid-tools
https://developer.blender.org/rB3bd4739d5c19b8d6b7ccea9ff93147e8126d8a45
Fluid: Added display support for guide velocity vectors
Used the existing functionality for fluid velocity display to show guide velocity grids.
===================================================================
M release/scripts/startup/bl_ui/properties_physics_fluid.py
M source/blender/blenkernel/intern/fluid.c
M source/blender/gpu/intern/gpu_draw_smoke.c
M source/blender/makesdna/DNA_fluid_types.h
M source/blender/makesrna/intern/rna_fluid.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 2c8ed363738..dd43953b8c4 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -1236,7 +1236,7 @@ class PHYSICS_PT_viewport_display(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- return (PhysicButtonsPanel.poll_gas_domain(context))
+ return (PhysicButtonsPanel.poll_fluid_domain(context))
def draw(self, context):
layout = self.layout
@@ -1307,7 +1307,7 @@ class PHYSICS_PT_viewport_display_debug(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- return (PhysicButtonsPanel.poll_gas_domain(context))
+ return (PhysicButtonsPanel.poll_fluid_domain(context))
def draw_header(self, context):
md = context.fluid.domain_settings
@@ -1324,6 +1324,10 @@ class PHYSICS_PT_viewport_display_debug(PhysicButtonsPanel, Panel):
col = flow.column()
col.active = domain.show_velocity
col.prop(domain, "vector_display_type", text="Display As")
+ col.prop(domain, "vector_grid_type", text="Grid Type")
+ if ((not domain.use_guide) and domain.vector_grid_type == 'GUIDE_VELOCITY'):
+ note = layout.split()
+ note.label(icon='INFO', text="Enable Guides first! Defaulting to Fluid Velocity.")
col.prop(domain, "vector_scale")
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index b75592836e0..d2ea5dba3d0 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4970,6 +4970,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *mmd)
mmd->domain->coba = NULL;
mmd->domain->vector_scale = 1.0f;
mmd->domain->vector_draw_type = VECTOR_DRAW_NEEDLE;
+ mmd->domain->vector_draw_grid_type = VECTOR_DRAW_GRID_FLUID_VELOCITY;
mmd->domain->use_coba = false;
mmd->domain->coba_field = FLUID_DOMAIN_FIELD_DENSITY;
@@ -5209,6 +5210,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *mmd,
}
tmds->vector_scale = mds->vector_scale;
tmds->vector_draw_type = mds->vector_draw_type;
+ tmds->vector_draw_grid_type = mds->vector_draw_grid_type;
tmds->use_coba = mds->use_coba;
tmds->coba_field = mds->coba_field;
diff --git a/source/blender/gpu/intern/gpu_draw_smoke.c b/source/blender/gpu/intern/gpu_draw_smoke.c
index 80c59ed47c9..2192039b3d7 100644
--- a/source/blender/gpu/intern/gpu_draw_smoke.c
+++ b/source/blender/gpu/intern/gpu_draw_smoke.c
@@ -376,10 +376,24 @@ void GPU_create_smoke_velocity(FluidModifierData *mmd)
#else
if (mmd->type & MOD_FLUID_TYPE_DOMAIN) {
FluidDomainSettings *mds = mmd->domain;
+ const float *vel_x, *vel_y, *vel_z;
+ const char grid_type = mds->vector_draw_grid_type;
+
+ switch(grid_type) {
+ case VECTOR_DRAW_GRID_GUIDE_VELOCITY:
+ if (manta_get_guide_velocity_x(mds->fluid)) {
+ vel_x = manta_get_guide_velocity_x(mds->fluid);
+ vel_y = manta_get_guide_velocity_y(mds->fluid);
+ vel_z = manta_get_guide_velocity_z(mds->fluid);
+ break;
+ }
- const float *vel_x = manta_get_velocity_x(mds->fluid);
- const float *vel_y = manta_get_velocity_y(mds->fluid);
- const float *vel_z = manta_get_velocity_z(mds->fluid);
+ default:
+ vel_x = manta_get_velocity_x(mds->fluid);
+ vel_y = manta_get_velocity_y(mds->fluid);
+ vel_z = manta_get_velocity_z(mds->fluid);
+ break;
+ }
if (ELEM(NULL, vel_x, vel_y, vel_z)) {
return;
diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h
index 7da33a369f3..41408486641 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -97,6 +97,11 @@ enum {
VECTOR_DRAW_STREAMLINE = 1,
};
+enum {
+ VECTOR_DRAW_GRID_FLUID_VELOCITY = 0,
+ VECTOR_DRAW_GRID_GUIDE_VELOCITY = 1,
+};
+
enum {
SNDPARTICLE_BOUNDARY_DELETE = 0,
SNDPARTICLE_BOUNDARY_PUSHOUT = 1,
@@ -497,21 +502,23 @@ typedef struct FluidDomainSettings {
struct ColorBand *coba;
float vector_scale;
char vector_draw_type;
+ char vector_draw_grid_type;
char use_coba;
char coba_field; /* Simulation field used for the color mapping. */
char interp_method;
+ char _pad9[7]; /* Unused. */
/* -- Deprecated / unsed options (below). -- */
/* View options. */
int viewsettings;
- char _pad9[4]; /* Unused. */
+ char _pad10[4]; /* Unused. */
/* OpenVDB cache options. */
int openvdb_comp;
float clipping;
char data_depth;
- char _pad10[7]; /* Unused. */
+ char _pad11[7]; /* Unused. */
/* Pointcache options. */
/* Smoke uses only one cache from now on (index [0]), but keeping the array for now for reading
@@ -521,7 +528,7 @@ typedef struct FluidDomainSettings {
int cache_comp;
int cache_high_comp;
char cache_file_format;
- char _pad11[7]; /* Unused. */
+ char _pad12[7]; /* Unused. */
} FluidDomainSettings;
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index 93c7c1f3480..6e7c34235f4 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -1164,6 +1164,12 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem vector_draw_grid_items[] = {
+ {VECTOR_DRAW_GRID_FLUID_VELOCITY, "FLUID_VELOCITY", 0, "Fluid Velocity", "Display fluid velocity grid"},
+ {VECTOR_DRAW_GRID_GUIDE_VELOCITY, "GUIDE_VELOCITY", 0, "Guide Velocity", "Display guide velocity grid"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
static const EnumPropertyItem sndparticle_boundary_items[] = {
{SNDPARTICLE_BOUNDARY_DELETE,
"DELETE",
@@ -2233,6 +2239,12 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Display Type", "");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+ prop = RNA_def_property(srna, "vector_grid_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "vector_draw_grid_type");
+ RNA_def_property_enum_items(prop, vector_draw_grid_items);
+ RNA_def_property_ui_text(prop, "Grid Type", "Type of vector grid to be displayed");
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
prop = RNA_def_property(srna, "vector_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vector_scale");
RNA_def_property_range(prop, 0.0, 1000.0);
More information about the Bf-blender-cvs
mailing list