Skip to content

Commit

Permalink
Made Z testing a toggleable option.
Browse files Browse the repository at this point in the history
  • Loading branch information
WhistleWiz committed Sep 14, 2023
1 parent 7c6723a commit 303215e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
29 changes: 16 additions & 13 deletions MapifyEditor/Tools/TrackToolsWindowDrawing/DrawHandles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,25 @@ private void DrawTrackExtraPreviews()
}
}

using (new Handles.DrawingScope(CurrentTrack.Curve.drawColor.Negative()))
if (_zTestTrack)
{
var ztest = Handles.zTest;
Handles.zTest = UnityEngine.Rendering.CompareFunction.Greater;

for (int i = 1; i < CurrentTrack.Curve.pointCount; i++)
using (new Handles.DrawingScope(CurrentTrack.Curve.drawColor.Negative()))
{
EditorHelper.DrawBezier(
CurrentTrack.Curve[i - 1].position,
CurrentTrack.Curve[i - 1].globalHandle2,
CurrentTrack.Curve[i].globalHandle1,
CurrentTrack.Curve[i].position,
_sampleCount);
}
var ztest = Handles.zTest;
Handles.zTest = UnityEngine.Rendering.CompareFunction.Greater;

for (int i = 1; i < CurrentTrack.Curve.pointCount; i++)
{
EditorHelper.DrawBezier(
CurrentTrack.Curve[i - 1].position,
CurrentTrack.Curve[i - 1].globalHandle2,
CurrentTrack.Curve[i].globalHandle1,
CurrentTrack.Curve[i].position,
_sampleCount);
}

Handles.zTest = ztest;
Handles.zTest = ztest;
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion MapifyEditor/Tools/TrackToolsWindowGUI/Other.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public partial class TrackToolsWindow
private bool _showSettings = false;
private bool _drawNewPreview = true;
private bool _performanceMode = false;
private int _updateCounter = 0;
private bool _zTestTrack = true;
private Color _forwardColour = Color.cyan;
private Color _backwardColour = Color.red;
private Color _newColour = Color.green;
private int _sampleCount = 8;

private int _updateCounter = 0;

// Foldout with the 5 prefabs used for track creation.
private void DrawPrefabFoldout()
{
Expand Down Expand Up @@ -98,6 +100,10 @@ private void DrawSettingsFoldout()
new GUIContent("Performance mode", "Reduces redraw frequency"),
_performanceMode);

_zTestTrack = EditorGUILayout.Toggle(
new GUIContent("Perform Z test", "Draw parts of the selected track that are behind objects as a different colour"),
_zTestTrack);

_forwardColour = EditorGUILayout.ColorField(
new GUIContent("Forward preview", "Colour for the forward track previews"),
_forwardColour);
Expand Down

0 comments on commit 303215e

Please sign in to comment.