Ejemplo n.º 1
0
void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) {
	AreaBullet *area = area_owner.get(p_area);
	ERR_FAIL_COND(!area);
	SpaceBullet *space = NULL;
	if (p_space.is_valid()) {
		space = space_owner.get(p_space);
		ERR_FAIL_COND(!space);
	}
	area->set_space(space);
}
Ejemplo n.º 2
0
void BulletPhysicsServer::free(RID p_rid) {
	if (shape_owner.owns(p_rid)) {

		ShapeBullet *shape = shape_owner.get(p_rid);

		// Notify the shape is configured
		for (Map<ShapeOwnerBullet *, int>::Element *element = shape->get_owners().front(); element; element = element->next()) {
			static_cast<ShapeOwnerBullet *>(element->key())->remove_shape(shape);
		}

		shape_owner.free(p_rid);
		bulletdelete(shape);
	} else if (rigid_body_owner.owns(p_rid)) {

		RigidBodyBullet *body = rigid_body_owner.get(p_rid);

		body->set_space(NULL);

		body->remove_all_shapes(true);

		rigid_body_owner.free(p_rid);
		bulletdelete(body);

	} else if (soft_body_owner.owns(p_rid)) {

		SoftBodyBullet *body = soft_body_owner.get(p_rid);

		body->set_space(NULL);

		soft_body_owner.free(p_rid);
		bulletdelete(body);

	} else if (area_owner.owns(p_rid)) {

		AreaBullet *area = area_owner.get(p_rid);

		area->set_space(NULL);

		area->remove_all_shapes(true);

		area_owner.free(p_rid);
		bulletdelete(area);

	} else if (joint_owner.owns(p_rid)) {

		JointBullet *joint = joint_owner.get(p_rid);
		joint->destroy_internal_constraint();
		joint_owner.free(p_rid);
		bulletdelete(joint);

	} else if (space_owner.owns(p_rid)) {

		SpaceBullet *space = space_owner.get(p_rid);

		space->remove_all_collision_objects();

		space_set_active(p_rid, false);
		space_owner.free(p_rid);
		bulletdelete(space);
	} else {

		ERR_EXPLAIN("Invalid ID");
		ERR_FAIL();
	}
}