24 #ifndef PXR_IMAGING_HD_TIME_SAMPLE_ARRAY_H
25 #define PXR_IMAGING_HD_TIME_SAMPLE_ARRAY_H
30 #include "pxr/base/vt/array.h"
43 return GfLerp(alpha, v0, v1);
52 return GfSlerp(
double(alpha), v0, v1);
62 for (
size_t i=0; i <
r.size(); ++i) {
83 if (numSamples == 0) {
101 }
else if (i == numSamples) {
103 return vs[numSamples-1];
104 }
else if (us[i] == us[i-1]) {
107 TF_WARN(
"HdResampleRawTimeSamples: overlapping samples at %f; "
108 "using first sample", us[i]);
112 float alpha = (u-us[i-1]) / (us[i]-us[i-1]);
121 template <
typename T>
127 const VtIntArray *is)
129 if (numSamples == 0) {
131 return std::pair<T, VtIntArray>(
T(), VtIntArray(0));
138 return std::pair<T, VtIntArray>(vs[i], is[i]);
146 return std::pair<T, VtIntArray>(vs[0], is[0]);
147 }
else if (i == numSamples) {
149 return std::pair<T, VtIntArray>(vs[numSamples-1], is[numSamples-1]);
150 }
else if (us[i] == us[i-1]) {
153 TF_WARN(
"HdResampleRawTimeSamples: overlapping samples at %f; "
154 "using first sample", us[i]);
155 return std::pair<T, VtIntArray>(vs[i-1], is[i-1]);
159 float alpha = (us[i]-u) / (us[i]-us[i-1]);
160 return std::pair<T, VtIntArray>(
171 template<
typename TYPE,
unsigned int CAPACITY>
194 virtual void Resize(
unsigned int newSize) {
214 for (
size_t i=0; i < box.
count; ++i) {
215 if (box.
values[i].template IsHolding<TYPE>() &&
216 box.
values[i].GetArraySize() > 0) {
233 template<
typename TYPE,
unsigned int CAPACITY>
255 void Resize(
unsigned int newSize)
override {
276 for (
size_t i=0; i < box.
count; ++i) {
277 if (box.
values[i].template IsHolding<TYPE>() &&
278 box.
values[i].GetArraySize() > 0) {
293 #endif // PXR_IMAGING_HD_TIME_SAMPLE_ARRAY_H
void resize(size_type newSize, const value_type &v=value_type())
GLsizei GLenum const void * indices
HdTimeSampleArray(const HdTimeSampleArray &rhs)
TfSmallVector< float, CAPACITY > times
PXR_NAMESPACE_OPEN_SCOPE T HdResampleNeighbors(float alpha, const T &v0, const T &v1)
Resample two neighboring samples.
TYPE Resample(float u) const
T GfLerp(double alpha, const T &a, const T &b)
GF_API GfQuatd GfSlerp(double alpha, const GfQuatd &q0, const GfQuatd &q1)
std::pair< TYPE, VtIntArray > ResampleIndexed(float u) const
bool UnboxFrom(HdTimeSampleArray< VtValue, CAPACITY > const &box)
GLfloat GLfloat GLfloat alpha
HdIndexedTimeSampleArray()
TfSmallVector< TYPE, CAPACITY > values
virtual void Resize(unsigned int newSize)
Resize the internal buffers.
void Resize(unsigned int newSize) override
Resize the internal buffers.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
GLenum GLsizei GLsizei GLint * values
HdIndexedTimeSampleArray(const HdIndexedTimeSampleArray &rhs)
#define PXR_NAMESPACE_CLOSE_SCOPE
HdIndexedTimeSampleArray & operator=(const HdIndexedTimeSampleArray &rhs)
T HdResampleRawTimeSamples(float u, size_t numSamples, const float *us, const T *vs)
IMF_EXPORT int numSamples(int s, int a, int b)
TfSmallVector< VtIntArray, CAPACITY > indices
HdTimeSampleArray & operator=(const HdTimeSampleArray &rhs)
bool UnboxFrom(HdIndexedTimeSampleArray< VtValue, CAPACITY > const &box)