Exemplo n.º 1
0
        public static bool SanitizeAttribute(ref string attribName, ref VariadicChannelOptions channels, int version)
        {
            bool   settingsChanged             = false;
            string oldName                     = attribName;
            VariadicChannelOptions oldChannels = channels;

            if (version < 1 && channels == VariadicChannelOptions.XZ) // Enumerators have changed
            {
                channels        = VariadicChannelOptions.XYZ;
                settingsChanged = true;
            }

            if (version < 1 && VFXBlockUtility.ConvertSizeAttributeIfNeeded(ref attribName, ref channels))
            {
                Debug.Log(string.Format("Sanitizing attribute: Convert {0} with channel {2} to {1}", oldName, attribName, oldChannels));
                settingsChanged = true;
            }

            // Changes attribute to variadic version
            VariadicChannelOptions newChannels;

            if (VFXBlockUtility.ConvertToVariadicAttributeIfNeeded(ref attribName, out newChannels))
            {
                Debug.Log(string.Format("Sanitizing attribute: Convert {0} to variadic attribute {1} with channel {2}", oldName, attribName, newChannels));
                channels        = newChannels;
                settingsChanged = true;
            }

            return(settingsChanged);
        }
Exemplo n.º 2
0
        public static bool ConvertToVariadicAttributeIfNeeded(ref string attribName, out VariadicChannelOptions outChannel)
        {
            var attrib = VFXAttribute.Find(attribName);

            if (attrib.variadic == VFXVariadic.BelongsToVariadic)
            {
                char component = attrib.name.ToLower().Last();
                VariadicChannelOptions channel;
                switch (component)
                {
                case 'x':
                    channel = VariadicChannelOptions.X;
                    break;

                case 'y':
                    channel = VariadicChannelOptions.Y;
                    break;

                case 'z':
                    channel = VariadicChannelOptions.Z;
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Cannot convert {0} to variadic version", attrib.name));
                }

                attribName = VFXAttribute.Find(attrib.name.Substring(0, attrib.name.Length - 1)).name; // Just to ensure the attribute can be found
                outChannel = channel;

                return(true);
            }

            outChannel = VariadicChannelOptions.X;
            return(false);
        }
Exemplo n.º 3
0
        public override void Sanitize(int version)
        {
            string newAttrib;
            VariadicChannelOptions channel;

            // Changes attribute to variadic version
            if (VFXBlockUtility.ConvertToVariadicAttributeIfNeeded(attribute, out newAttrib, out channel))
            {
                Debug.Log(string.Format("Sanitizing SetAttribute: Convert {0} to variadic attribute {1} with channel {2}", attribute, newAttrib, channel));
                attribute = newAttrib;
                channels  = channel;
                Invalidate(InvalidationCause.kSettingChanged);
            }

            base.Sanitize(version);
        }
Exemplo n.º 4
0
        static string MaskFromChannel(VariadicChannelOptions channel)
        {
            switch (channel)
            {
            case VariadicChannelOptions.X: return("x");

            case VariadicChannelOptions.Y: return("y");

            case VariadicChannelOptions.Z: return("z");

            case VariadicChannelOptions.XY: return("xy");

            case VariadicChannelOptions.XZ: return("xz");

            case VariadicChannelOptions.YZ: return("yz");

            case VariadicChannelOptions.XYZ: return("xyz");
            }
            throw new InvalidOperationException("MaskFromChannel missing for " + channel);
        }
Exemplo n.º 5
0
        public static bool ConvertSizeAttributeIfNeeded(ref string attribName, ref VariadicChannelOptions channels)
        {
            if (attribName == "size")
            {
                if (channels == VariadicChannelOptions.X) // Consider sizeX as uniform
                {
                    return(true);
                }
                else
                {
                    attribName = "scale";
                    return(true);
                }
            }

            if (attribName == "sizeX")
            {
                attribName = "size";
                channels   = VariadicChannelOptions.X;
                return(true);
            }

            if (attribName == "sizeY")
            {
                attribName = "scale";
                channels   = VariadicChannelOptions.Y;
                return(true);
            }

            if (attribName == "sizeZ")
            {
                attribName = "scale";
                channels   = VariadicChannelOptions.Z;
                return(true);
            }

            return(false);
        }