Add conditional showing of Clear Debug Draw buttons only if there is anything to clear

#2989
This commit is contained in:
Wojtek Figat
2025-03-03 09:51:05 +01:00
parent 6ad20b222d
commit 47b22b305d
4 changed files with 28 additions and 10 deletions

View File

@@ -347,6 +347,11 @@ struct DebugDrawContext
DebugDrawData DebugDrawDepthTest;
Float3 LastViewPos = Float3::Zero;
Matrix LastViewProj = Matrix::Identity;
inline int32 Count() const
{
return DebugDrawDefault.Count() + DebugDrawDepthTest.Count();
}
};
namespace
@@ -739,6 +744,13 @@ void DebugDraw::SetContext(void* context)
Context = context ? (DebugDrawContext*)context : &GlobalContext;
}
bool DebugDraw::CanClear(void* context)
{
if (!context)
context = &GlobalContext;
return ((DebugDrawContext*)context)->Count() != 0;
}
#endif
Vector3 DebugDraw::GetViewPos()

View File

@@ -62,6 +62,13 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
/// </summary>
/// <param name="context">The context or null.</param>
API_FUNCTION() static void SetContext(void* context);
/// <summary>
/// Checks if can clear all debug shapes displayed on screen. Can be used to disable this functionality when not needed for the user.
/// </summary>
/// <param name="context">The context.</param>
/// <returns>True fi context can be cleared (has any shapes), otherwise false.</returns>
API_FUNCTION() static bool CanClear(void* context = nullptr);
#endif
// Gets the last view position when rendering the current context. Can be sued for custom culling or LODing when drawing more complex shapes.