예제 #1
0
 private static void GetFunctionName(VFXBlock block, out string functionName, out string comment)
 {
     var settings = block.GetSettings(true).ToArray();
     if (settings.Length > 0)
     {
         comment = "";
         int hash = 0;
         foreach (var setting in settings)
         {
             var value = setting.value;
             hash = (hash * 397) ^ value.GetHashCode();
             comment += string.Format("{0}:{1} ", setting.field.Name, value.ToString());
         }
         functionName = string.Format("{0}_{1}", block.GetType().Name, hash.ToString("X"));
     }
     else
     {
         comment = null;
         functionName = block.GetType().Name;
     }
 }
예제 #2
0
        public static void MigrateBlockTShapeFromShape(VFXBlock to, VFXBlock from)
        {
            var fromSettings = from.GetSettings(true);
            var toSettings   = to.GetSettings(true);

            foreach (var fromSetting in fromSettings)
            {
                var toSetting = toSettings.FirstOrDefault(o => o.name.Equals(fromSetting.name, StringComparison.InvariantCultureIgnoreCase));
                if (toSetting.field != null)
                {
                    to.SetSettingValue(toSetting.name, fromSetting.value);
                }
            }

            if (from.inputSlots.Count != to.inputSlots.Count)
            {
                throw new InvalidOperationException();
            }

            for (int i = 0; i < from.inputSlots.Count; ++i)
            {
                var fromInputSlot = from.inputSlots[i];
                var toInputSlot   = to.inputSlots[i];

                if (toInputSlot.property.type == fromInputSlot.property.type)
                {
                    VFXSlot.CopyLinksAndValue(toInputSlot, fromInputSlot, true);
                }
                else if (toInputSlot.property.type == typeof(TArcSphere))
                {
                    MigrateTArcSphereFromArcSphere(toInputSlot, fromInputSlot);
                }
                else if (toInputSlot.property.type == typeof(TArcCircle))
                {
                    MigrateTArcCircleFromArcCircle(toInputSlot, fromInputSlot);
                }
                else if (toInputSlot.property.type == typeof(TArcTorus))
                {
                    MigrateTArcTorusFromArcTorus(toInputSlot, fromInputSlot);
                }
                else if (toInputSlot.property.type == typeof(TArcCone))
                {
                    //There wasn't a TArcCylinder type
                    MigrateTArcConeFromArcCone(toInputSlot, fromInputSlot);
                }
                else if (toInputSlot.property.type == typeof(TSphere))
                {
                    MigrateTSphereFromSphere(toInputSlot, fromInputSlot);
                }
                else if (toInputSlot.property.type == typeof(TCircle))
                {
                    MigrateTCircleFromCircle(toInputSlot, fromInputSlot);
                }
                else if (toInputSlot.property.type == typeof(TTorus))
                {
                    MigrateTTorusFromTorus(toInputSlot, fromInputSlot);
                }
                else if (toInputSlot.property.type == typeof(TCone) && fromInputSlot.property.type == typeof(Cone))
                {
                    //Actually, no reference of this case
                    MigrateTConeFromCone(toInputSlot, fromInputSlot);
                }
                else if (toInputSlot.property.type == typeof(TCone) && fromInputSlot.property.type == typeof(Cylinder))
                {
                    MigrateTConeFromCylinder(toInputSlot, fromInputSlot);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }