コード例 #1
0
        /// <summary>
        /// collector are thing for collecting info about colliders
        /// if you want to modify information or add maps there is best place to start
        /// </summary>
        private void PopulateCollectors()
        {
            if (profiler != null)
            {
                profiler.AddLog("collecting colliders");
            }

            HashSet <Collider> collidersHS = new HashSet <Collider>();

            //unity return ONE collider for terrain in editor but when playmode active it return lots! for evefy f*****g tree! who invent this? why?!
            foreach (var collider in Physics.OverlapBox(chunkOffsetedBounds.center, chunkOffsetedBounds.extents, Quaternion.identity, properties.includedLayers, QueryTriggerInteraction.Ignore))
            {
                collidersHS.Add(collider);//for this reason everything are puttet into hashset to exclude dublicates
            }

            Collider[] colliders = collidersHS.ToArray();

            colliderCollector          = new ColliderCollector(this);
            colliderCollector.profiler = profiler;
            colliderCollector.AddCollider(colliders);

            List <AreaWorldMod> mods = new List <AreaWorldMod>();

            ChunkContentMap.GetContent(chunkData.x, chunkData.z, mods); //this uses some grid based thing. you give it list to fill and where
            colliderCollector.AddModifyers(mods);
            hashData.AssignData();
        }
コード例 #2
0
        public void Collect()
        {
            shapeCollectorResult = ShapeCollector.GetFromPool(template.lengthX_extra, template.lengthZ_extra, template);

            if (profiler != null)
            {
                profiler.AddLog("Start Collecting Terrain");
            }
            CollectTerrainCPU(shapeCollectorResult);
            CollectTerrainGPU(shapeCollectorResult);
            if (profiler != null)
            {
                profiler.AddLog("End Collecting Terrain");
            }

            if (profiler != null)
            {
                profiler.AddLog("Start Collecting shapes");
            }
            CollectCollidersCPU(shapeCollectorResult);
            CollectCollidersGPU(shapeCollectorResult);
            if (profiler != null)
            {
                profiler.AddLog("End Collecting shapes");
            }


            if (profiler != null)
            {
                profiler.AddLog("Start Collecting shapes");
            }
            modsChangeArea.Sort(Comparer);
            modsMakeHole.Sort(Comparer);

            for (int i = 0; i < modsChangeArea.Count; i++)
            {
                shapeCollectorResult.ChangeArea(modsChangeArea[i].shapes, modsChangeArea[i].area);
            }

            for (int i = 0; i < modsMakeHole.Count; i++)
            {
                if (modsMakeHole[i].mode == ColliderInfoMode.MakeHoleApplyArea)
                {
                    shapeCollectorResult.MakeHole(modsMakeHole[i].shapes, modsMakeHole[i].area);
                }
                if (modsMakeHole[i].mode == ColliderInfoMode.MakeHoleRetainArea)
                {
                    shapeCollectorResult.MakeHole(modsMakeHole[i].shapes, null);
                }
            }

            if (profiler != null)
            {
                profiler.AddLog("End Collecting shapes");
            }
            //shapeCollectorGeneric.DebugMe();
        }
コード例 #3
0
        /// <summary>
        /// collector are thing for collecting info about colliders. this function are executing in main threads and collect further information
        /// if u wanna modify information or add maps there is best place to start
        /// </summary>
        private void PopulateCollectors()
        {
            if (profiler != null)
            {
                profiler.AddLog("collecting colliders");
            }

            HashSet <Collider> collidersHS = new HashSet <Collider>();

            //unity return ONE collider for terrain in editor but when playmode active it return lots! for evefy f*****g tree! who invent this? why?!
            foreach (var collider in Physics.OverlapBox(chunkOffsetedBounds.center, chunkOffsetedBounds.extents, Quaternion.identity, properties.includedLayers, QueryTriggerInteraction.Ignore))
            {
                collidersHS.Add(collider);
            }

            Collider[] colliders = collidersHS.ToArray();

            switch (PathFinder.terrainCollectionType)
            {
            case TerrainCollectorType.UnityWay:
                _terrainCollector = new ColliderCollectorTerrainUnityWay(this, colliders);
                break;

            case TerrainCollectorType.CPU:
                _terrainCollector = new ColliderCollectorTerrainCPU(this, colliders);
                break;

            case TerrainCollectorType.ComputeShader:
                _terrainCollector = new ColliderCollectorTerrainComputeShader(this, colliders);
                (_terrainCollector as ColliderCollectorTerrainComputeShader).CollectUsingComputeShader();
                break;
            }

            if (profiler != null)
            {
                profiler.AddLog("collected terrain templates: " + _terrainCollector.collectedCount);
                profiler.AddLog("start collecting primitive colliders");
            }

            switch (PathFinder.colliderCollectorType)
            {
            case ColliderCollectorType.CPU:
                _primitivesCollector = new ColliderCollectorPrimitivesCPU(this, colliders);
                break;

            case ColliderCollectorType.ComputeShader:
                _primitivesCollector = new ColliderCollectorPrimitivesComputeShader(this, colliders);
                (_primitivesCollector as ColliderCollectorPrimitivesComputeShader).CollectUsingComputeShader();
                break;
            }


            if (profiler != null)
            {
                profiler.AddLog("collected primitives: " + _primitivesCollector.collectedCount);
            }
        }