コード例 #1
0
        public static int GetTextureArrayIndex(
            ShapeDescriptor shapeDescriptor,
            short transferMode,
            bool isOpaqueSurface,
            SurfaceTypes surfaceType)
        {
            if (shapeDescriptor.IsEmpty())
            {
                return(0);
            }

            var landscapeTransferMode = transferMode == 9 || shapeDescriptor.UsesLandscapeCollection();

            var collectionKey =
                GetTexture2DArrayKeyDictionary(
                    shapeDescriptor,
                    landscapeTransferMode: landscapeTransferMode,
                    isOpaqueSurface: isOpaqueSurface,
                    surfaceType)
                [shapeDescriptor];

            var collection = Texture2DArrays[collectionKey];

            return(collection.GetBitmapIndex(shapeDescriptor));
        }
コード例 #2
0
        public static Material GetMaterial(
            ShapeDescriptor shapeDescriptor,
            short transferMode,
            bool isOpaqueSurface,
            SurfaceTypes surfaceType,
            bool incrementUsageCounter)
        {
            if (!shapeDescriptor.IsEmpty())
            {
                if (TextureUsageCounter.ContainsKey(shapeDescriptor))
                {
                    if (incrementUsageCounter)
                    {
                        TextureUsageCounter[shapeDescriptor]++;
                    }
                }
                else
                {
                    TextureUsageCounter[shapeDescriptor] = 1;
                }

                var landscapeTransferMode = transferMode == 9 || shapeDescriptor.UsesLandscapeCollection();

                return(GetTrackedMaterial(shapeDescriptor,
                                          landscapeTransferMode,
                                          isOpaqueSurface,
                                          surfaceType));
            }
            else
            {
                return(UnassignedMaterial);
            }
        }
コード例 #3
0
        public static void DecrementTextureUsage(ShapeDescriptor shapeDescriptor)
        {
            if (shapeDescriptor.IsEmpty())
            {
                return;
            }

            if (TextureUsageCounter.ContainsKey(shapeDescriptor))
            {
                TextureUsageCounter[shapeDescriptor]--;

                if (TextureUsageCounter[shapeDescriptor] <= 0)
                {
                    TextureUsageCounter.Remove(shapeDescriptor);
                }
            }
        }
