Example #1
0
        public ulong ShapeQueryFunc(cpShape a, cpShape b, ulong id, ShapeQueryContext context)
        {
            if (cpShapeFilter.Reject(a.filter, b.filter) || a == b)
            {
                return(id);
            }

            List <cpContact>  contacts = new List <cpContact>();
            cpContactPointSet set      = cpShape.Collide(a, b, ref contacts);

            if (set.count > 0)
            {
                if (context.func != null)
                {
                    context.func(b, set, context.data);
                }
                context.anyCollision = !(a.sensor || b.sensor);
            }
            return(id);
        }
Example #2
0
        public bool ShapeQuery(cpShape shape, Action <cpShape, cpContactPointSet, object> func, object data)
        {
            cpBody            body    = shape.body;
            cpBB              bb      = (body != null ? shape.Update(body.transform) : shape.bb);
            ShapeQueryContext context = new ShapeQueryContext(func, data, false);

            object ctx = (object)context;

            Lock();
            {
                this.staticShapes.Query(shape, bb,
                                        (o1, o2, s, o3) => ShapeQueryFunc(o1 as cpShape, o2 as cpShape, s, (ShapeQueryContext)o3)
                                        , ctx);

                this.dynamicShapes.Query(shape, bb,
                                         (o1, o2, s, o3) => ShapeQueryFunc(o1 as cpShape, o2 as cpShape, s, (ShapeQueryContext)o3)
                                         , ctx);
            } Unlock(true);

            return(((ShapeQueryContext)ctx).anyCollision);
        }
Example #3
0
        public ulong ShapeQueryFunc(cpShape a, cpShape b, ulong id, ShapeQueryContext context)
        {
            if (cpShapeFilter.Reject(a.filter, b.filter) || a == b) return id;

            List<cpContact> contacts = new List<cpContact>();
            cpContactPointSet set = cpShape.Collide(a, b, ref contacts);

            if (set.count > 0)
            {
                if (context.func != null) context.func(b, set, context.data);
                context.anyCollision = !(a.sensor || b.sensor);
            }
            return id;
        }
Example #4
0
        public bool ShapeQuery(cpShape shape, Action<cpShape, cpContactPointSet, object> func, object data)
        {
            cpBody body = shape.body;
            cpBB bb = (body != null ? shape.Update(body.transform) : shape.bb);
            ShapeQueryContext context = new ShapeQueryContext(func, data, false);

            object ctx = (object)context;

            Lock();
            {

                this.staticShapes.Query(shape, bb,
                    (o1, o2, s, o3) => ShapeQueryFunc(o1 as cpShape, o2 as cpShape, s, (ShapeQueryContext)o3)
                , ctx);

                this.dynamicShapes.Query(shape, bb,
                    (o1, o2, s, o3) => ShapeQueryFunc(o1 as cpShape, o2 as cpShape, s, (ShapeQueryContext)o3)
                , ctx);

            } Unlock(true);

            return ((ShapeQueryContext)ctx).anyCollision;
        }