123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- using System;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using UnityEngine;
- using UnityEngine.VFX;
- namespace UnityEditor.VFX
- {
- class VFXExpressionCastUintToFloat : VFXExpression
- {
- public VFXExpressionCastUintToFloat() : this(VFXValue<uint>.Default)
- {
- }
- public VFXExpressionCastUintToFloat(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from })
- {
- if (from.valueType != VFXValueType.Uint32)
- throw new InvalidCastException("Invalid VFXExpressionCastUintToFloat");
- }
- sealed public override VFXExpressionOperation operation
- {
- get
- {
- return VFXExpressionOperation.CastUintToFloat;
- }
- }
- sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents)
- {
- return VFXValue.Constant((float)reducedParents[0].Get<uint>());
- }
- sealed public override string GetCodeString(string[] parents)
- {
- return string.Format("(float){0}", parents[0]);
- }
- }
- class VFXExpressionCastIntToFloat : VFXExpression
- {
- public VFXExpressionCastIntToFloat() : this(VFXValue<int>.Default)
- {
- }
- public VFXExpressionCastIntToFloat(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from })
- {
- if (from.valueType != VFXValueType.Int32)
- throw new InvalidCastException("Invalid VFXExpressionCastIntToFloat");
- }
- sealed public override VFXExpressionOperation operation
- {
- get
- {
- return VFXExpressionOperation.CastIntToFloat;
- }
- }
- sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents)
- {
- return VFXValue.Constant((float)reducedParents[0].Get<int>());
- }
- sealed public override string GetCodeString(string[] parents)
- {
- return string.Format("(float){0}", parents[0]);
- }
- }
- class VFXExpressionCastFloatToUint : VFXExpression
- {
- public VFXExpressionCastFloatToUint() : this(VFXValue<float>.Default)
- {
- }
- public VFXExpressionCastFloatToUint(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from })
- {
- if (from.valueType != VFXValueType.Float)
- throw new InvalidCastException("Invalid VFXExpressionCastFloatToUint");
- }
- sealed public override VFXExpressionOperation operation
- {
- get
- {
- return VFXExpressionOperation.CastFloatToUint;
- }
- }
- sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents)
- {
- return VFXValue.Constant((uint)reducedParents[0].Get<float>());
- }
- sealed public override string GetCodeString(string[] parents)
- {
- return string.Format("(uint){0}", parents[0]);
- }
- }
- class VFXExpressionCastIntToUint : VFXExpression
- {
- public VFXExpressionCastIntToUint() : this(VFXValue<int>.Default)
- {
- }
- public VFXExpressionCastIntToUint(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from })
- {
- if (from.valueType != VFXValueType.Int32)
- throw new InvalidCastException("Invalid VFXExpressionCastIntToUint");
- }
- sealed public override VFXExpressionOperation operation
- {
- get
- {
- return VFXExpressionOperation.CastIntToUint;
- }
- }
- sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents)
- {
- return VFXValue.Constant((uint)reducedParents[0].Get<int>());
- }
- sealed public override string GetCodeString(string[] parents)
- {
- return string.Format("(uint){0}", parents[0]);
- }
- }
- class VFXExpressionCastFloatToInt : VFXExpression
- {
- public VFXExpressionCastFloatToInt() : this(VFXValue<float>.Default)
- {
- }
- public VFXExpressionCastFloatToInt(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from })
- {
- if (from.valueType != VFXValueType.Float)
- throw new InvalidCastException("Invalid VFXExpressionCastFloatToInt");
- }
- sealed public override VFXExpressionOperation operation
- {
- get
- {
- return VFXExpressionOperation.CastFloatToInt;
- }
- }
- sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents)
- {
- return VFXValue.Constant((int)reducedParents[0].Get<float>());
- }
- sealed public override string GetCodeString(string[] parents)
- {
- return string.Format("(int){0}", parents[0]);
- }
- }
- class VFXExpressionCastUintToInt : VFXExpression
- {
- public VFXExpressionCastUintToInt() : this(VFXValue<uint>.Default)
- {
- }
- public VFXExpressionCastUintToInt(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from })
- {
- if (from.valueType != VFXValueType.Uint32)
- throw new InvalidCastException("Invalid VFXExpressionCastUintToInt");
- }
- sealed public override VFXExpressionOperation operation
- {
- get
- {
- return VFXExpressionOperation.CastUintToInt;
- }
- }
- sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents)
- {
- return VFXValue.Constant((int)reducedParents[0].Get<uint>());
- }
- sealed public override string GetCodeString(string[] parents)
- {
- return string.Format("(int){0}", parents[0]);
- }
- }
- }
|