예제 #1
0
        /** Searches for physics shapes that intersects the ray. */
        public void RayCast(Func <CCPhysicsWorld, CCPhysicsRayCastInfo, object, bool> func, CCPoint point1, CCPoint point2, object data)
        {
            cp.AssertWarn(func != null, "func shouldn't be nullptr");

            if (func != null)
            {
                CCRayCastCallbackInfo info = new CCRayCastCallbackInfo(this, func, point1, point2, data);
                //Action<cpShape, cpVect, cpVect, float, object> func
                CCPhysicsWorldCallback.continues = true;

                this._info.getSpace().SegmentQuery(
                    PhysicsHelper.CCPointToCpVect(point1),
                    PhysicsHelper.CCPointToCpVect(point2), 1f,
                    new cpShapeFilter(cp.NO_GROUP, cp.ALL_LAYERS, cp.ALL_LAYERS),
                    (shape, v1, v2, f, o) => CCPhysicsWorldCallback.RayCastCallbackFunc(shape, f, PhysicsHelper.cpVectToCCPoint(v1), ref info), data
                    );
            }
        }
예제 #2
0
        public static void RayCastCallbackFunc(cpShape shape, float t, CCPoint n, ref CCRayCastCallbackInfo info)
        {
            if (!continues)
            {
                return;
            }

            CCPhysicsShapeInfo it;

            cp.AssertWarn(!CCPhysicsShapeInfo.Map.TryGetValue(shape, out it));

            CCPhysicsRayCastInfo callbackInfo = new CCPhysicsRayCastInfo(
                it.getShape(),
                info.p1,
                info.p2,
                new CCPoint(info.p1.X + (info.p2.X - info.p1.X) * t, info.p1.Y + (info.p2.Y - info.p1.Y) * t),
                new CCPoint(n.Y, n.Y),
                t, null
                );

            continues = info.func(info.world, callbackInfo, info.data);
        }
예제 #3
0
        public static void RayCastCallbackFunc(cpShape shape, float t, CCPoint n, ref CCRayCastCallbackInfo info)
        {
            if (!Continues)
            {
                return;
            }

            CCPhysicsShapeInfo it;

            cp.AssertWarn(!CCPhysicsShapeInfo.Map.TryGetValue(shape, out it));

            CCPhysicsRayCastInfo callbackInfo = new CCPhysicsRayCastInfo(
                it.Shape,
                info.Pont1,
                info.Point2,
                new CCPoint(info.Pont1.X + (info.Point2.X - info.Pont1.X) * t, info.Pont1.Y + (info.Point2.Y - info.Pont1.Y) * t),
                new CCPoint(n.Y, n.Y),
                t, null
                );

            Continues = info.Function(info.World, callbackInfo, info.Data);
        }
예제 #4
0
		/** Searches for physics shapes that intersects the ray. */
		public void RayCast(Func<CCPhysicsWorld, CCPhysicsRayCastInfo, object, bool> func, CCPoint point1, CCPoint point2, object data)
		{
			cp.AssertWarn(func != null, "func shouldn't be nullptr");

			if (func != null)
			{
				CCRayCastCallbackInfo info = new CCRayCastCallbackInfo(this, func, point1, point2, data);
				//Action<cpShape, cpVect, cpVect, float, object> func
				CCPhysicsWorldCallback.continues = true;

				this._info.getSpace().SegmentQuery(
                    PhysicsHelper.CCPointToCpVect(point1),
                    PhysicsHelper.CCPointToCpVect(point2), 1f,
									new cpShapeFilter(cp.NO_GROUP, cp.ALL_LAYERS, cp.ALL_LAYERS),
                    (shape, v1, v2, f, o) => CCPhysicsWorldCallback.RayCastCallbackFunc(shape, f, PhysicsHelper.cpVectToCCPoint(v1), ref info), data
									);
			}
		}
예제 #5
0
		public static void RayCastCallbackFunc(cpShape shape, float t, CCPoint n, ref CCRayCastCallbackInfo info)
		{
			if (!continues)
			{
				return;
			}

			CCPhysicsShapeInfo it;

			cp.AssertWarn(!CCPhysicsShapeInfo.Map.TryGetValue(shape, out it));

			CCPhysicsRayCastInfo callbackInfo = new CCPhysicsRayCastInfo(
		it.getShape(),
		info.p1,
		info.p2,
		new CCPoint(info.p1.X + (info.p2.X - info.p1.X) * t, info.p1.Y + (info.p2.Y - info.p1.Y) * t),
		 new CCPoint(n.Y, n.Y),
		t, null
	);

			continues = info.func(info.world, callbackInfo, info.data);
		}
예제 #6
0
		public static void RayCastCallbackFunc(cpShape shape, float t, CCPoint n, ref CCRayCastCallbackInfo info)
		{
			if (!Continues)
			{
				return;
			}

			CCPhysicsShapeInfo it;

			cp.AssertWarn(!CCPhysicsShapeInfo.Map.TryGetValue(shape, out it));

			CCPhysicsRayCastInfo callbackInfo = new CCPhysicsRayCastInfo(
        		it.Shape,
        		info.Pont1,
        		info.Point2,
        		new CCPoint(info.Pont1.X + (info.Point2.X - info.Pont1.X) * t, info.Pont1.Y + (info.Point2.Y - info.Pont1.Y) * t),
        		 new CCPoint(n.Y, n.Y),
        		t, null
        	);

			Continues = info.Function(info.World, callbackInfo, info.Data);
		}