Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 internal Grid(Geometry geometry, float gridCellSize, float padding, bool primeTheGrid)
 {
     GridConstructor(geometry, gridCellSize, padding, primeTheGrid);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 private void GridConstructor(Geometry geometry, float gridCellSize, float padding, bool primeTheGrid)
 {
     _geometry = geometry;
     _padding = padding;
     GridCellSize = gridCellSize;
     Initialize();
     if (primeTheGrid) {
         Prime();
     }
 }