Skip to content

Instantly share code, notes, and snippets.

@jspillers
Created April 12, 2017 14:00
Show Gist options
  • Save jspillers/27368e1079235181a3dea8acd38a0e84 to your computer and use it in GitHub Desktop.
Save jspillers/27368e1079235181a3dea8acd38a0e84 to your computer and use it in GitHub Desktop.
one method from a c# class
private void FlattenVolume() {
float flattenToY = Mathf.Lerp(deformerCollider.bounds.min.y, deformerCollider.bounds.max.y, flattenTo);
float flattenHeight = Coord.WorldHeightToTerrainHeight(flattenToY, terrain);
foreach (Vertex v in this.localHeightMap.localHeightmapVertices) {
if (v.insideDeformerCollider || (!v.insideDeformerCollider && this.flattenArea)) {
if (v.areaZ < this.terrainArea.terrainHeights.GetLength(0) || v.areaX < this.terrainArea.terrainHeights.GetLength(1)) {
this.terrainArea.terrainHeights[v.areaZ, v.areaX] = flattenHeight;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment