Esempio n. 1
0
        /// <summary>
        /// x,y중 한쪽만 우선한 벡터 방향 반환.
        /// 이동 벡터를 x,y 둘 다 가지는게 적합하지 않은 상황에 사용.
        /// 우선하지 않은 벡터 방향은 0을 반환함.
        /// </summary>
        /// <param name="relativeVec">상대적 좌표</param>
        /// <param name="PriorityVecType">우선할 좌표</param>
        /// <returns></returns>
        public static Vector2 GetDirOnlyOneSide(Vector2 relativeVec, VecType PriorityVecType)
        {
            var dir = GetDir(relativeVec);

            if (dir.x != 0 && dir.y != 0)
            {
                if (PriorityVecType == VecType.x)
                {
                    dir.y = 0;
                }
                else
                {
                    dir.x = 0;
                }
            }

            return(dir);
        }
Esempio n. 2
0
        static Meta()
        {
            #region VecTypes

            var vectorTypes = new List <VecType>();
            VecTypeMapArray = new Dictionary <SimpleType, VecType> [5];

            foreach (var n in VecTypeDimensions)
            {
                var typeMap = new Dictionary <SimpleType, VecType>();
                foreach (var ft in VecFieldTypes)
                {
                    var t = new VecType("V" + n + ft.Char)
                    {
                        Len       = n,
                        FieldType = ft,
                        Fields    = VecFields.Take(n).ToArray(),
                    };
                    typeMap[ft] = t;
                    vectorTypes.Add(t);
                }
                VecTypeMapArray[n] = typeMap;
            }

            VecTypes = vectorTypes.ToArray();

            #endregion

            #region MatTypes

            var matrixTypes = new List <MatType>();
            MatTypeMapArray = new Dictionary <SimpleType, MatType> [5, 5];

            foreach (var dim in MatTypeDimensions)
            {
                var typeMap = new Dictionary <SimpleType, MatType>();
                foreach (var ft in MatFieldTypes)
                {
                    var t = new MatType("M" + dim.Rows + dim.Cols + ft.Char)
                    {
                        Rows = dim.Rows, Cols = dim.Cols, FieldType = ft
                    };
                    typeMap[ft] = t;
                    matrixTypes.Add(t);
                }
                MatTypeMapArray[dim.Rows, dim.Cols] = typeMap;
            }

            MatTypes = matrixTypes.ToArray();

            #endregion

            VectorType = new GenericTensorType("Vector")
            {
                DataType     = TDataType,
                ViewType     = TDataType,
                Dim          = 1,
                IndexType    = LongType,
                IntIndexType = IntType,
            };

            VectorWithViewType = new GenericTensorType("Vector")
            {
                DataType     = TDataType,
                ViewType     = TViewType,
                Dim          = 1,
                IndexType    = LongType,
                IntIndexType = IntType,
            };

            MatrixType = new GenericTensorType("Matrix")
            {
                DataType     = TDataType,
                ViewType     = TDataType,
                Dim          = 2,
                IndexType    = VecTypeOf(2, LongType),
                IntIndexType = VecTypeOf(2, IntType),
            };

            MatrixWithViewType = new GenericTensorType("Matrix")
            {
                DataType     = TDataType,
                ViewType     = TViewType,
                Dim          = 2,
                IndexType    = VecTypeOf(2, LongType),
                IntIndexType = VecTypeOf(2, IntType),
            };

            VolumeType = new GenericTensorType("Volume")
            {
                DataType     = TDataType,
                ViewType     = TDataType,
                Dim          = 3,
                IndexType    = VecTypeOf(3, LongType),
                IntIndexType = VecTypeOf(3, IntType),
            };

            VolumeWithViewType = new GenericTensorType("Volume")
            {
                DataType     = TDataType,
                ViewType     = TViewType,
                Dim          = 3,
                IndexType    = VecTypeOf(3, LongType),
                IntIndexType = VecTypeOf(3, IntType),
            };

            Tensor4Type = new GenericTensorType("Tensor4")
            {
                DataType     = TDataType,
                ViewType     = TDataType,
                Dim          = 4,
                IndexType    = VecTypeOf(4, LongType),
                IntIndexType = VecTypeOf(4, IntType),
            };

            Tensor4WithViewType = new GenericTensorType("Tensor4")
            {
                DataType     = TDataType,
                ViewType     = TViewType,
                Dim          = 4,
                IndexType    = VecTypeOf(4, LongType),
                IntIndexType = VecTypeOf(4, IntType),
            };

            GenericTensorTypes = new GenericTensorType[]
            {
                VectorType, VectorWithViewType,
                MatrixType, MatrixWithViewType,
                VolumeType, VolumeWithViewType,
                Tensor4Type, Tensor4WithViewType,
            };

            RangeTypes       = GenerateRangeTypes().ToArray();
            BoxTypes         = GenerateBoxTypes().ToArray();
            RangeAndBoxTypes = RangeTypes.Concat(BoxTypes).ToArray();

            #region ColorTypes

            var colorTypes = new List <ColorType>();
            ColorTypeMapArray = new Dictionary <SimpleType, ColorType> [5];

            foreach (var n in ColorTypeDimensions)
            {
                var typeMap = new Dictionary <SimpleType, ColorType>();
                foreach (var ft in ColorFieldTypes)
                {
                    var t = new ColorType("C" + n + ft.Char)
                    {
                        Len       = n,
                        FieldType = ft,
                        Fields    = ColorFields.Take(n).ToArray(),
                        Channels  = ColorFields.Take(3).ToArray(),
                        HasAlpha  = n == 4,
                        MinValue  = ColorFieldTypeMinValue[ft],
                        MaxValue  = ColorFieldTypeMaxValue[ft],
                    };
                    typeMap[ft] = t;
                    colorTypes.Add(t);
                }
                ColorTypeMapArray[n] = typeMap;
            }

            ColorTypes = colorTypes.ToArray();

            #endregion

            DirectlyCodeableBuiltinTypes = IntegerTypes.Concat(RealTypes).ToArray();

            BuiltInTypes = BoolType.IntoArray()
                           .Concat(DirectlyCodeableBuiltinTypes)
                           .ToArray();

            StandardNumericTypes = IntegerTypes
                                   .Concat(RealTypes)
                                   .ToArray();

            foreach (var t in StandardNumericTypes)
            {
                s_typeNameIdentifierMap[t.Name] = t.Caps;
            }
            foreach (var t in TextTypes)
            {
                s_typeNameIdentifierMap[t.Name.ToLower()] = t.Name;
            }
            s_typeNameIdentifierMap[BoolType.Name] = BoolType.Caps;

            BuiltInNumericTypes = StandardNumericTypes
                                  .Concat(DecimalType.IntoArray())
                                  .ToArray();

            NumericTypes = StandardNumericTypes
                           .Concat(FractionType.IntoArray())
                           .ToArray();

            ComparableTypes = NumericTypes
                              .Concat(TimeTypes)
                              .ToArray();

            StructTypes = BuiltInTypes
                          .Concat(FractionType.IntoArray())
                          .Concat(SystemTypes)
                          .Concat(VecTypes)
                          .Concat(MatTypes)
                          .Concat(ColorTypes)
                          .Concat(RangeAndBoxTypes)
                          .Concat(TrafoTypes)
                          .ToArray();

            DirectlyCodeableTypes = DirectlyCodeableBuiltinTypes
                                    .Concat(FractionType.IntoArray())
                                    .Concat(VecTypes)
                                    .Concat(MatTypes)
                                    .Concat(ColorTypes)
                                    .Concat(RangeAndBoxTypes)
                                    .Concat(TrafoTypes)
                                    .ToArray();
        }