Skip to content

Commit

Permalink
Fix parallax floors
Browse files Browse the repository at this point in the history
  • Loading branch information
riperiperi committed Mar 31, 2024
1 parent 5d90d0c commit 6d7bfe2
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions TSOClient/tso.world/Components/3DFloorGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public ushort PatternConvert(ushort pattern, ushort index, sbyte level, bool bui
}
else return 0;
}
else if (pattern < 65534 || pattern == 65535) return pattern;
else if (pattern < 65534 || (pattern == 65535 && !af2019)) return pattern;
else
{
//pool tile... check adjacent tiles
Expand Down Expand Up @@ -251,6 +251,29 @@ public int SetGrassIndices(GraphicsDevice gd, Effect e, WorldState state)

private bool Alt;

private Vector4 GetParallaxMatrix(WorldState state)
{
Vector4 mat;

switch (state.Rotation)
{
case WorldRotation.TopLeft:
mat = new Vector4(0.7071f, -0.7071f, 0.7071f, 0.7071f);
break;
case WorldRotation.TopRight:
mat = new Vector4(0.7071f, 0.7071f, -0.7071f, 0.7071f);
break;
case WorldRotation.BottomRight:
mat = new Vector4(-0.7071f, 0.7071f, -0.7071f, -0.7071f);
break;
default:
mat = new Vector4(-0.7071f, -0.7071f, 0.7071f, -0.7071f);
break;
}

return mat;
}

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)
{
Expand Down Expand Up @@ -450,7 +473,7 @@ public void DrawFloor(GraphicsDevice gd, GrassEffect e, WorldZoom zoom, WorldRot
{
var parallaxPass = e.CurrentTechnique.Passes[4];
e.ParallaxTex = pSPR;
e.ParallaxUVTexMat = new Vector4(0.7071f, -0.7071f, 0.7071f, 0.7071f);
e.ParallaxUVTexMat = GetParallaxMatrix(state);
e.ParallaxHeight = 0.1f;
parallaxPass.Apply();
}
Expand Down Expand Up @@ -573,7 +596,7 @@ public FloorTileGroup AddGroup(ushort tileID)
{
FloorTileGroup group;

if (tileID == 65535)
if (!_3DFloorGeometry.af2019 && tileID == 65535)
{
//pool tile group
group = new Modelled3DPool(Bp);
Expand Down

0 comments on commit 6d7bfe2

Please sign in to comment.