Add option to enable Depth Test on cloth painting debug preview (enabled by default)

This commit is contained in:
Wojtek Figat
2024-02-14 12:36:04 +01:00
parent 31437e6dde
commit 3958a4740f
3 changed files with 23 additions and 3 deletions

View File

@@ -43,6 +43,19 @@ namespace FlaxEngine.Tools
/// Enables continuous painting, otherwise single paint on click.
/// </summary>
public bool ContinuousPaint;
/// <summary>
/// Enables drawing cloth paint debugging with Depth Test enabled (skips occluded vertices).
/// </summary>
public bool DebugDrawDepthTest
{
get => Gizmo.Cloth?.DebugDrawDepthTest ?? true;
set
{
if (Gizmo.Cloth != null)
Gizmo.Cloth.DebugDrawDepthTest = value;
}
}
#pragma warning restore CS0649
public override void Init(IGizmoOwner owner)
@@ -62,6 +75,7 @@ namespace FlaxEngine.Tools
public override void Dispose()
{
Owner.Gizmos.Remove(Gizmo);
Gizmo = null;
base.Dispose();
}
@@ -83,6 +97,7 @@ namespace FlaxEngine.Tools
private EditClothPaintAction _undoAction;
public bool IsPainting => _isPainting;
public Cloth Cloth => _cloth;
public ClothPaintingGizmo(IGizmoOwner owner, ClothPaintingGizmoMode mode)
: base(owner)

View File

@@ -415,9 +415,9 @@ void Cloth::OnDebugDrawSelected()
c1 = Color::Lerp(Color::Red, Color::White, _paint[i1]);
c2 = Color::Lerp(Color::Red, Color::White, _paint[i2]);
}
DebugDraw::DrawLine(v0, v1, c0, c1, 0, false);
DebugDraw::DrawLine(v1, v2, c1, c2, 0, false);
DebugDraw::DrawLine(v2, v0, c2, c0, 0, false);
DebugDraw::DrawLine(v0, v1, c0, c1, 0, DebugDrawDepthTest);
DebugDraw::DrawLine(v1, v2, c1, c2, 0, DebugDrawDepthTest);
DebugDraw::DrawLine(v2, v0, c2, c0, 0, DebugDrawDepthTest);
}
PhysicsBackend::UnlockClothParticles(_cloth);
}

View File

@@ -332,6 +332,11 @@ public:
bool OnPreUpdate();
void OnPostUpdate();
private:
#if USE_EDITOR
API_FIELD(Internal) bool DebugDrawDepthTest = true;
#endif
public:
// [Actor]
void Draw(RenderContext& renderContext) override;