<commit_before>using Microsoft.Xna.Framework.Graphics;

namespace CocosSharp
{
    internal struct CCV3F_T2F : IVertexType
    {
        internal static readonly VertexDeclaration VertexDeclaration;

        /// <summary>
        /// vertices (3F)
        /// </summary>
        internal CCVertex3F vertices; // 12 bytes

        /// <summary>
        /// tex coords (2F)
        /// </summary>
        internal CCTex2F texCoords; // 8 byts

        static CCV3F_T2F()
        {
            var elements = new[]
                {
                    new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
                    new VertexElement(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
                };
            VertexDeclaration = new VertexDeclaration(elements);
        }

        #region IVertexType Members

        VertexDeclaration IVertexType.VertexDeclaration
        {
            get { return VertexDeclaration; }
        }

        #endregion
    }

    /// <summary> 
    /// CCGrid3D is a 3D grid implementation. Each vertex has 3 dimensions: x,y,z
    /// </summary>
    public class CCGrid3D : CCGridBase
    {
        private bool m_bDirty;
        private CCIndexBuffer<ushort> m_pIndexBuffer;
        protected ushort[] m_pIndices;
        protected CCVertex3F[] m_pOriginalVertices;
        private CCVertexBuffer<CCV3F_T2F> m_pVertexBuffer;
        internal CCV3F_T2F[] m_pVertices;

        //protected CCPoint[] m_pTexCoordinates;
        //protected ccVertex3F[] m_pVertices;

        /// <summary>
        /// returns the vertex at a given position
        /// </summary>
        public CCVertex3F Vertex(CCGridSize pos)
        {
            return m_pVertices[pos.X * (m_sGridSize.Y + 1) + pos.Y].vertices;
        }

        /// <summary>
        /// returns the original (non-transformed) vertex at a given position
        /// </summary>
        public CCVertex3F OriginalVertex(CCGridSize pos)
        {
            return m_pOriginalVertices[pos.X * (m_sGridSize.Y + 1) + pos.Y];
        }

        /// <summary>
        /// sets a new vertex at a given position
        /// </summary>
        public void SetVertex(CCGridSize pos, ref CCVertex3F vertex)
        {
            m_pVertices[pos.X * (m_sGridSize.Y + 1) + pos.Y].vertices = vertex;
            m_bDirty = true;
        }

        public override void Blit()
        {
            if (m_bDirty)
            {
                m_pVertexBuffer.UpdateBuffer();
            }

            bool save = CCDrawManager.VertexColorEnabled;<commit_msg>Added accessor methods to CCGrid3D that takes an int x and int y so that we do not have keep creating CCGridSize struct all over the place just to Get and Set the Grid vertices.<commit_after>using Microsoft.Xna.Framework.Graphics;

namespace CocosSharp
{
    internal struct CCV3F_T2F : IVertexType
    {
        internal static readonly VertexDeclaration VertexDeclaration;

        /// <summary>
        /// vertices (3F)
        /// </summary>
        internal CCVertex3F vertices; // 12 bytes

        /// <summary>
        /// tex coords (2F)
        /// </summary>
        internal CCTex2F texCoords; // 8 byts

        static CCV3F_T2F()
        {
            var elements = new[]
                {
                    new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
                    new VertexElement(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
                };
            VertexDeclaration = new VertexDeclaration(elements);
        }

        #region IVertexType Members

        VertexDeclaration IVertexType.VertexDeclaration
        {
            get { return VertexDeclaration; }
        }

        #endregion
    }

    /// <summary> 
    /// CCGrid3D is a 3D grid implementation. Each vertex has 3 dimensions: x,y,z
    /// </summary>
    public class CCGrid3D : CCGridBase
    {
        private bool m_bDirty;
        private CCIndexBuffer<ushort> m_pIndexBuffer;
        protected ushort[] m_pIndices;
        protected CCVertex3F[] m_pOriginalVertices;
        private CCVertexBuffer<CCV3F_T2F> m_pVertexBuffer;
        internal CCV3F_T2F[] m_pVertices;

        //protected CCPoint[] m_pTexCoordinates;
        //protected ccVertex3F[] m_pVertices;

        /// <summary>
        /// returns the vertex at a given position
        /// </summary>
        public CCVertex3F Vertex(CCGridSize pos)
        {
            return m_pVertices[pos.X * (m_sGridSize.Y + 1) + pos.Y].vertices;
        }

		/// <summary>
		/// returns the vertex at a given position
		/// </summary>
		public CCVertex3F Vertex(int x, int y)
		{
			return m_pVertices[x * (m_sGridSize.Y + 1) + y].vertices;
		}

        /// <summary>
        /// returns the original (non-transformed) vertex at a given position
        /// </summary>
        public CCVertex3F OriginalVertex(CCGridSize pos)
        {
            return m_pOriginalVertices[pos.X * (m_sGridSize.Y + 1) + pos.Y];
        }

		/// <summary>
		/// returns the original (non-transformed) vertex at a given position
		/// </summary>
		public CCVertex3F OriginalVertex(int x, int y)
		{
			return m_pOriginalVertices[x * (m_sGridSize.Y + 1) + y];
		}

        /// <summary>
        /// sets a new vertex at a given position
        /// </summary>
        public void SetVertex(CCGridSize pos, ref CCVertex3F vertex)
        {
            m_pVertices[pos.X * (m_sGridSize.Y + 1) + pos.Y].vertices = vertex;
            m_bDirty = true;
        }

		/// <summary>
		/// sets a new vertex at a given position
		/// </summary>
		public void SetVertex(int x, int y, ref CCVertex3F vertex)
		{
			m_pVertices[x * (m_sGridSize.Y + 1) + y].vertices = vertex;
			m_bDirty = true;
		}

        public override void Blit()
        {
            if (m_bDirty)
            {
                m_pVertexBuffer.UpdateBuffer();
            }

            bool save = CCDrawManager.VertexColorEnabled;
{'fraction_non_alphanumeric': 0.0966022651565623, 'fraction_numerical': 0.012491672218520987, 'mean_word_length': 1.8446234012316438, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7361731', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1785, 'n_words': 447}