Exemple #1
0
 public Collision CompleteAndAdd(Collision it, int inflate = 0)
 {
     buildHelper.CompleteBBox(it, inflate);
     buildHelper.CompletePlane(it);
     CollisionList.Add(it);
     return(it);
 }
Exemple #2
0
        private void generateCollision()
        {
            int            lineCount = 0;
            int            tileGap;
            CollisionTiles currTile, firstTile, prevTile;

            prevTile = new CollisionTiles(0, new Rectangle(0, 0, 32, 32), null);

            for (int x = 0; x < m_collisionTiles.Count; x++)
            {
                currTile = m_collisionTiles[x];
                tileGap  = currTile.Rectangle.X - prevTile.Rectangle.X;


                if (currTile.Rectangle.Y >= 4000)
                {
                }

                if (currTile.Rectangle.Y == prevTile.Rectangle.Y)
                {
                    if (lineCount == 0)
                    {
                        firstTile = currTile;
                    }

                    if ((tileGap > 33) && (lineCount > 0))
                    {
                        firstTile = m_collisionTiles[x - lineCount];
                        CollisionList.Add(new BoundingBox(new Vector3(firstTile.Rectangle.X - 32, firstTile.Rectangle.Y, 0),
                                                          new Vector3(prevTile.Rectangle.X + prevTile.Rectangle.Width, prevTile.Rectangle.Y + prevTile.Rectangle.Height, 0)));
                        Thread.Sleep(10);
                        lineCount = 0;
                    }
                    else
                    {
                        lineCount++;
                    }
                }
                else
                {
                    firstTile = m_collisionTiles[x - lineCount];
                    CollisionList.Add(new BoundingBox(new Vector3(firstTile.Rectangle.X - 32, firstTile.Rectangle.Y, 0),
                                                      new Vector3(prevTile.Rectangle.X + prevTile.Rectangle.Width, prevTile.Rectangle.Y + prevTile.Rectangle.Height, 0)));
                    Thread.Sleep(10);
                    lineCount = 0;
                }
                prevTile = currTile;
            }
            lineCount = 0;
        }
Exemple #3
0
        /// <summary>
        /// Adds a new vertex to the TTM
        /// </summary>
        /// <returns></returns>
        public TriVertex AddPoint(double X, double Y, double Z)
        {
            TriVertex Result = SearchForPoint(X, Y, Z, out int HashIdx);

            if (Result == null)
            {
                Result = CreateVertex(X, Y, Z);
                Add(Result);

                List <TriVertex> CollisionList = HashArray[HashIdx];

                // Add the item to the collision list for this HashIndex, creating a new one
                // if no hashed item has been added to this entry.
                if (CollisionList == null)
                {
                    CollisionList      = new List <TriVertex>();
                    HashArray[HashIdx] = CollisionList;
                }

                CollisionList.Add(Result);
            }

            return(Result);
        }