Exemple #1
0
        public void MinMax_Native()
        {
            var count    = 512 * 512 * 256;
            var bounds   = new VoxelPhysicsBounds(int.MaxValue, int.MinValue);
            var position = new Vector3Int(int.MinValue, int.MinValue, int.MinValue);
            var sw       = Stopwatch.StartNew();

            for (var k = 0; k < count; k++)
            {
                if (bounds.min.x > position.x)
                {
                    bounds.min.x = position.x;
                }
                else if (bounds.max.x > position.x)
                {
                    bounds.max.x = position.x;
                }

                if (bounds.min.y > position.y)
                {
                    bounds.min.y = position.y;
                }
                else if (bounds.max.y > position.y)
                {
                    bounds.max.y = position.y;
                }

                if (bounds.min.z > position.z)
                {
                    bounds.min.z = position.z;
                }
                else if (bounds.max.z > position.z)
                {
                    bounds.max.z = position.z;
                }
            }

            UnityEngine.Debug.Log($"{nameof(MinMax_Native)}: {(sw.ElapsedTicks / 10000f)} ms");
        }
Exemple #2
0
        public void MinMax_For()
        {
            var count    = 512 * 512 * 256;
            var bounds   = new VoxelPhysicsBounds(int.MaxValue, int.MinValue);
            var position = new Vector3Int(int.MinValue, int.MinValue, int.MinValue);
            var sw       = Stopwatch.StartNew();

            for (var k = 0; k < count; k++)
            {
                for (var i = 0; i < 3; i++)
                {
                    if (bounds.min[i] > position[i])
                    {
                        bounds.min[i] = position[i];
                    }
                    else if (bounds.max[i] > position[i])
                    {
                        bounds.max[i] = position[i];
                    }
                }
            }

            UnityEngine.Debug.Log($"{nameof(MinMax_For)}: {(sw.ElapsedTicks / 10000f)} ms");
        }