HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
keyFrameUtils.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef PXR_BASE_TS_KEY_FRAME_UTILS_H
26 #define PXR_BASE_TS_KEY_FRAME_UTILS_H
27 
28 #include "pxr/pxr.h"
29 #include "pxr/base/ts/api.h"
30 #include "pxr/base/ts/types.h"
31 #include "pxr/base/ts/loopParams.h"
32 
34 
35 class Ts_Data;
36 class TsKeyFrame;
37 class TsKeyFrameMap;
38 
39 /// \brief Finds the keyframe in \p keyframes closest to the given
40 /// time. Returns NULL if there are no keyframes.
42  const TsKeyFrameMap &keyframes,
43  const TsTime targetTime );
44 
45 /// \brief Finds the closest keyframe in \p keyframes before the given
46 /// time. Returns NULL if no such keyframe exists.
48  const TsKeyFrameMap &keyframes,
49  const TsTime targetTime );
50 
51 /// \brief Finds the closest keyframe in \p keyframes after the given
52 /// time. Returns NULL if no such keyframe exists.
54  const TsKeyFrameMap &keyframes,
55  const TsTime targetTime );
56 
57 /// \brief Equivalant to calling Ts_GetClosestKeyFrameBefore and
58 /// Ts_GetClosestKeyFrameAfter, but twice the speed; for performance
59 /// critical applications.
60 std::pair<const TsKeyFrame *, const TsKeyFrame *>
62  const TsKeyFrameMap &keyframes,
63  const TsTime targetTime );
64 
65 /// \brief Returns true if the segment between the given (adjacent) key
66 /// frames is flat.
67 bool Ts_IsSegmentFlat(const TsKeyFrame &kf1, const TsKeyFrame &kf2 );
68 
69 /// \brief Returns true if the given key frame is redundant.
71  const TsKeyFrameMap &keyframes,
72  const TsKeyFrame &keyFrame,
73  const TsLoopParams &loopParams=TsLoopParams(),
74  const VtValue& defaultValue=VtValue());
75 
76 // Return a pointer to the Ts_Data object held by the keyframe.
77 // XXX: exported because used by templated functions starting from TsEvaluator
78 TS_API
80 
81 // Return a const pointer to the Ts_Data object held by the keyframe.
82 // XXX: exported because used by templated functions starting from TsEvaluator
83 TS_API
84 Ts_Data const* Ts_GetKeyFrameData(TsKeyFrame const& kf);
85 
86 // Uses a fixed epsilon to compare the values, iff both are float or double,
87 // else falls back to VtValue ==.
88 bool Ts_IsClose(const VtValue &v0, const VtValue &v1);
89 
91 
92 #endif
std::pair< const TsKeyFrame *, const TsKeyFrame * > Ts_GetClosestKeyFramesSurrounding(const TsKeyFrameMap &keyframes, const TsTime targetTime)
Equivalant to calling Ts_GetClosestKeyFrameBefore and Ts_GetClosestKeyFrameAfter, but twice the speed...
bool Ts_IsSegmentFlat(const TsKeyFrame &kf1, const TsKeyFrame &kf2)
Returns true if the segment between the given (adjacent) key frames is flat.
const TsKeyFrame * Ts_GetClosestKeyFrameAfter(const TsKeyFrameMap &keyframes, const TsTime targetTime)
Finds the closest keyframe in keyframes after the given time. Returns NULL if no such keyframe exists...
bool Ts_IsKeyFrameRedundant(const TsKeyFrameMap &keyframes, const TsKeyFrame &keyFrame, const TsLoopParams &loopParams=TsLoopParams(), const VtValue &defaultValue=VtValue())
Returns true if the given key frame is redundant.
An ordered sequence of keyframes with STL-compliant API for finding, inserting, and erasing keyframes...
Definition: keyFrameMap.h:50
TS_API Ts_Data * Ts_GetKeyFrameData(TsKeyFrame &kf)
const TsKeyFrame * Ts_GetClosestKeyFrame(const TsKeyFrameMap &keyframes, const TsTime targetTime)
Finds the keyframe in keyframes closest to the given time. Returns NULL if there are no keyframes...
const TsKeyFrame * Ts_GetClosestKeyFrameBefore(const TsKeyFrameMap &keyframes, const TsTime targetTime)
Finds the closest keyframe in keyframes before the given time. Returns NULL if no such keyframe exist...
Specifies the value of an TsSpline object at a particular point in time.
Definition: keyFrame.h:66
PXR_NAMESPACE_OPEN_SCOPE typedef double TsTime
The time type used by Ts.
Definition: types.h:57
#define TS_API
Definition: api.h:41
GLfloat v0
Definition: glcorearb.h:816
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
Holds the data for an TsKeyFrame.
Definition: data.h:50
GLfloat GLfloat v1
Definition: glcorearb.h:817
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
bool Ts_IsClose(const VtValue &v0, const VtValue &v1)
Definition: value.h:164