Blender  V3.3
btSdfCollisionShape.cpp
Go to the documentation of this file.
1 #include "btSdfCollisionShape.h"
2 #include "btMiniSDF.h"
4 
6 {
10 
12  : m_localScaling(1, 1, 1),
13  m_margin(0)
14  {
15  }
16 };
17 
18 bool btSdfCollisionShape::initializeSDF(const char* sdfData, int sizeInBytes)
19 {
20  bool valid = m_data->m_sdf.load(sdfData, sizeInBytes);
21  return valid;
22 }
24 {
25  m_shapeType = SDF_SHAPE_PROXYTYPE;
26  m_data = new btSdfCollisionShapeInternalData();
27 
28  //"E:/develop/bullet3/data/toys/ground_hole64_64_8.cdf");//ground_cube.cdf");
29  /*unsigned int field_id=0;
30  Eigen::Vector3d x (1,10,1);
31  Eigen::Vector3d gradient;
32  double dist = m_data->m_sdf.interpolate(field_id, x, &gradient);
33  printf("dist=%g\n", dist);
34  */
35 }
37 {
38  delete m_data;
39 }
40 
41 void btSdfCollisionShape::getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
42 {
43  btAssert(m_data->m_sdf.isValid());
44  btVector3 localAabbMin = m_data->m_sdf.m_domain.m_min;
45  btVector3 localAabbMax = m_data->m_sdf.m_domain.m_max;
46  btScalar margin(0);
47  btTransformAabb(localAabbMin, localAabbMax, margin, t, aabbMin, aabbMax);
48 }
49 
51 {
52  m_data->m_localScaling = scaling;
53 }
55 {
56  return m_data->m_localScaling;
57 }
59 {
60  inertia.setValue(0, 0, 0);
61 }
62 const char* btSdfCollisionShape::getName() const
63 {
64  return "btSdfCollisionShape";
65 }
67 {
68  m_data->m_margin = margin;
69 }
71 {
72  return m_data->m_margin;
73 }
74 
76 {
77  //not yet
78 }
79 
81 {
82  int field = 0;
84  double dist;
85  bool hasResult = m_data->m_sdf.interpolate(field, dist, ptInSDF, &grad);
86  if (hasResult)
87  {
88  normal.setValue(grad[0], grad[1], grad[2]);
89  distOut = dist;
90  }
91  return hasResult;
92 }
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
SIMD_FORCE_INLINE 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 btAssert(x)
Definition: btScalar.h:295
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
Definition: btVector3.h:82
bool initializeSDF(const char *sdfData, int sizeInBytes)
bool queryPoint(const btVector3 &ptInSDF, btScalar &distOut, btVector3 &normal)
virtual const char * getName() const
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
virtual void setMargin(btScalar margin)
virtual void setLocalScaling(const btVector3 &scaling)
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
virtual const btVector3 & getLocalScaling() const
DEGForeachIDComponentCallback callback
IconTextureDrawCall normal
BLI_INLINE float grad(int hash_val, float x, float y, float z)
Definition: noise.c:270
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