Bullet Collision Detection & Physics Library: btMiniSDF.h Source File

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