コード例 #1
0
        public static void PartitionObject(LSBody Body, bool gridBoundsCalculated = false)
        {
            if (gridBoundsCalculated == false)
            {
                GetGridBounds(Body);
            }

            Body.PastGridXMin = GridXMin;
            Body.PastGridXMax = GridXMax;
            Body.PastGridYMin = GridYMin;
            Body.PastGridYMax = GridYMax;

            for (int i = GridXMin; i <= GridXMax; i++)
            {
                for (int j = GridYMin; j <= GridYMax; j++)
                {
                    PartitionNode node = GetNode(i, j);
                    Body.PartitionChanged = true;
                    if (Body.Immovable)
                    {
                        node.AddImmovable(Body.ID);
                    }
                    else
                    {
                        node.Add(Body.ID);
                    }
                }
            }
        }
コード例 #2
0
        public static void UpdateObject(LSBody Body)
        {
            GridXMin = (Body.XMin - OffsetX) >> ShiftSize;
            GridXMax = ((Body.XMax - OffsetX) >> ShiftSize);
            GridYMin = ((Body.YMin - OffsetY) >> ShiftSize);
            GridYMax = ((Body.YMax - OffsetY) >> ShiftSize);
                        #if UNITY_EDITOR
            if (GridXMin < 0 || GridXMax >= Count || GridYMin < 0 || GridYMax >= Count)
            {
                Debug.LogError("Body with ID " + Body.ID.ToString() + " is out of partition bounds.");
                return;
            }
                        #endif
            if (Body.PastGridXMin != GridXMin ||
                Body.PastGridXMax != GridXMax ||
                Body.PastGridYMin != GridYMin ||
                Body.PastGridYMax != GridYMax)
            {
                for (long o = Body.PastGridXMin; o <= Body.PastGridXMax; o++)
                {
                    for (long p = Body.PastGridYMin; p <= Body.PastGridYMax; p++)
                    {
                        PartitionNode node = Nodes [o * Count + p];

                        node.Remove(Body.ID);
                    }
                }

                for (long i = GridXMin; i <= GridXMax; i++)
                {
                    for (long j = GridYMin; j <= GridYMax; j++)
                    {
                        PartitionNode node = Nodes [i * Count + j];

                        node.Add(Body.ID);
                    }
                }


                Body.PastGridXMin = GridXMin;
                Body.PastGridXMax = GridXMax;
                Body.PastGridYMin = GridYMin;
                Body.PastGridYMax = GridYMax;
            }
        }
コード例 #3
0
        public static void PartitionObject(LSBody Body)
        {
            GetGridBounds(Body);

            Body.PastGridXMin = GridXMin;
            Body.PastGridXMax = GridXMax;
            Body.PastGridYMin = GridYMin;
            Body.PastGridYMax = GridYMax;

            for (int i = GridXMin; i <= GridXMax; i++)
            {
                for (int j = GridYMin; j <= GridYMax; j++)
                {
                    PartitionNode node = GetNode(i, j);
                    node.Add(Body.ID);
                }
            }
        }
コード例 #4
0
 public static void PartitionObject(LSBody Body)
 {
     GridXMin          = ((Body.XMin - OffsetX) >> ShiftSize);
     GridXMax          = ((Body.XMax - OffsetX) >> ShiftSize);
     GridYMin          = ((Body.YMin - OffsetY) >> ShiftSize);
     GridYMax          = ((Body.YMax - OffsetY) >> ShiftSize);
     Body.PastGridXMin = GridXMin;
     Body.PastGridXMax = GridXMax;
     Body.PastGridYMin = GridYMin;
     Body.PastGridYMax = GridYMax;
     for (long i = GridXMin; i <= GridXMax; i++)
     {
         for (long j = GridYMin; j <= GridYMax; j++)
         {
             PartitionNode node = Nodes [i * Count + j];
             node.Add(Body.ID);
         }
     }
 }
コード例 #5
0
        public static void UpdateObject(LSBody Body)
        {
            GetGridBounds(Body);


            if (Body.PastGridXMin != GridXMin ||
                Body.PastGridXMax != GridXMax ||
                Body.PastGridYMin != GridYMin ||
                Body.PastGridYMax != GridYMax)
            {
                for (int o = Body.PastGridXMin; o <= Body.PastGridXMax; o++)
                {
                    for (int p = Body.PastGridYMin; p <= Body.PastGridYMax; p++)
                    {
                        PartitionNode node = GetNode(o, p);
                        node.Remove(Body.ID);
                    }
                }

                for (int i = GridXMin; i <= GridXMax; i++)
                {
                    for (int j = GridYMin; j <= GridYMax; j++)
                    {
                        PartitionNode node = GetNode(i, j);

                        node.Add(Body.ID);
                    }
                }


                Body.PastGridXMin = GridXMin;
                Body.PastGridXMax = GridXMax;
                Body.PastGridYMin = GridYMin;
                Body.PastGridYMax = GridYMax;
            }
        }
コード例 #6
0
        public static void PartitionObject(LSBody Body)
        {
            GridXMin = Body.XMin <= Body.FutureXMin ? ((Body.XMin - OffsetX) >> ShiftSize) : ((Body.FutureXMin - OffsetX) >> ShiftSize);
            GridXMax = Body.XMax >= Body.FutureXMax ? ((Body.XMax - OffsetX) >> ShiftSize) : ((Body.FutureXMax - OffsetX) >> ShiftSize);
            GridYMin = Body.YMin <= Body.FutureXMin ? ((Body.YMin - OffsetY) >> ShiftSize) : ((Body.FutureYMin - OffsetY) >> ShiftSize);
            GridYMax = Body.YMax >= Body.FutureYMax ? ((Body.YMax - OffsetY) >> ShiftSize) : ((Body.FutureYMax - OffsetY) >> ShiftSize);
            #if UNITY_EDITOR
            if (GridXMin < 0 || GridXMax >= Count || GridYMin < 0 || GridYMax >= Count)
            {
                Debug.LogError ("Body with ID " + Body.ID.ToString () + " is out of partition bounds.");
                return;
            }
            #endif
            if (Body.PastGridXMin != GridXMin ||
                Body.PastGridXMax != GridXMax ||
                Body.PastGridYMin != GridYMin ||
                Body.PastGridYMax != GridYMax) {
                for (o = Body.PastGridXMin; o <= Body.PastGridXMax; o++) {
                    for (p = Body.PastGridYMin; p <= Body.PastGridYMax; p++) {
                        node = Nodes [o * Count + p];

                        node.Remove (Body.ID);
                    }
                }

                for (i = GridXMin; i <= GridXMax; i++) {
                    for (j = GridYMin; j <= GridYMax; j++) {
                        node = Nodes [i * Count + j];

                        node.Add (Body.ID);
                    }
                }

                Body.PastGridXMin = GridXMin;
                Body.PastGridXMax = GridXMax;
                Body.PastGridYMin = GridYMin;
                Body.PastGridYMax = GridYMax;
            }
        }