bool MoveEntities(EntityManager srcManager, Entity sceneEntity)
        {
            NativeArray <EntityRemapUtility.EntityRemapInfo> entityRemapping;

            using (m_ExtractEntityRemapRefs.Auto())
            {
                if (!ExtractEntityRemapRefs(srcManager, out entityRemapping))
                {
                    return(false);
                }
            }


            var startCapacity = srcManager.EntityCapacity;

            using (m_AddSceneSharedComponents.Auto())
            {
#if UNITY_EDITOR
                var data = new EditorRenderData()
                {
                    SceneCullingMask = UnityEditor.SceneManagement.EditorSceneManager.DefaultSceneCullingMask | (1UL << 59),
                    PickableObject   = EntityManager.HasComponent <SubScene>(sceneEntity) ? EntityManager.GetComponentObject <SubScene>(sceneEntity).gameObject : null
                };
                srcManager.AddSharedComponentData(srcManager.UniversalQuery, data);
#endif

                srcManager.AddSharedComponentData(srcManager.UniversalQuery, new SceneTag {
                    SceneEntity = sceneEntity
                });
            }
            var endCapacity = srcManager.EntityCapacity;

            // ExtractEntityRemapRefs gathers entityRemapping based on Entities Capacity.
            // MoveEntitiesFrom below assumes that AddSharedComponentData on srcManager.UniversalQuery does not affect capacity.
            Assert.AreEqual(startCapacity, endCapacity);

            using (m_MoveEntitiesFrom.Auto())
            {
                EntityManager.MoveEntitiesFrom(srcManager, entityRemapping);
            }

            entityRemapping.Dispose();
            srcManager.PrepareForDeserialize();

            return(true);
        }
        private void NewMethod(FrozenRenderSceneTag tag, NativeArray <ArchetypeChunk> chunks,
                               NativeArray <int> sharedRendererCounts,
                               NativeArray <int> sortedChunkIndices, int sharedRenderCount,
                               ArchetypeChunkComponentType <RenderMeshFlippedWindingTag> meshInstanceFlippedTagType,
                               ArchetypeChunkSharedComponentType <EditorRenderData> editorRenderDataType,
                               ArchetypeChunkSharedComponentType <RenderMesh> RenderMeshType)
        {
            var job = new BatchingJob()
            {
                NativeEditorRenderDataIndex = new NativeList <int>(Allocator.TempJob),
                NativeDataArray1            = new NativeList <int4>(Allocator.TempJob),
                NativeFlipped        = new NativeList <bool>(Allocator.TempJob),
                SharedRendererCounts = sharedRendererCounts,
                SortedChunkIndices   = sortedChunkIndices,
                Chunks                     = chunks,
                SharedRenderCount          = sharedRenderCount,
                MeshInstanceFlippedTagType = meshInstanceFlippedTagType,
                EditorRenderDataType       = editorRenderDataType,
                RenderMeshType             = RenderMeshType
            };

            job.Run();

            for (int i = 0; i < job.NativeDataArray1.Length; i++)
            {
                var editorDataIndex = job.NativeEditorRenderDataIndex[i];
                EditorRenderData editorRenderData = m_DefaultEditorRenderData;

                if (editorDataIndex != -1)
                {
                    editorRenderData = EntityManager.GetSharedComponentData <EditorRenderData>(editorDataIndex);
                }

                var data1 = job.NativeDataArray1[i];

                m_InstancedRenderMeshBatchGroup.AddBatch(tag, data1.x,
                                                         data1.z, chunks, sortedChunkIndices, data1.y,
                                                         data1.w, job.NativeFlipped[i],
                                                         editorRenderData);
            }

            job.Dispose();
        }
Exemple #3
0
        bool MoveEntities(EntityManager srcManager, Entity sceneEntity)
        {
            NativeArray <EntityRemapUtility.EntityRemapInfo> entityRemapping;

            using (m_ExtractEntityRemapRefs.Auto())
            {
                if (!ExtractEntityRemapRefs(srcManager, out entityRemapping))
                {
                    return(false);
                }
            }

            using (m_AddSceneSharedComponents.Auto())
            {
#if UNITY_EDITOR
                var data = new EditorRenderData()
                {
                    SceneCullingMask = UnityEditor.SceneManagement.EditorSceneManager.DefaultSceneCullingMask | (1UL << 59),
                    PickableObject   = EntityManager.HasComponent <SubScene>(sceneEntity) ? EntityManager.GetComponentObject <SubScene>(sceneEntity).gameObject : null
                };
                srcManager.AddSharedComponentData(srcManager.UniversalGroup, data);
#endif

                srcManager.AddSharedComponentData(srcManager.UniversalGroup, new SceneTag {
                    SceneEntity = sceneEntity
                });
            }


            using (m_MoveEntitiesFrom.Auto())
            {
                EntityManager.MoveEntitiesFrom(srcManager, entityRemapping);
            }

            entityRemapping.Dispose();
            srcManager.PrepareForDeserialize();

            return(true);
        }