当前位置: 首页>>代码示例>>C#>>正文


C# Vector4f.ConvertToInt方法代码示例

本文整理汇总了C#中Mono.Simd.Vector4f.ConvertToInt方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4f.ConvertToInt方法的具体用法?C# Vector4f.ConvertToInt怎么用?C# Vector4f.ConvertToInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Simd.Vector4f的用法示例。


在下文中一共展示了Vector4f.ConvertToInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SimdTest

        public void SimdTest()
        {
            Bounds bounds = new Bounds(new Vector3(1, 1, 1), new Vector3(3, 3, 3));
            const int positionX = 4;
            const int positionZ = 3;

            // Non-SIMD version
            Vector3Int bMin;
            Vector3Int bMax;
            Vector3Int myVec52 = new Vector3Int(Chunk.Vec5.X, Chunk.Vec5.X, Chunk.Vec5.X);
            {
                Vector3Int pom = new Vector3Int(positionX * EngineSettings.ChunkConfig.SizeX, 0, positionZ * EngineSettings.ChunkConfig.SizeZ);

                int minX = Mathf.Clamp(Mathf.FloorToInt(bounds.min.x) - pom.X - myVec52.X, 0, EngineSettings.ChunkConfig.MaskX);
                int minY = Mathf.Clamp(Mathf.FloorToInt(bounds.min.y) - myVec52.Y, 0, EngineSettings.ChunkConfig.SizeYTotal - 1);
                int minZ = Mathf.Clamp(Mathf.FloorToInt(bounds.min.z) - pom.Z - myVec52.Z, 0, EngineSettings.ChunkConfig.MaskZ);
                bMin = new Vector3Int(minX, minY, minZ);

                int maxX = Mathf.Clamp(Mathf.Clamp(bMin.X, 0, EngineSettings.ChunkConfig.MaskX), 0, EngineSettings.ChunkConfig.MaskX);
                int maxY = Mathf.Clamp(Mathf.Clamp(bMin.Y, 0, EngineSettings.ChunkConfig.SizeYTotal - 1), 0, EngineSettings.ChunkConfig.SizeYTotal-1);
                int maxZ = Mathf.Clamp(Mathf.Clamp(bMin.Z, 0, EngineSettings.ChunkConfig.MaskZ), 0, EngineSettings.ChunkConfig.MaskZ);
                bMax = new Vector3Int(maxX, maxY, maxZ);
            }

            // SIMD version
            Vector4i bMinv;
            Vector4i bMaxv;
            {
                Vector4f bMinf = new Vector4f(bounds.min.x, bounds.min.y, bounds.min.z, 0f);
                bMinv = bMinf.ConvertToIntTruncated();
                Vector4f bMaxf = new Vector4f(bounds.max.x, bounds.max.y, bounds.max.z, 0f);
                bMaxv = bMaxf.ConvertToInt();

                Vector4i pom = new Vector4i(positionX, 0, positionZ, 0)*Chunk.VecSize;
                bMinv -= pom;
                bMinv -= Chunk.Vec5;
                bMinv = bMinv.Max(Vector4i.Zero).Min(Chunk.VecSize1);
                    // Clamp to 0..size (x,z) or 0..height (y) respectively

                bMaxv -= pom;
                bMaxv += Chunk.Vec5;
                bMaxv = bMaxv.Max(Vector4i.Zero).Min(Chunk.VecSize1);
                    // Clamp to 0..size (x,z) or 0..height (y) respectively
            }

            Assert.AreEqual(bMin.X, bMinv.X);
            Assert.AreEqual(bMin.Y, bMinv.Y);
            Assert.AreEqual(bMin.Z, bMinv.Z);

            Assert.AreEqual(bMax.X, bMaxv.X);
            Assert.AreEqual(bMax.Y, bMaxv.Y);
            Assert.AreEqual(bMax.Z, bMaxv.Z);
        }
开发者ID:Avatarchik,项目名称:Voxe,代码行数:53,代码来源:UTSimd.cs

示例2: test_0_f_to_i

	public static int test_0_f_to_i () {
		var a = new Vector4f (1.1f, 2.2f, 3.5f, 4.6f);
		var b = a.ConvertToInt ();
		if (b.X != 1)
			return 1;
		if (b.Y != 2)
			return 2;
		if (b.Z != 4)
			return 3;
		if (b.W != 5)
			return 4;
		return 0;
	}
开发者ID:Zman0169,项目名称:mono,代码行数:13,代码来源:basic-simd.cs


注:本文中的Mono.Simd.Vector4f.ConvertToInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。