コード例 #1
0
void
cpSpaceNearestPointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryFunc func, void *data)
{
	struct NearestPointQueryContext context = {point, maxDistance, layers, group, func};
	cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f));
	
	cpSpaceLock(space); {
		cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQuery, data);
		cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQuery, data);
	} cpSpaceUnlock(space, cpTrue);
}
コード例 #2
0
void
cpSpacePointQuery(cpSpace *space, cpVect point, cpLayers layers, cpGroup group, cpSpacePointQueryFunc func, void *data)
{
	struct PointQueryContext context = {point, layers, group, func, data};
	cpBB bb = cpBBNewForCircle(point, 0.0f);
	
	cpSpaceLock(space); {
    cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)PointQuery, data);
    cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)PointQuery, data);
	} cpSpaceUnlock(space, cpTrue);
}
コード例 #3
0
ファイル: rb_cpBB.c プロジェクト: Anaxim/chipmunk
static VALUE
rb_cpBBInitialize(int argc, VALUE *argv, VALUE self) {
  VALUE l, b, r, t;
  cpBB *bb = BBGET(self);

  rb_scan_args(argc, argv, "04", &l, &b, &r, &t);
  // initialize as a circle bounds box if ony 2 params
  if (NIL_P(r)) {
    if(NIL_P(l)) { 
       (*bb) = cpBBNew(0, 0, 1, 1); // unit box. 
    } else {
       cpVect * p =  VGET(l);
       (*bb) = cpBBNewForCircle(*p, NUM2DBL(b));
    }   
  } else {
   (*bb)  = cpBBNew(NUM2DBL(l), NUM2DBL(b), NUM2DBL(r), NUM2DBL(t));
  }  
  return self;
}
コード例 #4
0
cpShape *
cpSpaceNearestPointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpNearestPointQueryInfo *out)
{
	cpNearestPointQueryInfo info = {NULL, cpvzero, maxDistance, cpvzero};
	if(out){
		(*out) = info;
  } else {
		out = &info;
	}
	
	struct NearestPointQueryContext context = {
		point, maxDistance,
		layers, group,
		NULL
	};
	
	cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f));
	cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out);
	cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out);
	
	return out->shape;
}
コード例 #5
0
ファイル: main.c プロジェクト: Hakall/LetterBouleGame
 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);
 }
コード例 #6
0
ファイル: cpShape.c プロジェクト: 6311879/LearnCocos2D
static cpBB
cpCircleShapeCacheData(cpCircleShape *circle, cpTransform transform)
{
	cpVect c = circle->tc = cpTransformPoint(transform, circle->c);
	return cpBBNewForCircle(c, circle->r);
}
コード例 #7
0
ファイル: cpShape.c プロジェクト: johnstorm/pur
static cpBB
cpCircleShapeCacheData(cpCircleShape *circle, cpVect p, cpVect rot)
{
	cpVect c = circle->tc = cpvadd(p, cpvrotate(circle->c, rot));
	return cpBBNewForCircle(c, circle->r);
}