RenderManAPI  24.0
RixManifoldWalkConnection.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 2020 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 #ifndef RixManifoldWalkConnection_h
38 #define RixManifoldWalkConnection_h
39 
40 
41 // Stucture used to recover results of the manifold walk
43 {
44  // throughput along the caustic path found
46  // Direction of the new connection (bxdf side)
48  // Direction of the new connection (light side)
50  // Position of the last vertex on the caustic path
52  // Distance between the last vertex and the point on the light source
53  float *dist;
54  // Distance between two starting vertices
55  float *distDirect;
56 
58 
59  float *pdf;
60 
61  float *geoTerm;
62 
63  bool *hasConverged;
64 
65  int _maxSize;
66 
67  // when !_isDirty, Clear() is very cheap.
68  bool _isDirty;
69 
71  throughput(0x0),
72  dir(0x0),
73  toLight(0x0),
74  lastPoint(0x0),
75  dist(0x0),
76  distDirect(0x0),
77  transmission(0x0),
78  pdf(0x0),
79  geoTerm(0x0),
80  hasConverged(0x0),
81  _maxSize(0),
82  _isDirty(true)
83  {
84  }
85 
87  {
88  delete[] throughput; throughput = 0x0;
89  delete[] dir; dir = 0x0;
90  delete[] toLight; toLight= 0x0;
91  delete[] lastPoint; lastPoint = 0x0;
92  delete[] pdf; pdf = 0x0;
93  delete[] dist; dist = 0x0;
94  delete[] distDirect; distDirect = 0x0;
95  delete[] hasConverged; hasConverged = 0x0;
96  delete[] transmission; transmission = 0x0;
97  }
98 
99  void Clear()
100  {
101  //std::fill_n(pdf, _maxSize, 0.f); // not needed since Init() overwrites this anyway
102  if (_isDirty)
103  {
104  std::fill_n(hasConverged, _maxSize, false);
105  std::fill_n(throughput, _maxSize, RtColorRGB(0.f));
106  std::fill_n(transmission, _maxSize, RtColorRGB(0.f));
107  std::fill_n(dist, _maxSize, 0.f);
108  std::fill_n(distDirect, _maxSize, 0.f);
109  _isDirty = false;
110  }
111  }
112 
113  void Init(float* initPDF)
114  {
115  _isDirty = true; // we are about to start modifying this struct
116 
117  if (initPDF)
118  {
119  memcpy(pdf, initPDF, _maxSize*sizeof(float));
120  }
121  else
122  {
123  std::fill_n(pdf, _maxSize, 1.0f);
124  }
125 
126  std::fill_n(hasConverged, _maxSize, false);
127  }
128 
129  void Allocate(int maxSize)
130  {
131  throughput = new RtColorRGB[maxSize];
132  dir = new RtVector3[maxSize];
133  toLight = new RtVector3[maxSize];
134  lastPoint = new RtPoint3[maxSize];
135  dist = new float[maxSize];
136  distDirect = new float[maxSize];
137  pdf = new float[maxSize];
138  hasConverged = new bool[maxSize];
139  transmission = new RtColorRGB[maxSize];
140  _maxSize = maxSize;
141  }
142 };
143 
144 #endif
RtColorRGB * throughput
Definition: RixManifoldWalkConnection.h:45
~RixMWConnectionResult()
Definition: RixManifoldWalkConnection.h:86
RixMWConnectionResult()
Definition: RixManifoldWalkConnection.h:70
RtPoint3 * lastPoint
Definition: RixManifoldWalkConnection.h:51
bool _isDirty
Definition: RixManifoldWalkConnection.h:68
float * dist
Definition: RixManifoldWalkConnection.h:53
RtVector3 * toLight
Definition: RixManifoldWalkConnection.h:49
pxrcore::ColorRGB RtColorRGB
Definition: RiTypesHelper.h:520
RtFloat3 RtPoint3
Definition: RiTypesHelper.h:70
RtVector3 * dir
Definition: RixManifoldWalkConnection.h:47
void Allocate(int maxSize)
Definition: RixManifoldWalkConnection.h:129
void Init(float *initPDF)
Definition: RixManifoldWalkConnection.h:113
Definition: RixManifoldWalkConnection.h:42
void Clear()
Definition: RixManifoldWalkConnection.h:99
int _maxSize
Definition: RixManifoldWalkConnection.h:65
bool * hasConverged
Definition: RixManifoldWalkConnection.h:63
float * distDirect
Definition: RixManifoldWalkConnection.h:55
RtColorRGB * transmission
Definition: RixManifoldWalkConnection.h:57
float * geoTerm
Definition: RixManifoldWalkConnection.h:61
float * pdf
Definition: RixManifoldWalkConnection.h:59
RtFloat3 RtVector3
Definition: RiTypesHelper.h:72