コード例 #1
0
ファイル: TestMathUtils.cs プロジェクト: sw0817/open-brush
        public void TestTransformVector4AsVector()
        {
            TrTransform randomXf      = RandomTr();
            Matrix4x4   mat           = randomXf.ToMatrix4x4();
            int         listSize      = 10;
            var         list          = RandomVector4List(listSize);
            var         listDuplicate = new List <Vector4>(list);
            int         iVert         = 3;
            int         iVertEnd      = 8;

            // Do the original version.
            for (int i = iVert; i < iVertEnd; i++)
            {
                Vector3 v3            = new Vector3(list[i].x, list[i].y, list[i].z);
                Vector3 v3Transformed = randomXf.MultiplyVector(v3);
                list[i] = new Vector4(v3Transformed.x, v3Transformed.y, v3Transformed.z, list[i].w);
            }

            // Do the math utils version.
            MathUtils.TransformVector4AsVector(mat, iVert, iVertEnd, listDuplicate.GetBackingArray());

            // Check results.
            for (int i = 0; i < listSize; i++)
            {
                AssertAlmostEqual(list[i], listDuplicate[i]);
            }
        }