HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdTimeCode Class Reference

#include <timeCode.h>

Public Member Functions

constexpr UsdTimeCode (double t=0.0) noexcept
 Construct with optional time value. Impilicitly convert from double. More...
 
constexpr UsdTimeCode (const SdfTimeCode &timeCode) noexcept
 Construct and implicitly cast from SdfTimeCode. More...
 
bool IsEarliestTime () const
 
bool IsDefault () const
 
bool IsNumeric () const
 
double GetValue () const
 

Static Public Member Functions

static constexpr UsdTimeCode EarliestTime ()
 
static constexpr UsdTimeCode Default ()
 
static constexpr double SafeStep (double maxValue=1e6, double maxCompression=10.0)
 

Friends

bool operator== (const UsdTimeCode &lhs, const UsdTimeCode &rhs)
 Equality comparison. More...
 
bool operator!= (const UsdTimeCode &lhs, const UsdTimeCode &rhs)
 Inequality comparison. More...
 
bool operator< (const UsdTimeCode &lhs, const UsdTimeCode &rhs)
 
bool operator>= (const UsdTimeCode &lhs, const UsdTimeCode &rhs)
 
bool operator<= (const UsdTimeCode &lhs, const UsdTimeCode &rhs)
 
bool operator> (const UsdTimeCode &lhs, const UsdTimeCode &rhs)
 
size_t hash_value (const UsdTimeCode &time)
 Hash function. More...
 

Detailed Description

Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdTimeCode::Default().

A UsdTimeCode does not represent an SMPTE timecode, although we may, in future, support conversion functions between the two. Instead, UsdTimeCode is an abstraction that acknowledges that in the principal domains of use for USD, there are many different ways of encoding time, and USD must be able to capture and translate between all of them for interchange, retaining as much intent of the authoring application as possible.

A UsdTimeCode is therefore a unitless, generic time measurement that serves as the ordinate for time-sampled data in USD files. A client of USD relies on the UsdStage (which in turn consults metadata authored in its root layer) to define the mapping of TimeCodes to units like seconds and frames.

See Also
UsdStage::GetStartTimeCode()
UsdStage::GetEndTimeCode()
UsdStage::GetTimeCodesPerSecond()
UsdStage::GetFramesPerSecond()

As described in Usd_ValueResolution , USD optionally provides an unvarying, 'default' value for every attribute. UsdTimeCode embodies a time value that can either be a floating-point sample time, or the default.

All UsdAttribute and derived API that requires a time parameter defaults to UsdTimeCode::Default() if the parameter is left unspecified, and auto-constructs from a floating-point argument.

UsdTimeCode::EarliestTime() is provided to aid clients who wish to retrieve the first authored timesample for any attribute.

Definition at line 84 of file timeCode.h.

Constructor & Destructor Documentation

constexpr UsdTimeCode::UsdTimeCode ( double  t = 0.0)
inlinenoexcept

Construct with optional time value. Impilicitly convert from double.

Definition at line 87 of file timeCode.h.

constexpr UsdTimeCode::UsdTimeCode ( const SdfTimeCode timeCode)
inlinenoexcept

Construct and implicitly cast from SdfTimeCode.

Definition at line 90 of file timeCode.h.

Member Function Documentation

static constexpr UsdTimeCode UsdTimeCode::Default ( )
inlinestatic

Produce a UsdTimeCode representing the sentinel value for 'default'.

Note
In inequality comparisons, Default() is considered less than any numeric TimeCode, including EarliestTime(), indicative of the fact that in UsdAttribute value resolution, the sample at Default() (if any) is always weaker than any numeric timeSample in the same layer. For more information, see Usd_ValueResolution

Definition at line 112 of file timeCode.h.

static constexpr UsdTimeCode UsdTimeCode::EarliestTime ( )
inlinestatic

Produce a UsdTimeCode representing the lowest/earliest possible timeCode. Thus, for any given timeSample s, its time ordinate t will obey: t >= UsdTimeCode::EarliestTime()

This is useful for clients that wish to retrieve the first authored timeSample for an attribute, as they can use UsdTimeCode::EarliestTime() as the time argument to UsdAttribute::Get() and UsdAttribute::GetBracketingTimeSamples()

Definition at line 101 of file timeCode.h.

double UsdTimeCode::GetValue ( ) const
inline

Return the numeric value for this time. If this time IsDefault(), return a quiet NaN value.

Definition at line 151 of file timeCode.h.

bool UsdTimeCode::IsDefault ( ) const
inline

Return true if this time represents the 'default' sentinel value, false otherwise. This is equivalent to !IsNumeric().

Definition at line 139 of file timeCode.h.

bool UsdTimeCode::IsEarliestTime ( ) const
inline

Return true if this time represents the lowest/earliest possible timeCode, false otherwise.

Definition at line 133 of file timeCode.h.

bool UsdTimeCode::IsNumeric ( ) const
inline

Return true if this time represents a numeric value, false otherwise. This is equivalent to !IsDefault().

Definition at line 145 of file timeCode.h.

static constexpr double UsdTimeCode::SafeStep ( double  maxValue = 1e6,
double  maxCompression = 10.0 
)
inlinestatic

Produce a safe step value such that for any numeric UsdTimeCode t in [-maxValue, maxValue], t +/- (step / maxCompression) != t with a safety factor of 2. This is shorthand for std::numeric_limits<double>::epsilon() * maxValue * maxCompression * 2.0. Such a step value is recommended for simulating jump discontinuities in time samples. For example, author value x at time t, and value y at time t + SafeStep(). This ensures that as the sample times are shifted and scaled, t and t + SafeStep() remain distinct so long as they adhere to the maxValue and maxCompression limits.

Definition at line 126 of file timeCode.h.

Friends And Related Function Documentation

size_t hash_value ( const UsdTimeCode time)
friend

Hash function.

Definition at line 196 of file timeCode.h.

bool operator!= ( const UsdTimeCode lhs,
const UsdTimeCode rhs 
)
friend

Inequality comparison.

Definition at line 164 of file timeCode.h.

bool operator< ( const UsdTimeCode lhs,
const UsdTimeCode rhs 
)
friend

Less-than. Default() times are less than all numeric times, including EarliestTime()

Definition at line 170 of file timeCode.h.

bool operator<= ( const UsdTimeCode lhs,
const UsdTimeCode rhs 
)
friend

Less-equal. Default() times are less than all numeric times, including EarliestTime().

Definition at line 184 of file timeCode.h.

bool operator== ( const UsdTimeCode lhs,
const UsdTimeCode rhs 
)
friend

Equality comparison.

Definition at line 158 of file timeCode.h.

bool operator> ( const UsdTimeCode lhs,
const UsdTimeCode rhs 
)
friend

Greater-than. Default() times are less than all numeric times, including EarliestTime().

Definition at line 191 of file timeCode.h.

bool operator>= ( const UsdTimeCode lhs,
const UsdTimeCode rhs 
)
friend

Greater-equal. Default() times are less than all numeric times, including EarliestTime().

Definition at line 178 of file timeCode.h.


The documentation for this class was generated from the following file: