Example #1
0
        public void DirtyHeightmapRegion(RectInt region, TerrainHeightmapSyncControl syncControl)
        {
            int resolution = heightmapResolution;

            if (region.x < 0 || region.x >= resolution)
            {
                throw new ArgumentOutOfRangeException("region.x");
            }
            else if (region.width <= 0 || region.xMax > resolution)
            {
                throw new ArgumentOutOfRangeException("region.width");
            }
            if (region.y < 0 || region.y >= resolution)
            {
                throw new ArgumentOutOfRangeException("region.y");
            }
            else if (region.height <= 0 || region.yMax > resolution)
            {
                throw new ArgumentOutOfRangeException("region.height");
            }

            Internal_DirtyHeightmapRegion(region.x, region.y, region.width, region.height, syncControl);
            Experimental.TerrainAPI.TerrainCallbacks.InvokeHeightmapChangedCallback(this, region, syncControl == TerrainHeightmapSyncControl.HeightAndLod);
        }
 private extern void Internal_DirtyHeightmapRegion(int x, int y, int width, int height, TerrainHeightmapSyncControl syncControl);
 private extern void Internal_CopyActiveRenderTextureToHeightmap(RectInt rect, int destX, int destY, TerrainHeightmapSyncControl syncControl);
Example #4
0
        public void CopyActiveRenderTextureToHeightmap(RectInt sourceRect, Vector2Int dest, TerrainHeightmapSyncControl syncControl)
        {
            var source = RenderTexture.active;

            if (source == null)
            {
                throw new InvalidOperationException("Active RenderTexture is null.");
            }

            if (sourceRect.x < 0 || sourceRect.y < 0 || sourceRect.xMax > source.width || sourceRect.yMax > source.height)
            {
                throw new ArgumentOutOfRangeException("sourceRect");
            }
            else if (dest.x < 0 || dest.x + sourceRect.width > heightmapResolution)
            {
                throw new ArgumentOutOfRangeException("dest.x");
            }
            else if (dest.y < 0 || dest.y + sourceRect.height > heightmapResolution)
            {
                throw new ArgumentOutOfRangeException("dest.y");
            }

            Internal_CopyActiveRenderTextureToHeightmap(sourceRect, dest.x, dest.y, syncControl);
            Experimental.TerrainAPI.TerrainCallbacks.InvokeHeightmapChangedCallback(this, new RectInt(dest.x, dest.y, sourceRect.width, sourceRect.height), syncControl == TerrainHeightmapSyncControl.HeightAndLod);
        }