Skip to content

Commit

Permalink
Patch up the city painter a little, add the final town hall island
Browse files Browse the repository at this point in the history
City painter needs a lot of work, especially in terms of performance.
  • Loading branch information
riperiperi committed Dec 2, 2024
1 parent 9d083e8 commit 2f86b3a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
15 changes: 14 additions & 1 deletion TSOClient/tso.client/Rendering/City/Plugins/MapPainterPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ public class MapPainterPlugin : AbstractCityPlugin
new Color(255, 255, 255), //snow
new Color(255, 255, 0) //sand
};

public byte[] TerrainTypeIndices = new byte[] {
0, //grass
4, //water
2, //rock
3, //snow
1 //sand
};

public string[] TerrainTypeNames = new string[] {
"Grass",
"Water",
Expand Down Expand Up @@ -292,7 +301,11 @@ public override void TileHover(Vector2? tile)
{
BrushFunc(BrushSize, (x, y, strength) =>
{
if (strength > 0) City.MapData.TerrainTypeColorData[newPt.X+x + (newPt.Y+y) * 512] = TerrainTypes[SelectedModifier];
if (strength > 0)
{
City.MapData.TerrainTypeColorData[newPt.X + x + (newPt.Y + y) * 512] = TerrainTypes[SelectedModifier];
City.MapData.TerrainType[newPt.X + x + (newPt.Y + y) * 512] = TerrainTypeIndices[SelectedModifier];
}
});

AddChange(new Rectangle(newPt.X - (1+BrushSize), newPt.Y - (1+BrushSize), 3+BrushSize*2, 3+BrushSize*2));
Expand Down
16 changes: 15 additions & 1 deletion TSOClient/tso.client/Rendering/City/Terrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,21 @@ public void GenerateCityMesh(GraphicsDevice gd, Rectangle? range)
Geometry.MapData = Content.MapData;
SubdivGeometry.MapData = Content.MapData;
Foliage.MapData = Content.MapData;
Geometry.RegenMeshVerts(gd, range);

if (range == null)
{
Geometry.RegenMeshVerts(gd, range);
}
else
{
var pos = Camera.CalculateR();
var slicex = Math.Max(0, Math.Min(30, (int)Math.Round(pos.X / 16f) - 1));
var slicey = Math.Max(0, Math.Min(30, (int)Math.Round(pos.Y / 16f) - 1));
var slice = slicex + slicey * 32;

//Geometry.RegenMeshVerts(gd, range);
SubdivGeometry.SubRegenMeshVerts(m_GraphicsDevice, new Rectangle(slicex * 16, slicey * 16, 32, 32), 4, slice);
}
}

private Vector3 GetNormalAt(int x, int y)
Expand Down
Binary file modified TSOClient/tso.content/Content/Cities/city_0100/elevation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TSOClient/tso.content/Content/Cities/city_0100/terraintype.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2f86b3a

Please sign in to comment.