Commit: 4b12a5559133cfa61e80a528d02da1f00055c651
Author: Sriharsha Kotcharlakot
Date:   Thu Aug 6 11:33:38 2020 +0530
Branches: soc-2020-fluid-tools
https://developer.blender.org/rB4b12a5559133cfa61e80a528d02da1f00055c651

Fluid: Added options to toggle the display of MAC grid components along the axes

===================================================================

M       release/scripts/startup/bl_ui/properties_physics_fluid.py
M       source/blender/blenkernel/intern/fluid.c
M       source/blender/draw/engines/overlay/overlay_extra.c
M       source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl
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 488fd6578a7..9da3afcbc3a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -1342,11 +1342,19 @@ class 
PHYSICS_PT_viewport_display_debug(PhysicButtonsPanel, Panel):
         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.")
-        if domain.vector_display_type != "MAC":
+        
+        if domain.vector_display_type == "MAC":
+            sub = col.column(heading="MAC Grid")
+            sub.prop(domain, "vector_show_mac_x")
+            sub.prop(domain, "vector_show_mac_y")
+            sub.prop(domain, "vector_show_mac_z")
+        else:
             col.prop(domain, "vector_scale_with_magnitude")
+        
         col.prop(domain, "vector_scale")
 
 class PHYSICS_PT_viewport_display_advanced(PhysicButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 513fada74a8..77b368076b9 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4997,6 +4997,8 @@ void BKE_fluid_modifier_create_type_data(struct 
FluidModifierData *fmd)
     fmd->domain->vector_draw_type = VECTOR_DRAW_NEEDLE;
     fmd->domain->vector_draw_grid_type = VECTOR_DRAW_GRID_FLUID_VELOCITY;
     fmd->domain->vector_scale_with_magnitude = true;
+    fmd->domain->vector_draw_mac_components = VECTOR_DRAW_MAC_X | 
VECTOR_DRAW_MAC_Y |
+                                              VECTOR_DRAW_MAC_Z;
     fmd->domain->use_coba = false;
     fmd->domain->coba_field = FLUID_DOMAIN_FIELD_DENSITY;
     fmd->domain->gridlines_color_field = 0;
@@ -5248,6 +5250,7 @@ void BKE_fluid_modifier_copy(const struct 
FluidModifierData *fmd,
     tfds->vector_draw_type = fds->vector_draw_type;
     tfds->vector_draw_grid_type = fds->vector_draw_grid_type;
     tfds->vector_scale_with_magnitude = fds->vector_scale_with_magnitude;
+    tfds->vector_draw_mac_components = fds->vector_draw_mac_components;
     tfds->use_coba = fds->use_coba;
     tfds->coba_field = fds->coba_field;
     tfds->grid_scale = fds->grid_scale;
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c 
b/source/blender/draw/engines/overlay/overlay_extra.c
index aa408262660..55f34bd9d5f 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -1428,6 +1428,9 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers 
*cb,
   if (draw_velocity) {
     const bool use_needle = (fds->vector_draw_type == VECTOR_DRAW_NEEDLE);
     const bool use_mac = (fds->vector_draw_type == VECTOR_DRAW_MAC);
+    const bool draw_mac_x = (fds->vector_draw_mac_components & 
VECTOR_DRAW_MAC_X);
+    const bool draw_mac_y = (fds->vector_draw_mac_components & 
VECTOR_DRAW_MAC_Y);
+    const bool draw_mac_z = (fds->vector_draw_mac_components & 
VECTOR_DRAW_MAC_Z);
     const bool cell_centered = (fds->vector_draw_grid_type == 
VECTOR_DRAW_GRID_FORCE);
     int line_count = 1;
     if (use_needle) {
@@ -1457,6 +1460,13 @@ static void 
OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb,
     DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis);
     DRW_shgroup_uniform_bool_copy(grp, "scaleWithMagnitude", 
fds->vector_scale_with_magnitude);
     DRW_shgroup_uniform_bool_copy(grp, "isCellCentered", cell_centered);
+
+    if (use_mac) {
+      DRW_shgroup_uniform_bool_copy(grp, "drawMACX", draw_mac_x);
+      DRW_shgroup_uniform_bool_copy(grp, "drawMACY", draw_mac_y);
+      DRW_shgroup_uniform_bool_copy(grp, "drawMACZ", draw_mac_z);
+    }
+
     DRW_shgroup_call_procedural_lines(grp, ob, line_count);
   }
 
diff --git 
a/source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl 
b/source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl
index d3486754cd3..7159b2fac7f 100644
--- a/source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl
@@ -16,6 +16,10 @@ uniform vec3 domainOriginOffset;
 uniform ivec3 adaptiveCellOffset;
 
 #ifdef USE_MAC
+uniform bool drawMACX;
+uniform bool drawMACY;
+uniform bool drawMACZ;
+
 out vec4 finalColor;
 #else
 flat out vec4 finalColor;
@@ -154,27 +158,27 @@ void main()
 
   switch (gl_VertexID % 6) {
     case 0: /* tail of X component */
-      pos.x += -0.5 * cellSize.x;
+      pos.x += (drawMACX) ? -0.5 * cellSize.x : 0.0;
       color = vec3(1.0, 0.0, 0.0); /* red */
       break;
     case 1: /* head of X component */
-      pos.x += (-0.5 + vector.x * displaySize) * cellSize.x;
+      pos.x += (drawMACX) ? (-0.5 + vector.x * displaySize) * cellSize.x : 0.0;
       color = vec3(1.0, 1.0, 0.0); /* yellow */
       break;
     case 2: /* tail of Y component */
-      pos.y += -0.5 * cellSize.y;
+      pos.y += (drawMACY) ? -0.5 * cellSize.y : 0.0;
       color = vec3(0.0, 1.0, 0.0); /* green */
       break;
     case 3: /* head of Y component */
-      pos.y += (-0.5 + vector.y * displaySize) * cellSize.y;
+      pos.y += (drawMACY) ? (-0.5 + vector.y * displaySize) * cellSize.y : 0.0;
       color = vec3(1.0, 1.0, 0.0); /* yellow */
       break;
     case 4: /* tail of Z component */
-      pos.z += -0.5 * cellSize.z;
+      pos.z += (drawMACZ) ? -0.5 * cellSize.z : 0.0;
       color = vec3(0.0, 0.0, 1.0); /* blue */
       break;
     case 5: /* head of Z component */
-      pos.z += (-0.5 + vector.z * displaySize) * cellSize.z;
+      pos.z += (drawMACZ) ? (-0.5 + vector.z * displaySize) * cellSize.z : 0.0;
       color = vec3(1.0, 1.0, 0.0); /* yellow */
       break;
   }
diff --git a/source/blender/makesdna/DNA_fluid_types.h 
b/source/blender/makesdna/DNA_fluid_types.h
index f9ffd8efe29..ecabecbeb0c 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -94,6 +94,12 @@ enum {
   VECTOR_DRAW_MAC = 2,
 };
 
+enum {
+  VECTOR_DRAW_MAC_X = (1 << 0),
+  VECTOR_DRAW_MAC_Y = (1 << 1),
+  VECTOR_DRAW_MAC_Z = (1 << 2),
+};
+
 enum {
   VECTOR_DRAW_GRID_FLUID_VELOCITY = 0,
   VECTOR_DRAW_GRID_GUIDE_VELOCITY = 1,
@@ -646,23 +652,25 @@ typedef struct FluidDomainSettings {
   char vector_draw_type;
   char vector_draw_grid_type;
   char vector_scale_with_magnitude;
+  char vector_draw_mac_components;
   char use_coba;
   char coba_field; /* Simulation field used for the color mapping. */
   char interp_method;
   char gridlines_color_field; /* Simulation field used to color map onto 
gridlines. */
   char gridlines_cell_filter;
+  char _pad9[7];
 
   /* OpenVDB cache options. */
   int openvdb_compression;
   float clipping;
   char openvdb_data_depth;
-  char _pad9[7]; /* Unused. */
+  char _pad10[7]; /* Unused. */
 
   /* -- Deprecated / unsed options (below). -- */
 
   /* View options. */
   int viewsettings;
-  char _pad10[4]; /* Unused. */
+  char _pad11[4]; /* Unused. */
 
   /* Pointcache options. */
   /* Smoke uses only one cache from now on (index [0]), but keeping the array 
for now for reading
@@ -672,7 +680,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 3496e2bce09..8e44df0091e 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -2517,6 +2517,21 @@ static void rna_def_fluid_domain_settings(BlenderRNA 
*brna)
   RNA_def_property_ui_text(prop, "Magnitude", "Scale vectors with their 
magnitudes");
   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
 
+  prop = RNA_def_property(srna, "vector_show_mac_x", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "vector_draw_mac_components", 
VECTOR_DRAW_MAC_X);
+  RNA_def_property_ui_text(prop, "X", "Show X-component of MAC Grid");
+  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
+  prop = RNA_def_property(srna, "vector_show_mac_y", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "vector_draw_mac_components", 
VECTOR_DRAW_MAC_Y);
+  RNA_def_property_ui_text(prop, "Y", "Show Y-component of MAC Grid");
+  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
+  prop = RNA_def_property(srna, "vector_show_mac_z", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "vector_draw_mac_components", 
VECTOR_DRAW_MAC_Z);
+  RNA_def_property_ui_text(prop, "Z", "Show Z-component of MAC Grid");
+  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);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to