示例#1
0
        public void EndRequestSpace()
        {
            int vertex_count = r_quad_count * 4;

            if (!build_transform_job_datas.IsCreated)
            {
                build_transform_job_datas = new NativeBuffer <BuildTransformJobData>(r_capacity, Allocator.Persistent);
                build_transform_job_datas.AddLength(r_capacity);
                build_quad_datas = new NativeBuffer <BuildPerQuadData>(r_quad_count, Allocator.Persistent);
                build_quad_datas.AddLength(r_quad_count);
                vertex_datas = new NativeBuffer <Vertex>(vertex_count, Allocator.Persistent);
                vertex_datas.AddLength(vertex_count);
            }
            else
            {
                build_transform_job_datas.AddLength(r_capacity);
                build_quad_datas.AddLength(r_quad_count);
                vertex_datas.AddLength(vertex_count);
            }

            foreach (var info in pending_infos)
            {
                buffer_infos.Add(info.offset, info);
            }

            pending_infos.Clear();
        }
        public void EndCollectionMeshInfo(JobHandle batchs_handle)
        {
            int out_buffer_length = max_mesh_quad_count;
            int need_add          = out_buffer_length - out_poices.Length;

            if (need_add > 0)
            {
                int v_add = need_add * 4;
                out_poices.AddLength(v_add);
                out_uv0.AddLength(v_add);
                out_uv1.AddLength(v_add);
                out_colors.AddLength(v_add);
                out_indices.AddLength(need_add * 6);
            }

            var job = new CollectionMeshInfoJob()
            {
                vertices        = batch_data.vertex_datas,
                transform_datas = batch_data.build_transform_job_datas,
                quad_datas      = batch_data.build_quad_datas,

                transform_indices = transform_indices,
                offset_info       = indeices_offset,
                mesh_quad_count   = max_mesh_quad_count,

                out_poices  = out_poices,
                out_uv0     = out_uv0,
                out_uv1     = out_uv1,
                out_colors  = out_colors,
                out_indices = out_indices
            };

            //batchs_handle.Complete();
            handle       = job.Schedule(indeices_offset.Length, 1, batchs_handle);
            is_job_valid = true;
            JobHandle.ScheduleBatchedJobs();
        }