コード例 #4
0
        public override void OnValidatedPointerClick(PointerEventData eventData)
        {
            switch (ModeManager.Instance.PrimaryMode)
            {
            case ModeManager.PrimaryModes.Geometry:
                SelectionManager.Instance.ToggleObjectSelection(ParentPolygon, multiSelect: false);

                break;

            case ModeManager.PrimaryModes.Textures:
                if (ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Painting)
                {
                    var selectedTexture = PaletteManager.Instance.GetSelectedTexture();

                    if (!selectedTexture.IsEmpty())
                    {
                        ParentPolygon.SetShapeDescriptor(DataSource, selectedTexture);
                    }
                }
                else if (ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Editing &&
                         Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
                {
                    var selectedSourceObject  = SelectionManager.Instance.SelectedObject;
                    var selectedSourcePolygon = (selectedSourceObject is LevelEntity_Polygon) ? selectedSourceObject as LevelEntity_Polygon : null;

                    if (selectedSourcePolygon && selectedSourcePolygon != ParentPolygon)
                    {
                        ParentPolygon.SetOffset(DataSource,
                                                DataSource == LevelEntity_Polygon.DataSources.Floor ? selectedSourcePolygon.NativeObject.FloorOrigin.X : selectedSourcePolygon.NativeObject.CeilingOrigin.X,
                                                DataSource == LevelEntity_Polygon.DataSources.Floor ? selectedSourcePolygon.NativeObject.FloorOrigin.Y : selectedSourcePolygon.NativeObject.CeilingOrigin.Y,
                                                rebatch: true);
                    }
                }
                else
                {
                    SelectionManager.Instance.ToggleObjectSelection(ParentPolygon, multiSelect: false);
                    InputListener(ParentPolygon);

                    if (!surfaceShapeDescriptor.IsEmpty())
                    {
                        PaletteManager.Instance.SelectSwatchForTexture(surfaceShapeDescriptor, invokeToggleEvents: false);
                    }
                }

                break;

            case ModeManager.PrimaryModes.Lights:
                if (ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Painting)
                {
                    var selectedLight = PaletteManager.Instance.GetSelectedLight();

                    if (selectedLight != null)
                    {
                        ParentPolygon.SetLight(DataSource, selectedLight.NativeIndex);
                    }
                }
                else
                {
                    SelectionManager.Instance.ToggleObjectSelection(RuntimeLight, multiSelect: false);
                    PaletteManager.Instance.SelectSwatchForLight(RuntimeLight, invokeToggleEvents: false);
                }

                break;

            case ModeManager.PrimaryModes.Media:
                if (Media != null)
                {
                    SelectionManager.Instance.ToggleObjectSelection(Media, multiSelect: false);
                    PaletteManager.Instance.SelectSwatchForMedia(Media, invokeToggleEvents: false);
                }

                break;

            case ModeManager.PrimaryModes.Platforms:
                if (Platform != null)
                {
                    SelectionManager.Instance.ToggleObjectSelection(Platform, multiSelect: false);
                }

                break;

            default:
                Debug.LogError($"Selection in mode \"{ModeManager.Instance.PrimaryMode}\" is not supported.");
                return;
            }

            InspectorPanel.Instance.RefreshAllInspectors();
        }
コード例 #5
0
        public async override void OnValidatedPointerClick(PointerEventData eventData)
        {
            switch (ModeManager.Instance.PrimaryMode)
            {
            case ModeManager.PrimaryModes.Geometry:
                SelectionManager.Instance.ToggleObjectSelection(ParentSide, multiSelect: false);

                break;

            case ModeManager.PrimaryModes.Textures:
                if (ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Painting)
                {
                    var selectedTexture = PaletteManager.Instance.GetSelectedTexture();

                    if (!selectedTexture.IsEmpty())
                    {
                        var destinationIsLayered  = ParentSide.NativeObject.HasLayeredTransparentSide(LevelEntity_Level.Instance.Level);
                        var destinationDataSource = DataSource;

                        if (destinationIsLayered)
                        {
                            var result = await ShowLayerSourceDialog(isDestination : true);

                            if (!result.HasValue)
                            {
                                // Dialog was cancelled, so exit
                                return;
                            }

                            destinationDataSource = result.Value;
                        }

                        ParentSide.SetShapeDescriptor(destinationDataSource, selectedTexture);
                    }
                }
                else if (ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Editing &&
                         Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
                {
                    var selectedSourceObject = SelectionManager.Instance.SelectedObject;
                    var selectedSourceSide   = (selectedSourceObject is LevelEntity_Side) ? selectedSourceObject as LevelEntity_Side : null;

                    if (!selectedSourceSide)
                    {
                        // There is no selection to use as a source, so exit
                        return;
                    }

                    var destinationIsSource = selectedSourceSide == ParentSide;

                    // Assign defaults for when the destination is the source (instead of a neighbor).
                    // True for both of these means that there will be no offset difference from source to destination.
                    var neighborFlowsOutward = true;
                    var neighborIsLeft       = true;

                    if (destinationIsSource ||
                        selectedSourceSide.NativeObject.SideIsNeighbor(LevelEntity_Level.Instance.Level,
                                                                       ParentSide.NativeObject,
                                                                       out neighborFlowsOutward,
                                                                       out neighborIsLeft))
                    {
                        #region Alignment_DataSource_Destination
                        var destinationIsLayered  = ParentSide.NativeObject.HasLayeredTransparentSide(LevelEntity_Level.Instance.Level);
                        var destinationDataSource = DataSource;

                        if (destinationIsLayered)
                        {
                            var result = await ShowLayerSourceDialog(isDestination : true);

                            if (!result.HasValue)
                            {
                                // Dialog was cancelled, so exit
                                return;
                            }

                            destinationDataSource = result.Value;
                        }

                        var destinationUVChannel = (destinationDataSource == LevelEntity_Side.DataSources.Transparent && destinationIsLayered) ? 1 : 0;
                        #endregion Alignment_DataSource_Destination

                        #region Alignment_DataSource_Source
                        LevelEntity_Side.DataSources sourceDataSource;

                        if (destinationIsSource && destinationIsLayered)
                        {
                            sourceDataSource = destinationDataSource == LevelEntity_Side.DataSources.Primary ? LevelEntity_Side.DataSources.Transparent : LevelEntity_Side.DataSources.Primary;
                        }
                        else
                        {
                            List <LevelEntity_Side.DataSources> sourceDataSourceOptions = new List <LevelEntity_Side.DataSources>();

                            foreach (var dataSource in Enum.GetValues(typeof(LevelEntity_Side.DataSources)).Cast <LevelEntity_Side.DataSources>())
                            {
                                if (selectedSourceSide.NativeObject.HasDataSource(dataSource) &&
                                    (!destinationIsSource || dataSource != DataSource))
                                {
                                    sourceDataSourceOptions.Add(dataSource);
                                }
                            }

                            if (sourceDataSourceOptions.Count == 0)
                            {
                                // The source side has no textured surfaces,
                                // or the source is the destination and there was only one data source,
                                // so exit
                                return;
                            }
                            else if (sourceDataSourceOptions.Count == 1)
                            {
                                sourceDataSource = sourceDataSourceOptions[0];
                            }
                            else
                            {
                                var result = await ShowVariableDataSourceDialog(sourceDataSourceOptions.Select(source => source.ToString()).ToList(), isDestination : false);

                                if (!result.HasValue)
                                {
                                    // Dialog was cancelled, so exit
                                    return;
                                }

                                sourceDataSource = result.Value;
                            }
                        }
                        #endregion Alignment_DataSource_Source

                        AlignDestinationToSource(selectedSourceSide, sourceDataSource, ParentSide, destinationDataSource, neighborFlowsOutward, neighborIsLeft, rebatch: true);
                    }
                }
                else
                {
                    SelectionManager.Instance.ToggleObjectSelection(ParentSide, multiSelect: false);
                    InputListener(ParentSide);

                    if (!surfaceShapeDescriptor.IsEmpty())
                    {
                        PaletteManager.Instance.SelectSwatchForTexture(surfaceShapeDescriptor, invokeToggleEvents: false);
                    }
                }

                break;

            case ModeManager.PrimaryModes.Lights:
                if (ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Painting)
                {
                    var selectedLight = PaletteManager.Instance.GetSelectedLight();

                    if (selectedLight != null)
                    {
                        var destinationIsLayered  = ParentSide.NativeObject.HasLayeredTransparentSide(LevelEntity_Level.Instance.Level);
                        var destinationDataSource = DataSource;

                        if (destinationIsLayered)
                        {
                            var result = await ShowLayerSourceDialog(isDestination : true);

                            if (!result.HasValue)
                            {
                                // Dialog was cancelled, so exit
                                return;
                            }

                            destinationDataSource = result.Value;
                        }

                        ParentSide.SetLight(destinationDataSource, selectedLight.NativeIndex);
                    }
                }
                else
                {
                    SelectionManager.Instance.ToggleObjectSelection(RuntimeLight, multiSelect: false);
                    PaletteManager.Instance.SelectSwatchForLight(RuntimeLight, invokeToggleEvents: false);
                }

                break;

            case ModeManager.PrimaryModes.Media:
                if (Media != null)
                {
                    SelectionManager.Instance.ToggleObjectSelection(Media, multiSelect: false);
                    PaletteManager.Instance.SelectSwatchForMedia(Media, invokeToggleEvents: false);
                }

                break;

            case ModeManager.PrimaryModes.Platforms:
                if (Platform != null)
                {
                    SelectionManager.Instance.ToggleObjectSelection(Platform, multiSelect: false);
                }

                break;

            default:
                Debug.LogError($"Selection in mode \"{ModeManager.Instance.PrimaryMode}\" is not supported.");
                return;
            }

            InspectorPanel.Instance.RefreshAllInspectors();
        }