static int l_physics_shapeGC(lua_State* state) { l_physics_Shape* shape = (l_physics_Shape*)lua_touserdata(state, 1); if (shape->physics && shape->shape) cpSpaceRemoveShape(shape->physics->space, shape->shape); return 0; }
~Phys() { for (std::vector<Ship*>::iterator it = ship_list.begin(); it != ship_list.end(); ++it) { cpSpaceRemoveShape(space, (*it)->cpshape); cpSpaceRemoveBody(space, (*it)->body); delete *it; } ship_list.clear(); for (std::vector<Shell*>::iterator it = shell_list.begin(); it != shell_list.end(); ++it) { cpSpaceRemoveShape(space, (*it)->cpshape); cpSpaceRemoveBody(space, (*it)->body); delete *it; } shell_list.clear(); cpSpaceFree(space); }
Polygon::Polygon(ShapePolygon *src, float mass){ std::vector<glm::vec2> ofVerts = src->getPoints(); std::vector<cpVect> verts = toChipmunk(ofVerts); cpFloat moment = cpMomentForPoly(mass, verts.size(), verts.data(), cpvzero, cpPolyShapeGetRadius(src->shape)); DynamicBody::setup(cpShapeGetSpace(src->shape), mass, moment); cpSpaceRemoveShape(cpShapeGetSpace(src->shape), src->shape); ShapePolygon::setup(src); cpShapeSetBody(shape, body); cpSpaceAddShape(cpBodyGetSpace(body), shape); }
void PhysicsWorld::removeShape(PhysicsShape* shape) { for (auto cps : shape->_info->getShapes()) { if (cpSpaceContainsShape(_info->getSpace(), cps)) { cpSpaceRemoveShape(_info->getSpace(), cps); } } }
void ColliderDetector::setActive(bool active) { if (m_bActive == active) { return; } m_bActive = active; if (m_pB2Body) { if (active) { setB2Body(m_pB2Body); } else { for(auto object : *m_pColliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; b2Fixture *fixture = colliderBody->getB2Fixture(); m_pB2Body->DestroyFixture(fixture); colliderBody->setB2Fixture(nullptr); } } } else if (m_pCPBody) { if (m_bActive) { for(auto object : *m_pColliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; cpShape *shape = colliderBody->getShape(); if(shape->space == nullptr) { cpSpaceAddShape(m_pCPBody->space, shape); } } } else { for(auto object : *m_pColliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; cpShape *shape = colliderBody->getShape(); if (shape->space != nullptr) { cpSpaceRemoveShape(m_pCPBody->space, shape); } } } } }
void World::removeHuman(Human* h) { cpSpaceRemoveShape(space,h->shape); cpSpaceRemoveBody(space,h->body); for(int i=0;i<humans.size();i++) { if(h==humans[i]) { humans.erase(humans.begin()+i); break; } } }
void destroyEditorPalette(void) { int i; palette_object_t *obj; for (i = 0; i < MAX_PALETTE_SHAPES; ++i) { obj = paletteObjects[i]; if (obj) { cpSpaceRemoveShape(g_Space, obj->shape); paletteObjects[i] = NULL; } } }
static void remove_unused(void* s) { cpShape* shape = (cpShape*)s; chipmunk_data* p = (chipmunk_data*)shape->data; destroy_chipmunk_data(p, shape->body); /* The player was marked as to be deleted. The player is freed here, * to avoid concurrence problems if we delete somewhere else. */ cpSpaceRemoveShape(space, shape); cpShapeFree(shape); }
void PhysicsWorld::removeShape(PhysicsShape* shape) { if (shape) { for (auto cps : shape->_cpShapes) { if (cpSpaceContainsShape(_cpSpace, cps)) { cpSpaceRemoveShape(_cpSpace, cps); } } } }
void RigidBody2D::UnregisterFromSpace() { if (m_isRegistered) { cpSpace* space = m_world->GetHandle(); for (cpShape* shape : m_shapes) cpSpaceRemoveShape(space, shape); if (m_handle) cpSpaceRemoveBody(space, m_handle); m_isRegistered = false; } }
/** * Removes a player object from the grid. * This means moving him from the playing list to the queue. */ int player_remove(struct player *p, struct game *g) { if (p->list != g->p_p) { //The player isn't in the playing list return -2; } if (linkedlist_add_last(g->p_q, p)) { ERR_TRACE(); return -1; } linkedlist_remove_node(g->p_p, p->node); cpSpaceRemoveShape(g->cp, (struct cpShape *)&p->shape); cpSpaceRemoveBody(g->cp, &p->body); p->node = g->p_q->last; return 0; }
void RigidBody2D::Destroy() { cpSpace* space = m_world->GetHandle(); for (cpShape* shape : m_shapes) { cpSpaceRemoveShape(space, shape); cpShapeFree(shape); } if (m_handle) { cpSpaceRemoveBody(space, m_handle); cpBodyFree(m_handle); } m_shapes.clear(); }
CDynamics2DCylinderEntity::~CDynamics2DCylinderEntity() { if(m_ptBody != NULL) { cpSpaceRemoveConstraint(m_cEngine.GetPhysicsSpace(), m_ptLinearFriction); cpSpaceRemoveConstraint(m_cEngine.GetPhysicsSpace(), m_ptAngularFriction); cpConstraintFree(m_ptLinearFriction); cpConstraintFree(m_ptAngularFriction); cpSpaceRemoveBody(m_cEngine.GetPhysicsSpace(), m_ptBody); cpBodyFree(m_ptBody); cpSpaceRemoveShape(m_cEngine.GetPhysicsSpace(), m_ptShape); } else { cpSpaceRemoveStaticShape(m_cEngine.GetPhysicsSpace(), m_ptShape); cpSpaceRehashStatic(m_cEngine.GetPhysicsSpace()); } cpShapeFree(m_ptShape); }
CDynamics2DSingleBodyObjectModel::~CDynamics2DSingleBodyObjectModel() { bool bIsStatic = cpBodyIsStatic(m_ptBody); /* Dispose of shapes */ for(cpShape* pt_shape = m_ptBody->shapeList; pt_shape != NULL; pt_shape = pt_shape->next) { cpSpaceRemoveShape(GetDynamics2DEngine().GetPhysicsSpace(), pt_shape); cpShapeFree(pt_shape); } /* Dispose of body */ if(! bIsStatic) cpSpaceRemoveBody(GetDynamics2DEngine().GetPhysicsSpace(), m_ptBody); cpBodyFree(m_ptBody); /* Reindex space */ if(bIsStatic) cpSpaceReindexStatic(GetDynamics2DEngine().GetPhysicsSpace()); }
void TestColliderDetector::destroyCPBody(cpBody *body) { cpShape *shape = body->shapeList_private; while(shape) { cpShape *temp = shape->next_private; cpSpaceRemoveShape(space, shape); cpShapeFree(shape); shape = temp; } cpSpaceRemoveBody(space, body); cpBodyFree(body); }
GeometrySpringDynamic::~GeometrySpringDynamic() { clearJoints(); if( 0 != m_Shape && true == cpSpaceContainsShape( m_Space, m_Shape ) ) { cpSpaceRemoveShape( m_Space, m_Shape ); cpShapeFree( m_Shape ); m_Shape = 0; } if( 0 != m_Body && true == cpSpaceContainsBody( m_Space, m_Body ) ) { cpSpaceRemoveBody( m_Space, m_Body ); cpBodyFree( m_Body ); m_Body = 0; } }
void Slice::SliceShapePostStep(cpSpace *space, cpShape *shape, struct SliceContext *context) { cpVect a = context->a; cpVect b = context->b; // Clipping plane normal and distance. cpVect n = cpvnormalize(cpvperp(cpvsub(b, a))); cpFloat dist = cpvdot(a, n); ClipPoly(space, shape, n, dist); ClipPoly(space, shape, cpvneg(n), -dist); cpBody *body = cpShapeGetBody(shape); cpSpaceRemoveShape(space, shape); cpSpaceRemoveBody(space, body); cpShapeFree(shape); cpBodyFree(body); }
int remove_body(cpBody* body) { if(body == NULL) { return -1; // nyurupo~ } cpSpace* space; if(the_space != NULL) { space = the_space; } else { return -1; } cpBodyEachShape_b(body, ^(cpShape* s){ cpSpaceRemoveShape(space, s); cpShapeFree(s); });
LevelGrid::~LevelGrid(void) { delete this->m_BackgroundQuad; // Remove grid vertices for (int y = 0 ; y <= this->m_NumY ; ++y) { for (int x = 0 ; x <= this->m_NumX ; ++x) { delete this->m_GridVertices[y][x]; } delete this->m_GridVertices[y]; } delete this->m_GridVertices; // Delete the activators for (int i = 0 ; i < this->m_NumActivators ; ++i) { delete this->m_Activators[i]; } if (this->m_NumActivators > 0) { delete this->m_Activators; } // Free the physics shapes and body std::list<cpShape*>::const_iterator it; cpSpace *space = this->m_Engine->GetWorld()->GetSpace(); for (it = this->m_Shapes.begin() ; it != this->m_Shapes.end() ; ++it) { cpSpaceRemoveShape(space, *it); cpShapeFree(*it); } this->m_Shapes.clear(); delete this->m_Body; // Free the left and right index memory delete this->m_LeftLevelIndices; delete this->m_RightLevelIndices; // Free the left and right vertex memory delete this->m_LeftLevelVertices; delete this->m_RightLevelVertices; }
Unit::~Unit() { ActionTimer* timer = NULL; while( actionTimers != NULL ){ timer = actionTimers; Timer::DeleteTimerEventById( timer->timerId ); actionTimers = timer->next; delete timer, timer = NULL; } if( physShape ){ cpSpaceRemoveShape( Phys::space, physShape ); cpShapeFree( physShape ); } if( physBody ){ if( !cpBodyIsStatic(physBody) ) cpSpaceRemoveBody( Phys::space, physBody ); cpBodyFree( physBody ); } }
Player::~Player(void) { delete this->m_ParticleSystem; delete this->m_Sprite; delete this->m_ParticleSprite; // Delete weapon in weapon slots for (int i = 0 ; i < NUM_WEAPON_SLOTS ; ++i) { delete this->m_Weaponslots[i]; } delete this->m_Weaponslots; // Delete physics stuff cpSpace *space = this->m_Engine->GetWorld()->GetSpace(); cpSpaceRemoveShape(space, this->m_Shape); cpSpaceRemoveBody(space, this->m_Body); cpShapeFree(this->m_Shape); cpBodyFree(this->m_Body); }
void Bomb::destroy(cpSpace *space) { if (!destroyed) { destroyed = true; if (simulation_type == "DYNAMIC") cpSpaceRemoveShape(space, bombShape); else cpSpaceRemoveStaticShape(space, bombShape); if (simulation_type == "DYNAMIC") cpSpaceRemoveBody(space, body); cpShapeFree(bombShape); cpBodyFree(body); for (int j=0; j < PARTICLE_TOTAL; j++) { delete particles[j]; particles[j] = NULL; } delete [] particles; } }
CDynamics2DMultiBodyObjectModel::~CDynamics2DMultiBodyObjectModel() { /* Dispose of shapes and bodies */ while(!m_vecBodies.empty()) { /* Get pointer to body */ cpBody* ptBody = m_vecBodies.back().Body; /* Remove all of its shapes */ cpShape* ptCurShape = ptBody->shapeList; cpShape* ptNextShape; while(ptCurShape) { ptNextShape = ptCurShape->next; cpSpaceRemoveShape(GetDynamics2DEngine().GetPhysicsSpace(), ptCurShape); cpShapeFree(ptCurShape); ptCurShape = ptNextShape; } /* Dispose of body */ cpSpaceRemoveBody(GetDynamics2DEngine().GetPhysicsSpace(), ptBody); cpBodyFree(ptBody); /* Dispose of struct */ m_vecBodies.pop_back(); } }
void analyserLettres(int x1, int y1, int x2, int y2){ cpBB unCpBB; int n=0; char * result=(char *) malloc(sizeof(char) * 255); char * stringBoules=NULL; for(int i=0;i<50;i++) { unCpBB=cpBBNewForCircle(cpv(lesBoules[i].y, lesBoules[i].x ),lesBoules[i].radius); int intersected=cpBBIntersectsSegment(unCpBB, cpv(x1,y1),cpv(x2,y2));; if(intersected==1 && lesBoules[i].del==FALSE) { result[n]=*lesBoules[i].lettre; n++; //printf("%s",result); stringBoules=algo_1(result); if(stringBoules!=NULL){ for(int m=0;m<sizeof(result);m++){ if(*lesBoules[i].lettre==result[m]){ lesBoules[i].del=TRUE; cpSpaceRemoveShape(espace,lesBoules[i].shape); cpSpaceRemoveBody(espace,lesBoules[i].body); nbBoules=nbBoules-1; } } score+=sizeof(stringBoules)/4; printf(" \n %s",stringBoules); } } } free(result); }
int removeshells() { listremoveduplicates(rshell, nrshell); for (int i = 0; i < nrshell; i++) { cpSpaceRemoveShape(space, rshell[i]->cpshape); cpSpaceRemoveBody(space, rshell[i]->body); for (std::vector<Shell*>::iterator it = shell_list.begin(); it != shell_list.end(); ++it) { if (*it == rshell[i]) { shell_list.erase(it); break; } } delete rshell[i]; } nrshell = 0; if (rshell) delete rshell; rshell = 0; return 0; }
__declspec( dllexport ) void deletevar( const void * _in, int in_size, void * _out, int out_sz ) { cpBody *body; int i; int index; Variable *var; Variable *mainVar = vhRemoveVariable(&mVariableHandler,PEEKINT(INPUT_MEMBLOCK,0)); if (mainVar->mType == VarTypeBody) { body = (cpBody*)mainVar->mPtr; resetVariableList(); cpBodyEachShape(body,listShape,0); index = 0; for (i = 0;i != mVariableListIterator;i++) { var = mVariableList[i]; POKEINT(OUTPUT_MEMBLOCK,index,var->mCBPtr);index += 4; cpSpaceRemoveShape(&mSpace,(cpShape*)var->mPtr); cpShapeFree((cpShape*)var->mPtr); //MessageBoxA(NULL,"ShapeRemoved2","Error",MB_OK); vhRemoveVariable(&mVariableHandler,var->mLocalHandle); varFree(var); } resetVariableList(); cpBodyEachConstraint(body,listConstraint,0); for (i = 0;i != mVariableListIterator;i++) { var = mVariableList[i]; POKEINT(OUTPUT_MEMBLOCK,index,var->mCBPtr);index+=4; //MessageBoxA(NULL,"Constraint removed2","Error",MB_OK); cpSpaceRemoveConstraint(&mSpace,(cpConstraint*)var->mPtr); cpConstraintFree((cpConstraint*)var->mPtr); vhRemoveVariable(&mVariableHandler,var->mLocalHandle); varFree(var); } POKEINT(OUTPUT_MEMBLOCK,index,0);//End point //MessageBoxA(NULL,"BodyRemoved","Error",MB_OK); cpSpaceRemoveBody(&mSpace,body); cpBodyFree(body); varFree(mainVar); } else if (mainVar->mType == VarTypeShape) { cpSpaceRemoveShape(&mSpace,(cpShape*)mainVar->mPtr); cpShapeFree((cpShape*)mainVar->mPtr); //MessageBoxA(NULL,"ShapeRemoved","Error",MB_OK); varFree(mainVar); POKEINT(OUTPUT_MEMBLOCK,0,0); } else if (mainVar->mType == VarTypeConstraint) { cpSpaceRemoveConstraint(&mSpace,(cpConstraint*)mainVar->mPtr); cpConstraintFree((cpConstraint*)mainVar->mPtr); varFree(mainVar); POKEINT(OUTPUT_MEMBLOCK,0,0); } else if (mainVar->mType == VarTypeDataArray) { daFree((DataArray*)mainVar->mPtr); varFree(mainVar); POKEINT(OUTPUT_MEMBLOCK,0,0); } else { //Failure... MessageBoxA(NULL,"Unknown cpChipmunk error 11","Error",MB_OK); varFree(mainVar); POKEINT(OUTPUT_MEMBLOCK,0,0); } }
static void free_shape(cpBody *body, cpShape *shape, void *data) { cpSpace *space = cpBodyGetSpace(body); cpSpaceRemoveShape(space, shape); cpShapeDestroy(shape); cpShapeFree(shape); }
static void removeAndFreeShapeAndBody(cpShape *shape, cpSpace *space) { cpSpaceRemoveShape(space, shape); cpShapeFree(shape); }
static void shapeFreeWrap(cpSpace *space, cpShape *shape, void *unused){ cpSpaceRemoveShape(space, shape); cpShapeFree(shape); }
void Space::remove(shared_ptr<Shape> shape) { cpSpaceRemoveShape(space, *shape); shapes.erase(find(shapes.begin(), shapes.end(), shape)); }