~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/eltopo/eltopo3d/broadphase_blenderbvh.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#if 0
2
 
// ---------------------------------------------------------
3
 
//
4
 
//  broadphase_blenderbvh.h
5
 
//  Joseph Eagar 2011
6
 
//  
7
 
//  Broad phase collision detection culling using a K-DOP bvh structure
8
 
//
9
 
// ---------------------------------------------------------
10
 
 
11
 
#ifndef BROADPHASEGRID_H
12
 
#define BROADPHASEGRID_H
13
 
 
14
 
// ---------------------------------------------------------
15
 
// Nested includes
16
 
// ---------------------------------------------------------
17
 
 
18
 
#include <broadphase.h>
19
 
#include "../../../source/blender/blenlib/BLI_kdopbvh.h"
20
 
 
21
 
// ---------------------------------------------------------
22
 
//  Forwards and typedefs
23
 
// ---------------------------------------------------------
24
 
 
25
 
class DynamicSurface;
26
 
 
27
 
// ---------------------------------------------------------
28
 
//  Interface declarations
29
 
// ---------------------------------------------------------
30
 
 
31
 
// --------------------------------------------------------
32
 
///
33
 
/// Broad phase collision detector using three regular grids: one grid each for vertices, edges and triangles.
34
 
///
35
 
// --------------------------------------------------------
36
 
 
37
 
class BroadPhaseBVH : public BroadPhase
38
 
{
39
 
private:
40
 
        BVHTree *v_bvhtree;
41
 
        BVHTree *e_bvhtree;
42
 
        BVHTree *t_bvhtree;
43
 
 
44
 
public:
45
 
   
46
 
        BroadPhaseBVH() {
47
 
                m_bvhtree = NULL;
48
 
        }
49
 
  
50
 
   ~BroadPhaseGrid();
51
 
   
52
 
   /// Rebuild the broad phase using current vertex positions
53
 
   ///
54
 
   void update_broad_phase_static( const DynamicSurface& surface );
55
 
   
56
 
   /// Rebuild the broad phase using current and predicted vertex positions
57
 
   ///
58
 
   void update_broad_phase_continuous( const DynamicSurface& surface );
59
 
 
60
 
   inline void add_vertex( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high ); 
61
 
   inline void add_edge( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high ); 
62
 
   inline void add_triangle( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high );   
63
 
   
64
 
   inline void update_vertex( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high ); 
65
 
   inline void update_edge( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high ); 
66
 
   inline void update_triangle( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high ); 
67
 
   
68
 
   inline void remove_vertex( unsigned int index ); 
69
 
   inline void remove_edge( unsigned int index ); 
70
 
   inline void remove_triangle( unsigned int index ); 
71
 
   
72
 
   /// Get the set of vertices whose bounding volumes overlap the specified bounding volume
73
 
   ///
74
 
   inline void get_potential_vertex_collisions( const Vec3d& aabb_low, 
75
 
                                                const Vec3d& aabb_high, 
76
 
                                                std::vector<unsigned int>& overlapping_vertices );
77
 
   
78
 
   /// Get the set of edges whose bounding volumes overlap the specified bounding volume
79
 
   ///
80
 
   inline void get_potential_edge_collisions( const Vec3d& aabb_low, 
81
 
                                              const Vec3d& aabb_high, 
82
 
                                              std::vector<unsigned int>& overlapping_edges );
83
 
   
84
 
   /// Get the set of triangles whose bounding volumes overlap the specified bounding volume
85
 
   ///
86
 
   inline void get_potential_triangle_collisions( const Vec3d& aabb_low, 
87
 
                                                  const Vec3d& aabb_high, 
88
 
                                                  std::vector<unsigned int>& overlapping_triangles );
89
 
 
90
 
   /// Rebuild one of the grids
91
 
   ///
92
 
   void build_acceleration_grid( AccelerationGrid& grid, 
93
 
                                 std::vector<Vec3d>& xmins, 
94
 
                                 std::vector<Vec3d>& xmaxs, 
95
 
                                 double length_scale, 
96
 
                                 double grid_padding );
97
 
   
98
 
   /// Regular grids
99
 
   ///
100
 
   AccelerationGrid m_vertex_grid;
101
 
   AccelerationGrid m_edge_grid;
102
 
   AccelerationGrid m_triangle_grid;  
103
 
   
104
 
};
105
 
 
106
 
// ---------------------------------------------------------
107
 
//  Inline functions
108
 
// ---------------------------------------------------------
109
 
 
110
 
// --------------------------------------------------------
111
 
///
112
 
