Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-09-07 22:59:07 +0300
committerHans Goudey <h.goudey@me.com>2020-09-07 22:59:07 +0300
commit36aeb0ec1e2ec8cd6a3690ac11cd3c50f3851802 (patch)
tree4c9ce5df6ba5cc01eb2e0841c57fd9b0e9690b11 /source/blender/makesrna
parentd4cca7b7b0d858a45c684fd0725344881e0c1c63 (diff)
UI: Add temperature units
Based on the original patch by Vaishnav S (@padthai), this adds support for temperature units. Initially supported units are Celsius, Kelvin, and Fahrenheit. The units aren't used anywhere with this commit. Those changes should happen in separate patches by adding PROP_TEMPERATURE to RNA property definitions. But it should be ensured that the various solvers and simulations actually properly use real units. The complexity of some of the changes comes from the fact that these units have offsets from each other as well as coefficients. This also makes the implementation in the current unit system troublesome. For example, entering 0C evaluates correctly to 273K, but 0C + 0C doubles that result, because each unit value is evaluated separately. This is quite hard to solve in the general case with Blender's current unit system, though, so it is not handled in this commit. Differential Revision: https://developer.blender.org/D4401
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_types.h4
-rw-r--r--source/blender/makesrna/intern/makesrna.c4
-rw-r--r--source/blender/makesrna/intern/rna_rna.c1
-rw-r--r--source/blender/makesrna/intern/rna_scene.c16
4 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index ee7c045ebf9..1c488b2cac1 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -91,6 +91,7 @@ typedef enum PropertyUnit {
PROP_UNIT_ACCELERATION = (8 << 16), /* m/(s^2) */
PROP_UNIT_CAMERA = (9 << 16), /* mm */
PROP_UNIT_POWER = (10 << 16), /* W */
+ PROP_UNIT_TEMPERATURE = (11 << 16), /* C */
} PropertyUnit;
#define RNA_SUBTYPE_UNIT(subtype) ((subtype)&0x00FF0000)
@@ -156,6 +157,9 @@ typedef enum PropertySubType {
/** Light */
PROP_POWER = 42 | PROP_UNIT_POWER,
+
+ /* temperature */
+ PROP_TEMPERATURE = 43 | PROP_UNIT_TEMPERATURE,
} PropertySubType;
/* Make sure enums are updated with these */
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 2b1e5b3c702..a81bd4d0832 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3199,6 +3199,8 @@ static const char *rna_property_subtypename(PropertySubType type)
return "PROP_PASSWORD";
case PROP_POWER:
return "PROP_POWER";
+ case PROP_TEMPERATURE:
+ return "PROP_TEMPERATURE";
default: {
/* in case we don't have a type preset that includes the subtype */
if (RNA_SUBTYPE_UNIT(type)) {
@@ -3236,6 +3238,8 @@ static const char *rna_property_subtype_unit(PropertySubType type)
return "PROP_UNIT_CAMERA";
case PROP_UNIT_POWER:
return "PROP_UNIT_POWER";
+ case PROP_UNIT_TEMPERATURE:
+ return "PROP_UNIT_TEMPERATURE";
default:
return "PROP_UNIT_UNKNOWN";
}
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 9f5440be9f8..c7076d6c631 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -117,6 +117,7 @@ const EnumPropertyItem rna_enum_property_unit_items[] = {
{PROP_UNIT_MASS, "MASS", 0, "Mass", ""},
{PROP_UNIT_CAMERA, "CAMERA", 0, "Camera", ""},
{PROP_UNIT_POWER, "POWER", 0, "Power", ""},
+ {PROP_UNIT_TEMPERATURE, "TEMPERATURE", 0, "Temperature", ""},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 65edaf0bcca..ab4ffda8888 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2568,6 +2568,15 @@ const EnumPropertyItem *rna_UnitSettings_time_unit_itemf(bContext *UNUSED(C),
return rna_UnitSettings_itemf_wrapper(units->system, B_UNIT_TIME, r_free);
}
+const EnumPropertyItem *rna_UnitSettings_temperature_unit_itemf(bContext *UNUSED(C),
+ PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop),
+ bool *r_free)
+{
+ UnitSettings *units = ptr->data;
+ return rna_UnitSettings_itemf_wrapper(units->system, B_UNIT_TEMPERATURE, r_free);
+}
+
static void rna_UnitSettings_system_update(Main *UNUSED(bmain),
Scene *scene,
PointerRNA *UNUSED(ptr))
@@ -3906,6 +3915,13 @@ static void rna_def_unit_settings(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_UnitSettings_time_unit_itemf");
RNA_def_property_ui_text(prop, "Time Unit", "Unit that will be used to display time values");
RNA_def_property_update(prop, NC_WINDOW, NULL);
+
+ prop = RNA_def_property(srna, "temperature_unit", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items);
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_UnitSettings_temperature_unit_itemf");
+ RNA_def_property_ui_text(
+ prop, "Temperature Unit", "Unit that will be used to display temperature values");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
}
static void rna_def_view_layer_eevee(BlenderRNA *brna)