Skip to content

Commit

Permalink
LostArtefacts#241 TR3 Mirroring FD
Browse files Browse the repository at this point in the history
FDControl updates for mirroring:
- Renamed FDFunctions.FloorTriangulationNESW_SW to FDFunctions.FloorTriangulationNESW_SE as this appears to be a typo in TRosettaStone (SE indicates right-angle of triangle portal).
- Added ability to set Function, H1 and H2 values in FDSetup.
- Added ability to set corner values of FDTriangulationData.
  • Loading branch information
lahm86 committed Dec 19, 2021
1 parent 90e2838 commit 8aa1fa5
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public override void ApplyToLevel(TR3Level level)
case FDFunctions.CeilingTriangulationNE_Solid:
case FDFunctions.FloorTriangulationNWSE_SW:
case FDFunctions.FloorTriangulationNWSE_NE:
case FDFunctions.FloorTriangulationNESW_SW:
case FDFunctions.FloorTriangulationNESW_SE:
case FDFunctions.FloorTriangulationNESW_NW:
case FDFunctions.CeilingTriangulationNW_SW:
case FDFunctions.CeilingTriangulationNW_NE:
Expand Down
2 changes: 1 addition & 1 deletion TRFDControl/FDControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private void ParseFromSector(TRRoomSector sector, ushort[] FloorData, uint NumFl
case FDFunctions.CeilingTriangulationNE_Solid:
case FDFunctions.FloorTriangulationNWSE_SW:
case FDFunctions.FloorTriangulationNWSE_NE:
case FDFunctions.FloorTriangulationNESW_SW:
case FDFunctions.FloorTriangulationNESW_SE:
case FDFunctions.FloorTriangulationNESW_NW:
case FDFunctions.CeilingTriangulationNW_SW:
case FDFunctions.CeilingTriangulationNW_NE:
Expand Down
4 changes: 2 additions & 2 deletions TRFDControl/FDEntryTypes/TR3TriangulationEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public bool IsFloorTriangulation
FDFunctions function = (FDFunctions)Setup.Function;
return function == FDFunctions.FloorTriangulationNESW_NW
|| function == FDFunctions.FloorTriangulationNESW_Solid
|| function == FDFunctions.FloorTriangulationNESW_SW
|| function == FDFunctions.FloorTriangulationNESW_SE
|| function == FDFunctions.FloorTriangulationNWSE_NE
|| function == FDFunctions.FloorTriangulationNWSE_Solid
|| function == FDFunctions.FloorTriangulationNWSE_SW;
Expand All @@ -30,7 +30,7 @@ public bool IsFloorPortal
{
FDFunctions function = (FDFunctions)Setup.Function;
return function == FDFunctions.FloorTriangulationNESW_NW
|| function == FDFunctions.FloorTriangulationNESW_SW
|| function == FDFunctions.FloorTriangulationNESW_SE
|| function == FDFunctions.FloorTriangulationNWSE_NE
|| function == FDFunctions.FloorTriangulationNWSE_SW;
}
Expand Down
2 changes: 1 addition & 1 deletion TRFDControl/FDFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public enum FDFunctions
CeilingTriangulationNE_Solid = 0x0A,
FloorTriangulationNWSE_SW = 0x0B,
FloorTriangulationNWSE_NE = 0x0C,
FloorTriangulationNESW_SW = 0x0D,
FloorTriangulationNESW_SE = 0x0D, // TRosetta names this _SW but should be SE
FloorTriangulationNESW_NW = 0x0E,
CeilingTriangulationNW_SW = 0x0F,
CeilingTriangulationNW_NE = 0x10,
Expand Down
19 changes: 17 additions & 2 deletions TRFDControl/FDSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public byte Function
{
return (byte)(Value & 0x001F);
}
set
{
Value = (ushort)(Value & ~(Value & 0x001F));
Value |= value;
}
}

public byte ExtendedFunction
Expand Down Expand Up @@ -78,15 +83,25 @@ public sbyte H1
{
get
{
return (sbyte)(Value & 0x03E0);
return (sbyte)((Value & 0x03E0) >> 5);
}
set
{
Value = (ushort)(Value & ~(Value & 0x03E0));
Value |= (ushort)(value << 5);
}
}

public sbyte H2
{
get
{
return (sbyte)(Value & 0x7C00);
return (sbyte)((Value & 0x7C00) >> 10);
}
set
{
Value = (ushort)(Value & ~(Value & 0x7C00));
Value |= (ushort)(value << 10);
}
}
#endregion
Expand Down
20 changes: 20 additions & 0 deletions TRFDControl/FDTriangulationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public byte C10
{
return (byte)(Value & 0x000F);
}
set
{
Value = (ushort)(Value & ~(Value & 0x000F));
Value |= value;
}
}

public byte C00
Expand All @@ -24,6 +29,11 @@ public byte C00
{
return (byte)((Value & 0x00F0) >> 4);
}
set
{
Value = (ushort)(Value & ~(Value & 0x00F0));
Value |= (ushort)(value << 4);
}
}

public byte C01
Expand All @@ -32,6 +42,11 @@ public byte C01
{
return (byte)((Value & 0x0F00) >> 8);
}
set
{
Value = (ushort)(Value & ~(Value & 0x0F00));
Value |= (ushort)(value << 8);
}
}

public byte C11
Expand All @@ -40,6 +55,11 @@ public byte C11
{
return (byte)((Value & 0xF000) >> 12);
}
set
{
Value = (ushort)(Value & ~(Value & 0xF000));
Value |= (ushort)(value << 12);
}
}
}
}
2 changes: 1 addition & 1 deletion TRFDControl/Utilities/FDUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private static int CheckFloorTriangle(FDControl floorData, TRRoomSector sector,
{
return -1;
}
else if (func == FDFunctions.FloorTriangulationNESW_SW && dx <= dz)
else if (func == FDFunctions.FloorTriangulationNESW_SE && dx <= dz)
{
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions TRRandomizerCore/Utilities/LocationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private bool IsTriggerInvalid(FDTriggerEntry trigger)
break;

case FDFunctions.FloorTriangulationNESW_Solid:
case FDFunctions.FloorTriangulationNESW_SW:
case FDFunctions.FloorTriangulationNESW_SE:
case FDFunctions.FloorTriangulationNESW_NW:
triangle1 = new List<Vector3>
{
Expand Down Expand Up @@ -571,7 +571,7 @@ private bool IsTriggerInvalid(FDTriggerEntry trigger)
zOffset = zoff1;
bestMatch = new Vector4(triSum1.X, triSum1.Y, triSum1.Z, angle);
}
else if (func != FDFunctions.FloorTriangulationNESW_SW)
else if (func != FDFunctions.FloorTriangulationNESW_SE)
{
xOffset = xoff2;
zOffset = zoff2;
Expand Down

0 comments on commit 8aa1fa5

Please sign in to comment.