Nez.Portable/ECS/Components/Renderables/Mesh.cs
/// <summary>
/// recalculates the bounds and optionally sets the UVs. The UVs are setup to map the texture in a best fit fashion.
/// </summary>
/// <param name="recalculateUVs">If set to <c>true</c> recalculate U vs.</param>
recalculates the bounds and optionally sets the UVs. The UVs are setup to map the texture in a best fit fashion.
recalculates the bounds and optionally sets the UVs . The UVs are setup to map the texture in a best fit fashion .
public Mesh recalculateBounds(bool recalculateUVs)
        {
            _topLeftVertPosition = new Vector2(float.MaxValue, float.MaxValue);
            var max = new Vector2(float.MinValue, float.MinValue);
            for (var i = 0; i < _verts.Length; i++)
            {
                _topLeftVertPosition.X = MathHelper.Min(_topLeftVertPosition.X, _verts[i].Position.X);
                _topLeftVertPosition.Y = MathHelper.Min(_topLeftVertPosition.Y, _verts[i].Position.Y);
                max.X = MathHelper.Max(max.X, _verts[i].Position.X);
                max.Y = MathHelper.Max(max.Y, _verts[i].Position.Y);
            }
            _width = max.X - _topLeftVertPosition.X;
            _height = max.Y - _topLeftVertPosition.Y;
            _areBoundsDirty = true;
            if (recalculateUVs)
            {
                for (var i = 0; i < _verts.Length; i++)
                {
                    _verts[i].TextureCoordinate.X = (_verts[i].Position.X - _topLeftVertPosition.X) / _width;
                    _verts[i].TextureCoordinate.Y = (_verts[i].Position.Y - _topLeftVertPosition.Y) / _height;
                }
            }
            return this;
        }
public Mesh recalculateBounds ( bool recalculateUVs ) { _topLeftVertPosition = new Vector2 ( float . MaxValue , float . MaxValue ) ; var max = new Vector2 ( float . MinValue , float . MinValue ) ; for ( var i = 0 ; i < _verts . Length ; i ++ ) { _topLeftVertPosition . X = MathHelper . Min ( _topLeftVertPosition . X , _verts [ i ] . Position . X ) ; _topLeftVertPosition . Y = MathHelper . Min ( _topLeftVertPosition . Y , _verts [ i ] . Position . Y ) ; max . X = MathHelper . Max ( max . X , _verts [ i ] . Position . X ) ; max . Y = MathHelper . Max ( max . Y , _verts [ i ] . Position . Y ) ; } _width = max . X - _topLeftVertPosition . X ; _height = max . Y - _topLeftVertPosition . Y ; _areBoundsDirty = true ; if ( recalculateUVs ) { for ( var i = 0 ; i < _verts . Length ; i ++ ) { _verts [ i ] . TextureCoordinate . X = ( _verts [ i ] . Position . X - _topLeftVertPosition . X ) / _width ; _verts [ i ] . TextureCoordinate . Y = ( _verts [ i ] . Position . Y - _topLeftVertPosition . Y ) / _height ; } } return this ; }
recalculates the bounds and optionally sets the UVs.
recalculates the bounds and optionally sets the UVs .
// handle UVs if need be
recalculateUVs
bool
If set to true
If set to true