/// Add a vertex to the broad phase
113
 
///
114
 
// --------------------------------------------------------
115
 
 
116
 
inline void BroadPhaseGrid::add_vertex( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high )
117
 
{
118
 
   m_vertex_grid.add_element( index, aabb_low, aabb_high );
119
 
}
120
 
 
121
 
// --------------------------------------------------------
122
 
///
123
 
/// Add an edge to the broad phase
124
 
///
125
 
// --------------------------------------------------------
126
 
 
127
 
inline void BroadPhaseGrid::add_edge( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high )
128
 
{
129
 
   m_edge_grid.add_element( index, aabb_low, aabb_high );
130
 
}
131
 
 
132
 
// --------------------------------------------------------
133
 
///
134
 
/// Add a triangle to the broad phase
135
 
///
136
 
// --------------------------------------------------------
137
 
 
138
 
inline void BroadPhaseGrid::add_triangle( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high )
139
 
{
140
 
   m_triangle_grid.add_element( index, aabb_low, aabb_high );
141
 
}
142
 
 
143
 
 
144
 
inline void BroadPhaseGrid::update_vertex( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high )
145
 
{
146
 
   m_vertex_grid.update_element( index, aabb_low, aabb_high );
147
 
}
148
 
 
149
 
inline void BroadPhaseGrid::update_edge( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high )
150
 
{
151
 
   m_edge_grid.update_element( index, aabb_low, aabb_high );   
152
 
}
153
 
 
154
 
inline void BroadPhaseGrid::update_triangle( unsigned int index, const Vec3d& aabb_low, const Vec3d& aabb_high )
155
 
{
156
 
   m_triangle_grid.update_element( index, aabb_low, aabb_high );   
157
 
}
158
 
 
159
 
 
160
 
// --------------------------------------------------------
161
 
///
162
 
/// Remove a vertex from the broad phase
163
 
///
164
 
// --------------------------------------------------------
165
 
 
166
 
inline void BroadPhaseGrid::remove_vertex( unsigned int index )
167
 
{
168
 
   m_vertex_grid.remove_element( index );
169
 
}
170
 
 
171
 
// --------------------------------------------------------
172
 
///
173
 
/// Remove an edge from the broad phase
174
 
///
175
 
// --------------------------------------------------------
176
 
 
177
 
inline void BroadPhaseGrid::remove_edge( unsigned int index )
178
 
{
179
 
   m_edge_grid.remove_element( index );
180
 
}
181
 
 
182
 
// --------------------------------------------------------
183
 
///
184
 
/// Remove a triangle from the broad phase
185
 
///
186
 
// --------------------------------------------------------
187
 
 
188
 
inline void BroadPhaseGrid::remove_triangle( unsigned int index )
189
 
{
190
 
   m_triangle_grid.remove_element( index );
191
 
}
192
 
 
193
 
// --------------------------------------------------------
194
 
///
195
 
/// Query the broad phase to get the set of all vertices overlapping the given AABB
196
 
///
197
 
// --------------------------------------------------------
198
 
 
199
 
inline void BroadPhaseGrid::get_potential_vertex_collisions( const Vec3d& aabb_low, const Vec3d& aabb_high, std::vector<unsigned int>& overlapping_vertices )
200
 
{
201
 
   m_vertex_grid.find_overlapping_elements( aabb_low, aabb_high, overlapping_vertices );
202
 
}
203
 
 
204
 
// --------------------------------------------------------
205
 
///
206
 
/// Query the broad phase to get the set of all edges overlapping the given AABB
207
 
///
208
 
// --------------------------------------------------------
209
 
 
210
 
inline void BroadPhaseGrid::get_potential_edge_collisions( const Vec3d& aabb_low, const Vec3d& aabb_high, std::vector<unsigned int>& overlapping_edges )
211
 
{
212
 
   m_edge_grid.find_overlapping_elements( aabb_low, aabb_high, overlapping_edges );
213
 
}
214
 
 
215
 
// --------------------------------------------------------
216
 
///
217
 
/// Query the broad phase to get the set of all triangles overlapping the given AABB
218
 
///
219
 
// --------------------------------------------------------
220
 
 
221
 
inline void BroadPhaseGrid::get_potential_triangle_collisions( const Vec3d& aabb_low, const Vec3d& aabb_high, std::vector<unsigned int>& overlapping_triangles )
222
 
{
223
 
   m_triangle_grid.find_overlapping_elements( aabb_low, aabb_high, overlapping_triangles );
224
 
}
225
 
 
226
 
#endif
227
 
 
228
 
 
229
 
 
230
 
#endif