Skip to content

Commit

Permalink
Fix rendering issues caused by ceilings change
Browse files Browse the repository at this point in the history
  • Loading branch information
riperiperi committed Dec 2, 2024
1 parent e4d3c9a commit 12bc7bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions TSOClient/tso.world/Components/3DFloorGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private Vector4 GetParallaxMatrix(WorldState state)
}

public void DrawFloor(GraphicsDevice gd, GrassEffect e, WorldZoom zoom, WorldRotation rot, List<Texture2D> roommaps, HashSet<sbyte> floors, EffectPass pass,
Matrix? lightWorld = null, WorldState state = null, int minFloor = 0, bool screenAlignUV = false)
Matrix? lightWorld = null, WorldState state = null, int minFloor = 0, bool screenAlignUV = false, bool withCeilings = false)
{
bool is3D = state?.CameraMode == CameraRenderMode._3D;
var parallax = WorldConfig.Current.Complex;
Expand All @@ -290,7 +290,7 @@ public void DrawFloor(GraphicsDevice gd, GrassEffect e, WorldZoom zoom, WorldRot
e.ScreenAlignUV = screenAlignUV;
var baseRS = gd.RasterizerState;

if (lightWorld == null)
if (withCeilings)
{
gd.RasterizerState = RasterizerState.CullCounterClockwise;
}
Expand Down Expand Up @@ -495,7 +495,7 @@ public void DrawFloor(GraphicsDevice gd, GrassEffect e, WorldZoom zoom, WorldRot
}
gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, type.Value.GeomForOffset.Count * 2);

if (f > 1 && is3D && lightWorld == null)
if (f > 1 && is3D && withCeilings)
{
// Draw ceilings in 3D mode.
gd.RasterizerState = RasterizerState.CullClockwise;
Expand Down
5 changes: 4 additions & 1 deletion TSOClient/tso.world/Components/Geometry/Modelled3DFloor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ protected void AppendTile(List<int> inds, List<TerrainParallaxVertex> verts, Mod

var srcInds = tile.Indices;
var indLength = srcInds.Length;
for (int i=0; i<indLength; i++)
for (int i=0; i<indLength; i+=3)
{
// Flip the triangles to match the terrain geometry.
inds.Add(srcInds[i] + baseInd);
inds.Add(srcInds[i + 2] + baseInd);
inds.Add(srcInds[i + 1] + baseInd);
}

var baseX = (int)Math.Max(1, Math.Min(Bp.Width - 1, tileBaseX));
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.world/Components/TerrainComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public override void Draw(GraphicsDevice device, WorldState world){
var floors = new HashSet<sbyte>();
for (sbyte f = 0; f < world.Level; f++) floors.Add(f);
var pass = Effect.CurrentTechnique.Passes[(_3d) ? 2 : WorldConfig.Current.PassOffset];
Bp.FloorGeom.DrawFloor(device, Effect, world.Zoom, world.Rotation, world.Rooms.RoomMaps, floors, pass, state: world, screenAlignUV: !nonIso);
Bp.FloorGeom.DrawFloor(device, Effect, world.Zoom, world.Rotation, world.Rooms.RoomMaps, floors, pass, state: world, screenAlignUV: !nonIso, withCeilings: true);
Effect.GrassShininess = 0.02f;// (float)0.25);

pass.Apply();
Expand Down

0 comments on commit 12bc7bc

Please sign in to comment.