cpSpace* cpSpaceInit(cpSpace *space) { space->iterations = DEFAULT_ITERATIONS; space->elasticIterations = DEFAULT_ELASTIC_ITERATIONS; // space->sleepTicks = 300; space->gravity = cpvzero; space->damping = 1.0f; space->stamp = 0; space->staticShapes = cpSpaceHashNew(DEFAULT_DIM_SIZE, DEFAULT_COUNT, (cpSpaceHashBBFunc)shapeBBFunc); space->activeShapes = cpSpaceHashNew(DEFAULT_DIM_SIZE, DEFAULT_COUNT, (cpSpaceHashBBFunc)shapeBBFunc); space->bodies = cpArrayNew(0); space->arbiters = cpArrayNew(0); space->contactSet = cpHashSetNew(0, (cpHashSetEqlFunc)contactSetEql, (cpHashSetTransFunc)contactSetTrans); space->constraints = cpArrayNew(0); space->defaultHandler = defaultHandler; space->collFuncSet = cpHashSetNew(0, (cpHashSetEqlFunc)collFuncSetEql, (cpHashSetTransFunc)collFuncSetTrans); space->collFuncSet->default_value = &space->defaultHandler; space->postStepCallbacks = cpHashSetNew(0, (cpHashSetEqlFunc)postStepFuncSetEql, (cpHashSetTransFunc)postStepFuncSetTrans); return space; }
cpSpace* cpSpaceInit(cpSpace *space) { space->iterations = DEFAULT_ITERATIONS; // space->sleepTicks = 300; space->gravity = cpvzero; space->damping = 1.0f; space->stamp = 0; space->staticShapes = cpSpaceHashNew(DEFAULT_DIM_SIZE, DEFAULT_COUNT, &bbfunc); space->activeShapes = cpSpaceHashNew(DEFAULT_DIM_SIZE, DEFAULT_COUNT, &bbfunc); space->bodies = cpArrayNew(0); space->arbiters = cpArrayNew(0); space->contactSet = cpHashSetNew(0, contactSetEql, contactSetTrans); space->joints = cpArrayNew(0); cpCollPairFunc pairFunc = {0, 0, alwaysCollide, NULL}; space->defaultPairFunc = pairFunc; space->collFuncSet = cpHashSetNew(0, collFuncSetEql, collFuncSetTrans); space->collFuncSet->default_value = &space->defaultPairFunc; return space; }
void cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count) { cpSpatialIndex *staticShapes = cpSpaceHashNew(dim, count, (cpSpatialIndexBBFunc)cpShapeGetBB, NULL); cpSpatialIndex *dynamicShapes = cpSpaceHashNew(dim, count, (cpSpatialIndexBBFunc)cpShapeGetBB, staticShapes); cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)copyShapes, staticShapes); cpSpatialIndexEach(space->dynamicShapes, (cpSpatialIndexIteratorFunc)copyShapes, dynamicShapes); cpSpatialIndexFree(space->staticShapes); cpSpatialIndexFree(space->dynamicShapes); space->staticShapes = staticShapes; space->dynamicShapes = dynamicShapes; }
cpSpace* cpSpaceInit(cpSpace *space) { space->iterations = DEFAULT_ITERATIONS; space->elasticIterations = DEFAULT_ELASTIC_ITERATIONS; // space->sleepTicks = 300; space->gravity = cpvzero; space->damping = 1.0f; space->locked = 0; space->stamp = 0; space->staticShapes = cpSpaceHashNew(DEFAULT_DIM_SIZE, DEFAULT_COUNT, (cpSpaceHashBBFunc)shapeBBFunc); space->activeShapes = cpSpaceHashNew(DEFAULT_DIM_SIZE, DEFAULT_COUNT, (cpSpaceHashBBFunc)shapeBBFunc); space->allocatedBuffers = cpArrayNew(0); space->bodies = cpArrayNew(0); space->sleepingComponents = cpArrayNew(0); space->sleepTimeThreshold = INFINITY; space->idleSpeedThreshold = 0.0f; space->arbiters = cpArrayNew(0); space->pooledArbiters = cpArrayNew(0); cpContactBufferHeader *header = cpContactBufferHeaderInit(cpSpaceAllocContactBuffer(space), space); space->contactBuffersHead = header; space->contactBuffersTail = header; header->next = header; // Buffers will form a ring, start the ring explicitly space->contactSet = cpHashSetNew(0, (cpHashSetEqlFunc)contactSetEql, (cpHashSetTransFunc)contactSetTrans); space->constraints = cpArrayNew(0); space->defaultHandler = defaultHandler; space->collFuncSet = cpHashSetNew(0, (cpHashSetEqlFunc)collFuncSetEql, (cpHashSetTransFunc)collFuncSetTrans); space->collFuncSet->default_value = &space->defaultHandler; space->postStepCallbacks = cpHashSetNew(0, (cpHashSetEqlFunc)postStepFuncSetEql, (cpHashSetTransFunc)postStepFuncSetTrans); cpBodyInit(&space->staticBody, INFINITY, INFINITY); space->staticBody.space = space; return space; }
cpSpace* cpSpaceInit(cpSpace *space) { space->iterations = DEFAULT_ITERATIONS; space->elasticIterations = DEFAULT_ELASTIC_ITERATIONS; // space->sleepTicks = 300; space->gravity = cpvzero; space->damping = 1.0f; space->locked = 0; space->stamp = 0; space->staticShapes = cpSpaceHashNew(DEFAULT_DIM_SIZE, DEFAULT_COUNT, (cpSpaceHashBBFunc)shapeBBFunc); space->activeShapes = cpSpaceHashNew(DEFAULT_DIM_SIZE, DEFAULT_COUNT, (cpSpaceHashBBFunc)shapeBBFunc); space->allocatedBuffers = cpArrayNew(0); space->bodies = cpArrayNew(0); space->sleepingComponents = cpArrayNew(0); space->rousedBodies = cpArrayNew(0); space->sleepTimeThreshold = INFINITY; space->idleSpeedThreshold = 0.0f; space->arbiters = cpArrayNew(0); space->pooledArbiters = cpArrayNew(0); space->contactBuffersHead = NULL; space->contactSet = cpHashSetNew(0, (cpHashSetEqlFunc)contactSetEql, (cpHashSetTransFunc)contactSetTrans); space->constraints = cpArrayNew(0); space->defaultHandler = cpSpaceDefaultHandler; space->collFuncSet = cpHashSetNew(0, (cpHashSetEqlFunc)collFuncSetEql, (cpHashSetTransFunc)collFuncSetTrans); space->collFuncSet->default_value = &cpSpaceDefaultHandler; space->postStepCallbacks = NULL; cpBodyInitStatic(&space->staticBody); return space; }