NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
VisualizationBVH.hpp
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  * Marek Vinkler
29  *
30  */
31 
36 #pragma once
37 #include "Visualization.hpp"
38 
39 namespace FW
40 {
41 //------------------------------------------------------------------------
42 
48 {
49 public:
57  explicit VisualizationBVH (CudaBVH* bvh, Scene* scene, const Array<AABB> &emptyBoxes, const RayBuffer* rays = NULL, Buffer* visibility = NULL);
61  ~VisualizationBVH (void);
62 
68  virtual bool handleEvent (const Window::Event& ev); // must be before the listener that queries things
69 
73  void moveToParent ();
77  void moveToSibling ();
81  void moveToLeft ();
85  void moveToRight ();
90  void moveUp ();
95  void moveDown ();
96 
102  void draw (GLContext* gl, CameraControls& camera);
103 
104 private:
108  struct NodeData
109  {
110  S32 addr;
111  AABB box;
112 
116  NodeData(void) : addr(0) {}
117  };
118 
123  void getFromIndex (S32 idx);
127  void growParentBox ();
133  void drawNodes (GLContext* gl, bool onlyChildren);
140  void drawBox (GLContext* gl, const NodeData &node, U32 abgr);
146  void drawRays (GLContext* gl, U32 abgr);
151  void drawPrimitives (GLContext* gl);
155  void drawPathInfo (GLContext* gl);
159  void setColorMapping ();
164  void prepareTreeData (S32 node);
170  void addBoxQuads (const AABB &box, Array<Vec4f> &buffer);
171 
172 private:
173  // Global and path data
174  CudaBVH* m_bvh;
175  Array<S32> m_nodeStack;
176  // Currently visible node data
177  NodeData m_node;
178  SplitInfo m_nodeSplit;
179  NodeData m_sibling;
180  NodeData m_left;
181  NodeData m_right;
182 };
183 
184 //------------------------------------------------------------------------
185 }
Class for the visualization.
#define NULL
Definition: Defs.hpp:39
Cuda BVH class.
Definition: CudaBVH.hpp:93
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
void draw(GLContext *gl, CameraControls &camera)
The method used to draw the current state of visualization to the OpenGL context. ...
void moveDown()
Sets the node to be visualized to be the succesor of the currently visualized node on the set path...
void moveUp()
Sets the node to be visualized to be the predecesor of the currently visualized node on the set path...
void moveToRight()
Sets the node to be visualized to be the right child of the currently visualized node.
Visualisation framework abstract class above BVH/KDTree visualisations.
void moveToLeft()
Sets the node to be visualized to be the left child of the currently visualized node.
void moveToSibling()
Sets the node to be visualized to be the sibling of the currently visualized node.
Ray buffer class. Stores rays.
Definition: RayBuffer.hpp:38
signed int S32
Definition: Defs.hpp:88
void moveToParent()
Sets the node to be visualized to be the parent of the currently visualized node. ...
VisualizationBVH(CudaBVH *bvh, Scene *scene, const Array< AABB > &emptyBoxes, const RayBuffer *rays=NULL, Buffer *visibility=NULL)
Constructor.
unsigned int U32
Definition: Defs.hpp:85
Class holding information about a split of a BVH node.
Definition: BVHNode.hpp:58
Class holding 3d scene.
Definition: Scene.hpp:44
virtual bool handleEvent(const Window::Event &ev)
Handles visualization events - key commands influencing the output.
Class for the BVH visualization.
~VisualizationBVH(void)
Destructor.