HDK
|
#include <sparseValueWriter.h>
Public Member Functions | |
USDUTILS_API | UsdUtilsSparseAttrValueWriter (const UsdAttribute &attr, const VtValue &defaultValue=VtValue()) |
USDUTILS_API | UsdUtilsSparseAttrValueWriter (const UsdAttribute &attr, VtValue *defaultValue) |
USDUTILS_API bool | SetTimeSample (const VtValue &value, const UsdTimeCode time) |
USDUTILS_API bool | SetTimeSample (VtValue *value, const UsdTimeCode time) |
const UsdAttribute & | GetAttr () const |
Returns the attribute that's held in the sparse value writer. More... | |
A utility class for authoring time-varying attribute values with simple run-length encoding, by skipping any redundant time-samples. Time-samples that are close enough to each other, with relative difference smaller than a fixed epsilon value are considered to be equivalent. This is to avoid unnecessary authoring of time-samples caused by numerical fuzz in certain computations.
For vectors, matrices, and other composite types (like quaternions and arrays), each component is compared with the corresponding component for closeness. The chosen epsilon value for double precision floating point numbers is 1e-12. For single-precision, it is 1e-6 and for half-precision, it is 1e-2.
Example c++ usage:
Equivalent python example:
In the above examples, the specified default value of radius (1.0) will not be authored into scene description since it matches the fallback value. Additionally, the time-sample authored at time=2.0 will be skipped since it is redundant. Also note that for correct behavior, the calls to SetTimeSample() must be made with sequentially increasing time values. If not, a coding error is issued and the authored animation may be incorrect.
Definition at line 88 of file sparseValueWriter.h.
USDUTILS_API UsdUtilsSparseAttrValueWriter::UsdUtilsSparseAttrValueWriter | ( | const UsdAttribute & | attr, |
const VtValue & | defaultValue = VtValue() |
||
) |
The constructor initializes the data required for run-length encoding of time-samples. It also sets the default value of attr
to defaultValue
, if defaultValue
is non-empty and different from the existing default value of attr
.
defaultValue
can be unspecified (or left empty) if you don't care about authoring a default value. In this case, the sparse authoring logic is initialized with the existing authored default value or the fallback value, if attr
has one.
USDUTILS_API UsdUtilsSparseAttrValueWriter::UsdUtilsSparseAttrValueWriter | ( | const UsdAttribute & | attr, |
VtValue * | defaultValue | ||
) |
The constructor initializes the data required for run-length encoding of time-samples. It also sets the default value of attr
to defaultValue
, if defaultValue
is non-empty and different from the existing default value of attr
.
It defaultValue
is null or points to an empty VtValue, the sparse authoring logic is initialized with the existing authored default value or the fallback value, if attr
has one.
For efficiency, this function swaps out the given defaultValue
, leaving it empty.
|
inline |
Returns the attribute that's held in the sparse value writer.
Definition at line 139 of file sparseValueWriter.h.
USDUTILS_API bool UsdUtilsSparseAttrValueWriter::SetTimeSample | ( | const VtValue & | value, |
const UsdTimeCode | time | ||
) |
Sets a new time-sample on the attribute with given value
at the given time
. The time-sample is only authored if it's different from the previously set time-sample, in which case the previous time-sample is also authored, in order to to end the previous run of contiguous identical values and start a new run.
This incurs a copy of value
. Also, the value will be held in memory at least until the next time-sample is written or until the SparseAttrValueWriter instance is destroyed.
USDUTILS_API bool UsdUtilsSparseAttrValueWriter::SetTimeSample | ( | VtValue * | value, |
const UsdTimeCode | time | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
For efficiency, this function swaps out the given value
, leaving it empty. The value will be held in memory at least until the next time-sample is written or until the SparseAttrValueWriter instance is destroyed.