Treasure chest of Unity developer tools. Professional inspector tooling, high-performance utilities, spatial queries, and 20+ editor tools.
This guide explains convex and concave hulls, when to use each, and how they differ.
Illustration:
Illustration:
All hull helpers now offer both grid-aware (Grid + FastVector3Int) and gridless variants so you can work directly with Vector2/FastVector3Int data:
points.BuildConvexHull(includeColinearPoints: false) for pure Vector2.fastPoints.BuildConvexHull(includeColinearPoints: false) for FastVector3Int without a Grid.fastPoints.BuildConvexHull(grid, includeColinearPoints: false) when you need Grid.CellToWorld conversions.ConvexHullAlgorithm is available for both gridful and gridless overloads.vectorPoints.BuildConcaveHull(options) / BuildConcaveHullKnn / BuildConcaveHullEdgeSplit for Vector2.fastPoints.BuildConcaveHull(options) plus the Knn/EdgeSplit helpers for FastVector3Int without requiring a Grid.fastPoints.BuildConcaveHull(grid, options) remains available when your data lives in grid space.⚠️ The legacy line-division overload
BuildConcaveHull(IEnumerable<FastVector3Int>, Grid, float scaleFactor, float concavity)has been retired and now throwsNotSupportedException. Switch toConcaveHullStrategy.KnnorConcaveHullStrategy.EdgeSplitinstead.
Because the new overloads reuse the pooled implementations under the hood, behaviour (winding, pruning, GC profile) matches the grid versions—pick whichever signature best matches your data source.
Vector2, Vector3, or FastVector3Int without a Grid). This keeps the hull math independent of Unity’s tile conversion layer.Grid or Tilemap and you want the helper to respect Grid.CellToWorld so you can visualize the hull in scene space.Gridless example — pure Vector2 data for nav areas or spline fitting:
using System.Collections.Generic;
using UnityEngine;
using WallstopStudios.UnityHelpers.Core.Extension;
// outlinePoints could come from mouse clicks or a baked spline
List<Vector2> outlinePoints = CollectOutlineSamples();
UnityExtensions.ConcaveHullOptions outlineOptions = UnityExtensions.ConcaveHullOptions.Default
.WithStrategy(UnityExtensions.ConcaveHullStrategy.EdgeSplit)
.WithBucketSize(32)
.WithAngleThreshold(70f);
List<Vector2> hull = outlinePoints.BuildConcaveHull(outlineOptions);
Grid-aware example — FastVector3Int tiles aligned to a Grid for tilemaps or voxel data:
using System.Collections.Generic;
using UnityEngine;
using WallstopStudios.UnityHelpers.Core.DataStructure.Adapters;
using WallstopStudios.UnityHelpers.Core.Extension;
Grid grid = GetComponent<Grid>();
List<FastVector3Int> tileSamples = CollectTileCoordinates();
UnityExtensions.ConcaveHullOptions tileOptions = UnityExtensions.ConcaveHullOptions.Default
.WithStrategy(UnityExtensions.ConcaveHullStrategy.Knn)
.WithNearestNeighbors(5);
List<FastVector3Int> gridHull = tileSamples.BuildConcaveHull(grid, tileOptions);
See Samples~/Spatial Structures - 2D and 3D/Scripts/HullUsageDemo.cs for a runnable MonoBehaviour that draws both loops (cyan for gridless, yellow for grid-aware) and logs the strategy/neighbor counts so you can copy the pattern directly into your own tooling, or just open Samples~/Spatial Structures - 2D and 3D/Scenes/HullUsageDemo.unity and press Play to watch both flows without extra setup.
includeColinearPoints: true to BuildConvexHull (gridless) or its grid-aware overloads.UnityExtensionsComprehensiveTests.ConvexHullDenseSamplesOnAllEdgesCollapseToCorners (grid) and .Vector2ConvexHullDenseSamplesCollapseToCorners (gridless) cover both paths so you can trust the deterministic behavior.List<FastVector3Int> cornersOnly = gridPoints.BuildConvexHull(grid, includeColinearPoints: false);
List<FastVector3Int> withEdges = gridPoints.BuildConvexHull(grid, includeColinearPoints: true);