Optimize Spline debug rendering far from camera
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include "Engine/Core/Math/BoundingFrustum.h"
|
#include "Engine/Core/Math/BoundingFrustum.h"
|
||||||
#include "Engine/Core/Math/Matrix.h"
|
#include "Engine/Core/Math/Matrix.h"
|
||||||
#include "Engine/Scripting/ManagedCLR/MCore.h"
|
#include "Engine/Scripting/ManagedCLR/MCore.h"
|
||||||
|
#include "Engine/Engine/Units.h"
|
||||||
|
|
||||||
Spline::Spline(const SpawnParams& params)
|
Spline::Spline(const SpawnParams& params)
|
||||||
: Actor(params)
|
: Actor(params)
|
||||||
@@ -506,16 +507,33 @@ namespace
|
|||||||
return;
|
return;
|
||||||
Spline::Keyframe* prev = spline->Curve.GetKeyframes().Get();
|
Spline::Keyframe* prev = spline->Curve.GetKeyframes().Get();
|
||||||
Vector3 prevPos = transform.LocalToWorld(prev->Value.Translation);
|
Vector3 prevPos = transform.LocalToWorld(prev->Value.Translation);
|
||||||
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(prevPos, NodeSizeByDistance(prevPos, scaleByDistance)), color, 0.0f, depthTest);
|
float distance = Vector3::Distance(prevPos, DebugDraw::GetViewPos());
|
||||||
for (int32 i = 1; i < count; i++)
|
if (distance < METERS_TO_UNITS(800)) // 800m
|
||||||
{
|
{
|
||||||
Spline::Keyframe* next = prev + 1;
|
// Bezier curve
|
||||||
Vector3 nextPos = transform.LocalToWorld(next->Value.Translation);
|
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(prevPos, NodeSizeByDistance(prevPos, scaleByDistance)), color, 0.0f, depthTest);
|
||||||
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(nextPos, NodeSizeByDistance(nextPos, scaleByDistance)), color, 0.0f, depthTest);
|
for (int32 i = 1; i < count; i++)
|
||||||
const float d = (next->Time - prev->Time) / 3.0f;
|
{
|
||||||
DEBUG_DRAW_BEZIER(prevPos, prevPos + prev->TangentOut.Translation * d, nextPos + next->TangentIn.Translation * d, nextPos, color, 0.0f, depthTest);
|
Spline::Keyframe* next = prev + 1;
|
||||||
prev = next;
|
Vector3 nextPos = transform.LocalToWorld(next->Value.Translation);
|
||||||
prevPos = nextPos;
|
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(nextPos, NodeSizeByDistance(nextPos, scaleByDistance)), color, 0.0f, depthTest);
|
||||||
|
const float d = (next->Time - prev->Time) / 3.0f;
|
||||||
|
DEBUG_DRAW_BEZIER(prevPos, prevPos + prev->TangentOut.Translation * d, nextPos + next->TangentIn.Translation * d, nextPos, color, 0.0f, depthTest);
|
||||||
|
prev = next;
|
||||||
|
prevPos = nextPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Simplified
|
||||||
|
for (int32 i = 1; i < count; i++)
|
||||||
|
{
|
||||||
|
Spline::Keyframe* next = prev + 1;
|
||||||
|
Vector3 nextPos = transform.LocalToWorld(next->Value.Translation);
|
||||||
|
DEBUG_DRAW_LINE(prevPos, nextPos, color, 0.0f, depthTest);
|
||||||
|
prev = next;
|
||||||
|
prevPos = nextPos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user