Merge remote-tracking branch 'origin/master' into 1.10

# Conflicts:
#	Source/Engine/Graphics/Materials/MaterialShader.h
This commit is contained in:
Wojtek Figat
2025-02-18 09:19:59 +01:00
133 changed files with 2253 additions and 654 deletions

View File

@@ -750,6 +750,11 @@ void DebugDraw::SetContext(void* context)
#endif
Vector3 DebugDraw::GetViewPos()
{
return Context->LastViewPos;
}
void DebugDraw::Draw(RenderContext& renderContext, GPUTextureView* target, GPUTextureView* depthBuffer, bool enableDepthTest)
{
PROFILE_GPU_CPU("Debug Draw");
@@ -2073,16 +2078,23 @@ void DebugDraw::DrawWireArc(const Vector3& position, const Quaternion& orientati
prevPos = Float3(Math::Cos(TWO_PI - angleStep) * radius, Math::Sin(TWO_PI - angleStep) * radius, 0);
Float3::Transform(prevPos, world, prevPos);
}
const Color32 color32(color);
auto& debugDrawData = depthTest ? Context->DebugDrawDepthTest : Context->DebugDrawDefault;
#define ADD_LINE(a, b) if (duration > 0) debugDrawData.DefaultLines.Add({ a, b, color32, duration }); else { debugDrawData.OneFrameLines.Add({ a, color32 }); debugDrawData.OneFrameLines.Add({ b, color32 }); }
for (int32 i = 0; i <= resolution; i++)
{
Float3 pos(Math::Cos(currentAngle) * radius, Math::Sin(currentAngle) * radius, 0);
Float3::Transform(pos, world, pos);
DrawLine(prevPos, pos, color, duration, depthTest);
ADD_LINE(prevPos, pos);
currentAngle += angleStep;
prevPos = pos;
}
if (angle < TWO_PI)
DrawLine(prevPos, world.GetTranslation(), color, duration, depthTest);
{
Float3 pos(world.GetTranslation());
ADD_LINE(prevPos, pos);
}
#undef ADD_LINE
}
void DebugDraw::DrawWireArrow(const Vector3& position, const Quaternion& orientation, float scale, float capScale, const Color& color, float duration, bool depthTest)

View File

@@ -42,7 +42,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
#if USE_EDITOR
/// <summary>
/// Allocates the context for Debug Drawing. Can be use to redirect debug shapes collecting to a separate container (instead of global state).
/// Allocates the context for Debug Drawing. Can be used to redirect debug shapes collecting to a separate container (instead of global state).
/// </summary>
/// <returns>The context object. Release it wil FreeContext. Returns null if failed.</returns>
API_FUNCTION() static void* AllocateContext();
@@ -67,6 +67,9 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
API_FUNCTION() static void SetContext(void* context);
#endif
// Gets the last view position when rendering the current context. Can be sued for custom culling or LODing when drawing more complex shapes.
static Vector3 GetViewPos();
/// <summary>
/// Draws the collected debug shapes to the output.
/// </summary>
@@ -720,7 +723,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
API_FUNCTION() static void Clear(void* context = nullptr);
};
#define DEBUG_DRAW_AXIS_FROM_DIRECTION(origin, direction, size, duration, depthTest) DebugDraw::DrawAxisFromDirection(origin, direction, size, duration, depthTest);
#define DEBUG_DRAW_AXIS_FROM_DIRECTION(origin, direction, size, duration, depthTest) DebugDraw::DrawAxisFromDirection(origin, direction, size, duration, depthTest);
#define DEBUG_DRAW_DIRECTION(origin, direction, color, duration, depthTest) DebugDraw::DrawDirection(origin, direction, color, duration, depthTest);
#define DEBUG_DRAW_RAY(origin, direction, color, length, duration, depthTest) DebugDraw::DrawRay(origin, direction, color, length, duration, depthTest);
#define DEBUG_DRAW_RAY(ray, color, length, duration, depthTest) DebugDraw::DrawRay(ray, color, length, duration, depthTest);