Beispiel #1
0
        static void RayTest_PostProcess(Physics2DRayTestItem item, List <Physics2DRayTestItem.ResultItem> resultList)
        {
            if (resultList.Count == 0)
            {
                item.Result = Array.Empty <Physics2DRayTestItem.ResultItem>();
                return;
            }

            if (item.Mode == Physics2DRayTestItem.ModeEnum.OneClosest || item.Mode == Physics2DRayTestItem.ModeEnum.One)
            {
                item.Result = new Physics2DRayTestItem.ResultItem[] { resultList[0] };
                return;
            }

            if (item.Mode == Physics2DRayTestItem.ModeEnum.OneForEach)
            {
                item.Result = GetResultsOnePerShape(resultList);
                return;
            }

            //sort by distance in any other case
            CollectionUtility.SelectionSort(resultList, Compare);

            if (item.Mode == Physics2DRayTestItem.ModeEnum.All)
            {
                item.Result = resultList.ToArray();
                return;
            }

            //item.Mode == PhysicsRayTestItem.ModeEnum.OneClosestForEach
            item.Result = GetResultsOnePerShape(resultList);
        }
Beispiel #2
0
        static bool ShouldCollide(Fixture fixture, Physics2DRayTestItem item)
        {
            if (fixture.CollisionGroup != 0 && fixture.CollisionGroup == item.CollisionGroup)
            {
                return(fixture.CollisionGroup > 0);
            }

            bool collide =
                ((fixture.CollidesWith & item.CollisionCategories) != 0) &&
                ((item.CollidesWith & fixture.CollisionCategories) != 0);

            return(collide);
        }
Beispiel #3
0
 public static void Physics2DRayTest(this Component_Scene scene, Physics2DRayTestItem item)
 {
     Physics2DRayTest(scene, new Physics2DRayTestItem[] { item });
 }