Exemplo n.º 1
0
        public cpShape SegmentQueryFirst(cpVect start, cpVect end, float radius, cpShapeFilter filter, ref cpSegmentQueryInfo output)
        {
            cpSegmentQueryInfo info = new cpSegmentQueryInfo(null, end, cpVect.Zero, 1.0f);

            if (output == null)
            {
                output = info;
            }

            SegmentQueryContext context = new SegmentQueryContext(
                start, end,
                radius,
                filter,
                null);

            this.staticShapes.SegmentQuery(context, start, end, 1.0f,
                                           (o1, o2, o3) => SegmentQueryFirstFunc((SegmentQueryContext)o1, o2 as cpShape, (cpSegmentQueryInfo)o3)
                                           , output);
            //		this.dynamicShapes.SegmentQuery(context, start, end, output.alpha , SegmentQueryFirst, ref output);
            this.dynamicShapes.SegmentQuery(context, start, end, output.alpha,
                                            (o1, o2, o3) => SegmentQueryFirstFunc((SegmentQueryContext)o1, o2 as cpShape, (cpSegmentQueryInfo)o3)
                                            , output);

            return(output.shape);
        }
Exemplo n.º 2
0
        //MARK: Segment Query Functions

        public float SegmentQueryFunc(SegmentQueryContext context, cpShape shape, object data)
        {
            cpSegmentQueryInfo info = null;

            if (
                !cpShapeFilter.Reject(shape.filter, context.filter) &&
                shape.SegmentQuery(context.start, context.end, context.radius, ref info)
                )
            {
                context.func(shape, info.point, info.normal, info.alpha, data);
            }

            return(1.0f);
        }
Exemplo n.º 3
0
        public float SegmentQueryFirstFunc(SegmentQueryContext context, cpShape shape, cpSegmentQueryInfo output)
        {
            cpSegmentQueryInfo info = null;

            if (
                !cpShapeFilter.Reject(shape.filter, context.filter) && !shape.sensor &&
                shape.SegmentQuery(context.start, context.end, context.radius, ref info) &&
                info.alpha < output.alpha
                )
            {
                output = info;
            }

            return(output.alpha);
        }
Exemplo n.º 4
0
        public void SegmentQuery(cpVect start, cpVect end, float radius, cpShapeFilter filter, Action <cpShape, cpVect, cpVect, float, object> func, object data)
        {
            SegmentQueryContext context = new SegmentQueryContext(
                start, end,
                radius,
                filter,
                func
                );

            Lock();
            {
                this.staticShapes.SegmentQuery(context, start, end, 1.0f,
                                               (o1, o2, o3) => SegmentQueryFunc((SegmentQueryContext)o1, o2 as cpShape, o3)
                                               , data);
                this.dynamicShapes.SegmentQuery(context, start, end, 1.0f,
                                                (o1, o2, o3) => SegmentQueryFunc((SegmentQueryContext)o1, o2 as cpShape, o3)
                                                , data);
            } Unlock(true);
        }
Exemplo n.º 5
0
        //MARK: Segment Query Functions
        public float SegmentQueryFunc(SegmentQueryContext context, cpShape shape, object data)
        {
            cpSegmentQueryInfo info = null;

            if (
                !cpShapeFilter.Reject(shape.filter, context.filter) &&
                shape.SegmentQuery(context.start, context.end, context.radius, ref info)
            )
            {
                context.func(shape, info.point, info.normal, info.alpha, data);
            }

            return 1.0f;
        }
Exemplo n.º 6
0
        public float SegmentQueryFirstFunc(SegmentQueryContext context, cpShape shape, cpSegmentQueryInfo output)
        {
            cpSegmentQueryInfo info = null;

            if (
                !cpShapeFilter.Reject(shape.filter, context.filter) && !shape.sensor &&
                shape.SegmentQuery(context.start, context.end, context.radius, ref info) &&
                info.alpha < output.alpha
            )
            {
                output = info;
            }

            return output.alpha;
        }
Exemplo n.º 7
0
        public cpShape SegmentQueryFirst(cpVect start, cpVect end, float radius, cpShapeFilter filter, ref cpSegmentQueryInfo output)
        {
            cpSegmentQueryInfo info = new cpSegmentQueryInfo(null, end, cpVect.Zero, 1.0f);
            if (output == null)
                output = info;

            SegmentQueryContext context = new SegmentQueryContext(
               start, end,
               radius,
               filter,
               null);

            this.staticShapes.SegmentQuery(context, start, end, 1.0f,
             (o1, o2, o3) => SegmentQueryFirstFunc((SegmentQueryContext)o1, o2 as cpShape, (cpSegmentQueryInfo)o3)
                 , output);
            //		this.dynamicShapes.SegmentQuery(context, start, end, output.alpha , SegmentQueryFirst, ref output);
            this.dynamicShapes.SegmentQuery(context, start, end, output.alpha,
                 (o1, o2, o3) => SegmentQueryFirstFunc((SegmentQueryContext)o1, o2 as cpShape, (cpSegmentQueryInfo)o3)
                , output);

            return output.shape;
        }
Exemplo n.º 8
0
        public void SegmentQuery(cpVect start, cpVect end, float radius, cpShapeFilter filter, Action<cpShape, cpVect, cpVect, float, object> func, object data)
        {
            SegmentQueryContext context = new SegmentQueryContext(
            start, end,
            radius,
            filter,
            func
            );

            Lock();
            {
                this.staticShapes.SegmentQuery(context, start, end, 1.0f,
                    (o1, o2, o3) => SegmentQueryFunc((SegmentQueryContext)o1, o2 as cpShape, o3)
                , data);
                this.dynamicShapes.SegmentQuery(context, start, end, 1.0f,
                    (o1, o2, o3) => SegmentQueryFunc((SegmentQueryContext)o1, o2 as cpShape, o3)
                    , data);

            } Unlock(true);
        }