             }
         }
 
-        updateChanges.newImage = terrainImage.GetSubimage(IntRect(updateChanges.offset.x, updateChanges.offset.y, updateChanges.offset.x + brushImageWidth, updateChanges.offset.y + brushImageHeight));
+        updateChanges.newImage = terrainImage.GetSubimage(boundsRect);
     }
 
     private void UpdateTerrainSetHeight(Image@ terrainImage, IntVector2 position, TerrainEditorUpdateChanges@ updateChanges)

        uint brushImageHeight = scaledSelectedBrushImage.height;

        updateChanges.offset = IntVector2(position.x - (brushImageWidth / 2), position.y - (brushImageHeight / 2));
        updateChanges.oldImage = terrainImage.GetSubimage(IntRect(updateChanges.offset.x, updateChanges.offset.y, updateChanges.offset.x + brushImageWidth, updateChanges.offset.y + brushImageHeight));

        // Iterate over the entire brush image
        for (int y = 0; y < brushImageHeight; ++y)

            }
        }
    }

    private IntRect ClipIntRectToHeightmapBounds(Image@ terrainImage, IntRect intRect) {
        if (intRect.left > terrainImage.width)
            intRect.left = terrainImage.width;

        if (intRect.right > terrainImage.width)
            intRect.right = terrainImage.width;

        if (intRect.top > terrainImage.height)
            intRect.top = terrainImage.height;

        if (intRect.bottom > terrainImage.height)
            intRect.bottom = terrainImage.height;

        return intRect;
    }
}
