Bullet Collision Detection & Physics Library
btSdfCollisionShape.cpp
Go to the documentation of this file.
2#include "btMiniSDF.h"
4
7{
9
13
15 : m_localScaling(1, 1, 1),
16 m_margin(0)
17 {
18 }
19};
20
21bool btSdfCollisionShape::initializeSDF(const char* sdfData, int sizeInBytes)
22{
23 bool valid = m_data->m_sdf.load(sdfData, sizeInBytes);
24 return valid;
25}
27{
30
31 //"E:/develop/bullet3/data/toys/ground_hole64_64_8.cdf");//ground_cube.cdf");
32 /*unsigned int field_id=0;
33 Eigen::Vector3d x (1,10,1);
34 Eigen::Vector3d gradient;
35 double dist = m_data->m_sdf.interpolate(field_id, x, &gradient);
36 printf("dist=%g\n", dist);
37 */
38}
40{
41 delete m_data;
42}
43
44void btSdfCollisionShape::getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
45{
47 btVector3 localAabbMin = m_data->m_sdf.m_domain.m_min;
48 btVector3 localAabbMax = m_data->m_sdf.m_domain.m_max;
49 btScalar margin(0);
50 btTransformAabb(localAabbMin, localAabbMax, margin, t, aabbMin, aabbMax);
51}
52
54{
55 m_data->m_localScaling = scaling;
56}
58{
59 return m_data->m_localScaling;
60}
62{
63 inertia.setValue(0, 0, 0);
64}
66{
67 return "btSdfCollisionShape";
68}
70{
71 m_data->m_margin = margin;
72}
74{
75 return m_data->m_margin;
76}
77
78void btSdfCollisionShape::processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const
79{
80 //not yet
81}
82
83bool btSdfCollisionShape::queryPoint(const btVector3& ptInSDF, btScalar& distOut, btVector3& normal)
84{
85 int field = 0;
86 btVector3 grad;
87 double dist;
88 bool hasResult = m_data->m_sdf.interpolate(field, dist, ptInSDF, &grad);
89 if (hasResult)
90 {
91 normal.setValue(grad[0], grad[1], grad[2]);
92 distOut = dist;
93 }
94 return hasResult;
95}
void btTransformAabb(const btVector3 &halfExtents, btScalar margin, const btTransform &t, btVector3 &aabbMinOut, btVector3 &aabbMaxOut)
Definition: btAabbUtil2.h:172
@ SDF_SHAPE_PROXYTYPE
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:99
#define btAssert(x)
Definition: btScalar.h:153
bool initializeSDF(const char *sdfData, int sizeInBytes)
bool queryPoint(const btVector3 &ptInSDF, btScalar &distOut, btVector3 &normal)
virtual const char * getName() const
struct btSdfCollisionShapeInternalData * m_data
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
virtual btScalar getMargin() const
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
virtual void setMargin(btScalar margin)
virtual void setLocalScaling(const btVector3 &scaling)
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
virtual const btVector3 & getLocalScaling() const
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
btVector3 m_max
Definition: btMiniSDF.h:16
btVector3 m_min
Definition: btMiniSDF.h:15
btAlignedBox3d m_domain
Definition: btMiniSDF.h:92
bool load(const char *data, int size)
Definition: btMiniSDF.cpp:45
bool interpolate(unsigned int field_id, double &dist, btVector3 const &x, btVector3 *gradient) const
Definition: btMiniSDF.cpp:442
bool isValid() const
Definition: btMiniSDF.h:109