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:
authorSergey Sharybin <sergey.vfx@gmail.com>2021-06-08 12:50:19 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2021-06-10 13:15:59 +0300
commit5fa6cdb77a9860ce673f685fd29e11b1c3ee8ad8 (patch)
tree9f5fcc26cf0f1893054183db59bf7e5379450b02
parent5304c6ed7d6288ac40bbc79391668c397e30afb8 (diff)
Add unit for time stored in seconds
Allows to define properties which will have proper units displayed in the interface. The internal storage is expected to be seconds (which matches how other times are stored in Blender). Is not immediately used in Blender, but is required for the upcoming feature in Cycles X (D11526) The naming does not sound very exciting, but can't think of anything better either. For test it probably easiest to define FloatProperty with subdtype of TIME_ABSOLUTE. Differential Revision: https://developer.blender.org/D11532
-rw-r--r--source/blender/blenkernel/BKE_unit.h13
-rw-r--r--source/blender/blenkernel/intern/node.cc4
-rw-r--r--source/blender/blenkernel/intern/unit.c5
-rw-r--r--source/blender/makesrna/RNA_types.h24
-rw-r--r--source/blender/makesrna/intern/makesrna.c4
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c2
-rw-r--r--source/blender/makesrna/intern/rna_rna.c11
-rw-r--r--source/blender/nodes/intern/node_socket.cc1
-rw-r--r--source/blender/python/intern/bpy_props.c12
9 files changed, 56 insertions, 20 deletions
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index c4af9ab40e2..b28215a72d1 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -82,12 +82,13 @@ enum {
B_UNIT_MASS = 4,
B_UNIT_ROTATION = 5,
B_UNIT_TIME = 6,
- B_UNIT_VELOCITY = 7,
- B_UNIT_ACCELERATION = 8,
- B_UNIT_CAMERA = 9,
- B_UNIT_POWER = 10,
- B_UNIT_TEMPERATURE = 11,
- B_UNIT_TYPE_TOT = 12,
+ B_UNIT_TIME_ABSOLUTE = 7,
+ B_UNIT_VELOCITY = 8,
+ B_UNIT_ACCELERATION = 9,
+ B_UNIT_CAMERA = 10,
+ B_UNIT_POWER = 11,
+ B_UNIT_TEMPERATURE = 12,
+ B_UNIT_TYPE_TOT = 13,
};
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 8d8f7b90d3b..f4e78859749 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -1662,6 +1662,8 @@ const char *nodeStaticSocketType(int type, int subtype)
return "NodeSocketFloatAngle";
case PROP_TIME:
return "NodeSocketFloatTime";
+ case PROP_TIME_ABSOLUTE:
+ return "NodeSocketFloatTimeAbsolute";
case PROP_DISTANCE:
return "NodeSocketFloatDistance";
case PROP_NONE:
@@ -1737,6 +1739,8 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype)
return "NodeSocketInterfaceFloatAngle";
case PROP_TIME:
return "NodeSocketInterfaceFloatTime";
+ case PROP_TIME_ABSOLUTE:
+ return "NodeSocketInterfaceFloatTimeAbsolute";
case PROP_DISTANCE:
return "NodeSocketInterfaceFloatDistance";
case PROP_NONE:
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 3612a26315c..5cf76bb6452 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -358,6 +358,7 @@ static const struct bUnitCollection *bUnitSystems[][B_UNIT_TYPE_TOT] = {
NULL,
&buNaturalRotCollection,
&buNaturalTimeCollection,
+ &buNaturalTimeCollection,
NULL,
NULL,
NULL,
@@ -371,6 +372,7 @@ static const struct bUnitCollection *bUnitSystems[][B_UNIT_TYPE_TOT] = {
&buMetricMassCollection,
&buNaturalRotCollection,
&buNaturalTimeCollection,
+ &buNaturalTimeCollection,
&buMetricVelCollection,
&buMetricAclCollection,
&buCameraLenCollection,
@@ -384,12 +386,13 @@ static const struct bUnitCollection *bUnitSystems[][B_UNIT_TYPE_TOT] = {
&buImperialMassCollection,
&buNaturalRotCollection,
&buNaturalTimeCollection,
+ &buNaturalTimeCollection,
&buImperialVelCollection,
&buImperialAclCollection,
&buCameraLenCollection,
&buPowerCollection,
&buImperialTempCollection},
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
};
static const bUnitCollection *unit_get_system(int system, int type)
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 4a6d6dddec7..8e1cfafcc42 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -82,17 +82,18 @@ typedef enum PropertyType {
/* also update rna_property_subtype_unit when you change this */
typedef enum PropertyUnit {
PROP_UNIT_NONE = (0 << 16),
- PROP_UNIT_LENGTH = (1 << 16), /* m */
- PROP_UNIT_AREA = (2 << 16), /* m^2 */
- PROP_UNIT_VOLUME = (3 << 16), /* m^3 */
- PROP_UNIT_MASS = (4 << 16), /* kg */
- PROP_UNIT_ROTATION = (5 << 16), /* radians */
- PROP_UNIT_TIME = (6 << 16), /* frame */
- 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 */
- PROP_UNIT_TEMPERATURE = (11 << 16), /* C */
+ PROP_UNIT_LENGTH = (1 << 16), /* m */
+ PROP_UNIT_AREA = (2 << 16), /* m^2 */
+ PROP_UNIT_VOLUME = (3 << 16), /* m^3 */
+ PROP_UNIT_MASS = (4 << 16), /* kg */
+ PROP_UNIT_ROTATION = (5 << 16), /* radians */
+ PROP_UNIT_TIME = (6 << 16), /* frame */
+ PROP_UNIT_TIME_ABSOLUTE = (7 << 16), /* time in seconds (independent of scene) */
+ PROP_UNIT_VELOCITY = (8 << 16), /* m/s */
+ PROP_UNIT_ACCELERATION = (9 << 16), /* m/(s^2) */
+ PROP_UNIT_CAMERA = (10 << 16), /* mm */
+ PROP_UNIT_POWER = (11 << 16), /* W */
+ PROP_UNIT_TEMPERATURE = (12 << 16), /* C */
} PropertyUnit;
/**
@@ -157,6 +158,7 @@ typedef enum PropertySubType {
PROP_FACTOR = 15,
PROP_ANGLE = 16 | PROP_UNIT_ROTATION,
PROP_TIME = 17 | PROP_UNIT_TIME,
+ PROP_TIME_ABSOLUTE = 17 | PROP_UNIT_TIME_ABSOLUTE,
/** Distance in 3d space, don't use for pixel distance for eg. */
PROP_DISTANCE = 18 | PROP_UNIT_LENGTH,
PROP_DISTANCE_CAMERA = 19 | PROP_UNIT_CAMERA,
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index efe12114d55..7a9cfa79324 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3201,6 +3201,8 @@ static const char *rna_property_subtypename(PropertySubType type)
return "PROP_ANGLE";
case PROP_TIME:
return "PROP_TIME";
+ case PROP_TIME_ABSOLUTE:
+ return "PROP_TIME_ABSOLUTE";
case PROP_DISTANCE:
return "PROP_DISTANCE";
case PROP_DISTANCE_CAMERA:
@@ -3266,6 +3268,8 @@ static const char *rna_property_subtype_unit(PropertySubType type)
return "PROP_UNIT_ROTATION";
case PROP_UNIT_TIME:
return "PROP_UNIT_TIME";
+ case PROP_UNIT_TIME_ABSOLUTE:
+ return "PROP_UNIT_TIME_ABSOLUTE";
case PROP_UNIT_VELOCITY:
return "PROP_UNIT_VELOCITY";
case PROP_UNIT_ACCELERATION:
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 2bafbd57e11..6a38a22f9b2 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -10832,6 +10832,8 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
rna_def_node_socket_float(
brna, "NodeSocketFloatTime", "NodeSocketInterfaceFloatTime", PROP_TIME);
rna_def_node_socket_float(
+ brna, "NodeSocketFloatTimeAbsolute", "NodeSocketInterfaceFloatTimeAbsolute", PROP_TIME_ABSOLUTE);
+ rna_def_node_socket_float(
brna, "NodeSocketFloatDistance", "NodeSocketInterfaceFloatDistance", PROP_DISTANCE);
rna_def_node_socket_int(brna, "NodeSocketInt", "NodeSocketInterfaceInt", PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index f7a7b745493..9e7d0f99dfa 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -81,7 +81,16 @@ const EnumPropertyItem rna_enum_property_subtype_items[] = {
{PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""},
{PROP_FACTOR, "FACTOR", 0, "Factor", ""},
{PROP_ANGLE, "ANGLE", 0, "Angle", ""},
- {PROP_TIME, "TIME", 0, "Time", ""},
+ {PROP_TIME,
+ "TIME",
+ 0,
+ "Time (Scene Relative)",
+ "Time specified in frames, converted to seconds based on scene frame rate"},
+ {PROP_TIME_ABSOLUTE,
+ "TIME_ABSOLUTE",
+ 0,
+ "Time (Absolute)",
+ "Time specified in seconds, independent of the scene"},
{PROP_DISTANCE, "DISTANCE", 0, "Distance", ""},
{PROP_DISTANCE_CAMERA, "DISTANCE_CAMERA", 0, "Camera Distance", ""},
{PROP_POWER, "POWER", 0, "Power", ""},
diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc
index 052896d2f48..d00bf636e15 100644
--- a/source/blender/nodes/intern/node_socket.cc
+++ b/source/blender/nodes/intern/node_socket.cc
@@ -727,6 +727,7 @@ void register_standard_node_socket_types(void)
nodeRegisterSocketType(make_socket_type_float(PROP_FACTOR));
nodeRegisterSocketType(make_socket_type_float(PROP_ANGLE));
nodeRegisterSocketType(make_socket_type_float(PROP_TIME));
+ nodeRegisterSocketType(make_socket_type_float(PROP_TIME_ABSOLUTE));
nodeRegisterSocketType(make_socket_type_float(PROP_DISTANCE));
nodeRegisterSocketType(make_socket_type_int(PROP_NONE));
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index c21c635913f..6ad80f9160b 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -147,7 +147,17 @@ static const EnumPropertyItem property_subtype_number_items[] = {
{PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""},
{PROP_FACTOR, "FACTOR", 0, "Factor", ""},
{PROP_ANGLE, "ANGLE", 0, "Angle", ""},
- {PROP_TIME, "TIME", 0, "Time", ""},
+ {PROP_TIME,
+ "TIME",
+ 0,
+ "Time (Scene Relative)",
+ "Time specified in frames, converted to seconds based on scene frame rate"},
+ {PROP_TIME_ABSOLUTE,
+ "TIME_ABSOLUTE",
+ 0,
+ "Time (Absolute)",
+ "Time specified in seconds, independent of the scene"},
+ {PROP_TIME_ABSOLUTE, "TIME_ABSOLUTE", 0, "Time Absolute", ""},
{PROP_DISTANCE, "DISTANCE", 0, "Distance", ""},
{PROP_DISTANCE_CAMERA, "DISTANCE_CAMERA", 0, "Camera Distance", ""},
{PROP_POWER, "POWER", 0, "Power", ""},