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 
17 #include "VEX_Types.h"
18 
19 #include <UT/UT_Array.h>
20 #include <UT/UT_SharedString.h>
21 #include <UT/UT_StringHolder.h>
22 #include <UT/UT_StringSet.h>
23 #include <UT/UT_Vector3.h>
24 #include <UT/UT_VectorTypes.h>
25 #include <UT/UT_IntArray.h>
26 #include <UT/UT_PageArray.h>
27 
28 #include <hboost/variant.hpp>
29 
30 // Do NOT use VEX_API here for template classes with all code in the header!
31 
32 enum class VEX_GeoMode
33 {
34  SET,
35  ADD,
36  MAX,
37  MIN,
38  MULTIPLY,
39  TOGGLE,
40  APPEND,
41 
42  INVALID
43 };
44 enum class VEX_GeoPrimType
45 {
46  POLY_OPEN,
48  TET,
49  SPHERE,
50  CIRCLE,
51  TUBE,
52  METABALL,
53  METASQUAD,
55  PACKEDDISK,
56  HEX,
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 
91 namespace VEX_Geo
92 {
93  VEX_API VEX_GeoMode modeFromString(const char*);
97 
98 } // namespace VEX_Geo
99 
101 {
102 public:
103  VEX_GeoCommand(exint srcelem) { mySourceElem = srcelem; }
104  VEX_GeoCommand(): mySourceElem(-1) {}
105 
106  exint elem() const { return mySourceElem; }
107 
108 protected:
110 };
111 
112 template <VEX_Precision PREC>
114 {
115 public:
117  : VEX_GeoCommand(srcelem)
118  , myType(primtype)
119  {
120  }
122 
123  VEX_GeoPrimType type() const { return myType; }
124 
125 protected:
127 };
128 
129 template <VEX_Precision PREC>
131 {
132 public:
134  : VEX_GeoCommand(srcelem)
135  , myPos(pos)
136  , mySrcPt(-1)
137  {
138  }
140  : VEX_GeoCommand(srcelem)
141  , myPos(0.0, 0.0, 0.0)
142  , mySrcPt(srcpt)
143  {
144  }
146 
147  VEXvec3<PREC> pos() const { return myPos; }
148  VEXint<PREC> srcpt() const { return mySrcPt; }
149 
150 protected:
151  // Ideally we'd union, but C++ makes this frustrating.
154 };
155 
156 template <VEX_Precision PREC>
158 {
159 public:
162  : VEX_GeoCommand(srcelem)
163  , myPrimNum(primnum)
164  , myPtNum(ptnum)
165  {
166  }
168 
169  VEXint<PREC> primnum() const { return myPrimNum; }
170  VEXint<PREC> ptnum() const { return myPtNum; }
171 
172 protected:
175 };
176 
177 template <VEX_Precision PREC>
179 {
180 public:
182  : VEX_GeoCommand(srcelem)
183  , myObjID(obj_id)
184  {
185  }
187 
188  VEXint<PREC> objID() const { return myObjID; }
189 
190 protected:
192 };
193 
194 namespace VEX_DataObjID
195 {
196  static SYS_FORCE_INLINE void initID(int32 &id) { id = -1; }
197  static SYS_FORCE_INLINE bool isValidID(int32 id) { return id >= 0; }
198 
199  static SYS_FORCE_INLINE void initID(int64 &id) { id = -1; }
200  static SYS_FORCE_INLINE bool isValidID(int64 id) { return id >= 0; }
201 
202  static SYS_FORCE_INLINE void initID(UT_StringHolder &id) { id.clear(); }
203  static SYS_FORCE_INLINE bool isValidID(const UT_StringHolder &id)
204  { return id.isstring(); }
205 
206  static SYS_FORCE_INLINE void initID(UT_OptionsHolder &id) { id.clear(); }
207  static SYS_FORCE_INLINE bool isValidID(const UT_OptionsHolder &id)
208  { return !id.isEmpty(); }
209 };
210 
211 template <VEX_Precision PREC, typename OBJ_ID, typename SEC_ID, typename T>
213 {
214 public:
216  exint srcelem, const OBJ_ID &obj_id, const SEC_ID &sec_id,
218  : VEX_GeoCommand(srcelem)
219  , myObjID(obj_id)
220  , mySecID(sec_id)
221  , myMode(mode)
222  , myData(data)
223  {
224  }
226  : mySecID(-1)
228  , myData(T())
229  {
230  VEX_DataObjID::initID(myObjID);
231  }
232 
233  const OBJ_ID & objID() const { return myObjID; }
234  const SEC_ID & secID() const { return mySecID; }
235  VEX_GeoMode mode() const { return myMode; }
236  T data() const { return myData; }
237 
238 protected:
239  OBJ_ID myObjID;
240  SEC_ID mySecID;
243 };
244 
245 template <VEX_Precision PREC, typename T>
248 template <VEX_Precision PREC, typename T>
251 
252 template <VEX_Precision PREC>
254 {
255 public:
257  exint srcelem, VEXint<PREC> primnum,
258  VEXint<PREC> vtxidx, VEXint<PREC> newptnum)
259  : VEX_GeoCommand(srcelem)
260  , myPrimNum(primnum)
261  , myVtxIdx(vtxidx)
262  , myPtNum(newptnum)
263  {
264  }
266 
267  // -1 for primnum implies a linear vertex
268  VEXint<PREC> primnum() const { return myPrimNum; }
269  VEXint<PREC> vtxidx() const { return myVtxIdx; }
270  VEXint<PREC> ptnum() const { return myPtNum; }
271 
272 protected:
273  VEXint<PREC> myPrimNum, myVtxIdx, myPtNum;
274 };
275 
276 template <VEX_Precision PREC>
278 {
279 public:
281  const VEXfloat<PREC> &value,
282  VEXint<PREC> channelidx)
283  : VEX_GeoCommand(srcelem),
284  myPrimNum(primnum),
285  myValue(value),
286  myChannelIdx(channelidx)
287  {
288  }
289 
291  : myPrimNum(-1), myValue(0.0), myChannelIdx(-1)
292  {
293  }
294 
295  VEXint<PREC> primnum() const { return myPrimNum; }
296  VEXfloat<PREC> value() const { return myValue; }
297  VEXint<PREC> channelIdx() const { return myChannelIdx; }
298 
299 private:
300  VEXint<PREC> myPrimNum;
301  VEXfloat<PREC> myValue;
302  VEXint<PREC> myChannelIdx;
303 };
304 
305 template <VEX_Precision PREC>
307 {
308 public:
310  const VEXmat4<PREC> &xform, VEXint<PREC> xformidx, bool worldspace)
311  : VEX_GeoCommand(srcelem),
312  myPrimNum(primnum),
313  myData(SingleEdit(xform, xformidx)),
314  myWorldSpace(worldspace)
315  {
316  }
318  const UT_Array<VEXmat4<PREC>> &xforms, bool worldspace)
319  : VEX_GeoCommand(srcelem),
320  myPrimNum(primnum),
322  myWorldSpace(worldspace)
323  {
324  }
326 
327  VEXint<PREC> primnum() const { return myPrimNum; }
328  const VEXmat4<PREC> &xform() const
329  {
330  UT_ASSERT(myData.which() == 0);
331  return hboost::get<SingleEdit>(myData).first;
332  }
333  VEXint<PREC> xformidx() const
334  {
335  UT_ASSERT(myData.which() == 0);
336  return hboost::get<SingleEdit>(myData).second;
337  }
339  {
340  UT_ASSERT(myData.which() == 1);
341  return hboost::get<FullEdit>(myData);
342  }
343  bool worldspace() const { return myWorldSpace; }
344 
345  bool isSingleEdit() const { return myData.which() == 0; }
346 
347 protected:
348  typedef std::pair<VEXmat4<PREC>,VEXint<PREC>> SingleEdit;
350 
351  VEXint<PREC> myPrimNum;
352  // Allow setting a single transform or setting all of them
353  hboost::variant<SingleEdit, FullEdit> myData;
355 };
356 
357 template <VEX_Precision PREC>
359 {
360 public:
362  const UT_Array<VEXint<PREC>> &clipids,
365  const UT_Array<VEXint<PREC>> &clipxformgroupids,
366  const UT_Array<VEXint<PREC>> &cliplayerids,
367  const UT_Array<VEXint<PREC>> &cliplayermodes,
369  const UT_Array<VEXint<PREC>> &cliplayerparents)
370  : VEX_GeoCommand(srcelem),
371  myPrimNum(primnum),
380  {
381  }
382 
383  VEX_GeoCommandAgentClipEdit() = default;
388 
389  const VEXint<PREC> primnum() const { return myPrimNum; }
390  const UT_Array<VEXint<PREC>> &clipids() const { return myClipIds; }
391  const UT_Array<VEXfloat<PREC>> &cliptimes() const { return myClipTimes; }
398 
399 protected:
400  VEXint<PREC> myPrimNum;
409 };
410 
411 template <VEX_Precision PREC>
413 {
414 public:
416  const UT_Array<VEXint<PREC>> &layer_ids, bool is_collision)
417  : VEX_GeoCommand(srcelem),
418  myPrimNum(primnum),
419  myLayerIds(layer_ids),
420  myIsCollision(is_collision)
421  {
422  }
423  VEX_GeoCommandAgentLayerEdit() = default;
424 
425  VEXint<PREC> primnum() const { return myPrimNum; }
426  const UT_Array<VEXint<PREC>> &layerIds() const { return myLayerIds; }
427  bool isCollision() const { return myIsCollision; }
428 
429 private:
430  VEXint<PREC> myPrimNum = -1;
431  UT_Array<VEXint<PREC>> myLayerIds;
432  bool myIsCollision = false;
433 };
434 
435 class CL_Clip;
436 
437 template <VEX_Precision PREC>
439 {
440 public:
442  exint srcelem,
443  VEXint<PREC> primnum,
444  const UT_StringHolder &clip_name,
445  const UT_StringHolder &clip_path,
446  bool keep_ref)
447  : VEX_GeoCommand(srcelem)
448  , myPrimNum(primnum)
449  , myClipName(clip_name)
450  , myClipPath(clip_path)
451  , myKeepRef(keep_ref)
452  {
453  }
455  : VEX_GeoCommand()
456  , myPrimNum(-1)
457  , myClipName()
458  , myClipPath()
459  , myKeepRef(true)
460  {
461  }
462 
463  VEXint<PREC> primnum() const { return myPrimNum; }
464 
465  VEXint<PREC> myPrimNum;
468  bool myKeepRef;
469 };
470 
471 template <VEX_Precision PREC, typename OBJ_ID, typename SEC_ID>
473 {
474 public:
475  //
476  // A variant of all VEXint,VEXfloat,VEXvecN,VEXmatN types
478  {
479  public:
480  DefaultValue() { memset(f, 0, sizeof(VEXfloat<PREC>)*16); i = 0; }
481 
482  void set(VEXint<PREC> v) { i = v; }
483  void set(VEXfloat<PREC> v) { f[0] = v; }
484  void set(VEXvec2<PREC> v) { memcpy(f, &v, sizeof(v)); }
485  void set(VEXvec3<PREC> v) { memcpy(f, &v, sizeof(v)); }
486  void set(VEXvec4<PREC> v) { memcpy(f, &v, sizeof(v)); }
487  void set(VEXmat2<PREC> v) { memcpy(f, &v, sizeof(v)); }
488  void set(VEXmat3<PREC> v) { memcpy(f, &v, sizeof(v)); }
489  void set(VEXmat4<PREC> v) { memcpy(f, &v, sizeof(v)); }
490 
492  VEXint<PREC> i;
493  };
494 
496  const UT_StringHolder &name);
497  // This constructor is only used for the VEX_UsdEdit incarnation of
498  // this class. This avoids having to define a subclass and introducing
499  // virtual function calls. The path is used to group and sort USD edits
500  // according to their location in the scene graph tree, rather than just
501  // using the attribute name or metadata key (which are supplied in the
502  // name parameter).
504  const UT_StringHolder &path,
505  const UT_StringHolder &name);
506  ~VEX_AttribEdit();
507 
508  void setTypeInfo(exint srcelem,
509  const char *typeinfo);
510 
511  void addAttribute(exint srcelem,
512  VEX_Type type,
513  bool isarray,
514  const DefaultValue &value);
515 
516  void appendEdit(exint srcelem,
517  const OBJ_ID &obj_id,
518  const SEC_ID &sec_id,
521  void appendEdit(exint srcelem,
522  const OBJ_ID &obj_id,
523  const SEC_ID &sec_id,
525  VEXint<PREC> data);
526  void appendEdit(exint srcelem,
527  const OBJ_ID &obj_id,
528  const SEC_ID &sec_id,
531  void appendEdit(exint srcelem,
532  const OBJ_ID &obj_id,
533  const SEC_ID &sec_id,
536  void appendEdit(exint srcelem,
537  const OBJ_ID &obj_id,
538  const SEC_ID &sec_id,
541  void appendEdit(exint srcelem,
542  const OBJ_ID &obj_id,
543  const SEC_ID &sec_id,
546  void appendEdit(exint srcelem,
547  const OBJ_ID &obj_id,
548  const SEC_ID &sec_id,
551  void appendEdit(exint srcelem,
552  const OBJ_ID &obj_id,
553  const SEC_ID &sec_id,
556  void appendEdit(exint srcelem,
557  const OBJ_ID &obj_id,
558  const SEC_ID &sec_id,
560  const char *data);
561  void appendEdit(exint srcelem,
562  const OBJ_ID &obj_id,
563  const SEC_ID &sec_id,
565  UT_OptionsHolder dict);
566  void appendEdit(exint srcelem,
567  const OBJ_ID &obj_id,
568  const SEC_ID &sec_id,
570  const UT_Array<VEXfloat<PREC>> *data);
571  void appendEdit(exint srcelem,
572  const OBJ_ID &obj_id,
573  const SEC_ID &sec_id,
575  const UT_Array<VEXvec2<PREC>> *data);
576  void appendEdit(exint srcelem,
577  const OBJ_ID &obj_id,
578  const SEC_ID &sec_id,
580  const UT_Array<VEXvec3<PREC>> *data);
581  void appendEdit(exint srcelem,
582  const OBJ_ID &obj_id,
583  const SEC_ID &sec_id,
585  const UT_Array<VEXvec4<PREC>> *data);
586  void appendEdit(exint srcelem,
587  const OBJ_ID &obj_id,
588  const SEC_ID &sec_id,
590  const UT_Array<VEXmat2<PREC>> *data);
591  void appendEdit(exint srcelem,
592  const OBJ_ID &obj_id,
593  const SEC_ID &sec_id,
595  const UT_Array<VEXmat3<PREC>> *data);
596  void appendEdit(exint srcelem,
597  const OBJ_ID &obj_id,
598  const SEC_ID &sec_id,
600  const UT_Array<VEXmat4<PREC>> *data);
601  void appendEdit(exint srcelem,
602  const OBJ_ID &obj_id,
603  const SEC_ID &sec_id,
605  const UT_Array<VEXint<PREC>> *data);
606  void appendEdit(exint srcelem,
607  const OBJ_ID &obj_id,
608  const SEC_ID &sec_id,
611  void appendEdit(exint srcelem,
612  const OBJ_ID &obj_id,
613  const SEC_ID &sec_id,
616 
617 
618  // This may steal the command list from the source!
619  void merge(VEX_AttribEdit &src);
620 
621  void sort();
622 
623  void clear();
624 
625  // These convert our command list to the specified type.
626  //
627  // If the stored VEX_Type matches the return type, the result will be
628  // valid. Otherwise nullptr is returned.
629 
630  // Functions:
631  // fCmd, iCmd, v2Cmd, v3Cmd, v4Cmd, m2Cmd, m3Cmd, m4Cmd, sCmd, dCmd
632  // afCmd, aiCmd, av2Cmd, av3Cmd, av4Cmd, am2Cmd, am3Cmd, am4Cmd, asCmd, adCmd
633 #define VEX_GEOATTRIBEDIT_CASE(vtype, type, name, isarray) \
634  UT_Array<VEX_DataCommandAttribEdit<PREC, OBJ_ID, SEC_ID, type>> * \
635  name##Cmd() \
636  {\
637  if (myType == vtype && myIsArray == isarray)\
638  return (UT_Array<VEX_DataCommandAttribEdit<PREC, OBJ_ID, SEC_ID, type>>*) myCmdList;\
639  return nullptr;\
640  }
641 #define VEX_GEOATTRIBEDIT_CASE_DIRECT(ty, name) \
642  VEX_GEOATTRIBEDIT_CASE(VEX_VexTypeResolver<VEX##ty<PREC>>::type,VEX##ty<PREC>,name,false)
643 #define VEX_GEOATTRIBEDIT_CASE_ARRAY(ty, name) \
644  VEX_GEOATTRIBEDIT_CASE(VEX_VexTypeResolver<VEX##ty<PREC>>::type,const UT_Array<VEX##ty<PREC>>*,name,true)
645 
654 
657 
666 
667  VEX_GEOATTRIBEDIT_CASE(VEX_TYPE_STRING, const UT_Array<const char*>*, as, true)
668  VEX_GEOATTRIBEDIT_CASE(VEX_TYPE_DICT, const UT_Array<UT_OptionsHolder>*, ad, true)
669 
670 #undef VEX_GEOATTRIBEDIT_CASE_ARRAY
671 #undef VEX_GEOATTRIBEDIT_CASE_DIRECT
672 #undef VEX_GEOATTRIBEDIT_CASE
673 
674  VEX_GeoDictType dict() const { return myDict; }
675  const UT_StringHolder &name() const { return myName; }
676  VEX_Type type() const { return myType; }
677  bool isArray() const { return myIsArray; }
678  bool shouldcreate() const { return myDoCreate; }
679  VEX_GeoTypeInfo typeinfo() const { return myTypeInfo; }
680  const DefaultValue &defaultValue() const { return myDefValue; }
681 
682  // The path component is only used by USD edits, to hold the primitive or
683  // property path so that we can sort the edits and apply them in the order
684  // of the scene graph hierarchy.
685  const UT_StringHolder &path() const { return myPath; }
686 
687 protected:
688  // The earliest proc that refered to us.
694  bool myIsArray;
695  // The proc that set the typeinfo.
696  // Because we are logically overwriting, it makes sense for this
697  // to be the last person to set it!
700 
701  void *myCmdList;
702  // The proc that marked us for creation
705  DefaultValue myDefValue;
706 };
707 
709 {
710 public:
713  };
715  const UT_StringRef &path,
716  const UT_StringRef &name,
718  : myDict(dict),
719  myPath(UTmakeUnsafeRef(path)),
720  myName(UTmakeUnsafeRef(name))
721  { }
723  const UT_StringHolder &path,
724  const UT_StringHolder &name)
725  : myDict(dict),
726  myPath(path),
727  myName(name)
728  { }
729 
730  bool operator==(const VEX_AttribEditId &other) const
731  {
732  return myDict == other.myDict &&
733  myPath == other.myPath &&
734  myName == other.myName;
735  }
736 
740 };
741 std::size_t hash_value(const VEX_AttribEditId &id);
743 
744 template <VEX_Precision PREC>
746 template <VEX_Precision PREC>
748 
749 template <VEX_Precision PREC>
751 {
752 public:
754  exint srcelem,
755  VEXint<PREC> ptnum0, VEXint<PREC> ptnum1,
756  VEXint<PREC> data)
757  : VEX_GeoCommand(srcelem)
758  , myPtNum0(ptnum0)
759  , myPtNum1(ptnum1)
760  , myData(data)
761  {
762  }
764  : VEX_GeoCommand(), myPtNum0(-1) , myPtNum1(-1), myData(-1)
765  {}
766 
767  VEXint<PREC> ptNum0() const { return myPtNum0; }
768  VEXint<PREC> ptNum1() const { return myPtNum1; }
769  VEXint<PREC> data() const { return myData; }
770 
771 protected:
772  VEXint<PREC> myPtNum0;
773  VEXint<PREC> myPtNum1;
774  VEXint<PREC> myData;
775 };
776 
777 template <VEX_Precision PREC>
779 {
780 public:
781  VEX_GeoEdgeGroupEdit(const UT_StringHolder &groupname): myGroupName(groupname) {}
782 
783  const UT_StringHolder &groupName() const { return myGroupName; }
784 
785  const UT_Array<VEX_GeoCommandEdgeGroupEdit<PREC>> &cmd() const { return myCmdList; }
786 
787  void appendEdit(exint srcelem,
788  VEXint<PREC> ptnum0,
789  VEXint<PREC> ptnum1,
790  VEXint<PREC> data);
791 
792  void merge(VEX_GeoEdgeGroupEdit &src);
793 
794  void sort();
795 
796 protected:
799 };
800 
801 template <VEX_Precision PREC>
803 {
804 public:
807 
808  // Converts the given string to one in our string table, ensuring
809  // the pointer remains valid and avoids duplication.
810  const char *hardenString(const char *str);
811 
812  // Creates a new array which is owned by this queue. Does
813  // not de-duplicate, but will return 0 for empty lists.
814  const UT_Array<VEXfloat<PREC>> *hardenArray(const UT_Array<VEXfloat<PREC>> &arr);
815  const UT_Array<VEXvec2<PREC>> *hardenArray(const UT_Array<VEXvec2<PREC>> &arr);
816  const UT_Array<VEXvec3<PREC>> *hardenArray(const UT_Array<VEXvec3<PREC>> &arr);
817  const UT_Array<VEXvec4<PREC>> *hardenArray(const UT_Array<VEXvec4<PREC>> &arr);
818  const UT_Array<VEXmat2<PREC>> *hardenArray(const UT_Array<VEXmat2<PREC>> &arr);
819  const UT_Array<VEXmat3<PREC>> *hardenArray(const UT_Array<VEXmat3<PREC>> &arr);
820  const UT_Array<VEXmat4<PREC>> *hardenArray(const UT_Array<VEXmat4<PREC>> &arr);
821  const UT_Array<VEXint<PREC>> *hardenArray(const UT_Array<VEXint<PREC>> &arr);
822  // ALSO hardens the contents:
823  const UT_Array<const char *> *hardenArray(const UT_Array<const char *> &arr);
824 
825  const UT_Array<UT_OptionsHolder> *hardenArray(const UT_Array<UT_OptionsHolder> &arr);
826 
827  // Merges the src into us. Note that the result may still
828  // reference strings in the stringtable of src, so src must *not*
829  // be deleted until the queue is processed!
830  // This also may destroy src in the merging if stealing is more
831  // efficient.
832  void merge(VEX_GeoCommandQueue &src);
833  // Ensure our commands are in srcelem order.
834  void sort();
835 
836  bool isEmpty() const
837  {
838  return myPointAdd.isEmpty() &&
839  myPrimAdd.isEmpty() &&
840  myVertexAdd.isEmpty() &&
841  myVertexRewire.isEmpty() &&
842  myAttribEdit.isEmpty() &&
843  myUsdEdit.isEmpty() &&
844  myEdgeGroupEdit.isEmpty() &&
845  myAgentChannelEdit.isEmpty() &&
846  myAgentXformEdit.isEmpty() &&
847  myAgentClipEdit.isEmpty() &&
848  myAgentLayerEdit.isEmpty() &&
849  myAgentAddClip.isEmpty() &&
850  myPointRemove.isEmpty() &&
851  myPointWithPrimRemove.isEmpty() &&
852  myPrimRemove.isEmpty() &&
853  myPrimWithPointRemove.isEmpty() &&
854  myVertexRemove.isEmpty() &&
855  myLocalVariables.empty() &&
856  !myNewVisualizers &&
857  !myAttribRemoval[(int)VEX_GeoDictType::DETAIL] &&
858  !myAttribRemoval[(int)VEX_GeoDictType::PRIM] &&
859  !myAttribRemoval[(int)VEX_GeoDictType::PRIMGROUP] &&
860  !myAttribRemoval[(int)VEX_GeoDictType::POINT] &&
861  !myAttribRemoval[(int)VEX_GeoDictType::POINTGROUP] &&
862  !myAttribRemoval[(int)VEX_GeoDictType::VERTEX] &&
863  !myAttribRemoval[(int)VEX_GeoDictType::VERTEXGROUP]
864  ;
865  }
866 
867  // These return the new element number *relative* to the srcelem!
868  VEXint<PREC> addPrim(exint srcelem, VEX_GeoPrimType primtype);
869  VEXint<PREC> addPoint(exint srcelem, VEXvec3<PREC> pos);
870  VEXint<PREC> addPoint(exint srcelem, VEXint<PREC> srcpt);
871  VEXint<PREC> addVertex(exint srcelem, VEXint<PREC> primnum,
872  VEXint<PREC> ptnum);
873 
874  void setEdgeGroup(
875  exint srcelem,
876  const UT_StringHolder &groupname,
877  VEXint<PREC> ptnum0, VEXint<PREC> ptnum1,
878  VEXint<PREC> data);
879 
880  void addLocalVariable(exint srcelem, const char *attrib, const char *local);
881  void addVisualizer(const UT_StringHolder &visualizer);
882 
883  // If the given primnum is -1, it will treat vtxidx as a linear vertex
884  void rewireVertex( exint srcelem, VEXint<PREC> primum,
885  VEXint<PREC> vtxidx, VEXint<PREC> ptnum);
886 
887  void removeAttrib(VEX_GeoDictType owner, const UT_StringHolder &name);
888  void removePoint(exint srcelem, VEXint<PREC> ptnum, bool includeprims);
889  void removePrim(exint srcelem, VEXint<PREC> primnum, bool includepoints);
890  void removeVertex(exint srcelem, VEXint<PREC> primnum);
891 
892  void setAgentChannelValue(exint srcelem, VEXint<PREC> primnum,
894  VEXint<PREC> channelidx);
895 
896  void setAgentTransform(exint srcelem, VEXint<PREC> primnum,
897  const VEXmat4<PREC> &xform, VEXint<PREC> xformidx,
898  bool worldspace);
899 
900  void setAgentTransforms(exint srcelem, VEXint<PREC> primnum,
901  const UT_Array<VEXmat4<PREC>> &xforms,
902  bool worldspace);
903 
904  void setAgentClips(exint srcelem, VEXint<PREC> primnum,
905  const UT_Array<VEXint<PREC>> &clipids,
906  const UT_Array<VEXfloat<PREC>> &cliptimes,
907  const UT_Array<VEXfloat<PREC>> &clipweights,
908  const UT_Array<VEXint<PREC>> &clipxformgroupids,
909  const UT_Array<VEXint<PREC>> &cliplayerids,
910  const UT_Array<VEXint<PREC>> &cliplayermodes,
911  const UT_Array<VEXfloat<PREC>> &cliplayerweights,
912  const UT_Array<VEXint<PREC>> &cliplayerparents);
913 
914  void setAgentLayers(exint srcelem, VEXint<PREC> primnum,
915  const UT_Array<VEXint<PREC>> &layer_ids,
916  bool is_collision);
917 
918  void agentAddClip(
919  exint srcelem,
920  VEXint<PREC> primnum,
921  const UT_StringHolder &clip_name,
922  const UT_StringHolder &clip,
923  const bool keep_ref);
924 
926  const UT_StringRef &name);
927  VEX_GeoAttribEdit<PREC> *findOrCreateEdit(VEX_GeoDictType dict,
928  const UT_StringRef &name);
929 
930  // Finds a list of VEX edits to the given primitive (or property) path and
931  // name (could be a property or metadata item). We need to store the path
932  // as well as the name for USD edits so that we apply the edits walking
933  // down the scene graph hierarchy. This ensures that edits to attribs on
934  // a prim will occur after the prim has been created, or edits to metadata
935  // on a property will occur after the property has been created.
936  VEX_UsdEdit<PREC> *findOrCreateUsdEdit(VEX_GeoDictType dict,
937  const UT_StringRef &path,
938  const UT_StringRef &name);
939 
940  VEX_GeoEdgeGroupEdit<PREC> *findOrCreateEdgeGroupEdit(
941  const UT_StringHolder &groupname);
942 
943  // Creators
947  // Requested local variables.
949  {
951  const char *local; // hardened!
952  };
954 
957 
958  // Edits
970 
971  // Destructors
972  // Note we don't have to sort these. We do need to track
973  // the source element to be able to lookup the relevant point
974  // or primitive number, however.
980 
981  typedef UT_PageArray<
982  /* DATA_T */ VEXint<PREC>,
983  /* TSIZE */ 1,
984  /* TABLEHARDENED (owns its data) */ true,
985  /* PAGESHARDENED */ false,
986  /* THEPAGEBITS (2^10 tuples/page) */ 10,
987  /* INDEX_T */ exint
992 
993  exint myNumPrim, myNumPoint, myNumVertex;
994 
995 private:
996  UT_SharedString *myStrings;
997  UT_Array< UT_Array<VEXint<PREC>> *> myIntArrays;
998  UT_Array< UT_Array<VEXfloat<PREC>> *> myFloatArrays;
999  UT_Array< UT_Array<VEXvec2<PREC>> *> myV2Arrays;
1000  UT_Array< UT_Array<VEXvec3<PREC>> *> myV3Arrays;
1001  UT_Array< UT_Array<VEXvec4<PREC>> *> myV4Arrays;
1002  UT_Array< UT_Array<VEXmat2<PREC>> *> myM2Arrays;
1003  UT_Array< UT_Array<VEXmat3<PREC>> *> myM3Arrays;
1004  UT_Array< UT_Array<VEXmat4<PREC>> *> myM4Arrays;
1005  UT_Array< UT_Array<const char *> *> myCstArrays;
1006  UT_Array< UT_Array<UT_OptionsHolder> *> myDictArrays;
1007 };
1008 
1014 
1020 
1021 #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
const UT_Array< VEXfloat< PREC > > & clipweights() const
#define VEX_GEOATTRIBEDIT_CASE_ARRAY(ty, name)
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)
UT_StringHolder myName
GLint first
Definition: glcorearb.h:405
void set(VEXint< PREC > v)
const SEC_ID & secID() const
BlockArray myNetVertices
UT_PageArray< VEXint< PREC >, 1, true, false, 10, exint > BlockArray
const OBJ_ID & objID() const
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
UT_Array< VEXfloat< PREC > > myClipTimes
VEX_API VEX_GeoPrimType typeFromString(const char *)
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)
GLuint const GLchar * name
Definition: glcorearb.h:786
const UT_StringHolder & name() const
#define VEX_API
Definition: VEX_API.h:14
const UT_StringHolder & groupName() const
VEX_GeoDictType dict() const
GLenum src
Definition: glcorearb.h:1793
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
VEXint< PREC > xformidx() const
UT_StringHolder myGroupName
const UT_Array< VEX_GeoCommandEdgeGroupEdit< PREC > > & cmd() const
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
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)
const GLdouble * v
Definition: glcorearb.h:837
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 > myPrimNum
VEX_GeoDictType myDict
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
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
typename VEX_PrecisionResolver< P >::mat4_type VEXmat4
Definition: VEX_PodTypes.h:74
std::size_t hash_value(const VEX_AttribEditId &id)
const VEXmat4< PREC > & xform() const
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:819
hboost::variant< SingleEdit, FullEdit > myData
const UT_Array< VEXint< PREC > > & clipxformgroupids() const
VEXint< PREC > ptNum0() const
void set(VEXvec2< PREC > v)
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
GLfloat f
Definition: glcorearb.h:1926
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:153
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
#define const
Definition: zconf.h:214
const DefaultValue & defaultValue() const
type
Definition: core.h:1059
void set(VEXvec4< PREC > v)
bool isArray() const
const UT_Array< VEXint< PREC > > & cliplayerparents() const
GLdouble s
Definition: glew.h:1395
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)
void set(VEXvec3< PREC > v)
Definition: format.h:895
VEXint< PREC > objID() const
VEX_GeoDictType myDict
VEX_API VEX_GeoTypeInfo typeinfoFromString(const char *)