Bullet Collision Detection & Physics Library
btMiniSDF.h
Go to the documentation of this file.
1 #ifndef MINISDF_H
2 #define MINISDF_H
3 
4 #include "LinearMath/btVector3.h"
7 
8 
10 {
11  unsigned int ijk[3];
12 };
13 
15 {
18 
19  const btVector3& min() const
20  {
21  return m_min;
22  }
23 
24  const btVector3& max() const
25  {
26  return m_max;
27  }
28 
29 
30  bool contains(const btVector3& x) const
31  {
32  return TestPointAgainstAabb2(m_min, m_max, x);
33  }
34 
35  btAlignedBox3d(const btVector3& mn, const btVector3& mx)
36  :m_min(mn),
37  m_max(mx)
38  {
39  }
40 
42  {
43  }
44 };
45 
47 {
48  double m_vec[32];
49 
50  inline double& operator[](int i)
51  {
52  return m_vec[i];
53  }
54 
55  inline const double& operator[](int i) const
56  {
57  return m_vec[i];
58  }
59 
60 };
61 
63 {
64  btVector3 m_vec[32];
65 
66  void topRowsDivide(int row, double denom)
67  {
68  for (int i=0;i<row;i++)
69  {
70  m_vec[i] /= denom;
71  }
72  }
73 
74  void bottomRowsMul(int row, double val)
75  {
76  for (int i=32-row;i<32;i++)
77  {
78  m_vec[i] *= val;
79  }
80  }
81 
82  inline btScalar& operator()(int i, int j)
83  {
84  return m_vec[i][j];
85  }
86 };
87 
88 struct btCell32
89 {
90  unsigned int m_cells[32];
91 };
92 
93 struct btMiniSDF
94 {
95 
97  unsigned int m_resolution[3];
100  std::size_t m_n_cells;
101  std::size_t m_n_fields;
102  bool m_isValid;
103 
104 
108 
110  :m_isValid(false)
111  {
112  }
113  bool load(const char* data, int size);
114  bool isValid() const
115  {
116  return m_isValid;
117  }
118  unsigned int multiToSingleIndex(btMultiIndex const & ijk) const;
119 
120  btAlignedBox3d subdomain(btMultiIndex const& ijk) const;
121 
122  btMultiIndex singleToMultiIndex(unsigned int l) const;
123 
124  btAlignedBox3d subdomain(unsigned int l) const;
125 
126 
128  shape_function_(btVector3 const& xi, btShapeGradients* gradient = 0) const;
129 
130  bool interpolate(unsigned int field_id, double& dist, btVector3 const& x, btVector3* gradient) const;
131 };
132 
133 
134 #endif //MINISDF_H
void bottomRowsMul(int row, double val)
Definition: btMiniSDF.h:74
btAlignedObjectArray< btAlignedObjectArray< double > > m_nodes
Definition: btMiniSDF.h:105
double & operator[](int i)
Definition: btMiniSDF.h:50
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
bool contains(const btVector3 &x) const
Definition: btMiniSDF.h:30
btVector3 m_min
Definition: btMiniSDF.h:16
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
btVector3 m_max
Definition: btMiniSDF.h:17
std::size_t m_n_fields
Definition: btMiniSDF.h:101
btAlignedBox3d m_domain
Definition: btMiniSDF.h:96
const btVector3 & min() const
Definition: btMiniSDF.h:19
btAlignedObjectArray< btAlignedObjectArray< unsigned int > > m_cell_map
Definition: btMiniSDF.h:107
unsigned int ijk[3]
Definition: btMiniSDF.h:11
std::size_t m_n_cells
Definition: btMiniSDF.h:100
const btVector3 & max() const
Definition: btMiniSDF.h:24
const double & operator[](int i) const
Definition: btMiniSDF.h:55
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
btAlignedObjectArray< btAlignedObjectArray< btCell32 > > m_cells
Definition: btMiniSDF.h:106
btVector3 m_cell_size
Definition: btMiniSDF.h:98
bool TestPointAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1, const btVector3 &point)
conservative test for overlap between two aabbs
Definition: btAabbUtil2.h:36
void topRowsDivide(int row, double denom)
Definition: btMiniSDF.h:66
bool m_isValid
Definition: btMiniSDF.h:102
bool isValid() const
Definition: btMiniSDF.h:114
btAlignedBox3d(const btVector3 &mn, const btVector3 &mx)
Definition: btMiniSDF.h:35
btScalar & operator()(int i, int j)
Definition: btMiniSDF.h:82
btVector3 m_inv_cell_size
Definition: btMiniSDF.h:99
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292