Skip to content

Commit

Permalink
Fixed Prefer Texmap and FlatView
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Aug 24, 2024
1 parent 1716ce0 commit 907365b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions CentrED/Map/LandObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private bool AlwaysFlat(ushort id)
{
ref var tileData = ref TileDataLoader.Instance.LandData[id];
// Water tiles are always flat
return tileData.TexID == 0 || tileData.IsWet || Application.CEDGame.MapManager.FlatView;
return tileData.TexID == 0 || tileData.IsWet;
}

private bool IsFlat(float x, float y, float z, float w)
Expand Down Expand Up @@ -72,23 +72,24 @@ public void UpdateId(ushort newId)
(Vertices[0].Position.Z, Vertices[1].Position.Z, Vertices[2].Position.Z, Vertices[3].Position.Z);
var isTexMapValid = TexmapsLoader.Instance.GetValidRefEntry(newId).Length > 0;
var isLandTileValid = ArtLoader.Instance.GetValidRefEntry(newId).Length > 0;
var alwaysFlat = AlwaysFlat(newId);
if (Application.CEDGame.MapManager.FlatView)
{
isStretched = false;
for (int i = 0; i < 4; i++)
{
Vertices[i].Normal = Vector3.Zero;
Vertices[i].Normal = Vector3.Up;
}
}
else if (isTexMapValid && !AlwaysFlat(newId))
else if (isTexMapValid && !alwaysFlat)
{
isStretched |= CalculateNormals(out var normals);
for (int i = 0; i < 4; i++)
{
Vertices[i].Normal = normals[i];
}
}
var useTexMap = isTexMapValid && (Config.Instance.PreferTexMaps || isStretched || !isLandTileValid);
var useTexMap = !alwaysFlat && isTexMapValid && (Config.Instance.PreferTexMaps || isStretched || !isLandTileValid);
if (newId < 0x4000)
{
if (useTexMap)
Expand Down Expand Up @@ -144,15 +145,15 @@ public void UpdateId(ushort newId)

public void UpdateRightCorner(float z)
{
if (AlwaysFlat(Tile.Id))
if (AlwaysFlat(Tile.Id) || Application.CEDGame.MapManager.FlatView)
return;

Vertices[1].Position.Z = z * TILE_Z_SCALE;
UpdateId(Tile.Id); //Reassign same Id, to reconsider art vs tex
}
public void UpdateLeftCorner(float z)
{
if (AlwaysFlat(Tile.Id))
if (AlwaysFlat(Tile.Id) || Application.CEDGame.MapManager.FlatView)
return;

Vertices[2].Position.Z = z * TILE_Z_SCALE;
Expand All @@ -161,7 +162,7 @@ public void UpdateLeftCorner(float z)

public void UpdateBottomCorner(float z)
{
if (AlwaysFlat(Tile.Id))
if (AlwaysFlat(Tile.Id) || Application.CEDGame.MapManager.FlatView)
return;

Vertices[3].Position.Z = z * TILE_Z_SCALE;
Expand Down
4 changes: 2 additions & 2 deletions CentrED/UI/Windows/OptionsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected override void InternalDraw()
ImGui.Checkbox("Show NoDraw tiles", ref CEDGame.MapManager.ShowNoDraw);
if (ImGui.Checkbox("Prefer Texture Map for land tiles", ref Config.Instance.PreferTexMaps))
{
CEDGame.MapManager.Reset();
CEDGame.MapManager.UpdateAllTiles();
}
ImGui.Checkbox("Legacy mouse scroll behavior", ref Config.Instance.LegacyMouseScroll);
UIManager.Tooltip("Mouse scroll up/down: elevate tile\nCtrl + Mouse scroll up/down: Zoom in/out");
Expand Down Expand Up @@ -122,7 +122,7 @@ private void DrawLightOptions()
}
if (ImGui.Checkbox("ClassicUO Terrain Lighting", ref LightsManager.Instance.ClassicUONormals))
{
CEDGame.MapManager.Reset();
CEDGame.MapManager.UpdateAllTiles();
}
UIManager.Tooltip("Switches between terrain looking like original client and ClassicUO");
}
Expand Down

0 comments on commit 907365b

Please sign in to comment.