Пример #1
0
		internal override bool UpdateBaseShape(bool registerUndo = true)
		{
			List<ShapePolygon> newPolygons = null;
			var outlineVertices = settings.GetVertices(buildPlane, worldPosition, base.gridTangent, base.gridBinormal, out shapeIsValid);
			if (shapeIsValid)
			{
				newPolygons = ShapePolygonUtility.CreateCleanPolygonsFromVertices(outlineVertices, brushPosition, buildPlane);
				shapeIsValid = newPolygons != null;
			}
			//CSGBrushEditorManager.ResetMessage();

			if (shapeIsValid && newPolygons != null)
				UpdatePolygons(outlineVertices, newPolygons.ToArray());

			if (editMode != EditMode.EditShape &&
				editMode != EditMode.ExtrudeShape)
				return false;

			if (!shapeIsValid || !HaveExtrusion)
				return true;

			GenerateBrushesFromPolygons(inGridSpace: false);
			UpdateExtrudedShape();
			return true;
		}
Пример #2
0
        internal override bool StartExtrudeMode(bool showErrorMessage = true)
        {
            // reverse buildPlane if it's different
            if (BuildPlaneIsReversed)
            {
                buildPlane = buildPlane.Negated();
                CalculateWorldSpaceTangents();
            }

            var outlineVertices = settings.GetVertices(buildPlane, worldPosition, base.gridTangent, base.gridBinormal, out shapeIsValid);

            if (!shapeIsValid)
            {
                ClearPolygons();
                //if (showErrorMessage)
                //	CSGBrushEditorManager.ShowMessage("Could not create brush from given 2D shape");
                HideGenerateBrushes();
                return(false);
            }

            var newPolygons = ShapePolygonUtility.CreateCleanPolygonsFromVertices(outlineVertices, brushPosition, buildPlane);

            if (newPolygons == null)
            {
                shapeIsValid = false;
                ClearPolygons();
                //if (showErrorMessage)
                //	CSGBrushEditorManager.ShowMessage("Could not create brush from given 2D shape");
                HideGenerateBrushes();
                return(false);
            }
            EditModeManager.ResetMessage();
            shapeIsValid = true;

            UpdatePolygons(outlineVertices, newPolygons.ToArray());
            GenerateBrushesFromPolygons(inGridSpace: false);
            return(true);
        }