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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-02-08 14:31:28 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-02-17 18:23:00 +0300
commitce5d079a490841ea52736dacf418357a9bbc5923 (patch)
treed6726cb0cb63e59f350fc46ca7d6d0ad3a1148f1 /source/blender/makesrna
parent6c24de95c0f3af084c2314f2ff9443efba675453 (diff)
Units: add support for light power units in Watt. Use for Eevee lights.
This affects point, spot and area lights. Sun light strength remains without a unit. This change does not affect .blend file compatibility in any way, as with the rest of the unit system it's purely a display and editing feature. Not used for Cycles yet, that will be done after unifying the settings with Eevee.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_types.h4
-rw-r--r--source/blender/makesrna/intern/makesrna.c2
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c44
-rw-r--r--source/blender/makesrna/intern/rna_rna.c1
4 files changed, 40 insertions, 11 deletions
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 1742e8b8795..a02bf644620 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -90,6 +90,7 @@ typedef enum PropertyUnit {
PROP_UNIT_VELOCITY = (7 << 16), /* m/s */
PROP_UNIT_ACCELERATION = (8 << 16), /* m/(s^2) */
PROP_UNIT_CAMERA = (9 << 16), /* mm */
+ PROP_UNIT_POWER = (10 << 16), /* W */
} PropertyUnit;
#define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
@@ -146,6 +147,9 @@ typedef enum PropertySubType {
/* booleans */
PROP_LAYER = 40,
PROP_LAYER_MEMBER = 41,
+
+ /* light */
+ PROP_POWER = 42 | PROP_UNIT_POWER,
} 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 7230b65738b..df8911f425c 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2579,6 +2579,7 @@ static const char *rna_property_subtypename(PropertySubType type)
case PROP_LAYER: return "PROP_LAYER";
case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER";
case PROP_PASSWORD: return "PROP_PASSWORD";
+ case PROP_POWER: return "PROP_POWER";
default:
{
/* in case we don't have a type preset that includes the subtype */
@@ -2605,6 +2606,7 @@ static const char *rna_property_subtype_unit(PropertySubType type)
case PROP_UNIT_VELOCITY: return "PROP_UNIT_VELOCITY";
case PROP_UNIT_ACCELERATION: return "PROP_UNIT_ACCELERATION";
case PROP_UNIT_CAMERA: return "PROP_UNIT_CAMERA";
+ case PROP_UNIT_POWER: return "PROP_UNIT_POWER";
default: return "PROP_UNIT_UNKNOWN";
}
}
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index dc82e8b28f8..c15186399e7 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -137,12 +137,6 @@ static void rna_def_light(BlenderRNA *brna)
"Falloff distance - the light is at half the original intensity at this point");
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
- prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_default(prop, 10.0f);
- RNA_def_property_ui_range(prop, 0, 1000000.0f, 1, 3);
- RNA_def_property_ui_text(prop, "Energy", "Amount of light emitted");
- RNA_def_property_update(prop, 0, "rna_Light_draw_update");
-
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "r");
RNA_def_property_array(prop, 3);
@@ -187,6 +181,30 @@ static void rna_def_light(BlenderRNA *brna)
rna_def_animdata_common(srna);
}
+static void rna_def_light_energy(StructRNA *srna, bool distant)
+{
+ PropertyRNA *prop;
+
+ if(distant) {
+ /* Distant light strength has no unit defined, it's proportional to
+ * Watt/m^2 and is not sensitive to scene unit scale. */
+ prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_default(prop, 10.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
+ RNA_def_property_ui_text(prop, "Strength", "Amount of light emitted");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
+ }
+ else {
+ /* Lights with a location have power in Watt, which is sensitive to
+ * scene unit scale. */
+ prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_POWER);
+ RNA_def_property_float_default(prop, 10.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1000000.0f, 1, 5);
+ RNA_def_property_ui_text(prop, "Power", "Amount of light emitted");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
+ }
+}
+
static void rna_def_light_falloff(StructRNA *srna)
{
PropertyRNA *prop;
@@ -245,7 +263,7 @@ static void rna_def_light_falloff(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
}
-static void rna_def_light_shadow(StructRNA *srna, int sun)
+static void rna_def_light_shadow(StructRNA *srna, bool sun)
{
PropertyRNA *prop;
@@ -405,8 +423,9 @@ static void rna_def_point_light(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Point Light", "Omnidirectional point Light");
RNA_def_struct_ui_icon(srna, ICON_LIGHT_POINT);
+ rna_def_light_energy(srna, false);
rna_def_light_falloff(srna);
- rna_def_light_shadow(srna, 0);
+ rna_def_light_shadow(srna, false);
}
static void rna_def_area_light(BlenderRNA *brna)
@@ -427,7 +446,8 @@ static void rna_def_area_light(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Area Light", "Directional area Light");
RNA_def_struct_ui_icon(srna, ICON_LIGHT_AREA);
- rna_def_light_shadow(srna, 0);
+ rna_def_light_energy(srna, false);
+ rna_def_light_shadow(srna, false);
rna_def_light_falloff(srna);
prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
@@ -464,8 +484,9 @@ static void rna_def_spot_light(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Spot Light", "Directional cone Light");
RNA_def_struct_ui_icon(srna, ICON_LIGHT_SPOT);
+ rna_def_light_energy(srna, false);
rna_def_light_falloff(srna);
- rna_def_light_shadow(srna, 0);
+ rna_def_light_shadow(srna, false);
prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE);
@@ -502,7 +523,8 @@ static void rna_def_sun_light(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Sun Light", "Constant direction parallel ray Light");
RNA_def_struct_ui_icon(srna, ICON_LIGHT_SUN);
- rna_def_light_shadow(srna, 1);
+ rna_def_light_energy(srna, true);
+ rna_def_light_shadow(srna, true);
}
void RNA_def_light(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 594d947b996..6af3e30f1ab 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -116,6 +116,7 @@ const EnumPropertyItem rna_enum_property_unit_items[] = {
{PROP_UNIT_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""},
{PROP_UNIT_MASS, "MASS", 0, "Mass", ""},
{PROP_UNIT_CAMERA, "CAMERA", 0, "Camera", ""},
+ {PROP_UNIT_POWER, "POWER", 0, "Power", ""},
{0, NULL, 0, NULL, NULL},
};