17 #ifndef BT_SPARSE_SDF_H
18 #define BT_SPARSE_SDF_H
24 template <const
int DWORDLEN>
27 const unsigned short* data=(
const unsigned short*)pdata;
28 unsigned hash=DWORDLEN<<2,tmp;
29 for(
int i=0;i<DWORDLEN;++i)
32 tmp = (data[1]<<11)^hash;
33 hash = (hash<<16)^tmp;
37 hash^=hash<<3;hash+=hash>>5;
38 hash^=hash<<4;hash+=hash>>17;
39 hash^=hash<<25;hash+=hash>>6;
43 template <const
int CELLSIZE>
82 cells.resize(hashsize,0);
88 for(
int i=0,ni=
cells.size();i<ni;++i)
108 const int life=
puid-lifetime;
109 for(
int i=0;i<
cells.size();++i)
111 Cell*& root=
cells[i];
119 if(pp) pp->next=pn;
else root=pn;
135 for(
int i=0;i<
cells.size();++i)
137 Cell*& root=
cells[i];
145 if(pp) pp->next=pn;
else root=pn;
146 delete pc;pc=pp;++refcount;
164 const unsigned h=
Hash(ix.b,iy.b,iz.b,shape);
165 Cell*& root=
cells[
static_cast<int>(h%
cells.size())];
188 c->c[0]=ix.b;c->c[1]=iy.b;c->c[2]=iz.b;
193 const int o[]={ ix.i,iy.i,iz.i};
194 const btScalar d[]={ c->d[o[0]+0][o[1]+0][o[2]+0],
195 c->d[o[0]+1][o[1]+0][o[2]+0],
196 c->d[o[0]+1][o[1]+1][o[2]+0],
197 c->d[o[0]+0][o[1]+1][o[2]+0],
198 c->d[o[0]+0][o[1]+0][o[2]+1],
199 c->d[o[0]+1][o[1]+0][o[2]+1],
200 c->d[o[0]+1][o[1]+1][o[2]+1],
201 c->d[o[0]+0][o[1]+1][o[2]+1]};
204 const btScalar gx[]={ d[1]-d[0],d[2]-d[3],
205 d[5]-d[4],d[6]-d[7]};
206 const btScalar gy[]={ d[3]-d[0],d[2]-d[1],
207 d[7]-d[4],d[6]-d[5]};
208 const btScalar gz[]={ d[4]-d[0],d[5]-d[1],
209 d[7]-d[3],d[6]-d[2]};
211 Lerp(gx[2],gx[3],iy.f),iz.f));
213 Lerp(gy[2],gy[3],ix.f),iz.f));
215 Lerp(gz[2],gz[3],ix.f),iy.f));
222 Lerp(d[3],d[2],ix.f),iy.f);
224 Lerp(d[7],d[6],ix.f),iy.f);
225 return(
Lerp(d0,d1,iz.f)-margin);
234 for(
int k=0;k<=CELLSIZE;++k)
237 for(
int j=0;j<=CELLSIZE;++j)
240 for(
int i=0;i<=CELLSIZE;++i)
270 const int o=x<0?(int)(-x+1):0;
273 r.i=(int)k;r.f=k-r.i;r.b-=o;
295 myset.x=x;myset.y=y;myset.z=z;myset.p=(
void*)shape;
296 const void* ptr = &myset;
298 unsigned int result =
HsiehHash<
sizeof(btS)/4> (ptr);
306 #endif //BT_SPARSE_SDF_H