public void GetSectors(FastList <Sector3D <T> > list, Vector3 pos, float radius) { list.FastClear(); Int3 startSector = GetSectorIndex(new Vector3(pos.x - radius, pos.y - radius, pos.z - radius)); Int3 endSector = GetSectorIndex(new Vector3(pos.x + radius, pos.y + radius, pos.z + radius)); for (int z = startSector.z; z < endSector.z; z++) { for (int y = startSector.y; y <= endSector.y; y++) { for (int x = startSector.x; x <= endSector.x; x++) { if (sectors[x, y, z] == null) { continue; } list.Add(sectors[x, y, z]); } } } }
static public bool Create(Transform parentT, LayerMask overlapLayerMask, int lodGroupLayer, ref GameObject overlapCollidersGO, bool removeSamePositionTriangles) { colliderScaleMulti = (removeSamePositionTriangles ? 1.001f : 1f); lookupOrigCollider.Clear(); lookupColliderOrig.Clear(); lodInfoLookup.Clear(); lodGroupMeshes.Clear(); lodInfos.Clear(); SaveCollidersState(overlapLayerMask); int layerMaskValue = overlapLayerMask.value; if (layerMaskValue == 0) { return(false); } overlapLayer = Methods.GetFirstLayerInLayerMask(layerMaskValue); overlapCollidersGO = new GameObject("Overlap Colliders"); newT = overlapCollidersGO.transform; newT.parent = parentT; var lodGroups = Methods.SearchAllScenes <LODGroup>(false); for (int i = 0; i < lodGroups.Count; i++) { LODGroup lodGroup = lodGroups.items[i]; GameObject go = lodGroup.gameObject; if (!go.activeInHierarchy || !Methods.LayerMaskContainsLayer(layerMaskValue, go.layer)) { lodGroups.RemoveAt(i--); continue; } LodInfo lodInfo = new LodInfo(); lodInfo.CreateLodGroupColliders(lodGroup, newT); } if (lodInfos.Count > 0) { foundLodGroup = true; } var mrs = Methods.SearchAllScenes <MeshRenderer>(false); FastList <MeshFilter> mfs = new FastList <MeshFilter>(); for (int i = 0; i < mrs.Count; i++) { MeshRenderer mr = mrs.items[i]; GameObject go = mr.gameObject; if (mr.enabled && go.activeInHierarchy && Methods.LayerMaskContainsLayer(layerMaskValue, go.layer)) { MeshFilter mf = mr.GetComponent <MeshFilter>(); if (mf == null) { continue; } Mesh mesh = mf.sharedMesh; if (mesh == null || lodGroupMeshes.Contains(mesh)) { continue; } mfs.Add(mf); } } for (int i = 0; i < mfs.Count; i++) { MeshFilter mf = mfs.items[i]; CreateMeshCollider(mf, newT, "_"); } #if !UNITY_2017 Physics.SyncTransforms(); #endif return(true); }