Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,18 @@ public RenderWallSliceResult RenderWallSlices3D(Side side, Wall wall, bool isFro

var renderThrough = style != RenderDataStyle.Normal;
SectorPlane3D? lastPlane3D = null;
SetWallOffset(m_fakeSide, m_fakeWall, offsetY, GetStartAnchorZ(side, wall, otherSector, wallHeights3D), anchorZ, prevAnchorZ);

double addOffsetZ = 0;
double prevAddOffsetZ = 0;
// If this 3D sector is above the first plane then add the offset since it's not traversed. This happens when an upper is covering a 3D sector.
if (wallHeights3D != null && traversePlanes3D.Length > 0 && (wallHeights3D.Value.TopZ > traversePlanes3D[0].Plane.Z || wallHeights3D.Value.PrevTopZ > traversePlanes3D[0].Plane.PrevZ))
{
addOffsetZ = wallHeights3D.Value.TopZ - traversePlanes3D[0].Plane.Z;
prevAddOffsetZ = wallHeights3D.Value.PrevTopZ - traversePlanes3D[0].Plane.PrevZ;
}

SetWallOffset(m_fakeSide, m_fakeWall, offsetY, GetStartAnchorZ(side, wall, otherSector, wallHeights3D), anchorZ, prevAnchorZ, addOffsetZ, prevAddOffsetZ);

for (int i = 0; i < traversePlanes3D.Length - 1; i++)
{
ref var plane3D = ref traversePlanes3D[i];
Expand Down Expand Up @@ -384,11 +394,11 @@ private static SectorPlane CalculateAnchorPlane(Side side, Wall wall, Sector oth
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void SetWallOffset(Side side, Wall wall, float saveOffsetY, SectorPlane top, double anchorZ, double prevAnchorZ)
private static void SetWallOffset(Side side, Wall wall, float saveOffsetY, SectorPlane top, double anchorZ, double prevAnchorZ, double addOffsetZ = 0, double prevAddOffsetZ = 0)
{
// Use scrolling data for offset since normal wall offsets can't interpolate
side.ScrollData!.Offset(wall.Location, ScrollOffsetType.Current).Y = saveOffsetY + (float)(anchorZ - top.Z);
side.ScrollData!.Offset(wall.Location, ScrollOffsetType.Previous).Y = saveOffsetY + (float)(prevAnchorZ - top.PrevZ);
side.ScrollData!.Offset(wall.Location, ScrollOffsetType.Current).Y = saveOffsetY + (float)(anchorZ - top.Z + addOffsetZ);
side.ScrollData!.Offset(wall.Location, ScrollOffsetType.Previous).Y = saveOffsetY + (float)(prevAnchorZ - top.PrevZ + prevAddOffsetZ);
}

private static void AddVertices(DynamicArray<DynamicVertex> vertices, Span<DynamicVertex> add)
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ link:/ACS.md[ACS Support]

## Contact Us

If you want to talk about the game, follow development, or get involved, we have https://discord.gg/sb8P7Nuby8[a Discord server] as well as https://www.doomworld.com/forum/topic/132153-helion-c-0940-824-goodbye-bsp-tree-rendering/[a thread on the Doomworld forums].
If you want to talk about the game, follow development, or get involved, we have https://discord.gg/uCpmHdqnRc[a Discord server] as well as https://www.doomworld.com/forum/topic/132153-helion-c-0940-824-goodbye-bsp-tree-rendering/[a thread on the Doomworld forums].

If you encounter issues using Helion and would like to report a bug, you can do so either https://github.com/Helion-Engine/Helion/issues[here on GitHub Issues] or in the Doomworld thread above.
Binary file modified Tests/Resources/sector3d-map.zip
Binary file not shown.
19 changes: 19 additions & 0 deletions Tests/Unit/GameAction/3DSector/Sector3D_Walls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,25 @@ public void RenderLowerSliceWithNonSolidSector3D()
result.Vertices.Length.Should().Be(12);
}

[Fact(DisplayName = "Render correct offset when 3D sector line is covered by upper texture")]
public void RenderSectorLine3DWithUpper()
{
var sector = GameActions.GetSector(World, 240);
sector.Sectors3D.Length.Should().Be(1);
var sector3D = sector.Sectors3D[0];

SetSlices(new WallSlice(128, 80, 192, (0, 32)), new WallSlice(80, 64, 192, (0, 80)), new WallSlice(64, 32, 192, (0, 96)));

var line = GameActions.GetLine(World, 889);
GeometryRenderer.SetTestRenderSectorSliceFunc3D(RenderSlice3D);
var lineIndex = sector.Lines.IndexOf(line);
lineIndex.Should().NotBe(-1);
GeometryRenderer.SetSectorForLineRendering3D(sector3D);
GeometryRenderer.RenderSectorLine3D(sector3D, lineIndex, true, true, EmptyRenderSectorWallVertices3D);
GeometryRenderer.RestoreSectorSliceFunc3D();
AssertSlices();
}

[Fact(DisplayName = "Render one-sided middle sector line sliced by single 3D sector with lower unpeg")]
public void RenderOneSidedMiddleSliceLowerUnpeg()
{
Expand Down
Loading