aboutsummaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/docs/html/classmingfx_1_1_b_v_h.html
blob: 032d12845c9b8b40df956ed69b85d714e568150b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>MinGfx Toolkit: mingfx::BVH Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">MinGfx Toolkit
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacemingfx.html">mingfx</a></li><li class="navelem"><a class="el" href="classmingfx_1_1_b_v_h.html">BVH</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classmingfx_1_1_b_v_h-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">mingfx::BVH Class Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A Bounding Volume Hierarchy (<a class="el" href="classmingfx_1_1_b_v_h.html" title="A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...">BVH</a>) data structure that can be used to accelerate ray-object intersection tests by carving up space into a hierarchy of partitions represented in a tree. </p>
<p>Each node of the tree is represented as an <a class="el" href="classmingfx_1_1_a_a_b_b.html" title="A 3D axis-aligned bounding box defined by two corners (min and max).">AABB</a> (Axis-Aligned Bounding Box) that contains all of the nodes under it. Different objects can be stored inside each bounding box. For example, when a <a class="el" href="classmingfx_1_1_b_v_h.html" title="A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...">BVH</a> is created for a mesh, each leaf node can contain a <a class="el" href="classmingfx_1_1_a_a_b_b.html" title="A 3D axis-aligned bounding box defined by two corners (min and max).">AABB</a> that contains just a single triangle. Or, when a <a class="el" href="classmingfx_1_1_b_v_h.html" title="A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...">BVH</a> is created for an entire scene, you could have each leaf node contain an entire mesh or other object within the scene. In each case, use <a class="el" href="classmingfx_1_1_a_a_b_b.html" title="A 3D axis-aligned bounding box defined by two corners (min and max).">AABB</a>'s set_user_data() and user_data() methods to store a handle for whetever you want to store inside the nodes. </p>

<p class="definition">Definition at line <a class="el" href="bvh_8h_source.html#l00040">40</a> of file <a class="el" href="bvh_8h_source.html">bvh.h</a>.</p>
</div>
<p><code>#include &lt;<a class="el" href="bvh_8h_source.html">bvh.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:af812656193d247be31dd038a8e2fff75"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_b_v_h.html#af812656193d247be31dd038a8e2fff75">BVH</a> ()</td></tr>
<tr class="memdesc:af812656193d247be31dd038a8e2fff75"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the class with an empty hierarchy.  <a href="classmingfx_1_1_b_v_h.html#af812656193d247be31dd038a8e2fff75">More...</a><br /></td></tr>
<tr class="separator:af812656193d247be31dd038a8e2fff75"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af81906830adcf4648cc8cf4e214b4269"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_b_v_h.html#af81906830adcf4648cc8cf4e214b4269">~BVH</a> ()</td></tr>
<tr class="separator:af81906830adcf4648cc8cf4e214b4269"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8ed3e91ecd2a0585a0dbac605d6f2c71"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_b_v_h.html#a8ed3e91ecd2a0585a0dbac605d6f2c71">CreateFromMesh</a> (const <a class="el" href="classmingfx_1_1_mesh.html">Mesh</a> &amp;mesh)</td></tr>
<tr class="memdesc:a8ed3e91ecd2a0585a0dbac605d6f2c71"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a bounding volume hierarchy where each leaf node contains a single triangle from the mesh.  <a href="classmingfx_1_1_b_v_h.html#a8ed3e91ecd2a0585a0dbac605d6f2c71">More...</a><br /></td></tr>
<tr class="separator:a8ed3e91ecd2a0585a0dbac605d6f2c71"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a964420ca931fa93c420f0820e1b95942"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_b_v_h.html#a964420ca931fa93c420f0820e1b95942">CreateFromListOfBoxes</a> (const std::vector&lt; <a class="el" href="classmingfx_1_1_a_a_b_b.html">AABB</a> &gt; &amp;boxes)</td></tr>
<tr class="memdesc:a964420ca931fa93c420f0820e1b95942"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a <a class="el" href="classmingfx_1_1_b_v_h.html" title="A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...">BVH</a> where each leaf node contains one of the boxes passed in to the function.  <a href="classmingfx_1_1_b_v_h.html#a964420ca931fa93c420f0820e1b95942">More...</a><br /></td></tr>
<tr class="separator:a964420ca931fa93c420f0820e1b95942"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afad54f50a29e8b3aace6cdec5c792c56"><td class="memItemLeft" align="right" valign="top">std::vector&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_b_v_h.html#afad54f50a29e8b3aace6cdec5c792c56">IntersectAndReturnUserData</a> (const <a class="el" href="classmingfx_1_1_ray.html">Ray</a> &amp;r) const</td></tr>
<tr class="memdesc:afad54f50a29e8b3aace6cdec5c792c56"><td class="mdescLeft">&#160;</td><td class="mdescRight">Traverse the <a class="el" href="classmingfx_1_1_b_v_h.html" title="A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...">BVH</a> to find leaf nodes whose AABBs are intersected by the ray.  <a href="classmingfx_1_1_b_v_h.html#afad54f50a29e8b3aace6cdec5c792c56">More...</a><br /></td></tr>
<tr class="separator:afad54f50a29e8b3aace6cdec5c792c56"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="af812656193d247be31dd038a8e2fff75"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af812656193d247be31dd038a8e2fff75">&#9670;&nbsp;</a></span>BVH()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">mingfx::BVH::BVH </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes the class with an empty hierarchy. </p>

