internal void Prime(Geometry geometry) { _isOutside = true; if (_isPrimed) return; for (int i = 0; i < 4; i++) { _gridPoints[i].Prime(geometry); if (!_gridPoints[i].IsOutside) { _isOutside = false; } } _isPrimed = true; }
internal void Prime(Geometry geometry) { //Calculate signed distance and normal if (_isPrimed) return; Feature nearestFeature = geometry.GetNearestFeature(_position); //determine if inside or outside of geometry. Vector2 pointToFeaturePosition = Vector2.Subtract(_position, nearestFeature.Position); float dot = Vector2.Dot(pointToFeaturePosition, nearestFeature.Normal); if (dot < 0) { _distance = -nearestFeature.Distance; } else { _distance = nearestFeature.Distance; } _isPrimed = true; }
internal Grid(Geometry geometry, float gridCellSize, float padding, bool primeTheGrid) { GridConstructor(geometry, gridCellSize, padding, primeTheGrid); }
internal Grid(Geometry geometry, float gridCellSize, bool primeTheGrid) { if (geometry.LocalVertices.Count < 3) { throw new InvalidOperationException("A grid can only be constructed for geometries with 3 vertices or more"); } GridConstructor(geometry,gridCellSize, 0, primeTheGrid); }
private void GridConstructor(Geometry geometry, float gridCellSize, float padding, bool primeTheGrid) { _geometry = geometry; _padding = padding; GridCellSize = gridCellSize; Initialize(); if (primeTheGrid) { Prime(); } }