NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
VisualizationKDTree.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, FI MUNI CZ
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the <organization> nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * Authors:
28  * Radek Stibora
29  *
30  */
31 
33 #include "ray/PixelTable.hpp"
34 #include "cuda\Renderer.hpp"
35 
36 using namespace FW;
37 
38 #define NO_NODE FW_S32_MIN
39 #define ROOT_ADDR 0
40 
41 #define COLOR_NODE 0x14FFFFFF
42 #define COLOR_SIBLING 0x14000000
43 #define COLOR_LEFT 0x330000FF
44 #define COLOR_RIGHT 0x3300FF00
45 #define COLOR_RAY 0xFFFFFFFF
46 #define COLOR_TRI_INVIS 0xFF000000
47 #define COLOR_TRI_VIS 0xFFFFFFFF
48 
49 #define COLOR_LEFT_SAH 0x330000FF
50 #define COLOR_RIGHT_SAH 0x3300FF00
51 #define COLOR_LEFT_SVBH 0x33FF00FF
52 #define COLOR_RIGHT_SVBH 0x33FFFF00
53 #define COLOR_LEFT_OSAH 0x3300FFFF
54 #define COLOR_RIGHT_OSAH 0x33FF0000
55 
56 //------------------------------------------------------------------------
57 
58 VisualizationKDTree::VisualizationKDTree(CudaKDTree* kdtree, Scene* scene, const Array<AABB> &emptyBoxes, const RayBuffer* rays, Buffer* visibility)
59 : Visualization(scene),
60  m_kdtree(kdtree)
61 {
62  m_node.box = kdtree->getBBox(); // scene bounding box
63  m_node.addr = 0;
64 
65  splitNode(m_node, m_left.addr, m_right.addr, m_left.box, m_right.box, m_nodeSplit);
66 
67  // Initialize m_node, m_sibling, m_left and m_right
68  //m_bvh->getNode(m_node.addr, &m_nodeSplit, m_left.box, m_right.box, m_left.addr, m_right.addr);
69  //m_node.box = m_left.box + m_right.box; // Compute the root box
70  //growParentBox();
71  m_sibling.addr = NO_NODE;
72 
73  // Inititalize stacks
74  m_nodeStack.add(m_node);
75  m_splitPath.add(m_nodeSplit.getPos() + " " + m_nodeSplit.getAxisName() + ":");
76 
77  // Clear the osah split counts in current node
78  memset(m_osahSplits, 0, sizeof(m_osahSplits));
79 
80  // Initialize rays
81  if(rays != NULL)
82  {
83  Array<Vec4f> lines;
84  const int stride = 4096;
85 
86  //PixelTable pixelTable;
87  //pixelTable.setSize(Vec2i(1024, 768));
88 
89  //for(S32 i = 0; i < 1024*32; i++)
90  //{
91  // int index = pixelTable.getPixelToIndex().getMutablePtr()[i];
92  // Ray ray = rays->getRayForSlot(index);
93  // float t;
94  // if(rays->getResultForSlot(index).hit())
95  // //t = rays->getResultForSlot(i*stride).t;
96  // t = rays->getResultForSlot(index).padA;
97  // else
98  // t = ray.tmax;
99  // lines.add(Vec4f(ray.origin, 1.0f));
100  // lines.add(Vec4f(ray.origin + t*ray.direction, 1.0f));
101  //}
102 
103  for(S32 i = 0; i < rays->getSize()/stride; i++)
104  {
105  Ray ray = rays->getRayForSlot(i*stride);
106  float t;
107  if(rays->getResultForSlot(i*stride).hit())
108  //t = rays->getResultForSlot(i*stride).t;
109  t = rays->getResultForSlot(i*stride).padA;
110  else
111  t = ray.tmax;
112  lines.add(Vec4f(ray.origin, 1.0f));
113  lines.add(Vec4f(ray.origin + t*ray.direction, 1.0f));
114  }
115 
117  m_rays.set(lines.getPtr(), lines.getNumBytes());
118  }
119  else
120  {
121  m_showRays = false;
122  }
123 
124  // Initialize empty boxes
125  Array<Vec4f> boxes, colors, lineColors, colorPalette;
126  for(int i = 0; i < emptyBoxes.getSize(); i++)
127  addBoxQuads(emptyBoxes[i], boxes);
129  m_emptyBoxes.set(boxes.getPtr(), boxes.getNumBytes());
130  // Initialize colors for empty boxes
131  /*for(int r = 1; r > -1; r--)
132  for(int g = 1; g > -1; g--)
133  for(int b = 1; b > -1; b--)*/
134  for(int r = 0; r < 2; r++)
135  for(int g = 0; g < 2; g++)
136  for(int b = 0; b < 2; b++)
137  if(r+g+b < 3)
138  colorPalette.add(Vec4f((float)r, (float)g, (float)b, 0.33f));
139  for(int i = 0; i < emptyBoxes.getSize(); i++)
140  for(int j = 0; j < 6*4; j++) // Repeate for each vertex of the box 6 faces * 4 vertices per face
141  {
142  colors.add(colorPalette[i % colorPalette.getSize()]);
143  lineColors.add(colorPalette[i % colorPalette.getSize()]);
144  lineColors.getLast().w = 1.0f;
145  }
147  m_emptyColors.set(colors.getPtr(), colors.getNumBytes());
149  m_emptyLineColors.set(lineColors.getPtr(), lineColors.getNumBytes());
150 
151  // Initialize visibility
152  if(visibility != NULL)
153  {
154  m_visibility.set((S32*)visibility->getPtr(), scene->getNumTriangles());
155  }
156  else
157  {
160  }
161 
167 }
168 
169 //------------------------------------------------------------------------
170 
172 {
173 }
174 
175 //------------------------------------------------------------------------
176 
178 {
179  //FW_ASSERT(m_window == ev.window || ev.type == Window::EventType_AddListener);
180 
181  // Handle events.
182 
183  switch (ev.type)
184  {
185  /*case Window::EventType_AddListener:
186  FW_ASSERT(!m_window);
187  m_window = ev.window;
188  repaint();
189  return false;
190 
191  case Window::EventType_RemoveListener:
192  repaint();
193  m_window = NULL;
194  return false;*/
195 
197  //if (ev.key == FW_KEY_V) setVisible(!m_visible);
198  if(isVisible())
199  {
200  if (ev.key == FW_KEY_B) { m_splitColors = !m_splitColors; setColorMapping(); }
201  if (ev.key == FW_KEY_J) { m_showChildren = !m_showChildren; }
202  if (ev.key == FW_KEY_U && m_rays.getSize() > 0) { m_showRays = !m_showRays; }
203  if (ev.key == FW_KEY_P && m_emptyBoxes.getSize() > 0) { m_showEmpty = !m_showEmpty; }
204  if (ev.key == FW_KEY_O) { m_showCurrTris = !m_showCurrTris; prepareTreeData(m_node); }
205  if (ev.key == FW_KEY_L) { m_showAllOSAH = !m_showAllOSAH; prepareTreeData(m_node); }
206  if (ev.key == FW_KEY_T) { moveToParent(); if(m_showCurrTris || m_showAllOSAH) prepareTreeData(m_node); }
207  if (ev.key == FW_KEY_Y) { moveToSibling(); if(m_showCurrTris || m_showAllOSAH) prepareTreeData(m_node); }
208  if (ev.key == FW_KEY_G) { moveToLeft(); if(m_showCurrTris || m_showAllOSAH) prepareTreeData(m_node); }
209  if (ev.key == FW_KEY_H) { moveToRight(); if(m_showCurrTris || m_showAllOSAH) prepareTreeData(m_node); }
210  if (ev.key == FW_KEY_I) { moveUp(); if(m_showCurrTris || m_showAllOSAH) prepareTreeData(m_node); }
211  if (ev.key == FW_KEY_K) { moveDown(); if(m_showCurrTris || m_showAllOSAH) prepareTreeData(m_node); }
212  }
213  break;
214 
215  default:
216  break;
217  }
218 
219  return false;
220 }
221 
222 //------------------------------------------------------------------------
223 
225 {
226  moveUp();
227 
228  // Update path
229  m_nodeStack[m_currentDepth] = m_node;
230  if(!m_splitPath[m_currentDepth].endsWith(":"))
232  //(m_splitPath.get(m_currentDepth).[m_splitPath[m_currentDepth].indexOf(':')+1]) = ' ';
233  m_nodeStack.resize(m_currentDepth+1);
234  m_splitPath.resize(m_currentDepth+1);
235 }
236 
237 //------------------------------------------------------------------------
238 
240 {
241  if(m_sibling.addr == NO_NODE)
242  return;
243 
244  NodeData temp;
245  temp = m_node;
246  m_node = m_sibling;
247  m_sibling = temp;
248 
249  if(m_node.addr >= 0)//if(!m_kdtree->isLeaf(m_node.addr))
250  {
251  //m_bvh->getNode(m_node.addr, &m_nodeSplit, m_left.box, m_right.box, m_left.addr, m_right.addr);
252  splitNode(m_node, m_left.addr, m_right.addr, m_left.box, m_right.box, m_nodeSplit);
253  }
254  // Set color mapping for visible nodes
255  setColorMapping();
256 
257  // Update path
258  m_nodeStack[m_currentDepth] = m_node;
259  m_splitPath[m_currentDepth] = m_nodeSplit.getPos() + " " + m_nodeSplit.getAxisName() + ": ";
260  m_nodeStack.resize(m_currentDepth+1);
261  m_splitPath.resize(m_currentDepth+1);
262  // Flip child identifier from the previous split
263  if(m_splitPath[m_currentDepth-1][m_splitPath[m_currentDepth-1].indexOf(':')+1] == 'L')
264  {
265  m_splitPath[m_currentDepth-1] = m_splitPath[m_currentDepth-1].substring(0, m_splitPath[m_currentDepth-1].getLength()-1);
267  }
268  // m_splitPath[m_currentDepth-1][m_splitPath[m_currentDepth].indexOf(':')+1] = 'R';
269  else
270  {
271  // m_splitPath[m_currentDepth-1][m_splitPath[m_currentDepth].indexOf(':')+1] = 'L';
272  m_splitPath[m_currentDepth-1] = m_splitPath[m_currentDepth-1].substring(0, m_splitPath[m_currentDepth-1].getLength()-1);
274  }
275 }
276 
277 //------------------------------------------------------------------------
278 
280 {
281  if(m_left.addr < 0)
282  return;
283 
284  m_node = m_left;
285  m_sibling = m_right;
286 
287  if(m_node.addr >= 0)
288  {
289  splitNode(m_node, m_left.addr, m_right.addr, m_left.box, m_right.box, m_nodeSplit);
290  }
291  else
292  {
293  m_left.addr = NO_NODE;
294  m_right.addr = NO_NODE;
295  }
296 
297  //growParentBox();
298  // Set color mapping for visible nodes
299  setColorMapping();
300 
301  // Update path
303  m_nodeStack.resize(m_currentDepth+1);
304  m_splitPath.resize(m_currentDepth+1);
305  // Add to the path
306  m_nodeStack.add(m_node);
307  m_splitPath.add(m_nodeSplit.getPos() + " " + m_nodeSplit.getAxisName() + ": ");
308  m_currentDepth++;
309 }
310 
311 //------------------------------------------------------------------------
312 
314 {
315  if(m_right.addr < 0)
316  return;
317 
318  m_node = m_right;
319  m_sibling = m_left;
320 
321  if(m_node.addr >= 0)
322  {
323  splitNode(m_node, m_left.addr, m_right.addr, m_left.box, m_right.box, m_nodeSplit);
324  }
325  else
326  {
327  m_left.addr = NO_NODE;
328  m_right.addr = NO_NODE;
329  }
330 
331  //growParentBox();
332  // Set color mapping for visible nodes
333  setColorMapping();
334 
335  // Update path
337  m_nodeStack.resize(m_currentDepth+1);
338  m_splitPath.resize(m_currentDepth+1);
339  // Add to the path
340  m_nodeStack.add(m_node);
341  m_splitPath.add(m_nodeSplit.getPos() + " " + m_nodeSplit.getAxisName() + ": ");
342  m_currentDepth++;
343 }
344 
345 //------------------------------------------------------------------------
346 
348 {
349  if(m_currentDepth > 0)
350  {
351  m_currentDepth--;
352  getFromIndex(m_currentDepth);
353  }
354 }
355 
356 //------------------------------------------------------------------------
357 
359 {
360  if(m_currentDepth < m_nodeStack.getSize()-1)
361  {
362  m_currentDepth++;
363  getFromIndex(m_currentDepth);
364  }
365 }
366 
367 //------------------------------------------------------------------------
368 
370 {
371  FW_ASSERT(gl);
372 
373  if(!isVisible())
374  return;
375 
376  Mat4f oldXform = gl->setVGXform(gl->xformFitToView(-1.0f, 2.0f) * camera.getWorldToClip());
377  glPushAttrib(GL_ENABLE_BIT);
378  glEnable(GL_DEPTH_TEST);
379  glDepthFunc(GL_LESS);
380  glEnable(GL_CULL_FACE);
381  glFrontFace(GL_CW);
382 
383  // Draw primary rays
384  drawRays(gl, m_rayColor);
385 
386  // Obsolete visualization, boxes hide each other
387  // Draw back faces of bounding boxes - for correct depth
388  /*glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
389  //glCullFace(GL_FRONT);
390  drawNodes(gl, true);
391  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
392 
393  // Draw front faces of bounding boxes - for blending
394  glDisable(GL_DEPTH_TEST);
395  glDepthFunc(GL_LEQUAL);
396  glCullFace(GL_BACK);
397  drawNodes(gl, false);*/
398 
399  // New Visualization, all rays are visible
400  // Render boxes and primitives without culling so everything is visible
401  glDisable(GL_DEPTH_TEST);
402  glDisable(GL_CULL_FACE);
403 
404  // Draw boxes
405  drawNodes(gl, false);
406 
407  // Draw primitives
408  drawPrimitives(gl);
409 
410  //glDisable(GL_DEPTH_TEST);
411  glPopAttrib();
412  gl->setVGXform(oldXform);
413 
414  // Draw path information
415  drawPathInfo(gl);
416 }
417 
418 //------------------------------------------------------------------------
419 
420 void VisualizationKDTree::getFromIndex(S32 idx)
421 {
422  if(idx < 0 || idx > m_nodeStack.getSize()-1)
423  return;
424 
425  if(m_nodeStack[idx].addr >= 0)
426  {
427  splitNode(m_nodeStack[idx], m_left.addr, m_right.addr, m_left.box, m_right.box, m_nodeSplit);
428  }
429  else
430  {
431  m_left.addr = NO_NODE;
432  m_right.addr = NO_NODE;
433  }
434 
435  if(idx > 0) // Node is not the root, we can find its sibling
436  {
437  NodeData parent = m_nodeStack[idx-1];
438  NodeData left, right;
439 
440  splitNode(parent, left.addr, right.addr, left.box, right.box, m_nodeSplit);
441 
442  if(left.addr == m_nodeStack[idx].addr) // Left child is the current node
443  {
444  m_node = left;
445  m_sibling = right;
446  }
447  else // Right child is the current node
448  {
449  m_node = right;
450  m_sibling = left;
451  }
452  }
453  else // Node is the root, we need to compute the box and disable sibling
454  {
455  m_node.addr = m_nodeStack[idx].addr;
456  m_node.box = m_left.box + m_right.box;
457  m_sibling.addr = NO_NODE;
458  }
459 
460  //growParentBox();
461  // Set color mapping for visible nodes
462  setColorMapping();
463 }
464 
465 //------------------------------------------------------------------------
466 
467 void VisualizationKDTree::growParentBox()
468 {
469  float incrTop = (m_node.box.max() - m_node.box.min()).length() / 50.0f;
470  //float incrBottom = incrTop / 2.0f;
471  m_node.box.grow(m_node.box.min()-incrTop/*-0.01f*/); // Grow the parent box to avoid z-fighting
472  m_node.box.grow(m_node.box.max()+incrTop/*+0.01f*/); // Grow the parent box to avoid z-fighting
473 
474  if(m_sibling.addr != NO_NODE) // Root node has no sibling
475  {
476  m_sibling.box.grow(m_sibling.box.min()-incrTop/*+0.01f*/); // Grow the sibling box to avoid z-fighting
477  m_sibling.box.grow(m_sibling.box.max()+incrTop/*-0.01f*/); // Grow the sibling box to avoid z-fighting
478  }
479 }
480 
481 //------------------------------------------------------------------------
482 
483 void VisualizationKDTree::drawNodes(GLContext* gl, bool onlyChildren)
484 {
485  // Draw children of the current node
486  if(m_showChildren)
487  {
488  drawBox(gl, m_left, m_leftColor);
489  drawBox(gl, m_right, m_rightColor);
490  }
491 
492  // Draw current node and its sibling
493  if(!onlyChildren)
494  {
495  drawBox(gl, m_node, m_nodeColor);
496  drawBox(gl, m_sibling, m_siblingColor);
497  }
498 
499  // Draw visible child of the OSAH split
501  {
502  if(!onlyChildren)
503  {
504  // Draw filled faces
505  if(m_showEmpty)
506  gl->drawColorBuffer(m_emptyBoxes, m_emptyColors, GL_QUADS, 0);
507  //glDepthFunc(GL_ALWAYS);
508 
509  // Draw edges, use opaque ray color
510  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
511  if(m_showAllOSAH)
512  gl->drawBuffer(m_boxes, GL_QUADS, 0, COLOR_RAY);
513  if(m_showEmpty)
515  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
516  //glDepthFunc(GL_LEQUAL);
517  }
518  }
519 }
520 
521 //------------------------------------------------------------------------
522 
523 void VisualizationKDTree::drawBox(GLContext* gl, const NodeData &node, U32 abgr)
524 {
525  if(node.addr != NO_NODE)
526  {
527  // Draw filled faces
528  gl->drawBox(node.box.min(), node.box.max(), abgr);
529  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
530  // Draw edges, use the same color but opaque
531  gl->drawBox(node.box.min(), node.box.max(), abgr | 0xFF000000);
532  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
533  }
534 }
535 
536 //------------------------------------------------------------------------
537 
538 void VisualizationKDTree::drawRays(GLContext* gl, U32 abgr)
539 {
540  if(m_showRays)
541  {
542  glLineWidth(2.0f);
543  gl->drawBuffer(m_rays, GL_LINES, 0, abgr);
544  glLineWidth(1.0f);
545  }
546 }
547 
548 //------------------------------------------------------------------------
549 
550 void VisualizationKDTree::drawPrimitives(GLContext* gl)
551 {
552  if(m_showCurrTris)
553  {
554  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
555  gl->drawBuffer(m_invisTris, GL_TRIANGLES, 0, COLOR_TRI_INVIS);
556  gl->drawBuffer(m_visTris, GL_TRIANGLES, 0, COLOR_TRI_VIS);
557  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
558  }
559 }
560 
561 //------------------------------------------------------------------------
562 
563 void VisualizationKDTree::drawPathInfo(GLContext* gl)
564 {
565  S32 fontSize = 16;
566  Vec2f origin = Vec2f(8.0f, (F32)gl->getViewSize().y - 4.0f);
567  Vec2f pos = origin;
568 
569  Mat4f oldXform = gl->setVGXform(gl->xformMatchPixels());
570  gl->setFont("Arial", fontSize, GLContext::FontStyle_Bold);
571 
572  char leftBox[100], rightBox[100];
573  memset(leftBox, '\0', 100);
574  memset(rightBox, '\0', 100);
575  //m_left.box.min().sprint(leftBox, 100);
576  strcat_s(leftBox, ", ");
577  //m_left.box.max().sprint(leftBox + strlen(leftBox), 100-strlen(leftBox));
578  //m_right.box.min().sprint(rightBox, 100);
579  strcat_s(rightBox, ", ");
580  //m_right.box.max().sprint(rightBox + strlen(rightBox), 100-strlen(rightBox));
581 
582  if(m_showCurrTris)
583  {
584  gl->drawLabel(sprintf("Left count: %u Right count: %u",
585  m_leftPrims, m_rightPrims), pos, Vec2f(0.0f, 1.0f), 0xFFFFFFFF);
586  pos.y -= (F32)fontSize;
587  gl->drawLabel(sprintf("Left area: %.2f (%s) Right area: %.2f (%s)",
588  m_left.box.area(), leftBox, m_right.box.area(), rightBox), pos, Vec2f(0.0f, 1.0f), 0xFFFFFFFF);
589  }
590  else
591  {
592  gl->drawLabel(sprintf("Left area: %.2f (%s) Right area: %.2f (%s)",
593  m_left.box.area(), leftBox, m_right.box.area(), rightBox), pos, Vec2f(0.0f, 1.0f), 0xFFFFFFFF);
594  }
595  pos.y -= (F32)fontSize;
596  gl->drawLabel(sprintf("Current depth: %d Path depth: %d",
597  m_currentDepth, m_nodeStack.getSize()-1), pos, Vec2f(0.0f, 1.0f), 0xFFFFFFFF);
598  pos.y -= (F32)fontSize;
599 
600  const float rightMargin = 100.0f;
601  String header("Split path: ");
602  gl->drawLabel(header, pos, Vec2f(0.0f, 1.0f), 0xFFFFFFFF);
603  pos.x += gl->getStringSize(header).x;
604 
605  // Write path before the current node
606  for(S32 i = 0; i < m_currentDepth; i++)
607  {
608  if(pos.x > (F32)gl->getViewSize().x - rightMargin)
609  {
610  pos.x = origin.x;
611  pos.y -= (F32)fontSize;
612  }
613 
614  String cur = m_splitPath[i] + "| ";
615  gl->drawLabel(cur, pos, Vec2f(0.0f, 1.0f), 0xFFFFFFFF);
616  pos.x += gl->getStringSize(cur).x;
617  }
618 
619  // Write the current node
620  if(pos.x > (F32)gl->getViewSize().x - rightMargin)
621  {
622  pos.x = origin.x;
623  pos.y -= (F32)fontSize;
624  }
625  gl->drawLabel(m_splitPath[m_currentDepth], pos, Vec2f(0.0f, 1.0f), 0xFF0000FF);
626  pos.x += gl->getStringSize(m_splitPath[m_currentDepth]).x;
627 
628  // Write path after the current node
629  for(S32 i = m_currentDepth+1; i < m_splitPath.getSize(); i++)
630  {
631  if(pos.x > (F32)gl->getViewSize().x - rightMargin)
632  {
633  pos.x = origin.x;
634  pos.y -= (F32)fontSize;
635  }
636 
637  String cur = String("| ") + m_splitPath[i];
638  gl->drawLabel(cur, pos, Vec2f(0.0f, 1.0f), 0xFFFFFFFF);
639  pos.x += gl->getStringSize(cur).x;
640  }
641 
642  gl->setVGXform(oldXform);
643  gl->setDefaultFont();
644 }
645 
646 //-----------------------------------------------------------------------
647 
648 void VisualizationKDTree::setColorMapping()
649 {
650  if(!m_splitColors)
651  {
654  return;
655  }
656 
657  //if(m_nodeSplit.getType() == SplitInfo::SAH)
658  //{
659  // m_leftColor = COLOR_LEFT_SAH;
660  // m_rightColor = COLOR_RIGHT_SAH;
661  //}
662  //else if(m_nodeSplit.getType() == SplitInfo::SBVH)
663  //{
664  // m_leftColor = COLOR_LEFT_SVBH;
665  // m_rightColor = COLOR_RIGHT_SVBH;
666  //}
667  //else
668  //{
669  // m_leftColor = COLOR_LEFT_OSAH;
670  // m_rightColor = COLOR_RIGHT_OSAH;
671  //}
672 }
673 
674 //-----------------------------------------------------------------------
675 
676 void VisualizationKDTree::prepareTreeData(NodeData node)
677 {
678  NodeData stack[100];
679  int stackIndex = 1;
680  Array<Vec4f> boxes;
681  Array<Vec4f> verticesInvis;
682  Array<Vec4f> verticesVis;
683  Array<S32> indices;
684  U32 prims = 0;
685  S32 rightChild = 0;
686 
687  // Clear the osah split counts in current node
688  memset(m_osahSplits, 0, sizeof(m_osahSplits));
689 
690  while(stackIndex > 0)
691  {
692  for(;;)
693  {
694  if(node.addr < 0)
695  {
696  //if(node.addr == KDTREE_EMPTYLEAF)
697  // break;
698 
699  if(m_showCurrTris) // Process triangle
700  {
701  indices.clear();
702 
703  S32 idx = ~node.addr;
704  if (~idx != KDTREE_EMPTYLEAF)
705  {
706  while (((int*)m_kdtree->getTriIndexBuffer().getPtr())[idx] != KDTREE_EMPTYLEAF)
707  {
708  indices.add(((int*)m_kdtree->getTriIndexBuffer().getPtr())[idx]);
709  idx++;
710  }
711  }
712  //m_bvh->getTriangleIndices(node, indices);
713  prims += indices.getSize();
714 
715  for(int i = 0; i < indices.getSize(); i++)
716  {
717  Array<Vec4f> *ptr = &verticesInvis;
718  if(m_visibility[indices[i]])
719  ptr = &verticesVis;
720 
721  const Vec3i& ind = ((const Vec3i*)m_scene->getTriVtxIndexBuffer().getPtr())[indices[i]];
722  for(int j = 0; j < 3; j++)
723  {
724  const Vec3f& v = ((const Vec3f*)m_scene->getVtxPosBuffer().getPtr())[ind[j]];
725 
726  ptr->add(Vec4f(v, 1.0f));
727  }
728  }
729  }
730 
731  break;
732  }
733  else
734  {
735  AABB child0, child1;
736  S32 child0Addr, child1Addr;
737  SplitInfo splitInfo;
738 
739  splitNode(node, child0Addr, child1Addr, child0, child1, m_nodeSplit);
740  if(m_showCurrTris && rightChild == 0)
741  rightChild = child1Addr;
742 
743  if(true)/*m_showAllOSAH && splitInfo.getOSAHChosen()) */// Process split
744  {
745  //m_osahSplits[splitInfo.getAxis()]++;
746  // Compute the box
747  //AABB bbox = child0 + child1;
748  //AABB bbox = child0; // child with more visible triangles in case of OSAH split
749  //addBoxQuads(bbox, boxes);
750  addBoxQuads(child0, boxes);
751  addBoxQuads(child1, boxes);
752  }
753 
754  node.addr = child0Addr;
755  stack[stackIndex++].addr = child1Addr;
756  }
757  }
758  stackIndex--;
759  node = stack[stackIndex];
760  if(m_showCurrTris && node.addr == rightChild && stackIndex == 1)
761  {
762  m_leftPrims = prims;
763  prims = 0;
764  }
765  }
766 
767  if(m_showAllOSAH)
768  {
770  m_boxes.set(boxes.getPtr(), boxes.getNumBytes());
771  }
772 
773  if(m_showCurrTris)
774  {
775  m_rightPrims = prims;
776  m_invisTris.resizeDiscard(verticesInvis.getNumBytes());
777  m_invisTris.set(verticesInvis.getPtr(), verticesInvis.getNumBytes());
778  m_visTris.resizeDiscard(verticesVis.getNumBytes());
779  m_visTris.set(verticesVis.getPtr(), verticesVis.getNumBytes());
780  }
781 }
782 
783 //-----------------------------------------------------------------------
784 
785 void VisualizationKDTree::addBoxQuads(const AABB &box, Array<Vec4f> &buffer)
786 {
787  Vec3f min = box.min();
788  Vec3f max = box.max();
789  // Add buffer as 4 quads
790  // Min x
791  buffer.add(Vec4f(min.x, min.y, min.z, 1.0f));
792  buffer.add(Vec4f(min.x, max.y, min.z, 1.0f));
793  buffer.add(Vec4f(min.x, max.y, max.z, 1.0f));
794  buffer.add(Vec4f(min.x, min.y, max.z, 1.0f));
795  // Max
796  buffer.add(Vec4f(max.x, max.y, max.z, 1.0f));
797  buffer.add(Vec4f(max.x, max.y, min.z, 1.0f));
798  buffer.add(Vec4f(max.x, min.y, min.z, 1.0f));
799  buffer.add(Vec4f(max.x, min.y, max.z, 1.0f));
800  // Min y
801  buffer.add(Vec4f(min.x, min.y, min.z, 1.0f));
802  buffer.add(Vec4f(min.x, min.y, max.z, 1.0f));
803  buffer.add(Vec4f(max.x, min.y, max.z, 1.0f));
804  buffer.add(Vec4f(max.x, min.y, min.z, 1.0f));
805  // Max y
806  buffer.add(Vec4f(max.x, max.y, max.z, 1.0f));
807  buffer.add(Vec4f(min.x, max.y, max.z, 1.0f));
808  buffer.add(Vec4f(min.x, max.y, min.z, 1.0f));
809  buffer.add(Vec4f(max.x, max.y, min.z, 1.0f));
810  // Min z
811  buffer.add(Vec4f(min.x, min.y, min.z, 1.0f));
812  buffer.add(Vec4f(max.x, min.y, min.z, 1.0f));
813  buffer.add(Vec4f(max.x, max.y, min.z, 1.0f));
814  buffer.add(Vec4f(min.x, max.y, min.z, 1.0f));
815  // Max z
816  buffer.add(Vec4f(max.x, max.y, max.z, 1.0f));
817  buffer.add(Vec4f(max.x, min.y, max.z, 1.0f));
818  buffer.add(Vec4f(min.x, min.y, max.z, 1.0f));
819  buffer.add(Vec4f(min.x, max.y, max.z, 1.0f));
820 }
821 
822 //------------------------------------------------------------------------
823 
824 void VisualizationKDTree::splitNode(const NodeData& currNode, S32& leftAdd, S32& rightAdd, AABB& leftBox, AABB& rightBox, SplitInfo& split)
825 {
826  leftAdd = ((Vec4i*)m_kdtree->getNodeBuffer().getPtr())[currNode.addr].x;
827  rightAdd = ((Vec4i*)m_kdtree->getNodeBuffer().getPtr())[currNode.addr].y;
828 
829  float splitPos = *(float*)&(((Vec4i*)m_kdtree->getNodeBuffer().getPtr())[currNode.addr].z);
830  unsigned int type = ((Vec4i*)m_kdtree->getNodeBuffer().getPtr())[currNode.addr].w & KDTREE_MASK;
831  S32 dim = type >> KDTREE_DIMPOS;
832 
833  Vec3f leftCut = currNode.box.max();
834  leftCut[dim] = splitPos;
835 
836  Vec3f rightCut = currNode.box.min();
837  rightCut[dim] = splitPos;
838 
839  leftBox = AABB(currNode.box.min(), leftCut);
840  rightBox = AABB(rightCut, currNode.box.max());
841 
842  split.dim = dim;
843  split.pos = splitPos;
844 }
#define FW_KEY_L
Definition: Keys.hpp:204
~VisualizationKDTree(void)
Destructor.
Class for the visualization.
FW_CUDA_FUNC T length(const VectorBase< T, L, S > &v)
Definition: Math.hpp:459
S32 getSize() const
Gets size of the buffer (number of rays).
Definition: RayBuffer.hpp:52
#define NULL
Definition: Defs.hpp:39
void set(const void *ptr)
Definition: Buffer.hpp:92
VisualizationKDTree(CudaKDTree *kdtree, Scene *scene, const Array< AABB > &emptyBoxes, const RayBuffer *rays=NULL, Buffer *visibility=NULL)
Constructor.
Buffer & getTriVtxIndexBuffer(void)
Returns buffer of triangle's vertex indieces.
Definition: Scene.hpp:75
Buffer & getTriIndexBuffer(void)
Returns triangle index buffer.
Definition: CudaKDTree.hpp:58
void draw(GLContext *gl, CameraControls &camera)
The method used to draw the current state of visualization to the OpenGL context. ...
S32 m_currentDepth
Current node's depth information.
Buffer m_emptyLineColors
Buffer holding line colors of empty boxes as quad primitives.
Mat4f setVGXform(const Mat4f &m)
Definition: GLContext.hpp:171
void setDefaultFont(void)
Definition: GLContext.hpp:188
void moveToSibling()
Sets the node to be visualized to be the sibling of the currently visualized node.
#define COLOR_LEFT
U32 m_nodeColor
Color of the current node.
FW_CUDA_FUNC const Vec3f & max(void) const
Definition: Util.hpp:49
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer
Definition: DLLImports.inl:315
FW_CUDA_FUNC T max(void) const
Definition: Math.hpp:147
bool m_showEmpty
Flag whether to show empty nodes.
Cuda friendly KDTree representation.
Definition: CudaKDTree.hpp:20
void moveToRight()
Sets the node to be visualized to be the right child of the currently visualized node.
#define COLOR_RAY
S32 m_osahSplits[3]
Counters of the number of OSAH splits in the subtree under the set node in the x, y and z dimensions...
void ** ptr
Definition: DLLImports.cpp:74
Buffer m_rays
Buffer holding some rays as line segments.
Buffer & getVtxPosBuffer(void)
Returns vertex position buffer.
Definition: Scene.hpp:103
Vec2i drawLabel(const String &str, const Vec4f &pos, const Vec2f &align, U32 fgABGR, U32 bgABGR)
Definition: GLContext.cpp:704
FW_CUDA_FUNC bool hit(void) const
Definition: Util.hpp:80
#define FW_KEY_J
Definition: Keys.hpp:202
U32 m_leftColor
Color of the left child of the current node.
#define KDTREE_DIMPOS
Buffer m_emptyBoxes
Buffer holding empty boxes as quad primitives.
#define COLOR_SIBLING
Definition: Util.hpp:62
S64 getSize(void) const
Definition: Buffer.hpp:69
#define COLOR_NODE
void clear(void)
Definition: Array.hpp:359
void drawBuffer(Buffer &buffer, GLenum mode, int offset, U32 abgr)
Definition: GLContext.cpp:479
Vec2i getStringSize(const String &str)
Definition: GLContext.cpp:674
Mat4f getWorldToClip(void) const
const Ray & getRayForSlot(S32 slot) const
Gets a ray assigned to a given slot.
Definition: RayBuffer.hpp:89
const U8 * getPtr(S64 ofs=0)
Definition: Buffer.hpp:106
S32 getNumBytes(void) const
#define KDTREE_EMPTYLEAF
void drawColorBuffer(Buffer &buffer, Buffer &color, GLenum mode, int offset)
Definition: GLContext.cpp:558
bool m_splitColors
Flag whether to map left/right children colors based on the split type.
Mat4f xformFitToView(const Vec2f &pos, const Vec2f &size) const
Definition: GLContext.hpp:151
bool m_showAllOSAH
Flag whether to show all OSAH split nodes.
Vec3f origin
Definition: Util.hpp:67
void moveUp()
Sets the node to be visualized to be the predecesor of the currently visualized node on the set path...
void reset(S size=0)
Definition: Array.hpp:317
float F32
Definition: Defs.hpp:89
const T & getLast(void) const
#define NO_NODE
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v
Definition: DLLImports.inl:329
Buffer m_visTris
Buffer holding invisible selected triangles.
#define FW_KEY_I
Definition: Keys.hpp:201
Ray buffer class. Stores rays.
Definition: RayBuffer.hpp:38
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
Definition: Math.hpp:461
Vec3f direction
Definition: Util.hpp:69
FW_CUDA_FUNC T max(const VectorBase< T, L, S > &v)
Definition: Math.hpp:462
void setFont(const String &name, int size, U32 style)
Definition: GLContext.cpp:645
int getNumTriangles(void) const
Definition: Scene.hpp:61
float tmax
Definition: Util.hpp:70
#define FW_ASSERT(X)
Definition: Defs.hpp:67
#define FW_KEY_B
Definition: Keys.hpp:194
signed int S32
Definition: Defs.hpp:88
#define FW_KEY_H
Definition: Keys.hpp:200
Definitions for the BVH visualization framework.
S32 padA
Definition: Util.hpp:85
U32 m_rayColor
Color of the ray line indices.
#define COLOR_TRI_VIS
Array< String > m_splitPath
Text representation of the VisualizationBVH::m_nodeStack path.
virtual bool handleEvent(const Window::Event &ev)
Handles visualization events - key commands influencing the output.
Mat4f xformMatchPixels(void) const
Definition: GLContext.hpp:152
T & add(void)
Definition: Array.hpp:384
FW_CUDA_FUNC const Vec3f & min(void) const
Definition: Util.hpp:48
String sprintf(const char *fmt,...)
Definition: Defs.cpp:241
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int dim
Definition: DLLImports.inl:74
bool isVisible() const
Return whether the visualization renders its output.
unsigned int U32
Definition: Defs.hpp:85
#define FW_KEY_Y
Definition: Keys.hpp:217
#define FW_KEY_O
Definition: Keys.hpp:207
#define FW_KEY_U
Definition: Keys.hpp:213
Class holding information about a split of a BVH node.
Definition: BVHNode.hpp:58
Class holding 3d scene.
Definition: Scene.hpp:44
bool m_showRays
Flag whether to show the ray segments.
Buffer m_emptyColors
Buffer holding colors of empty boxes as quad primitives.
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z GLuint GLint GLenum GLboolean GLsizei stride
Definition: DLLImports.inl:365
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction f
Definition: DLLImports.inl:88
#define FW_KEY_T
Definition: Keys.hpp:212
U32 m_rightPrims
Number of primitives in the right child of the current node.
const RayResult & getResultForSlot(S32 slot) const
Gets a ray result assigned to a given slot.
Definition: RayBuffer.hpp:103
Buffer & getNodeBuffer(void)
Returns node buffer.
Definition: CudaKDTree.hpp:52
bool m_showChildren
Flag whether to show children of the current node.
#define COLOR_TRI_INVIS
void drawBox(const Vec3f &min, const Vec3f &max, U32 abgr)
Definition: GLContext.cpp:383
EventType type
Definition: Window.hpp:69
Buffer m_boxes
Buffer holding selected boxes as quad primitives.
void moveToLeft()
Sets the node to be visualized to be the left child of the currently visualized node.
T set(S idx, const T &item)
Definition: Array.hpp:248
U32 m_rightColor
Color of the right child of the current node.
void moveDown()
Sets the node to be visualized to be the succesor of the currently visualized node on the set path...
const Vec2i & getViewSize(void) const
Definition: GLContext.hpp:148
#define FW_KEY_K
Definition: Keys.hpp:203
#define FW_KEY_G
Definition: Keys.hpp:199
void moveToParent()
Sets the node to be visualized to be the parent of the currently visualized node. ...
bool m_showCurrTris
Flag whether to show triangles of the current node.};.
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type
Definition: DLLImports.inl:323
#define KDTREE_MASK
const T * getPtr(S32idx=0) const
U32 m_siblingColor
Color of the sibling of the current node.
void resizeDiscard(S64 size)
Definition: Buffer.hpp:83
#define COLOR_RIGHT
const AABB & getBBox(void) const
Returns bounding box of the CudaKDTree's source scene.
Definition: CudaKDTree.hpp:77
U32 m_leftPrims
Number of primitives in the left child of the current node.
void resize(S size)
Definition: Array.hpp:366
Array< S32 > m_visibility
Visibility of individual triangles.
S32 getSize(void) const
FW_CUDA_FUNC T min(void) const
Definition: Math.hpp:146
Buffer m_invisTris
Buffer holding visible selected triangles.
#define FW_KEY_P
Definition: Keys.hpp:208