RenderMan API  23.0
RiTypesHelper.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 1986-2019 Pixar. All rights reserved.
5 #
6 # The information in this file (the "Software") is provided for the exclusive
7 # use of the software licensees of Pixar ("Licensees"). Licensees have the
8 # right to incorporate the Software into other products for use by other
9 # authorized software licensees of Pixar, without fee. Except as expressly
10 # permitted herein, the Software may not be disclosed to third parties, copied
11 # or duplicated in any form, in whole or in part, without the prior written
12 # permission of Pixar.
13 #
14 # The copyright notices in the Software and this entire statement, including the
15 # above license grant, this restriction and the following disclaimer, must be
16 # included in all copies of the Software, in whole or in part, and all permitted
17 # derivative works of the Software, unless such copies or derivative works are
18 # solely in the form of machine-executable object code generated by a source
19 # language processor.
20 #
21 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL PIXAR BE
23 # LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
25 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
26 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. IN NO CASE WILL
27 # PIXAR'S TOTAL LIABILITY FOR ALL DAMAGES ARISING OUT OF OR IN CONNECTION WITH
28 # THE USE OR PERFORMANCE OF THIS SOFTWARE EXCEED $50.
29 #
30 # Pixar
31 # 1200 Park Ave
32 # Emeryville CA 94608
33 #
34 # ------------------------------------------------------------------------------
35 */
36 
37 
38 #ifndef RiTypesHelper_h
39 #define RiTypesHelper_h
40 
41 // This file is included via ri.h when using a C++ compiler.
42 // It represents a collection of classes that can be aliased
43 // atop the traditional "C" plain-ol-data representations for
44 // more programming expressivity without loss of performance or
45 // compactness.
46 //
47 // Here's an example programming idiom (for simple scalar case):
48 //
49 // RtPoint op = {1,2,3};
50 // RtPoint3 &np = reinterpret_cast<RtPoint3&>(op);
51 //
52 // Now the standard collection of operator-overriding tricks eagerly await
53 // your beck and call.
54 
55 #include <algorithm> // for swap
56 #include <cassert> // for assert
57 #include <cfloat> // for FLT_MIN
58 #include <cmath> // for fabsf, sqrt, exp
59 #include <cstring> // for memcpy, memcmp
60 #include <functional> // for hash
61 #include <iostream> // for operator<<, etc
62 #include <cstdint> // int32_t, etc.
63 
64 #include "RiEntrypoints.h"
65 #include "pxrcore/ustring/ustring.h"
66 #include "pxrcore/paramlist/types.h"
67 
68 typedef pxrcore::Float3 RtFloat3;
69 static_assert(sizeof(RtFloat3) == sizeof(float[3]), "ensure compat with legacy c-layout");
70 typedef RtFloat3 RtPoint3;
73 typedef pxrcore::Matrix4x4 RtMatrix4x4;
74 
75 
76 // -------------------------------------------------------------------------
77 // RtFloat2 is the base class for RtPoint2, RtVector2, RtNormal2.
78 // All geometrically insensitive operations are implemented here and
79 // used by subclasses. We use subclassing to preserve and convey
80 // geometric-type-sensitive behavior.
81 class RtFloat2
82 {
83  public:
84  // allow direct member access
85  float x, y;
86 
87  inline RtFloat2() = default;
88  inline RtFloat2(float xx, float yy) : x(xx), y(yy) {}
89  explicit inline RtFloat2(float v) : x(v), y(v) {}
90  // construct from a float array
91  // nb: RtFloat2(0) is ambiguous (float and NULL)
92  explicit inline RtFloat2(const float *d) : x(d[0]), y(d[1]) {}
93 
94  // offer access as array (original RtPoint was float[3])
95  inline float& operator[] (int i)
96  {
97  assert(i >= 0 && i<2);
98  return (&x)[i];
99  }
100  inline const float& operator[] (int i) const
101  {
102  assert(i >= 0 && i<2);
103  return (&x)[i];
104  }
105 
106  // Equality comparison
107  inline int operator==(const RtFloat2 &rhs) const
108  {
109  return x == rhs.x && y == rhs.y;
110  }
111  inline int operator!=(const RtFloat2 &rhs) const
112  {
113  return x != rhs.x || y != rhs.y;
114  }
115 
116  // Lexicographical ordering
117  inline bool operator<(const RtFloat2 &rhs) const
118  {
119  return (x < rhs.x ? true :
120  x > rhs.x ? false :
121  y < rhs.y);
122  }
123 
124  // type cast Too dangerous as the compiler does them automatically
125  // and we can't make them explicit (not supported before C++ 11)
126  // use &x[0]
127  //inline operator const float *() const { return (float *) &x; }
128  //inline operator float *() { return (float *) &x; }
129 
130  // serialize
131  friend std::ostream& operator<<(std::ostream& o, const RtFloat2& v)
132  {
133  o << v.x << " " << v.y ;
134  return o;
135  }
136 
137  // Addition
138  inline RtFloat2 operator+(const RtFloat2 &rhs) const
139  {
140  return RtFloat2(x + rhs.x, y + rhs.y);
141  }
142  inline RtFloat2 &operator+=(const RtFloat2 &rhs)
143  {
144  x += rhs.x;
145  y += rhs.y;
146  return *this;
147  }
148  // Subtraction
149  inline RtFloat2 operator-(const RtFloat2 &rhs) const
150  {
151  return RtFloat2(x - rhs.x, y - rhs.y);
152  }
153  inline RtFloat2 &operator-=(const RtFloat2 &rhs)
154  {
155  x -= rhs.x;
156  y -= rhs.y;
157  return *this;
158  }
159 
160  // Multiplication operator
161  inline RtFloat2 operator*(const RtFloat2 &rhs) const
162  {
163  return RtFloat2(x * rhs.x, y * rhs.y);
164  }
165  inline RtFloat2 &operator*=(const RtFloat2 &rhs)
166  {
167  x *= rhs.x;
168  y *= rhs.y;
169  return *this;
170  }
171 
172  // Division operator
173  inline RtFloat2 operator/(const RtFloat2 &rhs) const
174  {
175  return RtFloat2(x / rhs.x, y / rhs.y);
176  }
177  inline RtFloat2 &operator/=(const RtFloat2 &rhs)
178  {
179  x /= rhs.x;
180  y /= rhs.y;
181  return *this;
182  }
183 
184  // Unary minus
185  inline RtFloat2 operator-() const { return RtFloat2(-x, -y); }
186 
187  // Scalar multiplication
188  inline RtFloat2 operator*(float rhs) const
189  {
190  return RtFloat2(x * rhs, y * rhs);
191  }
192  inline friend RtFloat2 operator*(float lhs, const RtFloat2 &rhs) {
193  return rhs * lhs;
194  }
195  inline RtFloat2 &operator*=(float rhs)
196  {
197  x *= rhs;
198  y *= rhs;
199  return *this;
200  }
201 
202  // Scalar division
203  inline RtFloat2 operator/(float rhs) const
204  {
205  float inv = 1.0f / rhs;
206  return operator*(inv);
207  }
208  inline RtFloat2 & operator/=(float rhs)
209  {
210  float inv = 1.0f / rhs;
211  return operator*=(inv);
212  }
213 
214  // Length
215  inline float LengthSq() const
216  {
217  return (x*x + y*y);
218  }
219  inline float Length() const
220  {
221  return std::sqrt(LengthSq());
222  }
223 
224  // Check that a vector has (approximately) unit length
225  inline bool IsUnitLength(float eps=0.005f) const
226  {
227  float len = Length();
228  return (1.0f-eps <= len && len <= 1.0f+eps);
229  }
230 
231  // Normalize vector in place, return length
232  inline float Normalize(float eps = FLT_MIN)
233  {
234  float len = LengthSq();
235  if (len > eps)
236  {
237  len = std::sqrt(len);
238  *this /= len;
239  }
240  else
241  x = y = 0.0f;
242  return len;
243  }
244  inline friend float Normalize(RtFloat2 &v)
245  {
246  return v.Normalize();
247  }
248 
249  // Return normalized copy of vector
250  inline RtFloat2 NormalizeCopy(const RtFloat2 &v) const
251  {
252  RtFloat2 copy = v;
253  copy.Normalize();
254  return copy;
255  }
256  inline friend RtFloat2 NormalizeCopy(const RtFloat2 &v)
257  {
258  RtFloat2 copy = v;
259  copy.Normalize();
260  return copy;
261  }
262 
263  inline void Negate()
264  {
265  x = -x;
266  y = -y;
267  }
268 
269  // Dot product
270  inline float Dot(const RtFloat2 &v2) const
271  {
272  return x * v2.x + y * v2.y;
273  }
274  inline friend float Dot(const RtFloat2 &v1, const RtFloat2 &v2)
275  {
276  return v1.Dot(v2);
277  }
278 
279  // Absolute value of dot product
280  inline float AbsDot(const RtFloat2 &v2) const
281  {
282  return std::abs(this->Dot(v2));
283  }
284  inline friend float AbsDot(const RtFloat2 &v1, const RtFloat2 &v2)
285  {
286  return v1.AbsDot(v2);
287  }
288 
289  // Cross product
290  inline float Cross(const RtFloat2 &v2) const
291  {
292  return x * v2.y - y * v2.x;
293  }
294  inline friend float Cross(const RtFloat2 &v1, const RtFloat2 &v2)
295  {
296  return v1.Cross(v2);
297  }
298 
299  inline float ChannelAvg() const
300  {
301  return (x + y) * .5f;
302  }
303 
304  inline float ChannelMin() const
305  {
306  return std::min(x, y);
307  }
308 
309  inline float ChannelMax() const
310  {
311  return std::max(x, y);
312  }
313 
314 };
315 
316 static_assert(sizeof(RtFloat2) == sizeof(float[2]), "ensure compat with legacy c-layout");
317 typedef RtFloat2 RtPoint2;
319 
320 typedef pxrcore::Float4 RtFloat4;
321 static_assert(sizeof(RtFloat4) == sizeof(float[4]), "ensure compat with legacy c-layout");
322 typedef RtFloat4 RtPoint4;
323 
324 // -------------------------------------------------------------------------
325 // RtBBox - an axis-aligned bounding box
326 class RtBBox {
327  public:
328  // allow direct member access
329  RtPoint3 min, max;
330 
331  inline RtBBox() {}
332  inline RtBBox(float minx, float miny, float minz,
333  float maxx, float maxy, float maxz)
334  {
335  min.x = minx; min.y = miny; min.z = minz;
336  max.x = maxx; max.y = maxy; max.z = maxz;
337  }
338  inline RtBBox(const RtPoint3 &_min, const RtPoint3 &_max)
339  {
340  min = _min;
341  max = _max;
342  }
343 
344  inline void Expand(const float expansion) {
345  // Expand proportional to size near origin (i.e., interval
346  // contains zero) and proportional to distance from origin
347  // when farther away. Numerically, this guarantees expansion
348  // no matter where it is.
349  float d;
350  d = expansion * (fabsf(min.x) + fabsf(max.x));
351  min.x -= d;
352  max.x += d;
353 
354  d = expansion * (fabsf(min.y) + fabsf(max.y));
355  min.y -= d;
356  max.y += d;
357 
358  d = expansion * (fabsf(min.z) + fabsf(max.z));
359  min.z -= d;
360  max.z += d;
361  }
362 
363  // Volume of bounding box
364  inline float Volume() const
365  {
366  return ((max.x - min.x) *
367  (max.y - min.y) *
368  (max.z - min.z));
369  }
370 
371  // Surface area of bounding box
372  inline float SurfaceArea() const
373  {
374  RtVector3 diff(max - min);
375  return 2.0f * (diff.x * diff.y + diff.x * diff.z + diff.y * diff.z);
376  }
377 
378  // Length of the diagonal of the bounding box
379  inline float Diagonal() const
380  {
381  return RtVector3(max - min).Length();
382  }
383 
384  // Square of the length of the diagonal of the bounding box
385  inline float DiagonalSq() const
386  {
387  return RtVector3(max - min).LengthSq();
388  }
389 
390  inline RtPoint3 Center() const
391  {
392  return 0.5f * RtPoint3(min + max);
393  }
394 
395  // Make the bounding box contain point pt
396  inline void Expand(const RtPoint3 &pt)
397  {
398  if (pt.x < min.x) min.x = pt.x;
399  if (pt.y < min.y) min.y = pt.y;
400  if (pt.z < min.z) min.z = pt.z;
401  if (pt.x > max.x) max.x = pt.x;
402  if (pt.y > max.y) max.y = pt.y;
403  if (pt.z > max.z) max.z = pt.z;
404  }
405 
406  // this = this union bbox
407  inline void Union(const RtBBox &bbox)
408  {
409  if (bbox.min.x < min.x) min.x = bbox.min.x;
410  if (bbox.min.y < min.y) min.y = bbox.min.y;
411  if (bbox.min.z < min.z) min.z = bbox.min.z;
412  if (bbox.max.x > max.x) max.x = bbox.max.x;
413  if (bbox.max.y > max.y) max.y = bbox.max.y;
414  if (bbox.max.z > max.z) max.z = bbox.max.z;
415  }
416 
417  // this = this intersect bbox
418  inline void Intersect(const RtBBox &bbox)
419  {
420  if (bbox.min.x > min.x) min.x = bbox.min.x;
421  if (bbox.min.y > min.y) min.y = bbox.min.y;
422  if (bbox.min.z > min.z) min.z = bbox.min.z;
423  if (bbox.max.x < max.x) max.x = bbox.max.x;
424  if (bbox.max.y < max.y) max.y = bbox.max.y;
425  if (bbox.max.z < max.z) max.z = bbox.max.z;
426  }
427 
428  // Does this bounding box contain point pt?
429  inline bool Contains(const RtPoint3 &pt) const
430  {
431  bool contains =
432  (min.x < pt.x && pt.x < max.x &&
433  min.y < pt.y && pt.y < max.y &&
434  min.z < pt.z && pt.z < max.z);
435  return contains;
436  }
437 
438  // Is point pt entirely outside this bounding box?
439  // (Note: a point on the surface is neither contained nor outside.)
440  inline bool Outside(const RtPoint3 &pt) const
441  {
442  return (pt.x < min.x || max.x < pt.x ||
443  pt.y < min.y || max.y < pt.y ||
444  pt.z < min.z || max.z < pt.z);
445  }
446 
447  // Does this bounding box entirely enclose another bounding box?
448  inline bool Encloses(const RtBBox &bbox) const
449  {
450  return (bbox.min.x >= min.x && bbox.min.y >= min.y && bbox.min.z >= min.z &&
451  bbox.max.x <= max.x && bbox.max.y <= max.y && bbox.max.z <= max.z);
452  }
453 
454  // Does this bounding box overlap another bounding box?
455  inline bool Overlaps(const RtBBox &bbox) const
456  {
457  return !(max.x <= bbox.min.x || bbox.max.x <= min.x ||
458  max.y <= bbox.min.y || bbox.max.y <= min.y ||
459  max.z <= bbox.min.z || bbox.max.z <= min.z);
460  }
461 
462  // Is this bounding box intersected by the ray defined by origin
463  // org and inverse direction invdir between 0 and tmax? If yes,
464  // dist0 and dist1 contain the intersection points
465  inline bool Intersects(const RtPoint3 &org, const RtVector3 &invdir,
466  float tmax, float *dist0, float *dist1) const
467  {
468  float tmin = 0.0f;
469  float t0, t1;
470 
471  // Compute slab intersection intervals for x component
472  if (invdir.x < 0.0f) {
473  t0 = (max.x - org.x) * invdir.x;
474  t1 = (min.x - org.x) * invdir.x;
475  } else {
476  t0 = (min.x - org.x) * invdir.x;
477  t1 = (max.x - org.x) * invdir.x;
478  }
479  // At this point, t0 and t1 is +/-inf if ray->dir.x is +/-0.
480  // t0 or t1 is NaN if bbox-org is 0 and invdirx is inf (since
481  // inf*0 is NaN by convention)
482  if (t0 > tmin) tmin = t0;
483  if (t1 < tmax) tmax = t1;
484  if (tmin > tmax)
485  return false; // slab interval is empty
486 
487  // Compute slab intersection intervals for y component
488  if (invdir.y < 0.0f) {
489  t0 = (max.y - org.y) * invdir.y;
490  t1 = (min.y - org.y) * invdir.y;
491  } else {
492  t0 = (min.y - org.y) * invdir.y;
493  t1 = (max.y - org.y) * invdir.y;
494  }
495  if (t0 > tmin) tmin = t0;
496  if (t1 < tmax) tmax = t1;
497  if (tmin > tmax)
498  return false; // slab interval is empty
499 
500  // Compute slab intersection intervals for z component
501  if (invdir.z < 0.0f) {
502  t0 = (max.z - org.z) * invdir.z;
503  t1 = (min.z - org.z) * invdir.z;
504  } else {
505  t0 = (min.z - org.z) * invdir.z;
506  t1 = (max.z - org.z) * invdir.z;
507  }
508  if (t0 > tmin) tmin = t0;
509  if (t1 < tmax) tmax = t1;
510  if (tmin > tmax)
511  return false; // slab interval is empty
512 
513  *dist0 = tmin;
514  *dist1 = tmax;
515  return true;
516  }
517 };
518 
519 typedef pxrcore::ColorRGB RtColorRGB;
520 static_assert(sizeof(RtColorRGB) == sizeof(float[3]), "ensure compat with legacy c-layout");
521 
522 // -------------------------------------------------------------------------
523 // A simple reference counted pointer class.
524 //
525 // To use, the templated type should be a class/struct that implements the
526 // following public methods:
527 //
528 // void IncRef() // increment the reference count
529 // void DecRef() // decrement the reference count, deleting object when zero
530 // int GetRefCnt() // returns the current reference count
531 //
532 // Use about the same way that you would a boost::shared_ptr<T> class, except
533 // that the reference count is stored and modified within the templated type
534 // (tbb::atomic or similar would be recommended for multi-threaded usage).
535 //
536 // Portability note: When implementing DecRef() in your templated class, keep
537 // in mind that it is important on Windows that the call to new/delete or
538 // malloc/free of the reference-counted object happens in the same .dll / .exe.
539 //
540 // Note: We would just use boost or tr1 reference-counted pointers instead of
541 // providing this utility class, except that we don't want to introduce a
542 // dependency on boost or tr1 here for a few different reasons.
543 //
544 template<typename T>
546 {
547  public:
548 
549  // Default constructor; sets the pointer value to zero.
550  RixRefCntPtr() : m_ptr(0)
551  {
552  }
553 
554  // Construct from a direct pointer; increments the reference count.
555  RixRefCntPtr(T *ptr) : m_ptr(ptr)
556  {
557  if (m_ptr)
558  m_ptr->IncRef();
559  }
560 
561  // Copy constructor; increments the reference count.
563  {
564  m_ptr = that.m_ptr;
565  if (m_ptr)
566  m_ptr->IncRef();
567  }
568 
569  // Destructor; decrements the reference count, deleting if now unused.
571  {
572  if (m_ptr)
573  m_ptr->DecRef();
574  }
575 
576  // Assignment operator; increment the rhs count, decrement the lhs count.
577  RixRefCntPtr<T>& operator= (RixRefCntPtr<T> const &that)
578  {
579  if (that.m_ptr != m_ptr)
580  {
581  if (that.m_ptr)
582  that.m_ptr->IncRef();
583 
584  if (m_ptr)
585  m_ptr->DecRef();
586 
587  m_ptr = that.m_ptr;
588  }
589 
590  return *this;
591  }
592 
593  // Assignment operator; increment the rhs count, decrement the lhs count.
594  RixRefCntPtr<T>& operator= (T *ptr)
595  {
596  if (m_ptr != ptr)
597  {
598  if (ptr)
599  ptr->IncRef();
600 
601  if (m_ptr)
602  m_ptr->DecRef();
603 
604  m_ptr = ptr;
605  }
606 
607  return *this;
608  }
609 
610  // Equality test; check if pointers are the same.
611  bool operator== (RixRefCntPtr<T> const &that) const
612  {
613  return m_ptr == that.m_ptr;
614  }
615 
616  // Equality test; check if pointers are the same.
617  bool operator== (T const *ptr) const
618  {
619  return m_ptr == ptr;
620  }
621 
622  // Inequality test; check if the pointers are different.
623  bool operator!= (RixRefCntPtr<T> const &that) const
624  {
625  return m_ptr != that.m_ptr;
626  }
627 
628  // Inequality test; check if the pointers are different.
629  bool operator!= (T const *ptr) const
630  {
631  return m_ptr != ptr;
632  }
633 
634  // Comparison operator; comparison based on memory address.
635  bool operator< (RixRefCntPtr<T> const &that) const
636  {
637  return m_ptr < that.m_ptr;
638  }
639 
640  // Comparison operator; comparison based on memory address.
641  bool operator< (T const *ptr) const
642  {
643  return m_ptr < ptr;
644  }
645 
646  // Boolean conversion operator; true when pointer is non-null.
647  operator bool () const { return m_ptr != NULL; }
648 
649  // Indirection operator; return the pointer value by reference.
650  T& operator* () { return *m_ptr; }
651  T const& operator* () const { return *m_ptr; }
652 
653  // Dereference operator; return the pointer value.
654  T* operator-> () { return m_ptr; }
655  T const* operator-> () const { return m_ptr; }
656 
657  // Returns the pointer value.
658  T* GetPtr() { return m_ptr; }
659  const T* GetPtr() const { return m_ptr; }
660 
661  // Set the pointer value without modifying the reference count.
662  void SetPtr(T *ptr) { m_ptr = ptr; }
663 
664  // Returns the current reference count.
665  int GetRefCnt() const { return m_ptr ? m_ptr->GetRefCnt() : 0; }
666 
667  private:
668 
669  // The pointer value.
670  T *m_ptr;
671 };
672 
673 /*
674 namespace RixConstants
675 {
676  static const RtMatrix4x4 k_identityMatrix();
677  static const RtMatrix4x4 k_zeroMatrix(RtVector3(0.f), 0.f);
678 }
679 */
680 
681 typedef pxrcore::UString RtUString;
682 #define US_NULL RtUString()
683 
684 #endif
float Normalize(float eps=FLT_MIN)
pxrcore::ColorRGB RtColorRGB
RtFloat2 & operator-=(const RtFloat2 &rhs)
float Volume() const
int operator!=(const RtFloat2 &rhs) const
float ChannelAvg() const
const T * GetPtr() const
int GetRefCnt() const
RixRefCntPtr(RixRefCntPtr const &that)
RtPoint3 Center() const
RtFloat2 operator*(const RtFloat2 &rhs) const
void Union(const RtBBox &bbox)
bool operator<(const RtFloat2 &rhs) const
RtFloat2 & operator/=(float rhs)
void Intersect(const RtBBox &bbox)
int operator==(const RtFloat2 &rhs) const
RtFloat2(const float *d)
Definition: RiTypesHelper.h:92
RtFloat2 RtVector2
RtPoint3 min
RtFloat2 & operator*=(float rhs)
friend float AbsDot(const RtFloat2 &v1, const RtFloat2 &v2)
RtFloat3 RtPoint3
Definition: RiTypesHelper.h:69
RtFloat2 & operator+=(const RtFloat2 &rhs)
bool Encloses(const RtBBox &bbox) const
friend float Cross(const RtFloat2 &v1, const RtFloat2 &v2)
float Cross(const RtFloat2 &v2) const
pxrcore::Float4 RtFloat4
RtFloat2 & operator/=(const RtFloat2 &rhs)
void SetPtr(T *ptr)
float AbsDot(const RtFloat2 &v2) const
RtBBox(float minx, float miny, float minz, float maxx, float maxy, float maxz)
float Dot(const RtFloat2 &v2) const
float Diagonal() const
RtFloat2(float xx, float yy)
Definition: RiTypesHelper.h:88
friend float Normalize(RtFloat2 &v)
float ChannelMax() const
RtFloat3 RtNormal3
Definition: RiTypesHelper.h:72
RtFloat2 NormalizeCopy(const RtFloat2 &v) const
float LengthSq() const
RtFloat4 RtPoint4
RtBBox(const RtPoint3 &_min, const RtPoint3 &_max)
RtFloat2 operator*(float rhs) const
RtFloat2 & operator*=(const RtFloat2 &rhs)
RtFloat2 operator/(float rhs) const
friend RtFloat2 operator*(float lhs, const RtFloat2 &rhs)
float SurfaceArea() const
void Negate()
RixRefCntPtr(T *ptr)
pxrcore::UString RtUString
RtFloat2 operator/(const RtFloat2 &rhs) const
friend RtFloat2 NormalizeCopy(const RtFloat2 &v)
bool IsUnitLength(float eps=0.005f) const
RtFloat2 operator-() const
RtFloat2(float v)
Definition: RiTypesHelper.h:89
float ChannelMin() const
pxrcore::Matrix4x4 RtMatrix4x4
Definition: RiTypesHelper.h:73
void Expand(const float expansion)
pxrcore::Float3 RtFloat3
Definition: RiTypesHelper.h:68
RtPoint3 max
RtFloat2()=default
friend float Dot(const RtFloat2 &v1, const RtFloat2 &v2)
bool Overlaps(const RtBBox &bbox) const
float DiagonalSq() const
RtFloat2 operator+(const RtFloat2 &rhs) const
float Length() const
bool Contains(const RtPoint3 &pt) const
RtFloat2 operator-(const RtFloat2 &rhs) const
bool Intersects(const RtPoint3 &org, const RtVector3 &invdir, float tmax, float *dist0, float *dist1) const
friend std::ostream & operator<<(std::ostream &o, const RtFloat2 &v)
RtFloat2 RtPoint2
bool Outside(const RtPoint3 &pt) const
float & operator[](int i)
Definition: RiTypesHelper.h:95
void Expand(const RtPoint3 &pt)
RtFloat3 RtVector3
Definition: RiTypesHelper.h:71