<commit_before>﻿using System.Collections.Generic;
using Assets.Engine.Scripts.Builders;
using Assets.Engine.Scripts.Common.DataTypes;
using RenderBuffer = Assets.Engine.Scripts.Rendering.RenderBuffer;
using Assets.Engine.Scripts.Rendering;
using UnityEngine;

namespace Assets.Engine.Scripts.Core.Chunks
{
    /// <summary>
    ///     Represents one vertical part of a chunk
    /// </summary>
    public class MiniChunk: IOcclusionEntity
    {
        #region Public Properties

        //! The render buffer used for building MiniChunk geometry
        public RenderBuffer SolidRenderBuffer { get; private set; }        
        
        //! Current LOD level of the chunk. NOTE: Leftover. This needs to be done completely differently
        public int LOD { get; set; }

        //! True if MiniSection has already been built
        public bool IsBuilt { get; set; }

        public Vector2Int Pos
        {
            get { return m_parentChunk.Pos; }
        }

        //! Number of blocks which not air (non-empty blocks)
        public int NonEmptyBlocks { get; set; }

        public int OffsetY { get; private set; }

        //! Bounding box in world coordinates
        public Bounds WorldBounds { get; set; }

        #endregion Public Properties

        #region Private variabls

        //! Chunk owning this section
        private readonly Chunk m_parentChunk;
        //! Draw call batcher for this chunk
        private readonly DrawCallBatcher m_drawCallBatcher;

        #endregion Private variabls

        #region Constructor

        public MiniChunk(Chunk parentChunk, int positionY)
        {
            m_parentChunk = parentChunk;
            OffsetY = positionY * EngineSettings.ChunkConfig.Size;

            m_drawCallBatcher = new DrawCallBatcher(Globals.CubeMeshBuilder);
            SolidRenderBuffer = new RenderBuffer(Globals.CubeMeshBuilder);
            BBoxVertices = new List<Vector3>();
            BBoxVerticesTransformed = new List<Vector3>();

            Reset();
        }

        #endregion Constructor
        
        #region Public Methods

        public void Reset()
        {
            LOD = 0;
            NonEmptyBlocks = 0;            
            IsBuilt = false;

            m_drawCallBatcher.Clear();

            ResetBoundingMesh();
        }

        public void ResetBoundingMesh()
        {
            BBoxVertices.Clear();<commit_msg>[F] Always clear the render buffer when a chunk section is reset<commit_after>﻿using System.Collections.Generic;
using Assets.Engine.Scripts.Builders;
using Assets.Engine.Scripts.Common.DataTypes;
using RenderBuffer = Assets.Engine.Scripts.Rendering.RenderBuffer;
using Assets.Engine.Scripts.Rendering;
using UnityEngine;

namespace Assets.Engine.Scripts.Core.Chunks
{
    /// <summary>
    ///     Represents one vertical part of a chunk
    /// </summary>
    public class MiniChunk: IOcclusionEntity
    {
        #region Public Properties

        //! The render buffer used for building MiniChunk geometry
        public RenderBuffer SolidRenderBuffer { get; private set; }        
        
        //! Current LOD level of the chunk. NOTE: Leftover. This needs to be done completely differently
        public int LOD { get; set; }

        //! True if MiniSection has already been built
        public bool IsBuilt { get; set; }

        public Vector2Int Pos
        {
            get { return m_parentChunk.Pos; }
        }

        //! Number of blocks which not air (non-empty blocks)
        public int NonEmptyBlocks { get; set; }

        public int OffsetY { get; private set; }

        //! Bounding box in world coordinates
        public Bounds WorldBounds { get; set; }

        #endregion Public Properties

        #region Private variabls

        //! Chunk owning this section
        private readonly Chunk m_parentChunk;
        //! Draw call batcher for this chunk
        private readonly DrawCallBatcher m_drawCallBatcher;

        #endregion Private variabls

        #region Constructor

        public MiniChunk(Chunk parentChunk, int positionY)
        {
            m_parentChunk = parentChunk;
            OffsetY = positionY * EngineSettings.ChunkConfig.Size;

            m_drawCallBatcher = new DrawCallBatcher(Globals.CubeMeshBuilder);
            SolidRenderBuffer = new RenderBuffer(Globals.CubeMeshBuilder);
            BBoxVertices = new List<Vector3>();
            BBoxVerticesTransformed = new List<Vector3>();

            Reset();
        }

        #endregion Constructor
        
        #region Public Methods

        public void Reset()
        {
            LOD = 0;
            NonEmptyBlocks = 0;            
            IsBuilt = false;

            m_drawCallBatcher.Clear();
            SolidRenderBuffer.Clear();

            ResetBoundingMesh();
        }

        public void ResetBoundingMesh()
        {
            BBoxVertices.Clear();
{'fraction_non_alphanumeric': 0.0725050916496945, 'fraction_numerical': 0.002036659877800407, 'mean_word_length': 2.0389851485148514, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2777', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1232, 'n_words': 379}