Beispiel #1
0
        private void CheckOrientation()
        {
            // When we compute the normal automatically, we choose the orientation
            // so that the the sum of the signed areas of all contours is non-negative.
            float area = 0.0f;

            for (var f = _mesh._fHead._next; f != _mesh._fHead; f = f._next)
            {
                var e = f._anEdge;
                if (e._winding <= 0)
                {
                    continue;
                }
                do
                {
                    area += (e._Org._s - e._Dst._s) * (e._Org._t + e._Dst._t);
                    e     = e._Lnext;
                } while (e != f._anEdge);
            }
            if (area < 0.0f)
            {
                // Reverse the orientation by flipping all the t-coordinates
                for (var v = _mesh._vHead._next; v != _mesh._vHead; v = v._next)
                {
                    v._t = -v._t;
                }
                Vec3.Neg(ref _tUnit);
            }
        }
Beispiel #2
0
        private void CheckOrientation()
        {
            float num = 0f;

            for (MeshUtils.Face next = _mesh._fHead._next; next != _mesh._fHead; next = next._next)
            {
                if (next._anEdge._winding > 0)
                {
                    num += MeshUtils.FaceArea(next);
                }
            }
            if (num < 0f)
            {
                for (MeshUtils.Vertex next2 = _mesh._vHead._next; next2 != _mesh._vHead; next2 = next2._next)
                {
                    MeshUtils.Vertex vertex = next2;
                    vertex._t = 0f - vertex._t;
                }
                Vec3.Neg(ref _tUnit);
            }
        }
Beispiel #3
0
        private void CheckOrientation()
        {
            // When we compute the normal automatically, we choose the orientation
            // so that the sum of the signed areas of all contours is non-negative.
            DeterministicFloat area = new DeterministicFloat(0);

            for (var f = _mesh._fHead._next; f != _mesh._fHead; f = f._next)
            {
                if (f._anEdge._winding <= 0)
                {
                    continue;
                }
                area += MeshUtils.FaceArea(f);
            }
            if (area < 0)
            {
                // Reverse the orientation by flipping all the t-coordinates
                for (var v = _mesh._vHead._next; v != _mesh._vHead; v = v._next)
                {
                    v._t = -v._t;
                }
                Vec3.Neg(ref _tUnit);
            }
        }