HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
velocityMotionResolvingSceneIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2024 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HDSI_VELOCITY_MOTION_RESOLVING_SCENE_INDEX_H
8 #define PXR_IMAGING_HDSI_VELOCITY_MOTION_RESOLVING_SCENE_INDEX_H
9 
14 #include "pxr/imaging/hdsi/api.h"
15 
16 #include "pxr/usd/sdf/path.h"
17 
18 #include "pxr/base/tf/debug.h"
21 #include "pxr/base/tf/token.h"
22 
23 #include "pxr/pxr.h"
24 
26 
28  HDSI_VELOCITY_MOTION);
29 
30 #define HDSI_VELOCITY_MOTION_RESOLVING_SCENE_INDEX_TOKENS \
31  (disable) \
32  (enable) \
33  (ignore) \
34  (noAcceleration) \
35  (timeCodesPerSecond) \
36  ((velocityMotionMode, "__velocityMotionMode"))
37 
38 TF_DECLARE_PUBLIC_TOKENS(HdsiVelocityMotionResolvingSceneIndexTokens,
40 
42 
43 /// Scene index that resolves velocity-based motion for all prims that support
44 /// it. For a complete discussion of how velocity-based motion works, when it
45 /// is valid, and how it is resolved, see the UsdGeom documentation here:
46 /// https://openusd.org/dev/api/usd_geom_page_front.html#UsdGeom_VelocityInterpolation
47 ///
48 /// This scene index performs all the necessary calculations so that downstream
49 /// consumers do not need to worry about velocity-based motion. Downstream
50 /// consumers need only make the usual call to GetContributingSampleTimesForInterval()
51 /// for an affected primvar, then sample the primvar's value at the given times.
52 ///
53 /// Affected primvars are:
54 /// For points-based geometry:
55 /// - points
56 /// For point instancers:
57 /// - instancePositions
58 /// - instanceRotations
59 /// - instanceScales
60 ///
61 /// There is no need for downstream consumers to query velocities, accelerations,
62 /// or angularVelocities; their effects have already been applied to the sampled
63 /// values when appropriate. Downstream consumers will only see motion (or none),
64 /// again, as appropriate for the sampled primvar. Any distinction between
65 /// motion due to velocities and motion due to USD value interpolation is
66 /// intentionally lost.
67 ///
68 /// Note that, where non-linear motion has been applied (i.e., points or
69 /// instancePositions with accelerations, or instance rotations with
70 /// angularVelocities), GetContributingSampleTimesForInterval() will provide
71 /// the correct number of sample times for non-linear motion, taking
72 /// UsdGeomMotionAPI's nonlinearSampleCount into consideration.
73 /// (Downstream consumers should still check nonlinearSampleCount in the
74 /// case of instanceRotations.)
75 ///
76 /// Additionally, to support certain established workflows, the behavior of the
77 /// scene index may be controlled by the prim-level Hydra parameter
78 /// "__velocityMotionMode". This is never read from usd and must instead be
79 /// authored in a preceding filtering scene index. It is a token with one of the
80 /// following recognized values:
81 ///
82 /// - enable: velocity-based motion is resolved according to the normal rules.
83 /// - disable: velocity-based motion is frozen to the most recent authored
84 /// positions/rotations for the current frame.
85 /// - ignore: velocity-based motion is ignored as if velocities are not present.
86 /// - noAcceleration: the effect of authored accelerations is ignored.
87 ///
88 /// In all cases (except 'ignore'), __velocityMotionMode has no effect unless
89 /// the authored velocity data is valid (see link above for what counts as
90 /// valid). (In the case of 'ignore', validity is not evaluated.) Where the
91 /// velocity data is not valid, the scene index makes no changes to the incoming
92 /// scene data, which may indicate motion due to USD value interpolation where
93 /// appropriate.
94 ///
97 {
98 public:
99  HDSI_API
100  static HdsiVelocityMotionResolvingSceneIndexRefPtr
101  New(
102  const HdSceneIndexBaseRefPtr& inputSceneIndex,
103  const HdContainerDataSourceHandle& inputArgs = nullptr);
104 
105  HDSI_API
107  GetPrim(const SdfPath& primPath) const override;
108 
109  HDSI_API
111  GetChildPrimPaths(const SdfPath& primPath) const override;
112 
113  HDSI_API
114  static bool
115  PrimTypeSupportsVelocityMotion(const TfToken& primType);
116 
117 protected:
119  const HdSceneIndexBaseRefPtr& inputSceneIndex,
120  const HdContainerDataSourceHandle& inputArgs = nullptr);
121 
122  void
123  _PrimsAdded(
124  const HdSceneIndexBase& sender,
125  const HdSceneIndexObserver::AddedPrimEntries& entries) override;
126 
127  void
129  const HdSceneIndexBase& sender,
130  const HdSceneIndexObserver::RemovedPrimEntries& entries) override;
131 
132  void
134  const HdSceneIndexBase& sender,
135  const HdSceneIndexObserver::DirtiedPrimEntries& entries) override;
136 };
137 
139 
140 #endif // PXR_IMAGING_HDSI_VELOCITY_MOTION_RESOLVING_SCENE_INDEX_H
TF_DECLARE_PUBLIC_TOKENS(HdsiVelocityMotionResolvingSceneIndexTokens, HDSI_API, HDSI_VELOCITY_MOTION_RESOLVING_SCENE_INDEX_TOKENS)
static HDSI_API HdsiVelocityMotionResolvingSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr &inputSceneIndex, const HdContainerDataSourceHandle &inputArgs=nullptr)
HdsiVelocityMotionResolvingSceneIndex(const HdSceneIndexBaseRefPtr &inputSceneIndex, const HdContainerDataSourceHandle &inputArgs=nullptr)
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Definition: token.h:70
TF_DECLARE_REF_PTRS(HdsiVelocityMotionResolvingSceneIndex)
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
std::vector< class SdfPath > SdfPathVector
#define HDSI_VELOCITY_MOTION_RESOLVING_SCENE_INDEX_TOKENS
static HDSI_API bool PrimTypeSupportsVelocityMotion(const TfToken &primType)
Definition: path.h:273
PXR_NAMESPACE_OPEN_SCOPE TF_DEBUG_CODES(HDSI_VELOCITY_MOTION)
#define HDSI_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override