Beispiel #1
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);
            }
        }
Beispiel #2
0
 static ColliderCollectorPrimitivesCPU()
 {
     //to make shure it's loaded
     ColliderCollectorPrimitivesAbstract.EmptyStaticMethodToShureBaseStaticAreLOaded();
 }