HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Feather.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: GU Library (C++)
7  *
8  */
9 
10 #ifndef __GU_Feather_h__
11 #define __GU_Feather_h__
12 
13 #include "GU_API.h"
14 #include "GU_Detail.h"
15 #include "GU_GroomUtils.h"
16 #include "GU_PrimPoly.h"
17 
18 #include <GA/GA_Handle.h>
19 #include <GA/GA_Names.h>
20 #include <GEO/GEO_PrimPoly.h>
21 #include <GU/GU_SubDivCurve.h>
22 #include <SYS/SYS_Math.h>
23 #include <numeric>
24 #include <type_traits>
25 #include <iostream>
26 #include <chrono>
27 
28 class GU_FeatherROhandle;
31 
32 template<typename T>
34 {
35  template<class V = T>
36  using is_int = std::is_integral<V>;
37 
38  template<class V = T>
39  using is_flt = std::is_floating_point<V>;
40 
41 public:
42  template<class V = T>
43  static constexpr
44  typename std::enable_if<is_int<V>::value || is_flt<V>::value, int>::type
46  {
47  return 1;
48  }
49 
50  template<class V = T>
51  static constexpr
54  {
55  return V::tuple_size;
56  }
57 
58 };
59 
60 template<typename ValueType>
62 {
63 public:
65 
67  {}
68 
70  const GU_Detail &gdp,
73  const UT_StringRef &name)
74  : myDetail(SYSconst_cast(&gdp))
75  , myPos(pos)
76  , myOrient(orient)
77  {
78  GA_Attribute *attrib = findAttribByName(name);
79  if (attrib != nullptr)
80  setAttrib(*attrib);
81  };
82 
84  const GU_Detail &gdp,
85  const UT_StringRef &name)
86  : myDetail(SYSconst_cast(&gdp))
87  {
88  GA_Attribute *attrib = findAttribByName(name);
89  if (attrib != nullptr)
90  setAttrib(*attrib);
91  };
92 
94  const GU_Detail &gdp,
95  const GA_Attribute &attrib)
96  : myDetail(SYSconst_cast(&gdp))
97  {
98  setAttrib(SYSconst_cast(attrib));
99  };
100 
101  void
103  const GU_Detail *gdp,
104  const GA_Attribute *attrib)
105  {
106  myDetail = SYSconst_cast(gdp);
107 
108  if (attrib)
109  setAttrib(*SYSconst_cast(attrib));
110  }
111 
112  bool
113  isValid() const
114  {
115  return myAttrib != nullptr;
116  }
117 
118  GA_Attribute*
120  {
121  return myAttrib;
122  }
123 
124  const GA_Attribute*
125  getAttribute() const
126  {
127  return myAttrib;
128  }
129 
130  static int valueTupleSize()
131  {
133  }
134 
135  int numBarbPoints() const
136  {
137  int value_tuple_size = GU_FeatherBarbValueInfo<ValueType>::tupleSize();
138 
139  if (value_tuple_size == 0)
140  return 0;
141 
142  return myTupleSize / value_tuple_size;
143  }
144 
145  // get for integral/float types
146  template<class V = ValueType>
150  {
151  array.bumpSize(numBarbPoints());
152  V *data = reinterpret_cast<V*>(array.data());
153  myTuple->get(myAttrib, offset, data, myTupleSize);
154  }
155 
156  // get for vector types
157  template<class V = ValueType>
161  {
162  using ScalarType = typename ValueType::value_type;
163  array.bumpSize(numBarbPoints());
164  ScalarType *data = reinterpret_cast<ScalarType*>(array.data());
165  myTuple->get(myAttrib, offset, data, myTupleSize);
166  }
167 
168  template<typename T>
170  void
172  GA_Offset ptoff,
173  UT_Array<UT_Vector3T<T>> &array) const
174  {
175  UT_Vector3 pos = myPos.get(ptoff);
176  UT_Quaternion orient = myOrient.get(ptoff);
177 
178  for (UT_Vector3T<T> &barb : array)
179  {
180  barb = orient.rotate(barb);
181  barb += pos;
182  }
183  }
184 
185  template<typename T>
187  void
189  GA_Offset ptoff,
190  UT_Array<UT_Vector3T<T>> &array) const
191  {
192  UT_Vector3 pos = myPos.get(ptoff);
193  UT_Quaternion orient = myOrient.get(ptoff);
194 
195  for (UT_Vector3T<T> &barb : array)
196  {
197  if (barb.isZero())
198  continue;
199  barb = orient.rotate(barb);
200  barb += pos;
201  }
202  }
203 
204  template<typename T>
206  void
208  GA_Offset ptoff,
209  UT_Array<UT_Vector3T<T>> &array) const
210  {
211  UT_Vector3 pos = myPos.get(ptoff);
212  UT_Quaternion orient = myOrient.get(ptoff);
213 
214  for (UT_Vector3T<T> &barb : array)
215  {
216  barb -= pos;
217  barb = orient.rotateInverse(barb);
218  }
219  }
220 
221  template<typename T>
223  void
225  GA_Offset ptoff,
226  UT_Array<UT_Vector3T<T>> &array) const
227  {
228  UT_Vector3 pos = myPos.get(ptoff);
229  UT_Quaternion orient = myOrient.get(ptoff);
230 
231  for (UT_Vector3T<T> &barb : array)
232  {
233  if (barb.isZero())
234  continue;
235  barb -= pos;
236  barb = orient.rotateInverse(barb);
237  }
238  }
239 
240  const UT_Quaternion
242  {
243  return myOrient.get(offset);
244  }
245 
247  fpreal
249  {
250  if (myTupleSize < 3)
251  return 0.0;
252 
254  myTuple->get(myAttrib, ptoff, reinterpret_cast<fpreal32*>(data.data()), 3, myTupleSize-3);
255 
256  return data.length();
257  }
258 
259  int
260  tupleSize() const
261  {
262  return myTupleSize;
263  }
264 
265  void
266  bumpDataId() const
267  {
268  myAttrib->bumpDataId();
269  }
270 
271 protected:
275 
276  GA_Attribute *myAttrib = nullptr;
277  const GA_AIFTuple *myTuple = nullptr;
278  int myTupleSize = 0;
279 
280 private:
281  GA_Attribute *findAttribByName(const UT_StringRef &name)
282  {
284 
285  return myDetail->findFloatTuple(
286  GA_ATTRIB_POINT, name, tuple_size);
287  }
288 
289  void setAttrib(GA_Attribute &attrib)
290  {
291  myAttrib = &attrib;
292  myTuple = myAttrib->getAIFTuple();
293  myTupleSize = myTuple->getTupleSize(myAttrib);
294 
296  }
297 
298 };
299 
300 template<typename ValueType>
302 {
304 public:
306  : Base()
307  {}
308 
310  GU_Detail &gdp,
313  const UT_StringRef &name)
314  : Base(gdp, pos, orient, name)
315  {};
316 
318  const GU_Detail &gdp,
319  const UT_StringRef &name)
320  : Base(gdp, name)
321  {
322  };
323 
325  const GU_Detail &gdp,
326  const GA_Attribute &attrib)
327  : Base(gdp, attrib)
328  {
329  };
330 
332  {
333  return myAttrib;
334  }
335 
336  // vector set
337  template<class V = ValueType>
340  set(GA_Offset offset, const ValueType *array) const
341  {
342  using ScalarType = typename ValueType::value_type;
343  const ScalarType *data = reinterpret_cast<const ScalarType*>(array);
344  myTuple->set(myAttrib, offset, data, myTupleSize);
345  }
346 
347  // vector set
348  template<class V = ValueType>
351  blend(GA_Offset offset, const ValueType *array, float alpha) const
352  {
353  using ScalarType = typename ValueType::value_type;
354  const ScalarType *data = reinterpret_cast<const ScalarType*>(array);
355  for (int i=0; i<myTupleSize; ++i)
356  {
357  ScalarType value;
358  myTuple->get(myAttrib, offset, value, i);
359 
360  value = SYSlerp(value, data[i], alpha);
361  myTuple->set(myAttrib, offset, value, i);
362  }
363  }
364 
365  // scalar set
366  template<class V = ValueType>
369  set(GA_Offset offset, const ValueType *array) const
370  {
371  const V *data = reinterpret_cast<const V*>(array);
372  myTuple->set(myAttrib, offset, data, myTupleSize);
373  }
374 
375 private:
376  using Base::myTupleSize;
377  using Base::myTuple;
378  using Base::myAttrib;
379 };
380 
381 template<typename T>
383 {
384 public:
386  {
387  setDimensions(0, 0);
388  }
389 
390  GU_FeatherBarbFlat(int ptcount, int barbsegs)
391  {
392  setDimensions(ptcount, barbsegs);
393  }
394 
395  void
396  setDimensions(int ptcount, int barbsegs)
397  {
398  myBarbSegs = barbsegs;
399  myData.setSize(ptcount * barbsegs);
400  }
401 
402  void
403  bumpDimensions(int ptcount, int barbsegs)
404  {
405  myBarbSegs = barbsegs;
406  myData.bumpSize(ptcount * barbsegs);
407  }
408 
410  const T&
411  get(int index, int segindex) const
412  {
413  return myData[flatIndex(index, segindex)];
414  }
415 
417  const T*
418  getBarbPtr(int index) const
419  {
420  return &myData[flatIndex(index, 0)];
421  }
422 
424  void
425  set(int index, int segindex, const T &value)
426  {
427  myData[flatIndex(index, segindex)] = value;
428  }
429 
431  void
432  set(int index, const UT_Array<T> &value)
433  {
434  int segs = SYSmin(myBarbSegs, value.size());
435  for (int seg=0; seg < segs; ++seg)
436  {
437  myData[flatIndex(index, seg)] = value[seg];
438  }
439  }
440 
442  void
443  add(int index, int segindex, const T &value)
444  {
445  myData[flatIndex(index, segindex)] += value;
446  }
447 
448  void
450  {
451  myData.zero();
452  }
453 
454  void dump()
455  {
456  UTformat("flat barb data:\n");
457  for (int i=0; i<myData.size()/myBarbSegs; ++i)
458  {
459  for (int j=0; j<myBarbSegs; ++j)
460  {
461  UTformat("{} ", get(i, j));
462  }
463  UTformat("\n");
464  }
465  }
466 
467 private:
469  int
470  flatIndex(int index, int segindex) const
471  {
472  return index * myBarbSegs + segindex;
473  }
474 
475  int myBarbSegs;
476  UT_Array<T> myData;
477 };
478 
480 {
481 public:
483 
485  : myDetail(gdp)
486  {
487 
488  }
489 
490  const GU_Detail&
491  getDetail() const
492  {
493  return myDetail;
494  }
495 
496  // stores curve & edge lengths for each primitive
497  void storeLengths();
498 
500  {
501  // storeLengths() must have been run at this point.
502  UT_ASSERT(myDetail.getNumPrimitives() == 0 || myCurveLengths.size() > 0);
503 
504  return myCurveLengths;
505  }
506 
508  {
509  // storeLengths() must have been run at this point.
510  UT_ASSERT(myDetail.getNumPrimitives() == 0 || myEdgeLengths.size() > 0);
511 
512  return myEdgeLengths;
513  }
514 
515  // stores a map from template name to primitive offset
516  void storeOffsetMap(
517  GA_ROHandleS &templatenameattrib);
518 
519  const TemplateOffsetMap&
521  {
522  // storeLengths() must have been run at this point.
523  UT_ASSERT(myDetail.getNumPrimitives() == 0 || myTemplateOffsetMap.size() > 0);
524 
525  return myTemplateOffsetMap;
526  }
527 
528  void
529  storeFirstBarbAttrib();
530 
531  const GA_ROHandleI
533  {
534  return myFirstBarbAttrib.get();
535  }
536 
537 private:
538 
539  const GU_Detail &myDetail;
540  UT_Map<UT_StringHolder, GA_Offset> myTemplateOffsetMap;
541  UT_FloatArray myCurveLengths;
542  UT_Array<UT_FloatArray> myEdgeLengths;
543  GA_AttributeUPtr myFirstBarbAttrib;
544 };
545 
547 {
548 public:
550 
551  struct TempData
552  {
555  };
556 
558  const GU_Detail &gdp,
559  const GU_Detail &templategdp,
560  const GU_FeatherTemplateSet &templateinterp,
561  const UT_StringHolder &indices_attrib_name,
562  const UT_StringHolder &weights_attrib_name)
563  : myTemplateDetail(templategdp)
564  , myTemplateSet(templateinterp)
565  {
566  myTemplateIdentifierAttrib =
567  gdp.findStringArray(GA_ATTRIB_PRIMITIVE, indices_attrib_name);
568 
569  if (myTemplateIdentifierAttrib != nullptr)
570  {
571  myTemplateNamesArray = myTemplateIdentifierAttrib->getAIFSharedStringArray();
572  }
573  else
574  {
575  myTemplateIdentifierAttrib =
576  gdp.findIntArray(GA_ATTRIB_PRIMITIVE, indices_attrib_name);
577 
578  if (myTemplateIdentifierAttrib != nullptr)
579  myTemplateIndicesArray = myTemplateIdentifierAttrib->getAIFNumericArray();
580  }
581 
582  myTemplateWeightsAttrib =
583  gdp.findFloatArray(GA_ATTRIB_PRIMITIVE, weights_attrib_name);
584 
585  if (myTemplateWeightsAttrib != nullptr)
586  myTemplateWeightArray = myTemplateWeightsAttrib->getAIFNumericArray();
587  }
588 
590  const GU_Detail &gdp,
591  const GU_FeatherTemplateSet &templateinterp,
592  const GA_Attribute &templatenamesattrib,
593  const GA_Attribute &templateweightattrib)
594  : myTemplateDetail(gdp)
595  , myTemplateSet(templateinterp)
596  , myTemplateIdentifierAttrib(&templatenamesattrib)
597  , myTemplateWeightsAttrib(&templateweightattrib)
598  {
599  myTemplateNamesArray = templatenamesattrib.getAIFSharedStringArray();
600  myTemplateIndicesArray = templatenamesattrib.getAIFNumericArray();
601  myTemplateWeightArray = templateweightattrib.getAIFNumericArray();
602  }
603 
604  bool isValid() const
605  {
606  return
607  (myTemplateNamesArray != nullptr ||
608  myTemplateIndicesArray != nullptr)
609  && myTemplateWeightArray != nullptr;
610  }
611 
612  bool hasTemplateNames() const
613  {
614  return myTemplateNamesArray != nullptr;
615  }
616 
617  bool hasTemplateIndices() const
618  {
619  return myTemplateIndicesArray != nullptr;
620  }
621 
622  const GU_Detail&
624  {
625  return myTemplateDetail;
626  }
627 
628  void getNames(
629  GA_Offset primoff,
630  UT_StringArray &templatenames) const
631  {
632  myTemplateNamesArray->get(myTemplateIdentifierAttrib, primoff, templatenames);
633  }
634 
636  GA_Offset primoff,
637  UT_Int64Array &templateindices) const
638  {
639  myTemplateIndicesArray->get(myTemplateIdentifierAttrib, primoff, templateindices);
640  }
641 
643  GA_Offset primoff,
644  UT_FloatArray &templateweights) const
645  {
646  myTemplateWeightArray->get(myTemplateWeightsAttrib, primoff, templateweights);
647  }
648 
650  GA_OffsetArray &templateoffsets,
651  const UT_StringArray &templatenames,
652  GA_Offset primoff) const
653  {
654  templateoffsets.setSizeNoInit(templatenames.size());
655 
656  auto &templatemap = myTemplateSet.getTemplateOffsetMap();
657 
658  for (int i=0; i<templateoffsets.size(); ++i)
659  {
660  auto templateiter = templatemap.find(templatenames[i]);
661 
662  if (templateiter == templatemap.end())
663  templateoffsets[i] = GA_INVALID_OFFSET;
664  else
665  templateoffsets[i] = templateiter->second;
666  }
667  }
668 
670  GA_OffsetArray &templateoffsets,
671  const UT_Int64Array &templateindices,
672  GA_Offset primoff) const
673  {
674  templateoffsets.setSizeNoInit(templateindices.size());
675 
676  for (int i=0; i<templateindices.size(); ++i)
677  {
678  GA_Index index = templateindices[i];
679 
680  if (index >= 0 && index < myTemplateDetail.getNumPrimitives())
681  templateoffsets[i] = myTemplateDetail.primitiveOffset(index);
682  else
683  templateoffsets[i] = GA_INVALID_OFFSET;
684  }
685  }
686 
689  const GU_Detail *templategdp,
690  GA_ROHandleS &templatenameattrib)
691  {
692  UT_Vector3Array temppositions;
693  GA_ROHandleV3 tplposattrib(templategdp->getP());
694 
695  int num_templates = templategdp->getNumPrimitives();
696  UT_FloatArray tpllengths(num_templates, num_templates);
697  UT_Array<UT_FloatArray> tpledgelengths(num_templates, num_templates);
698 
699  templategdp->forEachPrimitive([&](GA_Offset primoff)
700  {
701  templatemap[templatenameattrib.get(primoff)] = primoff;
702  });
703  }
704 
706  GA_OffsetArray &templateoffsets,
707  UT_FloatArray &templateweights) const
708  {
709  float wsum(0.0);
710 
711  int templatecount =
712  SYSmin(templateoffsets.size(), templateweights.size());
713 
714  for (int i=0; i<templatecount; ++i)
715  {
716  if (templateoffsets[i] != GA_INVALID_OFFSET)
717  wsum += templateweights[i];
718  else
719  templateweights[i] = 0.0;
720  }
721 
722  if (wsum == 0.0)
723  return;
724 
725  float invwsum = SYSsaferecip(wsum);
726 
727  for (int i=0; i<templatecount; ++i)
728  templateweights[i] *= invwsum;
729  }
730 
732  GA_Offset primoff,
734  UT_FloatArray &weights,
735  TempData &temp) const
736  {
737  if (hasTemplateNames())
738  {
739  getNames(
740  primoff, temp.templatenames);
741 
742  getTemplateOffsets(
743  offsets,
744  temp.templatenames, primoff);
745  }
746  else if (hasTemplateIndices())
747  {
748  getIndices(
749  primoff, temp.templateindices);
750 
751  getTemplateOffsets(
752  offsets,
753  temp.templateindices, primoff);
754  }
755  else
756  {
757  offsets.setSize(0);
758  weights.setSize(0);
759  return;
760  }
761 
762  getWeights(primoff, weights);
763 
764  filterInvalid(offsets, weights);
765 
766  normalizeWeights(offsets, weights);
767  }
768 
769  float
771  int i,
772  int vtxcount,
773  GA_OffsetArray &templateoffsets,
774  UT_FloatArray &templateweights,
775  GA_ROHandleI &template_firstbarb_handle,
776  int shaftsegs,
777  fpreal curvelength,
778  UT_FloatArray &curveedgelengths)
779  {
780  float u = float(i) / (vtxcount-1);
781  float source_u(0.0);
782 
783  const GU_Detail &gdp = myTemplateSet.getDetail();
784 
785  auto &lengths = myTemplateSet.getCurveLengths();
786  auto &edgelengths = myTemplateSet.getEdgeLengths();
787 
788  for (int j=0; j<templateoffsets.size(); ++j)
789  {
790  GA_Offset tploffset = templateoffsets[j];
791  float w = templateweights[j];
792 
793  int tplfirstbarb = template_firstbarb_handle.get(tploffset);
794  int tplvtxcount = gdp.getPrimitiveVertexCount(tploffset);
795 
796  float tmpu = u;
797  if (i <= shaftsegs)
798  tmpu = float(i) * tplfirstbarb / shaftsegs;
799  else
800  tmpu = (tplvtxcount-tplfirstbarb-1) * float(i - shaftsegs) / (vtxcount-shaftsegs-1) + tplfirstbarb;
801 
802  tmpu /= tplvtxcount - 1;
803 
804  GA_Index tplindex = gdp.primitiveIndex(templateoffsets[j]);
806  lengths[tplindex], edgelengths[tplindex], tmpu);
807 
808  source_u += w * tmpu;
809  }
810 
811  return GU_GroomUtils::unitLengthToUnitDomain(curvelength, curveedgelengths, source_u);
812  }
813 
814 private:
815  void filterInvalid(
817  UT_FloatArray &weights) const
818  {
819  int index = 0;
820  for (int i=0; i<offsets.size(); ++i)
821  {
822  if (offsets[i] != GA_INVALID_OFFSET)
823  {
824  if (index != i)
825  {
826  offsets[index] = offsets[i];
827  weights[index] = weights[i];
828  }
829 
830  ++index;
831 
832  }
833  }
834 
835  offsets.setSize(index);
836  weights.setSize(index);
837  }
838 
839  const GU_Detail &myTemplateDetail;
840  const GU_FeatherTemplateSet &myTemplateSet;
841  const GA_Attribute *myTemplateIdentifierAttrib = nullptr;
842  const GA_Attribute *myTemplateWeightsAttrib = nullptr;
843  const GA_AIFSharedStringArray *myTemplateNamesArray = nullptr;
844  const GA_AIFNumericArray *myTemplateIndicesArray = nullptr;
845  const GA_AIFNumericArray *myTemplateWeightArray = nullptr;
846 };
847 
849 {
850 public:
851  enum class BarbSide
852  {
853  NONE = 0,
854  LEFT,
855  RIGHT
856  };
857 
858  struct AttribMap
859  {
861  const GU_Detail &from_detail,
862  GU_Detail &detail,
863  const UT_StringRef &name)
864  : fromName(name)
865  , toName(name)
866  , from(from_detail, name)
867  , to(detail, name)
868  {}
869 
871  const GU_Detail &from_detail,
872  GU_Detail &detail,
873  const UT_StringRef &from_name,
874  GA_Attribute &to_attrib)
875  : fromName(from_name)
876  , toName(to_attrib.getName())
877  , from(from_detail, from_name)
878  , to(detail, to_attrib)
879  {}
880 
882  const GU_Detail &from_detail,
883  GU_Detail &detail,
884  const GA_Attribute &from_attrib,
885  GA_Attribute &to_attrib)
886  : fromName(from_attrib.getName())
887  , toName(to_attrib.getName())
888  , from(from_detail, from_attrib)
889  , to(detail, to_attrib)
890  {}
891 
896  };
897 
905 
907  static const UT_StringHolder SideLeft;
909  static const UT_StringHolder SideRight;;
910 
911  static const UT_StringArray FeatherAttribs;
912 
914 
915  static const UT_StringHolder&
917  {
918  if (barbside == BarbSide::LEFT)
919  return SideLeft;
920  else if (barbside == BarbSide::RIGHT)
921  return SideRight;
922  else
924  }
925 
926  static UT_StringHolder
927  getBarbAttribName(const UT_StringRef &basename, BarbSide barbside)
928  {
930  buffer.format("{}_barb{}", basename, getBarbSideString(barbside));
931 
932  return UT_StringHolder(buffer);
933  }
934 
935  static GA_Attribute*
937  GU_Detail &detail,
938  const UT_StringRef &name,
939  int value_tuplesize,
940  int barbpts)
941  {
942  return detail.addFloatTuple(
944  name,
945  barbpts * value_tuplesize);
946  }
947 
948  static GA_ATINumericUPtr
950  const GU_Detail &detail,
952  int value_tuplesize,
953  int barbpts)
954  {
955  return detail.createDetachedTupleAttribute(
957  storage,
958  barbpts * value_tuplesize);
959  }
960 
961  static void
964  {
965  for (const char *attribname : GU_Feather::FeatherAttribsLengthScaled)
966  sampler.addLengthScaledAttrib(attribname);
967 
968  for (const char *attribname : GU_Feather::FeatherAttribs)
969  sampler.addAttrib(attribname);
970  }
971 
972  static
973  int
974  findFirstBarbIndex(
975  const GEO_PrimPoly &poly,
978  UT_Vector3Array &tempbarbvals);
979 
980  static
981  void
982  findFirstBarbIndex(
983  const GA_RWHandleI &indices,
984  const GU_Detail &detail,
987  const GA_PrimitiveGroup *group=nullptr);
988 
989  static void
990  computeBarbTangents(
991  const GU_Detail &detail,
994  const GU_FeatherBarbRWHandle<UT_Vector3> &tangentl,
995  const GU_FeatherBarbRWHandle<UT_Vector3> &tangentr,
996  const GU_FeatherBarbRWHandle<UT_Vector3> &bitangentl,
997  const GU_FeatherBarbRWHandle<UT_Vector3> &bitangentr,
998  const GA_ROHandleI &firstbarb_handle);
999 
1000  static void
1001  deltaDeform(
1002  GU_Detail &detail,
1003  const GU_Detail &rest_detail,
1004  const GU_Detail &anim_detail,
1005  int from_barbsegs,
1006  int to_barbsegs,
1007  const GA_ROHandleI &firstbarb_handle,
1008  const GA_ROHandleI &rest_firstbarb_handle,
1009  const GA_ROHandleI &anim_firstbarb_handle);
1010 
1011  static void
1012  populateBarbAttribMap(
1013  UT_Array<GU_Feather::AttribMap> &attribmaps,
1014  GU_Detail &gdp,
1015  const GU_Detail &sourcegdp,
1016  const UT_StringHolder &attribpattern);
1017 
1018  static void
1019  createDestBarbAttributes(
1020  UT_Array<GU_Feather::AttribMap> &attribmaps,
1021  GU_Detail &gdp);
1022 
1023  // Create barb attributes missing on gdp. If tuplesize is <= 0, match the
1024  // tuple size of source attributes, otherwise create all dest attribute
1025  // with the specified tuplesize
1026  static void
1027  createDestBarbAttributes(
1028  UT_Array<GU_Feather::AttribMap> &attribmaps,
1029  GU_Detail &gdp, int tuplesize);
1030 
1031  static void expandTemplateBarbAttribs(
1032  GU_Detail &gdp,
1033  const GA_PrimitiveGroup *group,
1034  const GU_Detail &sourcegdp,
1035  int shaft_base_segs,
1036  const GA_ROHandleI &shaft_base_segs_attrib);
1037 
1038  static void expandTemplateBarbAttribs(
1039  GU_Detail &gdp,
1040  const GA_PrimitiveGroup *group,
1041  const GU_Detail &sourcegdp,
1042  UT_Array<GU_Feather::AttribMap> &attribmaps,
1043  int shaft_base_segs,
1044  const GA_ROHandleI &shaft_base_segs_attrib);
1045 
1046  static void zeroBarbValues(
1047  GU_Detail &gdp,
1048  const GA_PrimitiveGroup *group);
1049 };
1050 
1052 {
1053 public:
1055  {
1058  };
1059 
1060  struct ShaftData
1061  {
1064  };
1065 
1067  {
1071 
1074 
1077 
1080 
1084 
1086  };
1087 
1088  template<typename WVEC, typename IVEC>
1089  static UT_Tuple<WVEC, IVEC> computeShaftPointCoeffs(
1090  int i,
1091  int to_ptcount,
1092  int from_ptcount);
1093 
1094  static void populateShaftData(
1095  const GEO_PrimPoly &poly,
1096  int firstbarbindex,
1097  const GA_ROHandleI &firstindexhandle,
1098  ShaftData &shaftdata)
1099  {
1100  GA_Size vtxcount = poly.getFastVertexCount();
1101 
1102  if (firstindexhandle.isValid())
1103  shaftdata.firstBarbIndex = firstindexhandle.get(poly.getMapOffset());
1104  else
1105  shaftdata.firstBarbIndex = firstbarbindex;
1106 
1107  if (shaftdata.firstBarbIndex < 0)
1108  return;
1109 
1110  shaftdata.ptOffs.bumpSize(vtxcount-shaftdata.firstBarbIndex);
1111  for (int i=shaftdata.firstBarbIndex; i<vtxcount; ++i)
1112  {
1113  shaftdata.ptOffs[i-shaftdata.firstBarbIndex] = poly.getPointOffset(i);
1114  }
1115 
1116  }
1117 
1118  static void
1119  interpolateBarbAttribs(
1120  bool use_subd,
1121  const GU_Detail &from_detail,
1122  GU_Detail &detail,
1123  const GA_PrimitiveGroup *group,
1124  const UT_Array<GU_Feather::AttribMap> &attribmaps,
1125  int shaft_base_segs,
1126  const GA_ROHandleI &firstbarb_handle,
1127  const GA_ROHandleS &from_side,
1128  const GA_ROHandleS &side,
1129  const GA_ROHandleF &blendattrib,
1130  const GU_FeatherTemplateSet &templateset,
1131  const GU_FeatherTemplateInterpolate *templateinterp=nullptr);
1132 
1133  static void
1134  interpolateBarbAttribs(
1135  GA_Offset primoff,
1136  BarbAttribInterpolateTemp &temp,
1137  GA_OffsetArray &source_primoffs,
1138  UT_FloatArray &source_primweights,
1139  UT_ValArray<bool> &source_flips,
1140  UT_Array<BarbInterpCoeffs> &barb_coeffs,
1141  bool use_subd,
1142  const GU_Detail &from_detail,
1143  GU_Detail &detail,
1144  const UT_Array<GU_Feather::AttribMap> &attribmaps,
1145  int shaft_base_segs,
1146  float alpha,
1147  const GU_FeatherTemplateSet &templateset);
1148 
1149  // Interpolate shaft curves using cubic coefficients
1150  template<typename T>
1151  static void interpolateVSubD(
1152  UT_Array<T> &out_values,
1153  const GA_OffsetArray &from_ptoffs,
1154  const UT_Vector4Array &s_coeffs,
1155  const UT_Vector4iArray &s_indices,
1156  const GA_ROHandleT<T> &from_attrib);
1157 
1158  // Interpolates across barbs, keeping the barb segment count of the input.
1159  // Combined with interpolateV this allows for quad interpolation.
1160  //
1161  // Outputs barb values as a flat array. Indices of barb values in the array
1162  // are computed as
1163  //
1164  // ptindex * nbarbsegs + barbseg.
1165  //
1166  // 3 source barbs: 4 output barbs:
1167  //
1168  // \ / \ /
1169  // \ / \ /
1170  // \ / \ \ / /
1171  // \ V / \ V /
1172  // \ | / \ \|/ /
1173  // \|/ \ V /
1174  // \ V / \ \|/ /
1175  // \ | / \ V /
1176  // \|/ \|/
1177  // V V
1178  //
1179  // (number of barbs differs,
1180  // barb segment count unchanged)
1181  template<typename T, typename WVEC, typename IVEC>
1182  static void interpolateV(
1183  GU_FeatherBarbFlat<T> &from_v_values,
1184  UT_Array<T> &temp,
1185  const GA_OffsetArray &from_ptoffs,
1186  const UT_ValArray<WVEC> &s_coeffs,
1187  const UT_ValArray<IVEC> &s_indices,
1188  const GU_FeatherBarbROHandle<T> &from_attrib);
1189 
1190 
1191  // Interpolates barb values, barb segment count can be different on the
1192  // destination, number of barbs stays the same. Combined with
1193  // interpolateV this allows for quad interpolation.
1194  //
1195  // Expects a flat array of barb values as output by interpolateV as
1196  // input. Outputs barb values as a flat array.
1197  //
1198  // For both arrays, barb value indices are computed as
1199  //
1200  // (ptindex * nbarbsegs + barbseg)
1201  //
1202  // Example:
1203  //
1204  // source barbs with 4 segments
1205  //
1206  // \ / output barbs with 3 segments
1207  // \ /
1208  // \ / \ /
1209  // \ V / \ /
1210  // \ | / V
1211  // \|/ \ | /
1212  // \ V / \|/
1213  // \ | / V
1214  // \|/ \ | /
1215  // V \|/
1216  // V
1217  //
1218  // (number of barbs unchanged,
1219  // barb segment count differs)
1220  template<typename T>
1221  static void interpolateUSubD(
1222  GU_FeatherBarbFlat<T> &attrib_outvalues,
1223  int to_ptcount,
1224  const GU_FeatherBarbFlat<T> &from_v_values,
1225  const BarbInterpCoeffs &barb_coeffs,
1226  float weight,
1227  bool flip);
1228 
1229  template<typename WVEC, typename IVEC>
1230  static void computeShaftCoeffs(
1231  UT_ValArray<WVEC> &s_coeffs,
1232  UT_ValArray<IVEC> &s_indices,
1233  const GEO_PrimPoly &poly,
1234  int to_firstbarbindex,
1235  int to_ptcount,
1236  int from_firstbarbpt,
1237  int from_ptcount);
1238 
1239  static void computeBarbInterpCoeffs(
1240  int from_barbpts,
1241  int to_barbpts,
1242  BarbInterpCoeffs &interpdata);
1243 
1244  static void computeBarbInterpCoeffs(
1245  const UT_Array<GU_Feather::AttribMap> &attribmaps,
1246  UT_Array<BarbInterpCoeffs> &barb_coeffs);
1247 
1248  template<typename T, typename WVEC, typename IVEC>
1249  static void interpolate(
1250  GU_FeatherBarbFlat<T> &attrib_outvalues,
1251  GU_FeatherBarbFlat<T> &from_v_values,
1252  UT_Array<T> &temp,
1253  const GA_OffsetArray &from_ptoffs,
1254  const UT_ValArray<WVEC> &s_coeffs,
1255  const UT_ValArray<IVEC> &s_indices,
1256  const GU_FeatherBarbROHandle<T> &from_attrib,
1257  int to_ptcount,
1258  const BarbInterpCoeffs &barb_coeffs,
1259  float weight,
1260  bool flip);
1261 
1262  template<typename T>
1263  static void setBarbs(
1264  const GU_FeatherBarbFlat<T> &attrib_values,
1265  const GA_OffsetArray &to_ptoffs,
1266  const GU_FeatherBarbRWHandle<T> &to_attrib);
1267 
1268  template<typename T>
1269  static void blendBarbs(
1270  const GU_FeatherBarbFlat<T> &attrib_values,
1271  const GA_OffsetArray &to_ptoffs,
1272  const GU_FeatherBarbRWHandle<T> &to_attrib,
1273  float alpha);
1274 };
1275 
1277 {
1278 public:
1280  const GU_Detail &gdp,
1281  const UT_StringRef &orientname)
1282  : myDetail(SYSconst_cast(gdp))
1283  , myPos(myDetail.getP())
1284  , myOrient(GU_GroomUtils::findNamedOrient(myDetail, orientname))
1285  , myBarbL(myDetail, myPos, myOrient, GU_Feather::BarbLAttrib)
1286  , myBarbR(myDetail, myPos, myOrient, GU_Feather::BarbRAttrib)
1287  {
1288  }
1289 
1291  fpreal
1292  boundingRadius(GA_Offset primoff) const
1293  {
1294  GEO_PrimPoly poly(
1295  &myDetail, primoff, myDetail.getPrimitiveVertexList(primoff));
1296 
1297  int vtxcount(poly.getFastVertexCount());
1298 
1299  fpreal maxradius(0.0);
1300 
1301  UT_Vector3 lastpos;
1302  GA_Offset lastptoff;
1303  fpreal seglength;
1304  fpreal lastseglength;
1305  for (int i=0; i<vtxcount; ++i)
1306  {
1307  GA_Offset ptoff;
1308  UT_Vector3 pos;
1309 
1310  if (i < vtxcount)
1311  {
1312  GA_Offset ptoff = poly.getPointOffset(i);
1313  pos = myPos.get(ptoff);
1314 
1315 
1316  if (i > 0)
1317  seglength = lastpos.distance(pos);
1318 
1319 
1320  //////////////
1321  fpreal radius = SYSmax(
1322  myBarbL.boundingRadius(ptoff),
1323  0.0);
1324 
1325  if (radius > maxradius)
1326  maxradius = radius;
1327  //////////////
1328  }
1329 
1330  continue;
1331 
1332  if (i>0)
1333  {
1334  float addedrad = 0;
1335 
1336 
1337  if (i > 1 && i < vtxcount)
1338  addedrad = SYSmax(seglength, lastseglength);
1339  else if (i==1)
1340  addedrad = seglength;
1341  else if (i==vtxcount)
1342  addedrad = lastseglength;
1343 
1344  fpreal radius = SYSmax(
1345  myBarbL.boundingRadius(lastptoff) + addedrad,
1346  myBarbL.boundingRadius(lastptoff) + addedrad);
1347 
1348  if (radius > maxradius)
1349  maxradius = radius;
1350  }
1351 
1352  if (i < vtxcount)
1353  {
1354  lastptoff = ptoff;
1355  lastpos = pos;
1356  lastseglength = seglength;
1357  }
1358  }
1359 
1360  return maxradius;
1361  }
1362 
1364  barbL() const
1365  {
1366  return myBarbL;
1367  }
1368 
1370  barbR() const
1371  {
1372  return myBarbR;
1373  }
1374 
1375 protected:
1381 };
1382 
1384 {
1385 public:
1387  GU_Detail &gdp,
1388  const UT_StringRef &orientname)
1389  : GU_FeatherROhandle(gdp, orientname)
1390  {
1391  }
1392 
1394  barbL() const
1395  {
1396  return myBarbL;
1397  }
1398 
1400  barbR() const
1401  {
1402  return myBarbR;
1403  }
1404 
1405 };
1406 
1408 {
1409 public:
1410  struct TempData
1411  {
1418  };
1419 
1422  const GU_FeatherBarbRWHandle<UT_Vector3> &tangent,
1423  const GU_FeatherBarbRWHandle<UT_Vector3> &bitangent)
1424  : myBarb(barb)
1425  , myTangent(tangent)
1426  , myBitangent(bitangent)
1427  {
1428  }
1429 
1430  void startPrim(
1431  const GU_Detail &detail,
1432  const GEO_PrimPoly &poly,
1433  int firstindex,
1434  TempData &tempdata);
1435 
1436  void computeForPoint(
1437  GA_Size i,
1438  TempData &tempdata);
1439 
1440 private:
1441  const GU_FeatherBarbROHandle<UT_Vector3> &myBarb;
1442  const GU_FeatherBarbRWHandle<UT_Vector3> &myTangent;
1443  const GU_FeatherBarbRWHandle<UT_Vector3> &myBitangent;
1444 
1445 };
1446 
1447 #endif
GA_Attribute * myAttrib
Definition: GU_Feather.h:276
#define SYSmax(a, b)
Definition: SYS_Math.h:1570
void normalizeWeights(GA_OffsetArray &templateoffsets, UT_FloatArray &templateweights) const
Definition: GU_Feather.h:705
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
static const UT_StringHolder BarbUVRAttrib
Definition: GU_Feather.h:902
static const UT_StringHolder BarbUVLAttrib
Definition: GU_Feather.h:901
GA_Attribute * getAttribute()
Definition: GU_Feather.h:119
GU_FeatherBarbRWHandle< UT_Vector3 > to
Definition: GU_Feather.h:895
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
Definition: GA_Primitive.h:254
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
static int valueTupleSize()
Definition: GU_Feather.h:130
Generic Attribute Interface class to access an attribute as a array.
static GA_Attribute * createBarbAttrib(GU_Detail &detail, const UT_StringRef &name, int value_tuplesize, int barbpts)
Definition: GU_Feather.h:936
const GA_Attribute * getAttribute() const
Definition: GU_Feather.h:125
void bumpDimensions(int ptcount, int barbsegs)
Definition: GU_Feather.h:403
void getTemplateOffsets(GA_OffsetArray &templateoffsets, const UT_StringArray &templatenames, GA_Offset primoff) const
Definition: GU_Feather.h:649
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
GLboolean * data
Definition: glcorearb.h:131
GA_Attribute * addFloatTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringHolder &name, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0), const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_REAL32, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
void bind(const GU_Detail *gdp, const GA_Attribute *attrib)
Definition: GU_Feather.h:102
GLsizei const GLfloat * value
Definition: glcorearb.h:824
const UT_FloatArray & getCurveLengths() const
Definition: GU_Feather.h:499
void setSizeNoInit(exint newsize)
Definition: UT_Array.h:695
GU_FeatherBarbFlat< UT_Vector3 > from_v_values
Definition: GU_Feather.h:1068
GA_Attribute * operator->() const
Definition: GU_Feather.h:331
bool isValid() const
Definition: GU_Feather.h:113
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
GU_FeatherBarbROHandle(const GU_Detail &gdp, const GA_Attribute &attrib)
Definition: GU_Feather.h:93
UT_StringHolder toName
Definition: GU_Feather.h:893
int tupleSize() const
Definition: GU_Feather.h:260
GA_Attribute * getP()
Convenience method to access the P attribute.
Definition: GA_Detail.h:164
SYS_FORCE_INLINE const HOLDER & get(GA_Offset off, int comp=0) const
Get the string at the given offset.
Definition: GA_Handle.h:911
virtual const GA_AIFTuple * getAIFTuple() const
Return the attribute's tuple interface or NULL.
bool hasTemplateNames() const
Definition: GU_Feather.h:612
const GU_Detail & getTemplateDetail() const
Definition: GU_Feather.h:623
SYS_FORCE_INLINE void xformToObjectNonZero(GA_Offset ptoff, UT_Array< UT_Vector3T< T >> &array) const
Definition: GU_Feather.h:188
static const UT_StringHolder SideLeft
Definition: GU_Feather.h:907
std::tuple< Types...> UT_Tuple
Definition: UT_Tuple.h:53
void addAttrib(const UT_StringRef &name)
static const UT_StringHolder BarbLAttrib
Definition: GU_Feather.h:898
virtual int getTupleSize(const GA_Attribute *attrib) const =0
constexpr SYS_FORCE_INLINE T length() const noexcept
Definition: UT_Vector3.h:361
GU_Detail & myDetail
Definition: GU_Feather.h:1376
UT_Matrix2T< T > SYSlerp(const UT_Matrix2T< T > &v1, const UT_Matrix2T< T > &v2, S t)
Definition: UT_Matrix2.h:675
GLuint sampler
Definition: glcorearb.h:1656
GU_FeatherBarbROHandle(const GU_Detail &gdp, const UT_StringRef &name)
Definition: GU_Feather.h:83
3D Vector class.
void bumpDataId() const
Definition: GU_Feather.h:266
GLuint buffer
Definition: glcorearb.h:660
SYS_FORCE_INLINE const T * getBarbPtr(int index) const
Definition: GU_Feather.h:418
exint size() const
Definition: UT_Array.h:646
uint64 value_type
Definition: GA_PrimCompat.h:29
void setSize(exint newsize)
Definition: UT_Array.h:666
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
void getTemplateOffsetsAndWeights(GA_Offset primoff, GA_OffsetArray &offsets, UT_FloatArray &weights, TempData &temp) const
Definition: GU_Feather.h:731
constexpr SYS_FORCE_INLINE const T * data() const noexcept
Definition: UT_Vector3.h:292
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
void bumpSize(exint newsize)
Definition: UT_Array.h:629
void getWeights(GA_Offset primoff, UT_FloatArray &templateweights) const
Definition: GU_Feather.h:642
GLuint GLsizei const GLuint const GLintptr * offsets
Definition: glcorearb.h:2621
const GA_Attribute * findIntArray(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name, int min_size=1, int max_size=-1) const
GU_Detail * myDetail
Definition: GU_Feather.h:272
GA_Size GA_Offset
Definition: GA_Types.h:646
static const UT_StringHolder TemplateNamesAttrib
Definition: GU_Feather.h:903
static UT_StringHolder getBarbAttribName(const UT_StringRef &basename, BarbSide barbside)
Definition: GU_Feather.h:927
SYS_FORCE_INLINE std::enable_if<!std::is_integral< V >::value &&!std::is_floating_point< V >::value, void >::type blend(GA_Offset offset, const ValueType *array, float alpha) const
Definition: GU_Feather.h:351
SYS_FORCE_INLINE GA_Index primitiveIndex(GA_Offset offset) const
Given a primitive's data offset, return its index.
Definition: GA_Detail.h:423
void getNames(GA_Offset primoff, UT_StringArray &templatenames) const
Definition: GU_Feather.h:628
static void addFeatherAttribsToCurveSampler(GU_GroomCurveAttribSampler &sampler)
Definition: GU_Feather.h:962
GU_FeatherTemplateSet(const GU_Detail &gdp)
Definition: GU_Feather.h:484
const GA_Attribute * findStringArray(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name, int min_size=1, int max_size=-1) const
void addLengthScaledAttrib(const UT_StringRef &name)
GLintptr offset
Definition: glcorearb.h:665
SYS_FORCE_INLINE void set(int index, int segindex, const T &value)
Definition: GU_Feather.h:425
IMATH_NAMESPACE::V2f float
UT_StringHolder fromName
Definition: GU_Feather.h:892
UT_Vector3T< T > rotateInverse(const UT_Vector3T< T > &) const
void getIndices(GA_Offset primoff, UT_Int64Array &templateindices) const
Definition: GU_Feather.h:635
SYS_FORCE_INLINE void xformToLocal(GA_Offset ptoff, UT_Array< UT_Vector3T< T >> &array) const
Definition: GU_Feather.h:207
SYS_FORCE_INLINE void add(int index, int segindex, const T &value)
Definition: GU_Feather.h:443
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
GU_FeatherTemplateInterpolate(const GU_Detail &gdp, const GU_Detail &templategdp, const GU_FeatherTemplateSet &templateinterp, const UT_StringHolder &indices_attrib_name, const UT_StringHolder &weights_attrib_name)
Definition: GU_Feather.h:557
SYS_FORCE_INLINE void forEachPrimitive(FUNCTOR &&functor) const
Definition: GA_Detail.h:1567
static void populateShaftData(const GEO_PrimPoly &poly, int firstbarbindex, const GA_ROHandleI &firstindexhandle, ShaftData &shaftdata)
Definition: GU_Feather.h:1094
GU_FeatherROhandle(const GU_Detail &gdp, const UT_StringRef &orientname)
Definition: GU_Feather.h:1279
static const UT_StringHolder theEmptyString
void getTemplateOffsets(GA_OffsetArray &templateoffsets, const UT_Int64Array &templateindices, GA_Offset primoff) const
Definition: GU_Feather.h:669
UT_Array< GU_FeatherBarbFlat< UT_Vector3 > > attrib_outvalues
Definition: GU_Feather.h:1069
const UT_Array< UT_FloatArray > & getEdgeLengths() const
Definition: GU_Feather.h:507
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GU_FeatherRWHandle(GU_Detail &gdp, const UT_StringRef &orientname)
Definition: GU_Feather.h:1386
GA_ROHandleQ myOrient
Definition: GU_Feather.h:274
static constexpr std::enable_if< is_int< V >::value||is_flt< V >::value, int >::type tupleSize()
Definition: GU_Feather.h:45
A specialization of GA_AIFStringArray to access "shared strings".
GA_RWHandleV3 myPos
Definition: GU_Feather.h:1377
AttribMap(const GU_Detail &from_detail, GU_Detail &detail, const UT_StringRef &from_name, GA_Attribute &to_attrib)
Definition: GU_Feather.h:870
const GU_FeatherBarbRWHandle< UT_Vector3F > & barbL() const
Definition: GU_Feather.h:1394
SYS_FORCE_INLINE GA_ATINumericUPtr createDetachedTupleAttribute(GA_AttributeOwner owner, GA_Storage storage, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0f), const GA_AttributeOptions *attribute_options=nullptr) const
Definition: GA_Detail.h:895
bool hasTemplateIndices() const
Definition: GU_Feather.h:617
GU_FeatherBarbRWHandle(const GU_Detail &gdp, const GA_Attribute &attrib)
Definition: GU_Feather.h:324
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:112
static const UT_StringHolder TemplateWeightsAttrib
Definition: GU_Feather.h:904
virtual const GA_AIFSharedStringArray * getAIFSharedStringArray() const
Return the attribute's shared string array interface or NULL.
GU_FeatherBarbRWHandle(GU_Detail &gdp, GA_ROHandleT< ValueType > &pos, GA_ROHandleQ &orient, const UT_StringRef &name)
Definition: GU_Feather.h:309
static const UT_StringHolder SideRight
Definition: GU_Feather.h:909
void setDimensions(int ptcount, int barbsegs)
Definition: GU_Feather.h:396
SYS_FORCE_INLINE T get(GA_Offset off, int comp=0) const
Definition: GA_Handle.h:203
#define GU_API
Definition: GU_API.h:14
static const UT_StringHolder & getBarbSideString(BarbSide barbside)
Definition: GU_Feather.h:916
GLuint const GLchar * name
Definition: glcorearb.h:786
AttribMap(const GU_Detail &from_detail, GU_Detail &detail, const UT_StringRef &name)
Definition: GU_Feather.h:860
GU_FeatherBarbFlat< UT_Vector3 > myBarbFlat
Definition: GU_Feather.h:1414
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:640
GU_FeatherTemplateInterpolate(const GU_Detail &gdp, const GU_FeatherTemplateSet &templateinterp, const GA_Attribute &templatenamesattrib, const GA_Attribute &templateweightattrib)
Definition: GU_Feather.h:589
const GA_ROHandleI getFirstBarbAttrib() const
Definition: GU_Feather.h:532
GA_API const UT_StringHolder orient
int numBarbPoints() const
Definition: GU_Feather.h:135
UT_UniquePtr< GA_Attribute > GA_AttributeUPtr
Definition: GA_Attribute.h:930
GA_ROHandleQ myOrient
Definition: GU_Feather.h:1378
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:187
ImageBuf OIIO_API flip(const ImageBuf &src, ROI roi={}, int nthreads=0)
SYS_FORCE_INLINE std::enable_if<!std::is_integral< V >::value &&!std::is_floating_point< V >::value, void >::type set(GA_Offset offset, const ValueType *array) const
Definition: GU_Feather.h:340
GLint j
Definition: glad.h:2733
GU_FeatherBarbROHandle< UT_Vector3 > from
Definition: GU_Feather.h:894
SYS_FORCE_INLINE fpreal boundingRadius(GA_Offset primoff) const
Definition: GU_Feather.h:1292
SYS_FORCE_INLINE void xformToLocalNonZero(GA_Offset ptoff, UT_Array< UT_Vector3T< T >> &array) const
Definition: GU_Feather.h:224
GU_FeatherDerivatives(const GU_FeatherBarbROHandle< UT_Vector3 > &barb, const GU_FeatherBarbRWHandle< UT_Vector3 > &tangent, const GU_FeatherBarbRWHandle< UT_Vector3 > &bitangent)
Definition: GU_Feather.h:1420
static const UT_StringHolder SideCenter
Definition: GU_Feather.h:908
size_t format(const char *fmt, const Args &...args)
SYS_FORCE_INLINE void set(int index, const UT_Array< T > &value)
Definition: GU_Feather.h:432
static float unitLengthToUnitDomain(const UT_Vector3Array &pos, float perimeter, const UT_FloatArray &edgelengths, float ulength)
SYS_FORCE_INLINE std::enable_if< std::is_integral< V >::value||std::is_floating_point< V >::value, void >::type set(GA_Offset offset, const ValueType *array) const
Definition: GU_Feather.h:369
GU_FeatherTemplateInterpolate::TempData interptemp
Definition: GU_Feather.h:1085
SYS_FORCE_INLINE void xformToObject(GA_Offset ptoff, UT_Array< UT_Vector3T< T >> &array) const
Definition: GU_Feather.h:171
const UT_Quaternion getOrient(GA_Offset offset) const
Definition: GU_Feather.h:241
fpreal64 fpreal
Definition: SYS_Types.h:277
GU_FeatherBarbFlat(int ptcount, int barbsegs)
Definition: GU_Feather.h:390
static GA_ATINumericUPtr createDetachedBarbAttrib(const GU_Detail &detail, GA_Storage storage, int value_tuplesize, int barbpts)
Definition: GU_Feather.h:949
GLuint index
Definition: glcorearb.h:786
GU_FeatherBarbROHandle(const GU_Detail &gdp, GA_ROHandleT< ValueType > &pos, GA_ROHandleQ &orient, const UT_StringRef &name)
Definition: GU_Feather.h:69
SYS_FORCE_INLINE GA_Offset getMapOffset() const
Gets the offset of this primitive in the detail containing it.
Definition: GA_Primitive.h:146
SYS_FORCE_INLINE GA_Size getNumPrimitives() const
Return the number of primitives.
Definition: GA_Detail.h:408
const GU_FeatherBarbRWHandle< UT_Vector3F > & barbR() const
Definition: GU_Feather.h:1400
size_t UTformat(FILE *file, const char *format, const Args &...args)
Definition: UT_Format.h:665
const GA_Attribute * findFloatArray(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name, int min_size=1, int max_size=-1) const
static const UT_StringHolder BarbRAttrib
Definition: GU_Feather.h:899
constexpr SYS_FORCE_INLINE T distance(const UT_Vector3T &b) const noexcept
Definition: UT_Vector3.h:371
static const UT_StringArray FeatherAttribsLengthScaled
Definition: GU_Feather.h:913
AttribMap(const GU_Detail &from_detail, GU_Detail &detail, const GA_Attribute &from_attrib, GA_Attribute &to_attrib)
Definition: GU_Feather.h:881
UT_Array< UT_Vector3 > myTempVecs
Definition: GU_Feather.h:1416
static const UT_StringHolder SideAttrib
Definition: GU_Feather.h:906
GU_FeatherBarbRWHandle< UT_Vector3F > myBarbR
Definition: GU_Feather.h:1380
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
void startPrim(const GU_Detail &detail, const GEO_PrimPoly &poly, int firstindex, TempData &tempdata)
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
SYS_FORCE_INLINE GA_Size getFastVertexCount() const
Definition: GEO_TriMesh.h:123
Definition: core.h:1131
const GU_Detail & getDetail() const
Definition: GU_Feather.h:491
SYS_FORCE_INLINE GA_Size getPrimitiveVertexCount(GA_Offset primoff) const
Definition: GA_Primitive.h:898
void computeForPoint(GA_Size i, TempData &tempdata)
UT_Array< bool > myBarbFetched
Definition: GU_Feather.h:1415
GU_FeatherBarbRWHandle(const GU_Detail &gdp, const UT_StringRef &name)
Definition: GU_Feather.h:317
const GU_FeatherBarbROHandle< UT_Vector3F > & barbL() const
Definition: GU_Feather.h:1364
GA_API const UT_StringHolder segs
UT_Vector3T< T > rotate(const UT_Vector3T< T > &) const
GU_FeatherBarbRWHandle< UT_Vector3F > myBarbL
Definition: GU_Feather.h:1379
#define SYSmin(a, b)
Definition: SYS_Math.h:1571
type
Definition: core.h:1059
Generic Attribute Interface class to access an attribute as a tuple.
Definition: GA_AIFTuple.h:32
const TemplateOffsetMap & getTemplateOffsetMap() const
Definition: GU_Feather.h:520
bool ValueType
Definition: NanoVDB.h:5729
SYS_FORCE_INLINE fpreal boundingRadius(GA_Offset ptoff) const
Definition: GU_Feather.h:248
GA_Storage
Definition: GA_Types.h:51
static constexpr std::enable_if<!(is_int< V >::value||is_flt< V >::value), int >::type tupleSize()
Definition: GU_Feather.h:53
const GU_FeatherBarbROHandle< UT_Vector3F > & barbR() const
Definition: GU_Feather.h:1370
void makeTemplateOffsetMap(UT_Map< UT_StringHolder, GA_Offset > &templatemap, const GU_Detail *templategdp, GA_ROHandleS &templatenameattrib)
Definition: GU_Feather.h:687
UT_UniquePtr< GA_ATINumeric > GA_ATINumericUPtr
float computeBlendedCurveParam(int i, int vtxcount, GA_OffsetArray &templateoffsets, UT_FloatArray &templateweights, GA_ROHandleI &template_firstbarb_handle, int shaftsegs, fpreal curvelength, UT_FloatArray &curveedgelengths)
Definition: GU_Feather.h:770
GA_ROHandleT< ValueType > myPos
Definition: GU_Feather.h:273
Definition: format.h:895
static const UT_StringHolder BarbOrientAttrib
Definition: GU_Feather.h:900
static const UT_StringArray FeatherAttribs
Definition: GU_Feather.h:909
GLsizei GLenum GLenum GLuint GLenum GLsizei * lengths
Definition: glcorearb.h:2542
static float unitToUnitLengthDomain(float perimeter, const UT_FloatArray &edgelengths, float uparm)
virtual const GA_AIFNumericArray * getAIFNumericArray() const
Return the attribute's arraydata interface or NULL.