private RenderContext CalculateRenderContext(ChunksToRender chunksToRender) { if (AffectedChannels.List.Contains(Channel.Mask)) { return(new RenderContext(Context.Channels.ToImmutable(), RenderCovering.Part, chunksToRender)); } else { return(new RenderContext(AffectedChannels.ToImmutable(), RenderCovering.Part, chunksToRender)); } }
private ChunksToRender CalculateChunksToRender(Vector2 brushPercentageSize, IEnumerable <Vector3> brushPositions) { var result = new ChunksToRender(Context); var chunkResolution = Context.ChunkResolution.AsInt; var textureResolution = Context.TextureResolution.AsInt; var isMultiTile = brushPercentageSize.x > chunkResolution / (float)textureResolution; foreach (var position in brushPositions) { var bottomLeft = new Vector2Int((int)(position.x * textureResolution / chunkResolution), (int)(position.y * textureResolution / chunkResolution)); var bottomRight = new Vector2Int((int)((position.x + brushPercentageSize.x) * textureResolution / chunkResolution), (int)(position.y * textureResolution / chunkResolution)); var topLeft = new Vector2Int((int)(position.x * textureResolution / chunkResolution), (int)((position.y + brushPercentageSize.y) * textureResolution / chunkResolution)); var topRight = new Vector2Int((int)((position.x + brushPercentageSize.x) * textureResolution / chunkResolution), (int)((position.y + brushPercentageSize.y) * textureResolution / chunkResolution)); if (isMultiTile) { for (int x = bottomLeft.x; x <= topRight.x; x++) { for (int y = bottomLeft.y; y <= topRight.y; y++) { result.AddChunkPosition(new Vector2Int(x, y)); } } } else { result.AddChunkPosition(bottomLeft); result.AddChunkPosition(bottomRight); result.AddChunkPosition(topLeft); result.AddChunkPosition(topRight); } } return(result); }