Ejemplo n.º 1
0
        private void ComputeBounds(CMeshVertex[] verts, bool updateBounds = false)
        {
            var numVerts = verts.Length;

            if (numVerts <= 0)
            {
                if (updateBounds)
                {
                    return;
                }
                Mins.Set(0f, 0f, 0f);
                Maxs.Set(0f, 0f, 0f);
                return;
            }

            var i = 0;

            if (!updateBounds)
            {
                Mins.Set(Maxs.Set(verts[i++].Position));
                numVerts--;
            }

            while (numVerts-- != 0)
            {
                var v = verts[i++].Position;
                if (v[0] < Mins[0])
                {
                    Mins[0] = v[0];
                }
                if (v[0] > Maxs[0])
                {
                    Maxs[0] = v[0];
                }
                if (v[1] < Mins[1])
                {
                    Mins[1] = v[1];
                }
                if (v[1] > Maxs[1])
                {
                    Maxs[1] = v[1];
                }
                if (v[2] < Mins[2])
                {
                    Mins[2] = v[2];
                }
                if (v[2] > Maxs[2])
                {
                    Maxs[2] = v[2];
                }
            }
        }