private void AddPointToLevelOfDetails(HashEntry hashEntry, Vector3 pointPosition, GameObject voxel) { int i = 0; foreach (Division d in m_Divisions) { GameObject levelContainer = GetLODContainer(voxel, d.numberOfDivisions); Vector3 localPoint = levelContainer.transform.InverseTransformPoint(pointPosition); Vector3 newPoint = GetClosestCenterByDivision(localPoint, d.numberOfDivisions); // Make a hash of the subvoxel based on the level and the CenterPoint int subHash = GetHash(newPoint, 100, m_HashTableSize); if (!hashEntry.lodContains(d.numberOfDivisions, subHash)) { //Debug.Log("> NewPoint: " + " " + hashEntry.hash + " " + newPoint + " SubHash: " + subHash); GameObject subVoxel = AddPointToVoxel(levelContainer, pointPosition); if (i == 0) { subVoxel.GetComponent <MeshRenderer>().material = PointcloudVisualizer.MaterialBlue; } hashEntry.lodCreateNewHash(d.numberOfDivisions, subHash, new Voxel(subVoxel)); subVoxel.name = levelContainer.name + "_voxel"; float subVoxelScale = 1.0f / (float)d.numberOfDivisions; subVoxel.transform.localPosition = newPoint; subVoxel.transform.localScale = new Vector3(subVoxelScale, subVoxelScale, subVoxelScale) * 0.95f; levelContainer.transform.SetParent(GameObject.Find("_voxel_" + hashEntry.hash).transform); hashEntry.lodGameObjects.Add(d.numberOfDivisions, levelContainer); DebugText.Instance.increaseNumberOfDetails(i); } i++; } }