HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_RayPrimitive.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  * COMMENTS: Ray info - cached information for each primitive type
9  *
10  */
11 
12 #ifndef __GU_RayPrimInfo_h__
13 #define __GU_RayPrimInfo_h__
14 
15 #include "GU_API.h"
16 #include "GU_RayRBezCurve.h"
17 #include "GU_RayRBezSurf.h"
18 #include <GEO/GEO_Detail.h>
19 #include <GEO/GEO_PrimitiveP.h>
20 #include <GEO/GEO_PrimVolume.h>
21 #include <GA/GA_Types.h>
22 #include <TS/TS_Expression.h>
23 
24 #include <UT/UT_BoundingBox.h>
25 #include <UT/UT_Matrix3.h>
26 #include <UT/UT_Matrix4.h>
28 #include <UT/UT_UniquePtr.h>
29 #include <UT/UT_VDBUtils.h>
30 #include <UT/UT_Vector3.h>
31 #include <UT/UT_Vector4Array.h>
32 #include <UT/UT_VoxelArray.h>
33 #include <SYS/SYS_Inline.h>
34 
35 #ifdef OPENVDB_ENABLED
36 #include <openvdb/openvdb.h>
37 #endif
38 
39 class GU_Detail;
40 class GU_MinInfo;
41 class GU_RayInfo;
42 class GU_RayIntersect;
43 class GEO_Primitive;
44 class GEO_PrimRBezSurf;
45 
47 {
48 public:
49  GU_Ray(const UT_Vector3 &o, const UT_Vector3 &d, const UT_Matrix4 *mat = 0);
50 
51  float globalDist(float t) const { return t / tscale; }
52  float localDist(float t) const { return t * tscale; }
53 
55  float tscale;
56 };
57 
58 // Finds intersection of ray & quad.
59 int
61  const UT_Vector3 &dir,
62  const UT_Vector3 &A, const UT_Vector3 &B,
63  const UT_Vector3 &C, const UT_Vector3 &D,
64  const UT_Vector3 &norm,
65  float &t, float &u, float &v, float &d2);
66 //________________________________________________________
67 //
68 // Base class for primitive info
69 //________________________________________________________
70 //
72 {
73 public:
74  GU_RayPrimInfo(GEO_ConstPrimitiveP prim, int serialidx);
75 
76  // TODO: Make pure virtual when compiler allows us
77  virtual int intersect(
78  const GEO_Detail &geo,
79  const UT_Vector3 &org,
80  const UT_Vector3 &dir,
81  GU_RayInfo &hitinfo)
82  {
83  return 0;
84  }
85  virtual int minimum(
86  const GEO_Detail &geo,
87  const UT_Vector3 &p,
88  GU_MinInfo &mininfo)
89  {
90  return 0;
91  }
92 
93  // NB: "t" value is position on this, (u,v,w) position
94  // on passed in primitive.
95  virtual int intersectPrim(
96  const GEO_Detail &geo,
97  const GEO_Detail &prim_geo,
98  GU_RayPrimInfo *prim,
99  GU_RayInfo &hitinfo)
100  {
101  return -1;
102  }
103  virtual int minimumPrim(
104  const GEO_Detail &geo,
105  const GEO_Detail &prim_geo,
106  GU_RayPrimInfo *prim,
107  GU_MinInfo &mininfo)
108  {
109  return 0;
110  }
111 
112  void bumpRefCount(int dir);
113  static void getXYProjection(const UT_Vector3 &nml, int &x, int &y);
114 
115  // Checks the dirty bit, if set, initializes.
116  void ensureClean(const GEO_Detail &geo);
117  // Initializes.
118  virtual void init(const GEO_Detail &geo)
119  {
120  }
121 
124  {
125  return GEO_ConstPrimitiveP(&geo, myPrimOffset);
126  }
127 
128  /// Report approximate memory usage.
129  virtual int64 getMemoryUsage(bool inclusive) const = 0;
130 
131 protected:
132  void initBBox(GEO_ConstPrimitiveP prim);
133 
134 public:
137  float sortValue;
138  int mySerialIdx; // Our index into a serial table
139 
141  // it is cute how we carefully conserve bits here, when you consider
142  // things like the UT_BoundingBox and what shows up in the
143  // subclasses!
144  bool degenerate:1;
145  //bool subclassflag:1;
146  volatile int myDirty;
147 
148 protected:
149  virtual ~GU_RayPrimInfo();
150 };
151 
152 //________________________________________________________
153 //
154 // Quadric ray intersection class
155 //________________________________________________________
156 //
158 {
159 public:
160  GU_RayQuadricInfo(GEO_ConstPrimitiveP prim, int serialidx);
161  virtual ~GU_RayQuadricInfo();
162 
163  virtual int intersect(
164  const GEO_Detail &geo,
165  const UT_Vector3 &org,
166  const UT_Vector3 &dir,
167  GU_RayInfo &hitinfo);
168  virtual int minimum(
169  const GEO_Detail &geo,
170  const UT_Vector3 &p,
171  GU_MinInfo &mininfo);
172 
173  virtual int64 getMemoryUsage(bool inclusive) const
174  {
175  int64 mem = inclusive ? sizeof(*this) : 0;
176  return mem;
177  }
178 
179 public:
180  static int circle(
181  GEO_ConstPrimitiveP prim,
182  const GU_Ray &ray,
183  GU_RayInfo &hi,
184  UT_Vector3 &nml);
185  static int sphere(
186  GEO_ConstPrimitiveP prim,
187  const GU_Ray &ray,
188  GU_RayInfo &hi,
189  UT_Vector3 &nml);
190  static int tube(
191  GEO_ConstPrimitiveP prim,
192  const GU_Ray &ray,
193  GU_RayInfo &hi,
194  UT_Vector3 &nml);
195 
196  static void minCircle(const UT_Vector3 &p, UT_Vector3 &minpt);
197  static void minSphere(const UT_Vector3 &p, UT_Vector3 &minpt);
198  static void minTube(
199  GEO_ConstPrimitiveP prim,
200  const UT_Vector3 &p,
201  UT_Vector3 &minpt,
202  float &u,
203  float &v);
204 
205  UT_Matrix4 xform; // Ray transform
206  UT_Matrix3 nmlXform; // Normal transform
207 };
208 
209 //________________________________________________________
210 //
211 // Triangle ray intersection class
212 //________________________________________________________
213 //
214 template<bool istet=false>
216 {
217 public:
218  GU_RayTriangleInfo(GEO_ConstPrimitiveP prim, int serialidx,
219  GA_Offset p0, GA_Offset p1,
220  GA_Offset p2, float w=0.0f);
221  virtual ~GU_RayTriangleInfo();
222 
223  virtual void init(const GEO_Detail &geo);
224 
225  virtual int intersect(
226  const GEO_Detail &geo,
227  const UT_Vector3 &org,
228  const UT_Vector3 &dir,
229  GU_RayInfo &hitinfo);
230  virtual int minimum(
231  const GEO_Detail &geo,
232  const UT_Vector3 &p,
233  GU_MinInfo &mininfo);
234 
235  virtual int64 getMemoryUsage(bool inclusive) const
236  {
237  int64 mem = inclusive ? sizeof(*this) : 0;
238  return mem;
239  }
240 
241 public:
242  GA_Offset myV[3]; // Three corner vertices
243  UT_Vector3 nml; // Surface normal
244  float D; // Plane eqn constant
245  int x, y; // Oriented to projected plane
246  const float myW;
247 };
248 
249 // These are hardened triangles:
250 template<bool istet=false>
252 {
253 public:
254  GU_RayHTriangleInfo(GEO_ConstPrimitiveP prim, int serialidx,
255  const UT_Vector3 &p1, const UT_Vector3 &p2,
256  const UT_Vector3 &p3, float w=0.0f);
257  virtual ~GU_RayHTriangleInfo();
258 
259  virtual void init(const GEO_Detail &geo);
260 
261  virtual int intersect(
262  const GEO_Detail &geo,
263  const UT_Vector3 &org,
264  const UT_Vector3 &dir,
265  GU_RayInfo &hitinfo);
266  virtual int minimum(
267  const GEO_Detail &geo,
268  const UT_Vector3 &p,
269  GU_MinInfo &mininfo);
270 
271  virtual int64 getMemoryUsage(bool inclusive) const
272  {
273  int64 mem = inclusive ? sizeof(*this) : 0;
274  return mem;
275  }
276 
277 public:
278  UT_Vector3 myV[3]; // Three corner verices
279  UT_Vector3 nml; // Surface normal
280  float D; // Plane eqn constant
281  int x, y; // Oriented to projected plane
282  const float myW;
283 };
284 
285 //________________________________________________________
286 //
287 // Tetrahedron ray intersection class
288 //________________________________________________________
289 //
291 {
292 public:
293  GU_RayTetInfo(GEO_ConstPrimitiveP prim, int serialidx,
294  GA_Offset p0, GA_Offset p1,
295  GA_Offset p2, GA_Offset p3);
296  virtual ~GU_RayTetInfo();
297 
298  virtual int intersect(
299  const GEO_Detail &geo,
300  const UT_Vector3 &org,
301  const UT_Vector3 &dir,
302  GU_RayInfo &hitinfo);
303  virtual int minimum(
304  const GEO_Detail &geo,
305  const UT_Vector3 &p,
306  GU_MinInfo &mininfo);
307 
308  virtual int64 getMemoryUsage(bool inclusive) const
309  {
310  int64 mem = inclusive ? sizeof(*this) : 0;
311  return mem;
312  }
313 
314 public:
315  GA_Offset myV[4]; // Four corner vertices
316 };
317 
318 // These are hardened triangles:
320 {
321 public:
322  GU_RayHTetInfo(GEO_ConstPrimitiveP prim, int serialidx,
323  const UT_Vector3 &p1, const UT_Vector3 &p2,
324  const UT_Vector3 &p3, const UT_Vector3 &p4);
325  virtual ~GU_RayHTetInfo();
326 
327  virtual int intersect(
328  const GEO_Detail &geo,
329  const UT_Vector3 &org,
330  const UT_Vector3 &dir,
331  GU_RayInfo &hitinfo);
332  virtual int minimum(
333  const GEO_Detail &geo,
334  const UT_Vector3 &p,
335  GU_MinInfo &mininfo);
336 
337  virtual int64 getMemoryUsage(bool inclusive) const
338  {
339  int64 mem = inclusive ? sizeof(*this) : 0;
340  return mem;
341  }
342 
343 public:
344  UT_Vector3 myV[4]; // Four corner verices
345 };
346 
347 //___________________________________________________________________________
348 //
349 // Quad ray intersection classes - HQuad is for hardened points (i.e. NURBS)
350 //___________________________________________________________________________
351 //
353 {
354 public:
355  GU_RayQuadInfo(GEO_ConstPrimitiveP prim, int serialidx,
356  GA_Offset p0, GA_Offset p1,
357  GA_Offset p2, GA_Offset p3,
358  float ustart = 0.0F, float ulength = 1.0F,
359  float vstart = 0.0F, float vlength = 1.0F,
360  float w=0.0f);
361  virtual ~GU_RayQuadInfo();
362 
363  virtual void init(const GEO_Detail &geo);
364 
365  virtual int intersect(
366  const GEO_Detail &geo,
367  const UT_Vector3 &org,
368  const UT_Vector3 &dir,
369  GU_RayInfo &hitinfo);
370  virtual int minimum(
371  const GEO_Detail &geo,
372  const UT_Vector3 &p,
373  GU_MinInfo &mininfo);
374 
375  virtual int64 getMemoryUsage(bool inclusive) const
376  {
377  int64 mem = inclusive ? sizeof(*this) : 0;
378  return mem;
379  }
380 
381 public:
382  GA_Offset myV[4]; // Four corner vertices
383  UT_Vector3 nml; // Surface normal
384 
385  //float D; // Plane eqn constant
386  //int x, y; // Oriented to projected plane
387  float myUStart, myULength;
388  float myVStart, myVLength;
389  const float myW;
390 };
391 
393 {
394 public:
395  GU_RayHQuadInfo(GEO_ConstPrimitiveP prim, int serialidx,
396  const UT_Vector3 &p0, const UT_Vector3 &p1,
397  const UT_Vector3 &p2, const UT_Vector3 &p3,
398  float ustart = 0.0f, float ulen = 1.0f,
399  float vstart = 0.0f, float vlen = 1.0f,
400  bool revnml = false, float w=0.0f);
401  virtual ~GU_RayHQuadInfo();
402 
403  virtual void init(const GEO_Detail &geo);
404 
405  virtual int intersect(
406  const GEO_Detail &geo,
407  const UT_Vector3 &org,
408  const UT_Vector3 &dir,
409  GU_RayInfo &hitinfo);
410  virtual int minimum(
411  const GEO_Detail &geo,
412  const UT_Vector3 &p,
413  GU_MinInfo &mininfo);
414 
415  virtual int64 getMemoryUsage(bool inclusive) const
416  {
417  int64 mem = inclusive ? sizeof(*this) : 0;
418  return mem;
419  }
420 
421 public:
422  UT_Vector3 myV[4]; // Four corner vertices
423  UT_Vector3 nml; // Surface normal
424  bool myRevNml; // Do we reverse the normal?
425 
426  // These numbers aren't needed by the bilinear code.
427  //float D; // Plane eqn constant
428  //int x, y; // Oriented to projected plane
429 
430  float myUStart, myULength;
431  float myVStart, myVLength;
432  const float myW;
433 };
434 
435 //________________________________________________________
436 //
437 // General Face ray intersection class
438 //________________________________________________________
439 //
441 {
442 public:
443  GU_RayPolyInfo(GEO_ConstPrimitiveP prim, int serialidx,
444  const UT_Array<GA_Offset> &ipts, float w=0.0f);
445  virtual ~GU_RayPolyInfo();
446 
447  virtual int intersect(
448  const GEO_Detail &geo,
449  const UT_Vector3 &org,
450  const UT_Vector3 &dir,
451  GU_RayInfo &hitinfo);
452  virtual int minimum(
453  const GEO_Detail &geo,
454  const UT_Vector3 &p,
455  GU_MinInfo &mininfo);
456 
457  virtual int64 getMemoryUsage(bool inclusive) const
458  {
459  int64 mem = inclusive ? sizeof(*this) : 0;
460  return mem;
461  }
462 
463 public:
465  float D;
466  int x, y;
468  const float myW;
469 };
470 
472 {
473 public:
475  GEO_ConstPrimitiveP prim,
476  int serialidx,
477  UT_Vector4Array &p,
478  float w = 0.0f);
479  virtual ~GU_RayHPolyInfo();
480 
481  virtual int intersect(
482  const GEO_Detail &geo,
483  const UT_Vector3 &org,
484  const UT_Vector3 &dir,
485  GU_RayInfo &hitinfo);
486  virtual int minimum(
487  const GEO_Detail &geo,
488  const UT_Vector3 &p,
489  GU_MinInfo &mininfo);
490 
491  virtual int64 getMemoryUsage(bool inclusive) const
492  {
493  int64 mem = inclusive ? sizeof(*this) : 0;
494  if (xval)
495  mem += npts * sizeof(xval[0]);
496  if (yval)
497  mem += npts * sizeof(yval[0]);
498  return mem;
499  }
500 
501 public:
503 
504  int npts;
508  float D;
509  int x, y;
510  const float myW;
511 };
512 
513 //________________________________________________________
514 //
515 // Meta-surface ray intersection class
516 //________________________________________________________
517 //
519 {
520 public:
521  GU_RayMetaInfo(const TS_MetaExpressionPtr &expr, int serialidx);
522  virtual ~GU_RayMetaInfo();
523 
524  virtual int intersect(
525  const GEO_Detail &geo,
526  const UT_Vector3 &org,
527  const UT_Vector3 &dir,
528  GU_RayInfo &hitinfo);
529 
530  virtual int64 getMemoryUsage(bool inclusive) const;
531 
532 public:
535 };
536 
537 //________________________________________________________
538 //
539 // VDB intersection class
540 //________________________________________________________
542 {
543 public:
544  GU_RayVDBInfo(GEO_ConstPrimitiveP vdb, int serialidx);
545  virtual ~GU_RayVDBInfo();
546 
547  virtual int intersect(
548  const GEO_Detail &geo,
549  const UT_Vector3 &org,
550  const UT_Vector3 &dir,
551  GU_RayInfo &hitinfo);
552 
553  virtual int64 getMemoryUsage(bool inclusive) const;
554 
555 public:
557  float myStepSize;
559  bool myFailed;
561 #ifdef OPENVDB_ENABLED
562  const openvdb::GridBase *myGridRawPtr;
563 #endif
564 
565 };
566 
567 //________________________________________________________
568 //
569 // HeightField intersection class
570 //________________________________________________________
572 {
573 public:
574  GU_RayHeightFieldInfo(const GEO_PrimVolume *vdb, int serialidx);
575  virtual ~GU_RayHeightFieldInfo();
576 
577  virtual int intersect(
578  const GEO_Detail &geo,
579  const UT_Vector3 &org,
580  const UT_Vector3 &dir,
581  GU_RayInfo &hitinfo);
582  virtual int minimum(
583  const GEO_Detail &geo,
584  const UT_Vector3 &p,
585  GU_MinInfo &mininfo);
586 
587  virtual int64 getMemoryUsage(bool inclusive) const;
588 
589 public:
590  int myAxis, myA1, myA2;
591  int myDim[3];
593  bool myFailed;
594  float myScale, myInvScale;
598 };
599 
600 //________________________________________________________
601 //
602 // Packed primitive intersection class
603 //________________________________________________________
604 
606 {
607 public:
608  GU_RayPackedInfo(GEO_ConstPrimitiveP prim, int serialidx, int picking,
609  int polyline, int harden, bool solidtet);
610  virtual ~GU_RayPackedInfo();
611 
612  virtual void init(const GEO_Detail &geo);
613 
614  virtual int intersect(
615  const GEO_Detail &geo,
616  const UT_Vector3 &org,
617  const UT_Vector3 &dir,
618  GU_RayInfo &hitinfo);
619  virtual int minimum(
620  const GEO_Detail &geo,
621  const UT_Vector3 &p,
622  GU_MinInfo &mininfo);
623 
624  virtual int64 getMemoryUsage(bool inclusive) const;
625 
626  void unpack(const GEO_Detail &geo);
627 
628 private:
629  const int myPicking;
630  const int myPolyLine;
631  const int myHarden;
632  const int mySolidTet;
633 
634  UT_UniquePtr<GEO_Detail> myUnpackedGdp;
635  UT_UniquePtr<GU_RayIntersect> myUnpackedIntersect;
636 };
637 
638 //________________________________________________________
639 //
640 // Polyline intersection class
641 //________________________________________________________
642 //
644 {
645 public:
647  GEO_ConstPrimitiveP prim,
648  int serialidx,
649  int span, int len);
650  virtual ~GU_RayPolyLineInfo();
651 
652  virtual int intersect(
653  const GEO_Detail &geo,
654  const UT_Vector3 &org,
655  const UT_Vector3 &dir,
656  GU_RayInfo &hitinfo);
657  virtual int minimum(
658  const GEO_Detail &geo,
659  const UT_Vector3 &p,
660  GU_MinInfo &mininfo);
661  virtual int intersectPrim(
662  const GEO_Detail &geo,
663  const GEO_Detail &prim_geo,
664  GU_RayPrimInfo *prim,
665  GU_RayInfo &hitInfo);
666  virtual int minimumPrim(
667  const GEO_Detail &geo,
668  const GEO_Detail &prim_geo,
669  GU_RayPrimInfo *prim,
670  GU_MinInfo &mininfo);
671 
672  virtual int64 getMemoryUsage(bool inclusive) const
673  {
674  int64 mem = inclusive ? sizeof(*this) : 0;
675  return mem;
676  }
677 
678 public:
679  int mySpan; // What part of the poly
680  int myLen; // we are responsible for
681 };
682 
683 //________________________________________________________
684 //
685 // Curve intersection class
686 //
687 // Note: working in homogeneous coordinate
688 //________________________________________________________
689 //
690 
692 {
693 public:
695  GEO_ConstPrimitiveP curve,
696  int serialidx,
697  bool is_first_span,
698  bool is_last_span)
699  : GU_RayPrimInfo(curve, serialidx)
700  , myFirstSpanFlag(is_first_span)
701  , myLastSpanFlag(is_last_span)
702  {
703  }
704  virtual ~GU_RayCurveInfo() {}
705 
706 protected:
707  // checks the proximity of the ray to the end points of the curve,
708  // and compares it with the tolerance given in hit_info,
709  // but only for these endpoints
710  // of the curve for which first/last span flags (the member data) are true.
711  // If ray passes within the given tolerance, in the hemispherical cup
712  // at the end of the curve, that "seals" the cylidrical zone around
713  // the curve, it is considered as a hit, and 1 is returned.
714  // INPUTS:
715  // org, dir - the origin and direction of the ray
716  // curve - the curve endpoints we investigate
717  // hit_info - its tolerance is treated as a radius of a hemisphere at the
718  // endpoints, within which to test the ray's presence
719  // OUTPUT
720  // hit_info - if hit, a hit is added
721  // RETURN:
722  // 1 if hit: ray passes within tolerance radius of endpoint(s), otherwise 0
723  int intersectEndPointZone(
724  const GEO_Detail &geo,
725  const UT_Vector3 &org,
726  const UT_Vector3 &dir,
727  const GU_RayRBezCurve* curve,
728  GU_RayInfo &hit_info) const;
729 
730 public:
731  // usually a curve primitive is subdivided into several spans, whose
732  // info is encoded in GU_RayRBezCurveInfo and GU_RayNURBCurveInfo.
733  // Following flags indicate if this span is first or last on the curve.
734  bool myFirstSpanFlag : 1, // 1 if it's firsrt span on curve
735  myLastSpanFlag : 1; // 1 if it's last span on curve
736 };
737 
738 class GEO_PrimRBezCurve;
739 
741 {
742 public:
744  const GEO_PrimRBezCurve *curve,
745  int serialidx,
746  bool is_first_span,
747  bool is_last_span,
748  int span,
749  int nvtx,
750  int ord);
751  virtual ~GU_RayRBezCurveInfo();
752 
753  virtual int intersect(
754  const GEO_Detail &geo,
755  const UT_Vector3 &org,
756  const UT_Vector3 &dir,
757  GU_RayInfo &hitinfo);
758  virtual int minimum(
759  const GEO_Detail &geo,
760  const UT_Vector3 &p,
761  GU_MinInfo &mininfo);
762  virtual int intersectPrim(
763  const GEO_Detail &geo,
764  const GEO_Detail &prim_geo,
765  GU_RayPrimInfo *prim,
766  GU_RayInfo &hitInfo);
767  virtual int minimumPrim(
768  const GEO_Detail &geo,
769  const GEO_Detail &prim_geo,
770  GU_RayPrimInfo *prim,
771  GU_MinInfo &mininfo);
772 
773  virtual void init(const GEO_Detail &geo);
774  GU_RayRBezCurve *buildCurve(const GEO_Detail &geo);
775 
776  virtual int64 getMemoryUsage(bool inclusive) const
777  {
778  int64 mem = inclusive ? sizeof(*this) : 0;
779  if (myCurve)
780  mem += myCurve->getMemoryUsage(true);
781  return mem;
782  }
783 
784 public:
785  int mySpan;
787 };
788 
790 {
791 public:
793  GEO_ConstPrimitiveP curve,
794  int serialidx,
795  UT_Interval u,
796  const UT_RefMatrix<UT_Vector4> &patch_cv,
797  int ord,
798  bool is_rational);
799  virtual ~GU_RayNURBCurveInfo();
800 
801  virtual int intersect(
802  const GEO_Detail &geo,
803  const UT_Vector3 &org,
804  const UT_Vector3 &dir,
805  GU_RayInfo &hitinfo);
806  virtual int minimum(
807  const GEO_Detail &geo,
808  const UT_Vector3 &p,
809  GU_MinInfo &mininfo);
810  virtual int intersectPrim(
811  const GEO_Detail &geo,
812  const GEO_Detail &prim_geo,
813  GU_RayPrimInfo *prim,
814  GU_RayInfo &hitInfo);
815  virtual int minimumPrim(
816  const GEO_Detail &geo,
817  const GEO_Detail &prim_geo,
818  GU_RayPrimInfo *prim,
819  GU_MinInfo &mininfo);
820 
821  virtual int64 getMemoryUsage(bool inclusive) const
822  {
823  int64 mem = inclusive ? sizeof(*this) : 0;
824  mem += myCurve.getMemoryUsage(false);
825  return mem;
826  }
827 
828 public:
830 };
831 
832 
833 //________________________________________________________
834 //
835 // Surface intersection class
836 //
837 // Note: working in homogeneous coordinate
838 //________________________________________________________
839 //
841 {
842 public:
844  const GEO_PrimRBezSurf *surf, int serialidx,
845  int u_span, int v_span,
846  int u_ord, int v_ord,
847  float u_start, float u_length,
848  float v_start, float v_length,
849  int u_beg, int v_beg,
850  int u_num, int v_num,
851  bool is_rational);
852  virtual ~GU_RayRBezSurfInfo();
853 
854  virtual int intersect(
855  const GEO_Detail &geo,
856  const UT_Vector3 &org,
857  const UT_Vector3 &dir,
858  GU_RayInfo &hitinfo);
859  virtual int minimum(
860  const GEO_Detail &geo,
861  const UT_Vector3 &p,
862  GU_MinInfo &mininfo);
863 
864  virtual int intersectPrim(
865  const GEO_Detail &geo,
866  const GEO_Detail &prim_geo,
867  GU_RayPrimInfo *prim,
868  GU_RayInfo &hitinfo);
869  virtual int minimumPrim(
870  const GEO_Detail &geo,
871  const GEO_Detail &prim_geo,
872  GU_RayPrimInfo *prim,
873  GU_MinInfo &hitinfo);
874 
875  virtual void init(const GEO_Detail &geo);
876  virtual GU_RayRBezSurf *buildSurf(const GEO_Detail &geo);
877 
878  virtual int64 getMemoryUsage(bool inclusive) const
879  {
880  int64 mem = inclusive ? sizeof(*this) : 0;
881  if (mySurf)
882  mem += mySurf->getMemoryUsage(true);
883  return mem;
884  }
885 
886 public:
887  int myUSpan, myVSpan;
889 };
890 
892 {
893 public:
895  GEO_ConstPrimitiveP surf, int serialidx,
896  int u_ord, int v_ord,
898  const UT_RefMatrix<UT_Vector4> &patch_cv,
899  bool is_rational);
900  virtual ~GU_RayNURBSurfInfo();
901 
902  virtual int intersect(
903  const GEO_Detail &geo,
904  const UT_Vector3 &org,
905  const UT_Vector3 &dir,
906  GU_RayInfo &hitinfo);
907  virtual int minimum(
908  const GEO_Detail &geo,
909  const UT_Vector3 &p,
910  GU_MinInfo &mininfo);
911  virtual int intersectPrim(
912  const GEO_Detail &geo,
913  const GEO_Detail &prim_geo,
914  GU_RayPrimInfo *prim,
915  GU_RayInfo &hitinfo);
916  virtual int minimumPrim(
917  const GEO_Detail &geo,
918  const GEO_Detail &prim_geo,
919  GU_RayPrimInfo *prim,
920  GU_MinInfo &hitinfo);
921 
922  virtual int64 getMemoryUsage(bool inclusive) const
923  {
924  int64 mem = inclusive ? sizeof(*this) : 0;
925  mem += mySurf.getMemoryUsage(false);
926  return mem;
927  }
928 
929 public:
931 };
932 
933 //___________________________________________________________________________
934 //
935 // Moving triangle ray intersection classes
936 // - HTriangle is for hardened points
937 //___________________________________________________________________________
938 //
940 {
941 public:
943  GEO_ConstPrimitiveP prim0, int serialidx,
944  GA_Offset p00, GA_Offset p01,
945  GA_Offset p02,
946  GEO_ConstPrimitiveP prim1,
947  GA_Offset p10, GA_Offset p11,
948  GA_Offset p12);
949  virtual ~GU_RayMovingTriangleInfo();
950 
951  virtual void init(const GEO_Detail &geo);
952 
953  virtual int intersect(
954  const GEO_Detail &geo,
955  const UT_Vector3 &org,
956  const UT_Vector3 &dir,
957  GU_RayInfo &hitinfo);
958 
959  virtual int64 getMemoryUsage(bool inclusive) const
960  {
961  int64 mem = inclusive ? sizeof(*this) : 0;
962  return mem;
963  }
964 
965 private:
966  int insertHit(
967  const GEO_Detail &geo,
968  const UT_Vector3 &org,
969  const UT_Vector3 &dir,
970  GU_RayInfo &hitinfo,
971  float t,
972  float nt);
973 
974 public:
976  GA_Offset myV0[3]; // Three corner vertices at t = 0
977  GA_Offset myV1[3]; // Three corner vertices at t = 1
978 
979  double a2, a1, a0; // Coefficients of x comp of normal
980  double b2, b1, b0; // Coefficients of y comp of normal
981  double c2, c1, c0; // Coefficients of z comp of normal
982 };
983 
984 
985 #endif
UT_VDBType myVDBType
TS_MetaExpressionPtr myExprRef
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
UT_BoundingBox bbox
const float myW
UT_VoxelArrayF myMinMap
volatile int myDirty
const UT_Array< GA_Offset > pts
virtual int minimum(const GEO_Detail &geo, const UT_Vector3 &p, GU_MinInfo &mininfo)
const GLdouble * v
Definition: glcorearb.h:836
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
UT_UniquePtr< GU_RayRBezCurve > myCurve
virtual void init(const GEO_Detail &geo)
UT_ThreadSpecificValue< TS_MetaExpressionPtr > myMetaExprCopies
virtual int minimumPrim(const GEO_Detail &geo, const GEO_Detail &prim_geo, GU_RayPrimInfo *prim, GU_MinInfo &mininfo)
virtual int intersectPrim(const GEO_Detail &geo, const GEO_Detail &prim_geo, GU_RayPrimInfo *prim, GU_RayInfo &hitinfo)
GEO_PrimVolumeXform myXform
GU_RayCurveInfo(GEO_ConstPrimitiveP curve, int serialidx, bool is_first_span, bool is_last_span)
GLint y
Definition: glcorearb.h:102
UT_VDBType
Definition: UT_VDBUtils.h:11
float tscale
int GU_getBilinearQuadIntersection(const UT_Vector3 &org, const UT_Vector3 &dir, const UT_Vector3 &A, const UT_Vector3 &B, const UT_Vector3 &C, const UT_Vector3 &D, const UT_Vector3 &norm, float &t, float &u, float &v, float &d2)
float globalDist(float t) const
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
GA_Size GA_Offset
Definition: GA_Types.h:617
long long int64
Definition: SYS_Types.h:100
UT_UniquePtr< GU_RayRBezSurf > mySurf
GLfloat f
Definition: glcorearb.h:1925
UT_Vector3 org
const openvdb::GridBase * myGridRawPtr
GU_RayRBezSurf mySurf
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
const float myW
GEO_ConstPrimitiveP myPrim2
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GA_PrimitiveP_T< const GEO_Primitive, const GEO_Detail > GEO_ConstPrimitiveP
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
virtual ~GU_RayCurveInfo()
float localDist(float t) const
#define GU_API
Definition: GU_API.h:11
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
const UT_VoxelArrayF * mySamples
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
SYS_FORCE_INLINE GEO_ConstPrimitiveP primP(const GEO_Detail &geo) const
GEO_PrimVolumeXform myXform
UT_VoxelMipMapF myMinMM
FloatPtrArray yval
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
FloatPtrArray xval
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
GLint GLenum GLint x
Definition: glcorearb.h:408
GA_Offset myPrimOffset
virtual int64 getMemoryUsage(bool inclusive) const =0
Report approximate memory usage.
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
UT_ThreadSpecificValue< void * > myCache
GU_RayRBezCurve myCurve
SYS_AtomicCounter refCount
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
virtual int64 getMemoryUsage(bool inclusive) const
Report approximate memory usage.
virtual int intersect(const GEO_Detail &geo, const UT_Vector3 &org, const UT_Vector3 &dir, GU_RayInfo &hitinfo)