Ejemplo n.º 1
0
        public cpShape PointQueryNearest(cpVect point, float maxDistance, cpShapeFilter filter, ref cpPointQueryInfo output)
        {
            cpPointQueryInfo info = new cpPointQueryInfo(null, cpVect.Zero, maxDistance, cpVect.Zero);

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

            PointQueryContext context = new PointQueryContext(
                point, maxDistance,
                filter,
                null
                );

            cpBB bb = cpBB.cpBBNewForCircle(point, cp.cpfmax(maxDistance, 0.0f));

            object outp = (object)output;

            this.dynamicShapes.Query(context, bb,
                                     (o1, o2, s, o3) => NearestPointQueryNearest(o1, (cpShape)o2, s, ref outp)
                                     , null);

            this.staticShapes.Query(context, bb,
                                    (o1, o2, s, o3) => NearestPointQueryNearest(o1, (cpShape)o2, s, ref outp)
                                    , null);

            output = (cpPointQueryInfo)outp;

            return(output.shape);
        }
Ejemplo n.º 2
0
        public cpShape(cpBody body, cpShapeMassInfo massInfo)
        {
            /// The rigid body this collision shape is attached to.
            this.body = body;

            this.massInfo = massInfo;

            /// The current bounding box of the shape.
            /// The current bounding box of the shape.
            ///
            //this.bb_l = this.bb_b = this.bb_r = this.bb_t = 0;
            this.bb = new cpBB(0, 0, 0, 0);

            //this.hashid = (cp.shapeIDCounter++).ToString();

            /// Sensor flag.
            /// Sensor shapes call collision callbacks but don't produce collisions.
            this.sensor = false;

            filter = new cpShapeFilter(cp.NO_GROUP, cp.ALL_CATEGORIES, cp.ALL_CATEGORIES);


            /// Coefficient of restitution. (elasticity)
            this.e = 0;
            /// Coefficient of friction.
            this.u = 0;
            /// Surface velocity used when solving for friction.
            this.surfaceV = cpVect.Zero;

            /// Collision type of this shape used when picking collision handlers.
            this.type = 0;

            this.space = null;
        }
