[Bf-blender-cvs] [c6c49257710] master: Fluid: Added domain check for new OpenVDB precision 'Mini' type

Sebastián Barschkis noreply at git.blender.org
Mon Oct 19 21:58:54 CEST 2020


Commit: c6c49257710c4c7976601de54bcddc45eb9ee206
Author: Sebastián Barschkis
Date:   Mon Oct 19 21:40:04 2020 +0200
Branches: master
https://developer.blender.org/rBc6c49257710c4c7976601de54bcddc45eb9ee206

Fluid: Added domain check for new OpenVDB precision 'Mini' type

Precision 'Mini' should only be available for liquids domains.

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

M	source/blender/blenkernel/BKE_fluid.h
M	source/blender/blenkernel/intern/fluid.c
M	source/blender/makesrna/intern/rna_fluid.c

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

diff --git a/source/blender/blenkernel/BKE_fluid.h b/source/blender/blenkernel/BKE_fluid.h
index 87e1c7a57ed..33ff6943514 100644
--- a/source/blender/blenkernel/BKE_fluid.h
+++ b/source/blender/blenkernel/BKE_fluid.h
@@ -93,7 +93,7 @@ void BKE_fluid_flow_type_set(struct Object *object, struct FluidFlowSettings *se
 void BKE_fluid_effector_type_set(struct Object *object,
                                  struct FluidEffectorSettings *settings,
                                  int type);
-void BKE_fluid_coba_field_sanitize(struct FluidDomainSettings *settings);
+void BKE_fluid_fields_sanitize(struct FluidDomainSettings *settings);
 void BKE_fluid_flow_behavior_set(struct Object *object,
                                  struct FluidFlowSettings *settings,
                                  int behavior);
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 7392c9161b8..f66ba428611 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4683,24 +4683,31 @@ void BKE_fluid_effector_type_set(Object *UNUSED(object), FluidEffectorSettings *
   settings->type = type;
 }
 
-void BKE_fluid_coba_field_sanitize(FluidDomainSettings *settings)
+void BKE_fluid_fields_sanitize(FluidDomainSettings *settings)
 {
-  /* Based on the domain type, the coba field is defaulted accordingly if the selected field
+  /* Based on the domain type, certain fields are defaulted accordingly if the selected field
    * is unsupported. */
-  const char field = settings->coba_field;
+  const char coba_field = settings->coba_field;
+  const char data_depth = settings->openvdb_data_depth;
 
   if (settings->type == FLUID_DOMAIN_TYPE_GAS) {
-    if (field == FLUID_DOMAIN_FIELD_PHI || field == FLUID_DOMAIN_FIELD_PHI_IN ||
-        field == FLUID_DOMAIN_FIELD_PHI_OUT || field == FLUID_DOMAIN_FIELD_PHI_OBSTACLE) {
+    if (coba_field == FLUID_DOMAIN_FIELD_PHI || coba_field == FLUID_DOMAIN_FIELD_PHI_IN ||
+        coba_field == FLUID_DOMAIN_FIELD_PHI_OUT ||
+        coba_field == FLUID_DOMAIN_FIELD_PHI_OBSTACLE) {
       /* Defaulted to density for gas domain. */
       settings->coba_field = FLUID_DOMAIN_FIELD_DENSITY;
     }
+
+    /* Gas domains do not support vdb mini precision. */
+    if (data_depth == VDB_PRECISION_MINI_FLOAT) {
+      settings->openvdb_data_depth = VDB_PRECISION_HALF_FLOAT;
+    }
   }
   else if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) {
-    if (field == FLUID_DOMAIN_FIELD_COLOR_R || field == FLUID_DOMAIN_FIELD_COLOR_G ||
-        field == FLUID_DOMAIN_FIELD_COLOR_B || field == FLUID_DOMAIN_FIELD_DENSITY ||
-        field == FLUID_DOMAIN_FIELD_FLAME || field == FLUID_DOMAIN_FIELD_FUEL ||
-        field == FLUID_DOMAIN_FIELD_HEAT) {
+    if (coba_field == FLUID_DOMAIN_FIELD_COLOR_R || coba_field == FLUID_DOMAIN_FIELD_COLOR_G ||
+        coba_field == FLUID_DOMAIN_FIELD_COLOR_B || coba_field == FLUID_DOMAIN_FIELD_DENSITY ||
+        coba_field == FLUID_DOMAIN_FIELD_FLAME || coba_field == FLUID_DOMAIN_FIELD_FUEL ||
+        coba_field == FLUID_DOMAIN_FIELD_HEAT) {
       /* Defaulted to phi for liquid domain. */
       settings->coba_field = FLUID_DOMAIN_FIELD_PHI;
     }
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index ad117933764..84187786c46 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -665,12 +665,205 @@ static void rna_Fluid_cache_directory_set(struct PointerRNA *ptr, const char *va
   // settings->cache_flag = 0;
 }
 
+static const EnumPropertyItem *rna_Fluid_cobafield_itemf(bContext *UNUSED(C),
+                                                         PointerRNA *ptr,
+                                                         PropertyRNA *UNUSED(prop),
+                                                         bool *r_free)
+{
+  FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
+
+  EnumPropertyItem *item = NULL;
+  EnumPropertyItem tmp = {0, "", 0, "", ""};
+  int totitem = 0;
+
+  tmp.value = FLUID_DOMAIN_FIELD_FLAGS;
+  tmp.identifier = "FLAGS";
+  tmp.icon = 0;
+  tmp.name = "Flags";
+  tmp.description = "Flag grid of the fluid domain";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  tmp.value = FLUID_DOMAIN_FIELD_PRESSURE;
+  tmp.identifier = "PRESSURE";
+  tmp.icon = 0;
+  tmp.name = "Pressure";
+  tmp.description = "Pressure field of the fluid domain";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_X;
+  tmp.identifier = "VELOCITY_X";
+  tmp.icon = 0;
+  tmp.name = "X Velocity";
+  tmp.description = "X component of the velocity field";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_Y;
+  tmp.identifier = "VELOCITY_Y";
+  tmp.icon = 0;
+  tmp.name = "Y Velocity";
+  tmp.description = "Y component of the velocity field";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_Z;
+  tmp.identifier = "VELOCITY_Z";
+  tmp.icon = 0;
+  tmp.name = "Z Velocity";
+  tmp.description = "Z component of the velocity field";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  tmp.value = FLUID_DOMAIN_FIELD_FORCE_X;
+  tmp.identifier = "FORCE_X";
+  tmp.icon = 0;
+  tmp.name = "X Force";
+  tmp.description = "X component of the force field";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  tmp.value = FLUID_DOMAIN_FIELD_FORCE_Y;
+  tmp.identifier = "FORCE_Y";
+  tmp.icon = 0;
+  tmp.name = "Y Force";
+  tmp.description = "Y component of the force field";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  tmp.value = FLUID_DOMAIN_FIELD_FORCE_Z;
+  tmp.identifier = "FORCE_Z";
+  tmp.icon = 0;
+  tmp.name = "Z Force";
+  tmp.description = "Z component of the force field";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  if (settings->type == FLUID_DOMAIN_TYPE_GAS) {
+    tmp.value = FLUID_DOMAIN_FIELD_COLOR_R;
+    tmp.identifier = "COLOR_R";
+    tmp.icon = 0;
+    tmp.name = "Red";
+    tmp.description = "Red component of the color field";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_COLOR_G;
+    tmp.identifier = "COLOR_G";
+    tmp.icon = 0;
+    tmp.name = "Green";
+    tmp.description = "Green component of the color field";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_COLOR_B;
+    tmp.identifier = "COLOR_B";
+    tmp.icon = 0;
+    tmp.name = "Blue";
+    tmp.description = "Blue component of the color field";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_DENSITY;
+    tmp.identifier = "DENSITY";
+    tmp.icon = 0;
+    tmp.name = "Density";
+    tmp.description = "Quantity of soot in the fluid";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_FLAME;
+    tmp.identifier = "FLAME";
+    tmp.icon = 0;
+    tmp.name = "Flame";
+    tmp.description = "Flame field";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_FUEL;
+    tmp.identifier = "FUEL";
+    tmp.icon = 0;
+    tmp.name = "Fuel";
+    tmp.description = "Fuel field";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_HEAT;
+    tmp.identifier = "HEAT";
+    tmp.icon = 0;
+    tmp.name = "Heat";
+    tmp.description = "Temperature of the fluid";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+  }
+  else if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) {
+    tmp.value = FLUID_DOMAIN_FIELD_PHI;
+    tmp.identifier = "PHI";
+    tmp.icon = 0;
+    tmp.name = "Fluid Levelset";
+    tmp.description = "Levelset representation of the fluid";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_PHI_IN;
+    tmp.identifier = "PHI_IN";
+    tmp.icon = 0;
+    tmp.name = "Inflow Levelset";
+    tmp.description = "Levelset representation of the inflow";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_PHI_OUT;
+    tmp.identifier = "PHI_OUT";
+    tmp.icon = 0;
+    tmp.name = "Outflow Levelset";
+    tmp.description = "Levelset representation of the outflow";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+
+    tmp.value = FLUID_DOMAIN_FIELD_PHI_OBSTACLE;
+    tmp.identifier = "PHI_OBSTACLE";
+    tmp.icon = 0;
+    tmp.name = "Obstacle Levelset";
+    tmp.description = "Levelset representation of the obstacles";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+  }
+
+  RNA_enum_item_end(&item, &totitem);
+  *r_free = true;
+
+  return item;
+}
+
+static const EnumPropertyItem *rna_Fluid_data_depth_itemf(bContext *UNUSED(C),
+                                                          PointerRNA *ptr,
+                                                          PropertyRNA *UNUSED(prop),
+                                                          bool *r_free)
+{
+  FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
+
+  EnumPropertyItem *item = NULL;
+  EnumPropertyItem tmp = {0, "", 0, "", ""};
+  int totitem = 0;
+
+  tmp.value = VDB_PRECISION_FULL_FLOAT;
+  tmp.identifier = "32";
+  tmp.icon = 0;
+  tmp.name = "Full";
+  tmp.description = "Full float (Use 32 bit for all data)";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  tmp.value = VDB_PRECISION_HALF_FLOAT;
+  tmp.identifier = "16";
+  tmp.icon = 0;
+  tmp.name = "Half";
+  tmp.description = "Half float (Use 16 bit for all data)";
+  RNA_enum_item_add(&item, &totitem, &tmp);
+
+  if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) {
+    tmp.value = VDB_PRECISION_MINI_FLOAT;
+    tmp.identifier = "8";
+    tmp.icon = 0;
+    tmp.name = "Mini";
+    tmp.description = "Mini float (Use 8 bit where possible, otherwise use 16 bit)";
+    RNA_enum_item_add(&item, &totitem, &tmp);
+  }
+
+  RNA_enum_item_end(&item, &totitem);
+  *r_free = true;
+
+  return item;
+}
+
 static void rna_Fluid_domaintype_set(struct PointerRNA *ptr, int value)
 {
   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
   Object *ob = (Object *)ptr->owner_id;
   BKE_fluid_domain_type_set(ob, settings, value);
-  BKE_fluid_coba_field_sanitize(settings);
+  BKE_fluid_fields_sanitize(settings);
 }
 
 static char *rna_FluidDomain

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list