</div>
</div>
<a id="af81906830adcf4648cc8cf4e214b4269"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af81906830adcf4648cc8cf4e214b4269">&#9670;&nbsp;</a></span>~BVH()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual mingfx::BVH::~BVH </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a964420ca931fa93c420f0820e1b95942"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a964420ca931fa93c420f0820e1b95942">&#9670;&nbsp;</a></span>CreateFromListOfBoxes()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::BVH::CreateFromListOfBoxes </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; <a class="el" href="classmingfx_1_1_a_a_b_b.html">AABB</a> &gt; &amp;&#160;</td>
          <td class="paramname"><em>boxes</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Creates a <a class="el" href="classmingfx_1_1_b_v_h.html" title="A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...">BVH</a> where each leaf node contains one of the boxes passed in to the function. </p>

</div>
</div>
<a id="a8ed3e91ecd2a0585a0dbac605d6f2c71"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8ed3e91ecd2a0585a0dbac605d6f2c71">&#9670;&nbsp;</a></span>CreateFromMesh()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::BVH::CreateFromMesh </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_mesh.html">Mesh</a> &amp;&#160;</td>
          <td class="paramname"><em>mesh</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Creates a bounding volume hierarchy where each leaf node contains a single triangle from the mesh. </p>
<p>For leaf nodes, the triangle index can be retrieved with: </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> tri_id = leafnode-&gt;box.user_data();</div>
</div><!-- fragment --><p> The user_data will be -1 for non-leaf nodes. Once the structure has been created, it can be used to perform fast ray-mesh intersection tests. See <a class="el" href="classmingfx_1_1_ray.html#ac90097090f0f8f49db13f6f232712afc" title="Checks to see if the ray intersects a triangle mesh.">Ray::FastIntersectMesh()</a>. </p>

</div>
</div>
<a id="afad54f50a29e8b3aace6cdec5c792c56"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afad54f50a29e8b3aace6cdec5c792c56">&#9670;&nbsp;</a></span>IntersectAndReturnUserData()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::vector&lt;int&gt; mingfx::BVH::IntersectAndReturnUserData </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_ray.html">Ray</a> &amp;&#160;</td>
          <td class="paramname"><em>r</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Traverse the <a class="el" href="classmingfx_1_1_b_v_h.html" title="A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...">BVH</a> to find leaf nodes whose AABBs are intersected by the ray. </p>
<p>These are candidates to test more thoroughly using whatever ray-object intersection test is appropriate for the objects stored inside the <a class="el" href="classmingfx_1_1_a_a_b_b.html" title="A 3D axis-aligned bounding box defined by two corners (min and max).">AABB</a>. This routine returns the user_data for each <a class="el" href="classmingfx_1_1_a_a_b_b.html" title="A 3D axis-aligned bounding box defined by two corners (min and max).">AABB</a> leaf node. In the case of a <a class="el" href="classmingfx_1_1_b_v_h.html" title="A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...">BVH</a> created using CreateFromMesh, this means it stores the indices to the mesh triangles that should be tested for ray-triangle intersection. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>src/<a class="el" href="bvh_8h_source.html">bvh.h</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.9.1
</small></address>
</body>
</html>