Ejemplo n.º 3
0
 public BBQueryContext(cpBB bb1, cpShapeFilter filter1, Action <cpShape, object> func1)
 {
     // TODO: Complete member initialization
     this.bb     = bb1;
     this.filter = filter1;
     this.func   = func1;
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 public BBQueryContext(cpBB bb1, cpShapeFilter filter1, Action<cpShape, object> func1)
 {
     // TODO: Complete member initialization
     this.bb = bb1;
     this.filter = filter1;
     this.func = func1;
 }
Ejemplo n.º 6
0
 public PointQueryContext(cpVect point1, float maxDistance1, cpShapeFilter filter1, Action <cpShape, cpVect, float, cpVect, object> func1)
 {
     // TODO: Complete member initialization
     this.point       = point1;
     this.maxDistance = maxDistance1;
     this.filter      = filter1;
     this.func        = func1;
 }
Ejemplo n.º 7
0
 public PointQueryContext(cpVect point1, float maxDistance1, cpShapeFilter filter1, Action<cpShape, cpVect, float, cpVect, object> func1)
 {
     // TODO: Complete member initialization
     this.point = point1;
     this.maxDistance = maxDistance1;
     this.filter = filter1;
     this.func = func1;
 }
Ejemplo n.º 8
0
 public SegmentQueryContext(cpVect start1, cpVect end1, float radius1, cpShapeFilter filter1, Action <cpShape, cpVect, cpVect, float, object> func1)
 {
     // TODO: Complete member initialization
     this.start  = start1;
     this.end    = end1;
     this.radius = radius1;
     this.filter = filter1;
     this.func   = func1;
 }
Ejemplo n.º 9
0
        public void PointQuery(cpVect point, float maxDistance, cpShapeFilter filter, Action <cpShape, cpVect, float, cpVect, object> func, object data)
        {
            PointQueryContext context = new PointQueryContext(point, maxDistance, filter, func);
            cpBB bb = cpBB.cpBBNewForCircle(point, cp.cpfmax(maxDistance, 0.0f));

            Lock();
            {
                this.staticShapes.Query(context, bb, (ctx, shape, colid, o) => NearestPointQuery((PointQueryContext)ctx, shape as cpShape, colid, o), data);
                this.dynamicShapes.Query(context, bb, (ctx, shape, colid, o) => NearestPointQuery((PointQueryContext)ctx, shape as cpShape, colid, o), data);
            } Unlock(true);
        }
Ejemplo n.º 10
0
 public static bool Reject(cpShapeFilter a, cpShapeFilter b)
 {
     // Reject the collision if:
     return(
         // They are in the same non-zero group.
         (a.group != 0 && a.group == b.group) ||
         // One of the category/mask combinations fails.
         (a.categories & b.mask) == 0 ||
         (b.categories & a.mask) == 0
         );
 }
Ejemplo n.º 11
0
        public void BBQuery(cpBB bb, cpShapeFilter filter, Action <cpShape, object> func, object data)
        {
            BBQueryContext context = new BBQueryContext(bb, filter, func);

            Lock();
            {
                this.staticShapes.Query(context, bb, (o1, o2, s, o3) =>

                                        BBQueryFunc((BBQueryContext)o1, o2 as cpShape, s, o3)
                                        , data);

                this.dynamicShapes.Query(context, bb, (o1, o2, s, o3) =>

                                         BBQueryFunc((BBQueryContext)o1, o2 as cpShape, s, o3)
                                         , data);
            } Unlock(true);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 public bool Reject(cpShapeFilter b)
 {
     return Reject(this, b);
 }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        public cpShape PointQueryNearest(cpVect point, float maxDistance, cpShapeFilter filter, ref cpPointQueryInfo output)
        {
            cpPointQueryInfo info = new cpPointQueryInfo(null, cpVect.Zero, maxDistance, cpVect.Zero);
            if (output == null)
                output = info;

            PointQueryContext context = new PointQueryContext(
            point, maxDistance,
            filter,
            null
            );

            cpBB bb = cpBB.cpBBNewForCircle(point, cp.cpfmax(maxDistance, 0.0f));

            object outp = (object)output;

            this.dynamicShapes.Query(context, bb,
                (o1, o2, s, o3) => NearestPointQueryNearest(o1, (cpShape)o2, s, ref outp)
            , null);

            this.staticShapes.Query(context, bb,
                (o1, o2, s, o3) => NearestPointQueryNearest(o1, (cpShape)o2, s, ref outp)
            , null);

            output = (cpPointQueryInfo)outp;

            return output.shape;
        }
Ejemplo n.º 17
0
        public void PointQuery(cpVect point, float maxDistance, cpShapeFilter filter, Action<cpShape, cpVect, float, cpVect, object> func, object data)
        {
            PointQueryContext context = new PointQueryContext(point, maxDistance, filter, func);
            cpBB bb = cpBB.cpBBNewForCircle(point, cp.cpfmax(maxDistance, 0.0f));

            Lock();
            {
                this.staticShapes.Query(context, bb, (ctx, shape, colid, o) => NearestPointQuery((PointQueryContext)ctx, shape as cpShape, colid, o), data);
                this.dynamicShapes.Query(context, bb, (ctx, shape, colid, o) => NearestPointQuery((PointQueryContext)ctx, shape as cpShape, colid, o), data);
            } Unlock(true);
        }
Ejemplo n.º 18
0
 public void SetFilter(cpShapeFilter filter)
 {
     body.Activate();
     this.filter = filter;
 }
Ejemplo n.º 19
0
 public SegmentQueryContext(cpVect start1, cpVect end1, float radius1, cpShapeFilter filter1, Action<cpShape, cpVect, cpVect, float, object> func1)
 {
     // TODO: Complete member initialization
     this.start = start1;
     this.end = end1;
     this.radius = radius1;
     this.filter = filter1;
     this.func = func1;
 }
Ejemplo n.º 20
0
        public cpShape(cpBody body, cpShapeMassInfo massInfo)
        {
            /// The rigid body this collision shape is attached to.
            this.body = body;

            this.massInfo = massInfo;

            /// The current bounding box of the shape.
            /// The current bounding box of the shape.
            ///
            //this.bb_l = this.bb_b = this.bb_r = this.bb_t = 0;
            this.bb = new cpBB(0, 0, 0, 0);

            //this.hashid = (cp.shapeIDCounter++).ToString();

            /// Sensor flag.
            /// Sensor shapes call collision callbacks but don't produce collisions.
            this.sensor = false;

            filter = new cpShapeFilter(cp.NO_GROUP, cp.ALL_CATEGORIES, cp.ALL_CATEGORIES);

            /// Coefficient of restitution. (elasticity)
            this.e = 0;
            /// Coefficient of friction.
            this.u = 0;
            /// Surface velocity used when solving for friction.
            this.surfaceV = cpVect.Zero;

            /// Collision type of this shape used when picking collision handlers.
            this.type = 0;

            this.space = null;
        }
Ejemplo n.º 21
0
 public void SetFilter(cpShapeFilter filter)
 {
     body.Activate();
     this.filter = filter;
 }
Ejemplo n.º 22
0
 public static bool Reject(cpShapeFilter a, cpShapeFilter b)
 {
     // Reject the collision if:
     return (
         // They are in the same non-zero group.
         (a.group != 0 && a.group == b.group) ||
         // One of the category/mask combinations fails.
         (a.categories & b.mask) == 0 ||
         (b.categories & a.mask) == 0
     );
 }
Ejemplo n.º 23
0
 public bool Reject(cpShapeFilter b)
 {
     return(Reject(this, b));
 }
Ejemplo n.º 24
0
		public void SetFilter(cpShapeFilter filter)
		{
			SetGroup(filter.group);
			SetCategoryBitmask(filter.categories);
			SetCollisionBitmask(filter.mask);
		}
Ejemplo n.º 25
0
        public void BBQuery(cpBB bb, cpShapeFilter filter, Action<cpShape, object> func, object data)
        {
            BBQueryContext context = new BBQueryContext(bb, filter, func);

            Lock();
            {

                this.staticShapes.Query(context, bb, (o1, o2, s, o3) =>

                    BBQueryFunc((BBQueryContext)o1, o2 as cpShape, s, o3)
                , data);

                this.dynamicShapes.Query(context, bb, (o1, o2, s, o3) =>

                    BBQueryFunc((BBQueryContext)o1, o2 as cpShape, s, o3)
                , data);

            } Unlock(true);
        }