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
This commit is contained in:
parent
5304c6ed7d
commit
5fa6cdb77a
Notes:
blender-bot
2023-02-13 15:31:06 +01:00
Referenced by commit ec66b3ef9b
, Fix issues with absolute time unit
Referenced by issue #97927, bpy.utils.units.to_string uses wrong units for velocity, acceleration, lens length, and power
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -10831,6 +10831,8 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
|
|||
brna, "NodeSocketFloatAngle", "NodeSocketInterfaceFloatAngle", PROP_ANGLE);
|
||||
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);
|
||||
|
||||
|
|
|
@ -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", ""},
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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", ""},
|
||||
|
|
Loading…
Reference in New Issue