17#ifndef BT_SPARSE_SDF_H
18#define BT_SPARSE_SDF_H
24template <const
int DWORDLEN>
27 const unsigned short* data=(
const unsigned short*)
pdata;
32 tmp = (data[1]<<11)^hash;
33 hash = (hash<<16)^
tmp;
43template <const
int CELLSIZE>
113 for(
int i=0;i<
cells.size();++i)
139 for(
int i=0;i<
cells.size();++i)
201 c->c[0]=
ix.b;c->c[1]=
iy.b;c->c[2]=
iz.b;
206 const int o[]={
ix.i,
iy.i,
iz.i};
208 c->d[
o[0]+1][
o[1]+0][
o[2]+0],
209 c->d[
o[0]+1][
o[1]+1][
o[2]+0],
210 c->d[
o[0]+0][
o[1]+1][
o[2]+0],
211 c->d[
o[0]+0][
o[1]+0][
o[2]+1],
212 c->d[
o[0]+1][
o[1]+0][
o[2]+1],
213 c->d[
o[0]+1][
o[1]+1][
o[2]+1],
214 c->d[
o[0]+0][
o[1]+1][
o[2]+1]};
218 d[5]-d[4],d[6]-d[7]};
220 d[7]-d[4],d[6]-d[5]};
222 d[7]-d[3],d[6]-d[2]};
268 if(
shape->isConvex())
283 const int o=x<0?(
int)(-x+1):0;
const T & btMax(const T &a, const T &b)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
unsigned int HsiehHash(const void *pdata)
btSparseSdf implementation by Nathanael Presson
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
btVector3 can be used to represent 3D points and vectors.
void setZ(btScalar _z)
Set the z value.
const btScalar & z() const
Return the z value.
btVector3 normalized() const
Return a normalized version of this vector.
void setY(btScalar _y)
Set the y value.
void setX(btScalar _x)
Set the x value.
static btScalar SignedDistance(const btVector3 &position, btScalar margin, const btConvexShape *shape, const btTransform &wtrs, sResults &results)
const btCollisionShape * pclient
btScalar d[CELLSIZE+1][CELLSIZE+1][CELLSIZE+1]
void GarbageCollect(int lifetime=256)
static IntFrac Decompose(btScalar x)
static btScalar DistanceToShape(const btVector3 &x, const btCollisionShape *shape)
int RemoveReferences(btCollisionShape *pcs)
btAlignedObjectArray< Cell * > cells
btScalar Evaluate(const btVector3 &x, const btCollisionShape *shape, btVector3 &normal, btScalar margin)
static btScalar Lerp(btScalar a, btScalar b, btScalar t)
static unsigned int Hash(int x, int y, int z, const btCollisionShape *shape)
void Initialize(int hashsize=2383, int clampCells=256 *1024)