VoxelPrefab CreateVoxel(Vector3Int position) { if (!createdVoxels.ContainsKey(position)) { VoxelPrefab go = Instantiate(voxelPrefab.gameObject, position, lastVoxelCreated.rootEntity.gameObject.transform.rotation).GetComponent <VoxelPrefab>(); createdVoxels.Add(position, go); return(go); } return(null); }
bool IsVoxelAtValidPoint(VoxelPrefab voxelPrefab, List <DCLBuilderInWorldEntity> entitiesToCheck) { if (!currentScene.IsInsideSceneBoundaries(voxelPrefab.meshRenderer.bounds)) { return(false); } Bounds bounds = voxelPrefab.meshRenderer.bounds; bounds.size -= Vector3.one * VOXEL_BOUND_ERROR; foreach (DCLBuilderInWorldEntity entity in entitiesToCheck) { if (entity.rootEntity.meshesInfo == null || entity.rootEntity.meshesInfo.renderers == null) { continue; } if (bounds.Intersects(entity.rootEntity.meshesInfo.mergedBounds)) { return(false); } } bounds.size += Vector3.one * VOXEL_BOUND_ERROR; return(true); }