public SceneContext( IGroupSelector groupSelector, ITerrainGenerator2i terrainGenerator, IMeshUpdater meshUpdater, Vector3 cameraPosition, IReadOnlyList <Plane> cameraPlanes, IReadOnlyPooledList <Vector3> cameraFrustumCorners, Matrix4x4 cameraLocalToWorldMatrix, Matrix4x4 parentContainerWorldToLocalMatrix, IReadOnlySet <Vector2i> existingGroups, Vector2i cellInGroupCount, IImage2i image, Rect2i invalidatedArea_imageSpace, IImageSampler2i imageSampler, Func <GameObject> gameObjectFactory, ProfilerFactoryDelegate profilerFactory, LoggerFactoryDelegate loggerFactory) { GroupSelector = groupSelector; TerrainGenerator = terrainGenerator; MeshUpdater = meshUpdater; CameraPosition = cameraPosition; CameraPlanes = cameraPlanes; CameraFrustumCorners = cameraFrustumCorners; CameraLocalToWorldMatrix = cameraLocalToWorldMatrix; ParentContainerWorldToLocalMatrix = parentContainerWorldToLocalMatrix; ExistingGroups = existingGroups; CellInGroupCount = cellInGroupCount; Image = image; ImageSampler = imageSampler; GameObjectFactory = gameObjectFactory; ProfilerFactory = profilerFactory; LoggerFactory = loggerFactory; RangeZ = image.RangeZ; GroupBounds = new Bounds(new Vector3(CellInGroupCount.x / 2.0f, CellInGroupCount.y / 2.0f, RangeZ.Center), new Vector3(CellInGroupCount.x, CellInGroupCount.y, RangeZ.Size)); InvalidatedArea_worldSpace = ImageSampler .ImageToWorld(invalidatedArea_imageSpace) .RoundToContain(); (Image as IInitializableImage)?.StartUsing(); }
public static Rect ImageToWorld(this IImageSampler2i sampler, Rect2i rect) { var min = sampler.ImageToWorld(rect.min); var max = sampler.ImageToWorld(rect.max); return Rect.MinMaxRect(min.x, min.y, max.x, max.y); }