cpSpatialIndexFree(cpSpatialIndex *index) { if(index){ cpSpatialIndexDestroy(index); cpfree(index); } }
cpSpatialIndexInit(cpSpatialIndex *index, cpSpatialIndexClass klass, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { index.klass = klass; index.bbfunc = bbfunc; index.staticIndex = staticIndex; if(staticIndex){ // cpAssertHard(!staticIndex.dynamicIndex, "This static index is already associated with a dynamic index."); staticIndex.dynamicIndex = index; } return index; }
cpSpaceHashNew(double celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { return cpSpaceHashInit(cpSpaceHashAlloc(), celldim, cells, bbfunc, staticIndex); }
cpSpaceHashInit(cpSpaceHash *hash, double celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { cpSpatialIndexInit((cpSpatialIndex *)hash, Klass(), bbfunc, staticIndex); cpSpaceHashAllocTable(hash, next_prime(numcells)); hash.celldim = celldim; hash.handleSet = cpHashSetNew(0, (cpHashSetEqlFunc)handleSetEql); hash.pooledHandles = cpArrayNew(0); hash.pooledBins = null; hash.allocatedBuffers = cpArrayNew(0); hash.stamp = 1; return (cpSpatialIndex *)hash; }