24 #ifndef __GUSD_INSTANCERWRAPPER_H__
25 #define __GUSD_INSTANCERWRAPPER_H__
28 #include "pxr/usd/usdGeom/pointInstancer.h"
30 #include "primWrapper.h"
32 #include <UT/UT_Map.h>
33 #include <UT/UT_StringHolder.h>
36 PXR_NAMESPACE_OPEN_SCOPE
41 typedef UT_Map<TfToken, int> RelationshipIndexMap;
45 GusdInstancerWrapper(
const UsdStagePtr& stage,
48 bool isOverride =
false );
51 GusdPurposeSet purposes );
52 virtual ~GusdInstancerWrapper();
54 virtual const UsdGeomImageable getUsdPrim()
const override {
return m_usdPointInstancer; }
57 const UsdStagePtr& stage,
60 const GT_PrimitiveHandle& sourcePrim )
override;
62 virtual const char* className()
const override;
64 virtual void enlargeBounds(UT_BoundingBox boxes[],
int nsegments)
const override;
66 virtual int getMotionSegments()
const override;
68 virtual int64 getMemoryUsage()
const override;
70 virtual GT_PrimitiveHandle doSoftCopy()
const override;
74 const UT_Matrix4D& houXform,
76 GusdSimpleXformCache& xformCache )
override;
78 virtual bool isValid()
const override;
80 virtual bool refine( GT_Refine& refiner,
81 const GT_RefineParms* parms = NULL )
const override;
85 const UT_StringRef& fileName,
87 const UT_Matrix4D& xform,
89 const char * viewportLod,
90 GusdPurposeSet purposes )
override;
94 static GT_PrimitiveHandle
96 const UsdStagePtr& stage,
100 static GT_PrimitiveHandle
103 GusdPurposeSet purposes );
106 bool initUsdPrim(
const UsdStagePtr& stage,
111 const UsdStagePtr& stage,
112 const GT_PrimitiveHandle& sourcePrim);
114 void storePreOverlayData(
bool justProtoIndices,
const UsdTimeCode* time);
116 void clearPreOverlayData();
118 void setTransformAttrsFromMatrices(
const UT_Matrix4D &worldToLocal,
119 const GT_AttributeListHandle gtAttrs,
121 GT_PrimitiveHandle sourcePrim);
129 RelationshipIndexMap m_relationshipIndexMap;
133 std::vector<UT_Matrix4D> m_prototypeTransforms;
139 std::vector<TfToken> m_usdGeomTokens = {
UsdGeomTokens->protoIndices,
150 struct PreOverlayDataEntry {
151 std::map<UsdTimeCode, VtArray<T>> preOverlayDataMap;
154 PreOverlayDataEntry(
UsdAttribute usdAttr) : usdAttr(usdAttr) {}
156 PreOverlayDataEntry() {}
157 ~PreOverlayDataEntry() {}
158 PreOverlayDataEntry(PreOverlayDataEntry &&other) {
159 preOverlayDataMap = std::move(other.preOverlayDataMap);
160 usdAttr = other.usdAttr;
162 PreOverlayDataEntry& operator=(PreOverlayDataEntry &&other) {
163 preOverlayDataMap = std::move(other.preOverlayDataMap);
164 usdAttr = other.usdAttr;
167 PreOverlayDataEntry(PreOverlayDataEntry
const& other){
168 preOverlayDataMap = other.preOverlayDataMap;
169 usdAttr = other.usdAttr;
175 if (usdAttr.Get(&dataArray, time)){
176 preOverlayDataMap[time] = dataArray;
181 bool getPointValue(
UsdTimeCode time,
int ptNum, T& value) {
183 if (preOverlayDataMap.count(time) > 0) {
184 dataArray = preOverlayDataMap[time];
185 if (dataArray.
size() > ptNum) {
186 value = dataArray[ptNum];
190 usdAttr.Get(&dataArray, time);
191 if (dataArray.
size() > ptNum) {
192 value = dataArray[ptNum];
202 typedef boost::variant<PreOverlayDataEntry<int>,
203 PreOverlayDataEntry<GfVec3f>,
204 PreOverlayDataEntry<GfQuath>> dataEntry;
207 std::map<TfToken, dataEntry> m_preOverlayDataMap;
210 struct StoreAtTime :
public boost::static_visitor<>
216 template <
typename T>
217 void operator()(T& t)
const {
223 struct ClearData :
public boost::static_visitor<>
225 template <
typename T>
226 void operator()(T t)
const {
227 t.preOverlayDataMap.clear();
232 PXR_NAMESPACE_CLOSE_SCOPE
234 #endif // __GUSD_INSTANCERWRAPPER_H__
A GT_Primitive that wraps a USD Prim.
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
virtual bool updateFromGTPrim(const GT_PrimitiveHandle &sourcePrim, const UT_Matrix4D &houXform, const GusdContext &ctxt, GusdSimpleXformCache &xformCache)
Fill a USD prim's attribute samples for a frame from the attributes in a GT primitive.
virtual bool redefine(const UsdStagePtr &stage, const SdfPath &path, const GusdContext &ctxt, const GT_PrimitiveHandle &sourcePrim)
Create a new USD prim to match GT primitive.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
USDGEOM_API TfStaticData< UsdGeomTokensType > UsdGeomTokens
A global variable with static, efficient TfTokens for use in all public USD API.
static GT_PrimitiveHandle defineForWrite(const GT_PrimitiveHandle &sourcePrim, const UsdStagePtr &stage, const SdfPath &path, const GusdContext &ctxt)
Given a GT_Primitive, create a USD prim of the proper type.
A GusdContext structure is created by the ROPs that write USD files and passed to the GusdPrimWrapper...
size_t size() const
Return the total number of elements in this array.
A path value used to locate objects in layers or scenegraphs.
virtual bool isValid() const
Return true if the underlying USD prim is valid.
static GT_PrimitiveHandle defineForRead(const UsdGeomImageable &sourcePrim, UsdTimeCode time, GusdPurposeSet purposes)
Given a USD prim, create a GusdPrimWrapper of the proper type.
Encodes vectorized instancing of multiple, potentially animated, prototypes (object/instance masters)...
Base class for all prims that may require rendering or visualization of some sort.