Exemple #1
0
            static void Index1dTo2d_VS_PointToIndex2d(float2 position, float2 gridWorldSize, int gridWidth, int gridHeight)
            {
                int  Ai  = NativeGrid.PointToIndex(position, gridWorldSize, gridWidth, gridHeight);
                int2 Ai2 = NativeGrid.Index1dTo2d(Ai, gridWidth);
                int2 Bi2 = NativeGrid.PointToIndex2d(position, gridWorldSize, gridWidth, gridHeight);

                Assert.AreEqual(Ai2, Bi2, $"\tNativeGrid.Index1dTo2d(NativeGrid.PointToIndex(params)) returned: {Ai2}\n\tNativeGrid.PointToIndex2d returned: {Bi2}");
            }
Exemple #2
0
            static void PointToIndex2d_Test(float2 a, float2 b)
            {
                float2    worldSize = new float2(3000f, 3000f);
                float2    gridOrigin = new float2(-1500f, -1500f);
                const int width = 1500, height = 1500;
                INT2      A = NativeGrid.PointToIndex2d(a - gridOrigin, worldSize, width, height);
                INT2      B = NativeGrid.PointToIndex2d(b - gridOrigin, worldSize, width, height);

                // Debug.Log( $"a:{GetPositionInsideCell_GetDebugString(a,width,height,worldSize)}\nb:{GetPositionInsideCell_GetDebugString(b,width,height,worldSize)}" );
                Assert.AreEqual(A, B);
            }
Exemple #3
0
            public static void PointToIndex2d_Test_1x1(float2 a, float2 b)
            {
                float2 worldSize = new float2 {
                    x = 2f, y = 1f
                }; const int width = 1, height = 1;
                INT2         A = NativeGrid.PointToIndex2d(a, worldSize, width, height);
                INT2         B = NativeGrid.PointToIndex2d(b, worldSize, width, height);

                // Debug.Log( $"a:{GetPositionInsideCell_GetDebugString(a,width,height,worldSize)}\nb:{GetPositionInsideCell_GetDebugString(b,width,height,worldSize)}" );
                Assert.AreEqual(A, B);
            }
Exemple #4
0
            public static void PointToIndex2d_Test_2x2(float2 a, float2 b, bool equalityTest = true)
            {
                float2 worldSize = new float2(2f, 2f); const int width = 2, height = 2;
                INT2   A = NativeGrid.PointToIndex2d(a, worldSize, width, height);
                INT2   B = NativeGrid.PointToIndex2d(b, worldSize, width, height);

                // Debug.Log( $"a:{GetPositionInsideCell_GetDebugString(a,width,height,worldSize)}\nb:{GetPositionInsideCell_GetDebugString(b,width,height,worldSize)}" );
                if (equalityTest)
                {
                    Assert.AreEqual(A, B);
                }
                else
                {
                    Assert.AreNotEqual(A, B);
                }
            }
 public static int2 PointToIndex2d(FLOAT2 point, FLOAT2 worldSize, INT width, INT height) => NativeGrid.PointToIndex2d(point, worldSize, width, height);