HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VEX_GeoCommand.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: VEX_GeoCommand.h ( VEX Library, C++)
7  *
8  * COMMENTS: Generic commands and queues to store geometry
9  * edit operations
10  */
11 
12 #ifndef __VEX_GeoCommand__
13 #define __VEX_GeoCommand__
14 
15 #include "VEX_API.h"
16 #include "VEX_Types.h"
17 #include <UT/UT_Array.h>
18 #include <UT/UT_IntArray.h>
19 #include <UT/UT_NonCopyable.h>
20 #include <UT/UT_PageArray.h>
21 #include <UT/UT_SharedString.h>
22 #include <UT/UT_StringHolder.h>
23 #include <UT/UT_StringSet.h>
24 #include <UT/UT_Vector3.h>
25 #include <UT/UT_VectorTypes.h>
26 
27 #include <variant>
28 
29 // Do NOT use VEX_API here for template classes with all code in the header!
30 
31 enum class VEX_GeoMode
32 {
33  SET,
34  ADD,
35  MAX,
36  MIN,
37  MULTIPLY,
38  TOGGLE,
39  APPEND,
40 
41  INVALID
42 };
43 enum class VEX_GeoPrimType
44 {
45  POLY_OPEN,
47  TET,
48  SPHERE,
49  CIRCLE,
50  TUBE,
51  METABALL,
52  METASQUAD,
54  PACKEDDISK,
55  HEX,
56  CHANNEL,
57 
58  INVALID
59 };
60 enum class VEX_GeoDictType
61 {
62  DETAIL,
64  PRIM,
66  PRIMGROUP,
67  POINT,
68  POINTGROUP,
69  VERTEX,
71 
72  INVALID
73 };
74 enum class VEX_GeoTypeInfo
75 {
76  NOCHANGE = -1,
77  NONE = 0,
78  POINT,
79  HPOINT,
80  VECTOR,
81  NORMAL,
82  COLOR,
83  TRANSFORM,
84  QUATERNION,
85  INDEXPAIR,
89 };
90 
92 {
93  InsertKey,
94  DestroyKey,
95  Clear,
99 
100  Invalid
101 };
102 
103 // These must match the order of the definitions in $SHS/vex/include/chprim_util.h
105 {
106  In,
107  Out,
108  InOut
109 };
110 
111 namespace VEX_Geo
112 {
113  VEX_API VEX_GeoMode modeFromString(const char*);
117 
118 } // namespace VEX_Geo
119 
121 {
122 public:
123  VEX_GeoCommand(exint srcelem) { mySourceElem = srcelem; }
124  VEX_GeoCommand(): mySourceElem(-1) {}
125 
126  exint elem() const { return mySourceElem; }
127 
128 protected:
130 };
131 
132 template <VEX_Precision PREC>
134 {
135 public:
137  : VEX_GeoCommand(srcelem)
138  , myType(primtype)
139  {
140  }
142 
143  VEX_GeoPrimType type() const { return myType; }
144 
145 protected:
147 };
148 
149 template <VEX_Precision PREC>
151 {
152 public:
154  : VEX_GeoCommand(srcelem)
155  , myPos(pos)
156  , mySrcPt(-1)
157  {
158  }
160  : VEX_GeoCommand(srcelem)
161  , myPos(0.0, 0.0, 0.0)
162  , mySrcPt(srcpt)
163  {
164  }
166 
167  VEXvec3<PREC> pos() const { return myPos; }
168  VEXint<PREC> srcpt() const { return mySrcPt; }
169 
170 protected:
171  // Ideally we'd union, but C++ makes this frustrating.
174 };
175 
176 template <VEX_Precision PREC>
178 {
179 public:
182  : VEX_GeoCommand(srcelem)
183  , myPrimNum(primnum)
184  , myPtNum(ptnum)
185  {
186  }
188 
189  VEXint<PREC> primnum() const { return myPrimNum; }
190  VEXint<PREC> ptnum() const { return myPtNum; }
191 
192 protected:
195 };
196 
197 template <VEX_Precision PREC>
199 {
200 public:
202  : VEX_GeoCommand(srcelem)
203  , myObjID(obj_id)
204  {
205  }
207 
208  VEXint<PREC> objID() const { return myObjID; }
209 
210 protected:
212 };
213 
214 namespace VEX_DataObjID
215 {
216  static SYS_FORCE_INLINE void initID(int32 &id) { id = -1; }
217  static SYS_FORCE_INLINE bool isValidID(int32 id) { return id >= 0; }
218 
219  static SYS_FORCE_INLINE void initID(int64 &id) { id = -1; }
220  static SYS_FORCE_INLINE bool isValidID(int64 id) { return id >= 0; }
221 
222  static SYS_FORCE_INLINE void initID(UT_StringHolder &id) { id.clear(); }
223  static SYS_FORCE_INLINE bool isValidID(const UT_StringHolder &id)
224  { return id.isstring(); }
225 
226  static SYS_FORCE_INLINE void initID(UT_OptionsHolder &id) { id.clear(); }
227  static SYS_FORCE_INLINE bool isValidID(const UT_OptionsHolder &id)
228  { return !id.isEmpty(); }
229 };
230 
231 template <VEX_Precision PREC, typename OBJ_ID, typename SEC_ID, typename T>
233 {
234 public:
236  exint srcelem, const OBJ_ID &obj_id, const SEC_ID &sec_id,
238  : VEX_GeoCommand(srcelem)
239  , myObjID(obj_id)
240  , mySecID(sec_id)
241  , myMode(mode)
242  , myData(data)
243  {
244  }
246  : mySecID(-1)
248  , myData(T())
249  {
250  VEX_DataObjID::initID(myObjID);
251  }
252 
253  const OBJ_ID & objID() const { return myObjID; }
254  const SEC_ID & secID() const { return mySecID; }
255  VEX_GeoMode mode() const { return myMode; }
256  T data() const { return myData; }
257 
258 protected:
259  OBJ_ID myObjID;
260  SEC_ID mySecID;
263 };
264 
265 template <VEX_Precision PREC, typename T>
268 template <VEX_Precision PREC, typename T>
271 
272 template <VEX_Precision PREC>
274 {
275 public:
277  exint srcelem, VEXint<PREC> primnum,
278  VEXint<PREC> vtxidx, VEXint<PREC> newptnum)
279  : VEX_GeoCommand(srcelem)
280  , myPrimNum(primnum)
281  , myVtxIdx(vtxidx)
282  , myPtNum(newptnum)
283  {
284  }
286 
287  // -1 for primnum implies a linear vertex
288  VEXint<PREC> primnum() const { return myPrimNum; }
289  VEXint<PREC> vtxidx() const { return myVtxIdx; }
290  VEXint<PREC> ptnum() const { return myPtNum; }
291 
292 protected:
293  VEXint<PREC> myPrimNum, myVtxIdx, myPtNum;
294 };
295 
296 template <VEX_Precision PREC>
298 {
299 public:
301  const VEXfloat<PREC> &value,
302  VEXint<PREC> channelidx)
303  : VEX_GeoCommand(srcelem),
304  myPrimNum(primnum),
305  myValue(value),
306  myChannelIdx(channelidx)
307  {
308  }
309 
311  : myPrimNum(-1), myValue(0.0), myChannelIdx(-1)
312  {
313  }
314 
315  VEXint<PREC> primnum() const { return myPrimNum; }
316  VEXfloat<PREC> value() const { return myValue; }
317  VEXint<PREC> channelIdx() const { return myChannelIdx; }
318 
319 private:
320  VEXint<PREC> myPrimNum;
321  VEXfloat<PREC> myValue;
322  VEXint<PREC> myChannelIdx;
323 };
324 
325 template <VEX_Precision PREC>
327 {
328 public:
330  const VEXmat4<PREC> &xform, VEXint<PREC> xformidx, bool worldspace)
331  : VEX_GeoCommand(srcelem),
332  myPrimNum(primnum),
333  myData(SingleEdit(xform, xformidx)),
334  myWorldSpace(worldspace)
335  {
336  }
338  const UT_Array<VEXmat4<PREC>> &xforms, bool worldspace)
339  : VEX_GeoCommand(srcelem),
340  myPrimNum(primnum),
342  myWorldSpace(worldspace)
343  {
344  }
346 
347  VEXint<PREC> primnum() const { return myPrimNum; }
348  const VEXmat4<PREC> &xform() const
349  {
350  UT_ASSERT(myData.index() == 0);
351  return std::get<SingleEdit>(myData).first;
352  }
353  VEXint<PREC> xformidx() const
354  {
355  UT_ASSERT(myData.index() == 0);
356  return std::get<SingleEdit>(myData).second;
357  }
359  {
360  UT_ASSERT(myData.index() == 1);
361  return std::get<FullEdit>(myData);
362  }
363  bool worldspace() const { return myWorldSpace; }
364 
365  bool isSingleEdit() const { return myData.index() == 0; }
366 
367 protected:
368  typedef std::pair<VEXmat4<PREC>,VEXint<PREC>> SingleEdit;
370 
371  VEXint<PREC> myPrimNum;
372  // Allow setting a single transform or setting all of them
373  std::variant<SingleEdit, FullEdit> myData;
375 };
376 
377 template <VEX_Precision PREC>
379 {
380 public:
382  const UT_Array<VEXint<PREC>> &clipids,
385  const UT_Array<VEXint<PREC>> &clipxformgroupids,
386  const UT_Array<VEXint<PREC>> &cliplayerids,
387  const UT_Array<VEXint<PREC>> &cliplayermodes,
389  const UT_Array<VEXint<PREC>> &cliplayerparents)
390  : VEX_GeoCommand(srcelem),
391  myPrimNum(primnum),
400  {
401  }
402 
403  VEX_GeoCommandAgentClipEdit() = default;
408 
409  const VEXint<PREC> primnum() const { return myPrimNum; }
410  const UT_Array<VEXint<PREC>> &clipids() const { return myClipIds; }
411  const UT_Array<VEXfloat<PREC>> &cliptimes() const { return myClipTimes; }
418 
419 protected:
420  VEXint<PREC> myPrimNum;
429 };
430 
431 template <VEX_Precision PREC>
433 {
434 public:
436  const UT_Array<VEXint<PREC>> &layer_ids, bool is_collision)
437  : VEX_GeoCommand(srcelem),
438  myPrimNum(primnum),
439  myLayerIds(layer_ids),
440  myIsCollision(is_collision)
441  {
442  }
443  VEX_GeoCommandAgentLayerEdit() = default;
444 
445  VEXint<PREC> primnum() const { return myPrimNum; }
446  const UT_Array<VEXint<PREC>> &layerIds() const { return myLayerIds; }
447  bool isCollision() const { return myIsCollision; }
448 
449 private:
450  VEXint<PREC> myPrimNum = -1;
451  UT_Array<VEXint<PREC>> myLayerIds;
452  bool myIsCollision = false;
453 };
454 
455 class CL_Clip;
456 
457 template <VEX_Precision PREC>
459 {
460 public:
462  exint srcelem,
463  VEXint<PREC> primnum,
464  const UT_StringHolder &clip_name,
465  const UT_StringHolder &clip_path,
466  bool keep_ref)
467  : VEX_GeoCommand(srcelem)
468  , myPrimNum(primnum)
469  , myClipName(clip_name)
470  , myClipPath(clip_path)
471  , myKeepRef(keep_ref)
472  {
473  }
475  : VEX_GeoCommand()
476  , myPrimNum(-1)
477  , myClipName()
478  , myClipPath()
479  , myKeepRef(true)
480  {
481  }
482 
483  VEXint<PREC> primnum() const { return myPrimNum; }
484 
485  VEXint<PREC> myPrimNum;
488  bool myKeepRef;
489 };
490 
491 template <VEX_Precision PREC>
493 {
494 public:
496  exint srcelem,
497  VEXint<PREC> primnum,
498  VEX_GeoPrimChannelOperation operation,
499  float time = 0.0,
500  float value = 0.0,
502  : VEX_GeoCommand(srcelem)
503  , myPrimNum(primnum)
504  , myOperation(operation)
505  , myTime(time)
506  , myValue(value)
507  , myHalf(half)
508  {
509  }
511  : VEX_GeoCommand()
512  , myPrimNum(-1)
514  , myTime(0)
515  , myValue(0)
517  {
518  }
519 
520  VEXint<PREC> primnum() const { return myPrimNum; }
521 
522  VEXint<PREC> myPrimNum;
524  float myTime;
525  float myValue;
527 };
528 
529 template <VEX_Precision PREC, typename OBJ_ID, typename SEC_ID>
531 {
532 public:
533  //
534  // A variant of all VEXint,VEXfloat,VEXvecN,VEXmatN types
536  {
537  public:
538  DefaultValue() { memset(f, 0, sizeof(VEXfloat<PREC>)*16); i = 0; }
539 
540  void set(VEXint<PREC> v) { i = v; }
541  void set(VEXfloat<PREC> v) { f[0] = v; }
542  void set(VEXvec2<PREC> v) { memcpy(f, &v, sizeof(v)); }
543  void set(VEXvec3<PREC> v) { memcpy(f, &v, sizeof(v)); }
544  void set(VEXvec4<PREC> v) { memcpy(f, &v, sizeof(v)); }
545  void set(VEXmat2<PREC> v) { memcpy(f, &v, sizeof(v)); }
546  void set(VEXmat3<PREC> v) { memcpy(f, &v, sizeof(v)); }
547  void set(VEXmat4<PREC> v) { memcpy(f, &v, sizeof(v)); }
548 
550  VEXint<PREC> i;
551  };
552 
554  const UT_StringHolder &name);
555  // This constructor is only used for the VEX_UsdEdit incarnation of
556  // this class. This avoids having to define a subclass and introducing
557  // virtual function calls. The path is used to group and sort USD edits
558  // according to their location in the scene graph tree, rather than just
559  // using the attribute name or metadata key (which are supplied in the
560  // name parameter).
562  const UT_StringHolder &path,
563  const UT_StringHolder &name);
564  ~VEX_AttribEdit();
565 
567 
568  void setTypeInfo(exint srcelem,
569  const char *typeinfo);
570 
571  void addAttribute(exint srcelem,
572  VEX_Type type,
573  bool isarray,
574  const DefaultValue &value);
575 
576  void appendEdit(exint srcelem,
577  const OBJ_ID &obj_id,
578  const SEC_ID &sec_id,
580  VEXfloat<PREC> data);
581  void appendEdit(exint srcelem,
582  const OBJ_ID &obj_id,
583  const SEC_ID &sec_id,
584  VEX_GeoMode mode,
585  VEXint<PREC> data);
586  void appendEdit(exint srcelem,
587  const OBJ_ID &obj_id,
588  const SEC_ID &sec_id,
589  VEX_GeoMode mode,
590  VEXvec2<PREC> data);
591  void appendEdit(exint srcelem,
592  const OBJ_ID &obj_id,
593  const SEC_ID &sec_id,
594  VEX_GeoMode mode,
595  VEXvec3<PREC> data);
596  void appendEdit(exint srcelem,
597  const OBJ_ID &obj_id,
598  const SEC_ID &sec_id,
599  VEX_GeoMode mode,
600  VEXvec4<PREC> data);
601  void appendEdit(exint srcelem,
602  const OBJ_ID &obj_id,
603  const SEC_ID &sec_id,
604  VEX_GeoMode mode,
605  VEXmat2<PREC> data);
606  void appendEdit(exint srcelem,
607  const OBJ_ID &obj_id,
608  const SEC_ID &sec_id,
609  VEX_GeoMode mode,
610  VEXmat3<PREC> data);
611  void appendEdit(exint srcelem,
612  const OBJ_ID &obj_id,
613  const SEC_ID &sec_id,
614  VEX_GeoMode mode,
615  VEXmat4<PREC> data);
616  void appendEdit(exint srcelem,
617  const OBJ_ID &obj_id,
618  const SEC_ID &sec_id,
619  VEX_GeoMode mode,
620  const char *data);
621  void appendEdit(exint srcelem,
622  const OBJ_ID &obj_id,
623  const SEC_ID &sec_id,
624  VEX_GeoMode mode,
625  UT_OptionsHolder dict);
626  void appendEdit(exint srcelem,
627  const OBJ_ID &obj_id,
628  const SEC_ID &sec_id,
629  VEX_GeoMode mode,
630  const UT_Array<VEXfloat<PREC>> *data);
631  void appendEdit(exint srcelem,
632  const OBJ_ID &obj_id,
633  const SEC_ID &sec_id,
634  VEX_GeoMode mode,
635  const UT_Array<VEXvec2<PREC>> *data);
636  void appendEdit(exint srcelem,
637  const OBJ_ID &obj_id,
638  const SEC_ID &sec_id,
639  VEX_GeoMode mode,
640  const UT_Array<VEXvec3<PREC>> *data);
641  void appendEdit(exint srcelem,
642  const OBJ_ID &obj_id,
643  const SEC_ID &sec_id,
644  VEX_GeoMode mode,
645  const UT_Array<VEXvec4<PREC>> *data);
646  void appendEdit(exint srcelem,
647  const OBJ_ID &obj_id,
648  const SEC_ID &sec_id,
649  VEX_GeoMode mode,
650  const UT_Array<VEXmat2<PREC>> *data);
651  void appendEdit(exint srcelem,
652  const OBJ_ID &obj_id,
653  const SEC_ID &sec_id,
654  VEX_GeoMode mode,
655  const UT_Array<VEXmat3<PREC>> *data);
656  void appendEdit(exint srcelem,
657  const OBJ_ID &obj_id,
658  const SEC_ID &sec_id,
659  VEX_GeoMode mode,
660  const UT_Array<VEXmat4<PREC>> *data);
661  void appendEdit(exint srcelem,
662  const OBJ_ID &obj_id,
663  const SEC_ID &sec_id,
664  VEX_GeoMode mode,
665  const UT_Array<VEXint<PREC>> *data);
666  void appendEdit(exint srcelem,
667  const OBJ_ID &obj_id,
668  const SEC_ID &sec_id,
669  VEX_GeoMode mode,
670  const UT_Array<const char *> *data);
671  void appendEdit(exint srcelem,
672  const OBJ_ID &obj_id,
673  const SEC_ID &sec_id,
674  VEX_GeoMode mode,
675  const UT_Array<UT_OptionsHolder> *data);
676 
677 
678  // This may steal the command list from the source!
679  void merge(VEX_AttribEdit &src);
680 
681  void sort();
682 
683  void clear();
684 
685  // These convert our command list to the specified type.
686  //
687  // If the stored VEX_Type matches the return type, the result will be
688  // valid. Otherwise nullptr is returned.
689 
690  // Functions:
691  // fCmd, iCmd, v2Cmd, v3Cmd, v4Cmd, m2Cmd, m3Cmd, m4Cmd, sCmd, dCmd
692  // afCmd, aiCmd, av2Cmd, av3Cmd, av4Cmd, am2Cmd, am3Cmd, am4Cmd, asCmd, adCmd
693 #define VEX_GEOATTRIBEDIT_CASE(vtype, type, name, isarray) \
694  UT_Array<VEX_DataCommandAttribEdit<PREC, OBJ_ID, SEC_ID, type>> * \
695  name##Cmd() \
696  {\
697  if (myType == vtype && myIsArray == isarray)\
698  return (UT_Array<VEX_DataCommandAttribEdit<PREC, OBJ_ID, SEC_ID, type>>*) myCmdList;\
699  return nullptr;\
700  }
701 #define VEX_GEOATTRIBEDIT_CASE_DIRECT(ty, name) \
702  VEX_GEOATTRIBEDIT_CASE(VEX_VexTypeResolver<VEX##ty<PREC>>::type,VEX##ty<PREC>,name,false)
703 #define VEX_GEOATTRIBEDIT_CASE_ARRAY(ty, name) \
704  VEX_GEOATTRIBEDIT_CASE(VEX_VexTypeResolver<VEX##ty<PREC>>::type,const UT_Array<VEX##ty<PREC>>*,name,true)
705 
714 
715  VEX_GEOATTRIBEDIT_CASE(VEX_TYPE_STRING, const char*, s, false)
717 
726 
727  VEX_GEOATTRIBEDIT_CASE(VEX_TYPE_STRING, const UT_Array<const char*>*, as, true)
728  VEX_GEOATTRIBEDIT_CASE(VEX_TYPE_DICT, const UT_Array<UT_OptionsHolder>*, ad, true)
729 
730 #undef VEX_GEOATTRIBEDIT_CASE_ARRAY
731 #undef VEX_GEOATTRIBEDIT_CASE_DIRECT
732 #undef VEX_GEOATTRIBEDIT_CASE
733 
734  VEX_GeoDictType dict() const { return myDict; }
735  const UT_StringHolder &name() const { return myName; }
736  VEX_Type type() const { return myType; }
737  bool isArray() const { return myIsArray; }
738  bool shouldcreate() const { return myDoCreate; }
739  VEX_GeoTypeInfo typeinfo() const { return myTypeInfo; }
740  const DefaultValue &defaultValue() const { return myDefValue; }
741 
742  // The path component is only used by USD edits, to hold the primitive or
743  // property path so that we can sort the edits and apply them in the order
744  // of the scene graph hierarchy.
745  const UT_StringHolder &path() const { return myPath; }
746 
747 protected:
748  // The earliest proc that refered to us.
754  bool myIsArray;
755  // The proc that set the typeinfo.
756  // Because we are logically overwriting, it makes sense for this
757  // to be the last person to set it!
760 
761  void *myCmdList;
762  // The proc that marked us for creation
765  DefaultValue myDefValue;
766 };
767 
769 {
770 public:
773  };
775  const UT_StringRef &path,
776  const UT_StringRef &name,
778  : myDict(dict),
779  myPath(UTmakeUnsafeRef(path)),
780  myName(UTmakeUnsafeRef(name))
781  { }
783  const UT_StringHolder &path,
784  const UT_StringHolder &name)
785  : myDict(dict),
786  myPath(path),
787  myName(name)
788  { }
789 
790  bool operator==(const VEX_AttribEditId &other) const
791  {
792  return myDict == other.myDict &&
793  myPath == other.myPath &&
794  myName == other.myName;
795  }
796 
800 };
801 VEX_API std::size_t hash_value(const VEX_AttribEditId &id);
803 
804 template <VEX_Precision PREC>
806 template <VEX_Precision PREC>
808 
809 template <VEX_Precision PREC>
811 {
812 public:
814  exint srcelem,
815  VEXint<PREC> ptnum0, VEXint<PREC> ptnum1,
816  VEXint<PREC> data)
817  : VEX_GeoCommand(srcelem)
818  , myPtNum0(ptnum0)
819  , myPtNum1(ptnum1)
820  , myData(data)
821  {
822  }
824  : VEX_GeoCommand(), myPtNum0(-1) , myPtNum1(-1), myData(-1)
825  {}
826 
827  VEXint<PREC> ptNum0() const { return myPtNum0; }
828  VEXint<PREC> ptNum1() const { return myPtNum1; }
829  VEXint<PREC> data() const { return myData; }
830 
831 protected:
832  VEXint<PREC> myPtNum0;
833  VEXint<PREC> myPtNum1;
834  VEXint<PREC> myData;
835 };
836 
837 template <VEX_Precision PREC>
839 {
840 public:
841  VEX_GeoEdgeGroupEdit(const UT_StringHolder &groupname): myGroupName(groupname) {}
842 
843  const UT_StringHolder &groupName() const { return myGroupName; }
844 
845  const UT_Array<VEX_GeoCommandEdgeGroupEdit<PREC>> &cmd() const { return myCmdList; }
846 
847  void appendEdit(exint srcelem,
848  VEXint<PREC> ptnum0,
849  VEXint<PREC> ptnum1,
850  VEXint<PREC> data);
851 
852  void merge(VEX_GeoEdgeGroupEdit &src);
853 
854  void sort();
855 
856 protected:
859 };
860 
861 template <VEX_Precision PREC>
863 {
864 public:
868 
869  // Converts the given string to one in our string table, ensuring
870  // the pointer remains valid and avoids duplication.
871  const char *hardenString(const char *str);
872 
873  // Creates a new array which is owned by this queue. Does
874  // not de-duplicate, but will return 0 for empty lists.
875  const UT_Array<VEXfloat<PREC>> *hardenArray(const UT_Array<VEXfloat<PREC>> &arr);
876  const UT_Array<VEXvec2<PREC>> *hardenArray(const UT_Array<VEXvec2<PREC>> &arr);
877  const UT_Array<VEXvec3<PREC>> *hardenArray(const UT_Array<VEXvec3<PREC>> &arr);
878  const UT_Array<VEXvec4<PREC>> *hardenArray(const UT_Array<VEXvec4<PREC>> &arr);
879  const UT_Array<VEXmat2<PREC>> *hardenArray(const UT_Array<VEXmat2<PREC>> &arr);
880  const UT_Array<VEXmat3<PREC>> *hardenArray(const UT_Array<VEXmat3<PREC>> &arr);
881  const UT_Array<VEXmat4<PREC>> *hardenArray(const UT_Array<VEXmat4<PREC>> &arr);
882  const UT_Array<VEXint<PREC>> *hardenArray(const UT_Array<VEXint<PREC>> &arr);
883  // ALSO hardens the contents:
884  const UT_Array<const char *> *hardenArray(const UT_Array<const char *> &arr);
885 
886  const UT_Array<UT_OptionsHolder> *hardenArray(const UT_Array<UT_OptionsHolder> &arr);
887 
888  // Merges the src into us. Note that the result may still
889  // reference strings in the stringtable of src, so src must *not*
890  // be deleted until the queue is processed!
891  // This also may destroy src in the merging if stealing is more
892  // efficient.
893  void merge(VEX_GeoCommandQueue &src);
894  // Ensure our commands are in srcelem order.
895  void sort();
896 
897  bool isEmpty() const
898  {
899  return myPointAdd.isEmpty() &&
900  myPrimAdd.isEmpty() &&
901  myVertexAdd.isEmpty() &&
902  myVertexRewire.isEmpty() &&
903  myAttribEdit.isEmpty() &&
904  myUsdEdit.isEmpty() &&
905  myEdgeGroupEdit.isEmpty() &&
906  myAgentChannelEdit.isEmpty() &&
907  myAgentXformEdit.isEmpty() &&
908  myAgentClipEdit.isEmpty() &&
909  myAgentLayerEdit.isEmpty() &&
910  myAgentAddClip.isEmpty() &&
911  myPrimChannelEdit.isEmpty() &&
912  myPointRemove.isEmpty() &&
913  myPointWithPrimRemove.isEmpty() &&
914  myPrimRemove.isEmpty() &&
915  myPrimWithPointRemove.isEmpty() &&
916  myVertexRemove.isEmpty() &&
917  myLocalVariables.empty() &&
918  !myNewVisualizers &&
919  !myAttribRemoval[(int)VEX_GeoDictType::DETAIL] &&
920  !myAttribRemoval[(int)VEX_GeoDictType::PRIM] &&
921  !myAttribRemoval[(int)VEX_GeoDictType::PRIMGROUP] &&
922  !myAttribRemoval[(int)VEX_GeoDictType::POINT] &&
923  !myAttribRemoval[(int)VEX_GeoDictType::POINTGROUP] &&
924  !myAttribRemoval[(int)VEX_GeoDictType::VERTEX] &&
925  !myAttribRemoval[(int)VEX_GeoDictType::VERTEXGROUP]
926  ;
927  }
928 
929  // These return the new element number *relative* to the srcelem!
930  VEXint<PREC> addPrim(exint srcelem, VEX_GeoPrimType primtype);
931  VEXint<PREC> addPoint(exint srcelem, VEXvec3<PREC> pos);
932  VEXint<PREC> addPoint(exint srcelem, VEXint<PREC> srcpt);
933  VEXint<PREC> addVertex(exint srcelem, VEXint<PREC> primnum,
934  VEXint<PREC> ptnum);
935 
936  void setEdgeGroup(
937  exint srcelem,
938  const UT_StringHolder &groupname,
939  VEXint<PREC> ptnum0, VEXint<PREC> ptnum1,
940  VEXint<PREC> data);
941 
942  void addLocalVariable(exint srcelem, const char *attrib, const char *local);
943  void addVisualizer(const UT_StringHolder &visualizer);
944 
945  // If the given primnum is -1, it will treat vtxidx as a linear vertex
946  void rewireVertex( exint srcelem, VEXint<PREC> primum,
947  VEXint<PREC> vtxidx, VEXint<PREC> ptnum);
948 
949  void removeAttrib(VEX_GeoDictType owner, const UT_StringHolder &name);
950  void removePoint(exint srcelem, VEXint<PREC> ptnum, bool includeprims);
951  void removePrim(exint srcelem, VEXint<PREC> primnum, bool includepoints);
952  void removeVertex(exint srcelem, VEXint<PREC> primnum);
953 
954  void setAgentChannelValue(exint srcelem, VEXint<PREC> primnum,
955  VEXfloat<PREC> value,
956  VEXint<PREC> channelidx);
957 
958  void setAgentTransform(exint srcelem, VEXint<PREC> primnum,
959  const VEXmat4<PREC> &xform, VEXint<PREC> xformidx,
960  bool worldspace);
961 
962  void setAgentTransforms(exint srcelem, VEXint<PREC> primnum,
963  const UT_Array<VEXmat4<PREC>> &xforms,
964  bool worldspace);
965 
966  void setAgentClips(exint srcelem, VEXint<PREC> primnum,
967  const UT_Array<VEXint<PREC>> &clipids,
968  const UT_Array<VEXfloat<PREC>> &cliptimes,
969  const UT_Array<VEXfloat<PREC>> &clipweights,
970  const UT_Array<VEXint<PREC>> &clipxformgroupids,
971  const UT_Array<VEXint<PREC>> &cliplayerids,
972  const UT_Array<VEXint<PREC>> &cliplayermodes,
973  const UT_Array<VEXfloat<PREC>> &cliplayerweights,
974  const UT_Array<VEXint<PREC>> &cliplayerparents);
975 
976  void setAgentLayers(exint srcelem, VEXint<PREC> primnum,
977  const UT_Array<VEXint<PREC>> &layer_ids,
978  bool is_collision);
979 
980  void agentAddClip(
981  exint srcelem,
982  VEXint<PREC> primnum,
983  const UT_StringHolder &clip_name,
984  const UT_StringHolder &clip,
985  const bool keep_ref);
986 
987  void primChannelInsertKey(exint srcelem,
988  VEXint<PREC> primnum,
989  float time);
990 
991  void primChannelDestroyKey(exint srcelem,
992  VEXint<PREC> primnum,
993  float time);
994 
995  void primChannelClear(exint srcelem, VEXint<PREC> primnum);
996 
997  void primChannelSetKeyValue(exint srcelem, VEXint<PREC> primnum,
998  float time, float value,
1000 
1001  void primChannelSetKeySlope(exint srcelem, VEXint<PREC> primnum,
1002  float time, float slope,
1004 
1005  void primChannelSetKeyAccel(exint srcelem, VEXint<PREC> primnum,
1006  float time, float accel,
1008 
1010  const UT_StringRef &name);
1011  VEX_GeoAttribEdit<PREC> *findOrCreateEdit(VEX_GeoDictType dict,
1012  const UT_StringRef &name);
1013 
1014  // Finds a list of VEX edits to the given primitive (or property) path and
1015  // name (could be a property or metadata item). We need to store the path
1016  // as well as the name for USD edits so that we apply the edits walking
1017  // down the scene graph hierarchy. This ensures that edits to attribs on
1018  // a prim will occur after the prim has been created, or edits to metadata
1019  // on a property will occur after the property has been created.
1020  VEX_UsdEdit<PREC> *findOrCreateUsdEdit(VEX_GeoDictType dict,
1021  const UT_StringRef &path,
1022  const UT_StringRef &name);
1023 
1024  VEX_GeoEdgeGroupEdit<PREC> *findOrCreateEdgeGroupEdit(
1025  const UT_StringHolder &groupname);
1026 
1027  // Creators
1031  // Requested local variables.
1033  {
1035  const char *local; // hardened!
1036  };
1038 
1041 
1042  // Edits
1054 
1056 
1057  // Destructors
1058  // Note we don't have to sort these. We do need to track
1059  // the source element to be able to lookup the relevant point
1060  // or primitive number, however.
1066 
1067  typedef UT_PageArray<
1068  /* DATA_T */ VEXint<PREC>,
1069  /* TSIZE */ 1,
1070  /* TABLEHARDENED (owns its data) */ true,
1071  /* PAGESHARDENED */ false,
1072  /* THEPAGEBITS (2^10 tuples/page) */ 10,
1073  /* INDEX_T */ exint
1078 
1079  exint myNumPrim, myNumPoint, myNumVertex;
1080 
1081 private:
1082  UT_SharedString *myStrings;
1083  UT_Array< UT_Array<VEXint<PREC>> *> myIntArrays;
1084  UT_Array< UT_Array<VEXfloat<PREC>> *> myFloatArrays;
1085  UT_Array< UT_Array<VEXvec2<PREC>> *> myV2Arrays;
1086  UT_Array< UT_Array<VEXvec3<PREC>> *> myV3Arrays;
1087  UT_Array< UT_Array<VEXvec4<PREC>> *> myV4Arrays;
1088  UT_Array< UT_Array<VEXmat2<PREC>> *> myM2Arrays;
1089  UT_Array< UT_Array<VEXmat3<PREC>> *> myM3Arrays;
1090  UT_Array< UT_Array<VEXmat4<PREC>> *> myM4Arrays;
1091  UT_Array< UT_Array<const char *> *> myCstArrays;
1092  UT_Array< UT_Array<UT_OptionsHolder> *> myDictArrays;
1093 };
1094 
1100 
1106 
1107 #endif
exint elem() const
VEX_GeoCommandAgentAddClip(exint srcelem, VEXint< PREC > primnum, const UT_StringHolder &clip_name, const UT_StringHolder &clip_path, bool keep_ref)
VEX_Type
VEX variable types.
Definition: VEX_VexTypes.h:18
UT_Array< VEX_GeoCommandPrimAdd< PREC > > myPrimAdd
GLint first
Definition: glcorearb.h:405
const UT_Array< VEXfloat< PREC > > & clipweights() const
#define VEX_GEOATTRIBEDIT_CASE_ARRAY(ty, name)
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
VEX_GeoCommandAgentClipEdit(exint srcelem, VEXint< PREC > primnum, const UT_Array< VEXint< PREC >> &clipids, const UT_Array< VEXfloat< PREC >> &cliptimes, const UT_Array< VEXfloat< PREC >> &clipweights, const UT_Array< VEXint< PREC >> &clipxformgroupids, const UT_Array< VEXint< PREC >> &cliplayerids, const UT_Array< VEXint< PREC >> &cliplayermodes, const UT_Array< VEXfloat< PREC >> &cliplayerweights, const UT_Array< VEXint< PREC >> &cliplayerparents)
UT_Array< VEX_GeoCommandAgentXformEdit< PREC > > myAgentXformEdit
const char * local
void set(VEXmat3< PREC > v)
int int32
Definition: SYS_Types.h:39
VEXint< PREC > primnum() const
VEX_GeoCommandAgentXformEdit(exint srcelem, VEXint< PREC > primnum, const UT_Array< VEXmat4< PREC >> &xforms, bool worldspace)
UT_StringMap< VariableEntry > myLocalVariables
UT_Array< VEX_GeoEdgeGroupEdit< PREC > * > myEdgeGroupEdit
const UT_Array< VEXint< PREC > > & cliplayerids() const
VEX_GeoCommandAgentLayerEdit(exint srcelem, VEXint< PREC > primnum, const UT_Array< VEXint< PREC >> &layer_ids, bool is_collision)
GA_API const UT_StringHolder accel
UT_StringHolder myName
imath_half_bits_t half
if we're in a C-only context, alias the half bits type to half
Definition: half.h:266
void set(VEXint< PREC > v)
void
Definition: png.h:1083
const SEC_ID & secID() const
UT_PageArray< VEXint< PREC >, 1, true, false, 10, exint > BlockArray
GT_API const UT_StringHolder time
const OBJ_ID & objID() const
const GLdouble * v
Definition: glcorearb.h:837
std::pair< VEXmat4< PREC >, VEXint< PREC > > SingleEdit
VEXint< PREC > primnum() const
VEX_Type type() const
VEXint< PREC > primnum() const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
VEX_GeoEdgeGroupEdit(const UT_StringHolder &groupname)
UT_Array< VEX_GeoCommandEdgeGroupEdit< PREC > > myCmdList
UT_StringSet * myNewVisualizers
UT_Array< VEXint< PREC > > myClipXformGroupIds
int64 exint
Definition: SYS_Types.h:125
constexpr VEX_Precision VEX_64
Definition: VEX_PodTypes.h:31
std::variant< SingleEdit, FullEdit > myData
UT_Array< VEXfloat< PREC > > myClipTimes
VEX_API VEX_GeoPrimType typeFromString(const char *)
GLdouble s
Definition: glad.h:3009
UT_Array< VEXint< PREC > > myClipLayerIds
VEX_GeoCommandPrimAdd(exint srcelem, VEX_GeoPrimType primtype)
VEXint< PREC > ptnum() const
VEX_GeoCommandPointAdd(exint srcelem, VEXint< PREC > srcpt)
UT_Array< VEX_GeoCommandAgentChannelEdit< PREC > > myAgentChannelEdit
#define VEX_GEOATTRIBEDIT_CASE_DIRECT(ty, name)
const UT_StringHolder & name() const
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
#define VEX_API
Definition: VEX_API.h:14
const UT_StringHolder & groupName() const
VEX_GeoDictType dict() const
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:819
VEX_GeoCommandAgentChannelEdit(exint srcelem, VEXint< PREC > primnum, const VEXfloat< PREC > &value, VEXint< PREC > channelidx)
typename VEX_PrecisionResolver< P >::vec3_type VEXvec3
Definition: VEX_PodTypes.h:70
exint elem
VEX_GeoTypeInfo typeinfo() const
UT_Array< VEX_GeoCommandObjectRemove< PREC > > myPrimRemove
VEXint< PREC > primnum() const
#define VEX_GEOATTRIBEDIT_CASE(vtype, type, name, isarray)
void set(VEXmat4< PREC > v)
VEXint< PREC > data() const
UT_Array< VEXmat4< PREC > > FullEdit
UT_Array< VEXint< PREC > > myClipLayerParents
bool isEmpty() const
VEX_GeoDictType
UT_Array< VEX_UsdEdit< PREC > * > myUsdEdit
VEX_AttribEditIndexMap myUsdEditIndexMap
UT_Array< VEX_GeoCommandAgentClipEdit< PREC > > myAgentClipEdit
void set(VEXfloat< PREC > v)
VEX_GeoCommandEdgeGroupEdit(exint srcelem, VEXint< PREC > ptnum0, VEXint< PREC > ptnum1, VEXint< PREC > data)
VEX_GeoTypeInfo
GLfloat f
Definition: glcorearb.h:1926
VEXint< PREC > xformidx() const
UT_StringHolder myGroupName
const UT_Array< VEX_GeoCommandEdgeGroupEdit< PREC > > & cmd() const
VEXfloat< PREC > value() const
DefaultValue myDefValue
VEX_GeoCommand(exint srcelem)
bool shouldcreate() const
UT_StringHolder myPath
VEX_GeoCommandAgentXformEdit(exint srcelem, VEXint< PREC > primnum, const VEXmat4< PREC > &xform, VEXint< PREC > xformidx, bool worldspace)
VEX_GeoCommandObjectRemove(exint srcelem, VEXint< PREC > obj_id)
VEXint< PREC > primnum() const
typename VEX_PrecisionResolver< P >::float_type VEXfloat
Definition: VEX_PodTypes.h:67
void set(VEXmat2< PREC > v)
VEX_GeoMode
SYS_FORCE_INLINE const UT_StringHolder & UTmakeUnsafeRef(const UT_StringRef &ref)
Convert a UT_StringRef into a UT_StringHolder that is a shallow reference.
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
VEXint< PREC > primnum() const
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
VEXint< PREC > myPrimNum
VEX_GeoDictType myDict
UT_Array< VEX_GeoCommandPrimChannelEdit< PREC > > myPrimChannelEdit
UT_Array< VEX_GeoCommandPointAdd< PREC > > myPointAdd
long long int64
Definition: SYS_Types.h:116
VEX_AttribEditIndexMap myAttribEditIndexMap
VEXint< PREC > srcpt() const
UT_Array< VEXint< PREC > > myClipIds
VEX_GeoPrimType myType
constexpr VEX_Precision VEX_32
Definition: VEX_PodTypes.h:30
typename VEX_PrecisionResolver< P >::mat4_type VEXmat4
Definition: VEX_PodTypes.h:74
const VEXmat4< PREC > & xform() const
GLuint const GLchar * name
Definition: glcorearb.h:786
VEX_API std::size_t hash_value(const VEX_AttribEditId &id)
const UT_Array< VEXint< PREC > > & clipxformgroupids() const
VEXint< PREC > ptNum0() const
VEX_GeoCommandPrimChannelEdit(exint srcelem, VEXint< PREC > primnum, VEX_GeoPrimChannelOperation operation, float time=0.0, float value=0.0, VEX_GeoPrimChannelKeyHalf half=VEX_GeoPrimChannelKeyHalf::InOut)
void set(VEXvec2< PREC > v)
VEX_GeoPrimChannelKeyHalf
VEXint< PREC > ptNum1() const
const UT_Array< VEXint< PREC > > & layerIds() const
UT_Array< VEX_GeoCommandObjectRemove< PREC > > myVertexRemove
const UT_Array< VEXint< PREC > > & cliplayermodes() const
GLenum mode
Definition: glcorearb.h:99
VEX_DataCommandAttribEdit(exint srcelem, const OBJ_ID &obj_id, const SEC_ID &sec_id, VEX_GeoMode mode, T data)
VEX_EXTERN_TEMPLATE(VEX_AttribEdit< VEX_32, VEXint< VEX_32 >, VEXint< VEX_32 >>)
VEX_API VEX_GeoMode modeFromString(const char *)
typename VEX_PrecisionResolver< P >::mat2_type VEXmat2
Definition: VEX_PodTypes.h:72
VEXint< PREC > primnum() const
UT_StringHolder myName
VEX_GeoTypeInfo myTypeInfo
typename VEX_PrecisionResolver< P >::vec2_type VEXvec2
Definition: VEX_PodTypes.h:69
VEX_GeoCommandPointAdd(exint srcelem, VEXvec3< PREC > pos)
VEX_AttribEditId(VEX_GeoDictType dict, const UT_StringRef &path, const UT_StringRef &name, UseUnsafeStringsType)
const UT_Array< VEXfloat< PREC > > & cliplayerweights() const
VEXint< PREC > ptnum() const
UT_Array< VEX_GeoCommandVertexAdd< PREC > > myVertexAdd
UT_Array< VEXint< PREC > > myClipLayerModes
UT_Array< VEXfloat< PREC > > myClipLayerWeights
const UT_Array< VEXmat4< PREC > > & xforms() const
bool operator==(const VEX_AttribEditId &other) const
UT_Array< VEX_GeoCommandObjectRemove< PREC > > myPointWithPrimRemove
VEXvec3< PREC > myPos
VEX_GeoPrimType type() const
UT_Array< VEX_GeoCommandVertexRewire< PREC > > myVertexRewire
VEX_AttribEditId(VEX_GeoDictType dict, const UT_StringHolder &path, const UT_StringHolder &name)
VEXint< PREC > mySrcPt
UT_Array< VEX_GeoCommandObjectRemove< PREC > > myPrimWithPointRemove
typename VEX_PrecisionResolver< P >::vec4_type VEXvec4
Definition: VEX_PodTypes.h:71
UT_StringHolder myPath
UT_Array< VEX_GeoCommandAgentLayerEdit< PREC > > myAgentLayerEdit
VEXint< PREC > channelIdx() const
UT_Array< VEXfloat< PREC > > myClipWeights
typename VEX_PrecisionResolver< P >::int_type VEXint
Definition: VEX_PodTypes.h:68
VEXint< PREC > vtxidx() const
VEX_API VEX_GeoDictType dictFromString(const char *)
const UT_StringHolder & path() const
VEX_GeoCommandVertexAdd(exint srcelem, VEXint< PREC > primnum, VEXint< PREC > ptnum)
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Definition: core.h:1131
const UT_Array< VEXint< PREC > > & clipids() const
const VEXint< PREC > primnum() const
VEX_GeoPrimType
const UT_Array< VEXfloat< PREC > > & cliptimes() const
UT_Array< VEX_GeoCommandAgentAddClip< PREC > > myAgentAddClip
const DefaultValue & defaultValue() const
VEX_GeoPrimChannelKeyHalf myHalf
void set(VEXvec4< PREC > v)
bool isArray() const
type
Definition: core.h:1059
const UT_Array< VEXint< PREC > > & cliplayerparents() const
VEX_GeoPrimChannelOperation
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T clip(const T &p, const Box< T > &box) IMATH_NOEXCEPT
Definition: ImathBoxAlgo.h:29
typename VEX_PrecisionResolver< P >::mat3_type VEXmat3
Definition: VEX_PodTypes.h:73
void sort(I begin, I end, const Pred &pred)
Definition: pugixml.cpp:7334
VEXvec3< PREC > pos() const
UT_Array< VEX_GeoAttribEdit< PREC > * > myAttribEdit
UT_Array< VEX_GeoCommandObjectRemove< PREC > > myPointRemove
VEX_GeoMode mode() const
VEX_GeoCommandAgentClipEdit & operator=(const VEX_GeoCommandAgentClipEdit &)=default
VEX_GeoCommandVertexRewire(exint srcelem, VEXint< PREC > primnum, VEXint< PREC > vtxidx, VEXint< PREC > newptnum)
VEX_GeoPrimChannelOperation myOperation
void set(VEXvec3< PREC > v)
Definition: format.h:895
VEXint< PREC > objID() const
VEX_GeoDictType myDict
GLenum src
Definition: glcorearb.h:1793
VEX_API VEX_GeoTypeInfo typeinfoFromString(const char *)