UnityEngine.Mathf.FloorToInt C# (CSharp) Method

FloorToInt() public static method

public static FloorToInt ( float f ) : int
f float
return int
        public static int FloorToInt(float f)
        {
            return (int)Math.Floor(f);
        }

Usage Example

コード例 #1
0
        /** Returns a rect containing the indices of all tiles touching the specified bounds.
         * \param rect Graph space rectangle (in graph space all tiles are on the XZ plane regardless of graph rotation and other transformations, the first tile has a corner at the origin)
         */
        public static IntRect GetTouchingTilesInGraphSpace(this NavmeshBase self, Rect rect)
        {
            // Calculate world bounds of all affected tiles
            var r = new IntRect(Mathf.FloorToInt(rect.xMin / self.TileWorldSizeX), Mathf.FloorToInt(rect.yMin / self.TileWorldSizeZ), Mathf.FloorToInt(rect.xMax / self.TileWorldSizeX), Mathf.FloorToInt(rect.yMax / self.TileWorldSizeZ));

            // Clamp to bounds
            r = IntRect.Intersection(r, new IntRect(0, 0, self.tileXCount - 1, self.tileZCount - 1));
            return(r);
        }
All Usage Examples Of UnityEngine.Mathf::FloorToInt