コード例 #1
0
ファイル: cbchipmunk.c プロジェクト: Latexi95/cbChipmunk
__declspec( dllexport ) void shapeundersegment( const void * _in, int in_size, void * _out, int out_sz )
{
	cpSegmentQueryInfo segmentQuery;
	cpBool hit;
	Variable *var = vhGetVariable(&mVariableHandler,PEEKINT(INPUT_MEMBLOCK,0));
	cpShape *shape = (cpShape*)var->mPtr;
	hit = cpShapeSegmentQuery(shape,PEEKVECT(INPUT_MEMBLOCK,4),PEEKVECT(INPUT_MEMBLOCK,12),&segmentQuery);
	POKEBYTE(OUTPUT_MEMBLOCK,0,hit);
	POKEFLOAT(OUTPUT_MEMBLOCK,1,segmentQuery.t);
	POKEVECT(OUTPUT_MEMBLOCK,5,segmentQuery.n);
}
コード例 #2
0
ファイル: cpSpaceQuery.cpp プロジェクト: marmalade/chipmunk
static cpFloat
segQueryFunc(segQueryContext *context, cpShape *shape, void *data)
{
	cpSegmentQueryInfo info;
	
	if(
		!(shape->group && context->group == shape->group) && (context->layers&shape->layers) &&
		cpShapeSegmentQuery(shape, context->start, context->end, &info)
	){
		context->func(shape, info.t, info.n, data);
	}
	
	return 1.0f;
}
コード例 #3
0
static cpFloat
SegmentQueryFirst(struct SegmentQueryContext *context, cpShape *shape, cpSegmentQueryInfo *out)
{
	cpSegmentQueryInfo info;
	
	if(
		!(shape->group && context->group == shape->group) && (context->layers&shape->layers) &&
		!shape->sensor &&
		cpShapeSegmentQuery(shape, context->start, context->end, &info) &&
		info.t < out->t
	){
		(*out) = info;
	}
	
	return out->t;
}
コード例 #4
0
ファイル: cpSpace.c プロジェクト: rickystone/TwilightGolf
static cpFloat
segQueryFirst(segQueryFirstContext *context, cpShape *shape, cpSegmentQueryInfo *out)
{
	cpSegmentQueryInfo info;// = {NULL, 1.0f, cpvzero};
	if(
		!(shape->group && context->group == shape->group) && (context->layers&shape->layers) &&
		cpShapeSegmentQuery(shape, context->start, context->end, &info)
	){
		if(info.t < out->t){
			out->shape = info.shape;
			out->t = info.t;
			out->n = info.n;
		}
		
		return info.t;
	}
	
	return 1.0f;
}
コード例 #5
0
bool CDynamics2DCylinderEntity::CheckIntersectionWithRay(Real& f_t_on_ray,
        const CRay& c_ray) const {
    cpSegmentQueryInfo tInfo;
    if(cpShapeSegmentQuery(m_ptShape,
                           cpv(c_ray.GetStart().GetX(), c_ray.GetStart().GetY()),
                           cpv(c_ray.GetEnd().GetX()  , c_ray.GetEnd().GetY()  ),
                           &tInfo)) {
        CVector3 cIntersectionPoint;
        c_ray.GetPoint(cIntersectionPoint, tInfo.t);
        if((cIntersectionPoint.GetZ() >= GetEmbodiedEntity().GetPosition().GetZ() - m_fHalfHeight) &&
                (cIntersectionPoint.GetZ() <= GetEmbodiedEntity().GetPosition().GetZ() + m_fHalfHeight) ) {
            f_t_on_ray = tInfo.t;
            return true;
        }
        else {
            return false;
        }
    }
    else {
        return false;
    }
}
コード例 #6
0
ファイル: wrapper.c プロジェクト: Et999/Hipmunk
int wrShapeSegmentQuery(cpShape *shape, cpVect *a, cpVect *b,
                        cpSegmentQueryInfo *info) {
    return cpShapeSegmentQuery(shape, *a, *b, info);
}