示例#1
0
        public void Validate()
        {
            if (!IsValid)
            {
                return;
            }

            if (version != kLatestVersion)
            {
                version = kLatestVersion;
            }

            brushOutline.CalculatePlanes();

            // If the brush is concave, we set the generator to not be valid, so that when we commit, it will be reverted
            validState = brushOutline.HasVolume() &&            // TODO: implement this, so we know if a brush is a 0D/1D/2D shape
                         !brushOutline.IsConcave() &&           // TODO: eventually allow concave shapes
                         !brushOutline.IsSelfIntersecting();    // TODO: in which case this needs to be implemented

            // TODO: shouldn't do this all the time:
            {
                // Detect if outline is inside-out and if so, just invert all polygons.
                isInsideOut = brushOutline.IsInsideOut();
                if (isInsideOut)
                {
                    brushOutline.Invert();
                    isInsideOut = false;
                }
            }
        }
        public void Validate()
        {
            if (!IsValid)
            {
                return;
            }

            if (version != kLatestVersion)
            {
                version           = kLatestVersion;
                surfaceDefinition = null;
            }

            if (surfaceDefinition == null)
            {
                surfaceDefinition = new ChiselSurfaceDefinition();
                surfaceDefinition.EnsureSize(brushOutline.polygons.Length);
                if (brushOutline.polygons.Length > 0)
                {
                    for (int p = 0; p < brushOutline.polygons.Length; p++)
                    {
                        surfaceDefinition.surfaces[p].surfaceDescription = brushOutline.polygons[p].surface.surfaceDescription;
                        surfaceDefinition.surfaces[p].brushMaterial      = brushOutline.polygons[p].surface.brushMaterial;
                    }
                }
            }
            else
            {
                surfaceDefinition.EnsureSize(brushOutline.polygons.Length);
            }

            // Temporary fix for misformed brushes
            for (int i = 0; i < brushOutline.polygons.Length; i++)
            {
                brushOutline.polygons[i].surfaceID = i;
            }

            brushOutline.CalculatePlanes();

            // If the brush is concave, we set the generator to not be valid, so that when we commit, it will be reverted
            validState = brushOutline.HasVolume() &&            // TODO: implement this, so we know if a brush is a 0D/1D/2D shape
                         !brushOutline.IsConcave() &&           // TODO: eventually allow concave shapes
                         !brushOutline.IsSelfIntersecting();    // TODO: in which case this needs to be implemented

            // TODO: shouldn't do this all the time:
            {
                // Detect if outline is inside-out and if so, just invert all polygons.
                isInsideOut = brushOutline.IsInsideOut();
                if (isInsideOut)
                {
                    brushOutline.Invert();
                    isInsideOut = false;
                }
            }
        }